comparison check_sections_details.php @ 13:3d206aa0c77d

add timer reminder
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 24 Jun 2015 16:20:03 +0200
parents 7e04cbe8b2a0
children 6ea0f9030f72
comparison
equal deleted inserted replaced
12:7e04cbe8b2a0 13:3d206aa0c77d
102 $lg_url = $lgserver_url."rest/utils/getUser?sessionId=".$session_id; // url to get username from LGService 102 $lg_url = $lgserver_url."rest/utils/getUser?sessionId=".$session_id; // url to get username from LGService
103 //$lg_url = "http://localgazetteers-dev/LGServices/rest/utils/getUser?sessionId=".$session_id; // url to get username from LGService 103 //$lg_url = "http://localgazetteers-dev/LGServices/rest/utils/getUser?sessionId=".$session_id; // url to get username from LGService
104 $output = file_get_contents($lg_url); 104 $output = file_get_contents($lg_url);
105 $user_info = json_decode($output, true); 105 $user_info = json_decode($output, true);
106 $current_editor = (string)$user_info['userName']; 106 $current_editor = (string)$user_info['userName'];
107 107
108 if ($current_editor == null || strcmp($user_info['status'], "error") == 0) { 108 if ($current_editor == null || $current_editor == "" || strcmp($current_editor, "") === 0 || strcmp($user_info['status'], "ok") !== 0) {
109 // redirect to LGServices homepage 109 // redirect to LGServices homepage
110 //header("Location: http://localgazetteers.mpiwg-berlin.mpg.de/LGServices");
110 header("Location: "+$lgserver_url+"LGServices"); 111 header("Location: "+$lgserver_url+"LGServices");
111 //header('Location: http://localgazetteers/LGServices');
112 } 112 }
113 113
114 } else { 114 } else {
115 // test locally 115 // test locally
116 // redirect to LGServices homepage 116 // redirect to LGServices homepage
117 header("Location: "+$lgserver_url+"LGServices"); 117 header("Location: "+$lgserver_url+"LGServices");
118 //header('Location: http://localgazetteers/LGServices');
119 } 118 }
120 119
121 120
122 ?> 121 ?>
123 122
188 } 187 }
189 ?> 188 ?>
190 </div> 189 </div>
191 </div> 190 </div>
192 <div id="panel"></div> 191 <div id="panel"></div>
193 <script>var version = <?php echo $version;?>; 192 <script>
194 var session_id = "<?php echo $_GET['sessionId']; ?>"; 193 var version = <?php echo $version;?>;
194 var session_id = "<?php echo $_GET['sessionId']; ?>";
195 </script> 195 </script>
196 196
197 <script type="text/javascript"> 197 <script type="text/javascript">
198 function setCurrentEditor() { 198 function setCurrentEditor() {
199 // current_editor is gotten from LGService 199 // current_editor is gotten from LGService
200 var current_editor = <?php echo json_encode($current_editor) ?>; 200 var current_editor = <?php echo json_encode($current_editor) ?>;
201 if (current_editor != "") { 201 if (current_editor != "") {
202 $("#saveBook .editor").val(current_editor); 202 $("#saveBook .editor").val(current_editor);
203 } else { 203 } else {
204 console.log("You have to login from LGService!"); 204 alert("Error!! You have to login from LGService!");
205 } 205 }
206 } 206 }
207 207
208 document.getElementById("show_all").onclick = function(){showAll()}; 208 document.getElementById("show_all").onclick = function(){showAll()};
209 209
241 document.getElementById("editor").innerHTML = ""; 241 document.getElementById("editor").innerHTML = "";
242 document.getElementById("date").innerHTML = ""; 242 document.getElementById("date").innerHTML = "";
243 } 243 }
244 244
245 245
246 /* 246
247 // --- timeout reminder --- 247 // --- timeout reminder ---
248 var timeoutID; 248 var timeoutID;
249 delayedAlert(); 249 delayedAlert();
250 function delayedAlert() { 250 function delayedAlert() {
251 timeoutID = window.setTimeout(slowAlert, 4000); 251 timeoutID = window.setTimeout(slowAlert, 3600*1000); // 1 hr
252 } 252 }
253 function slowAlert() { 253 function slowAlert() {
254 if (confirm("Reminder: It's been 30 mins. Don't forget to save your work. \n\nKeep working? \n(Press Cancel will turn off this reminder.)")) { 254 if (confirm("Reminder: It's been 1 hour. Remember saving your work to prevent data lost. \n\nKeep working? \n(Press Cancel will turn off this reminder.)")) {
255 timeoutID = window.setTimeout(slowAlert, 4000); 255 timeoutID = window.setTimeout(slowAlert, 60*60*1000);
256 // renew session? 256 // renew session?
257 257
258 var lg_url = "<?php echo $lgserver_url?>" + "rest/utils/getUser?sessionId=" + session_id; 258 var lg_url = "<?php echo $lgserver_url?>" + "rest/utils/getUser?sessionId=" + session_id;
259 console.log(lg_url); 259 console.log(lg_url);
260 260
261 $.post(lg_url, function(data) { 261 $.post(lg_url, function(data) {
262 262 console.log("renew session.");
263 ///console.log(data);
264
265 }); 263 });
266 } 264 }
267 } 265 }
268 */ 266
269 267
270 268
271 269
272 </script> 270 </script>
273 271