with gmail widget..

This commit is contained in:
Harry Bomrah committed 2012-04-26 14:47:49 +08:00
1 parent a298cbd5f6
commit 64be61d61b
6 files changed
+102 -2

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
var gmail = function(){
var usernm = $("#gmail input[type=text]").val();
var pwd = $("#gmail input[type=password]").val();
// usernm = "hr@rulingcom.com";
// pwd = "hr08973"
if(usernm!="" && pwd!=""){
$("#gmail a#gmail_button").text("Check again");
$("#gmail #loading").show();
$("#gmail table#form").hide();
$.ajax({
url: "/desktop/forgmail",
dataType : "xml",
data : {username:usernm,password:pwd},
success:function(data){
if($(data).find("HEAD").find("TITLE").text()=="Unauthorized"){
$("#gmail #forerror").text($(data).find("HEAD").find("TITLE").text()).show();
$("#gmail table#form").show();
}else{
if($(data).find("fullcount").text()=="0"){
$("#gmail #forerror").hide();
$("#gmail #content #msgbody").text("No new mails");
}else{
var msg;
if($(data).find("fullcount").text()=="1")
msg = $(data).find("fullcount").text()+" new message in your inbox."
else
msg = $(data).find("fullcount").text()+" new messages in your inbox."
o.notify(msg,"alert",2);
$(data).find("entry").each(function(i,val){
if(i==0){
$("#gmail #forerror").hide();
var atag = $("<a href='"+$(this).find("link").attr("href")+"'>"+$(this).find("title").text()+"</a>");
$("#gmail #content #subject").html($(this).find("title").text());
$("#gmail #content #date").text($(this).find("issued").text());
$("#gmail #content #msgbody").text($(this).find("summary").text());
}
})
}
}
$("#gmail #loading").hide();
$("#gmail #content").show();
}
});
}
}
@@ -0,0 +1,25 @@
<div id="gmail">
<div id="forerror" style="color:red;display:none;"></div>
<table id="form">
<tr>
<td><label class="thmtxt" style="width:75px;">Username:</label></td><td><input type="text" style="width:150px;" /></td>
</tr>
<tr>
<td><label class="thmtxt" style="width:75px;">Password:</label></td><td><input type="password" style="width:150px;" /></td>
</tr>
<tr>
<td colspan="2" align='center'><a href="" onclick="gmail();return false;" class='thmtxt' id="gmail_button">Check for new mail</button></td>
</tr>
</table>
<div id="loading" style="display:none" class="thmtxt">Retrieving new emails...</div>
<div id="content" style="display:none;"background-color:#000;height:200px;"" >
<div id="subject" ></div>
<div id="date" class='thmtxt'></div>
<div id="msgbody" class='thmtxt'></div>
</div>
</div>
<script>
$(document).ready(function(){
// gmail();
})
</script>