Mercurial > hg > extraction-interface
changeset 119:eebfc2d7e935 extractapp
bug fixed : error message can not be shown properly
author | Calvin Yeh <cyeh@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 28 Sep 2017 17:47:58 +0200 |
parents | 3bca624e4ac2 |
children | 71b611a676c3 |
files | views/Extractapp/EditTaglist.php |
diffstat | 1 files changed, 63 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/views/Extractapp/EditTaglist.php Thu Sep 28 17:46:20 2017 +0200 +++ b/views/Extractapp/EditTaglist.php Thu Sep 28 17:47:58 2017 +0200 @@ -17,7 +17,7 @@ * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>. */ -/*! \file +/*! \file * This is the view for EditTaglist. * It shows the detail of taglist in the current topic in a new window. * User can edit values for each tag except the topic_tag. @@ -36,6 +36,7 @@ <html> <head> <title></title> +<?php include 'views/maintemplate.php'; ?> <link rel="stylesheet" href="../css/colorpicker.css" type="text/css" /> <script type="text/javascript" src="../js/colorpicker.js"></script> <script type="text/javascript" src="../js/eye.js"></script> @@ -61,13 +62,13 @@ $(document).on("keydown", ".englishOnly", function () { //$(".englishOnly").on( "keydown", function( event ) { - + console.log(".englishOnly"); var englishAlphabet =/[A-Za-z0-9]/g; var key = String.fromCharCode(event.which); - + // --- key code: --- // space: 32, delete: 8, enter: 13, tab: 9 // [a-z]: 65-91 @@ -77,17 +78,17 @@ // cmd: 91 // -: 189 - if (event.keyCode == 8 || event.keyCode == 9 || (event.keyCode >= 16 && event.keyCode <= 20) || event.keyCode == 27 || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 91 || event.keyCode == 189 || englishAlphabet.test(key)) { - - return true; - } + if (event.keyCode == 8 || event.keyCode == 9 || (event.keyCode >= 16 && event.keyCode <= 20) || event.keyCode == 27 || event.keyCode == 37 || event.keyCode == 39 || event.keyCode == 91 || event.keyCode == 189 || englishAlphabet.test(key)) { + + return true; + } alert("Please type in (lowercase) English characters."); - - $(this).val(""); - + $(this).val(""); + + return false; }); @@ -98,7 +99,7 @@ } else { setCookie(""); } - + }; @@ -108,42 +109,42 @@ var row = tableMain.insertBefore(document.createElement("tr"), document.getElementById("trAddTag") ); row.setAttribute("height","50"); row.id = "tr"+largestId; - row.setAttribute("class", "bg-warning"); + row.setAttribute("class", "bg-warning"); var newcolumn = document.createElement("td"); newcolumn.id = "tdId"+largestId; newcolumn.setAttribute("width","150"); row.appendChild(newcolumn).innerHTML=largestId; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","150"); newcolumn.id = "tdName"+largestId; newcolumn.setAttribute("idnum",largestId); newcolumn.setAttribute("name","tdName"); row.appendChild(newcolumn).innerHTML=""; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","150"); newcolumn.id = "tdTag"+largestId; newcolumn.setAttribute("idnum",largestId); newcolumn.setAttribute("name","tdTag"); - + row.appendChild(newcolumn).innerHTML=""; // --- - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","150"); row.appendChild(newcolumn).innerHTML="<div id=\"colorSelector"+largestId+"\"><div id=\"colorSelectorB"+largestId+"\" style=\"background-color: #000000\"></div></div>"; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","50"); row.appendChild(newcolumn).innerHTML="<button onclick=\"newTag("+largestId+")\">Save</button>"; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","50"); row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+largestId+")\">Delete</button>"; - + $('#colorSelector'+largestId).ColorPicker({ color: '#000000', onShow: function (colpkr) { @@ -172,31 +173,31 @@ if (x.insertRule) { x.insertRule(selector1+' {position:relative; width:36px; height:36px; background:url(../images/select.png);}', x.cssRules.length); x.insertRule(selector2+' {position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background:url(../images/select.png) center;}', x.cssRules.length); - + } else if (x.addRule) { x.addRule(selector1, "position: relative; width: 36px; height: 36px; background: url(../images/select.png);"); x.addRule(selector2, "position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background: url(../images/select.png) center;"); } - + -} +} function addNode( id, name, tag, color ) { // if ( parseInt(id) > largestId ) largestId=parseInt(id); - + var tableMain=document.getElementById("tableMain"); - + if ( id == "AddTag" ) { var row = tableMain.appendChild(document.createElement("tr")); row.id = "trAddTag"; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","150"); newcolumn.setAttribute("colspan","6"); newcolumn.setAttribute("align","center"); row.appendChild(newcolumn).innerHTML="<button onclick=\"addTag()\" style=\"height: 50px; width: 300px\">Add New Tag</button>"; - + return 0; } @@ -204,9 +205,9 @@ var row = tableMain.appendChild(document.createElement("tr")); row.setAttribute("height","50"); row.id = "tr"+id; - + if (id == "ID") { - row.setAttribute("class", "bg-info"); + row.setAttribute("class", "bg-info"); } @@ -215,7 +216,7 @@ newcolumn.setAttribute("width","150"); newcolumn.setAttribute("class","text-muted"); row.appendChild(newcolumn).innerHTML=id; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","150"); newcolumn.id = "tdName"+id; @@ -225,7 +226,7 @@ newcolumn.setAttribute("class","editable"); } row.appendChild(newcolumn).innerHTML=name; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","150"); newcolumn.id = "tdTag"+id; @@ -235,7 +236,7 @@ newcolumn.setAttribute("class","editable"); } row.appendChild(newcolumn).innerHTML=tag; - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","150"); if ( color=="Color") { @@ -254,7 +255,7 @@ row.appendChild(newcolumn).innerHTML="<button onclick=\"saveTag("+id+", 'update')\">Save</button>"; } - + var newcolumn = document.createElement("td"); newcolumn.setAttribute("width","50"); if ( color=="Color") { @@ -265,7 +266,7 @@ } else { row.appendChild(newcolumn).innerHTML="<button onclick=\"DeleteTag("+id+")\">Delete</button>"; } - + $('#colorSelector'+id).ColorPicker({ color: color, @@ -291,16 +292,16 @@ if (x.insertRule) { x.insertRule(selector1+' {position:relative; width:36px; height:36px; background:url(../images/select.png);}', x.cssRules.length); x.insertRule(selector2+' {position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background:url(../images/select.png) center;}', x.cssRules.length); - + } else if (x.addRule) { x.addRule(selector1, "position: relative; width: 36px; height: 36px; background: url(../images/select.png);"); x.addRule(selector2, "position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; background: url(../images/select.png) center;"); } - + } function newTag( id ) { - + var elid = document.getElementById("tdId"+id).textContent; var elname = document.getElementById("tdName"+id).textContent; var eltag = document.getElementById("tdTag"+id).textContent; @@ -321,7 +322,7 @@ console.log("elid="+elid+', elname='+elname+', eltag='+eltag); var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>'); - + $.ajax({ url : './EditTaglist', async : false, @@ -332,9 +333,9 @@ }, success: function (e) { console.log(e); - if (e[0] == 0){ + if (e === "0"){ alert("Saving error when create new tag. Check if the tag already exists."); - } else if (e[0] == 1) { + } else if (e === "1") { alert("Saving error when update tag topic relation. Please contact IT for support."); } else { alert("Saved!"); @@ -362,9 +363,9 @@ */ var elcolor = $("#colorSelectorB"+id).css("background-color"); - + console.log(elid+','+elname+','+eltag+','+elcolor); - + var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>'); $.ajax({ @@ -377,10 +378,19 @@ alert("Saving failed. Please check if the tag already exists."); }, success: function (e) { - alert("Saved!"); + + if (e === "0"){ + + alert("Saving error. English name is duplicated"); + } + else{ - setCookie("Saved"); - console.log("log success the saving.." + getCookie()); + alert("Saved!"); + + setCookie("Saved"); + console.log("log success the saving.." + getCookie()); + } + //document.location.reload(true); } }).done(function(result) { @@ -389,7 +399,7 @@ -function DeleteTag( id ) { +function DeleteTag( id ) { $("#tr"+id).remove(); var topic_id = JSON.parse('<?php echo json_encode($topic_id) ?>'); $.ajax({ @@ -400,7 +410,7 @@ }).done(function(result) { alert("Saved!"); setCookie("Saved"); - + }); } @@ -428,7 +438,7 @@ newTextBox.setAttribute("onfocus","this.select()"); newTextBox.setAttribute("size","20"); this.appendChild(newTextBox).value=startPageValue; - + $("#input"+this.id).focus(); } ); @@ -436,7 +446,7 @@ if ( $("#input"+this.id).length > 0 ) { return; } - + if (this.id == "tdTag"+topic_tag_id || this.id == "tdTagID") { return; } @@ -449,12 +459,12 @@ newTextBox.setAttribute("name","inputTag"); newTextBox.setAttribute("onfocus","this.select()"); newTextBox.setAttribute("size","20"); - + newTextBox.setAttribute("class","englishOnly"); newTextBox.setAttribute("placeholder","Lowercase English characters only"); - + this.appendChild(newTextBox).value=startPageValue; - + $("#input"+this.id).focus(); } ); @@ -487,14 +497,14 @@ }); -<?php +<?php // echo "addNode( \"".$topic_tag_id."\",\"".$taglistArray[$topic_tag_id][0]."\",\"".$taglistArray[$topic_tag_id][1]."\",\"".$taglistArray[$topic_tag_id][2]."\" );\n"; ?> addNode( "AddTag","","","" ); addNode( "ID","Name","Tag","Color" ); -<?php +<?php foreach ( $taglistArray as $tagId => $tagArray ) { echo "addNode( \"".$tagId."\",\"".$tagArray[0]."\",\"".$tagArray[1]."\",\"".$tagArray[2]."\" );\n"; }