diff views/Extractapp/EditTaglist.php @ 97:c1bb174a22f3 extractapp

Topic synchronization with LGServices. Adaption for moving table from Gazetteer to LGService.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Tue, 16 Feb 2016 15:07:43 +0100
parents 9a29e9d28ece
children c3e149277b58
line wrap: on
line diff
--- a/views/Extractapp/EditTaglist.php	Mon Nov 23 16:24:57 2015 +0100
+++ b/views/Extractapp/EditTaglist.php	Tue Feb 16 15:07:43 2016 +0100
@@ -41,6 +41,7 @@
 <script type="text/javascript" src="../js/eye.js"></script>
 <script type="text/javascript" src="../js/utils.js"></script>
 <script type="text/javascript" src="../js/layout.js?ver=1.0.2"></script>
+
 </head>
 
 <body>
@@ -56,6 +57,38 @@
 var largestId = JSON.parse('<?php echo json_encode($largestId) ?>');
 var topic_tag_id = JSON.parse('<?php echo json_encode($topic_tag_id) ?>');
 
+$(document).on("keydown", ".englishOnly", function () {
+
+//$(".englishOnly").on( "keydown", function( event ) {
+	
+	console.log(".englishOnly");
+
+	var englishAlphabetAndWhiteSpace =/[A-Za-z 0-9]/g;
+
+	var key = String.fromCharCode(event.which);
+	
+	// --- key code: ---
+	// space: 32, delete: 8, enter: 13, tab: 9
+	// [a-z]: 65-91
+	// [0-9]: 48-57
+	// esc: 27
+	// shift, ctr, alt: 16, 17, 18, 20
+	// cmd: 91
+	
+	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 || englishAlphabetAndWhiteSpace.test(key)) { 
+		return true; 
+	}	
+
+
+	alert("Please type in English characters.");
+	
+	$(this).val(""); 
+
+	
+	return false;
+});
+
+
 function addTag() {
 
 	largestId++;
@@ -81,6 +114,7 @@
 	newcolumn.id = "tdTag"+largestId;
 	newcolumn.setAttribute("idnum",largestId);
 	newcolumn.setAttribute("name","tdTag");
+	
 	row.appendChild(newcolumn).innerHTML="";
 	// ---
 
@@ -368,6 +402,10 @@
 	newTextBox.setAttribute("name","inputTag");
 	newTextBox.setAttribute("onfocus","this.select()");
 	newTextBox.setAttribute("size","20");
+	
+	newTextBox.setAttribute("class","englishOnly");
+	newTextBox.setAttribute("placeholder","English characters only");
+	
 	this.appendChild(newTextBox).value=startPageValue;
 	
 	$("#input"+this.id).focus();