diff views/Extractapp/EditTaglist.php @ 101:a264460c77ca extractapp

new: auto save and reload page after updating taglist.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 04 May 2016 15:22:11 +0200
parents c3e149277b58
children 6ba742b712b0
line wrap: on
line diff
--- a/views/Extractapp/EditTaglist.php	Mon May 02 15:47:03 2016 +0200
+++ b/views/Extractapp/EditTaglist.php	Wed May 04 15:22:11 2016 +0200
@@ -92,6 +92,16 @@
 });
 
 
+window.onbeforeunload = function() {
+	if (getCookie() == "Saved") {
+		setCookie("reload");
+	} else {
+		setCookie("");
+	}
+	
+};
+
+
 function addTag() {
 
 	largestId++;
@@ -294,6 +304,12 @@
 	var elid = document.getElementById("tdId"+id).textContent;
 	var elname = document.getElementById("tdName"+id).textContent;
 	var eltag = document.getElementById("tdTag"+id).textContent;
+
+
+	if (elname == "" || eltag == "") {
+		alert("Name and Tag cannot be empty.");
+		return;
+	}
 	/*
 	var elid = document.getElementById("tdId"+id).innerHTML;
 	var elname = document.getElementById("tdName"+id).innerHTML;
@@ -315,7 +331,9 @@
 		},
 		success: function (e) {
 			alert("Saved!");
-			document.location.reload(true);
+
+			setCookie("Saved");
+			//document.location.reload(true);
 		}
 	}).done(function(result) {
 	});
@@ -348,12 +366,17 @@
 		},
 		success: function (e) {
 			alert("Saved!");
-			document.location.reload(true);
+
+			setCookie("Saved");
+			console.log("log success the saving.." + getCookie());
+			//document.location.reload(true);
 		}
 	}).done(function(result) {
 	});
 }
 
+
+
 function DeleteTag( id ) {	
 	$("#tr"+id).remove();
 	var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>');
@@ -364,10 +387,16 @@
 		data : 'func=DeleteTag'+'&id='+id+'&type=delete&topic_id='+topic_id
 	}).done(function(result) {
 		alert("Saved!");
+		setCookie("Saved");
+		
 	});
 }
 
 
+
+
+
+
 $(document).on("click", "[name=tdName]", function () {
 	if ( $("#input"+this.id).length > 0 ) {
 		return;