Mercurial > hg > extraction-interface
comparison views/Extractapp/TaggingText.php @ 79:e6e213b26454 extractapp
Bug fixed: file crashed after saving (preg_replace remove unnecessary symbols within br tag
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Mon, 20 Apr 2015 16:55:33 +0200 |
parents | 960ba96efce1 |
children | f1f849d31272 |
comparison
equal
deleted
inserted
replaced
78:960ba96efce1 | 79:e6e213b26454 |
---|---|
147 /* | 147 /* |
148 if ($(this).prop("tagName").toLowerCase() != taglistValue[2]) { | 148 if ($(this).prop("tagName").toLowerCase() != taglistValue[2]) { |
149 return 0; | 149 return 0; |
150 } | 150 } |
151 */ | 151 */ |
152 // pop_remove_tag_window is a global variable which indicates if to show the remove-popup-window | |
152 if (pop_remove_tag_window) { | 153 if (pop_remove_tag_window) { |
153 removeTagNewDiv( e, tagName , $(this)); | 154 removeTagNewDiv( e, tagName , $(this)); |
154 }; | 155 }; |
155 }); | 156 }); |
156 }; | 157 }; |
258 | 259 |
259 container = document.createElement("div"); | 260 container = document.createElement("div"); |
260 container.appendChild(selection.getRangeAt(0).cloneContents()); | 261 container.appendChild(selection.getRangeAt(0).cloneContents()); |
261 | 262 |
262 if(selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) { | 263 if(selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) { |
263 | 264 try{ |
264 var newdiv = document.createElement("div"); | 265 var newdiv = document.createElement("div"); |
265 newdiv.id = "tagItemDivId"; | 266 newdiv.id = "tagItemDivId"; |
266 newdiv.setAttribute("class", "tagItemDivClass"); | 267 newdiv.setAttribute("class", "tagItemDivClass"); |
267 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px; z-index:4'; | 268 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px; z-index:4'; |
268 | 269 |
269 //console.log(selection.getRangeAt(0).cloneContents()); | 270 //console.log(selection.getRangeAt(0).cloneContents()); |
270 if ( container.innerHTML.indexOf( "br" ) != -1 ) { | 271 if ( container.innerHTML.indexOf( "br" ) != -1 ) { |
271 var newselect = document.createElement("select"); | 272 var newselect = document.createElement("select"); |
272 newselect.id = "TitletagType"; | 273 newselect.id = "TitletagType"; |
273 //console.log(JSON.parse('<?php echo json_encode($taglistArray) ?>')); | 274 //console.log(JSON.parse('<?php echo json_encode($taglistArray) ?>')); |
274 | 275 |
275 <?php | 276 <?php |
277 foreach ( $taglistArray as $taglistValue ) { | |
278 echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n"; | |
279 } | |
280 ?> | |
281 newdiv.appendChild(newselect); | |
282 | |
283 //matchValue = .match(); | |
284 myRegexp = new RegExp("〈(.*?)〉", "g") | |
285 matchValue = myRegexp.exec(String(selection)); | |
286 | |
287 if ( matchValue != null ) { | |
288 newdiv.innerHTML += "<input id=\"TitletagName\" value=\""+ matchValue[1] +"\"></br>"; | |
289 } else { | |
290 newdiv.innerHTML += "<input id=\"TitletagName\" value=\"\"></br>"; | |
291 } | |
292 | |
293 | |
294 newdiv.innerHTML += "<button onclick=\"addTagTitle( range, container )\">Add Title Tag To Each Line</button></br>"; | |
295 | |
296 /* | |
297 newdiv.innerHTML += "<button onclick=\"exportTable( range, container )\">Export As A Table</button></br></br>"; | |
298 */ | |
299 | |
300 var newselect = document.createElement("select"); | |
301 newselect.id = "RemoveTitletagType"; | |
302 <?php | |
303 foreach ( $taglistArray as $taglistValue ) { | |
304 echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n"; | |
305 } | |
306 ?> | |
307 newdiv.appendChild(newselect); | |
308 | |
309 newdiv.innerHTML += "<input id=\"RemoveTitletagName\" value=\"\"></br>"; | |
310 newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>"; | |
311 } else { | |
312 // for pop up window on edit-area for tag list | |
313 newdiv.innerHTML = "Tag: "+String(selection)+"<br>"; | |
314 | |
315 <?php | |
276 foreach ( $taglistArray as $taglistValue ) { | 316 foreach ( $taglistArray as $taglistValue ) { |
277 echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n"; | 317 |
278 } | 318 if ($taglistValue[2] == $topic_tag) { |
279 ?> | 319 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">[TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)</button>\";\n"; |
280 newdiv.appendChild(newselect); | 320 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; |
281 | 321 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; |
282 //matchValue = .match(); | 322 |
283 myRegexp = new RegExp("〈(.*?)〉", "g") | 323 /* |
284 matchValue = myRegexp.exec(String(selection)); | |
285 | |
286 if ( matchValue != null ) { | |
287 newdiv.innerHTML += "<input id=\"TitletagName\" value=\""+ matchValue[1] +"\"></br>"; | |
288 } else { | |
289 newdiv.innerHTML += "<input id=\"TitletagName\" value=\"\"></br>"; | |
290 } | |
291 | |
292 | |
293 newdiv.innerHTML += "<button onclick=\"addTagTitle( range, container )\">Add Title Tag To Each Line</button></br>"; | |
294 | |
295 /* | |
296 newdiv.innerHTML += "<button onclick=\"exportTable( range, container )\">Export As A Table</button></br></br>"; | |
297 */ | |
298 | |
299 var newselect = document.createElement("select"); | |
300 newselect.id = "RemoveTitletagType"; | |
301 <?php | |
302 foreach ( $taglistArray as $taglistValue ) { | |
303 echo "newselect.innerHTML += \"<option value='".$taglistValue[2]."'>".$taglistValue[1]."</option>\";\n"; | |
304 } | |
305 ?> | |
306 newdiv.appendChild(newselect); | |
307 | |
308 newdiv.innerHTML += "<input id=\"RemoveTitletagName\" value=\"\"></br>"; | |
309 newdiv.innerHTML += "<button onclick=\"removeTagTitle( range, container )\">Remove</button></br>"; | |
310 } else { | |
311 // for pop up window on edit-area for tag list | |
312 newdiv.innerHTML = "Tag: "+String(selection)+"<br>"; | |
313 | |
314 <?php | |
315 foreach ( $taglistArray as $taglistValue ) { | |
316 | |
317 if ($taglistValue[2] == $topic_tag) { | |
318 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">[TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)</button>\";\n"; | |
319 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; | |
320 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
321 | |
322 /* | |
323 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; | |
324 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
325 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
326 */ | |
327 break; | |
328 } | |
329 } | |
330 ?> | |
331 | |
332 newdiv.innerHTML += "<button accesskey=\"2\" onclick=\"tagwithtitle( range, '"+String(selection)+"' )\">Tag As Title</button></br>"; | |
333 | |
334 <?php | |
335 | |
336 foreach ( $taglistArray as $taglistValue ) { | |
337 /* | |
338 if ( $taglistValue[2] == "person") { | |
339 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; | 324 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; |
340 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | 325 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; |
341 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | 326 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; |
342 } else */ | 327 */ |
343 if ($taglistValue[2] == $topic_tag) { | 328 break; |
344 // pass | 329 } |
345 } else if ($taglistValue[2] == "post_time") { | |
346 echo "newdiv.innerHTML += \"<button accesskey=\\\"3\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
347 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
348 } else if ($taglistValue[2] == "office") { | |
349 echo "newdiv.innerHTML += \"<button accesskey=\\\"4\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
350 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
351 } else { | |
352 echo "newdiv.innerHTML += \"<button onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
353 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
354 } | |
355 | |
356 } | 330 } |
357 ?> | 331 ?> |
332 | |
333 newdiv.innerHTML += "<button accesskey=\"2\" onclick=\"tagwithtitle( range, '"+String(selection)+"' )\">Tag As Title</button></br>"; | |
334 | |
335 <?php | |
336 | |
337 foreach ( $taglistArray as $taglistValue ) { | |
338 /* | |
339 if ( $taglistValue[2] == "person") { | |
340 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(No BR)</button>\";\n"; | |
341 echo "newdiv.innerHTML += \"<button accesskey=\\\"1\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."2' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
342 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
343 } else */ | |
344 if ($taglistValue[2] == $topic_tag) { | |
345 // pass | |
346 } else if ($taglistValue[2] == "post_time") { | |
347 echo "newdiv.innerHTML += \"<button accesskey=\\\"3\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
348 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
349 } else if ($taglistValue[2] == "office") { | |
350 echo "newdiv.innerHTML += \"<button accesskey=\\\"4\\\" onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
351 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
352 } else { | |
353 echo "newdiv.innerHTML += \"<button onclick=\\\"tagwithOnlytag( range, '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."</button>\";\n"; | |
354 echo "newdiv.innerHTML += \"<button onclick=\\\"tagStringWithTag( '\"+String(selection)+\"', '".$taglistValue[2]."' )\\\">Tag as:".$taglistValue[1]."(ALL)</button></br>\";\n"; | |
355 } | |
356 | |
357 } | |
358 ?> | |
359 } | |
360 | |
361 //$('#tagItemDivId').addClass(); // tagItemDivId is newdiv's id | |
362 $('body').append(newdiv); | |
363 | |
364 $('#TitletagType').val(lastAddTag); | |
365 | |
366 // selected some words, so hide popping up remove-tag-window | |
367 pop_remove_tag_window = false; // questionMarkID | |
358 } | 368 } |
359 | 369 catch(err){ |
360 //$('#tagItemDivId').addClass(); // tagItemDivId is newdiv's id | 370 pop_remove_tag_window = true; // questionMarkID |
361 $('body').append(newdiv); | 371 |
362 | 372 } |
363 $('#TitletagType').val(lastAddTag); | |
364 | |
365 // selected some words, so hide popping up remove-tag-window | |
366 pop_remove_tag_window = false; // questionMarkID | |
367 | |
368 } else { | 373 } else { |
369 // without selecting any word, so pop up remove-tag-window | 374 // without selecting any word, so pop up remove-tag-window |
370 pop_remove_tag_window = true; | 375 pop_remove_tag_window = true; |
371 } | 376 } |
372 | 377 |