# HG changeset patch # User Zoe Hong # Date 1462368131 -7200 # Node ID a264460c77cafa7b337b25fb5c0f040f1771644b # Parent 8a97db7b910889413fda55f5266ae404d1f6978d new: auto save and reload page after updating taglist. diff -r 8a97db7b9108 -r a264460c77ca data/wordlist/4.txt --- a/data/wordlist/4.txt Mon May 02 15:47:03 2016 +0200 +++ b/data/wordlist/4.txt Wed May 04 15:22:11 2016 +0200 @@ -1,1 +1,1 @@ -一
\ No newline at end of file +一
\ No newline at end of file diff -r 8a97db7b9108 -r a264460c77ca js/taggingtext.js --- a/js/taggingtext.js Mon May 02 15:47:03 2016 +0200 +++ b/js/taggingtext.js Wed May 04 15:22:11 2016 +0200 @@ -32,6 +32,23 @@ //return "Unsaved data will be lost."; }; +function setCookie(value) { + document.cookie = "cookie-msg-test=" + value + "; path=/"; + return true; +} +function getCookie() { + var cname = "cookie-msg-test="; + var ca = document.cookie.split(';'); + + for (var i=0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0)==' ') c = c.substring(1,c.length); + if (c.indexOf(cname) == 0) { + return c.substring(cname.length, c.length); + } + } + return null; +} /* $(document).on("mouseup", function (e) { diff -r 8a97db7b9108 -r a264460c77ca models/extractapp.php --- a/models/extractapp.php Mon May 02 15:47:03 2016 +0200 +++ b/models/extractapp.php Wed May 04 15:22:11 2016 +0200 @@ -1339,7 +1339,7 @@ $name = $postdata['text']; } - $query1 = sprintf("INSERT INTO `Wordlist` (`name`) VALUES (%s,)", + $query1 = sprintf("INSERT INTO `Wordlist` (`name`) VALUES (%s)", $this->GetSQLValueString($name, "text")); //$this->GetSQLValueString($this->systemNAME, "text")); $result1 = mysql_query($query1); diff -r 8a97db7b9108 -r a264460c77ca views/Extractapp/EditTaglist.php --- 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(''); @@ -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; diff -r 8a97db7b9108 -r a264460c77ca views/Extractapp/TaggingText.php --- a/views/Extractapp/TaggingText.php Mon May 02 15:47:03 2016 +0200 +++ b/views/Extractapp/TaggingText.php Wed May 04 15:22:11 2016 +0200 @@ -119,6 +119,22 @@ } +// ---- use cookie to save text and reload page for the up-to-date taglist +function updatePage() { + var text = getCookie(); + //document.forms['receiver'].elements['message'].value = text; + console.log(text); + if (text == "reload") { + setCookie(""); + saveTextToLGService(); + + } + setTimeout(updatePage, 500); + +} +updatePage(); + +// ------ function reloadText() { /** @@ -1448,6 +1464,9 @@ } ?> + +
+
OR (USE "|" TO SEPARATE WORDS):


@@ -1546,8 +1565,6 @@ -->
-
-