common.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /**
  2. * Copyright (c) 2016, 2024, the Open Gallery's contributors
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither Open Gallery nor the names of its contributors
  13. * may be used to endorse or promote products derived from this software
  14. * without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  17. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. * commons.js
  28. *
  29. * Common constants and functions
  30. *
  31. * @author Daniele Bonini <my25mb@aol.com>
  32. * @copyrights (c) 2016, 2024, the Open Gallery's contributors
  33. * @license https://opensource.org/licenses/BSD-3-Clause
  34. */
  35. var blinkTimeoutID = 0;
  36. bFullImageVisible = false;
  37. /**
  38. * Manage the Back/Forward/Refresh button press event is some specific
  39. * conditions such as:
  40. * - inside fullscreen image views
  41. *
  42. * @param {Event} e The window beforeUnoad event object
  43. * @returns {String} the message to show to the user
  44. */
  45. function beforeUnload(e) {
  46. if (bFullImageVisible) {
  47. var confMsg = "\o/";
  48. e.returnValue = confMsg;
  49. e.preventDefault();
  50. return confMsg;
  51. }
  52. }
  53. /**
  54. * Blink the the given text
  55. *
  56. * @param {string} tagID the tag ID containing the text to blink
  57. * @param {string} color the color of the text
  58. * @param {int} interval the interval of the "flashing"
  59. * @returns {void}
  60. */
  61. function blinkMe(tagID, color, interval) {
  62. if ( $(tagID) ) {
  63. if ($(tagID).css("color") !== "transparent") {
  64. color = $(tagID).css("color");
  65. $(tagID).css("color", "transparent");
  66. } else {
  67. $(tagID).css("color", color.toString());
  68. }
  69. }
  70. setTimeout("blinkMe()", interval, tagID, color, interval);
  71. }
  72. /**
  73. * Blink the the given text
  74. *
  75. * @param {string} tagID the tag ID containing the text to blink
  76. * @param {int} interval the interval of the "flashing"
  77. * @returns {void}
  78. */
  79. function blinkMe2(tagID, interval) {
  80. if (blinkTimeoutID!==0) {
  81. clearTimeout(blinkTimeoutID);
  82. }
  83. if ( $(tagID) ) {
  84. if ($(tagID).css("visibility") !== "hidden") {
  85. $(tagID).css("visibility", "hidden");
  86. } else {
  87. $(tagID).css("visibility", "visible");
  88. }
  89. }
  90. blinkTimeoutID = setTimeout(blinkMe2, interval, tagID, interval);
  91. }
  92. /**
  93. * Copy the text of the given control to the clipboard
  94. *
  95. * @param {string} selector the selector of the control
  96. * @returns {none}
  97. */
  98. function copyTextToClipboard(selector) {
  99. var control = $(selector);
  100. control.select();
  101. try {
  102. document.execCommand("copy");
  103. } catch (e) {
  104. }
  105. }
  106. /**
  107. * Count items into a selector collection
  108. *
  109. * @param {string} selector the selector for the collection
  110. * @returns {integer}
  111. */
  112. function countItemsBySelector(selector) {
  113. i=0;
  114. $(selector).each(function() {
  115. i=i+1;
  116. });
  117. return i;
  118. }
  119. /**
  120. * Encrypt the given string
  121. *
  122. * @param {string} string - The string to encrypt
  123. * @returns {string} the encrypted string
  124. */
  125. function encryptSha2(string) {
  126. var jsSHAo = new jsSHA("SHA-256", "TEXT", 1);
  127. jsSHAo.update(string);
  128. return jsSHAo.getHash("HEX");
  129. }
  130. /**
  131. * Delay the runtime execution for the given interval of time
  132. *
  133. * @param {int} interval -the interval of time of the delay
  134. * @returns {void}
  135. */
  136. function delay(interval) {
  137. var d = new Date();
  138. startTime = d.getTime();
  139. endTime = startTime;
  140. while((endTime - startTime) < interval) {
  141. d = new Date();
  142. endTime = d.getTime();
  143. //console.log(endTime - startTime);
  144. }
  145. }
  146. /**
  147. * Filter the keys of the given search query input box
  148. *
  149. * @param {object} this1 - The search query input box to filter
  150. * @returns {none}
  151. */
  152. function filterKeysQ(this1) {
  153. var value = $(this1).val();
  154. //var re = /[^\w\-: ]/gui;
  155. var re = new RegExp(/[^\w\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-: ]/, "gui");
  156. if (re.test(value)) {
  157. $(this1).val(value.replace(re, ""));
  158. }
  159. }
  160. /**
  161. * Filter the keys of the given email input box
  162. *
  163. * @param {object} this1 - The email input box to filter
  164. * @returns {none}
  165. */
  166. function filterKeysEmail(this1) {
  167. var value = $(this1).val();
  168. var re = new RegExp(/[^A-Za-z0-9-_@.]/, "g");
  169. //$(this1).val(value.replace(/[^A-Za-z0-9-_@.]/g, ""));
  170. if (re.test(value)) {
  171. $(this1).val(value.replace(re, ""));
  172. }
  173. }
  174. /**
  175. * Filter the keys of the given image name input box
  176. *
  177. * @param {object} this1 - The name input box to filter
  178. * @returns {none}
  179. */
  180. function filterKeysImageName(this1) {
  181. var value = $(this1).val();
  182. //$(this1).val(value.replace(/[^A-Za-z0-9-_\s]/, ""));
  183. //var re = new RegExp('/[^A-Za-z0-9\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-\s]/gui');
  184. //re.compile();
  185. //if (re.test(value)) {
  186. $(this1).val(value.replace(/[^A-Za-z0-9\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-\s]/gi, ""));
  187. //}
  188. }
  189. /**
  190. * Filter the keys of the given image tags input box
  191. *
  192. * @param {object} this1 - The tags input box to filter
  193. * @returns {none}
  194. */
  195. function filterKeysImageTags(this1) {
  196. var value = $(this1).val();
  197. //$(this1).val(value.replace(/[^A-Za-z0-9-_\s]/, ""));
  198. //var re = new RegExp(/[^\w\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-\s]/, "gui");
  199. //if (re.test(value)) {
  200. $(this1).val(value.replace(/[^\w\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-\s]/gi, ""));
  201. //}
  202. }
  203. /**
  204. * Filter the keys of the given image url input box
  205. *
  206. * @param {object} this1 - The url input box to filter
  207. * @returns {none}
  208. */
  209. function filterKeysImageUrl(this1) {
  210. var value = $(this1).val();
  211. //$(this1).val(value.replace(/[^A-Za-z0-9-_]/, ""));
  212. //var re = new RegExp('/[^\w\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-]/gui');
  213. //re.compile();
  214. //if (re.test(value)) {
  215. $(this1).val(value.replace(/[^\w\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-]/gi, ""));
  216. //}
  217. }
  218. /**
  219. * Filter the keys of the given email input box
  220. *
  221. * @param {object} this1 - The email input box to filter
  222. * @returns {none}
  223. */
  224. function filterKeysUsername(this1) {
  225. var value = $(this1).val();
  226. //$(this1).val(value.replace(/[^A-Za-z0-9-_]/, ""));
  227. var re = new RegExp(/[^\w\-]/, "gui");
  228. if (re.test(value)) {
  229. $(this1).val(value.replace(re, ""));
  230. }
  231. }
  232. /**
  233. * Return the array key of a given value
  234. *
  235. * @param {array} array - The array to search for the value
  236. * @param {string} value - The value to search
  237. * @returns {string} The key corrisponding to the value, if exists
  238. */
  239. function getArrayKeyByValue(array, value) {
  240. for (var key in array) {
  241. if (key === 'length' || !array.hasOwnProperty(key)) continue;
  242. if (array[key]===value) {
  243. return key;
  244. }
  245. }
  246. return "";
  247. }
  248. /**
  249. * Get the height of the whole document
  250. *
  251. * @param {none}
  252. * @returns {int} the document height
  253. */
  254. function getDocHeight() {
  255. var D = document;
  256. return Math.max(
  257. D.body.scrollHeight, D.documentElement.scrollHeight,
  258. D.body.offsetHeight, D.documentElement.offsetHeight,
  259. D.body.clientHeight, D.documentElement.clientHeight
  260. );
  261. }
  262. function getDocHeight2() {
  263. var D = document;
  264. var scrollMaxY;
  265. if (window.scrollMaxY) {
  266. scrollMaxY = window.scrollMaxY;
  267. } else {
  268. scrollMaxY = D.documentElement.scrollHeight;
  269. }
  270. var height = Math.max(
  271. D.body.scrollHeight, scrollMaxY,
  272. D.body.offsetHeight, D.documentElement.offsetHeight,
  273. D.body.clientHeight, D.documentElement.clientHeight
  274. );
  275. return height;
  276. }
  277. /**
  278. * Get the width of the whole document
  279. *
  280. * @param {none}
  281. * @returns {int} the document width
  282. */
  283. function getDocWidth() {
  284. var D = document;
  285. return Math.max(
  286. D.body.scrollWidth, D.documentElement.scrollWidth,
  287. D.body.offsetWidth, D.documentElement.offsetWidth,
  288. D.body.clientWidth, D.documentElement.clientWidth
  289. );
  290. }
  291. function getDocWidth2() {
  292. var D = document;
  293. var scrollMaxX;
  294. if (window.scrollMaxX) {
  295. scrollMaxX = window.scrollMaxX;
  296. } else {
  297. scrollMaxX = D.documentElement.scrollWidth;
  298. }
  299. return Math.max(
  300. D.body.scrollWidth, scrollMaxX,
  301. D.body.offsetWidth, D.documentElement.offsetWidth,
  302. D.body.clientWidth, D.documentElement.clientWidth
  303. );
  304. }
  305. function getTimestampInSec() {
  306. var d = new Date();
  307. timestamp = parseInt(d.getTime() / 1000);
  308. return timestamp;
  309. }
  310. function getWindowScrollX() {
  311. var supportPageOffset = window.pageXOffset !== undefined;
  312. var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
  313. return supportPageOffset ? window.pageXOffset : isCSS1Compat ? document.documentElement.scrollLeft : document.body.scrollLeft;
  314. }
  315. function getWindowScrollY() {
  316. var supportPageOffset = window.pageYOffset !== undefined;
  317. var isCSS1Compat = ((document.compatMode || "") === "CSS1Compat");
  318. return supportPageOffset ? window.pageYOffset : isCSS1Compat ? document.documentElement.scrollTop : document.body.scrollTop;
  319. }
  320. /**
  321. * Check if it is a valid username
  322. *
  323. * @param {string} s - The string to check
  324. * @returns {bool} if it is a valid username, true/false
  325. */
  326. function isUsername(s) {
  327. //var usernameRegEx = /^[a-zA-Z0-9_-]+?$/;
  328. //var usernameRegEx = /^[\w\-]+?$/;
  329. //var re = new RegExp(/^[\w\-]+$/, "i");
  330. var re = /^[\w\-]+$/i;
  331. return (re.test(s) && s.length>=3 && s.length<=20);
  332. }
  333. /**
  334. * Check if it is a valid email
  335. *
  336. * @param {string} s - The string to check
  337. * @returns {bool} if it is a valid email, true/false
  338. */
  339. function isEmail(s) {
  340. //var re = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  341. var re = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
  342. return (re.test(s) && s.length>=8 && s.length<=255);
  343. }
  344. /**
  345. * Check if it is a valid image name
  346. *
  347. * @param {string} s - The string to check
  348. * @returns {bool} if it is a valid image name, true/false
  349. */
  350. function isImageName(s) {
  351. //var imageNameRegEx = /^[a-zA-Z0-9_-\s]+?$/;
  352. //var imageNameRegEx = /^[\w\-\s]+?$/;
  353. var re = new RegExp('/^[A-Za-z0-9\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-\s]+?$/ui');
  354. re.compile();
  355. return (re.test(s) && s.length>=3 && s.length<=50);
  356. }
  357. /**
  358. * Check if it is a valid image url
  359. *
  360. * @param {string} s - The string to check
  361. * @returns {bool} if it is a valid image url, true/false
  362. */
  363. function isImageUrl(s) {
  364. //var imageUrlRegEx = /^[a-zA-Z0-9_-]+?$/;
  365. //var imageUrlRegEx = /^[\w\-]+?$/;
  366. var re = new RegExp('/^[\w\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\-]+?$/ui');
  367. re.compile();
  368. return (re.test(s) && s.length>=3 && s.length<=255);
  369. }
  370. /**
  371. * Check if it is a latin lang string
  372. *
  373. * @param {string} s - The string to check
  374. * @returns {bool} if it is a latin lang string, true/false
  375. */
  376. function isLatinLang(s) {
  377. var re = new RegExp(/^[\u31C0-\u31EF\u3300-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F]+?$/, "gui");
  378. return (!re.test(s));
  379. }
  380. /**
  381. * Load the footer content
  382. *
  383. * @param {string} scriptName the script name
  384. * @returns {none}
  385. */
  386. function loadPageFooter(scriptName) {
  387. $("div.footer").load("/footercontent?SCRIPT_NAME=" + scriptName + "&v=" + rnd(50000, 99999));
  388. }
  389. /**
  390. * Load the header content
  391. *
  392. * @param {string} scriptName the script name
  393. * @param {string} q the query string
  394. * @returns {none}
  395. */
  396. function loadPageHeader(scriptName, q, catMaskedPath, platform, errNo, errMsg, errScript, errLine, errStack, loginLnp) {
  397. $("div.header").load("/headercontent?SCRIPT_NAME=" + scriptName + "&q=" + q + "&catMaskedPath=" + catMaskedPath + "&platform=" + platform + "&errNo=" + errNo + "&errMsg=" + errMsg + "&errScript=" + errScript + "&errLine=" + errLine + "&errStack=" + errStack + "&loginLnp=" + loginLnp);
  398. }
  399. /**
  400. * Open a link from any event handler
  401. *
  402. * @param {string} href the link to open
  403. * @param {string} target the frame target
  404. * @returns {none}
  405. */
  406. function openLink(href, target) {
  407. window.open(href, target);
  408. }
  409. function rnd(min, max) {
  410. min = Math.ceil(min);
  411. max = Math.floor(max);
  412. return Math.floor(Math.random() * (max - min +1)) + min;
  413. }
  414. /**
  415. * Retain the focus at the given control
  416. *
  417. * @param {object} self - the given control
  418. * @returns {none} none
  419. */
  420. function retainFocus(self) {
  421. setTimeout(function() { self.focus(); }, 10);
  422. }
  423. /**
  424. * Position a div box to the middle of the screen
  425. *
  426. * @param {object} box div box to position
  427. * @returns {none}
  428. */
  429. function setBoxToMiddle(box) {
  430. boxHeight = parseInt(box.height());
  431. box.css("top", "-" + (parseInt(screen.availHeight - boxHeight)) + "px");
  432. }
  433. /**
  434. * Position a div box to the top of the screen
  435. *
  436. * @param {jQuery} box div box to position
  437. * @returns {none}
  438. */
  439. function setBoxToTop(box) {
  440. //undo last change (and remove all the following)
  441. //// boxHeight = parseInt(box.height());
  442. //// box.css("top", "-" + (parseInt((getDocHeight2()-boxHeight)/2)) + "px");
  443. // box.css("position", "relative");
  444. // box.css("top", "20px");
  445. // end undo
  446. boxWidth = parseInt(box.width());
  447. docWidth = parseInt(box.parent().width()); //getDocWidth2();
  448. box.css("position", "absolute");
  449. box.css("top", (window.scrollY + 20) + "px");
  450. box.css("left", parseInt(((docWidth - boxWidth) / 2)) + "px");
  451. }
  452. /**
  453. * Resize a div container to the doc height
  454. *
  455. * @param {object} container div container to resize
  456. * @returns {none}
  457. */
  458. function setContToDocHeight(container) {
  459. container.css("height", getDocHeight() + "px");
  460. }
  461. /**
  462. * Set the footer position
  463. *
  464. * @returns {void}
  465. */
  466. function setFooterPosition() {
  467. if ($(".footer")) {
  468. //$(".footer").attr("top", "-3000px");
  469. //var docHeight = parseInt(getDocHeight2());
  470. bodyRect = document.body.getBoundingClientRect();
  471. var docHeight = bodyRect.height;
  472. //$(".body-area").css("height", "500px");
  473. //$("#linkContainer").css("height", "500px");
  474. $("#linkContainer").css("height", parseInt(docHeight) + "px");
  475. //var screenHeight = parseInt(screen.availHeight);
  476. //var screenWidth = parseInt(screen.availWidth);
  477. //var footerRect = document.getElementsByClassName("footer")[0].getBoundingClientRect();
  478. //var footerTollerance = 25;
  479. var footerHeight = 80;
  480. var newTop = docHeight - footerHeight;
  481. if (newTop < 550) {
  482. newTop = 550;
  483. }
  484. /*
  485. // if in home page..
  486. if (document.getElementById("linkContainer")) {
  487. var headerHeight = 300;
  488. var linkContainerRect = document.getElementById("linkContainer").getBoundingClientRect();
  489. //var bodyAreaRect = document.getElementsByClassName("body-area")[0].getBoundingClientRect();
  490. newTop = linkContainerRect.height + headerHeight;
  491. if (newTop < (screenHeight -footerHeight)) {
  492. newTop = screenHeight - (footerHeight*1) - footerTollerance;
  493. }
  494. //document.getElementsByClassName("body-area")[0].style.height = parseInt(((screenHeight - (footerHeight*1) - footerTollerance) * 100) / screenHeight) + "%";
  495. }
  496. */
  497. //
  498. //if (newTop < window.innerHeight) {
  499. // //newTop = window.innerHeight - footerRect.height;
  500. //}
  501. newTop = newTop - 25;
  502. $(".footer").css("top", newTop.toString() + "px");
  503. // if in search page..
  504. if (document.getElementById("qrcodeCont") && document.getElementById("frmSearch")) {
  505. //var frmSearchRect = document.getElementById("frmSearch").getBoundingClientRect();
  506. var qrcodeContRect = document.getElementById("qrcodeCont").getBoundingClientRect();
  507. //newTop = docHeight - footerRect.height - qrcodeContRect.height;
  508. newTop = parseInt($(".footer").css("top")) - qrcodeContRect.height - 50;
  509. //$("#qrcodeTitle").text(newTop);
  510. //if (newTop < 320) {
  511. // newTop = 320;
  512. //}
  513. $("#qrcodeCont").css("top", newTop.toString() + "px");
  514. }
  515. setFeedbackIconPos();
  516. //setFeedbackPos();
  517. newTop = parseInt($(".footer").css("top")) + 25;
  518. $(".footer").css("top", newTop.toString() + "px");
  519. }
  520. }
  521. function setFooterPos() {
  522. if (document.getElementById("footerCont")) {
  523. tollerance = 25;
  524. $("#footerCont").css("top", parseInt( window.innerHeight - $("#footerCont").height() - tollerance ) + "px");
  525. $("#footer").css("top", parseInt( window.innerHeight - $("#footer").height() - tollerance ) + "px");
  526. }
  527. }
  528. function setCookieBannerPos() {
  529. if (document.getElementById("bannerCookies")) {
  530. tollerance = 30;
  531. bodyRect = document.body.getBoundingClientRect();
  532. docHeight = parseInt(getDocHeight2());
  533. $("#bannerCookies").css("top", parseInt(window.scrollY + window.innerHeight - ($("#bannerCookies").height() + tollerance)));
  534. $("#bannerCookies").css("left", parseInt(bodyRect.width - ($("#bannerCookies").width() + tollerance)));
  535. }
  536. }
  537. function setFeedbackPos() {
  538. if (document.getElementById("popupFeedback")) {
  539. $("#popupFeedback").attr("top", "-3000px");
  540. $("#popupFeedback").attr("left", "-3000px");
  541. bodyRect = document.body.getBoundingClientRect();
  542. var docHeight = parseInt(getDocHeight2()); //window.scrollY + bodyRect.height;
  543. var docWidth = bodyRect.width;
  544. var feedbackRect = document.getElementById("popupFeedback").getBoundingClientRect();
  545. newTop = docHeight - (feedbackRect.height + 10);
  546. newLeft = docWidth - (feedbackRect.width + 10);
  547. $("#popupFeedback").css("top", newTop.toString() + "px");
  548. $("#popupFeedback").css("left", newLeft.toString() + "px");
  549. }
  550. }
  551. function setFeedbackIconPos() {
  552. if (document.getElementById("butFeedback")) {
  553. bodyRect = document.body.getBoundingClientRect();
  554. var docHeight = parseInt(getDocHeight2());
  555. var docWidth = bodyRect.width; //window.scrollX + bodyRect.width;
  556. var feedbackIconRect = document.getElementById("butFeedback").getBoundingClientRect();
  557. newTop = -65; //docHeight - (feedbackIconRect.height + 10);
  558. newLeft = docWidth - (55 + 10);
  559. $("#butFeedback").css("top", newTop.toString() + "px");
  560. $("#butFeedback").css("left", newLeft.toString() + "px");
  561. $("#butFeedback").css("display", "inline");
  562. }
  563. }
  564. function setParentButPos() {
  565. bodyRect = document.body.getBoundingClientRect();
  566. var docWidth = bodyRect.width;
  567. if (docWidth < 850) {
  568. $("div#butParent").css("left","+5px");
  569. } else {
  570. $("div#butParent").css("left","+40px");
  571. }
  572. $("div#butParent").css("display","inline");
  573. }
  574. // Global window load event handler..
  575. //window.addEventListener("scroll", function() {
  576. // Reposition footer..
  577. //$(".footer").attr("top", "-3000px");
  578. //$("#popupFeedback").attr("top", "-3000px");
  579. //$("#popupFeedback").attr("left", "-3000px");
  580. //setTimeout("setFooterPosition2()", 1000);
  581. //$("#bannerCookies").attr("top", "-3000px");
  582. //setTimeout("setCookieBannerPos()", 4500);
  583. //}, true);
  584. function resetDispElmnts() {
  585. $(".footer").attr("top", "-3000px");
  586. //$(".body-area").css("height", "500px");
  587. //$("#linkContainer").css("height", "500px");
  588. }
  589. // Global window resize event handler..
  590. window.addEventListener("resize", function() {
  591. // Reposition footer..
  592. //resetDispElmnts();
  593. //$(".footer").attr("top", "-3000px");
  594. //$("#popupFeedback").attr("top", "-3000px");
  595. //$("#popupFeedback").attr("left", "-3000px");
  596. setTimeout("setFooterPos()", 3000);
  597. bodyRect = document.body.getBoundingClientRect();
  598. bodyRect.width = window.innerWidth;
  599. $(".body-area").css("width", parseInt(window.innerWidth)+"px");
  600. $(".footer").css("width", parseInt(window.innerWidth)+"px");
  601. $("#footerCont").css("width", parseInt(window.innerWidth)+"px");
  602. //$("#bannerCookies").attr("top", "-3000px");
  603. //setTimeout("setCookieBannerPos()", 4500);
  604. // Resizing the burger menu..
  605. if (bBurgerMenuVisible) {
  606. $("div#contBurgerMenuBox").css("height", getDocHeight2() + "px");
  607. }
  608. setTimeout("setParentButPos()", 1300);
  609. }, true);
  610. // Global window load event handler..
  611. window.addEventListener("load", function() {
  612. // Reposition footer..
  613. //resetDispElmnts();
  614. //$(".footer").attr("top", "-3000px");
  615. //$("#popupFeedback").attr("top", "-3000px");
  616. //$("#popupFeedback").attr("left", "-3000px");
  617. setTimeout("setFooterPos()", 3000);
  618. bodyRect = document.body.getBoundingClientRect();
  619. bodyRect.width = window.innerWidth;
  620. $(".body-area").css("width", parseInt(window.innerWidth)+"px");
  621. $(".footer").css("width", parseInt(window.innerWidth)+"px");
  622. $("#footerCont").css("width", parseInt(window.innerWidth)+"px");
  623. //$("#bannerCookies").attr("top", "-3000px");
  624. //setTimeout("setCookieBannerPos()", 4500);
  625. setTimeout("setParentButPos()", 1300);
  626. }, true);
  627. $(document).ready(function() {
  628. $(".content-area-results").on("click", function() {
  629. // Hide the Feedback for if visible..
  630. if (bFeedbackVisible) {
  631. $("#popupFeedback").css("display", "none");
  632. bFeedbackVisible = false;
  633. }
  634. });
  635. });