Thank you.
Okay, i think it's better you can tell me the usage of _IG_Fecth ...
My gadget is simply get some XML and show it to user as event
calendar.
Here my code snippet:
function updateDataXMLEvent (xml) {
if (xml.parseError == 0) { // Kalau ga error
nevent = 0;
// mendapatkan array of event
var eventList = xml.getElementsByTagName("event");
// mulai menelusuri dalem-dalemnya
for (i=0; i<eventList.length; i++) {
var title; var publisher; var publisher_id; var date;
var month;
var year;
var time; var description;
for (j=0; j<eventList[i].childNodes.length; j++) {
if (eventList[i].childNodes[j].nodeType == 1) {
// nodeType untuk
tag adalah 1
if (eventList[i].childNodes[j].nodeName
== "title") {
title =
eventList[i].childNodes[j].firstChild.nodeValue;
} else if
(eventList[i].childNodes[j].nodeName == "publisher") {
publisher =
eventList[i].childNodes[j].firstChild.nodeValue;
} else if
(eventList[i].childNodes[j].nodeName == "publisher_id")
{
publisher_id =
eval(eventList[i].childNodes[j].firstChild.nodeValue);
} else if
(eventList[i].childNodes[j].nodeName == "day") {
date =
eval(eventList[i].childNodes[j].firstChild.nodeValue);
} else if
(eventList[i].childNodes[j].nodeName == "month") {
month =
eval(eventList[i].childNodes[j].firstChild.nodeValue);
} else if
(eventList[i].childNodes[j].nodeName == "year") {
year =
eval(eventList[i].childNodes[j].firstChild.nodeValue);
} else if
(eventList[i].childNodes[j].nodeName == "time") {
time =
eventList[i].childNodes[j].firstChild.nodeValue;
} else if
(eventList[i].childNodes[j].nodeName == "description")
{
description =
eventList[i].childNodes[j].firstChild.nodeValue;
}
}
}
event[++nevent] = (newEvent(title, publisher,
publisher_id, date,
month, year, time, description));
}
return 0;
} else {
debug.error (xml.parseError.reason);
return -1;
}
}
function REFRESHALL () {
nevent = 0;
if (isNetworkOnline()) {
updateData();
refreshKalenderView();
initEventView();
refreshEventView();
teksGagal.innerText = "";
} else {
refreshKalenderView();
initEventView();
refreshEventView();
teksGagal.innerText = "Tidak Terkoneksi";
}
}
function CEKONLINESTATUS() {
if (isNetworkOnline()) {
if (onlineStatus == "notconnected" || teksGagal.innerText !=
"") {
teksGagal.innerText = "";
REFRESHALL();
onlineStatus = "connected";
}
} else {
if (onlineStatus == "connected") {
teksUpdateTerakhir.innerText = "";
teksGagal.innerText = "Tidak Terkoneksi";
REFRESHALL();
onlineStatus = "notconnected";
}
}
}
// return -1 = koneksi gagal
function updateData() {
now = new Date();
teksUpdateTerakhir.innerText = "Update Terakhir: " + now.getHours() +
":" + now.getMinutes();
var connectStatus = "gagal";
teksGagal.innerText = "Pengambilan Data Gagal";
// if (isNetworkOnline()) {
var req = new XMLHttpRequest();
try {
req.open("GET", XMLUrl, true);
} catch (e) {
}
req.onreadystatechange = function() {
debug.trace ("masuk ! " + req.readyState);
if (req.readyState == 4) {
if (req.status == 200) {
if (updateDataXMLEvent (req.responseXML) == 0) {
connectStatus = "sukses";
teksGagal.innerText = "";
debug.trace ("sukses");
}
} else {
teksGagal.innerText = "Pengambilan Data Gagal";
}
} else {
return;
}
}
try {
req.send();
} catch (e) {
connectStatus = "gagal";
teksGagal.innerText = "Pengambilan Data Gagal";
}
}
// Saat pertama di run
function view_onOpen() {
/*****************************************************/
/*
event[1] = newEvent ("Judul 1", "Publisher 1", 1, 1, 5, 2008, "7",
"00", "Cuma test 1");
event[2] = newEvent ("Judul 2", "Publisher 2", 1, 1, 6, 2008, "16",
"00", "Cuma test 2");
event[3] = newEvent ("Judul 3", "Publisher 3", 1, 15, 6, 2008, "16",
"00", "Cuma test 3");
event[4] = newEvent ("Judul 4", "Publisher 4", 1, 30, 6, 2008, "16",
"00", "Cuma test 4");
event[5] = newEvent ("Judul 5", "Publisher 5", 1, 30, 6, 2008, "18",
"00", "Cuma test 5");
event[6] = newEvent ("Judul 6", "Publisher 6", 1, 22, 7, 2008, "18",
"00", "Cuma test 6");
nevent = 6;
*/
nevent = 0;
/*****************************************************/
// Mendapatkan data hari sekarang
today = new Date();
todayBulan = today.getMonth() + 1;
todayTanggal = today.getDate();
todayTahun = today.getFullYear();
todayHari = today.getDay() + 1;
kalenderBulan = todayBulan;
kalenderTahun = todayTahun;
// set Text hari ini
textToday.innerText = getHariName(todayHari) + ", " + todayTanggal +
" " + getBulanName(todayBulan)+ " " + todayTahun;
tanggal[1] = t1; tanggal[2] = t2; tanggal[3] = t3; tanggal[4] = t4;
tanggal[5] = t5;
tanggal[6] = t6; tanggal[7] = t7; tanggal[8] = t8; tanggal[9] = t9;
tanggal[10] = t10;
tanggal[11] = t11; tanggal[12] = t12; tanggal[13] = t13; tanggal[14]
= t14; tanggal[15] = t15;
tanggal[16] = t16; tanggal[17] = t17; tanggal[18] = t18; tanggal[19]
= t19; tanggal[20] = t20;
tanggal[21] = t21; tanggal[22] = t22; tanggal[23] = t23; tanggal[24]
= t24; tanggal[25] = t25;
tanggal[26] = t26; tanggal[27] = t27; tanggal[28] = t28; tanggal[29]
= t29; tanggal[30] = t30;
tanggal[31] = t31; tanggal[32] = t32; tanggal[33] = t33; tanggal[34]
= t34; tanggal[35] = t35;
tanggal[36] = t36; tanggal[37] = t37; tanggal[38] = t38; tanggal[39]
= t39; tanggal[40] = t40;
tanggal[41] = t41; tanggal[42] = t42;
//updateData();
view.setInterval("REFRESHALL();", 3600000);
view.setInterval("CEKONLINESTATUS();", 1000);
REFRESHALL();
}
Thank you.
Regards,
Damas
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"iGoogle Developer Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Gadgets-API?hl=en
-~----------~----~----~----~------~----~------~--~---