Rev 108 | Rev 113 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 108 | Rev 112 | ||
---|---|---|---|
Line 20... | Line 20... | ||
20 | // $('#html').jstree(); |
20 | // $('#html').jstree(); |
21 | 21 | ||
22 | current_node = ""; |
22 | current_node = ""; |
23 | popstate_running = false; |
23 | popstate_running = false; |
24 | 24 | ||
25 | system_title = ""; |
- | |
26 | - | ||
27 | String.prototype.explode = function (separator, limit) { |
25 | String.prototype.explode = function (separator, limit) { |
28 | // https://stackoverflow.com/questions/4514323/javascript-equivalent-to-php-explode |
26 | // https://stackoverflow.com/questions/4514323/javascript-equivalent-to-php-explode |
29 | const array = this.split(separator); |
27 | const array = this.split(separator); |
30 | if (limit !== undefined && array.length >= limit) { |
28 | if (limit !== undefined && array.length >= limit) { |
31 | array.push(array.splice(limit - 1).join(separator)); |
29 | array.push(array.splice(limit - 1).join(separator)); |
Line 39... | Line 37... | ||
39 | 37 | ||
40 | String.prototype.html_entity_decode = function () { |
38 | String.prototype.html_entity_decode = function () { |
41 | return $('<textarea />').html(this).text(); |
39 | return $('<textarea />').html(this).text(); |
42 | }; |
40 | }; |
43 | 41 | ||
- | 42 | function getMeta(metaName) { |
|
- | 43 | const metas = document.getElementsByTagName('meta'); |
|
- | 44 | ||
- | 45 | for (let i = 0; i < metas.length; i++) { |
|
- | 46 | if (metas[i].getAttribute('name') === metaName) { |
|
- | 47 | return metas[i].getAttribute('content'); |
|
- | 48 | } |
|
- | 49 | } |
|
- | 50 | ||
- | 51 | return ''; |
|
- | 52 | } |
|
- | 53 | ||
- | 54 | function getOidPlusSystemTitle() { |
|
- | 55 | return getMeta('OIDplus-SystemTitle') |
|
- | 56 | } |
|
- | 57 | ||
44 | function combine_systemtitle_and_pagetitle(systemtitle, pagetitle) { |
58 | function combine_systemtitle_and_pagetitle(systemtitle, pagetitle) { |
45 | if (systemtitle == pagetitle) { |
59 | if (systemtitle == pagetitle) { |
46 | return systemtitle; |
60 | return systemtitle; |
47 | } else { |
61 | } else { |
48 | return systemtitle + ' - ' + pagetitle; |
62 | return systemtitle + ' - ' + pagetitle; |
Line 61... | Line 75... | ||
61 | openOidInPanel(current_node, false); |
75 | openOidInPanel(current_node, false); |
62 | $('#oidtree').jstree("refresh"); |
76 | $('#oidtree').jstree("refresh"); |
63 | } |
77 | } |
64 | 78 | ||
65 | function x_rec(x_data, i) { |
79 | function x_rec(x_data, i) { |
66 | console.log("rec: " + x_data); |
- | |
67 | $('#oidtree').jstree('open_node', x_data[i], function(e, data) { |
80 | $('#oidtree').jstree('open_node', x_data[i], function(e, data) { |
68 | if (i+1 < x_data.length) { |
81 | if (i+1 < x_data.length) { |
69 | x_rec(x_data, i+1); |
82 | x_rec(x_data, i+1); |
70 | } else { |
83 | } else { |
71 | $('#oidtree').jstree('select_node', x_data[i]); |
84 | $('#oidtree').jstree('select_node', x_data[i]); |
Line 131... | Line 144... | ||
131 | return; |
144 | return; |
132 | } |
145 | } |
133 | 146 | ||
134 | data.id = id; |
147 | data.id = id; |
135 | 148 | ||
136 | document.title = combine_systemtitle_and_pagetitle(system_title, data.title); |
149 | document.title = combine_systemtitle_and_pagetitle(getOidPlusSystemTitle(), data.title); |
137 | var state = { |
150 | var state = { |
138 | "node_id":id, |
151 | "node_id":id, |
139 | "titleHTML":(data.icon ? '<img src="'+data.icon+'" width="48" height="48" alt="'+data.title.htmlentities()+'"> ' : '') + data.title.htmlentities(), |
152 | "titleHTML":(data.icon ? '<img src="'+data.icon+'" width="48" height="48" alt="'+data.title.htmlentities()+'"> ' : '') + data.title.htmlentities(), |
140 | "textHTML":data.text, |
153 | "textHTML":data.text, |
141 | "staticlinkHREF":"index.php?goto="+encodeURIComponent(id), |
154 | "staticlinkHREF":"index.php?goto="+encodeURIComponent(id), |
Line 152... | Line 165... | ||
152 | $('#real_title').html('<img src="'+data.icon+'" width="48" height="48" alt="'+data.title.htmlentities()+'"> ' + data.title.htmlentities()); |
165 | $('#real_title').html('<img src="'+data.icon+'" width="48" height="48" alt="'+data.title.htmlentities()+'"> ' + data.title.htmlentities()); |
153 | } else { |
166 | } else { |
154 | $('#real_title').html(data.title.htmlentities()); |
167 | $('#real_title').html(data.title.htmlentities()); |
155 | } |
168 | } |
156 | $('#real_content').html(data.text); |
169 | $('#real_content').html(data.text); |
157 | document.title = combine_systemtitle_and_pagetitle(system_title, data.title); |
170 | document.title = combine_systemtitle_and_pagetitle(getOidPlusSystemTitle(), data.title); |
158 | current_node = id; |
171 | current_node = id; |
159 | }) |
172 | }) |
160 | .catch(function(error) { |
173 | .catch(function(error) { |
161 | alert("Failed to load content: " + error); |
174 | alert("Failed to load content: " + error); |
162 | console.error(error); |
175 | console.error(error); |
Line 192... | Line 205... | ||
192 | var h1s = document.getElementsByTagName("h1"); |
205 | var h1s = document.getElementsByTagName("h1"); |
193 | for (var i = 0; i < h1s.length; i++) { |
206 | for (var i = 0; i < h1s.length; i++) { |
194 | var h1 = h1s[i]; |
207 | var h1 = h1s[i]; |
195 | h1.innerHTML = document.getElementById('titleedit').value.htmlentities(); |
208 | h1.innerHTML = document.getElementById('titleedit').value.htmlentities(); |
196 | } |
209 | } |
197 | document.title = combine_systemtitle_and_pagetitle(system_title, document.getElementById('titleedit').value); |
210 | document.title = combine_systemtitle_and_pagetitle(getOidPlusSystemTitle(), document.getElementById('titleedit').value); |
198 | 211 | ||
199 | var mce = tinymce.get('description'); |
212 | var mce = tinymce.get('description'); |
200 | if (mce != null) mce.isNotDirty = 1; |
213 | if (mce != null) mce.isNotDirty = 1; |
201 | } else { |
214 | } else { |
202 | alert("Error: " + data.error); |
215 | alert("Error: " + data.error); |
Line 367... | Line 380... | ||
367 | $('#real_title').html(data.titleHTML); |
380 | $('#real_title').html(data.titleHTML); |
368 | $('#real_content').html(data.textHTML); |
381 | $('#real_content').html(data.textHTML); |
369 | $('#static_link').attr("href", data.staticlinkHREF); |
382 | $('#static_link').attr("href", data.staticlinkHREF); |
370 | $('#static_link_desktop').attr("href", data.staticlinkHREF_Desktop); |
383 | $('#static_link_desktop').attr("href", data.staticlinkHREF_Desktop); |
371 | $('#static_link_mobile').attr("href", data.staticlinkHREF_Mobile); |
384 | $('#static_link_mobile').attr("href", data.staticlinkHREF_Mobile); |
372 | document.title = combine_systemtitle_and_pagetitle(system_title, data.titleHTML.html_entity_decode()); |
385 | document.title = combine_systemtitle_and_pagetitle(getOidPlusSystemTitle(), data.titleHTML.html_entity_decode()); |
373 | } catch (err) { |
386 | } catch (err) { |
374 | popstate_running = false; |
387 | popstate_running = false; |
375 | } finally { |
388 | } finally { |
376 | popstate_running = false; |
389 | popstate_running = false; |
377 | } |
390 | } |