Rev 356 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 356 | Rev 360 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | 21 | ||
22 | var current_node = ""; |
22 | var current_node = ""; |
23 | var popstate_running = false; |
23 | var popstate_running = false; |
24 | var externalWaiting = 0; |
24 | var externalWaiting = 0; |
25 | var DEFAULT_LANGUAGE = "enus"; |
25 | var DEFAULT_LANGUAGE = "enus"; |
- | 26 | // language_messages will be set by oidplus.min.js.php |
|
- | 27 | // language_tblprefix will be set by oidplus.min.js.php |
|
26 | 28 | ||
27 | function oidplus_loadScript(src) { |
29 | function oidplus_loadScript(src) { |
28 | externalWaiting++; |
30 | externalWaiting++; |
29 | var script = document.createElement('script'); |
31 | var script = document.createElement('script'); |
30 | script.onload = function () { |
32 | script.onload = function () { |
31 | externalWaiting--; |
33 | externalWaiting--; |
32 | }; |
34 | }; |
33 | script.src = src; |
35 | script.src = src; |
34 | script.rel = "preload" |
36 | script.rel = "preload"; |
35 | document.head.appendChild(script); |
37 | document.head.appendChild(script); |
36 | } |
38 | } |
37 | 39 | ||
38 | function isInternetExplorer() { |
40 | function isInternetExplorer() { |
39 | var ua = window.navigator.userAgent; |
41 | var ua = window.navigator.userAgent; |
Line 83... | Line 85... | ||
83 | 85 | ||
84 | return ''; |
86 | return ''; |
85 | } |
87 | } |
86 | 88 | ||
87 | function getOidPlusSystemTitle() { |
89 | function getOidPlusSystemTitle() { |
88 | return getMeta('OIDplus-SystemTitle'); |
90 | return getMeta('OIDplus-SystemTitle'); // do not translate |
89 | } |
91 | } |
90 | 92 | ||
91 | function combine_systemtitle_and_pagetitle(systemtitle, pagetitle) { |
93 | function combine_systemtitle_and_pagetitle(systemtitle, pagetitle) { |
92 | // Please also change the function in index.php |
94 | // Please also change the function in index.php |
93 | if (systemtitle == pagetitle) { |
95 | if (systemtitle == pagetitle) { |
Line 146... | Line 148... | ||
146 | data:{ |
148 | data:{ |
147 | action:"tree_search", |
149 | action:"tree_search", |
148 | search:id |
150 | search:id |
149 | }, |
151 | }, |
150 | error:function(jqXHR, textStatus, errorThrown) { |
152 | error:function(jqXHR, textStatus, errorThrown) { |
151 | console.error("Error: " + errorThrown); |
153 | console.error(_L("Error: %1",errorThrown)); |
152 | }, |
154 | }, |
153 | success:function(data) { |
155 | success:function(data) { |
154 | if ("error" in data) { |
156 | if ("error" in data) { |
155 | console.error(data); |
157 | console.error(data); |
156 | } else if ((data instanceof Array) && (data.length > 0)) { |
158 | } else if ((data instanceof Array) && (data.length > 0)) { |
Line 180... | Line 182... | ||
180 | fetch('ajax.php?action=get_description&id='+encodeURIComponent(id)) |
182 | fetch('ajax.php?action=get_description&id='+encodeURIComponent(id)) |
181 | .then(function(response) { |
183 | .then(function(response) { |
182 | response.json() |
184 | response.json() |
183 | .then(function(data) { |
185 | .then(function(data) { |
184 | if ("error" in data) { |
186 | if ("error" in data) { |
185 | alert(_L("Failed to load content") + ": " + data.error); |
187 | alert(_L("Failed to load content: %1",data.error)); |
186 | console.error(data.error); |
188 | console.error(data.error); |
187 | return; |
189 | return; |
188 | } |
190 | } |
189 | 191 | ||
190 | data.id = id; |
192 | data.id = id; |
Line 214... | Line 216... | ||
214 | if (anchor != '') { |
216 | if (anchor != '') { |
215 | jumpToAnchor(anchor); |
217 | jumpToAnchor(anchor); |
216 | } |
218 | } |
217 | }) |
219 | }) |
218 | .catch(function(error) { |
220 | .catch(function(error) { |
219 | alert(_L("Failed to load content") + ": " + error); |
221 | alert(_L("Failed to load content: %1",error)); |
220 | console.error(error); |
222 | console.error(error); |
221 | }); |
223 | }); |
222 | }) |
224 | }) |
223 | .catch(function(error) { |
225 | .catch(function(error) { |
224 | alert(_L("Failed to load content") + ": " + error); |
226 | alert(_L("Failed to load content: %1",error)); |
225 | console.error(error); |
227 | console.error(error); |
226 | }); |
228 | }); |
227 | } |
229 | } |
228 | 230 | ||
229 | // This function opens the "parentID" node, and then selects the "childID" node (which should be beneath the parent node) |
231 | // This function opens the "parentID" node, and then selects the "childID" node (which should be beneath the parent node) |
Line 357... | Line 359... | ||
357 | }); |
359 | }); |
358 | 360 | ||
359 | $("#gotobox").addClass("mobilehidden"); |
361 | $("#gotobox").addClass("mobilehidden"); |
360 | $("#languageBox").addClass("mobilehidden"); |
362 | $("#languageBox").addClass("mobilehidden"); |
361 | document.getElementById('gotobox').style.display = "block"; |
363 | document.getElementById('gotobox').style.display = "block"; |
362 | document.getElementById('languageBox').style.display = "block"; |
- | |
363 | $('#gotoedit').keypress(function(event) { |
364 | $('#gotoedit').keypress(function(event) { |
364 | var keycode = (event.keyCode ? event.keyCode : event.which); |
365 | var keycode = (event.keyCode ? event.keyCode : event.which); |
365 | if (keycode == '13') { |
366 | if (keycode == '13') { |
366 | gotoButtonClicked(); |
367 | gotoButtonClicked(); |
367 | } |
368 | } |
Line 467... | Line 468... | ||
467 | 468 | ||
468 | if (isInternetExplorer()) { |
469 | if (isInternetExplorer()) { |
469 | // Internet Explorer has problems with sending new cookies to new AJAX requests, so we reload the page completely |
470 | // Internet Explorer has problems with sending new cookies to new AJAX requests, so we reload the page completely |
470 | window.location.reload(); |
471 | window.location.reload(); |
471 | } else { |
472 | } else { |
472 | openOidInPanel(current_node, false); |
473 | reloadContent(); |
473 | mobileNavClose(); |
474 | mobileNavClose(); |
474 | } |
475 | } |
475 | } |
476 | } |
476 | 477 | ||
477 | function getCurrentLang() { |
478 | function getCurrentLang() { |
- | 479 | // Note: If the argument "?lang=" is used, PHP will automatically set a Cookie, so it is OK when we only check for the cookie |
|
478 | var lang = getCookie('LANGUAGE'); |
480 | var lang = getCookie('LANGUAGE'); |
479 | return (typeof lang != "undefined") ? lang : DEFAULT_LANGUAGE; |
481 | return (typeof lang != "undefined") ? lang : DEFAULT_LANGUAGE; |
480 | } |
482 | } |
481 | 483 | ||
482 | function _L(str) { |
484 | function _L() { |
- | 485 | var args = Array.prototype.slice.call(arguments); |
|
- | 486 | var str = args.shift(); |
|
- | 487 | ||
- | 488 | var tmp = ""; |
|
483 | if (typeof language_messages[getCurrentLang()] == "undefined") return str; |
489 | if (typeof language_messages[getCurrentLang()] == "undefined") { |
- | 490 | tmp = str; |
|
- | 491 | } else { |
|
484 | var msg = language_messages[getCurrentLang()][str]; |
492 | var msg = language_messages[getCurrentLang()][str]; |
485 | return (typeof msg != "undefined") ? msg : str; |
493 | if (typeof msg != "undefined") { |
- | 494 | tmp = msg; |
|
- | 495 | } else { |
|
- | 496 | tmp = str; |
|
- | 497 | } |
|
- | 498 | } |
|
- | 499 | ||
- | 500 | tmp = tmp.replace('###', language_tblprefix); |
|
- | 501 | ||
- | 502 | var n = 1; |
|
- | 503 | while (args.length > 0) { |
|
- | 504 | var val = args.shift(); |
|
- | 505 | tmp = tmp.replace("%"+n, val); |
|
- | 506 | n++; |
|
- | 507 | } |
|
- | 508 | ||
- | 509 | return tmp; |
|
486 | } |
510 | } |