Mercurial > hg > extraction-interface
annotate js/taggingtext.js @ 117:e6b516fa7b60 extractapp
1. add new columns : book year and edition year.
2. remove duplicate column : time.
author | Calvin Yeh <cyeh@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 28 Sep 2017 17:45:30 +0200 |
parents | 7f2c5d542616 |
children | 21e89eca0b84 |
rev | line source |
---|---|
81 | 1 /* |
2 * taggingtext.js | |
3 * This file is part of Extraction-interface. | |
4 * | |
5 * Extraction-interface is free software: you can redistribute it and/or modify | |
6 * it under the terms of the GNU General Public License as published by | |
7 * the Free Software Foundation, either version 3 of the License, or | |
8 * (at your option) any later version. | |
9 * | |
10 * Extraction-interface is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with Extraction-interface. If not, see <http://www.gnu.org/licenses/>. | |
17 */ | |
18 | |
19 /*! \file | |
20 * There are javscript functions for Extractapp. | |
21 * It is included by views/Extractapp/maintemplate.php and maintemplate_local.php. | |
77
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
72
diff
changeset
|
22 */ |
97c1e5102a22
New: export table for a file from LGService
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
72
diff
changeset
|
23 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
24 // === for taggingtext.php === |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
25 var stringBeforeChange=""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
26 var stringBeforeChangeStack = []; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
27 var lastAddTag=""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
28 |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
29 var regex_element_index = 0; |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
30 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
31 window.onbeforeunload = function() { |
98
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
32 //return "Unsaved data will be lost."; |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
33 }; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
34 |
101
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
35 function setCookie(value) { |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
36 document.cookie = "cookie-msg-test=" + value + "; path=/"; |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
37 return true; |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
38 } |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
39 function getCookie() { |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
40 var cname = "cookie-msg-test="; |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
41 var ca = document.cookie.split(';'); |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
42 |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
43 for (var i=0; i < ca.length; i++) { |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
44 var c = ca[i]; |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
45 while (c.charAt(0)==' ') c = c.substring(1,c.length); |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
46 if (c.indexOf(cname) == 0) { |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
47 return c.substring(cname.length, c.length); |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
48 } |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
49 } |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
50 return null; |
a264460c77ca
new: auto save and reload page after updating taglist.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
100
diff
changeset
|
51 } |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
52 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
53 /* |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
54 $(document).on("mouseup", function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
55 e.stopPropagation(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
56 $('.questionMarkClass').remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
57 $('.tagItemDivClass').remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
58 alert("Remove"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
59 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
60 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
61 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
62 $(document).on("click", '.questionMarkClass', function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
63 e.stopPropagation(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
64 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
65 */ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
66 function tagTime() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
67 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
68 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
69 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
70 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
71 var regexText=/(<?php echo $wordlistArray[0][2]; ?>)(○?)(一|二|三|四|五|六|七|八|九)?(○?)(十)?(○?)(一|二|三|四|五|六|七|八|九|元|十)(○?)(年)/g; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
72 var replaceText="<time>$1$2$3$4$5$6$7$8$9</time>"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
73 var matchedCount = str.match(regexText).length; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
74 str = str.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
75 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
76 var regexText=/(?!(>))(<?php echo $wordlistArray[0][2]; ?>)/g; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
77 var replaceText="<time>$1$2</time>"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
78 matchedCount += str.match(regexText).length; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
79 el.innerHTML = str.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
80 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
81 var regexText=/(一|二|三|四|五|六|七|八|九)?(○?)(十)?(○?)(一|二|三|四|五|六|七|八|九|元|十)(○?)(年)(?!(<))/g; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
82 var replaceText="<time>$1$2$3$4$5$6$7</time>"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
83 matchedCount += str.match(regexText).length; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
84 el.innerHTML = str.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
85 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
86 alert( "Tagged "+matchedCount+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
87 } |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
88 function removeEmptyNodes( node ) { |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
89 if (node.hasChildNodes()) { |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
90 var children = node.childNodes; |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
91 for (var i = 0; i < children.length; i++) { |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
92 if (children[i].textContent == "" && children[i].innerHTML == "" && children[i].nodeName != "BR") { |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
93 //console.log("removing child: "+children[i].nodeName+", its parent: "+node.nodeName); |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
94 node.removeChild(children[i]); |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
95 } else { |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
96 //console.log("recursive to "+children[i].nodeName+"("+children[i].textContent+")") |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
97 removeEmptyNodes(children[i]); // recursive |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
98 } |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
99 |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
100 }; |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
101 } else { |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
102 //console.log(node.nodeName+" ("+node.textContent+") has no childNodes."); |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
103 } |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
104 |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
105 } |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
106 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
107 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
108 function removeTagTitle( range, container ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
109 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
110 range.deleteContents(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
111 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
112 lastAddTag = $('#RemoveTitletagType').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
113 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
114 var stringtemp = container.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
115 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
116 if ( $('#RemoveTitletagName').val() == "" ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
117 var regexText="<"+lastAddTag+">〈(.*?)〉</"+lastAddTag+">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
118 var replaceText=""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
119 stringtemp = stringtemp.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
120 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
121 var regexText="<"+lastAddTag+">(.*?)</"+lastAddTag+">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
122 var replaceText="$1"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
123 stringtemp = stringtemp.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
124 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
125 var regexText="<"+lastAddTag+">〈"+$('#RemoveTitletagName').val()+"〉</"+lastAddTag+">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
126 var replaceText=""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
127 stringtemp = stringtemp.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
128 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
129 var regexText="<"+lastAddTag+">("+$('#RemoveTitletagName').val()+")</"+lastAddTag+">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
130 var replaceText="$1"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
131 stringtemp = stringtemp.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
132 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
133 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
134 var newdiv = document.createElement("aaaa"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
135 newdiv.innerHTML = stringtemp; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
136 range.insertNode(newdiv); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
137 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
138 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
139 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
140 var regexText=/<aaaa>/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
141 var replaceText=''; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
142 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
143 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
144 var regexText=/<\/aaaa>/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
145 var replaceText=''; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
146 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
147 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
148 $('.tagItemDivClass').remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
149 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
150 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
151 function addTagTitle( range, container ) { |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
152 // TODO: bug: here generate self-closing tag when the end of text with tag on it |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
153 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
154 saveUndoText(); |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
155 |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
156 var el = document.getElementById("editable-area"); |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
157 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
158 lastAddTag = $('#TitletagType').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
159 var tag = "<"+$('#TitletagType').val()+">〈"+$('#TitletagName').val()+"〉</"+$('#TitletagType').val()+">"; |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
160 |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
161 range.deleteContents(); // may causes self-closing tag |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
162 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
163 var stringtemp = container.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
164 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
165 var regexText=/<br>/g; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
166 var replaceText="<br>"+tag; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
167 stringtemp = stringtemp.replace(regexText, replaceText); |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
168 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
169 var newdiv = document.createElement("aaaa"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
170 newdiv.innerHTML = tag+stringtemp; |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
171 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
172 range.insertNode(newdiv); |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
173 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
174 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
175 var regexText=/<aaaa>/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
176 var replaceText=''; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
177 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
178 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
179 var regexText=/<\/aaaa>/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
180 var replaceText=''; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
181 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
182 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
183 $('.tagItemDivClass').remove(); |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
184 |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
185 removeEmptyNodes(el); // removing self-closing tags |
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
186 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
187 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
188 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
189 function cleanUpTextArea() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
190 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
191 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
192 var regexText=/<div>/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
193 var replaceText='<br>'; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
194 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
195 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
196 var regexText=/<\/div>/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
197 var replaceText=''; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
198 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
199 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
200 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
201 var regexText=/<span style="(.*?)">/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
202 var replaceText=''; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
203 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
204 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
205 var regexText=/<\/span>/gi; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
206 var replaceText=''; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
207 el.innerHTML = el.innerHTML.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
208 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
209 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
210 function Undo() { |
103 | 211 $("#loading").show(); |
212 | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
213 if ( stringBeforeChangeStack.length > 0 ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
214 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
215 el.innerHTML = stringBeforeChangeStack.pop(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
216 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
217 var el = document.getElementById("buttonUndo"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
218 el.disabled = true; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
219 } |
103 | 220 |
221 $("#loading").hide(); | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
222 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
223 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
224 function saveUndoText() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
225 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
226 //stringBeforeChange = el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
227 stringBeforeChangeStack.push(el.innerHTML); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
228 var el = document.getElementById("buttonUndo"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
229 el.disabled = false; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
230 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
231 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
232 function editText() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
233 var el = document.getElementById("editable-area"); |
100 | 234 if ( $("#editTextId").html() == "Edit text" ) { |
72
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
235 // --- in editing mode --- |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
236 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
237 el.contentEditable = true; |
72
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
238 |
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
239 // disable/close functions |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
240 $("button").attr("disabled", true); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
241 $("#editTextId").attr("disabled", false); |
72
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
242 $("#popups").css("display","none"); // close the popup windows |
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
243 $("input").attr('disabled', true); // disable input |
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
244 // clean editable-area |
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
245 $('.questionMarkClass').remove(); |
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
246 $('.tagItemDivClass').remove(); |
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
247 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
248 $("#editTextId").html("Edit completed!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
249 } else { |
72
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
250 // --- not editing mode --- |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
251 el.contentEditable = false; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
252 cleanUpTextArea(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
253 $("button").attr("disabled", false); |
72
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
254 $("#popups").css("display","block"); // open the popup windows |
6974309983d1
Bug fixed:1.remove tagging popup window on editable-area, 2.close/disable inputs and buttons, when entering edit-text mode.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
70
diff
changeset
|
255 $("input").attr('disabled', false); // enable input |
100 | 256 $("#editTextId").html("Edit text"); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
257 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
258 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
259 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
260 |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
261 function removeTagNewDiv( eventObject, tag, tagObject ) { |
93
a05491461199
bug fixed: solve the nested tagging issue
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
89
diff
changeset
|
262 saveUndoText(); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
263 |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
264 var newdiv = document.createElement("div"); |
93
a05491461199
bug fixed: solve the nested tagging issue
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
89
diff
changeset
|
265 //$(newdiv).id = "questionMarkId"; |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
266 $(newdiv).attr("class", "questionMarkClass"); |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
267 |
93
a05491461199
bug fixed: solve the nested tagging issue
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
89
diff
changeset
|
268 |
65
f9ae94a9b041
New: adding topic names: name_en, name_ch, name_pinyin
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
64
diff
changeset
|
269 // set z-index to 3 to bring popup tag windwo to front |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
270 newdiv.style.cssText = 'top:'+eventObject.pageY+'; left:'+eventObject.pageX+';'; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
271 |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
272 // find tag displaying name by tagName then showing in the innerHTML |
98
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
273 |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
274 var tag_name = getTagNameByTag(tag); |
98
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
275 // newdiv.innerHTML = "Tag: "+tag_name+"<br>Value: "+tagObject.text()+"<br>"; |
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
276 |
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
277 // TODO maybe also shown tag itself? |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
278 newdiv.innerHTML = "Tag: "+tag_name+"<br>Value: "+tagObject.text()+"<br>"; |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
279 |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
280 |
98
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
281 |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
282 var newbutton = $('<button class="btn btn-default">Remove this</button>').mouseup(function (e2) { |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
283 var textKeep = $(this).parent().parent().html(); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
284 var regexText=/<div(.*?)<\/div>/g; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
285 var replaceText=""; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
286 textKeep = textKeep.replace(regexText, replaceText); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
287 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
288 $(this).parent().parent().replaceWith( textKeep ); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
289 }); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
290 newbutton.appendTo(newdiv); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
291 |
99
c3e149277b58
modifications based on the docs 'Improving LGServices interface.docx'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
98
diff
changeset
|
292 var newbutton = $('<button class="btn btn-default">Remove this(with line break)</button>').mouseup(function (e2) { |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
293 var textKeep = $(this).parent().parent().html(); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
294 var regexText=/<div(.*?)<\/div>/g; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
295 var replaceText=""; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
296 textKeep = textKeep.replace(regexText, replaceText); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
297 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
298 var newLineBefore = $(this).parent().parent().prev(); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
299 if ( newLineBefore.prop("tagName") == "BR" ) { |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
300 $(this).parent().parent().prev().replaceWith( ); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
301 } |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
302 $(this).parent().parent().replaceWith( textKeep ); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
303 }); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
304 newbutton.appendTo(newdiv); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
305 |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
306 var newbutton = $('<button class="btn btn-default">Remove all</button>').mouseup(function (e2) { |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
307 var textKeep = $(this).parent().parent().html(); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
308 var regexText=/<div(.*?)<\/div>/g; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
309 var replaceText=""; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
310 textKeep = textKeep.replace(regexText, replaceText); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
311 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
312 $(this).parent().parent().replaceWith( textKeep ); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
313 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
314 var el = document.getElementById("editable-area"); |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
315 var regexText=new RegExp("<"+tag+">("+textKeep+")</"+tag+">", "g"); |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
316 var replaceText="$1"; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
317 var str="" + el.innerHTML; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
318 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
319 if ( str.match(regexText)==null ) { |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
320 alert( "Removed 1 entity!" ); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
321 } else { |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
322 alert( "Removed "+(parseInt(str.match(regexText).length)+1)+" entities!" ); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
323 } |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
324 el.innerHTML = str.replace(regexText, replaceText); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
325 }); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
326 newbutton.appendTo(newdiv); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
327 |
99
c3e149277b58
modifications based on the docs 'Improving LGServices interface.docx'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
98
diff
changeset
|
328 var newbutton = $('<button class="btn btn-default">Remove all(with line break)</button>').mouseup(function (e2) { |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
329 var textKeep = $(this).parent().parent().html(); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
330 var regexText=/<div(.*?)<\/div>/g; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
331 var replaceText=""; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
332 textKeep = textKeep.replace(regexText, replaceText); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
333 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
334 $(this).parent().remove(); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
335 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
336 var el = document.getElementById("editable-area"); |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
337 var regexText=new RegExp("<br><"+tag+">("+textKeep+")</"+tag+">", "g"); |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
338 var replaceText="$1"; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
339 var str="" + el.innerHTML; |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
340 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
341 alert( "Removed "+str.match(regexText).length+" entities!" ); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
342 el.innerHTML = str.replace(regexText, replaceText); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
343 }); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
344 newbutton.appendTo(newdiv); |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
345 |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
346 tagObject.append(newdiv); |
93
a05491461199
bug fixed: solve the nested tagging issue
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
89
diff
changeset
|
347 |
a05491461199
bug fixed: solve the nested tagging issue
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
89
diff
changeset
|
348 |
63
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
349 } |
3395385476d1
bug fixed: popup tag window is closed automatically when saving text file
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
54
diff
changeset
|
350 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
351 function saveText(section_id) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
352 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
353 $.ajax({ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
354 url : './'+section_id, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
355 async : false, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
356 type : 'POST', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
357 data : 'func=SaveFullText'+'&text='+encodeURIComponent(el.innerHTML)+'&filename='+section_id, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
358 // data : 'func=SaveFullText'+'&text='+el.innerHTML+'&filename='+section_id |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
359 success: function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
360 alert("Saved!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
361 }, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
362 error: function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
363 alert("Haven't saved!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
364 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
365 }).done(function(result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
366 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
367 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
368 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
369 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
370 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
371 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
372 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
373 function preg_quote (str, delimiter) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
374 // http://kevin.vanzonneveld.net |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
375 // + original by: booeyOH |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
376 // + improved by: Ates Goral (http://magnetiq.com) |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
377 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
378 // + bugfixed by: Onno Marsman |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
379 // + improved by: Brett Zamir (http://brett-zamir.me) |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
380 // * example 1: preg_quote("$40"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
381 // * returns 1: '\$40' |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
382 // * example 2: preg_quote("*RRRING* Hello?"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
383 // * returns 2: '\*RRRING\* Hello\?' |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
384 // * example 3: preg_quote("\\.+*?[^]$(){}=!<>|:"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
385 // * returns 3: '\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:' |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
386 return (str + '').replace(new RegExp('[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\' + (delimiter || '') + '-]', 'g'), '\\$&'); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
387 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
388 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
389 function replaceRegex() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
390 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
391 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
392 var startPage = $('#regexPageStart2').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
393 var endPage = $('#regexPageEnd2').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
394 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
395 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
396 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
397 var regexText=document.getElementById("regexText").value; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
398 var replaceText=document.getElementById("replaceText").value; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
399 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
400 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
401 if ( startPage == "" ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
402 alert( "Tagged "+str.match(new RegExp(regexText, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
403 el.innerHTML = str.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
404 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
405 var regexText2="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
406 var partString = ""+str.match(new RegExp(regexText2, "g")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
407 alert(partString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
408 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
409 alert( "Tagged "+partString.match(new RegExp(regexText, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
410 var resultString = partString.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
411 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
412 str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
413 el.innerHTML = str.replace(new RegExp(regexText, "g"), resultString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
414 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
415 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
416 //document.styleSheets[0].addRule("tag001", "color:green;") |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
417 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
418 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
419 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
420 //Tagging Items |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
421 function getSelected() { |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
422 if(window.getSelection) { // all browsers, except IE before version 9 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
423 return window.getSelection(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
424 } else if (document.getSelection) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
425 return document.getSelection(); |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
426 } else { // IE |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
427 var selection = document.selection && document.selection.createRange(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
428 if(selection.text) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
429 return selection.text; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
430 } |
54
f9e7119339b2
bug fixed: when addTagTitle, removing self-closing tag which causes error in coloring tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
50
diff
changeset
|
431 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
432 return false; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
433 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
434 return false; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
435 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
436 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
437 function tagStringWithTag( stringValue, tag ) { |
103 | 438 $('#loading').show(); |
439 | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
440 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
441 var el = document.getElementById("editable-area"); |
98
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
442 |
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
443 // TODO: bug? when stringValue contain already tag, it should be preserved |
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
444 |
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
445 console.log(stringValue); |
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
446 |
5bea390e7ca9
new: short tag in front of long tag
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
95
diff
changeset
|
447 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
448 var regexText="("+String(stringValue)+")"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
449 if ( tag=="person") { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
450 var replaceText="<br><"+tag+">$1</"+tag+">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
451 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
452 var replaceText="<"+tag+">$1</"+tag+">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
453 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
454 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
455 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
456 $('.tagItemDivClass').remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
457 alert( "Tagged "+str.match(new RegExp(regexText, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
458 el.innerHTML = str.replace(new RegExp(regexText, "g"), replaceText); |
103 | 459 |
460 $('#loading').hide(); | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
461 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
462 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
463 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
464 function tagwithtitle( range, stringSelection ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
465 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
466 range.deleteContents(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
467 //var newdiv = document.createElement("br"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
468 //range.insertNode(newdiv); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
469 range.insertNode(document.createTextNode("〈"+stringSelection+"〉")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
470 var newdiv = document.createElement("br"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
471 range.insertNode(newdiv); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
472 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
473 $('.tagItemDivClass').remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
474 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
475 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
476 function tagNameWithLastName() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
477 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
478 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
479 var regexText=/(○|】|^)(王|李|張|趙|劉|陳|楊|吳|黃|黄|朱|孫|郭|胡|呂|高|宋|徐|程|林|鄭|范|何|韓|曹|馬|許|田|馮|杜|周|曾|汪|蘇|董|方|蔡|梁|石|謝|賈|薛|彭|崔|唐|潘|鄧|史|錢|侯|魏|羅|葉|沈|孟|姚|傅|丁|章|蕭|蔣|盧|陸|袁|晁|譚|邵|歐陽|孔|詹|俞|尹|廖|閻|洪|夏|雷|葛|文|柳|陶|毛|丘|龔|蒲|邢|郝|龐|安|裴|折|施|游|金|鄒|湯|虞|嚴|鍾)([^○(舉人|縣人|歲貢|間任)]{1,3}|○[^○])(?=(○|$))/g; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
480 var replaceText="$1<br><person>$2$3</person>$4"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
481 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
482 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
483 alert( "Tagged "+str.match(regexText).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
484 el.innerHTML = str.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
485 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
486 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
487 function tagNameWithLastName2() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
488 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
489 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
490 var regexText="(○|】|^)("+$('#surname').val()+")([^○(舉人|縣人|歲貢|間任)]{1,3}|○[^○])(?=(○|$))"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
491 var replaceText="$1<br><person>$2$3</person>$4"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
492 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
493 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
494 alert( "Tagged "+str.match(new RegExp(regexText, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
495 el.innerHTML = str.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
496 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
497 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
498 function tagBiogAddr() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
499 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
500 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
501 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
502 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
503 var regexText=/(○)([^○]{1,6})(○?)(人)/g; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
504 var replaceText="$1<biog_addr>$2</biog_addr>$3$4"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
505 el.innerHTML = str.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
506 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
507 alert( "Tagged "+str.match(regexText).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
508 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
509 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
510 function smartRegexNew() { |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
511 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
512 var popup_status = $('#smartRegexPopUpDiv').css("display"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
513 if (popup_status == "block") { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
514 $('#smartRegexPopUpDiv').css("display", "none"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
515 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
516 $('#smartRegexPopUpDiv').css("display", "block"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
517 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
518 |
66
e71a437ae49f
New: responsive. some css style
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
65
diff
changeset
|
519 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
520 $('#smartRegexPopUpAdd').attr("disabled", false); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
521 $('#smartRegexPopUpEdit').attr("disabled", "disabled"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
522 $('#smartRegexPopUpDel').attr("disabled", "disabled"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
523 $('#smartRegexPopUpBack').attr("disabled", "disabled"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
524 $('#smartRegexPopUpFor').attr("disabled", "disabled"); |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
525 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
526 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
527 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
528 function replaceSmartClose() { |
70
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
529 $('#smartRegexShowDiv > span').css("border","1px solid black"); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
530 $('#smartRegexPopUpDiv').css("display", "none"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
531 $("#smartRegexPopUpSelectWord").val("NULL"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
532 $("#smartRegexPopUpText").val(""); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
533 $("#smartRegexPopUpName").val(""); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
534 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
535 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
536 function replaceSmartEdit(){ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
537 thisObject = $('#smartRegexPopUpDiv').attr("editID"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
538 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
539 $('#smartRegexShowDiv > #'+thisObject).attr("class", "span_"+$("#smartRegexPopUpSelectTag").val()); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
540 $('#smartRegexShowDiv > #'+thisObject).attr("regexText", $("#smartRegexPopUpText").val()); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
541 $('#smartRegexShowDiv > #'+thisObject).attr("regexReplace", $("#smartRegexPopUpSelectTag").val()); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
542 $('#smartRegexShowDiv > #'+thisObject).text($("#smartRegexPopUpName").val()); // smartRgextPopUpName.val() is the name of this regex |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
543 // id should be the same as it was |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
544 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
545 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
546 function replaceSmartDel() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
547 thisObject = $('#smartRegexPopUpDiv').attr("editID"); |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
548 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
549 $('#smartRegexShowDiv > #'+thisObject).remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
550 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
551 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
552 function replaceSmartFor() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
553 thisObject = $('#smartRegexPopUpDiv').attr("editID"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
554 //var wahaha = $('#'+thisObject).clone(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
555 //var hahawa = $('#'+thisObject).next(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
556 //$('#'+thisObject).remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
557 //wahaha.insertAfter(hahawa); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
558 $('#smartRegexShowDiv > #'+thisObject).insertAfter( $('#'+thisObject).next() ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
559 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
560 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
561 function replaceSmartBack() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
562 thisObject = $('#smartRegexPopUpDiv').attr("editID"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
563 //var wahaha = $('#'+thisObject).clone(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
564 //var hahawa = $('#'+thisObject).prev(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
565 //$('#'+thisObject).remove(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
566 //wahaha.insertBefore(hahawa); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
567 $('#smartRegexShowDiv > #'+thisObject).insertBefore( $('#'+thisObject).prev() ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
568 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
569 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
570 function replaceSmartAdd() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
571 var newdiv = document.createElement("span"); |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
572 //newdiv.innerHTML = " "+$("#smartRegexPopUpName").val()+" "; |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
573 //newdiv.innerHTML = $("#smartRegexPopUpName").val(); |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
574 $(newdiv).text($("#smartRegexPopUpName").val()); |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
575 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
576 $(newdiv).css("border", "1px solid black"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
577 $(newdiv).css("width", "100px"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
578 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
579 $(newdiv).attr("class", "span_"+$("#smartRegexPopUpSelectTag").val()); |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
580 |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
581 |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
582 |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
583 // id is the name from user's input, which dose not guarantee to be unique |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
584 // id should be unique |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
585 regex_element_index += 1; |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
586 $(newdiv).attr("id", "regex_elem_"+regex_element_index); |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
587 // $(newdiv).attr("id", "span_"+$("#smartRegexPopUpName").val()); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
588 $(newdiv).attr("regexText", $("#smartRegexPopUpText").val()); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
589 $(newdiv).attr("regexReplace", $("#smartRegexPopUpSelectTag").val()); |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
590 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
591 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
592 $('#smartRegexShowDiv').append(newdiv); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
593 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
594 replaceSmartClose(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
595 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
596 |
95 | 597 $(document).keyup(function(e) { |
598 if (e.keyCode == 27) { // escape key maps to keycode `27` | |
599 // close popups | |
600 $('#load_topic_div').css("display", "none"); | |
601 $('#new_topic_div').css("display", "none"); | |
602 $('#load_regex_div').css("display", "none"); | |
603 $('#regex_generator').css("display", "none"); | |
604 $('#smartRegexPopUpDiv').css("display", "none"); | |
605 $('.questionMarkClass').css("display", "none"); | |
606 $('.tagItemDivClass').css("display", "none"); | |
607 } | |
608 }); | |
609 | |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
610 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
611 $(document).on("click", '#smartRegexShowDiv > span', function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
612 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
613 $('#smartRegexPopUpDiv').css("display", "block"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
614 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
615 $('#smartRegexPopUpDiv').attr("editID", $(this).attr("id")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
616 |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
617 $('#smartRegexPopUpName').val($(this).text()); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
618 // $('#smartRegexPopUpName').val($(this).html()); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
619 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
620 $('#smartRegexPopUpText').val($(this).attr("regexText")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
621 $('#smartRegexPopUpSelectTag').val($(this).attr("regexReplace")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
622 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
623 $('#smartRegexPopUpAdd').attr("disabled", "disabled"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
624 $('#smartRegexPopUpEdit').attr("disabled", false); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
625 $('#smartRegexPopUpDel').attr("disabled", false); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
626 $('#smartRegexPopUpBack').attr("disabled", false); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
627 $('#smartRegexPopUpFor').attr("disabled", false); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
628 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
629 |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
630 function genRegexWindowOpen(){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
631 var btn_state = $('#regex_generator').css('display'); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
632 if (btn_state == "block") { |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
633 genRegexWindowClose(); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
634 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
635 $('#regex_generator').css("display", "block"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
636 $("#gen_regex_window_open_id").text("Close Gen Regex"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
637 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
638 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
639 function genRegexWindowClose(){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
640 $('#regex_generator').css("display", "none"); |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
641 $("#gen_regex_window_open_id").text("Open Gen Regex"); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
642 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
643 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
644 function sharedStart_(array){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
645 var A= array.concat().sort(), |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
646 a1= A[0], a2= A[A.length-1], L= a1.length, i= 0; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
647 while(i<L && a1.charAt(i)=== a2.charAt(i)) i++; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
648 return a1.substring(0, i); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
649 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
650 |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
651 function getTagNameByTag(tag){ |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
652 var name = ""; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
653 // taglistArray is a global variable |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
654 for (var i = 0; i < taglistArray.length; i++) { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
655 var taglistValue = taglistArray[i]; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
656 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
657 var _tag = taglistValue[2]; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
658 var _name = taglistValue[1]; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
659 if (_tag == tag) { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
660 name = _name; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
661 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
662 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
663 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
664 return name; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
665 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
666 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
667 function genRegexAddToSmartRegex() { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
668 // append blocks of generated regex to smart regex |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
669 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
670 smartRegexEmpty(); // clear |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
671 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
672 var reg_obj = getSuggestedRegex(); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
673 console.log(reg_obj); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
674 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
675 for (var i = 0; i < reg_obj.length; i++) { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
676 if (reg_obj[i].txt != "") { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
677 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
678 var newdiv = document.createElement("span"); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
679 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
680 $(newdiv).css("border", "1px solid black"); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
681 $(newdiv).css("width", "100px"); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
682 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
683 if (reg_obj[i].tag == null) { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
684 if (reg_obj[i].txt == "○") { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
685 $(newdiv).text("空白"); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
686 } else { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
687 $(newdiv).text(reg_obj[i].txt); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
688 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
689 $(newdiv).attr("class", "span_NOTAG"); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
690 $(newdiv).attr("regexReplace","NOTAG"); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
691 } else { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
692 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
693 var name = getTagNameByTag(reg_obj[i].tag); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
694 $(newdiv).text(name+"名"); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
695 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
696 $(newdiv).attr("class", "span_"+reg_obj[i].tag); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
697 $(newdiv).attr("regexReplace", reg_obj[i].tag); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
698 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
699 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
700 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
701 regex_element_index += 1; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
702 $(newdiv).attr("id", "regex_elem_"+regex_element_index); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
703 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
704 $(newdiv).attr("regexText", reg_obj[i].txt); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
705 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
706 $('#smartRegexShowDiv').append(newdiv); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
707 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
708 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
709 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
710 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
711 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
712 |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
713 function longestCommonSubstring_(string1, string2){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
714 // init max value |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
715 var longestCommonSubstring = 0; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
716 // init 2D array with 0 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
717 var table = [], |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
718 len1 = string1.length, |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
719 len2 = string2.length, |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
720 row, col; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
721 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
722 for(row = 0; row <= len1; row++){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
723 table[row] = []; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
724 for(col = 0; col <= len2; col++){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
725 table[row][col] = 0; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
726 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
727 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
728 // fill table |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
729 var i, j; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
730 for(i = 0; i < len1; i++){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
731 for(j = 0; j < len2; j++){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
732 if(string1[i]==string2[j]){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
733 if(table[i][j] == 0){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
734 table[i+1][j+1] = 1; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
735 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
736 table[i+1][j+1] = table[i][j] + 1; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
737 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
738 if(table[i+1][j+1] > longestCommonSubstring){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
739 longestCommonSubstring = table[i+1][j+1]; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
740 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
741 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
742 table[i+1][j+1] = 0; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
743 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
744 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
745 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
746 return longestCommonSubstring; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
747 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
748 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
749 function longestCommonSubstring(s1, s2) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
750 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
751 var start_idx = 0; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
752 var max_len = 0; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
753 for (var i = 0; i < s1.length; i++) |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
754 { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
755 for (var j = 0; j < s2.length; j++) |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
756 { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
757 var x = 0; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
758 while (s1.charAt(i + x) == s2.charAt(j + x)) |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
759 { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
760 x++; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
761 if ((i + x) >= s1.length || ((j + x) >= s2.length)) |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
762 break; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
763 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
764 if (x > max_len) |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
765 { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
766 max_len = x; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
767 start_idx = i; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
768 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
769 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
770 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
771 return s1.substring(start_idx, (start_idx + max_len)); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
772 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
773 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
774 |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
775 var suggestedRegex = []; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
776 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
777 function setSuggestedRegex(_pattern) { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
778 /* |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
779 console.log(_pattern[0]); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
780 console.log(_pattern[1]); |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
781 */ |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
782 var p0 = _pattern[0]; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
783 var p1 = _pattern[1]; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
784 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
785 // TODO: find common pattern |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
786 suggestedRegex = []; // it's a global variable |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
787 |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
788 if (p0.length > p1.length) { |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
789 suggestedRegex = p0; |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
790 } else if(p0.length < p1.length) { |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
791 suggestedRegex = p1; |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
792 } else { // equal length |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
793 // find matching string |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
794 var cnt = p0.length; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
795 for (var i = 0; i < cnt; i++) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
796 if (p1[i].tag != null) { |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
797 suggestedRegex.push({tag:p1[i].tag, txt:"[^○如即而之有<>〈〉【】]{1,"+p1[i].txt.length+"}"}); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
798 } else if (p0[i].tag != null) { |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
799 suggestedRegex.push({tag:p0[i].tag, txt:"[^○如即而之有<>〈〉【】]{1,"+p0[i].txt.length+"}"}); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
800 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
801 // find matching for text in each corresponding position |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
802 var texts = [p0[i].txt, p1[i].txt]; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
803 var common = longestCommonSubstring(p0[i].txt, p1[i].txt); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
804 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
805 /* |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
806 var reg_for_common = "["; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
807 for (var i = 0; i < common.length; i++) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
808 common[i]; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
809 reg_for_common += common[i]+"|"; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
810 }; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
811 reg_for_common += "]"; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
812 */ |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
813 suggestedRegex.push({tag:null, txt:common}); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
814 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
815 }; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
816 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
817 |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
818 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
819 } |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
820 |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
821 function getSuggestedRegex(){ |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
822 return suggestedRegex; |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
823 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
824 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
825 var pattern_obj = []; // record pattern array for regex generator. only contain pattern1 and pattern2 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
826 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
827 function genRegexBySelection(tag_item_div, _selection) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
828 var add_gen_regex_button = document.createElement("button"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
829 $(add_gen_regex_button).id = "addToGenRegex"; |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
830 $(add_gen_regex_button).addClass("btn btn-xs btn-default"); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
831 $(add_gen_regex_button).click( function(){ |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
832 // popup for selected words regex gen |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
833 /* |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
834 console.log("Debug: "); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
835 console.log(_selection); |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
836 */ |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
837 |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
838 if (_selection.type == "Range") { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
839 // select words, not just click on text |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
840 var anchor_node = _selection.anchorNode; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
841 var focus_node = _selection.focusNode; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
842 var sibling_node = anchor_node.nextElementSibling; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
843 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
844 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
845 if (anchor_node && sibling_node && focus_node && container.innerHTML.indexOf( "br" ) == -1) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
846 // Chrome can work on this. |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
847 // Safari does not support some of the member in selection object |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
848 // container.innerHTML.indexOf( "br" ) == -1: selection does not contain br. |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
849 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
850 var seleted_div = document.createElement("div"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
851 var seleted_obj = []; // array for selected text as well as its tag if it has any |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
852 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
853 if (anchor_node == focus_node ) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
854 // selected text in plain text |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
855 var text_all = anchor_node.textContent; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
856 var text_ = text_all.substring(_selection.anchorOffset, _selection.focusOffset); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
857 $(seleted_div).text(text_); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
858 seleted_obj.push({tag:null, txt:text_}); // push object into array |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
859 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
860 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
861 // selected text contain tags |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
862 var text_before = anchor_node.textContent.substring(_selection.anchorOffset, anchor_node.length); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
863 var tag_name = sibling_node.nodeName.toLowerCase(); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
864 var tagged_text = sibling_node.textContent; |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
865 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
866 var text_after = _selection.focusNode.textContent.substring(0, _selection.focusOffset); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
867 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
868 $(seleted_div).text(text_before+tagged_text+text_after); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
869 seleted_obj.push({tag:null, txt:text_before}); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
870 seleted_obj.push({tag:tag_name, txt:tagged_text}); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
871 seleted_obj.push({tag:null, txt:text_after}); |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
872 /* |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
873 console.log(text_before); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
874 console.log(tag_name); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
875 console.log(tagged_text); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
876 console.log(text_after); |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
877 */ |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
878 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
879 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
880 |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
881 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
882 var generated_regex_plaintext = ""; |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
883 // show generate regex window |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
884 $('#regex_generator').css("display", "block"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
885 $("#gen_regex_window_open_id").text("Close Gen Regex"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
886 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
887 //var seleted_text = String(_selection).replace(/^\s+|\s+$/g,''); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
888 var pattern1 = $('#regex_pattern1'); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
889 var pattern2 = $('#regex_pattern2'); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
890 if (pattern1.children().length == 0) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
891 pattern1.append(seleted_div); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
892 pattern_obj.push(seleted_obj); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
893 // pattern1.text(seleted_div.text()); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
894 } else if (pattern2.children().length == 0) { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
895 pattern2.append(seleted_div); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
896 pattern_obj.push(seleted_obj); |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
897 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
898 setSuggestedRegex(pattern_obj); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
899 var generated_regex = getSuggestedRegex(); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
900 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
901 // get plaintext from generated_regex obj |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
902 for (var i = 0; i < generated_regex.length; i++) { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
903 generated_regex_plaintext += generated_regex[i].txt; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
904 } |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
905 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
906 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
907 // pattern1 and pattern2 are already having text |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
908 pattern1.children().remove(); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
909 pattern1.append(pattern2.children()); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
910 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
911 pattern2.children().remove(); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
912 pattern2.append(seleted_div); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
913 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
914 pattern_obj.shift(); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
915 pattern_obj.push(seleted_obj); |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
916 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
917 setSuggestedRegex(pattern_obj); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
918 var generated_regex = getSuggestedRegex(); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
919 |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
920 // get plaintext from generated_regex obj |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
921 for (var i = 0; i < generated_regex.length; i++) { |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
922 generated_regex_plaintext += generated_regex[i].txt; |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
923 } |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
924 |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
925 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
926 } |
89
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
927 //$('#generated_regex').text(generated_regex); |
e681d693240e
new: generated regex to SmartRegex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
87
diff
changeset
|
928 $('#generated_regex').text(generated_regex_plaintext); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
929 // --- |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
930 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
931 $('#regex_generator_error_msg').text(""); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
932 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
933 $('#regex_generator_error_msg').text("Note: Not a valid selection for regex generator."); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
934 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
935 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
936 $('.tagItemDivClass').remove(); // close the tag window |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
937 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
938 } else if (_selection.type == "Caret") { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
939 // TODO: click on tagged text case rather than select |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
940 // If do this process, also need to consider between browers since not all of them support |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
941 // and also need to modify pop_remove_tag_window |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
942 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
943 }); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
944 |
94
b0cecc104639
new: modified tags can work on tagged text
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
93
diff
changeset
|
945 $(add_gen_regex_button).text("Add to Gen Regex (developing...)"); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
946 tag_item_div.appendChild(add_gen_regex_button); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
947 } |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
948 |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
949 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
950 function smartRegexEmpty() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
951 $('#smartRegexShowDiv').html(""); |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
952 regex_element_index = 0; |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
953 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
954 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
955 function replaceSmartRunWithBr() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
956 |
103 | 957 $("#loading").show(); |
958 | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
959 var replaceSmartRegexString = ""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
960 var replaceSmartReplaceString = ""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
961 var count=1; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
962 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
963 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
964 |
80
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
965 // skip everything inside "【】", including "【】". // (【([^【】])*】) //(【.*】) |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
966 replaceSmartRegexString += "(【[^【】]+(?!.*})】)*"; |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
967 replaceSmartReplaceString += "$"+count; |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
968 count ++; |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
969 // --- |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
970 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
971 $('#smartRegexShowDiv').children('span').each(function () { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
972 replaceSmartRegexString += "(" + $(this).attr("regexText") + ")"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
973 if ( $(this).attr("regexReplace") == "notag" || $(this).attr("regexReplace") == "NOTAG") { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
974 replaceSmartReplaceString += "$" + count; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
975 } else if ( $(this).attr("regexReplace") == "title" ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
976 replaceSmartReplaceString += "<br>〈" + "$" + count + "〉<br>"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
977 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
978 // with <br> before |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
979 replaceSmartReplaceString += "<br><" + $(this).attr("regexReplace") + ">" + "$" + count + "</"+ $(this).attr("regexReplace") +">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
980 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
981 count++; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
982 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
983 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
984 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
985 var startPage = $('#regexPageStart').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
986 var endPage = $('#regexPageEnd').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
987 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
988 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
989 |
106
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
990 // if there's no match || the it's a null object.. |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
991 if (str.match(new RegExp(replaceSmartRegexString, "g")) == null) { |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
992 alert( "Tagged 0 entity!" ); |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
993 |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
994 } else if ( startPage == "" ) { |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
995 alert( "Tagged "+str.match(new RegExp(replaceSmartRegexString, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
996 el.innerHTML = str.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
997 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
998 var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
999 var partString = ""+str.match(new RegExp(regexText, "g")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1000 alert(partString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1001 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1002 alert( "Tagged "+partString.match(new RegExp(replaceSmartRegexString, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1003 var resultString = partString.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1004 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1005 str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1006 el.innerHTML = str.replace(new RegExp(regexText, "g"), resultString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1007 } |
103 | 1008 |
1009 $("#loading").hide(); | |
1010 | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1011 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1012 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1013 function replaceSmartRun() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1014 |
103 | 1015 $("#loading").show(); |
1016 | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1017 var replaceSmartRegexString = ""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1018 var replaceSmartReplaceString = ""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1019 var count=1; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1020 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1021 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1022 |
80
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
1023 // skip everything inside "【】", including "【】". |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
1024 replaceSmartRegexString += "(【[^【】]+(?!.*})】)*"; |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
1025 replaceSmartReplaceString += "$"+count; |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
1026 count ++; |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
1027 // --- |
c15f53afd7a5
Bug fixed: skiping everything inside '??', including '??'
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
77
diff
changeset
|
1028 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1029 $('#smartRegexShowDiv').children('span').each(function () { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1030 replaceSmartRegexString += "(" + $(this).attr("regexText") + ")"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1031 if ( $(this).attr("regexReplace") == "notag" || $(this).attr("regexReplace") == "NOTAG" ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1032 replaceSmartReplaceString += "$" + count; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1033 } else if ( $(this).attr("regexReplace") == "title" ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1034 replaceSmartReplaceString += "<br>〈" + "$" + count + "〉<br>"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1035 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1036 replaceSmartReplaceString += "<" + $(this).attr("regexReplace") + ">" + "$" + count + "</"+ $(this).attr("regexReplace") +">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1037 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1038 count++; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1039 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1040 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1041 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1042 var startPage = $('#regexPageStart').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1043 var endPage = $('#regexPageEnd').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1044 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1045 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1046 |
106
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1047 // if there's no match || the it's a null object.. |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1048 if (str.match(new RegExp(replaceSmartRegexString, "g")) == null) { |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1049 alert( "Tagged 0 entity!" ); |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1050 |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1051 } else if ( startPage == "" ) { |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1052 alert( "Tagged "+str.match(new RegExp(replaceSmartRegexString, "g")).length+" entities!" ); |
106
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1053 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1054 el.innerHTML = str.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1055 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1056 var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1057 var partString = ""+str.match(new RegExp(regexText, "g")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1058 alert(partString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1059 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1060 alert( "Tagged "+partString.match(new RegExp(replaceSmartRegexString, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1061 var resultString = partString.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1062 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1063 str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1064 el.innerHTML = str.replace(new RegExp(regexText, "g"), resultString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1065 } |
103 | 1066 |
1067 $("#loading").hide(); | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1068 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1069 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1070 function replaceSmartRunSpace() { |
103 | 1071 |
1072 $("#loading").show(); | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1073 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1074 var replaceSmartRegexString = ""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1075 var replaceSmartReplaceString = ""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1076 var count=1; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1077 saveUndoText(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1078 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1079 $('#smartRegexShowDiv').children('span').each(function () { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1080 //alert($(this).attr("regexText")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1081 replaceSmartRegexString += "(" + $(this).attr("regexText") + ")(○*)"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1082 if ( $(this).attr("regexReplace") == "notag" || $(this).attr("regexReplace") == "NOTAG") { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1083 replaceSmartReplaceString += "$" + count; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1084 } else if ( $(this).attr("regexReplace") == "title" ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1085 replaceSmartReplaceString += "<br>〈" + "$" + count + "〉<br>"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1086 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1087 replaceSmartReplaceString += "<" + $(this).attr("regexReplace") + ">" + "$" + count + "</"+ $(this).attr("regexReplace") +">"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1088 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1089 count++; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1090 replaceSmartReplaceString += "$" + count; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1091 count++; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1092 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1093 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1094 var startPage = $('#regexPageStart').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1095 var endPage = $('#regexPageEnd').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1096 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1097 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1098 |
106
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1099 // if there's no match || the it's a null object.. |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1100 if (str.match(new RegExp(replaceSmartRegexString, "g")) == null) { |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1101 alert( "Tagged 0 entity!" ); |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1102 |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1103 } else if ( startPage == "" ) { |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1104 alert( "Tagged "+str.match(new RegExp(replaceSmartRegexString, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1105 el.innerHTML = str.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1106 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1107 var regexText="【<a([^<>]*?)>"+startPage+"</a>】(.*?)【<a([^<>]*?)>"+endPage+"</a>】"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1108 var partString = ""+str.match(new RegExp(regexText, "g")); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1109 alert(partString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1110 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1111 alert( "Tagged "+partString.match(new RegExp(replaceSmartRegexString, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1112 var resultString = partString.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1113 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1114 str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1115 el.innerHTML = str.replace(new RegExp(regexText, "g"), resultString); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1116 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1117 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1118 //alert( "Tagged "+str.match(new RegExp(replaceSmartRegexString, "g")).length+" entities!" ); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1119 //el.innerHTML = str.replace(new RegExp(replaceSmartRegexString, "g"), replaceSmartReplaceString); |
103 | 1120 |
1121 $("#loading").hide(); | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1122 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1123 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1124 function smartRegexSave(topic_id) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1125 console.log("topic_id"+topic_id); |
81 | 1126 |
1127 var today = new Date(); | |
1128 var minute = today.getMinutes(); | |
1129 var hour = today.getHours(); | |
1130 var dd = today.getDate(); | |
1131 var mm = today.getMonth()+1; //January is 0! | |
1132 var yyyy = today.getFullYear(); | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1133 |
81 | 1134 if(dd<10) { |
1135 dd='0'+dd | |
1136 } | |
1137 if(mm<10) { | |
1138 mm='0'+mm | |
1139 } | |
1140 if (hour<10) { | |
1141 hour='0'+hour; | |
1142 } | |
1143 if (minute<10) { | |
1144 minute='0'+minute; | |
1145 } | |
1146 today = hour+'_'+minute+'_'+dd+'_'+mm+'_'+yyyy; | |
1147 | |
1148 var name=prompt("Please enter this Regex name", RegexLoadedName+"_"+today); | |
1149 | |
106
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1150 |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1151 |
81 | 1152 if (name!=null && name != ''){ |
106
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1153 |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1154 // the name not allowed to contain " ", "(", ")" |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1155 if (name.indexOf(' ') >= 0 || name.indexOf('(') >= 0 || name.indexOf(')') >= 0) { |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1156 |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1157 alert("Save Regex Failed.\nPlease don't use space or '(' or ')' in the name. Consider to use '-' or '_' instead. "); |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1158 return; |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1159 } |
6de4932d993b
bug fixed: prevent page halted bcuz the null tagging result from Regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
103
diff
changeset
|
1160 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1161 $.ajax({ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1162 type : 'POST', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1163 url : './TaggingText', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1164 async : false, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1165 data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name+'&topic_id='+topic_id, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1166 error: function (result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1167 alert("Error"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1168 }, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1169 success: function (result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1170 var obj = jQuery.parseJSON(result); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1171 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1172 if (obj == "ErrorDB") { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1173 alert("Error when saving to database!!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1174 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1175 } else if (obj == "ForceSave") { |
81 | 1176 var retVal = confirm("Danger! You will over write the previous regex file. Do you want to proceed?"); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1177 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1178 if( retVal == true ){ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1179 // update regex file |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1180 $.ajax({ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1181 type : 'POST', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1182 url : './TaggingText', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1183 async : false, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1184 data : 'func=SmartRegexSave'+'&text='+encodeURIComponent($('#smartRegexShowDiv').html())+'&filename='+name+'&topic_id='+topic_id+'&forcesave=1', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1185 error: function (result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1186 alert("Error"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1187 }, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1188 success: function (result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1189 alert("Update regex file."); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1190 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1191 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1192 }else{ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1193 alert("You have not saved the regex file."); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1194 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1195 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1196 } else { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1197 alert("Saved!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1198 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1199 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1200 }).done(function(result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1201 }); |
81 | 1202 } else { |
1203 alert("You haven't saved it."); | |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1204 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1205 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1206 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1207 function smartRegexLoad(topic_id) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1208 $('#load_regex_div').html(""); |
87
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
1209 var popup_status = $('#load_regex_div').css("display"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
1210 if (popup_status == "block") { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
1211 $('#load_regex_div').css("display", "none"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
1212 } else { |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
1213 $('#load_regex_div').css("display", "block"); |
fb5049fc5dd7
New:(1)UI(2)generate simple regex by examples(3)coordinates in book metadata
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
81
diff
changeset
|
1214 } |
66
e71a437ae49f
New: responsive. some css style
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
65
diff
changeset
|
1215 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1216 var newselect = document.createElement("select"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1217 newselect.id = "loadRegexSelect"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1218 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1219 $.ajax({ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1220 type: 'POST', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1221 url: './TaggingText', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1222 dataType: 'json', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1223 data: "func=SmartRegexLoad&topic_id="+topic_id, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1224 //cache: false, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1225 success: function (data) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1226 $.each(data, function(index, element) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1227 // index is the filename (without '.txt') |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1228 // element is the content in the file |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1229 newselect.innerHTML += "<option value=\""+index+"\">"+index+"</option>\n"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1230 //alert(index); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1231 //alert(element); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1232 var newdiv = document.createElement("div"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1233 $(newdiv).css("display", "none"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1234 $(newdiv).html(element); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1235 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1236 $(newdiv).attr("id", "div_"+index); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1237 $('#load_regex_div').append(newdiv); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1238 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1239 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1240 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1241 }, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1242 error: function (data) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1243 console.log("SmartRegexLoad fails"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1244 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1245 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1246 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1247 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1248 /* |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1249 $.ajax({ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1250 type: 'POST', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1251 url: '../models/_extractapp_func.php', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1252 dataType: 'json', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1253 data: "func=SmartRegexLoad", |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1254 //cache: false, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1255 success: function (data) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1256 $.each(data, function(index, element) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1257 newselect.innerHTML += "<option value=\""+index+"\">"+index+"</option>\n"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1258 //alert(index); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1259 //alert(element); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1260 var newdiv = document.createElement("div"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1261 $(newdiv).css("display", "none"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1262 $(newdiv).html(element); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1263 $(newdiv).attr("id", "div_"+index); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1264 $('#load_regex_div').append(newdiv); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1265 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1266 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1267 }, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1268 error: function (data) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1269 console.log("SmartRegexLoad fails"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1270 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1271 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1272 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1273 */ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1274 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1275 $('#load_regex_div').append(newselect); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1276 var newbutton = document.createElement("button"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1277 $(newbutton).html("Load"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1278 $(newbutton).addClass("btn btn-info"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1279 $(newbutton).attr("onclick", "loadRegexAdd()"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1280 $('#load_regex_div').append(newbutton); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1281 var newbutton = document.createElement("button"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1282 $(newbutton).html("Close"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1283 $(newbutton).addClass("btn btn-default"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1284 $(newbutton).attr("onclick", "$('#load_regex_div').css(\"display\", \"none\");"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1285 $('#load_regex_div').append(newbutton); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1286 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1287 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1288 var RegexLoadedName = ""; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1289 function loadRegexAdd() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1290 RegexLoadedName = $('#loadRegexSelect').val(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1291 var divName = "#div_"+RegexLoadedName; |
70
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1292 var regex_content = $(divName).html(); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1293 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1294 $('#smartRegexShowDiv').html(regex_content); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1295 $('#load_regex_div').css("display", "none"); |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1296 |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1297 // get the largest regex element index in the regex file |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1298 // for all children (span) in #smartRegexShowDiv, find MAX(id) |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1299 var regex_elem = $('#smartRegexShowDiv').children(); |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1300 var max_id = 0; |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1301 for (var i = 0; i < regex_elem.length; i++) { |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1302 var r_id = parseInt(regex_elem[i].id.slice(11)); // cut the first 11 char out: "regex_elem_" |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1303 if (r_id > max_id) { |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1304 max_id = r_id; |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1305 } |
70
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1306 |
50
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1307 } |
3e42a63de0ea
bug fix: unique regex element id, edit/update/delete regex
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
49
diff
changeset
|
1308 regex_element_index = max_id; |
70
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1309 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1310 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1311 // hover on #smartRegexShowDiv > span, change border width |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1312 $("#smartRegexShowDiv > span").hover( function() { |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1313 // hover in |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1314 $(this).css("border","3px solid black"); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1315 }, function() { |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1316 // hover out |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1317 // TODO: if this is clicked... |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1318 $(this).css("border","1px solid black"); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1319 }); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1320 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1321 /* |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1322 // TODO: click |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1323 $("#smartRegexShowDiv > span").click( function() { |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1324 $(this).css("border","3px double black"); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1325 console.log("Debug: clicked"); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1326 }); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1327 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1328 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1329 $('#smartRegexShowDiv > span').on({ |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1330 mouseover: function(){ |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1331 $(this).css("border","3px solid black"); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1332 }, |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1333 mouseleave: function(){ |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1334 $(this).css("border","1px solid black"); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1335 }, |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1336 click: function(){ |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1337 $(this).off('mouseleave'); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1338 } |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1339 }); |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1340 */ |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1341 } |
70
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1342 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1343 |
359f48d58cbc
New: hover on regex elem
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
66
diff
changeset
|
1344 |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1345 // === |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1346 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1347 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1348 // === for editwordlist.php === |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1349 function addNewList() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1350 var el = document.getElementById("listNameText"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1351 $.ajax({ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1352 //url : '../../models/_extractapp_func.php', |
49
b2c1fae5cf6a
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
1353 url : './EditWordlist', |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1354 async : false, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1355 type : 'POST', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1356 data : 'func=AddNewList'+'&text='+el.value, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1357 success: function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1358 alert("Added!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1359 document.location.reload(true); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1360 }, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1361 error: function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1362 console.log("error when add new list"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1363 alert("Haven't added new list!!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1364 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1365 }).done(function(result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1366 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1367 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1368 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1369 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1370 function saveWordlist(id ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1371 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1372 $.ajax({ |
49
b2c1fae5cf6a
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
47
diff
changeset
|
1373 url : './EditWordlist', |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1374 async : false, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1375 type : 'POST', |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1376 data : 'func=SaveWordlist'+'&text='+el.innerHTML+'&filename='+id, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1377 success: function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1378 alert("Saved!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1379 }, |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1380 error: function (e) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1381 alert("Haven't saved!"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1382 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1383 }).done(function(result) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1384 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1385 }); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1386 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1387 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1388 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1389 function editWordlistText( id ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1390 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1391 el.contentEditable = true; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1392 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1393 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1394 function replaceRegex() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1395 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1396 var regexText=document.getElementById("regexText").value; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1397 var replaceText=document.getElementById("replaceText").value; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1398 var str="" + el.innerHTML; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1399 el.innerHTML = str.replace(new RegExp(regexText, "g"), replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1400 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1401 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1402 function showListContent( id ) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1403 var xhr = new XMLHttpRequest(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1404 xhr.onreadystatechange = process; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1405 xhr.open("POST", "../data/wordlist/"+id+".txt?t=" + Math.random(), true); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1406 // TODO: should show the latest wordlist file. eg. id_timestamp.txt, rather than open the original id.txt file |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1407 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1408 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1409 xhr.send(); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1410 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1411 function process() { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1412 if (xhr.readyState == 4) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1413 var el = document.getElementById("editable-area"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1414 var str = xhr.responseText |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1415 var regexText=/\n/g; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1416 var replaceText="<br>\n"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1417 el.innerHTML = str.replace(regexText, replaceText); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1418 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1419 document.getElementById("button-area").innerHTML= |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1420 "<form action=\"javascript:void(0);\"> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1421 <fieldset><legend>Edit:</legend> \ |
100 | 1422 <button id=\"buttonEditText\" onclick=\"editWordlistText("+id+")\" style=\"height: 30px; width: 220px\">Edit text</button></br> \ |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1423 <button id=\"buttonSaveText\" onclick=\"saveWordlist("+id+")\" style=\"height: 30px; width: 220px\">Save the text</button> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1424 </fieldset> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1425 <fieldset><legend>Replace By Regex:</legend> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1426 Regex: <input type=\"text\" size=\"30\" id=\"regexText\"></br> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1427 Replace: <input type=\"text\" size=\"30\" id=\"replaceText\"><br> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1428 <button onclick=\"replaceRegex()\">Replace!</button> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1429 </fieldset> \ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1430 </form>"; |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1431 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1432 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1433 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1434 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1435 // ============ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1436 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1437 // === for edittaglist.php === |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1438 function editTaglist(topic_id) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1439 var form = document.createElement("form"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1440 form.setAttribute("method", "post"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1441 form.setAttribute("action", "./EditTaglist"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1442 form.setAttribute("target", "_blank"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1443 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1444 var hiddenField = document.createElement("input"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1445 hiddenField.setAttribute("name", "topic_id"); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1446 hiddenField.setAttribute("value", topic_id); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1447 form.appendChild(hiddenField); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1448 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1449 if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1450 document.body.appendChild(form); |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1451 form.submit(); |
107
7f2c5d542616
fixed form submit issue in Chrome 56.x
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
106
diff
changeset
|
1452 document.body.removeChild(form); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1453 } else { |
107
7f2c5d542616
fixed form submit issue in Chrome 56.x
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
106
diff
changeset
|
1454 //form.submit(); // works under IE and Chrome, but not FF |
7f2c5d542616
fixed form submit issue in Chrome 56.x
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
106
diff
changeset
|
1455 document.body.appendChild(form); |
7f2c5d542616
fixed form submit issue in Chrome 56.x
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
106
diff
changeset
|
1456 form.submit(); |
7f2c5d542616
fixed form submit issue in Chrome 56.x
Calvin Yeh <cyeh@mpipw-berlin.mpg.com>
parents:
106
diff
changeset
|
1457 document.body.removeChild(form); |
47
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1458 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1459 } |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1460 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1461 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1462 // ============ |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1463 // |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1464 |
886f43b26ee2
move/remove develop folder
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff
changeset
|
1465 |