comparison js/taggingtext.js @ 94:b0cecc104639 extractapp

new: modified tags can work on tagged text
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 09 Nov 2015 12:00:24 +0100
parents a05491461199
children 9a29e9d28ece
comparison
equal deleted inserted replaced
93:a05491461199 94:b0cecc104639
235 $("#editTextId").html("Edit the text"); 235 $("#editTextId").html("Edit the text");
236 } 236 }
237 } 237 }
238 238
239 239
240 function removeTagNewDiv( eventObject, tagName, tagObject ) { 240 function removeTagNewDiv( eventObject, tag, tagObject ) {
241 saveUndoText(); 241 saveUndoText();
242 242
243 var newdiv = document.createElement("div"); 243 var newdiv = document.createElement("div");
244 //$(newdiv).id = "questionMarkId"; 244 //$(newdiv).id = "questionMarkId";
245 $(newdiv).attr("class", "questionMarkClass"); 245 $(newdiv).attr("class", "questionMarkClass");
246 246
247 247
248 // set z-index to 3 to bring popup tag windwo to front 248 // set z-index to 3 to bring popup tag windwo to front
249 newdiv.style.cssText = 'top:'+eventObject.pageY+'; left:'+eventObject.pageX+';'; 249 newdiv.style.cssText = 'top:'+eventObject.pageY+'; left:'+eventObject.pageX+';';
250 250
251 newdiv.innerHTML = "Tag: "+tagName+"<br>Value: "+tagObject.text()+"<br>"; 251 // find tag displaying name by tagName then showing in the innerHTML
252 252 var tag_name = getTagNameByTag(tag);
253 newdiv.innerHTML = "Tag: "+tag_name+"<br>Value: "+tagObject.text()+"<br>";
254
255
253 var newbutton = $('<button class="btn btn-default">Remove this</button>').mouseup(function (e2) { 256 var newbutton = $('<button class="btn btn-default">Remove this</button>').mouseup(function (e2) {
254 var textKeep = $(this).parent().parent().html(); 257 var textKeep = $(this).parent().parent().html();
255 var regexText=/<div(.*?)<\/div>/g; 258 var regexText=/<div(.*?)<\/div>/g;
256 var replaceText=""; 259 var replaceText="";
257 textKeep = textKeep.replace(regexText, replaceText); 260 textKeep = textKeep.replace(regexText, replaceText);
281 textKeep = textKeep.replace(regexText, replaceText); 284 textKeep = textKeep.replace(regexText, replaceText);
282 285
283 $(this).parent().parent().replaceWith( textKeep ); 286 $(this).parent().parent().replaceWith( textKeep );
284 287
285 var el = document.getElementById("editable-area"); 288 var el = document.getElementById("editable-area");
286 var regexText=new RegExp("<"+tagName+">("+textKeep+")</"+tagName+">", "g"); 289 var regexText=new RegExp("<"+tag+">("+textKeep+")</"+tag+">", "g");
287 var replaceText="$1"; 290 var replaceText="$1";
288 var str="" + el.innerHTML; 291 var str="" + el.innerHTML;
289 292
290 if ( str.match(regexText)==null ) { 293 if ( str.match(regexText)==null ) {
291 alert( "Removed 1 entity!" ); 294 alert( "Removed 1 entity!" );
303 textKeep = textKeep.replace(regexText, replaceText); 306 textKeep = textKeep.replace(regexText, replaceText);
304 307
305 $(this).parent().remove(); 308 $(this).parent().remove();
306 309
307 var el = document.getElementById("editable-area"); 310 var el = document.getElementById("editable-area");
308 var regexText=new RegExp("<br><"+tagName+">("+textKeep+")</"+tagName+">", "g"); 311 var regexText=new RegExp("<br><"+tag+">("+textKeep+")</"+tag+">", "g");
309 var replaceText="$1"; 312 var replaceText="$1";
310 var str="" + el.innerHTML; 313 var str="" + el.innerHTML;
311 314
312 alert( "Removed "+str.match(regexText).length+" entities!" ); 315 alert( "Removed "+str.match(regexText).length+" entities!" );
313 el.innerHTML = str.replace(regexText, replaceText); 316 el.innerHTML = str.replace(regexText, replaceText);
775 var pattern_obj = []; // record pattern array for regex generator. only contain pattern1 and pattern2 778 var pattern_obj = []; // record pattern array for regex generator. only contain pattern1 and pattern2
776 779
777 function genRegexBySelection(tag_item_div, _selection) { 780 function genRegexBySelection(tag_item_div, _selection) {
778 var add_gen_regex_button = document.createElement("button"); 781 var add_gen_regex_button = document.createElement("button");
779 $(add_gen_regex_button).id = "addToGenRegex"; 782 $(add_gen_regex_button).id = "addToGenRegex";
780 $(add_gen_regex_button).addClass("btn btn-md"); 783 $(add_gen_regex_button).addClass("btn btn-xs btn-default");
781 $(add_gen_regex_button).click( function(){ 784 $(add_gen_regex_button).click( function(){
782 // popup for selected words regex gen 785 // popup for selected words regex gen
783 /* 786 /*
784 console.log("Debug: "); 787 console.log("Debug: ");
785 console.log(_selection); 788 console.log(_selection);
890 // If do this process, also need to consider between browers since not all of them support 893 // If do this process, also need to consider between browers since not all of them support
891 // and also need to modify pop_remove_tag_window 894 // and also need to modify pop_remove_tag_window
892 } 895 }
893 }); 896 });
894 897
895 $(add_gen_regex_button).text("Add to Gen Regex"); 898 $(add_gen_regex_button).text("Add to Gen Regex (developing...)");
896 tag_item_div.appendChild(add_gen_regex_button); 899 tag_item_div.appendChild(add_gen_regex_button);
897 } 900 }
898 901
899 902
900 function smartRegexEmpty() { 903 function smartRegexEmpty() {