wow, so web
BIN
chipet/ndupdate/.DS_Store
vendored
Normal file
BIN
chipet/ndupdate/Images/.DS_Store
vendored
Normal file
BIN
chipet/ndupdate/Images/download.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
chipet/ndupdate/Images/gloss-fill.png
Normal file
After Width: | Height: | Size: 149 B |
BIN
chipet/ndupdate/Images/gloss-left.png
Normal file
After Width: | Height: | Size: 185 B |
BIN
chipet/ndupdate/Images/gloss-right.png
Normal file
After Width: | Height: | Size: 182 B |
BIN
chipet/ndupdate/Images/later.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
chipet/ndupdate/Images/main-bottomleft.png
Normal file
After Width: | Height: | Size: 166 B |
BIN
chipet/ndupdate/Images/main-bottomright.png
Normal file
After Width: | Height: | Size: 160 B |
BIN
chipet/ndupdate/Images/main-fill.png
Normal file
After Width: | Height: | Size: 133 B |
BIN
chipet/ndupdate/Images/main-topleft.png
Normal file
After Width: | Height: | Size: 169 B |
BIN
chipet/ndupdate/Images/main-topright.png
Normal file
After Width: | Height: | Size: 172 B |
BIN
chipet/ndupdate/Images/nd-logo.png
Normal file
After Width: | Height: | Size: 675 B |
BIN
chipet/ndupdate/Images/shadow-bottom.png
Normal file
After Width: | Height: | Size: 140 B |
BIN
chipet/ndupdate/Images/shadow-bottomleft.png
Normal file
After Width: | Height: | Size: 257 B |
BIN
chipet/ndupdate/Images/shadow-bottomright.png
Normal file
After Width: | Height: | Size: 279 B |
BIN
chipet/ndupdate/Images/shadow-right.png
Normal file
After Width: | Height: | Size: 138 B |
BIN
chipet/ndupdate/Images/shadow-topright.png
Normal file
After Width: | Height: | Size: 274 B |
248
chipet/ndupdate/ndupdate.css
Normal file
@ -0,0 +1,248 @@
|
||||
#NDmain {
|
||||
position:fixed;
|
||||
top:1px;
|
||||
left:1px;
|
||||
right:6px;
|
||||
bottom:6px;
|
||||
z-index:9000;
|
||||
}
|
||||
#NDtitle {
|
||||
position:absolute;
|
||||
width:100%;
|
||||
top:6px;
|
||||
font-family:Arial;
|
||||
font-weight:bold;
|
||||
font-size:14px;
|
||||
color:#D5D5D5;
|
||||
text-align:center;
|
||||
z-index:4;
|
||||
}
|
||||
#NDupdate {
|
||||
position:absolute;
|
||||
width:100%;
|
||||
top:35%;
|
||||
font-family:Arial;
|
||||
font-size:20px;
|
||||
color:#D5D5D5;
|
||||
text-align:center;
|
||||
z-index:5;
|
||||
}
|
||||
#NDbuttons {
|
||||
position:absolute;
|
||||
width:100%;
|
||||
bottom:12%;
|
||||
height:10px;
|
||||
text-align:center;
|
||||
z-index:6;
|
||||
}
|
||||
#NDdownload {
|
||||
position:relative;
|
||||
left:2px;
|
||||
cursor:pointer;
|
||||
}
|
||||
#NDlater {
|
||||
position:relative;
|
||||
right:2px;
|
||||
cursor:pointer;
|
||||
}
|
||||
#NDtop {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
right:0px;
|
||||
height:0px;
|
||||
z-index:2;
|
||||
}
|
||||
#NDtopFill {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:5px;
|
||||
right:5px;
|
||||
height:5px;
|
||||
background:url('Images/main-fill.png') repeat;
|
||||
}
|
||||
#NDtopLeft {
|
||||
position:absolute;
|
||||
left:0px;
|
||||
top:0px;
|
||||
width:5px;
|
||||
height:5px;
|
||||
background:url('Images/main-topleft.png');
|
||||
}
|
||||
#NDtopRight {
|
||||
position:absolute;
|
||||
right:0px;
|
||||
top:0px;
|
||||
width:5px;
|
||||
height:5px;
|
||||
background:url('Images/main-topright.png');
|
||||
}
|
||||
|
||||
#NDmid {
|
||||
position:absolute;
|
||||
top:5px;
|
||||
left:0px;
|
||||
right:0px;
|
||||
bottom:5px;
|
||||
z-index:2;
|
||||
}
|
||||
#NDmidLogo {
|
||||
position:absolute;
|
||||
width:54px;
|
||||
height:36px;
|
||||
background:url('Images/nd-logo.png');
|
||||
}
|
||||
#NDmidTop {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
right:0px;
|
||||
background:url('Images/main-fill.png') repeat;
|
||||
}
|
||||
#NDmidBottom {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:0px;
|
||||
right:0px;
|
||||
background:url('Images/main-fill.png') repeat;
|
||||
}
|
||||
#NDmidLeft {
|
||||
position:absolute;
|
||||
left:0px;
|
||||
height:36px;
|
||||
background:url('Images/main-fill.png') repeat;
|
||||
}
|
||||
#NDmidRight {
|
||||
position:absolute;
|
||||
right:0px;
|
||||
height:36px;
|
||||
background:url('Images/main-fill.png') repeat;
|
||||
}
|
||||
|
||||
#NDbottom {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:0px;
|
||||
right:0px;
|
||||
height:0px;
|
||||
z-index:2;
|
||||
}
|
||||
#NDbottomFill {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:5px;
|
||||
right:5px;
|
||||
height:5px;
|
||||
background:url('Images/main-fill.png') repeat;
|
||||
}
|
||||
#NDbottomLeft {
|
||||
position:absolute;
|
||||
left:0px;
|
||||
bottom:0px;
|
||||
width:5px;
|
||||
height:5px;
|
||||
background:url('Images/main-bottomleft.png');
|
||||
}
|
||||
#NDbottomRight {
|
||||
position:absolute;
|
||||
right:0px;
|
||||
bottom:0px;
|
||||
width:5px;
|
||||
height:5px;
|
||||
background:url('Images/main-bottomright.png');
|
||||
}
|
||||
|
||||
#NDgloss {
|
||||
position:absolute;
|
||||
top:2px;
|
||||
left:2px;
|
||||
right:2px;
|
||||
height:12px;
|
||||
z-index:3;
|
||||
}
|
||||
#NDglossFill {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:4px;
|
||||
right:4px;
|
||||
height:12px;
|
||||
background:url('Images/gloss-fill.png') repeat;
|
||||
}
|
||||
#NDglossLeft {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
left:0px;
|
||||
width:4px;
|
||||
height:12px;
|
||||
background:url('Images/gloss-left.png');
|
||||
}
|
||||
#NDglossRight {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
right:0px;
|
||||
width:4px;
|
||||
height:12px;
|
||||
background:url('Images/gloss-right.png');
|
||||
z-index:2;
|
||||
}
|
||||
|
||||
#NDshadow {
|
||||
position:absolute;
|
||||
top:-1px;
|
||||
bottom:-6px;
|
||||
right:-6px;
|
||||
left:0px;
|
||||
z-index:1;
|
||||
}
|
||||
#NDshadowBottom {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:0px;
|
||||
right:0px;
|
||||
}
|
||||
#NDshadowBottomLeft {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:0px;
|
||||
width:39px;
|
||||
height:9px;
|
||||
background:url('Images/shadow-bottomleft.png');
|
||||
}
|
||||
#NDshadowBottomFill {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
left:39px;
|
||||
right:11px;
|
||||
height:6px;
|
||||
background:url('Images/shadow-bottom.png') repeat;
|
||||
}
|
||||
#NDshadowBottomRight {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
right:0px;
|
||||
width:11px;
|
||||
height:11px;
|
||||
background:url('Images/shadow-bottomright.png');
|
||||
}
|
||||
#NDshadowRight {
|
||||
position:absolute;
|
||||
bottom:11px;
|
||||
top:0px;
|
||||
right:0px;
|
||||
}
|
||||
#NDshadowRightFill {
|
||||
position:absolute;
|
||||
bottom:0px;
|
||||
right:0px;
|
||||
top:30px;
|
||||
width:6px;
|
||||
background:url('Images/shadow-right.png') repeat;
|
||||
}
|
||||
#NDshadowTopRight {
|
||||
position:absolute;
|
||||
top:0px;
|
||||
right:0px;
|
||||
width:11px;
|
||||
height:30px;
|
||||
background:url('Images/shadow-topright.png');
|
||||
}
|
228
chipet/ndupdate/ndupdate.js
Normal file
@ -0,0 +1,228 @@
|
||||
var widgetName = NDgetKeyValue("Info.plist", "CFBundleName");
|
||||
var location = 'http://novisdesign.net/WidgetResorces/Updates/ChiPet.txt';
|
||||
var current = NDgetKeyValue("Info.plist", "CFBundleVersion");
|
||||
var downloadPage = 'http://www.novisdesign.net/Widgets?chipet';
|
||||
var checkDays = 5;
|
||||
var newestVersion;
|
||||
|
||||
function NDupdate() {
|
||||
if (window.widget) {
|
||||
var lastDate = widget.preferenceForKey('lastDate');
|
||||
if (lastDate != undefined) {
|
||||
NDcheckAmount();
|
||||
}
|
||||
else {
|
||||
NDsetTimeForNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var NDreq;
|
||||
function NDcheck() {
|
||||
NDreq = new XMLHttpRequest();
|
||||
NDreq.onreadystatechange = NDcompare;
|
||||
NDreq.open("GET", location, true);
|
||||
NDreq.setRequestHeader("Cache-Control", "no-cache");
|
||||
NDreq.send(null);
|
||||
}
|
||||
function NDcompare() {
|
||||
if (NDreq.readyState == 4) {
|
||||
if (NDreq.status == 200) {
|
||||
var newNumber = NDreq.responseText;
|
||||
if (newNumber > current) {
|
||||
newestVersion = newNumber;
|
||||
NDshow()
|
||||
}
|
||||
else {
|
||||
NDaddTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var w = window.innerWidth;
|
||||
var h = window.innerHeight;
|
||||
var leftPx = Math.round(((w - 20) - 54) / 2)
|
||||
var topPx = Math.round(((h - 30) - 36) / 2)
|
||||
|
||||
function NDshow() {
|
||||
if (!document.getElementById('NDmain')) {
|
||||
var newElm = document.createElement('div');
|
||||
newElm.id = 'NDmain';
|
||||
|
||||
var title = document.createElement('div');
|
||||
title.id = 'NDtitle';
|
||||
title.innerHTML = 'Update Avaliable';
|
||||
|
||||
var update = document.createElement('div');
|
||||
update.id = 'NDupdate';
|
||||
update.innerHTML = widgetName + ' version ' + newestVersion + '<br/> <b>now available</b>';
|
||||
|
||||
var buttons = document.createElement('div');
|
||||
buttons.id = 'NDbuttons';
|
||||
var bElm = document.createElement('div');
|
||||
bElm.id = 'NDbElm';
|
||||
bElm.innerHTML = '<img src="ndupdate/Images/download.png" id="NDdownload" onclick="NDgoToDownlaod();NDaddTime();"/> <img src="ndupdate/Images/later.png" id="NDlater" onclick="NDaddTime()"/>';
|
||||
buttons.appendChild(bElm);
|
||||
|
||||
var top = document.createElement('div');
|
||||
top.id = 'NDtop';
|
||||
var topFill = document.createElement('div');
|
||||
topFill.id = 'NDtopFill';
|
||||
var topLeft = document.createElement('div');
|
||||
topLeft.id = 'NDtopLeft';
|
||||
var topRight = document.createElement('div');
|
||||
topRight.id = 'NDtopRight';
|
||||
top.appendChild(topFill);
|
||||
top.appendChild(topLeft);
|
||||
top.appendChild(topRight);
|
||||
|
||||
var mid = document.createElement('div');
|
||||
mid.id = 'NDmid';
|
||||
var midLogo = document.createElement('div');
|
||||
midLogo.id = 'NDmidLogo';
|
||||
midLogo.style.left = leftPx + 'px';
|
||||
midLogo.style.top = topPx + 'px';
|
||||
var midTop = document.createElement('div');
|
||||
midTop.id = 'NDmidTop';
|
||||
midTop.style.height = topPx + 'px';
|
||||
var midBottom = document.createElement('div');
|
||||
midBottom.id = 'NDmidBottom';
|
||||
midBottom.style.top = topPx + 36 + 'px';
|
||||
var midLeft = document.createElement('div');
|
||||
midLeft.id = 'NDmidLeft';
|
||||
midLeft.style.top = topPx + 'px';
|
||||
midLeft.style.width = leftPx + 'px';
|
||||
var midRight = document.createElement('div');
|
||||
midRight.id = 'NDmidRight';
|
||||
midRight.style.top = topPx + 'px';
|
||||
midRight.style.left = leftPx + 54 + 'px';
|
||||
mid.appendChild(midLogo);
|
||||
mid.appendChild(midTop);
|
||||
mid.appendChild(midBottom);
|
||||
mid.appendChild(midLeft);
|
||||
mid.appendChild(midRight);
|
||||
|
||||
var bottom = document.createElement('div');
|
||||
bottom.id = 'NDbottom';
|
||||
var bottomFill = document.createElement('div');
|
||||
bottomFill.id = 'NDbottomFill';
|
||||
var bottomLeft = document.createElement('div');
|
||||
bottomLeft.id = 'NDbottomLeft';
|
||||
var bottomRight = document.createElement('div');
|
||||
bottomRight.id = 'NDbottomRight';
|
||||
bottom.appendChild(bottomFill);
|
||||
bottom.appendChild(bottomLeft);
|
||||
bottom.appendChild(bottomRight);
|
||||
|
||||
var gloss = document.createElement('div');
|
||||
gloss.id = 'NDgloss';
|
||||
var glossFill = document.createElement('div');
|
||||
glossFill.id = 'NDglossFill';
|
||||
var glossLeft = document.createElement('div');
|
||||
glossLeft.id = 'NDglossLeft';
|
||||
var glossRight = document.createElement('div');
|
||||
glossRight.id = 'NDglossRight';
|
||||
gloss.appendChild(glossFill);
|
||||
gloss.appendChild(glossLeft);
|
||||
gloss.appendChild(glossRight);
|
||||
|
||||
var shadow = document.createElement('div');
|
||||
shadow.id = 'NDshadow';
|
||||
var shadowBottom = document.createElement('div');
|
||||
shadowBottom.id = 'NDshadowBottom';
|
||||
var shadowBottomLeft = document.createElement('div');
|
||||
shadowBottomLeft.id = 'NDshadowBottomLeft';
|
||||
var shadowBottomFill = document.createElement('div');
|
||||
shadowBottomFill.id = 'NDshadowBottomFill';
|
||||
var shadowBottomRight = document.createElement('div');
|
||||
shadowBottomRight.id = 'NDshadowBottomRight';
|
||||
shadowBottom.appendChild(shadowBottomLeft)
|
||||
shadowBottom.appendChild(shadowBottomFill)
|
||||
shadowBottom.appendChild(shadowBottomRight)
|
||||
var shadowRight = document.createElement('div');
|
||||
shadowRight.id = 'NDshadowRight';
|
||||
var shadowRightFill = document.createElement('div');
|
||||
shadowRightFill.id = 'NDshadowRightFill';
|
||||
var shadowTopRight = document.createElement('div');
|
||||
shadowTopRight.id = 'NDshadowTopRight';
|
||||
shadowRight.appendChild(shadowRightFill)
|
||||
shadowRight.appendChild(shadowTopRight)
|
||||
shadow.appendChild(shadowBottom)
|
||||
shadow.appendChild(shadowRight)
|
||||
|
||||
newElm.appendChild(title);
|
||||
newElm.appendChild(update);
|
||||
newElm.appendChild(buttons);
|
||||
newElm.appendChild(top);
|
||||
newElm.appendChild(mid);
|
||||
newElm.appendChild(bottom);
|
||||
newElm.appendChild(gloss);
|
||||
newElm.appendChild(shadow);
|
||||
|
||||
document.body.appendChild(newElm)
|
||||
}
|
||||
}
|
||||
|
||||
function NDgoToDownlaod() {
|
||||
if (window.widget) {
|
||||
widget.openURL(downloadPage);
|
||||
}
|
||||
}
|
||||
|
||||
function NDaddTime() {
|
||||
if (window.widget) {
|
||||
var d = new Date();
|
||||
var mil = d.getTime();
|
||||
widget.setPreferenceForKey(mil,'lastDate');
|
||||
}
|
||||
document.body.removeChild(document.getElementById('NDmain'));
|
||||
}
|
||||
|
||||
function NDcheckAmount() {
|
||||
if (window.widget) {
|
||||
var d = new Date();
|
||||
var lastDate = widget.preferenceForKey('lastDate');
|
||||
var nowDate = d.getTime();
|
||||
if ((nowDate - lastDate) > (86400000 * checkDays)) {
|
||||
NDcheck();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function NDsetTimeForNow() {
|
||||
if (window.widget) {
|
||||
var d = new Date();
|
||||
var mil = d.getTime();
|
||||
widget.setPreferenceForKey(mil,'lastDate');
|
||||
}
|
||||
}
|
||||
|
||||
// Adapted from Jon Brown's Tutorial
|
||||
function NDgetKeyValue(plist, key) {
|
||||
var xml_http = new XMLHttpRequest();
|
||||
xml_http.open("GET", plist, false);
|
||||
xml_http.send(null);
|
||||
|
||||
var xml = xml_http.responseXML;
|
||||
var key_value = null;
|
||||
var nodes = xml.getElementsByTagName("dict")[0].childNodes;
|
||||
|
||||
for (var i=0; i < nodes.length; i++) {
|
||||
if (nodes[i].nodeType == 1 && nodes[i].tagName.toLowerCase() == "key" && nodes[i].firstChild.data == key) {
|
||||
if (nodes[i+2].tagName.toLowerCase() != "array") {
|
||||
key_value = nodes[i+2].firstChild.data;
|
||||
}
|
||||
else {
|
||||
key_value = new Array();
|
||||
var ar_nodes = nodes[i+2].childNodes;
|
||||
for (var j=0; j < ar_nodes.length; j++) {
|
||||
if (ar_nodes[j].nodeType == 1)
|
||||
key_value.push(ar_nodes[j].firstChild.data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return key_value;
|
||||
}
|