Rev 327 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 327 | Rev 355 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | 19 | ||
20 | // $('#html').jstree(); |
20 | // $('#html').jstree(); |
21 | 21 | ||
22 | var current_node = ""; |
22 | var current_node = ""; |
23 | var popstate_running = false; |
23 | var popstate_running = false; |
- | 24 | var DEFAULT_LANGUAGE = "enus"; |
|
24 | 25 | ||
25 | function oidplus_loadScript(src) { |
26 | function oidplus_loadScript(src) { |
26 | var js = document.createElement('script'); |
27 | var js = document.createElement('script'); |
27 | js.src = src; |
28 | js.src = src; |
28 | js.onload = function() { |
29 | js.onload = function() { |
Line 163... | Line 164... | ||
163 | 164 | ||
164 | // This loads the actual content |
165 | // This loads the actual content |
165 | 166 | ||
166 | document.title = ""; |
167 | document.title = ""; |
167 | $('#real_title').html(" "); |
168 | $('#real_title').html(" "); |
168 | $('#real_content').html("Loading..."); |
169 | $('#real_content').html(_L("Loading...")); |
169 | $('#static_link').attr("href", "index.php?goto="+encodeURIComponent(id)); |
170 | $('#static_link').attr("href", "index.php?goto="+encodeURIComponent(id)); |
170 | $("#gotoedit").val(id); |
171 | $("#gotoedit").val(id); |
171 | 172 | ||
172 | // Normal opening of a description |
173 | // Normal opening of a description |
173 | fetch('ajax.php?action=get_description&id='+encodeURIComponent(id)) |
174 | fetch('ajax.php?action=get_description&id='+encodeURIComponent(id)) |
174 | .then(function(response) { |
175 | .then(function(response) { |
175 | response.json() |
176 | response.json() |
176 | .then(function(data) { |
177 | .then(function(data) { |
177 | if ("error" in data) { |
178 | if ("error" in data) { |
178 | alert("Failed to load content: " + data.error); |
179 | alert(_L("Failed to load content") + ": " + data.error); |
179 | console.error(data.error); |
180 | console.error(data.error); |
180 | return; |
181 | return; |
181 | } |
182 | } |
182 | 183 | ||
183 | data.id = id; |
184 | data.id = id; |
Line 207... | Line 208... | ||
207 | if (anchor != '') { |
208 | if (anchor != '') { |
208 | jumpToAnchor(anchor); |
209 | jumpToAnchor(anchor); |
209 | } |
210 | } |
210 | }) |
211 | }) |
211 | .catch(function(error) { |
212 | .catch(function(error) { |
212 | alert("Failed to load content: " + error); |
213 | alert(_L("Failed to load content") + ": " + error); |
213 | console.error(error); |
214 | console.error(error); |
214 | }); |
215 | }); |
215 | }) |
216 | }) |
216 | .catch(function(error) { |
217 | .catch(function(error) { |
217 | alert("Failed to load content: " + error); |
218 | alert(_L("Failed to load content") + ": " + error); |
218 | console.error(error); |
219 | console.error(error); |
219 | }); |
220 | }); |
220 | } |
221 | } |
221 | 222 | ||
222 | // This function opens the "parentID" node, and then selects the "childID" node (which should be beneath the parent node) |
223 | // This function opens the "parentID" node, and then selects the "childID" node (which should be beneath the parent node) |
Line 313... | Line 314... | ||
313 | 314 | ||
314 | // --- Layout |
315 | // --- Layout |
315 | 316 | ||
316 | document.getElementById('system_title_menu').style.display = "block"; |
317 | document.getElementById('system_title_menu').style.display = "block"; |
317 | 318 | ||
- | 319 | var tmpObjectTree = _L("OBJECT TREE").replace(/(.{1})/g,"$1<br>"); |
|
- | 320 | tmpObjectTree = tmpObjectTree.substring(0, tmpObjectTree.length-"<br>".length); |
|
- | 321 | ||
318 | $('#oidtree').addClass('ui-layout-west'); |
322 | $('#oidtree').addClass('ui-layout-west'); |
319 | $('#content_window').addClass('ui-layout-center'); |
323 | $('#content_window').addClass('ui-layout-center'); |
320 | $('#system_title_bar').addClass('ui-layout-north'); |
324 | $('#system_title_bar').addClass('ui-layout-north'); |
321 | glayout = $('#frames').layout({ |
325 | glayout = $('#frames').layout({ |
322 | north__size: 40, |
326 | north__size: 40, |
Line 325... | Line 329... | ||
325 | north__resizable: false, |
329 | north__resizable: false, |
326 | west__size: 450, |
330 | west__size: 450, |
327 | west__spacing_closed: 20, |
331 | west__spacing_closed: 20, |
328 | west__togglerLength_closed: 230, |
332 | west__togglerLength_closed: 230, |
329 | west__togglerAlign_closed: "top", |
333 | west__togglerAlign_closed: "top", |
330 | west__togglerContent_closed: "O<br>B<br>J<br>E<br>C<br>T<br><br>T<BR>R<BR>E<BR>E", |
334 | west__togglerContent_closed: tmpObjectTree, |
331 | west__togglerTip_closed: "Open & Pin Menu", |
335 | west__togglerTip_closed: _L("Open & Pin Menu"), |
332 | west__sliderTip: "Slide Open Menu", |
336 | west__sliderTip: _L("Slide Open Menu"), |
333 | west__slideTrigger_open: "mouseover", |
337 | west__slideTrigger_open: "mouseover", |
334 | center__maskContents: true // IMPORTANT - enable iframe masking |
338 | center__maskContents: true // IMPORTANT - enable iframe masking |
335 | }); |
339 | }); |
336 | 340 | ||
337 | $("#gotobox").addClass("mobilehidden"); |
341 | $("#gotobox").addClass("mobilehidden"); |
- | 342 | $("#languageBox").addClass("mobilehidden"); |
|
338 | document.getElementById('gotobox').style.display = "block"; |
343 | document.getElementById('gotobox').style.display = "block"; |
- | 344 | document.getElementById('languageBox').style.display = "block"; |
|
339 | $('#gotoedit').keypress(function(event) { |
345 | $('#gotoedit').keypress(function(event) { |
340 | var keycode = (event.keyCode ? event.keyCode : event.which); |
346 | var keycode = (event.keyCode ? event.keyCode : event.which); |
341 | if (keycode == '13') { |
347 | if (keycode == '13') { |
342 | gotoButtonClicked(); |
348 | gotoButtonClicked(); |
343 | } |
349 | } |
Line 369... | Line 375... | ||
369 | 375 | ||
370 | $("#oidtree").slideUp("medium").promise().done(function() { |
376 | $("#oidtree").slideUp("medium").promise().done(function() { |
371 | $("#oidtree").addClass("ui-layout-west"); |
377 | $("#oidtree").addClass("ui-layout-west"); |
372 | $("#oidtree").show(); |
378 | $("#oidtree").show(); |
373 | // $("#gotobox").hide(); |
379 | // $("#gotobox").hide(); |
- | 380 | // $("#languageBox").hide(); |
|
374 | $("#gotobox").addClass("mobilehidden"); |
381 | $("#gotobox").addClass("mobilehidden"); |
- | 382 | $("#languageBox").addClass("mobilehidden"); |
|
375 | }); |
383 | }); |
376 | $("#system_title_menu").removeClass("active"); |
384 | $("#system_title_menu").removeClass("active"); |
377 | } |
385 | } |
378 | 386 | ||
379 | function mobileNavOpen() { |
387 | function mobileNavOpen() { |
380 | $("#oidtree").hide(); |
388 | $("#oidtree").hide(); |
381 | $("#oidtree").removeClass("ui-layout-west"); |
389 | $("#oidtree").removeClass("ui-layout-west"); |
382 | $("#oidtree").slideDown("medium"); |
390 | $("#oidtree").slideDown("medium"); |
383 | // $("#gotobox").show(); |
391 | // $("#gotobox").show(); |
- | 392 | // $("#languageBox").show(); |
|
384 | $("#gotobox").removeClass("mobilehidden"); |
393 | $("#gotobox").removeClass("mobilehidden"); |
- | 394 | $("#languageBox").removeClass("mobilehidden"); |
|
385 | $("#system_title_menu").addClass("active"); |
395 | $("#system_title_menu").addClass("active"); |
386 | } |
396 | } |
387 | 397 | ||
388 | function mobileNavButtonClick(sender) { |
398 | function mobileNavButtonClick(sender) { |
389 | if ($("#oidtree").hasClass("ui-layout-west")) { |
399 | if ($("#oidtree").hasClass("ui-layout-west")) { |
Line 403... | Line 413... | ||
403 | 413 | ||
404 | function jumpToAnchor(anchor) { |
414 | function jumpToAnchor(anchor) { |
405 | window.location.href = "#" + anchor; |
415 | window.location.href = "#" + anchor; |
406 | } |
416 | } |
407 | 417 | ||
- | 418 | function getCookie(cname) { |
|
- | 419 | // Source: https://www.w3schools.com/js/js_cookies.asp |
|
- | 420 | var name = cname + "="; |
|
- | 421 | var decodedCookie = decodeURIComponent(document.cookie); |
|
- | 422 | var ca = decodedCookie.split(';'); |
|
- | 423 | for(var i = 0; i <ca.length; i++) { |
|
- | 424 | var c = ca[i]; |
|
- | 425 | while (c.charAt(0) == ' ') { |
|
- | 426 | c = c.substring(1); |
|
- | 427 | } |
|
- | 428 | if (c.indexOf(name) == 0) { |
|
- | 429 | return c.substring(name.length, c.length); |
|
- | 430 | } |
|
- | 431 | } |
|
- | 432 | return undefined; |
|
- | 433 | } |
|
- | 434 | ||
- | 435 | function setLanguage(lngid) { |
|
- | 436 | $.ajax({ |
|
- | 437 | url:"ajax.php", |
|
- | 438 | method:"POST", |
|
- | 439 | data:{ |
|
- | 440 | action:"set_language", |
|
- | 441 | language:lngid |
|
- | 442 | }, |
|
- | 443 | error:function(jqXHR, textStatus, errorThrown) { |
|
- | 444 | console.error("Error: " + errorThrown); |
|
- | 445 | }, |
|
- | 446 | success:function(data) { |
|
- | 447 | if ("error" in data) { |
|
- | 448 | console.error(data); |
|
- | 449 | } else if (data.status == 0) { |
|
- | 450 | $(".lng_flag").each(function(){ |
|
- | 451 | $(this).addClass("picture_grayout"); |
|
- | 452 | }); |
|
- | 453 | $("#lng_flag_"+lngid).removeClass("picture_grayout"); |
|
- | 454 | openOidInPanel(current_node, false); |
|
- | 455 | } else { |
|
- | 456 | console.error(data); |
|
- | 457 | } |
|
- | 458 | } |
|
- | 459 | }); |
|
- | 460 | } |
|
- | 461 | ||
- | 462 | function getCurrentLang() { |
|
- | 463 | var lang = getCookie('LANGUAGE'); |
|
- | 464 | return (typeof lang != "undefined") ? lang : DEFAULT_LANGUAGE; |
|
- | 465 | } |
|
- | 466 | ||
- | 467 | function _L(str) { |
|
- | 468 | if (typeof language_messages[getCurrentLang()] == "undefined") return str; |
|
- | 469 | var msg = language_messages[getCurrentLang()][str]; |
|
- | 470 | return (typeof msg != "undefined") ? msg : str; |
|
- | 471 | } |