Mercurial > hgrepos > hgweb.cgi > s4
annotate s4-main.js @ 1054:cf0e33324a12 draft default tip
FIX: summary/detail not fired after table
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 06 Jun 2024 22:59:12 +0900 |
parents | 11a8837b1cda |
children |
rev | line source |
---|---|
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1 // 愛 |
586 | 2 (function (){ |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
3 var isOlderJS; // Set in init(); |
972
8781f341d93a
Add referring text to hover title of ">#xxxx" marks.
HIROSE Yuuji <yuuji@gentei.org>
parents:
969
diff
changeset
|
4 var hoverTextLines = 10; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
5 var hasTouchPad = |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
6 (navigator.maxTouchPoints && navigator.maxTouchPoints >0); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
7 var myurl = document.URL, |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
8 mypath = myurl.substring(myurl.lastIndexOf("/")); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
9 var art_m_list = []; |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
10 var mathjax = false; |
1040 | 11 var filterSelect, filterOption = null; |
915
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
12 let input_pdfsw = 'input[name="comppdf"]'; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
13 if (mypath.match(/(.*)\/(.*)/)) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
14 mypath = RegExp.$2; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
15 mypath = mypath.substring(0, mypath.lastIndexOf("?")); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
16 //alert("mypath="+mypath); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
17 } |
984
a094bd547d6b
Escape chars in hover string
HIROSE Yuuji <yuuji@gentei.org>
parents:
982
diff
changeset
|
18 function escapeChars(old) { |
1000
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
19 return old.replaceAll('&', '&') |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
20 .replaceAll('"', '"') |
984
a094bd547d6b
Escape chars in hover string
HIROSE Yuuji <yuuji@gentei.org>
parents:
982
diff
changeset
|
21 .replaceAll("<", '<') |
a094bd547d6b
Escape chars in hover string
HIROSE Yuuji <yuuji@gentei.org>
parents:
982
diff
changeset
|
22 .replaceAll(">", '>'); |
a094bd547d6b
Escape chars in hover string
HIROSE Yuuji <yuuji@gentei.org>
parents:
982
diff
changeset
|
23 } |
667
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
24 function collectElementsByAttr(elm, attr, val) { |
586 | 25 var e = document.getElementsByTagName(elm); |
26 if (!e) return null; | |
27 var list = []; | |
28 for (var i of e) { | |
667
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
29 if (i.getAttribute(attr) == val) |
586 | 30 list.push(i) |
31 } | |
32 return list; | |
33 } | |
675
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
34 function nthChildOf(parent, n, elem) { // Return Nth child of type ELEM |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
35 // N begins with 1 |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
36 var i=0; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
37 var le = elem.toLowerCase(); |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
38 for (var c of parent.childNodes) { |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
39 if (!c.tagName) continue; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
40 if (c.tagName.toLowerCase() == le) { |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
41 if (++i >= n) return c; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
42 } |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
43 } |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
44 return null; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
45 } |
586 | 46 function insertRedirect(e) { |
47 var articleId, textarea = document.getElementById("text"); | |
48 var p = e.target, checked = p.checked; | |
49 while (p = p.parentNode) | |
50 if (p.nodeName.match(/^td$/i)) break; | |
51 if (!p) return; | |
52 while (p = p.nextSibling) | |
53 if (p.nodeName.match(/^td$/i)) break; | |
54 if (!p) return; | |
55 articleId = p.getAttribute("id"); | |
56 if (textarea && articleId) { | |
57 var tv = textarea.value, lines; | |
58 if (tv) | |
59 lines = tv.split("\n"); | |
60 else | |
61 lines = [""]; | |
62 var re = new RegExp("[, ]*#"+articleId+"(?![0-9])"); | |
590
f480fa97fba6
Redirection also inserted by #XXX anchors
HIROSE Yuuji <yuuji@gentei.org>
parents:
586
diff
changeset
|
63 checked = (p.nodeName.match(/^input$/) |
f480fa97fba6
Redirection also inserted by #XXX anchors
HIROSE Yuuji <yuuji@gentei.org>
parents:
586
diff
changeset
|
64 ? p.checked // checkbox obeys its status |
f480fa97fba6
Redirection also inserted by #XXX anchors
HIROSE Yuuji <yuuji@gentei.org>
parents:
586
diff
changeset
|
65 : !lines[0].match(re)) // a-elment toggles redirection |
586 | 66 if (checked) { |
67 if (!lines[0].match(re)) { | |
68 var re2 = new RegExp(/>#[#0-9, ]+[0-9]/); | |
69 if (lines[0].match(re2)) | |
70 lines[0] = lines[0].replace( | |
71 re2, '$&, '+'#'+articleId); | |
72 else { | |
73 if (lines[0] > "") lines[0] = " "+lines[0]; | |
74 lines[0] = ">#"+articleId+lines[0]; | |
75 } | |
76 } | |
77 } else { // Remove #xxxxx | |
78 if (lines[0].match(/^>#[0-9 ,]+#/)) // 2 or more #id's | |
79 lines[0] = lines[0].replace( | |
80 new RegExp("^>#"+articleId+"[ ,]*"), ">").replace( | |
81 new RegExp("[ ,]*#"+articleId), ""); | |
82 else { | |
83 lines[0] = lines[0].replace( | |
84 new RegExp(">#"+articleId+"[ ,]*"), ""); | |
85 } | |
86 } | |
87 lines[0] = lines[0].replace(/^> *$/, ''); | |
88 textarea.value = lines.join("\n"); | |
89 } | |
90 } | |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
91 function registPjaxViewers(aHrefList) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
92 let apos=art_m_list.length; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
93 for (let a of aHrefList) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
94 let href = a.getAttribute("href"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
95 let localvar = apos; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
96 let td = a.parentNode, |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
97 tr = td.parentNode, |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
98 id = td.id, |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
99 text = td.textContent, |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
100 author = tr.getElementsByTagName("a"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
101 if (author) author = author[0].getAttribute("title"); |
939
6c2f8bb3cc6e
Activate direct link to attached files
HIROSE Yuuji <yuuji@gentei.org>
parents:
938
diff
changeset
|
102 if (href.match(/\?showattc\+article_m\+([0-9]+)$/)) { |
6c2f8bb3cc6e
Activate direct link to attached files
HIROSE Yuuji <yuuji@gentei.org>
parents:
938
diff
changeset
|
103 if (td.innerHTML.match(/読み取り不可/)) { |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
104 a.removeAttribute("href"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
105 continue; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
106 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
107 let url = RegExp.lastMatch; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
108 // console.log("pjaxView(e, "+href+", "+apos+")"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
109 a.addEventListener("click", function(e) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
110 // Shoud use closure local variable: localvar |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
111 pjaxView(e, href, localvar); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
112 }, false); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
113 apos++; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
114 art_m_list.push({ |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
115 url: href, id: id, author: author, text: text |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
116 }); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
117 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
118 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
119 } |
1044
41921e6ada54
Modify procedure of resetPjaxViewers()
HIROSE Yuuji <yuuji@gentei.org>
parents:
1043
diff
changeset
|
120 function resetPjaxViewers(arefs) { |
41921e6ada54
Modify procedure of resetPjaxViewers()
HIROSE Yuuji <yuuji@gentei.org>
parents:
1043
diff
changeset
|
121 art_m_list = []; |
41921e6ada54
Modify procedure of resetPjaxViewers()
HIROSE Yuuji <yuuji@gentei.org>
parents:
1043
diff
changeset
|
122 registPjaxViewers(arefs) |
41921e6ada54
Modify procedure of resetPjaxViewers()
HIROSE Yuuji <yuuji@gentei.org>
parents:
1043
diff
changeset
|
123 } |
906
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
124 function registInsertDirect(aHrefList) { |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
125 for (i of aHrefList) |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
126 if (i.getAttribute("href").match(/^#[0-9]+$/)) |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
127 if (RegExp.lastMatch == i.innerHTML) |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
128 i.addEventListener("click", insertRedirect, false) |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
129 } |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
130 function mathjaxUpdate(arg) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
131 try { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
132 if (MathJax && MathJax.typesetPromise) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
133 MathJax.texReset(); // Reset Math counters |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
134 MathJax.typesetPromise(arg); // MathJax v3 |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
135 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
136 } catch (err) {console.log(err);} |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
137 } |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
138 var ajaxSubmit; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
139 function replAddNews(newtable) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
140 let newids = [], idlist=[]; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
141 let getArticleID = function (td) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
142 return parseInt(td.parentNode.getElementsByTagName("td")[1].id); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
143 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
144 for (let i of newtable.querySelectorAll("td.repl")) |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
145 newids.push(i); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
146 newids = newids.sort((a,b)=> { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
147 return (getArticleID(a) - getArticleID(b)); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
148 }); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
149 for (i of newids) |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
150 idlist.push(getArticleID(i)); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
151 console.log("IDList="+idlist.join()); |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
152 let cnt=0, ntr; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
153 let current = collectElementsByAttr("td", "class", "repl"), |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
154 ncur=0, n, icur=0, o, oid, nid, otr; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
155 current = document.querySelectorAll('td[class="repl"]'); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
156 let last=current[current.length-1], |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
157 tbody = last.parentNode.parentNode; |
906
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
158 let addEventsToNewTr = function(tr) { |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
159 let td = tr.getElementsByTagName("td"), |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
160 td0 = td[0], td1 = td[1]; |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
161 td0.classList.add("new"); |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
162 registInsertDirect(td0.querySelectorAll("a[href]")); |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
163 registPjaxViewers(td1.querySelectorAll("a[href]")); |
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
164 } |
919
27edbd91022c
Erase all "new" flags after arrival of ajax response
HIROSE Yuuji <yuuji@gentei.org>
parents:
916
diff
changeset
|
165 // Erase all "new article" flags before merging |
27edbd91022c
Erase all "new" flags after arrival of ajax response
HIROSE Yuuji <yuuji@gentei.org>
parents:
916
diff
changeset
|
166 for (let i of document.querySelectorAll("td.new")) |
27edbd91022c
Erase all "new" flags after arrival of ajax response
HIROSE Yuuji <yuuji@gentei.org>
parents:
916
diff
changeset
|
167 i.classList.remove("new"); |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
168 // Now reconstruct articles with merge-sort like method |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
169 outer: for (; ncur<newids.length; ncur++) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
170 n = newids[ncur]; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
171 if (!n.id) continue; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
172 nid = parseInt(n.id); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
173 if (nid<=0) continue; |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
174 ntr = n.parentNode; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
175 for (; icur<current.length; icur++) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
176 o = current[icur]; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
177 otr = o.parentNode; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
178 oid = getArticleID(o); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
179 if (!oid || oid=="") continue; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
180 if (oid >= nid) { |
906
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
181 addEventsToNewTr(ntr); |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
182 tbody.insertBefore(ntr, otr); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
183 if (oid==nid) otr.remove(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
184 cnt++; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
185 continue outer; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
186 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
187 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
188 // Append absolutely new articles. |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
189 ntr = n.parentNode; |
906
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
190 addEventsToNewTr(ntr) |
964 | 191 tbody.appendChild(atMarkView(ntr)); |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
192 ntr.classList.add("dissolving"); |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
193 let localntr = ntr; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
194 setTimeout(() => { |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
195 localntr.classList.remove("dissolving"); |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
196 localntr.classList.add("emerging"); |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
197 }, 100); |
981
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
198 rewriteReplyHover(ntr); |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
199 cnt++; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
200 } |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
201 mathjaxUpdate(newids); |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
202 console.log("Update "+cnt+"rows"); |
901
1cff36303150
Handling of the option for "scrollIntoView" changed
HIROSE Yuuji <yuuji@gentei.org>
parents:
900
diff
changeset
|
203 if (cnt>0 && ntr.scrollIntoView) { |
1cff36303150
Handling of the option for "scrollIntoView" changed
HIROSE Yuuji <yuuji@gentei.org>
parents:
900
diff
changeset
|
204 let option = {behavior: "smooth"}; |
1cff36303150
Handling of the option for "scrollIntoView" changed
HIROSE Yuuji <yuuji@gentei.org>
parents:
900
diff
changeset
|
205 if (!isOlderJS) option.block = "center"; |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
206 try { // Scroll to last updated row |
901
1cff36303150
Handling of the option for "scrollIntoView" changed
HIROSE Yuuji <yuuji@gentei.org>
parents:
900
diff
changeset
|
207 ntr.scrollIntoView(option); |
1cff36303150
Handling of the option for "scrollIntoView" changed
HIROSE Yuuji <yuuji@gentei.org>
parents:
900
diff
changeset
|
208 } catch (e1) {} |
1cff36303150
Handling of the option for "scrollIntoView" changed
HIROSE Yuuji <yuuji@gentei.org>
parents:
900
diff
changeset
|
209 } |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
210 return cnt; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
211 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
212 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
213 function warnFileSize(form) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
214 let szmax = form.querySelector('input[name="filesize_max"]').value; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
215 if (!szmax || szmax=="") return; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
216 szmax = parseInt(szmax); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
217 if (szmax <= 0) return; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
218 // szmax = 10000 |
915
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
219 let ng = "", rcval=false, fileexists=false, |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
220 pdfsw = form.querySelector(input_pdfsw), |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
221 pdfmsg = "Try compressing PDF?\nPDFを圧縮してみますか?\n" + |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
222 "(それでも収まらない場合もあります)"; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
223 for (let f of form.querySelectorAll('input[type="file"]')) { |
915
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
224 let thiserr = false; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
225 for (let i of f.files) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
226 fileexists = true; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
227 let fn = i.name, sz = i.size; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
228 console.log("max="+szmax+", fn="+fn+", sz="+sz); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
229 if (sz > szmax) { |
915
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
230 if (fn.match(/\.pdf/i) |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
231 && sz < szmax*3 // XXX : x3 reasonable? |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
232 && (pdfsw || confirm(pdfmsg))) { |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
233 if (!pdfsw) { |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
234 pdfsw = document.createElement("input"); |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
235 pdfsw.name = "comppdf"; |
916
7cac220d52a7
Pdfsw type should be hidden!
HIROSE Yuuji <yuuji@gentei.org>
parents:
915
diff
changeset
|
236 pdfsw.type = "hidden"; |
915
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
237 f.parentNode.insertBefore(pdfsw, f); |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
238 pdfsw.value = "yes"; |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
239 } |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
240 } else { |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
241 thiserr = true; |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
242 ng += ((ng>"" ? ", " : "")+fn) |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
243 } |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
244 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
245 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
246 thiserr ? f.classList.add("warnbg") : f.classList.remove("warnbg"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
247 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
248 if (ng>"") { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
249 rcval = "File-size Limit Error: "+ng+"\n"+ |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
250 "Should be less than "+szmax+"bytes.\n"+ |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
251 szmax+"バイト未満にしてください" |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
252 alert(rcval); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
253 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
254 if (form.text.value == "") { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
255 let w; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
256 if (fileexists) |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
257 w = "Fill the text area\n" + |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
258 "添付したファイルに関する説明を入れてください。"; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
259 else |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
260 w = "Enter your comment!\n何か書き込んでね!"; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
261 alert(w); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
262 rcval = (rcval || w); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
263 form.text.classList.add("warnbg"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
264 setTimeout(() => {form.text.classList.remove("warnbg");}, 2000) |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
265 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
266 return rcval; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
267 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
268 function ajaxPost(e) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
269 e.preventDefault(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
270 let rowid; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
271 if (!myurl.match(/replyblog\+([0-9]+)/)) return; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
272 rowid = RegExp.$1 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
273 let myform = document.querySelector("form.replyblog"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
274 let data = new FormData(myform), |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
275 fetchtime = data.get("fetchtime"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
276 if (!fetchtime || fetchtime=="") return; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
277 ///*XX*/fetchtime = "2020-06-14T00:00:00";data.set("fetchtime", fetchtime) |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
278 |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
279 ajaxSubmit = e.target; |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
280 ajaxSubmit.back = ajaxSubmit.textContent; |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
281 if (ajaxSubmit.id == "reload") { |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
282 ajaxSubmit.textContent = "更新中" |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
283 data.set("text", "") |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
284 } else { |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
285 if (warnFileSize(myform)) return; |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
286 ajaxSubmit.textContent = "送信中"; |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
287 } |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
288 ajaxSubmit.blur(); |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
289 ajaxSubmit.disabled = true; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
290 let act = mypath+"?blog_fetch+"+rowid+"+f:"+fetchtime; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
291 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
292 function respUpdate(tbody) { |
907
ce1a355e7cb1
Warn password timeout in ajaxpost
HIROSE Yuuji <yuuji@gentei.org>
parents:
906
diff
changeset
|
293 ajaxSubmit.textContent = ajaxSubmit.back; |
ce1a355e7cb1
Warn password timeout in ajaxpost
HIROSE Yuuji <yuuji@gentei.org>
parents:
906
diff
changeset
|
294 ajaxSubmit.disabled = false; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
295 let div = document.createElement("div"), form, newform; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
296 try { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
297 div.innerHTML = tbody; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
298 form = div.querySelector("form"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
299 } catch (er) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
300 alert("Cannot parse fetch data"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
301 return; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
302 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
303 let update = replAddNews(form); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
304 let dispelem = myform.querySelector("textarea").parentNode; |
907
ce1a355e7cb1
Warn password timeout in ajaxpost
HIROSE Yuuji <yuuji@gentei.org>
parents:
906
diff
changeset
|
305 if (div.querySelector('input[name="user"]')) { // is login form |
ce1a355e7cb1
Warn password timeout in ajaxpost
HIROSE Yuuji <yuuji@gentei.org>
parents:
906
diff
changeset
|
306 dispInfoMomentary("Login Again Please", dispelem) |
ce1a355e7cb1
Warn password timeout in ajaxpost
HIROSE Yuuji <yuuji@gentei.org>
parents:
906
diff
changeset
|
307 return; |
ce1a355e7cb1
Warn password timeout in ajaxpost
HIROSE Yuuji <yuuji@gentei.org>
parents:
906
diff
changeset
|
308 } |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
309 newform = new FormData(form); |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
310 if (data.get("text") > "") { // Called by submit button |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
311 myform.reset(); |
1040 | 312 if (filterOption) { // Restore TEAM filterin if any |
313 filterSelect.selectedIndex = filterOption; | |
314 } | |
915
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
315 let pdfsw = myform.querySelector(input_pdfsw); |
b47f64276427
Try to compress PDF if gs is available
HIROSE Yuuji <yuuji@gentei.org>
parents:
914
diff
changeset
|
316 if (pdfsw) pdfsw.remove(); |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
317 // myform.text.value = ''; |
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
318 } |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
319 myform.fetchtime.value = newform.get("fetchtime"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
320 myform.id.value = newform.get("id"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
321 if (update && update > 0) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
322 let s = update + " new article" + |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
323 (update>1 ? "s" : "") + " posted"; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
324 dispInfoMomentary(s, dispelem); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
325 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
326 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
327 fetch(act, { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
328 method: "POST", body: data, |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
329 credentials: "include" // For older firefox |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
330 }).then((resp) => { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
331 return resp.text(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
332 }).then((tbody) => { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
333 respUpdate(tbody); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
334 }) |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
335 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
336 function pjaxView(ev, url, mynum) { |
928
a3623f901e32
Shift-Click also suppress pjaxViewer
HIROSE Yuuji <yuuji@gentei.org>
parents:
927
diff
changeset
|
337 if (ev.ctrlKey||ev.shiftKey) return; |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
338 ev.preventDefault(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
339 let box = document.createElement("div") |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
340 box.setAttribute("class", "pjaxview"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
341 let p1 = document.createElement("p"), |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
342 bt = document.createElement("button"), |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
343 sl = document.createElement("button"), |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
344 sr = document.createElement("button"), |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
345 loading = document.createElement("span"), |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
346 info = document.createElement("p"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
347 info1 = document.createElement("span"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
348 info2 = document.createElement("span"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
349 iframe = document.createElement("iframe"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
350 var curpos = mynum; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
351 var historyBase = history.length; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
352 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
353 function _setPjaxCurposInfo() { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
354 let len = art_m_list.length; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
355 let cur = art_m_list[curpos] |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
356 info1.textContent = (1+curpos)+" of "+len+" article #"+cur.id+ |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
357 (cur.author ? " by "+cur.author : "") + ":"; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
358 info2.textContent = cur.text.trim(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
359 info2.setAttribute("class", "border textdigest"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
360 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
361 function _resetPjax() { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
362 // All we can do surely is to back 1 page, |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
363 // because we cannot move to desirable entry of history list. |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
364 history.back(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
365 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
366 function setSwipeAct(iframe) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
367 // We cannot use DOMContentLoaded nor iframe.contentWindow here. |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
368 // PDF.js does not construct contentWindow...? |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
369 iframe.addEventListener("load", () => { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
370 loading.classList.remove("loading"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
371 if (!hasTouchPad) return; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
372 let ifm = iframe.contentDocument; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
373 let startX, moveX, thresh = 100; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
374 ifm.addEventListener("touchstart", (e) => { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
375 e.preventDefault(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
376 startX = e.touches[0].pageX; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
377 }, false); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
378 ifm.addEventListener("touchmove", (e) => { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
379 e.preventDefault(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
380 moveX = e.touches[0].pageX; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
381 }, false); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
382 ifm.addEventListener("touchend", (e) => { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
383 if (startX < moveX && startX + thresh < moveX) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
384 switchTo(e, -1); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
385 } else if (startX > moveX && startX - thresh > moveX) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
386 switchTo(e, +1); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
387 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
388 }, false); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
389 }, false); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
390 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
391 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
392 function switchTo(e, direction) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
393 e.preventDefault(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
394 let len = art_m_list.length, cur, newpos, url; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
395 newpos = (curpos+len+direction)%len; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
396 if (curpos == newpos) return; // No need to switch to same one |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
397 curpos = newpos; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
398 cur = art_m_list[curpos]; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
399 url = cur.url; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
400 // We should remove iframe once to preserve history Object |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
401 // https://inthetechpit.com/2019/04/20/update-iframe-without-affecting-browser-history/ |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
402 let parent = iframe.parentNode; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
403 // alert("D = "+direction); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
404 iframe.remove(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
405 parent.appendChild(iframe); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
406 try { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
407 loading.classList.add("loading"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
408 iframe.src = url; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
409 // iframe.contentDocument.location.replace(url); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
410 // location.replace cannot be used because PDF viewer.js |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
411 // does not have iframe.contentDocument |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
412 } catch (err) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
413 alert("Cannot load "+src+" : "+err.name); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
414 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
415 _setPjaxCurposInfo(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
416 setSwipeAct(iframe); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
417 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
418 function switchToByKey(e) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
419 // alert("KEY="+e.key); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
420 switch (e.key) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
421 case "ArrowLeft": |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
422 switchTo(e, -1); break; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
423 case "ArrowRight": |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
424 switchTo(e, +1); break; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
425 case "Escape": |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
426 history.back(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
427 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
428 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
429 // <div><p> |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
430 // <button> << </button><button>Dismiss</button><button> >> </button> |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
431 // </p><p><span> info1 </span> <span> info2 </span></p> |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
432 // <iframe src="..."></iframe> |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
433 // </div> |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
434 // ==> [ << ][Dissmiss][ >> ] |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
435 // ==> ## of ## article #xxx by AUTHOR |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
436 sl.textContent = " << "; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
437 sr.textContent = " >> "; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
438 sl.addEventListener("click", (e) => {switchTo(e, -1);}); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
439 sr.addEventListener("click", (e) => {switchTo(e, +1);}); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
440 sl.setAttribute("title", "to="+(mynum-1)); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
441 sr.setAttribute("title", "to="+(mynum+1)); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
442 document.body.appendChild(box); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
443 bt.textContent = "Click to dismiss / もどる"+mynum; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
444 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
445 box.appendChild(p1); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
446 p1.appendChild(sl); p1.appendChild(bt); p1.appendChild(sr); |
930
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
447 { // TEST: Normal mode |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
448 let only = document.createElement("button"), |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
449 h = location.href; |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
450 only.textContent = ".oO□"; |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
451 only.setAttribute("title", "Open in Normal Window"); |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
452 only.addEventListener("click", function() { |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
453 location.replace(iframe.src); |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
454 }); |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
455 p1.appendChild(only); |
1221335459c6
Add evaluation code of opening files in normal window
HIROSE Yuuji <yuuji@gentei.org>
parents:
928
diff
changeset
|
456 } |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
457 p1.appendChild(loading); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
458 info.appendChild(info1); info.appendChild(info2); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
459 loading.textContent=" Loading..."; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
460 loading.classList.add("hidden"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
461 loading.classList.add("loading"); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
462 box.appendChild(info); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
463 iframe.src = url; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
464 |
925
713441f69ab8
Key-event Listener should be restricted to "box" div.
HIROSE Yuuji <yuuji@gentei.org>
parents:
919
diff
changeset
|
465 box.addEventListener("keydown", switchToByKey); |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
466 //box.addEventListener("click", (e) => {_resetPjax();}); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
467 bt.addEventListener("click", (e) => {_resetPjax();}); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
468 // dp.addEventListener("click", (e) => {_resetPjax();}); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
469 info.addEventListener("click", (e) => {_resetPjax();}); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
470 box.appendChild(iframe); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
471 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
472 setSwipeAct(iframe); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
473 |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
474 _setPjaxCurposInfo(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
475 bt.focus(); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
476 setTimeout(() => {box.classList.add("pjaxview2");}, 10); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
477 // Finally update history stack |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
478 pjaxHistoryPush(box); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
479 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
480 function pjaxHistoryPush(box) { |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
481 if (history.pushState) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
482 let h = location.href.replace(/#.*/, '')+"#pjaxview"; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
483 history.pushState({url: h}, null, h); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
484 window.addEventListener("popstate", (e) => { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
485 if (box) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
486 box.remove(); box = null; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
487 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
488 }, false); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
489 } |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
490 } |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
491 function reverseChecks() { |
667
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
492 var names = collectElementsByAttr("input", "name", "usel"); |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
493 for (let u of names) { |
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
494 u.checked = !u.checked; |
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
495 } |
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
496 } |
852 | 497 function renumberOL(str, start) { |
498 var stra = str.split("\n"); | |
499 for (var i=1; i<stra.length; i++) { | |
500 if (stra[i].match(/^[1-9][0-9]*\. /)) { | |
501 let orig=stra[i]; | |
502 stra[i] = (++start)+". "+RegExp.rightContext; | |
503 } else if (stra[i].match(/^ /)) { | |
504 continue; | |
505 } else | |
506 break; | |
507 } | |
508 return stra.join("\n"); | |
509 } | |
934
9184aa358773
Fake click at Ctrl-Enter posting for ajax post.
HIROSE Yuuji <yuuji@gentei.org>
parents:
931
diff
changeset
|
510 function submitThisForm(e) { |
9184aa358773
Fake click at Ctrl-Enter posting for ajax post.
HIROSE Yuuji <yuuji@gentei.org>
parents:
931
diff
changeset
|
511 var input = e.target, ajaxpost = document.getElementById("c"); |
852 | 512 for (var elm=input.parentNode; elm; elm = elm.parentNode) { |
934
9184aa358773
Fake click at Ctrl-Enter posting for ajax post.
HIROSE Yuuji <yuuji@gentei.org>
parents:
931
diff
changeset
|
513 if (ajaxpost) { |
9184aa358773
Fake click at Ctrl-Enter posting for ajax post.
HIROSE Yuuji <yuuji@gentei.org>
parents:
931
diff
changeset
|
514 ajaxpost.click(); |
9184aa358773
Fake click at Ctrl-Enter posting for ajax post.
HIROSE Yuuji <yuuji@gentei.org>
parents:
931
diff
changeset
|
515 return true; |
9184aa358773
Fake click at Ctrl-Enter posting for ajax post.
HIROSE Yuuji <yuuji@gentei.org>
parents:
931
diff
changeset
|
516 } else if (elm.nodeName.match(/form/i)) { |
852 | 517 elm.submit(); |
518 return true; | |
519 } | |
520 } | |
521 return false; | |
522 } | |
523 function helpMarkdownBS(e) { | |
524 var area = e.target, pos = area.selectionStart, text = area.value; | |
525 if (area.selectionStart != area.selectionEnd) return; | |
526 if (pos<2) return; | |
527 if (text.substr(pos-1, 2)=="\n\n") return; | |
528 var bol = text.lastIndexOf("\n", pos-1), | |
529 eol = text.indexOf("\n", pos); | |
530 if (bol<=0 || bol==eol) return; | |
531 var thisline = text.substring(bol+1, eol==-1 ? text.length : eol); | |
532 thisline = text.substring(bol+1, pos); | |
533 if (thisline == "* ") { | |
534 area.setSelectionRange(pos-2, pos); | |
535 } else if (thisline.match(/^[1-9][0-9]*\. $/)) { | |
536 area.setSelectionRange(pos-RegExp.lastMatch.length, pos); | |
537 } | |
538 } | |
539 function helpMarkdownEnter(e) { | |
540 if (e.keyCode == 13 && !e.shiftKey) { | |
934
9184aa358773
Fake click at Ctrl-Enter posting for ajax post.
HIROSE Yuuji <yuuji@gentei.org>
parents:
931
diff
changeset
|
541 if (e.ctrlKey && submitThisForm(e)) { |
852 | 542 e.preventDefault(); |
543 return; | |
544 } | |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
545 var area = e.target; |
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
546 var pos = area.selectionStart, text = area.value; |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
547 if (pos==0) return; |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
548 var last = text.lastIndexOf("\n", pos-1); |
852 | 549 var rest = text.substring(pos), rest0=rest; |
550 var line = last ? text.substring(last+1, pos) : text; | |
551 var next = rest.substring(rest.indexOf("\n"))||rest; | |
552 next=next.substring(1); | |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
553 var tail = text.substring(pos-2, pos), br = (tail==" "); |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
554 var add = "", offset = 1; |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
555 if (line.startsWith("* ")) { |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
556 add = "* "; |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
557 offset += add.length; |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
558 if (br) { |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
559 add = " " + "\n" + add; |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
560 } |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
561 } else if (line.match(/^([1-9][0-9]*)\. /)) { |
852 | 562 var ln = parseInt(RegExp.$1), nn=ln+1, |
563 len = RegExp.lastMatch.length; | |
564 add = nn+". "; | |
565 let toeol = text.substr(pos, text.indexOf("\n")); | |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
566 if (br) { |
852 | 567 if (next.startsWith(add)) { |
568 add=" ".repeat(len); | |
569 nn = ln; | |
570 } else { | |
571 add = " ".repeat(len)+ "\n" + add; | |
572 offset -= len+1; | |
573 } | |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
574 } |
852 | 575 if (next.match(/^[1-9][0-9]*\. /)) |
576 rest = renumberOL(rest, nn); | |
577 offset += add.length; | |
578 } else if (line.match(/^\|( *).+\|/)) { | |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
579 add = "|" + RegExp.$1 + " |"; |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
580 offset += add.length-2; |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
581 } else { |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
582 return; |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
583 } |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
584 e.preventDefault(); |
852 | 585 if (!document.execCommand("insertText", false, "\n"+add)) { |
586 //Firefox | |
587 area.selectionEnd = area.value.length; | |
588 area.setRangeText("\n"+add+rest); | |
589 area.selectionEnd = null; | |
590 } else { | |
591 area.selectionEnd = area.value.length; | |
592 area.setSelectionRange(area.selectionStart, area.value.length); | |
593 document.execCommand("insertText", false, rest); | |
594 area.selectionEnd = null; | |
595 area.focus(); | |
596 } | |
597 area.selectionStart = pos+offset; | |
598 return; | |
599 if (document.execCommand("insertText", false, "\n"+add)) { | |
600 //area.setSelectionRange(area.selectionStart, text.length); | |
601 // alert("rest=["+rest+"], add=["+add+"]"); | |
602 alert(text.substring(pos, area.value.length)); | |
603 if (rest != rest0) { | |
604 area.setSelectionRange(pos, area.value.length); | |
605 return; | |
606 document.execCommand("delete"); | |
607 } | |
608 document.execCommand("insertText", false, rest); | |
609 } else { | |
610 // Firefox cannot use insertText in textarea... | |
611 area.value = text.substring(0, pos) + "\n" + add + rest; | |
612 } | |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
613 //area.setSelectionRange(pos+length(add)); |
847
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
614 area.selectionStart=area.selectionEnd = (pos + offset); |
a9e147e355fd
Do not file helper when no pattern matches
HIROSE Yuuji <yuuji@gentei.org>
parents:
846
diff
changeset
|
615 |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
616 } |
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
617 } |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
618 var helpParenPreview = 0; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
619 function helpMarkdownParen(e) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
620 if (!mathjax) return; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
621 var area = e.target, pos = area.selectionStart, text = area.value; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
622 if (pos<2) return; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
623 if (text[pos-1] == "\\") { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
624 let ins="( \\)"; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
625 if (text[pos-2] == "\\") ins="( \\\\)"; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
626 area.setRangeText(ins, pos, pos); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
627 area.selectionStart = pos+2; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
628 if (helpParenPreview++ < 1) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
629 dispInfoMomentary("Preview formula by Meta-p\n"+ |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
630 "Meta-p で数式プレビュー", e.target.parentNode); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
631 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
632 e.preventDefault(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
633 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
634 } |
947
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
635 function textInsert(area, string, pos1, pos2) { |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
636 console.log("str="+string); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
637 area.setRangeText(string, pos1||area.selectionStart, |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
638 pos2||pos1||area.selectionStart); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
639 area.selectionStart += string.length; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
640 } |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
641 function beginningOfLine(area, pos) { |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
642 pos = pos||area.selectionStart; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
643 let b = area.value.lastIndexOf("\n", pos); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
644 if (pos>1 && area.value.charCodeAt(pos)==10) |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
645 b = area.value.lastIndexOf("\n", pos-1);; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
646 return b>=0 ? b : 0; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
647 } |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
648 function isInBeginEnd(area, pos){ |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
649 pos = pos||area.selectionStart; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
650 let bol = beginningOfLine(area, pos); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
651 let thisline = area.value.substr(bol); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
652 console.log("curchar="+area.value.charCodeAt(pos)); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
653 console.log("prechar="+area.value.charCodeAt(pos-1)); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
654 console.log("bol="+bol+", thisline="+thisline); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
655 let match = thisline.search(/\\(begin|end){([A-Za-z]*)/), lm, be; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
656 if (match >= 0) { |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
657 lm = RegExp.lastMatch; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
658 be = RegExp.$1; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
659 return RegExp.$2 |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
660 } |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
661 return null; |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
662 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
663 function helpMarkdownBrace(e) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
664 if (!mathjax) return; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
665 var area = e.target, pos = area.selectionStart, text = area.value, |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
666 begin = "\\begin", end = "\\end"; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
667 if (pos < end.length) return; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
668 if (text.substr(pos-end.length).startsWith(end)) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
669 let beg = text.lastIndexOf(begin, pos); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
670 if (beg >= 0) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
671 let env = text.substr(beg).search(/\\begin{(.*?)}/); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
672 if (env >= 0) { |
947
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
673 textInsert(area, "{"+RegExp.$1+"}", pos); |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
674 e.preventDefault(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
675 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
676 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
677 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
678 } |
947
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
679 function helpMarkdownBraceClose(e) { |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
680 if (!mathjax) return; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
681 let area = e.target, pos = area.selectionStart, text = area.value, |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
682 begin = "\\begin", end = "\\end"; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
683 if (text.substr(pos).startsWith("}")) { |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
684 area.setRangeText("", pos, pos+1); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
685 // e.preventDefault(); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
686 } |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
687 let inbegend = isInBeginEnd(area, pos); |
948
1310b29b6ab1
Prevent \end completion when not enclosed with \begin
HIROSE Yuuji <yuuji@gentei.org>
parents:
947
diff
changeset
|
688 if (!inbegend) return; |
947
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
689 let nextendpos = text.substr(pos).indexOf("\\end{"); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
690 let nextcurend = text.substr(pos).indexOf("\\end{"+inbegend+"}"); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
691 if (nextcurend<0 || nextendpos!=nextcurend) { |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
692 area.setRangeText("}\n\n\\end{"+inbegend+"}", pos, pos); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
693 area.selectionStart = pos+2; |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
694 e.preventDefault(); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
695 } |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
696 console.log(inbegend); |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
697 |
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
698 } |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
699 function helpMarkdownPreview(area) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
700 if (!mathjax) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
701 alert("no"+e.target) |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
702 dispInfoMomentary("This board has no MathJax mode.\n"+ |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
703 "この掲示板は数式モードOFFです。", |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
704 e.target.parentNode); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
705 return; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
706 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
707 let text = area.value; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
708 let preview = document.createElement("div"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
709 let bp = document.createElement("p"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
710 let btn = document.createElement("button"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
711 btn.innerText = "Click or ESC to Dissmiss / クリックかESCで戻る"; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
712 bp.classList.add("c"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
713 preview.classList.add("pjaxview"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
714 preview.classList.add("pjaxview2"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
715 let pre = document.createElement("p"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
716 bp.appendChild(btn); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
717 preview.appendChild(bp); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
718 preview.appendChild(pre); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
719 pre.innerText = text; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
720 document.body.appendChild(preview); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
721 function dismiss(t) { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
722 history.back(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
723 preview.remove(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
724 area.focus(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
725 } |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
726 preview.addEventListener("click", dismiss, false); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
727 preview.addEventListener("keydown", dismiss, false); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
728 MathJax.typesetPromise([pre]); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
729 pjaxHistoryPush(preview); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
730 btn.focus(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
731 } |
960
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
732 function helpMarkdownAt(e) { |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
733 var area = e.target, pos = area.selectionStart; |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
734 if (pos == 0) { |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
735 area.value = "@all" + area.value; |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
736 area.selectionStart = area.selectionEnd = 4; |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
737 dispInfoMomentary("@all で全員に通知します", area.parentNode); |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
738 e.preventDefault(); |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
739 } |
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
740 } |
1054
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
741 function helpMarkdownTriple(e, mark, defSuffix, tooltip) { |
1051 | 742 let area = e.target, pos=area.selectionStart, text=area.value, |
743 last = text.lastIndexOf("\n", pos-1), | |
744 line = last ? text.substring(last+1, pos) : text, | |
745 prev = text.substring(0, last), | |
1054
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
746 triple = mark+mark+mark, |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
747 add1 = mark+defSuffix, |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
748 add2 = `\n\n${mark}${mark}${mark}`; |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
749 if (line == mark+mark) { // is like "<<" |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
750 let oprx = RegExp(`(?<=^|\n)${triple} *.*(?=\n|$)`, "g"), |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
751 clrx = RegExp(`(?<=\n)${triple} *.*(?=\n|$)`, "g"), |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
752 r = prev.match(oprx); |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
753 if (r && r.pop() != triple) return; // If recent <<< is header |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
754 r = text.substring(pos).match(clrx); |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
755 if (r && r[0] == triple) return; // If already closed |
1051 | 756 e.preventDefault(); |
757 if (!document.execCommand("insertText", false, add1+add2)) { | |
1054
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
758 //To enable undo, use deperecated function once. |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
759 |
1051 | 760 } else { |
1054
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
761 // setRangeText breaks undo ring... |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
762 area.setRangeText(add1+add2, pos, pos); |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
763 area.selectionStart = pos+1; |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
764 area.selectionEnd = pos+1+defSuffix.length; |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
765 if (tooltip) { |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
766 dispInfoMomentary(tooltip, area.parentNode); |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
767 } |
1051 | 768 } |
769 } | |
770 } | |
1054
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
771 function helpMarkdownLT(e) { |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
772 helpMarkdownTriple(e, "<", " See more..."); |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
773 } |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
774 function helpMarkdownExclamation(e) { |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
775 helpMarkdownTriple(e, "!", "info", "!!!info / !!!warn / !!!alert"); |
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
776 } |
852 | 777 function helpMarkdown(e) { |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
778 switch (e.key) { |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
779 case "Backspace": helpMarkdownBS(e); break; |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
780 case "Enter": helpMarkdownEnter(e); break; |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
781 case "(": helpMarkdownParen(e); break; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
782 case "p": if (e.metaKey) helpMarkdownPreview(e.target); break; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
783 case "{": helpMarkdownBrace(e); break; |
947
b7f9c4ce8cbd
Add auto-completion of \begin\end
HIROSE Yuuji <yuuji@gentei.org>
parents:
946
diff
changeset
|
784 case "}": helpMarkdownBraceClose(e); break; |
960
0d9caeab3d81
Instant notify by "@all" sign at the beginning of article.
HIROSE Yuuji <yuuji@gentei.org>
parents:
959
diff
changeset
|
785 case "@": helpMarkdownAt(e); break; |
1051 | 786 case "<": helpMarkdownLT(e); break; |
1054
cf0e33324a12
FIX: summary/detail not fired after table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1051
diff
changeset
|
787 case "!": helpMarkdownExclamation(e); break; |
852 | 788 } |
789 } | |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
790 /* Init event listeners */ |
837
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
791 function addFileInput() { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
792 var inpfile = collectElementsByAttr("input", "name", "image"); |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
793 if (!inpfile) return; |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
794 var filled = true; |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
795 var i, ih; |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
796 for (i of inpfile) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
797 if (! i.value) filled=false; |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
798 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
799 if (filled) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
800 ih = i.parentNode.innerHTML; |
1013
1ffaa8b2b1bf
Modify blog comment form layout
HIROSE Yuuji <yuuji@gentei.org>
parents:
1003
diff
changeset
|
801 let ipph = i.parentNode.parentNode.innerHTML; //Entire td inside |
1ffaa8b2b1bf
Modify blog comment form layout
HIROSE Yuuji <yuuji@gentei.org>
parents:
1003
diff
changeset
|
802 if (ipph) { |
1ffaa8b2b1bf
Modify blog comment form layout
HIROSE Yuuji <yuuji@gentei.org>
parents:
1003
diff
changeset
|
803 let ip = i.parentNode; |
1ffaa8b2b1bf
Modify blog comment form layout
HIROSE Yuuji <yuuji@gentei.org>
parents:
1003
diff
changeset
|
804 var inpf = ipph.substring(ipph.indexOf('<span class="file')), |
1ffaa8b2b1bf
Modify blog comment form layout
HIROSE Yuuji <yuuji@gentei.org>
parents:
1003
diff
changeset
|
805 newi = "<br>"+inpf.substring(0, inpf.indexOf("/span>")+6); |
1ffaa8b2b1bf
Modify blog comment form layout
HIROSE Yuuji <yuuji@gentei.org>
parents:
1003
diff
changeset
|
806 ip.insertAdjacentHTML("afterend", newi) |
1ffaa8b2b1bf
Modify blog comment form layout
HIROSE Yuuji <yuuji@gentei.org>
parents:
1003
diff
changeset
|
807 ip.nextSibling.nextSibling.addEventListener('change', () => { |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
808 warnFileSize(document.forms[0]); |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
809 }); |
837
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
810 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
811 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
812 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
813 function initFileInput() { // Multiplies "input type=file" |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
814 var el, morefile = document.getElementById("morefile"); |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
815 if (morefile) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
816 for (el of collectElementsByAttr("input", "name", "image")) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
817 el.addEventListener("change", function(ev) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
818 if (ev.target.value > "" && ev.target.files.length == 1) |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
819 morefile.style.visibility = "visible"; |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
820 // No need to hide again, sure? |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
821 }); |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
822 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
823 morefile.addEventListener("click", addFileInput, null); |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
824 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
825 // When renaming, select basename part |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
826 for (el of collectElementsByAttr("input", "class", "mv")) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
827 el.addEventListener("focus", function(ev) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
828 var i = ev.target; |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
829 if (i) { |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
830 i.setSelectionRange(0, i.value.lastIndexOf(".")); |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
831 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
832 }); |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
833 } |
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
834 } |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
835 function initTextarea() { |
1051 | 836 let te = collectElementsByAttr("textarea", "name", "text"), |
837 th = collectElementsByAttr("textarea", "name", "heading"); | |
838 if (!te || !te[0]) te = th; | |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
839 if (!te || !te[0]) return; |
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
840 te[0].addEventListener("keydown", helpMarkdown, false); |
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
841 } |
964 | 842 function atMarkView(elem) { |
843 // Enclose "@all" with span | |
844 for (i of elem.querySelectorAll("td.repl")) { | |
1001
bbd5a0c50d5b
Keep pjaxview in @all post
HIROSE Yuuji <yuuji@gentei.org>
parents:
1000
diff
changeset
|
845 if (i.textContent.startsWith("@all")) { |
bbd5a0c50d5b
Keep pjaxview in @all post
HIROSE Yuuji <yuuji@gentei.org>
parents:
1000
diff
changeset
|
846 i.firstChild.nodeValue = i.firstChild.nodeValue.substring(4); |
bbd5a0c50d5b
Keep pjaxview in @all post
HIROSE Yuuji <yuuji@gentei.org>
parents:
1000
diff
changeset
|
847 i.insertAdjacentHTML( |
bbd5a0c50d5b
Keep pjaxview in @all post
HIROSE Yuuji <yuuji@gentei.org>
parents:
1000
diff
changeset
|
848 'afterbegin', '<div class="atall">@all</div>' |
bbd5a0c50d5b
Keep pjaxview in @all post
HIROSE Yuuji <yuuji@gentei.org>
parents:
1000
diff
changeset
|
849 ); |
bbd5a0c50d5b
Keep pjaxview in @all post
HIROSE Yuuji <yuuji@gentei.org>
parents:
1000
diff
changeset
|
850 i.classList.add("atall"); |
964 | 851 } |
852 } | |
853 return elem; | |
854 } | |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
855 var authVisible = false; |
969
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
856 function toggleAuthorVisibility(e) { |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
857 // Click to hideauth button toggles visibility of author columns |
969
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
858 e.stopPropagation(); |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
859 let b = document.getElementById("hideauth"); |
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
860 if (authVisible) { |
969
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
861 for (let i of document.querySelectorAll("td.repatt")) { |
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
862 i.classList.remove("hideauthor"); |
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
863 } |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
864 authVisible = false; |
969
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
865 } else { |
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
866 for (let i of document.querySelectorAll("td.repatt")) { |
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
867 i.classList.add("hideauthor"); |
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
868 } |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
869 authVisible = true; |
969
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
870 } |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
871 b.textContent = b.textContent.replace(/OFF|ON/, authVisible ? "ON" : "OFF"); |
969
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
872 } |
997
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
873 function downloadFile(filename, content, BOM) { |
989 | 874 let bom = new Uint8Array([0xEF, 0xBB, 0xBF]); |
997
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
875 let str = new Blob(BOM ? [bom, content] : [content], |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
876 {type: "text/csv"}); |
989 | 877 var uri = URL.createObjectURL(str); |
878 let a = document.createElement("a"); | |
997
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
879 a.download = (BOM ? "BOM-" : "")+filename; |
989 | 880 a.href = uri; |
881 document.body.appendChild(a); | |
882 a.click(); | |
883 document.body.removeChild(a); | |
884 } | |
885 function getTextContentCSV_1(e) { | |
886 let blogtbl = document.querySelector("table.blog_replies"); | |
997
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
887 let needBOM = e.ctrlKey; |
989 | 888 if (!blogtbl) return; |
889 let trw = blogtbl.querySelector("tr.warn"), a; | |
1040 | 890 if (trw && (a=document.getElementById("showall"))) { |
891 if (window.confirm(`50件以下に表示制限されています。 | |
989 | 892 取得し直しますか? |
993
83119d97a2f2
Add English message(CSVget)
HIROSE Yuuji <yuuji@gentei.org>
parents:
992
diff
changeset
|
893 Cancelを押すとこのまま取得します。 |
83119d97a2f2
Add English message(CSVget)
HIROSE Yuuji <yuuji@gentei.org>
parents:
992
diff
changeset
|
894 Seen articles limited to 50 items. |
83119d97a2f2
Add English message(CSVget)
HIROSE Yuuji <yuuji@gentei.org>
parents:
992
diff
changeset
|
895 Push OK to get all articles, Cancel to get only seen articles.`)) { |
1040 | 896 a.click(); |
897 return; | |
989 | 898 } |
899 } | |
997
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
900 if (navigator.userAgent.match(/Windows/)) { |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
901 if (!e.ctrlKey && !e.shiftKey && !window.confirm(`Excelで読ませるCSVの場合はBOMが必要です。 |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
902 その場合は一度キャンセルして Ctrl キーを押しながらボタンクリックして下さい。 |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
903 逆にExcel以外(GoogleスプレッドシートやLibreOfficeや他のツール)で読む場合はBOMをつけるとファイルの1行目の先頭にゴミのようなものが見える場合あるのでそのときは除去する必要があります。 |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
904 今後もBOM不要の場合はShiftキーを押しながらクリックして下さい。 |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
905 If you feed this CSV into Microsoft Excel, consider adding BOM sequence that can be prepended by pressing Control key with click. |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
906 In this case, click CSVget with ctrl key after Cancel this dialog. |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
907 If you never need BOM, press Shift key with click.`)) |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
908 return; |
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
909 } |
989 | 910 outcsv = [] |
911 for (let row of blogtbl.querySelectorAll("tr[id]")) { | |
912 let tds = row.querySelectorAll("td"), | |
913 a = tds[0].querySelector("a.author"), | |
914 author = a.title, | |
915 name = a.innerText, | |
916 time = tds[0].querySelector("span").title, | |
917 id = tds[1].id, | |
918 body = tds[1].textContent; | |
919 //console.log(`${author},${name},${time},#${id},${body}`); | |
920 outcsv.push({ | |
921 "author": author, "name": name, "time": time, | |
922 "id": "#"+id, "body": body}); | |
923 } | |
924 let line = new CSV(outcsv, {header:true}).encode(), | |
992
17cdef0e8767
Remove trailing suffixes from file name(CSVget)
HIROSE Yuuji <yuuji@gentei.org>
parents:
991
diff
changeset
|
925 fn = myurl.replace(/.*\?/, "").replaceAll("+", "-") |
17cdef0e8767
Remove trailing suffixes from file name(CSVget)
HIROSE Yuuji <yuuji@gentei.org>
parents:
991
diff
changeset
|
926 .replace(/#.*/, "").replace("-n:all", ""); |
997
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
927 downloadFile(fn+".csv", line, needBOM); |
989 | 928 } |
929 function getTextContentCSV(e) { | |
930 if (!document.getElementById("csvminjs")) { | |
931 let csvmin = document.createElement("script"); | |
932 csvmin.src="https://www.yatex.org/libcache/csv.min.js"; | |
933 csvmin.id = "csvminjs"; | |
934 // https://stackoverflow.com/questions/14521108/dynamically-load-js-inside-js | |
935 csvmin.addEventListener("load", ()=>{ | |
936 getTextContentCSV_1(e)}, 10); | |
937 document.querySelector("head").appendChild(csvmin); | |
938 } else { | |
939 getTextContentCSV_1(e); | |
940 } | |
941 } | |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
942 function initBlogs() { |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
943 // (1)Auto-complete #xxxx, (2)Prepare sort |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
944 |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
945 // (1)Complete #xxxx |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
946 let i, check = collectElementsByAttr("input", "name", "notifyto"); |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
947 let blogheadtd = document.querySelector("table.bloghead tr td"); |
586 | 948 if (check) |
900
1fa8b4440f8f
Update button changed to ajax
HIROSE Yuuji <yuuji@gentei.org>
parents:
899
diff
changeset
|
949 for (i of check) { |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
950 i.addEventListener("click", insertRedirect, false); |
586 | 951 } |
906
9f237a8f550d
Add eventListener to newly added TR contents
HIROSE Yuuji <yuuji@gentei.org>
parents:
902
diff
changeset
|
952 registInsertDirect(document.querySelectorAll("a[href]")); |
911
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
953 if (myurl.match(/replyblog\+[0-9]/) |
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
954 && document.querySelector("td.repl")) { |
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
955 // There's no need to provide ajax posting when |
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
956 // no replies written to the blog. Therefore we |
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
957 // assign ajax post when td.repl exists. |
909
1442d73c55e5
Cannot fire ajax when blog has no articles
HIROSE Yuuji <yuuji@gentei.org>
parents:
907
diff
changeset
|
958 for (i of document.querySelectorAll('input#c[value="送信"]')) { |
1442d73c55e5
Cannot fire ajax when blog has no articles
HIROSE Yuuji <yuuji@gentei.org>
parents:
907
diff
changeset
|
959 let b = document.createElement("button"); |
1442d73c55e5
Cannot fire ajax when blog has no articles
HIROSE Yuuji <yuuji@gentei.org>
parents:
907
diff
changeset
|
960 b.textContent = "送信!"; |
1442d73c55e5
Cannot fire ajax when blog has no articles
HIROSE Yuuji <yuuji@gentei.org>
parents:
907
diff
changeset
|
961 b.addEventListener("click", ajaxPost, false); |
1442d73c55e5
Cannot fire ajax when blog has no articles
HIROSE Yuuji <yuuji@gentei.org>
parents:
907
diff
changeset
|
962 // i.insertAdjacentElement('afterend', b); |
910
043748271354
Copy attributes from old POST button to new ajax-post button
HIROSE Yuuji <yuuji@gentei.org>
parents:
909
diff
changeset
|
963 b.setAttribute("class", i.getAttribute("class")) |
043748271354
Copy attributes from old POST button to new ajax-post button
HIROSE Yuuji <yuuji@gentei.org>
parents:
909
diff
changeset
|
964 b.setAttribute("title", i.getAttribute("title")) |
043748271354
Copy attributes from old POST button to new ajax-post button
HIROSE Yuuji <yuuji@gentei.org>
parents:
909
diff
changeset
|
965 i.parentNode.replaceChild(b, i); |
909
1442d73c55e5
Cannot fire ajax when blog has no articles
HIROSE Yuuji <yuuji@gentei.org>
parents:
907
diff
changeset
|
966 b.id = i.id; |
914
cfb6247a2266
Add auxiliary submit button
HIROSE Yuuji <yuuji@gentei.org>
parents:
911
diff
changeset
|
967 // i.remove(); |
cfb6247a2266
Add auxiliary submit button
HIROSE Yuuji <yuuji@gentei.org>
parents:
911
diff
changeset
|
968 i.classList.add("aux"); |
cfb6247a2266
Add auxiliary submit button
HIROSE Yuuji <yuuji@gentei.org>
parents:
911
diff
changeset
|
969 i.value = "送信(予備)" |
cfb6247a2266
Add auxiliary submit button
HIROSE Yuuji <yuuji@gentei.org>
parents:
911
diff
changeset
|
970 b.parentNode.appendChild(i); |
909
1442d73c55e5
Cannot fire ajax when blog has no articles
HIROSE Yuuji <yuuji@gentei.org>
parents:
907
diff
changeset
|
971 } |
911
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
972 i = document.getElementById("reload"); |
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
973 if (i) i.addEventListener("click", ajaxPost, false); |
989 | 974 // Add CSV download button |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
975 if (blogheadtd) { |
989 | 976 let btn = document.createElement("button"); |
977 btn.innerText = "CSVget"; | |
978 btn.type = "button"; | |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
979 btn.accessKey = "g"; |
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
980 btn.title = `Shortcut: G |
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
981 見えている書き込みをCSVで取得します |
989 | 982 全件表示されていることを確認してから利用して下さい。 |
997
f7cd4528926b
Warning message for BOM fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
993
diff
changeset
|
983 Excelで利用する場合は Ctrl を押しながらクリックして下さい。 |
989 | 984 Get seen TEXT content as CSV.`; |
985 btn.addEventListener("click", getTextContentCSV, false); | |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
986 let artlink = blogheadtd.querySelector('a[accesskey="f"]'); |
989 | 987 let spacer = document.createElement("span"); |
991
b563e1ff9e74
CSVget button position fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
990
diff
changeset
|
988 if (artlink) { |
b563e1ff9e74
CSVget button position fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
990
diff
changeset
|
989 spacer.innerText = "|"; |
b563e1ff9e74
CSVget button position fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
990
diff
changeset
|
990 artlink.insertAdjacentElement('beforebegin', btn); |
b563e1ff9e74
CSVget button position fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
990
diff
changeset
|
991 artlink.insertAdjacentElement('beforebegin', spacer); |
b563e1ff9e74
CSVget button position fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
990
diff
changeset
|
992 } else { |
b563e1ff9e74
CSVget button position fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
990
diff
changeset
|
993 spacer.innerText = " "; |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
994 blogheadtd.appendChild(spacer); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
995 blogheadtd.appendChild(btn); |
991
b563e1ff9e74
CSVget button position fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
990
diff
changeset
|
996 } |
989 | 997 } |
911
fe6e6b72de17
Restrict ajax button activation to certain case
HIROSE Yuuji <yuuji@gentei.org>
parents:
910
diff
changeset
|
998 } |
902 | 999 for (i of document.querySelectorAll('input[type="file"]')) { |
1000 i.addEventListener('change', (e) => { | |
1001 warnFileSize(document.forms[0]); | |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
1002 }, false) |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
1003 } |
1002
47b3e770372d
Auth-ON/OFF button available in all modes
HIROSE Yuuji <yuuji@gentei.org>
parents:
1001
diff
changeset
|
1004 if (i=document.getElementById("hideauth")) { |
969
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
1005 i.addEventListener('click', toggleAuthorVisibility, false); |
b327b5691b59
Add author-hide/show button in quiz mode
HIROSE Yuuji <yuuji@gentei.org>
parents:
964
diff
changeset
|
1006 } |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
1007 // Hack article_m links |
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
1008 registPjaxViewers(document.querySelectorAll("a[href]")); |
964 | 1009 atMarkView(document); |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1010 /*****************************************************************/ |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1011 //(2) Prepare sort |
1040 | 1012 let limit50 = document.getElementById("showall"); |
1013 if (blogheadtd && limit50==null) { | |
1036
9c392ddb4d8a
Add shortcut to sort-button
HIROSE Yuuji <yuuji@gentei.org>
parents:
1035
diff
changeset
|
1014 let umode = "byUser", amode = "byArticle"; |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1015 let sbtn = document.createElement("button"); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1016 sbtn.textContent = umode; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1017 sbtn.type = 'button'; |
1036
9c392ddb4d8a
Add shortcut to sort-button
HIROSE Yuuji <yuuji@gentei.org>
parents:
1035
diff
changeset
|
1018 sbtn.accessKey = "o"; |
9c392ddb4d8a
Add shortcut to sort-button
HIROSE Yuuji <yuuji@gentei.org>
parents:
1035
diff
changeset
|
1019 sbtn.title = `Shortcut: O |
9c392ddb4d8a
Add shortcut to sort-button
HIROSE Yuuji <yuuji@gentei.org>
parents:
1035
diff
changeset
|
1020 書き込みを著者順に並べ替えます(全件表示時のみ)。 |
9c392ddb4d8a
Add shortcut to sort-button
HIROSE Yuuji <yuuji@gentei.org>
parents:
1035
diff
changeset
|
1021 特定のユーザの書き込みを探すときに有用です。 |
9c392ddb4d8a
Add shortcut to sort-button
HIROSE Yuuji <yuuji@gentei.org>
parents:
1035
diff
changeset
|
1022 Sort articles by UserID or ArticleID. |
9c392ddb4d8a
Add shortcut to sort-button
HIROSE Yuuji <yuuji@gentei.org>
parents:
1035
diff
changeset
|
1023 Handy at searching for articles by certain user.`; |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1024 let spacer = document.createElement("span"); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1025 spacer.textContent = " "; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1026 let hide = document.getElementById("hideauth"); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1027 if (hide) { |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1028 hide.insertAdjacentElement('afterend', sbtn); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1029 hide.insertAdjacentElement('afterend', spacer); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1030 } else { |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1031 blogheadtd.appendChild(spacer); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1032 blogheadtd.appendChild(sbtn); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1033 } |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1034 function compareRowsByUid(a, b) { |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1035 if (a.key1 < b.key1) return -1; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1036 if (a.key1 > b.key1) return 1; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1037 if (a.key2 < b.key2) return -1; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1038 if (a.key2 > b.key2) return 1; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1039 return 0; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1040 } |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1041 function compareRowsByAid(a, b) { |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1042 if (a.key2 < b.key2) return -1; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1043 if (a.key2 > b.key2) return 1; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1044 return 0; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1045 } |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1046 sbtn.addEventListener("click", (e)=>{ |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1047 let uidsort = (sbtn.textContent.indexOf(umode) >= 0); |
1037
634fee6a6bd2
Add row number to title attribute after sort.
HIROSE Yuuji <yuuji@gentei.org>
parents:
1036
diff
changeset
|
1048 let rows = [], elm, i=0, |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1049 tbl = document.querySelector("table.blog_replies"); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1050 for (let tr of tbl.rows) { |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1051 elm = {}; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1052 elm.tr = tr; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1053 elm.key1 = tr.querySelector("a.author").title; // userid |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1054 tr.innerHTML.match(/<a href="(#[0-9]+)">\1</); // ArticleID |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1055 elm.key2 = RegExp.$1; |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1056 rows.push(elm); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1057 } |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1058 rows.sort(uidsort ? compareRowsByUid : compareRowsByAid); |
1037
634fee6a6bd2
Add row number to title attribute after sort.
HIROSE Yuuji <yuuji@gentei.org>
parents:
1036
diff
changeset
|
1059 for (let r of rows) { |
634fee6a6bd2
Add row number to title attribute after sort.
HIROSE Yuuji <yuuji@gentei.org>
parents:
1036
diff
changeset
|
1060 tbl.appendChild(r.tr); |
634fee6a6bd2
Add row number to title attribute after sort.
HIROSE Yuuji <yuuji@gentei.org>
parents:
1036
diff
changeset
|
1061 r.tr.title = ++i; |
634fee6a6bd2
Add row number to title attribute after sort.
HIROSE Yuuji <yuuji@gentei.org>
parents:
1036
diff
changeset
|
1062 } |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1063 sbtn.textContent = uidsort ? amode : umode; |
1043
dd1115454635
Reset pjaxViewers when byUser/byArticle button pressed
HIROSE Yuuji <yuuji@gentei.org>
parents:
1040
diff
changeset
|
1064 // Re-sort pjax viewer links |
1044
41921e6ada54
Modify procedure of resetPjaxViewers()
HIROSE Yuuji <yuuji@gentei.org>
parents:
1043
diff
changeset
|
1065 resetPjaxViewers(document.querySelectorAll("a[href]")); |
1035
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1066 }); |
e8f73df7ed5d
Add "sort by uid" button to blog table
HIROSE Yuuji <yuuji@gentei.org>
parents:
1013
diff
changeset
|
1067 } |
1040 | 1068 /*****************************************************************/ |
1069 //(3) Prepare Filtering by Team | |
1070 let teamfilter = document.getElementById("team4filter"); | |
1071 if (blogheadtd && teamfilter) { | |
1072 let teams = {}; | |
1073 for (let row of teamfilter.querySelectorAll("tr")) { | |
1074 let cols = row.querySelectorAll("td"); | |
1075 if (cols.length == 2) { | |
1076 // <TD>TeamName</TD><TD>["user1@dom1","user2@dom2"]</td> | |
1077 teams[cols[0].textContent] = cols[1].textContent; | |
1078 } | |
1079 } | |
1080 if (Object.keys(teams).length > 0) { | |
1081 function filterArticles(e) { | |
1082 if (limit50) { | |
1083 if (window.confirm(`表示数制限があります。 | |
1084 全件表示に切り替えますか。Cencel すると限定表示のまま絞り込みます。 | |
1085 Not all articles are seen. | |
1086 Push OK to switch to all-articles mode, Cencel to continue without limit.`)) { | |
1087 limit50.click(); | |
1088 return; | |
1089 } | |
1090 } | |
1091 let userlist; | |
1092 try { | |
1093 userlist = JSON.parse(e.target.value); | |
1094 } catch (e) { | |
1095 return; | |
1096 } | |
1097 let showall = (userlist == ""); | |
1098 let tbl = document.querySelector("table.blog_replies"); | |
1099 for (let row of tbl.querySelectorAll("tr")) { | |
1100 let author = row.querySelector("a[title]"); | |
1101 let visible = true; | |
1102 if (!showall && author) { | |
1103 let home = author.href; | |
1104 if (home && home.match(/home\+([0-9]+)/)) { | |
1105 let uid = RegExp.$1; | |
1106 visible = userlist.find(e=>e==uid) | |
1107 } | |
1108 } | |
1109 if (visible) | |
1110 row.classList.remove("hide") | |
1111 else | |
1112 row.classList.add("hide") | |
1113 filterOption = e.target.selectedIndex; | |
1114 } | |
1115 | |
1116 } | |
1117 // Do Filter Addition | |
1118 let optall = document.createElement("option"); | |
1119 filterSelect = document.createElement("select"); | |
1120 optall.textContent = "-- ALL(全件) --"; | |
1121 optall.value = '""'; // -> showall=true | |
1122 filterSelect.appendChild(optall); | |
1123 filterSelect.addEventListener('change', filterArticles, false) | |
1124 for (let k in teams) { | |
1125 let o = document.createElement("option"); | |
1126 o.textContent = k; | |
1127 o.value = teams[k]; | |
1128 filterSelect.appendChild(o); | |
1129 } | |
1130 let table = document.querySelector("table.blog_replies"); | |
1131 if (table) { | |
1132 let p = document.createElement("p"); | |
1133 p.textContent = "Filter by TEAM: "; | |
1134 p.classList.add("filter"); | |
1135 p.appendChild(filterSelect); | |
1136 table.insertAdjacentElement('beforebegin', p) | |
1137 } | |
1138 } | |
1139 } | |
586 | 1140 } |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1141 function initGrpAction() { |
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1142 var rev = document.getElementById("reverse"); |
667
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1143 if (!rev) return; // Is not grpAction page |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1144 if (rev.tagName.match(/span/i)) { |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1145 rev.textContent = " 反転 "; |
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1146 rev.addEventListener("click", reverseChecks, null); |
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1147 } |
667
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1148 var emailbtn = document.getElementById("email"); |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1149 emailbtn.addEventListener("click", function(ev){ |
675
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1150 // Enlarge box and Select user's checkbox |
667
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1151 if (!ev.target.checked) return; |
673
42bf03cb3712
Enlarge div of form field when bring them visible
HIROSE Yuuji <yuuji@gentei.org>
parents:
667
diff
changeset
|
1152 var x = collectElementsByAttr("div", "class", "foldtabs"); |
42bf03cb3712
Enlarge div of form field when bring them visible
HIROSE Yuuji <yuuji@gentei.org>
parents:
667
diff
changeset
|
1153 if (x && x[0] && x[0].style) { |
42bf03cb3712
Enlarge div of form field when bring them visible
HIROSE Yuuji <yuuji@gentei.org>
parents:
667
diff
changeset
|
1154 x[0].style.height = "10em"; |
42bf03cb3712
Enlarge div of form field when bring them visible
HIROSE Yuuji <yuuji@gentei.org>
parents:
667
diff
changeset
|
1155 } |
667
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1156 let myuid = document.getElementById("myuid"); |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1157 if (myuid) { |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1158 let usel = collectElementsByAttr("input", "name", "usel"); |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1159 if (usel) { |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1160 for (u of usel) { |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1161 if (u.value == myuid.value) |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1162 u.checked = true; |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1163 } |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1164 } |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1165 } |
9ee0e242c25a
Grp-Message customized for Report-handout
HIROSE Yuuji <yuuji@gentei.org>
parents:
659
diff
changeset
|
1166 }, null); |
675
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1167 var teamsel = document.getElementById("selteam"); |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1168 if (teamsel) { |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1169 var usel, p, team; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1170 // Select all members of the team |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1171 teamsel.addEventListener("change", function(ev) { |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1172 var teamname = teamsel.value, |
676
cd6f0badcff4
\b cannot be used for Japanese boundary...
HIROSE Yuuji <yuuji@gentei.org>
parents:
675
diff
changeset
|
1173 selected = new RegExp('(^| )'+teamname+"($|,)"); |
675
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1174 usel = collectElementsByAttr("input", "name", "usel"); |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1175 if (!usel) return; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1176 for (u of usel) { |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1177 p = u.parentNode; // should be label |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1178 if (!p) continue; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1179 if (teamname == "TEAM") { // Reset all checks |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1180 u.checked = false; // when "TEAM" is selected |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1181 } else { |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1182 p = p.parentNode.parentNode;// should be tr |
987
e71a86651d72
Table in GrpAction page contains userid(localpart) for summary
HIROSE Yuuji <yuuji@gentei.org>
parents:
984
diff
changeset
|
1183 team = nthChildOf(p, 5, "td") |
675
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1184 if (team && team.textContent |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1185 && team.textContent.match(selected)) { |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1186 u.checked = true; |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1187 } |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1188 } |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1189 } |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1190 }, null); |
9c54908814be
Team selection in GrpAction anabled with js
HIROSE Yuuji <yuuji@gentei.org>
parents:
673
diff
changeset
|
1191 } |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1192 } |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1193 function dispInfoMomentary(msg, elem) { |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1194 // Momentarily display MSG in tooltip-baloon relative to ELEM element. |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1195 let help = document.createElement("p"); |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1196 elem.style.position = 'relative'; |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1197 elem.style.overflow = 'visible'; |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1198 help.setAttribute("class", "info-tooltip"); |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1199 help.innerHTML = msg; |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1200 elem.appendChild(help); |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1201 setTimeout(() => { |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1202 help.classList.add("dissolving"); |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1203 setTimeout(() => help.remove(), 3000); |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1204 }, 1000); |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1205 } |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1206 function initGrphome() { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1207 console.log("initGrphome"); |
894 | 1208 // (1)Setup Frozen State Changing Button |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1209 var ja = navigator.language.match(/ja/i); |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1210 |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1211 function toggleFrozen(e, rowid) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1212 let tgt = mypath+"?blog_setfrozen+"+rowid; |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1213 let td = e.target.parentNode; |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1214 let tr = td.parentNode; |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1215 fetch(tgt, { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1216 method: "POST", |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1217 headers: {'Content-Type': 'text/html; charset=utf-8'}, |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
1218 credentials: "include" |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1219 }).then(function(resp) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1220 return resp.text(); |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1221 }).then(function(tbody) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1222 try { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1223 var json = JSON.parse(tbody); |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1224 } catch (e) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1225 return; |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1226 } |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1227 let state = json.state, newstate, info; |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1228 if (json.alert) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1229 alert(json.alert) |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1230 } |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1231 if (state.match(/frozen/i)) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1232 newstate = "凍結"; |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1233 info = ja ? newstate+"に設定しました" : 'Set Frozen'; |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1234 } else { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1235 newstate = null; |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1236 info = ja ? '稼動に設定しました' : 'Set Running'; |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1237 } |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1238 tr.setAttribute("class", newstate); |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1239 dispInfoMomentary(info, td); |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1240 }); |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1241 } |
894 | 1242 let btn = document.querySelectorAll("button.toggle-frozen"); |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1243 for (let b of btn) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1244 let rowid = null; |
893
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1245 let td=b.parentNode, tr = td.parentNode, fr, ru; |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1246 ru = ja ? "動" : "Running"; |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1247 fr = ja ? "凍" : "Frozen"; |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1248 b.setAttribute('frozen-marker', fr); |
c1a5d137740d
Display momentary information of frozen state change
HIROSE Yuuji <yuuji@gentei.org>
parents:
889
diff
changeset
|
1249 b.setAttribute('running-marker', ru); |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1250 for (let a of tr.querySelectorAll("a[href]")) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1251 if (a.getAttribute("href").match(/\?replyblog\+([0-9]+)/)) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1252 rowid = parseInt(RegExp.$1); |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1253 break; |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1254 } |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1255 } |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1256 if (rowid && rowid>0) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1257 b.addEventListener("click", function(e) { |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1258 if (!btn) return; |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1259 toggleFrozen(e, rowid); |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1260 }, false); |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1261 b.setAttribute("title", "稼動/凍結をその場で切り替えます\n\ |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1262 Toggle Running/Frozen ("+rowid+")"); |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1263 } |
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1264 } |
894 | 1265 // (2)Setup Column Collapse Button |
1266 // INCOMPLETE: Cannot restore original state, but it's enough... | |
1267 function toggleColmnWidth(th) { | |
1268 let tbl = document.querySelector("table.dumpblogs"); | |
1269 let colname = th.textContent, newwidth; | |
1270 if (th.style.width) { | |
1271 newwidth = null | |
1272 // https://developer.mozilla.org/ja/docs/Web/CSS/table-layout | |
1273 tbl.style.tableLayout = 'auto'; | |
1274 tbl.style.width = null; | |
1275 } else { | |
1276 newwidth = "2em"; | |
1277 tbl.style.tableLayout = 'fixed'; | |
1278 tbl.style.width = '100%'; | |
1279 } | |
1280 th.style.width = newwidth; | |
1281 th.style.overflow = "hidden"; | |
1282 for (let td of document.querySelectorAll("td."+colname)) { | |
1283 console.log(td.tagName); | |
1284 td.style.width = newwidth; | |
1285 console.log(td.style.width); | |
1286 } | |
1287 } | |
1288 let row1 = document.querySelector("table.dumpblogs tr:first-child"); | |
1289 if (row1) { | |
1290 let heads = row1.querySelectorAll("th"); | |
1291 for (let h of heads) { | |
1292 h.addEventListener("click", function(e) { | |
1293 toggleColmnWidth(h); | |
1294 }, false); | |
1295 h.setAttribute("title", "Click to shrink these columns"); | |
1296 } | |
1297 } | |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1298 } |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1299 function initMath() { |
959
193d9d2ed9c9
Avoid "not defined" exception for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
954
diff
changeset
|
1300 mathjax = window.MathJax||document.getElementById("mathjax"); |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1301 if (!mathjax) return; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1302 let ta = document.querySelector("textarea"); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1303 if (!ta) return; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1304 let btn = document.createElement("button"); |
954
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1305 btn.setAttribute("title", "\\( と \\) で数式利用\n"+ |
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1306 "\\[ と \\] で段組み数式モード\n"+ |
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1307 "便利なマクロ:\n"+ |
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1308 " \\boxed{aaa}, \\fcolorbox{framecolor}{bgcolor}{text}\n"+ |
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1309 " \\underline{aaa}, \\fcolorbox{framecolor}{bgcolor}{text}\n"+ |
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1310 "独自定義マクロ:\n"+ |
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1311 " \\warn{xxx} 注意喚起用色付き枠\n"+ |
ab78a6e229a6
Add some macros for MathJax
HIROSE Yuuji <yuuji@gentei.org>
parents:
949
diff
changeset
|
1312 " \\Warn{xxx} 大きな文字で注意喚起") |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1313 btn.innerHTML = "MathJax<br>Preview"; |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1314 btn.addEventListener('click', (e) => { |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1315 e.preventDefault(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1316 ta.focus(); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1317 helpMarkdownPreview(ta); |
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1318 }); |
949
d8a258cc8a7d
Insert-position of MathJax Preview button changed
HIROSE Yuuji <yuuji@gentei.org>
parents:
948
diff
changeset
|
1319 ta.parentNode.appendChild(btn); |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1320 } |
981
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1321 function rewriteReplyHover(unit) { |
973 | 1322 function getTextById(id) { |
974 | 1323 let repltd = document.getElementById(id); |
1324 if (repltd) { | |
1325 let txt = repltd.innerText, | |
1326 authtd = repltd.parentNode.getElementsByTagName("td")[0], | |
976
ae6c5df09f22
Add class="author" to link of author
HIROSE Yuuji <yuuji@gentei.org>
parents:
975
diff
changeset
|
1327 author = authtd.querySelector("a.author").innerText, |
974 | 1328 digest = txt.split("\n").splice(0, hoverTextLines).join("\n"); |
984
a094bd547d6b
Escape chars in hover string
HIROSE Yuuji <yuuji@gentei.org>
parents:
982
diff
changeset
|
1329 return escapeChars("[[ "+author+" ]]\n"+digest); |
974 | 1330 } else |
1331 return ""; | |
972
8781f341d93a
Add referring text to hover title of ">#xxxx" marks.
HIROSE Yuuji <yuuji@gentei.org>
parents:
969
diff
changeset
|
1332 } |
975
ec5cb1790119
Apply referring hover to td ajax-posted
HIROSE Yuuji <yuuji@gentei.org>
parents:
974
diff
changeset
|
1333 unit = unit||document; |
ec5cb1790119
Apply referring hover to td ajax-posted
HIROSE Yuuji <yuuji@gentei.org>
parents:
974
diff
changeset
|
1334 for (let td of unit.querySelectorAll("td.repl")) { |
1000
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1335 let firstC = td.firstChild; |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1336 // Direct replacing innerHTML breaks embedded DOM event handlers. |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1337 // So, we split td.repl into elements and replace the first |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1338 // textNode(nodeType==3) with hover-text embeded content. |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1339 if (firstC.nodeType==3 && firstC.nodeValue.startsWith(">#")) { |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1340 let newline = firstC.nodeValue.indexOf("\n"); |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1341 let firstline; |
979
084326d5ba19
FIX: JS return -1 when string-search fails...
HIROSE Yuuji <yuuji@gentei.org>
parents:
978
diff
changeset
|
1342 if (newline > 0) { |
1000
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1343 firstline = firstC.nodeValue.substring(0, 1+newline); |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1344 firstC.nodeValue = firstC.nodeValue.substring(1+newline); |
977 | 1345 } else { |
1000
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1346 // Cannot be reached here, but leave this for robustness |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1347 firstline = firstC.nodeValue; |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1348 firstC.nodeValue = ""; |
977 | 1349 } |
1000
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1350 td.insertAdjacentHTML( |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1351 'afterbegin', |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1352 escapeChars(firstline).replace( |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1353 /#([0-9]+)/g, |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1354 (match, start, whole) => { |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1355 let id = RegExp.$1 |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1356 return '<a title="' + getTextById(id) |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1357 + '" href="' + match |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1358 + '">' + match + '</a>'; |
ddf85e80f64e
Hover text for reply marks were breaking pjax view, fixed.
HIROSE Yuuji <yuuji@gentei.org>
parents:
997
diff
changeset
|
1359 })); |
972
8781f341d93a
Add referring text to hover title of ">#xxxx" marks.
HIROSE Yuuji <yuuji@gentei.org>
parents:
969
diff
changeset
|
1360 } |
8781f341d93a
Add referring text to hover title of ">#xxxx" marks.
HIROSE Yuuji <yuuji@gentei.org>
parents:
969
diff
changeset
|
1361 } |
8781f341d93a
Add referring text to hover title of ">#xxxx" marks.
HIROSE Yuuji <yuuji@gentei.org>
parents:
969
diff
changeset
|
1362 } |
981
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1363 function initReplyHover(unit) { |
982
f5a7fbd6c0d0
Add reference URL in a comment
HIROSE Yuuji <yuuji@gentei.org>
parents:
981
diff
changeset
|
1364 // https://stackoverflow.com/questions/60154233/event-when-typesetting-is-done-mathjax-3 |
981
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1365 if (mathjax && MathJax.startup) |
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1366 MathJax.startup.promise.then(()=>rewriteReplyHover()); |
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1367 else |
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1368 rewriteReplyHover(); |
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1369 } |
1003
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1370 var getHandoutCSV; |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1371 function initGetHandoutCSV() { |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1372 getHandoutCSV = document.getElementById("gethandoutcsv"); |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1373 if (!getHandoutCSV) return; |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1374 document.getElementById("bommsg").innerText = |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1375 `Excelで開く場合は上記CSVリンクをCtrlを押しながら。 |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1376 You need to click CSV link above with Ctrl-key when you handle CSV with Excel`; |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1377 getHandoutCSV.addEventListener("click", (e) => { |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1378 e.preventDefault(); // Stop visiting link |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1379 let bom = e.ctrlKey; |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1380 let csv = document.getElementById("totalcsv"); |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1381 if (!csv || !csv.textContent) return; |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1382 let fn = "report-count", plus=myurl.lastIndexOf("+"); |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1383 if (plus) fn += ("-"+myurl.substring(1+plus)); |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1384 fn = fn.replace(/#.*/, ""); |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1385 downloadFile(fn+".csv", csv.textContent, bom); |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1386 }); |
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1387 } |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1388 function init() { |
898
411ce55c0dae
AJAX posting and PJAX file-viewer initially introduced.
HIROSE Yuuji <yuuji@gentei.org>
parents:
894
diff
changeset
|
1389 isOlderJS = !("insertAdjacentElement" in document.body); |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1390 initGrpAction(); |
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1391 initBlogs(); |
837
a6462eea48be
Multiple files upload for tablets added and file renaming fixed
HIROSE Yuuji <yuuji@gentei.org>
parents:
676
diff
changeset
|
1392 initFileInput(); |
846
9c4e16c173db
Add support for small help on describing markdown
HIROSE Yuuji <yuuji@gentei.org>
parents:
837
diff
changeset
|
1393 initTextarea(); |
889
5843755e3b30
The beginning of AJAX operations
HIROSE Yuuji <yuuji@gentei.org>
parents:
852
diff
changeset
|
1394 initGrphome(); |
946
420ad90116e6
MathJax preview initial version
HIROSE Yuuji <yuuji@gentei.org>
parents:
945
diff
changeset
|
1395 initMath(); |
981
eb51a80f73c2
Divide task of ReplyHover()
HIROSE Yuuji <yuuji@gentei.org>
parents:
980
diff
changeset
|
1396 initReplyHover(); |
1003
5bd1b5125049
Direct link to lshandoutall in group home for grp-admin
HIROSE Yuuji <yuuji@gentei.org>
parents:
1002
diff
changeset
|
1397 initGetHandoutCSV(); |
659
a36a2c3b3056
GrpAction: Reverse selection and supplemental rcpt address
HIROSE Yuuji <yuuji@gentei.org>
parents:
590
diff
changeset
|
1398 } |
586 | 1399 document.addEventListener('DOMContentLoaded', init, null); |
1400 })(); |