changeset 19:c0eccf597fcc

after saved successfully, pop up a message to let user know page will be reloaded.
author Calvin Yeh <cyeh@mpiwg-berlin.mpg.de>
date Mon, 25 Sep 2017 14:26:21 +0200
parents a15320882b30
children ae69cfe4f9d2
files js/check_sections_details.js
diffstat 1 files changed, 23 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/js/check_sections_details.js	Mon Sep 25 14:23:20 2017 +0200
+++ b/js/check_sections_details.js	Mon Sep 25 14:26:21 2017 +0200
@@ -1,4 +1,5 @@
 var saving=0;
+
 $(document).ready(function(){
 	initEntry();
 	initName();
@@ -71,7 +72,7 @@
 			$(this).html("<input type='text' value='"+name+"'>");
 			$(this).children("input").focus();
 		}
-	});	
+	});
 }
 function initInsert(){
 	var insert=$("<div/>").addClass("insert");
@@ -100,11 +101,11 @@
 	$(".insertAfter").click(function(){
 		addEntry($(this).parent().parent().parent(),1);
 		$(this).parent().hide();
-	});	
+	});
 	$(".insertBefore").click(function(){
 		addEntry($(this).parent().parent().parent(),0);
 		$(this).parent().hide();
-	});	
+	});
 }
 function addEntry(obj,pos){//obj: the obj next to which we would like to add a new entry, pos: before the obj or after the obj
 	var clone=$(".clone").clone(true);
@@ -115,15 +116,15 @@
 
 	// bug: section_after field is not correct
 
-	
+
 	if(pos==0){
 		clone.insertBefore(obj);
 		//$("<br>").insertAfter(clone);
 	}else{
 		clone.insertAfter(obj);
 		//$("<br>").insertBefore(clone);
-	}	
-	
+	}
+
 
 	$("#searchResults .sequence").each(function(idx){
 		$(this).html(idx+1);
@@ -148,7 +149,7 @@
 			//console.log($(this).parent().children(".editLevel").children().first().val());
 		}
 	});
-		
+
 }
 
 
@@ -163,9 +164,9 @@
 	for(var i=1; i<=3; i++){
 		$("div.level"+i+" .editLevel select").val(i);
 	}
-	
+
 	$(".editLevel select").change(function(){//add classes for text indent, to control layout style
-		var entryObj=$(this).parent().parent();	
+		var entryObj=$(this).parent().parent();
 		var className="";
 		if(entryObj.hasClass("level1")){
 			className="level1";
@@ -191,9 +192,9 @@
 	for(var i=1; i<=3; i++){
 		$("div.level"+i+" .editLevel select").val(i);
 	}
-	
+
 	$(".editLevel select").change(function(){//add classes for text indent, to control layout style
-		var entryObj=$(this).parent().parent();	
+		var entryObj=$(this).parent().parent();
 		var className="";
 		if(entryObj.hasClass("level1")){
 			className="level1";
@@ -234,7 +235,7 @@
 		if($("#deleteRange").is(":visible")){
 			deleteRangeObj.insertAfter($("#searchResults"));
 			$("#deleteRange").hide();
-		}	
+		}
 	});
 	$(".deleteEntry").hover(function(){
 		var entryObj=$(this).parent();
@@ -354,31 +355,35 @@
 			version:version,
 			editor:editor,
 			bookId:bookId,
-			sectionArray:sectionArray	
+			sectionArray:sectionArray
 		},
 		function(data){//things to do after edit_section_db is done
+
 			if(data=="Succeeded."){
+
+                alert("Saved Successfully !! Sysetm will reload the page for saved sections, but maybe you will need to re-login.");
+
 				saving=1;
 				var hideDeletedChecked=$(".hideDeleted input:checkbox").is(":checked");//get the previous setting for checked
 				var href=window.location.href;
 				var reg=/count=[0-9^\?]+/g;
 				var count=reg.exec(href);
     				reg = /[^\?]+/g;
-    				href = reg.exec(href);		
+    				href = reg.exec(href);
 
 				href=href+"?book_id="+bookId+"&"+count+"&hideDeletedChecked="+hideDeletedChecked+"&editor="+editor+"&sessionId="+session_id;
 				location.href=href; //refresh the page to load the sections saved in db
-				
+
 			}else{
 				console.log("db failed. log: ", data);
 				alert("Saving failed. You've NOT saved your editing.");
 				alert("Please check your editing again. If the issue remains, please contact us.");
 				$("#loading").hide();
-				
+
 			}
 		},
 		"json"
-	);	
+	);
 }
 function collectSectionArray(){
 	var sectionArray=new Array();
@@ -415,7 +420,7 @@
 		var sectionAfter=$(this).children(".hiddenInfo").children(".sectionAfter").html()
 		var level=$(this).children(".editLevel").children("select").val();
 		var splitFrom=$(this).children(".hiddenInfo").children(".splitFrom").html();
-		if(splitFrom==""){splitFrom="NULL";}	
+		if(splitFrom==""){splitFrom="NULL";}
 		sectionArray[idx]={name:name,booksId:booksId,sectionAfter:sectionAfter,
 				startPage:startPage,endPage:endPage,
 				level:level,splitFrom:splitFrom,