Changeset 61 for trunk/Sillaj-widget
- Timestamp:
- 05/16/07 20:33:25 (3 years ago)
- Files:
-
- 1 modified
-
trunk/Sillaj-widget/Sillaj.wdgt/sillaj.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Sillaj-widget/Sillaj.wdgt/sillaj.js
r60 r61 1 1 var flipper; 2 2 3 var conf = {'baseURL':'', 'username':'', 'password':'', 'round':1}; 3 var conf = {'baseURL':'', 'username':'', 'password':'', 'round':1, 4 'php_session_timeout':1440}; // the php_session_timeout var should be same as session.gc_maxlifetime in php.ini. Defaults to 1440 seconds 4 5 5 6 var loggedIn = null; … … 51 52 } 52 53 53 function postEvent(data, cb, recursive)54 {55 login();56 doRequest("POST", "index.php", data, function(c)57 {58 var r=c.responseText;59 if(r.match(/login/))60 {61 // not logged in...62 if(recursive == true)63 {64 // Failed to post event due to login failure...65 document.getElementById('status').innerHTML+="Failed to post event!";66 }67 else68 {69 login(true, function(){70 postEvent(data, cb, true); // try again71 });72 }73 }else74 {75 // assume OK76 if(cb)77 cb();78 }79 }80 );81 }82 83 54 function login(force, cb) 84 55 { 85 if(force == false && (loggedIn != null && (new Date()).getTime()/1000 < loggedIn.getTime()/100 + 3600))56 if(force == false && (loggedIn != null && (new Date()).getTime()/1000 < loggedIn.getTime()/1000 + conf['php_session_timeout'])) 86 57 { 87 58 if(cb) … … 106 77 } 107 78 79 function postEvent(data, cb, recursive) 80 { 81 login(false, function() 82 { 83 doRequest("POST", "index.php", data, function(c) 84 { 85 var r=c.responseText; 86 if(r.match(/login/)) 87 { 88 // not logged in... 89 if(recursive == true) 90 { 91 // Failed to post event due to login failure... 92 document.getElementById('status').innerHTML+="Failed to post event!"; 93 } 94 else 95 { 96 login(true, function(){ 97 postEvent(data, cb, true); // try again 98 }); 99 } 100 }else 101 { 102 // assume OK 103 if(cb) 104 cb(); 105 } 106 } 107 ); 108 } 109 ); 110 } 111 108 112 function updateProjects() 109 113 { … … 191 195 if(n == lastSel) 192 196 newSel = index-1; 197 } 198 199 if(lastSel != null && newSel != 0) 200 { 201 // Get date of lastSel and compare it to current. if more than 6 hours diff, ignore lastSel 202 var dd = sd.options[lastSel].value; 203 var d = Date.parse(d) 204 if(d.getTime() + 3600*6*1000 < (new Date()).getTime()) 205 newSel = 0; // set current date 193 206 } 194 207 sd.selectedIndex = newSel; … … 245 258 246 259 var m = d.getMinutes().toString(); 247 m = Math.round(m / conf.round) * conf.round;260 m = ""+(Math.round(m / conf.round) * conf.round); 248 261 if (m.length == 1) 249 262 m = "0" + m;
