changeset 14:6ea0f9030f72

add timer reminder
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 24 Jun 2015 16:50:32 +0200
parents 3d206aa0c77d
children e4c5f9cf66cb
files check_sections_details.php
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/check_sections_details.php	Wed Jun 24 16:20:03 2015 +0200
+++ b/check_sections_details.php	Wed Jun 24 16:50:32 2015 +0200
@@ -202,6 +202,7 @@
 				$("#saveBook .editor").val(current_editor);
 		    } else {
 		    	alert("Error!! You have to login from LGService!");
+				$("#loading").show();
 		    }
 		}
 
@@ -252,14 +253,25 @@
 		}
 		function slowAlert() {
 		 	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.)")) {
-		 		timeoutID = window.setTimeout(slowAlert, 60*60*1000);
-		 		// renew session?
 		 		
 				var lg_url = "<?php echo $lgserver_url?>" + "rest/utils/getUser?sessionId=" + session_id;
-				console.log(lg_url);
 
 		 		$.post(lg_url, function(data) {
 		 			console.log("renew session.");
+		 			
+		 		}).done(function(data){
+		 			console.log(data);
+		 			console.log("login as: " + data['userName']);
+
+		 			if (data['userName'] == "") {
+		 				alert("Error!! You have to login from LGService!");
+						$("#loading").show();
+		 			} else {
+				 		timeoutID = window.setTimeout(slowAlert, 3600*1000);
+		 			}
+
+		 		}).fail(function(){
+		 			console.log("fail to renew session.");
 		 		});
 		 	}
 		}