两个 Gadget 小程序
2009-07-20 13:19 闫妍 阅读(169) 评论(0) 编辑 收藏 举报这三天,做了两个小gadget。
待办的代码:
Gadget.htm
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>我的待办</title>
<script src="jquery.js" type="text/javascript"></script>
<style>
body{margin:0px; font-family:"微软雅黑", "宋体"; font-size:12px; color:#FFFFFF}
table,td{font-size:12px}
A:link{
font-size:12px;
color:#ffffff;
text-decoration:none;
font-family:"微软雅黑", "宋体";
letter-spacing:5px;
}
A:visited{
font-size:12px;
color:#ffffff;
text-decoration:none;
font-family:"微软雅黑", "宋体";
letter-spacing:5px;
}
A:hover{
font-size:12px;
color:#ffffff;
text-decoration:none;
font-family:"微软雅黑", "宋体";
letter-spacing:5px;
}
</style>
<script type="text/javascript">
var openUrl;
var hostIP = "http://localhost:9999";
//http://10.204.32.116/ActiveChart/Chart/GadgetService.asmx
//var hostIP = "http://10.204.32.116/ActiveChart";
function updateChart() {
var OAName = System.Gadget.Settings.readString("OAName");
System.Debug.outputString(OAName); //DEBUG CODE
var OAPass = System.Gadget.Settings.readString("OAPass");
System.Debug.outputString(OAPass); //DEBUG CODE
var HostName = System.Gadget.Settings.readString("HostName");
System.Debug.outputString(HostName); //DEBUG CODE
if (OAName != "") {
var ipTest = hostIP + "/Chart/GadgetService.asmx/GetAllWorkSigns";
System.Debug.outputString(ipTest); //DEBUG CODE
var str = "";
var count = 0;
$.ajax({
type: "POST", //访问WebService使用Post方式请求
contentType: "application/json", //WebService 会返回Json类型
url: hostIP + "/Chart/GadgetService.asmx/GetAllWorkSigns", //调用WebService的地址和方法名称组合 ---- WsURL/方法名
data: "{hostName:'" + "jiangguoqiang" + "',oaName:'" + OAName + "',oaPass:'" + OAPass + "'}", //这里是要传递的参数,格式为 data: "{paraName:paraValue}",下面将会看到
dataType: 'json',
success: function(result) { //回调函数,result,返回值
$(result.d).each(function() {
if (count % 4 == 0) {
str += "<tr >";
}
System.Debug.outputString("记录信息:" + this['SignName'] + System.Gadget.Settings.readString(this['SignName']));
if (System.Gadget.Settings.readString(this['SignName']) == "True") {
str += "<td width=\"25%\" height=\"38\" align=\"center\"><div onmousedown=\"javascript:windowOpen('" + this['SignUrl'] + "');\"><img alt='" + this['SignName'] + "' src=\"images/" + this['SignName'] + ".png\" width=\"32\" height=\"32\"><br /><span height=\"15\" align=\"center\">(" + this['SignCount'] + ")</span></td>"
//System.Debug.outputString(str);
count = count + 1;
}
if (count == 4 || count == 8 || count == 12) {
str += "</tr>";
}
});
System.Debug.outputString("添加表格内容:" + str);
$("#tb1").html(str);
}
});
}
else {
$("#tb1").html("<tr><td>请点击设置功能键登陆!</td></tr>");
System.Debug.outputString("未设置"); //DEBUG CODE
}
timerID = setTimeout(updateChart, 10000);
}
function Initialize() {
System.Gadget.settingsUI = "options.html";
}
function windowOpen(url) {
window.open(url, "NewWin", "height=524,width=1100,top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,fullscreen=yes");
}
</script>
</head>
<body onload="Initialize();updateChart();" style=" margin:0; width: 228px; height: 240px; background-repeat:no-repeat;background:url(bgbk5.png);"><div style="width:228px">
<table width="228" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="images/head_db.png" width="228" height="25"></td>
</tr>
<tr>
<td height="150" valign="top" background="images/body_bk.png">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="180" background="images/body1.png" style="background-repeat:no-repeat" valign=top>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="18"></td>
</tr>
</table>
<table id="tb1" width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<!--
<tr id="tr1">
<td width="25%" height="38" align="center"><div onmousedown="javascript:windowOpen('');"><img src="images/HD.png" width="32" height="32"><br /><span height="15" align="center">申请(1)</span></div></td>
<td width="25%" align="center"><img src="images/ie7_ico2.png" width="32" height="32"><br /><span height="15" align="center">硬盘(2)</span></td>
<td width="25%" align="center"><img src="images/System.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
<td width="25%" align="center"><img src="images/System.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
</tr>
<tr id="tr2">
<td width="25%" height="38" align="center"><img src="images/HD.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
<td width="25%" align="center"><img src="images/ie7_ico2.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
<td width="25%" align="center"><img src="images/System.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
<td width="25%" align="center"><img src="images/System.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
</tr>
<tr id="tr3">
<td width="25%" height="38" align="center"><img src="images/HD.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
<td width="25%" align="center"><img src="images/ie7_ico2.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
<td width="25%" align="center"><img src="images/System.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
<td width="25%" align="center"><img src="images/System.png" width="32" height="32"><br /><span height="15" align="center">硬盘</span></td>
</tr>
-->
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top"><div align="justify"><img src="images/bottom.png" width="228" height="13"></div></td>
</tr>
</table>
</div>
</body>
</html>
Setting.htm
<html>
<head>
<title>Options</title>
<script src="jquery.js" type="text/javascript"></script>
<script>
function LoadSettings() {
try {
System.Gadget.onSettingsClosing = onclose;
} catch (e) { };
txtOAName.value = System.Gadget.Settings.readString("OAName");
txtOAPass.value = System.Gadget.Settings.readString("OAPass");
System.Gadget.Settings.write("申告", false);
System.Gadget.Settings.write("待办项", false);
System.Gadget.Settings.write("故障", false);
System.Gadget.Settings.write("作业工单", false);
System.Gadget.Settings.write("问题", false);
System.Gadget.Settings.write("变更", false);
System.Gadget.Settings.write("OA待办", false);
System.Gadget.Settings.write("OA公文", false);
}
function onclose(event) {
if (event.closeAction == event.Action.commit) {
System.Gadget.Settings.write("OAName", txtOAName.value);
System.Gadget.Settings.write("OAPass", txtOAPass.value);
var environmentVariableValue = System.Environment.getEnvironmentVariable("UserName");
System.Gadget.Settings.write("HostName", environmentVariableValue);
if ($("#ckbSG").attr('checked') == true) {
System.Gadget.Settings.write("申告", true);
}
if ($("#ckbSG").attr('checked') == true) {
System.Gadget.Settings.write("待办项", true);
}
if ($("#ckbGZ").attr('checked') == true) {
System.Gadget.Settings.write("故障", true);
}
if ($("#ckbZYGD").attr('checked') == true) {
System.Gadget.Settings.write("作业工单", true);
}
if ($("#ckbWT").attr('checked') == true) {
System.Gadget.Settings.write("问题", true);
}
if ($("#ckbBG").attr('checked') == true) {
System.Gadget.Settings.write("变更", true);
}
if ($("#ckbOADB").attr('checked') == true) {
System.Gadget.Settings.write("OA待办", true);
}
if ($("#ckbOAGW").attr('checked') == true) {
System.Gadget.Settings.write("OA公文", true);
}
}
System.Debug.outputString(txtOAPass.value);
event.cancel = false;
}
</script>
<style type="text/css">
body
{
margin: 0px;
font-family: Segoe UI, Tahoma, sans-serif;
font-size: 12px;
width: 260px;
height: 120px;
}
table
{
font-size: 12px;
font-family: Segoe UI, Tahoma, sans-serif;
}
</style>
</head>
<body onload="LoadSettings();">
<table border="0" width="260" cellpadding="0" cellspacing="5">
<tr>
<td valign="middle">
用户名:
</td>
<td align="left">
<input type="text" id="txtOAName" style='width: 120px;' />
</td>
</tr>
<tr>
<td valign="middle">
密码:
</td>
<td align="left">
<input type="password" id="txtOAPass" style='width: 120px;' />
</td>
</tr>
<tr>
<td valign="middle" colspan="2">
申告<input id="ckbSG" type="checkbox" checked="checked" />
待办项<input id="ckbDBX" type="checkbox" checked="checked" />
故障<input id="ckbGZ" type="checkbox" checked="checked" />
作业工单<input id="ckbZYGD" type="checkbox" checked="checked" />
</td>
</tr>
<tr>
<td valign="middle" colspan="2">
问题<input id="ckbWT" type="checkbox" checked="checked" />
变更<input id="ckbBG" type="checkbox" checked="checked" />
OA待办<input id="ckbOADB" type="checkbox" checked="checked" />
OA公文<input id="ckbOAGW" type="checkbox" checked="checked" />
</td>
</tr>
</table>
</body>
</html>