comparison js/taggingtext.js @ 98:5bea390e7ca9 extractapp

new: short tag in front of long tag
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 14 Mar 2016 14:43:42 +0100
parents 9a29e9d28ece
children c3e149277b58
comparison
equal deleted inserted replaced
97:c1bb174a22f3 98:5bea390e7ca9
27 var lastAddTag=""; 27 var lastAddTag="";
28 28
29 var regex_element_index = 0; 29 var regex_element_index = 0;
30 30
31 window.onbeforeunload = function() { 31 window.onbeforeunload = function() {
32 return "Unsaved data will be lost."; 32 //return "Unsaved data will be lost.";
33 }; 33 };
34 34
35 35
36 /* 36 /*
37 $(document).on("mouseup", function (e) { 37 $(document).on("mouseup", function (e) {
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 // find tag displaying name by tagName then showing in the innerHTML 251 // find tag displaying name by tagName then showing in the innerHTML
252
252 var tag_name = getTagNameByTag(tag); 253 var tag_name = getTagNameByTag(tag);
254 // newdiv.innerHTML = "Tag: "+tag_name+"<br>Value: "+tagObject.text()+"<br>";
255
256 // TODO maybe also shown tag itself?
253 newdiv.innerHTML = "Tag: "+tag_name+"<br>Value: "+tagObject.text()+"<br>"; 257 newdiv.innerHTML = "Tag: "+tag_name+"<br>Value: "+tagObject.text()+"<br>";
254 258
259
255 260
256 var newbutton = $('<button class="btn btn-default">Remove this</button>').mouseup(function (e2) { 261 var newbutton = $('<button class="btn btn-default">Remove this</button>').mouseup(function (e2) {
257 var textKeep = $(this).parent().parent().html(); 262 var textKeep = $(this).parent().parent().html();
258 var regexText=/<div(.*?)<\/div>/g; 263 var regexText=/<div(.*?)<\/div>/g;
259 var replaceText=""; 264 var replaceText="";
409 } 414 }
410 415
411 function tagStringWithTag( stringValue, tag ) { 416 function tagStringWithTag( stringValue, tag ) {
412 saveUndoText(); 417 saveUndoText();
413 var el = document.getElementById("editable-area"); 418 var el = document.getElementById("editable-area");
419
420 // TODO: bug? when stringValue contain already tag, it should be preserved
421
422 console.log(stringValue);
423
424
414 var regexText="("+String(stringValue)+")"; 425 var regexText="("+String(stringValue)+")";
415 if ( tag=="person") { 426 if ( tag=="person") {
416 var replaceText="<br><"+tag+">$1</"+tag+">"; 427 var replaceText="<br><"+tag+">$1</"+tag+">";
417 } else { 428 } else {
418 var replaceText="<"+tag+">$1</"+tag+">"; 429 var replaceText="<"+tag+">$1</"+tag+">";