squeejs.js 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  1. /**
  2. * Copyright (c) 2021, 2024, 5 Mode and other contributors
  3. * Released under the MIT license
  4. *
  5. * This file is part of Squeejs.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
  8. * and associated documentation files (the "Software"), to deal in the Software
  9. * without restriction, including without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
  11. * Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or
  14. * substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  17. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  18. * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  19. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  20. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. *
  23. * squeejs.js
  24. *
  25. * Squeejs production release.
  26. *
  27. * @version 1.0.8
  28. * @author Daniele Bonini <my25mb@aol.com>
  29. * @copyrights (c) 2016, 2024, 5 Mode
  30. * @license https://opensource.org/licenses/MIT
  31. */
  32. function SqueeJS() {
  33. const SQJS_GEOURL = "https://ss.squeejs.com/";
  34. // Highlight
  35. this.highlightOriTop=[];
  36. this.highlightOriLeft=[];
  37. this.highlightOriHeight=[];
  38. this.highlightOriWidth=[];
  39. this.highlightOriFontSize=[];
  40. this.highlightOriBorder=[];
  41. this.highlightOriPosition=[];
  42. this.highlightDiv = myhighlightDiv;
  43. this.unlightDiv = myunlightDiv;
  44. this.highlightInput = myhighlightInput;
  45. this.unlightInput = myunlightInput;
  46. this.highlightTextArea = myhighlightTextArea;
  47. this.unlightTextArea = myunlightTextArea;
  48. // Splash
  49. this.splashMainContainerId = "";
  50. this.splashMainContainerOriHeight = 0;
  51. this.splashTitle = "";
  52. this.splashLogoURI = "";
  53. this.splashBG = "";
  54. this.splashTimeout = 6000;
  55. this.createSplash = mycreateSplash;
  56. this.splashStartApp = mySplashStartApp;
  57. this.initAppWithSplash = myinitAppWithSplash;
  58. this.initAppWithoutSplash = myinitAppWithoutSplash;
  59. // Work In Progress
  60. this.wipMainContainerId = "";
  61. this.wipMainContainerOriHeight = 0;
  62. this.wipBG = "";
  63. this.wipStartApp = myWIPStartApp;
  64. this.initAppWithWIP = myinitAppWithWIP;
  65. this.initAppWithoutWIP = myinitAppWithoutWIP;
  66. //Banners
  67. this.bannerIndex = 0;
  68. this.bannerIMG = [];
  69. this.bannerURL = [];
  70. this.createBanner = mycreateBanner;
  71. this.closeBanner = mycloseBanner;
  72. //Footer
  73. this.footerHTML = "";
  74. this.footerBG = "";
  75. this.createFooter = mycreateFooter;
  76. //AppMenu
  77. this.appmenuContentContId = "";
  78. this.appmenuVisible = false;
  79. this.appmenuOnIco = false;
  80. this.appmenuPopUp = myappmenuPopUp;
  81. this.appmenuHide = myappmenuHide;
  82. this.appmenuCheckFlagIco = myappmenuCheckFlagIco;
  83. this.appmenuUnCheckFlagIco = myappmenuUnCheckFlagIco;
  84. this.appmenuBodyOnClick = myappmenuBodyOnClick;
  85. this.createAppMenu = mycreateAppMenu;
  86. //GeoLocation
  87. this.geoLocation = "";
  88. this.retrieveGeoLocation = myretrieveGeoLocation;
  89. this.hideElByGeoLocation = myhideElByGeoLocation;
  90. this.showElByGeoLocation = myshowElByGeoLocation;
  91. //UserTranslation
  92. this.usertransContentContId = "";
  93. this.usertransVisible = false;
  94. this.usertransOnIco = false;
  95. this.tranSource = [];
  96. this.tranDest = [];
  97. this.usertransPopUp=myusertransPopUp;
  98. this.usertransHide=myusertransHide;
  99. this.usertransCheckFlagIco=myusertransCheckFlagIco;
  100. this.usertransUnCheckFlagIco=myusertransUnCheckFlagIco;
  101. this.usertransBodyOnClick=myusertransBodyOnClick;
  102. this.getTranslitarates = mygetTranslitarates;
  103. this.translate = mytranslate;
  104. this.createUserTrans = mycreateUserTrans;
  105. /**
  106. * gfSQJZDocWidth
  107. *
  108. * Get the width of the whole document
  109. *
  110. * @returns {int} the document width
  111. *
  112. * This function is part of SqueeJS.
  113. */
  114. function gfSQJZDocWidth() {
  115. var D = document;
  116. var scrollMaxX;
  117. if (window.scrollMaxX) {
  118. scrollMaxX = window.scrollMaxX;
  119. } else {
  120. scrollMaxX = D.documentElement.scrollWidth;
  121. }
  122. return Math.max(
  123. D.body.scrollWidth, scrollMaxX,
  124. D.body.offsetWidth, D.documentElement.offsetWidth,
  125. D.body.clientWidth, D.documentElement.clientWidth
  126. );
  127. }
  128. /**
  129. * gfSQJZDocHeight
  130. *
  131. * Get the height of the whole document
  132. *
  133. * @returns {int} the document height
  134. *
  135. * This function is part of SqueeJS.
  136. */
  137. function gfSQJZDocHeight() {
  138. var D = document;
  139. var scrollMaxY;
  140. if (window.scrollMaxY) {
  141. scrollMaxY = window.scrollMaxY;
  142. } else {
  143. scrollMaxY = D.documentElement.scrollHeight;
  144. }
  145. var height = Math.max(
  146. D.body.scrollHeight, scrollMaxY,
  147. D.body.offsetHeight, D.documentElement.offsetHeight,
  148. D.body.clientHeight, D.documentElement.clientHeight
  149. );
  150. return height;
  151. }
  152. /**
  153. * gfSQJZrnd
  154. *
  155. * Geenerate a random number between the given limits
  156. *
  157. * @param {int} min, the starting limit
  158. * @param {int} max, the max limit
  159. * @returns {int} the generated random value
  160. *
  161. * This function is part of SqueeJS.
  162. */
  163. function gfSQJZrnd(min, max) {
  164. min = Math.ceil(min);
  165. max = Math.floor(max);
  166. return Math.floor(Math.random() * (max - min +1)) + min;
  167. }
  168. /**
  169. *
  170. * Highlight
  171. *
  172. */
  173. /**
  174. * highlightDiv
  175. *
  176. * highlight the current DIV element
  177. *
  178. * Context:
  179. * - call this function in the onmouseenter event
  180. *
  181. * @param {Element} tthis, the current DIV element (this on the function call)
  182. * @returns {void}
  183. *
  184. * This function is part of SqueeJS.
  185. */
  186. function myhighlightDiv(tthis) {
  187. if (tthis.tagName !== "DIV") {
  188. return;
  189. }
  190. // --- saving original data
  191. myR = tthis.getBoundingClientRect();
  192. highlightIndex = tthis.getAttribute("highlightIndex");
  193. this.highlightOriTop[highlightIndex] = parseInt(myR.top);
  194. this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
  195. this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
  196. this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
  197. this.highlightOriBorder[highlightIndex] = tthis.style.border;
  198. this.highlightOriPosition[highlightIndex] = tthis.style.position;
  199. // ---
  200. tthis.style.position = "absolute";
  201. tthis.style.height = "480px";
  202. tthis.style.width = "650px";
  203. tthis.style.border = "3px dashed darkcyan";
  204. tthis.style.fontSize = "25px";
  205. //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
  206. }
  207. /**
  208. * unlightDiv
  209. *
  210. * unlight the current DIV element
  211. *
  212. * Context:
  213. * - call this function in the onmouseleave event
  214. *
  215. * @param {Element} tthis, the current DIV element (this on the function call)
  216. * @returns {void}
  217. *
  218. * This function is part of SqueeJS.
  219. */
  220. function myunlightDiv(tthis) {
  221. if (tthis.tagName !== "DIV") {
  222. return;
  223. }
  224. // --- restoring original data
  225. highlightIndex = tthis.getAttribute("highlightIndex");
  226. if (this.highlightOriTop[highlightIndex]===null) {
  227. return;
  228. }
  229. tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
  230. tthis.style.border = this.highlightOriBorder[highlightIndex];
  231. tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
  232. tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
  233. tthis.style.position = this.highlightOriPosition[highlightIndex];
  234. // ---
  235. //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
  236. }
  237. /**
  238. * highlightInput
  239. *
  240. * highlight the current INPUT element
  241. *
  242. * Context:
  243. * - call this function in the onmouseenter event
  244. *
  245. * @param {Element} tthis, the current INPUT element (this on the function call)
  246. * @returns {void}
  247. *
  248. * This function is part of SqueeJS.
  249. */
  250. function myhighlightInput(tthis) {
  251. if (tthis.tagName !== "INPUT") {
  252. return;
  253. }
  254. // --- saving original data
  255. myR = tthis.getBoundingClientRect();
  256. highlightIndex = tthis.getAttribute("highlightIndex");
  257. this.highlightOriTop[highlightIndex] = parseInt(myR.top);
  258. this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
  259. this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
  260. this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
  261. this.highlightOriBorder[highlightIndex] = tthis.style.border;
  262. this.highlightOriPosition[highlightIndex] = tthis.style.position;
  263. // ---
  264. tthis.style.position = "absolute";
  265. tthis.style.height = "40px";
  266. tthis.style.width = "400px";
  267. tthis.style.border = "3px solid lightblue";
  268. tthis.style.fontSize = "25px";
  269. //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
  270. }
  271. /**
  272. * unlightInput
  273. *
  274. * unlight the current INPUT element
  275. *
  276. * Context:
  277. * - call this function in the onmouseleave event
  278. *
  279. * @param {Element} tthis, the current INPUT element (this on the function call)
  280. * @returns {void}
  281. *
  282. * This function is part of SqueeJS.
  283. */
  284. function myunlightInput(tthis) {
  285. if (tthis.tagName !== "INPUT") {
  286. return;
  287. }
  288. // --- restoring original data
  289. highlightIndex = tthis.getAttribute("highlightIndex");
  290. if (this.highlightOriTop[highlightIndex]===null) {
  291. return;
  292. }
  293. tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
  294. tthis.style.border = this.highlightOriBorder[highlightIndex];
  295. tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
  296. tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
  297. tthis.style.position = this.highlightOriPosition[highlightIndex];
  298. // ---
  299. //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
  300. }
  301. /**
  302. * highlightTextArea
  303. *
  304. * highlight the current TEXTAREA element
  305. *
  306. * Context:
  307. * - call this function in the onmouseenter event
  308. *
  309. * @param {Element} tthis, the current TEXTAREA element (this on the function call)
  310. * @returns {void}
  311. *
  312. * This function is part of SqueeJS.
  313. */
  314. function myhighlightTextArea(tthis) {
  315. if (tthis.tagName !== "TEXTAREA") {
  316. return;
  317. }
  318. // --- saving original data
  319. myR = tthis.getBoundingClientRect();
  320. highlightIndex = tthis.getAttribute("highlightIndex");
  321. this.highlightOriTop[highlightIndex] = parseInt(myR.top);
  322. this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
  323. this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
  324. this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
  325. this.highlightOriBorder[highlightIndex] = tthis.style.border;
  326. this.highlightOriPosition[highlightIndex] = tthis.style.position;
  327. // ---
  328. tthis.style.position = "absolute";
  329. tthis.style.height = "240px";
  330. tthis.style.width = "400px";
  331. tthis.style.border = "3px solid lightblue";
  332. tthis.style.fontSize = "25px";
  333. //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
  334. }
  335. /**
  336. * unlightTextArea
  337. *
  338. * highlight the current TEXTAREA element
  339. *
  340. * Context:
  341. * - call this function in the onmouseleave event
  342. *
  343. * @param {Element} tthis, the current TEXTAREA element (this on the function call)
  344. * @returns {void}
  345. *
  346. * This function is part of SqueeJS.
  347. */
  348. function myunlightTextArea(tthis) {
  349. if (tthis.tagName !== "TEXTAREA") {
  350. return;
  351. }
  352. // --- restoring original data
  353. highlightIndex = tthis.getAttribute("highlightIndex");
  354. if (this.highlightOriTop[highlightIndex]===null) {
  355. return;
  356. }
  357. tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
  358. tthis.style.border = this.highlightOriBorder[highlightIndex];
  359. tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
  360. tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
  361. tthis.style.position = this.highlightOriPosition[highlightIndex];
  362. // ---
  363. //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
  364. }
  365. // --- End Highlight
  366. /**
  367. *
  368. * Splash Screen
  369. */
  370. /**
  371. * createSplash
  372. *
  373. * create the tag DIV for the splash screen
  374. *
  375. * Context:
  376. * - this function is for internal use
  377. *
  378. * @returns {void}
  379. *
  380. * This function is part of SqueeJS.
  381. */
  382. function mycreateSplash() {
  383. var D = document;
  384. w = gfSQJZDocWidth();
  385. splashLeft = parseInt((w - 265) / 2);
  386. h = gfSQJZDocHeight();
  387. title = this.splashTitle;
  388. logoURI = this.splashLogoURI;
  389. BG = this.splashBG;
  390. //alert(this.splashTitle);
  391. //alert(this.splashLogoURI);
  392. //alert(this.splashBG);
  393. splash = "";
  394. splash += "<br><br><br><br>";
  395. splash += "<div style='width:267px;margin:auto;text-align:center;'>"+title+"</div><br>";
  396. splash += "<div style='width:267px;margin:auto;'><img src='"+logoURI+"' style='width:265px;'></div>";
  397. newdiv=D.createElement("div");
  398. newdiv.id = "SQJSsplash";
  399. newdiv.style.background = BG;
  400. newdiv.style.width = w;
  401. newdiv.style.height = h;
  402. newdiv.style.textAlign = 'left';
  403. newdiv.style.fontFamily = 'Arial,Sans,Verdana';
  404. newdiv.style.fontSize = '35px';
  405. newdiv.style.fontWeight = '900';
  406. newdiv.style.paddingLeft = splashLeft+"px";
  407. newdiv.innerHTML = splash;
  408. D.body.appendChild(newdiv);
  409. }
  410. /**
  411. * SPALSHstartApp
  412. *
  413. * Start the web app just after the Splash
  414. *
  415. * Context:
  416. * - this function is for internal use
  417. *
  418. * @returns {void}
  419. *
  420. * This function is part of SqueeJS.
  421. */
  422. function mySplashStartApp() {
  423. //alert("hello");
  424. //Splash
  425. if (document.getElementById("SQJSsplash")) {
  426. document.getElementById("SQJSsplash").style.display = "none";
  427. }
  428. //Main Container
  429. document.getElementById(this.splashMainContainerId).style.height = this.splashMainContainerOriHeight;
  430. document.getElementById(this.splashMainContainerId).style.display = "inline";
  431. window.scrollTo(0,0);
  432. }
  433. /**
  434. * _SPLASHstartApp
  435. *
  436. * Set the timeout to start the web app just after the Splash
  437. *
  438. * Context:
  439. * - this function is for internal use
  440. *
  441. * @param {int} time, the interval of time to wait before to start the webapp
  442. * @returns {void}
  443. *
  444. * This function is part of SqueeJS.
  445. */
  446. //function _SPLASHstartApp(time) {
  447. // Fisnished the Intro with the Splash we load the app..
  448. // setTimeout("SPLASHstartApp()", time);
  449. //}
  450. /**
  451. * _initAppWithSplash
  452. *
  453. * Init the web app to start with the Splash
  454. *
  455. * Context:
  456. * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
  457. *
  458. * @param {string} mainContainerId, the container ID for the webpage content
  459. * @param {string} title, the title of the splash screen
  460. * @param {string} logoURI, the logo to display in the splash screen
  461. * @param {string} BG, the background for the splash screen
  462. * @param {int} timeout, the splash screen timeout
  463. * @returns {void}
  464. *
  465. * This function is part of SqueeJS.
  466. */
  467. function myinitAppWithSplash(mainContainerId, title, logoURI, BG, timeout) {
  468. this.splashMainContainerId = mainContainerId;
  469. this.splashTitle = title;
  470. this.splashLogoURI = logoURI;
  471. this.splashBG = BG;
  472. if (timeout!==null) {
  473. this.splashTimeout = timeout;
  474. }
  475. //Main Container
  476. document.getElementById(this.splashMainContainerId).style.display = "none";
  477. //Splash
  478. this.createSplash();
  479. document.getElementById("SQJSsplash").style.display = "inline";
  480. //window.scrollTo(1,1);
  481. document.body.style.height = parseInt(window.innerHeight) + "px";
  482. this.splashMainContainerOriHeight = document.getElementById(this.splashMainContainerId).style.height;
  483. document.getElementById(this.splashMainContainerId).style.height = parseInt(window.innerHeight) + "px";
  484. setTimeout("SQJS.splashStartApp()", this.splashTimeout);
  485. }
  486. /**
  487. * _initAppWithoutSplash
  488. *
  489. * Init the web app to start withOUT the Splash
  490. *
  491. * Context:
  492. * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
  493. *
  494. * @param {string} mainContainerId, the container ID for the webpage content
  495. * @returns {void}
  496. *
  497. * This function is part of SqueeJS.
  498. */
  499. function myinitAppWithoutSplash(mainContainerId) {
  500. this.splashMainContainerId = mainContainerId;
  501. //Main Container
  502. document.getElementById(this.splashMainContainerId).style.display = "inline";
  503. //Splash
  504. //document.getElementById("SQJSsplash").style.display = "none";
  505. setTimeout("SQJS.splashStartApp()", 1);
  506. }
  507. // --- End Splash Screen
  508. /**
  509. *
  510. * Work in Progress
  511. */
  512. /**
  513. * createWIP
  514. *
  515. * create the tag DIV for the Work In Progress Banner
  516. *
  517. * Context:
  518. * - this function is for internal use
  519. *
  520. * @returns {void}
  521. *
  522. * This function is part of SqueeJS.
  523. */
  524. function _createWIP() {
  525. var D = document;
  526. w = gfSQJZDocWidth();
  527. wipLeft = parseInt((w - 450) / 2);
  528. h = gfSQJZDocHeight();
  529. bannerURI = "//squeejs.com/res/work-in-progress.png";
  530. BG = this.wipBG;
  531. wip = "";
  532. wip += "<br><br><br><br><br><br><br>";
  533. wip += "<div style='width:450px;margin:auto;'><img src='"+bannerURI+"' style='width:450px;'></div>";
  534. newdiv=D.createElement("div");
  535. newdiv.id = "SQJSWIP";
  536. newdiv.style.background = BG;
  537. newdiv.style.width = w;
  538. newdiv.style.height = h;
  539. newdiv.style.textAlign = 'left';
  540. newdiv.style.fontFamily = 'Arial,Sans,Verdana';
  541. newdiv.style.fontSize = '35px';
  542. newdiv.style.fontWeight = '900';
  543. newdiv.style.paddingLeft = wipLeft+"px";
  544. newdiv.innerHTML = wip;
  545. D.body.appendChild(newdiv);
  546. }
  547. /**
  548. * WIPstartApp
  549. *
  550. * Start the web app just after the WIP banner
  551. *
  552. * Context:
  553. * - this function is for internal use
  554. *
  555. * @returns {void}
  556. *
  557. * This function is part of SqueeJS.
  558. */
  559. function myWIPStartApp() {
  560. //Splash
  561. if (document.getElementById("SQJSWIP")) {
  562. document.getElementById("SQJSWIP").style.display = "none";
  563. }
  564. //Main Container
  565. document.getElementById(this.wipMainContainerId).style.height = this.wipMainContainerOriHeight;
  566. document.getElementById(this.wipMainContainerId).style.display = "inline";
  567. window.scrollTo(0,0);
  568. }
  569. /**
  570. * _WIPstartApp
  571. *
  572. * Set the timeout to start the web app just after the Splash
  573. *
  574. * Context:
  575. * - this function is for internal use
  576. *
  577. * @param {int} time, the interval of time to wait before to start the webapp
  578. * @returns {void}
  579. *
  580. * This function is part of SqueeJS.
  581. */
  582. //function _WIPstartApp(time) {
  583. // Fisnished the Intro with the Splash we load the app..
  584. // setTimeout("WIPstartApp()", time);
  585. //}
  586. /**
  587. * _initAppWithWIP
  588. *
  589. * Init the web app to start with the work in progress banner
  590. *
  591. * Context:
  592. * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
  593. *
  594. * @param {string} mainContainerId, the container ID for the webpage content
  595. * @param {string} BG, the background for the wip banner
  596. * @returns {void}
  597. *
  598. * This function is part of SqueeJS.
  599. */
  600. function myinitAppWithWIP(mainContainerId, BG) {
  601. this.wipMainContainerId = mainContainerId;
  602. this.wipBG = BG;
  603. //Main Container
  604. document.getElementById(this.wipMainContainerId).style.display = "none";
  605. //Banner
  606. _createWIP();
  607. document.getElementById("SQJSWIP").style.display = "inline";
  608. //window.scrollTo(1,1);
  609. document.body.style.height = parseInt(window.innerHeight) + "px";
  610. this.wipMainContainerOriHeight = document.getElementById(this.wipMainContainerId).style.height;
  611. document.getElementById(this.wipMainContainerId).style.height = parseInt(window.innerHeight) + "px";
  612. }
  613. /**
  614. * _initAppWithoutWIP
  615. *
  616. * Init the web app to start withOUT the WIP banner
  617. *
  618. * Context:
  619. * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
  620. *
  621. * @param {string} mainContainerId, the container ID for the webpage content
  622. * @returns {void}
  623. *
  624. * This function is part of SqueeJS.
  625. */
  626. function myinitAppWithoutWIP(mainContainerId) {
  627. this.wipMainContainerId = mainContainerId;
  628. //Main Container
  629. document.getElementById(this.wipMainContainerId).style.display = "inline";
  630. //Splash
  631. //document.getElementById("SQJSWIP").style.display = "none";
  632. setTimeout("SQJS.wipStartApp()", 1);
  633. }
  634. // --- Work in Progress
  635. /**
  636. *
  637. * Banner
  638. */
  639. /**
  640. * createBanner
  641. *
  642. * create a new Banner
  643. *
  644. * Context:
  645. * - Call in the body of your webpage
  646. *
  647. * @param {string} img, the banner img (471px width)
  648. * @param {string} url, the banner target url
  649. * @param {string} align, the banner horizontal alignment [left|middle|right]
  650. * @param {string} display, the banner display [fixed|absolute|relative|none]
  651. * @param {int} minScreenWidth, min screen width to display the banner
  652. * @returns {string} the id of the resulting banner
  653. *
  654. * This function is part of SqueeJS.
  655. */
  656. function mycreateBanner(img, url, align, display, minScreenWidth) {
  657. this.bannerIndex++;
  658. this.bannerIMG[this.bannerIndex] = img;
  659. this.bannerURL[this.bannerIndex] = url;
  660. var D = document;
  661. w = gfSQJZDocWidth();
  662. switch (align) {
  663. case "middle":
  664. bannerLeft = parseInt((w - 473) / 2);
  665. break;
  666. case "left":
  667. bannerLeft = 0;
  668. break;
  669. case "right":
  670. bannerLeft = parseInt(w - 473);
  671. break;
  672. default:
  673. bannerLeft = parseInt((w - 473) / 2);
  674. break;
  675. }
  676. bbannerIMG = this.bannerIMG[this.bannerIndex];
  677. bbannerURL = this.bannerURL[this.bannerIndex];
  678. banner = "";
  679. banner += "<button type='button' class='SQJSclose-button' onclick='SQJS.closeBanner(this);'>";
  680. banner += "<span style='font-weight:900;'>&times;</span>";
  681. banner += "</button>";
  682. banner += "<a href='"+bbannerURL+"' target='_blank'><img src='"+bbannerIMG+"' style='width:471px;'></a>";
  683. newdiv=D.createElement("div");
  684. newdiv.id = "SQJSBANNER" + this.bannerIndex;
  685. //newdiv.style.width = w;
  686. //newdiv.style.height = h;
  687. newdiv.style.textAlign = 'left';
  688. //newdiv.style.fontFamily = 'Arial,Sans,Verdana';
  689. //newdiv.style.fontSize = '35px';
  690. //newdiv.style.fontWeight = '900';
  691. newdiv.style.marginLeft = bannerLeft+"px";
  692. bannerDisplay = true;
  693. switch (display) {
  694. case "fixed":
  695. newdiv.className = "SQJSbanner-fixed";
  696. newdiv.style.top = (((35 +62) * (this.bannerIndex-1))) + "px";
  697. break;
  698. case "absolute":
  699. newdiv.className = "SQJSbanner-absolute";
  700. newdiv.style.top = (((35 +62) * (this.bannerIndex-1))) + "px";
  701. break;
  702. case "relative":
  703. newdiv.className = "SQJSbanner-relative";
  704. break;
  705. case "none":
  706. bannerDisplay = false;
  707. break;
  708. }
  709. if (window.innerWidth < minScreenWidth) {
  710. bannerDisplay = false;
  711. }
  712. if (!bannerDisplay) {
  713. newdiv.style.display = "none";
  714. }
  715. newdiv.innerHTML = banner;
  716. //D.body.appendChild(newdiv);
  717. D.write(newdiv.outerHTML);
  718. return "SQJSBANNER"+this.bannerIndex;
  719. }
  720. function mycloseBanner(tthis) {
  721. tthis.parentNode.style.display = "none";
  722. }
  723. // --- Banner
  724. /**
  725. *
  726. * Footer
  727. */
  728. /**
  729. * createFooter
  730. *
  731. * create the tag DIV for the footer
  732. *
  733. * Context:
  734. * - Call it in the body of your webpage
  735. *
  736. * @param {string} html, the html to insert as footer
  737. * @param {string} BG, the background of the footer
  738. * @param {string} align, the banner horizontal alignment [left|middle|right]
  739. * @param {string} display, the banner display [fixed|relative|none]
  740. * @returns {string} the id of the footer DIV element
  741. *
  742. * This function is part of SqueeJS.
  743. */
  744. function mycreateFooter(html, BG, align, display) {
  745. htollerance = 12;
  746. htollerance = 12;
  747. footerContHeight = 35;
  748. footerHeight = 32;
  749. footerFloat = "";
  750. this.footerHTML = html;
  751. this.BG = BG;
  752. var D = document;
  753. w = gfSQJZDocWidth();
  754. h = window.innerHeight;
  755. footerDisplay = true;
  756. footerContClassName = "";
  757. footerClassName = "";
  758. switch (display) {
  759. case "fixed":
  760. footerContClassName = "SQJSfooterCont";
  761. footerClassName = "SQJSfooter";
  762. break;
  763. case "relative":
  764. footerContClassName = "SQJSfooterCont";
  765. footerClassName = "SQJSfooter";
  766. break;
  767. case "none":
  768. footerContClassName = "SQJSfooterCont";
  769. footerClassName = "SQJSfooter";
  770. footerDisplay = false;
  771. break;
  772. default:
  773. display="relative";
  774. footerContClassName = "SQJSfooterCont";
  775. footerClassName = "SQJSfooter";
  776. break;
  777. }
  778. footer = "";
  779. footer += "<div class='"+footerContClassName+"'>&nbsp;</div>";
  780. footer += "<div class='"+footerClassName+"'>"+html+"</div> ";
  781. newdiv=D.createElement("div");
  782. newdiv.id = "SQJSfooter";
  783. newdiv.className = "footer";
  784. //newdiv.style.textAlign = 'left';
  785. newdiv.innerHTML = footer;
  786. D.body.appendChild(newdiv);
  787. document.getElementsByClassName(footerClassName)[0].style.background = BG;
  788. switch (align) {
  789. case "middle":
  790. footerLeft = parseInt((w - document.getElementsByClassName(footerClassName)[0].getBoundingClientRect().width) / 2);
  791. break;
  792. case "left":
  793. footerLeft = 0;
  794. footerFloat = "left";
  795. break;
  796. case "right":
  797. footerLeft = parseInt(w - document.getElementsByClassName(footerClassName)[0].getBoundingClientRect().width);
  798. footerFloat = "right";
  799. break;
  800. default:
  801. align="left";
  802. footerLeft = 0;
  803. footerFloat = "left";
  804. break;
  805. }
  806. document.getElementsByClassName(footerClassName)[0].style.float = footerFloat;
  807. if (display === "relative") {
  808. //document.getElementsByClassName(footerClassName)[0].style.top = "-" + footerContHeight + "px";
  809. } else if (display === "fixed") {
  810. document.getElementsByClassName("footer")[0].style.marginLeft = (footerLeft-wtollerance)+"px";
  811. document.getElementsByClassName("footer")[0].style.position = "fixed";
  812. document.getElementsByClassName("footer")[0].style.top = ""+parseInt(h - footerContHeight - htollerance) + "px";
  813. if (align === "right") {
  814. //document.getElementsByClassName("footer")[0].style.textAlign = "right";
  815. } else if (align === "middle") {
  816. //document.getElementsByClassName(footerClassName)[0].style.width = "800px";
  817. document.getElementsByClassName("footer")[0].style.textAlign = "center";
  818. }
  819. } else {
  820. newdiv.style.display = "none";
  821. }
  822. return newdiv.id;
  823. }
  824. // --- Footer
  825. /**
  826. *
  827. * AppMenu
  828. */
  829. /**
  830. * myappmenuPopUp
  831. *
  832. * Display/hide the appmenu
  833. *
  834. * Context:
  835. * - this function is for internal use
  836. *
  837. * @returns {void}
  838. *
  839. * This function is part of SqueeJS.
  840. */
  841. function myappmenuPopUp() {
  842. if (!this.appmenuVisible) {
  843. document.getElementById("SQJSappMenu").style.display = "inline";
  844. document.getElementById("SQJSappMenu").style.zIndex = "99998";
  845. document.getElementById(this.appmenuContentContId).style.zIndex = "99997";
  846. document.getElementById(this.appmenuContentContId ).style.opacity = "0.3";
  847. } else {
  848. document.getElementById("SQJSappMenu").style.display = "none";
  849. document.getElementById("SQJSappMenu").style.zIndex = "99992";
  850. document.getElementById(this.appmenuContentContId).style.zIndex = "99993";
  851. document.getElementById(this.appmenuContentContId).style.opacity = "1.0";
  852. }
  853. this.appmenuVisible=!this.appmenuVisible;
  854. }
  855. /**
  856. * myappmenuHide
  857. *
  858. * Hide the appmenu
  859. *
  860. * Context:
  861. * - this function is for internal use
  862. *
  863. * @returns {void}
  864. *
  865. * This function is part of SqueeJS.
  866. */
  867. function myappmenuHide() {
  868. document.getElementById("SQJSappMenu").style.display = "none";
  869. this.appmenuVisible=false;
  870. document.getElementById(this.appmenuContentContId).style.opacity = "1.0";
  871. }
  872. /**
  873. * myappmenuCheckFlagIco
  874. *
  875. * Check to true the menu icon flag
  876. *
  877. * Context:
  878. * - this function is for internal use
  879. *
  880. * @returns {void}
  881. *
  882. * This function is part of SqueeJS.
  883. */
  884. function myappmenuCheckFlagIco() {
  885. this.appmenuOnIco = true;
  886. }
  887. /**
  888. * myappmenuUnCheckFlagIco
  889. *
  890. * Check to false the menu icon flag
  891. *
  892. * Context:
  893. * - this function is for internal use
  894. *
  895. * @returns {void}
  896. *
  897. * This function is part of SqueeJS.
  898. */
  899. function myappmenuUnCheckFlagIco() {
  900. this.appmenuOnIco = false;
  901. }
  902. /**
  903. * myappmenuBodyOnClick
  904. *
  905. * Body click event function: if open, hide the menu
  906. *
  907. * Context:
  908. * - this function is for internal use
  909. *
  910. * @returns {void}
  911. *
  912. * This function is part of SqueeJS.
  913. */
  914. function myappmenuBodyOnClick() {
  915. if (!this.appmenuOnIco) {
  916. this.appmenuHide();
  917. }
  918. }
  919. /**
  920. * mycreateAppMenu
  921. *
  922. * create the tag DIV of menu icon and app menu
  923. *
  924. * Context:
  925. * - Call it in the body of your webpage
  926. *
  927. * @param {string} icoURI, the URI of the menu icon
  928. * @param {string} menuURL, the URL of the menu web page
  929. * @param {string} contentContId, the container of the body content (the menu will disable it)
  930. * @param {string} top, the y coord of the menu position
  931. * @param {string} left, the x coord of the menu position
  932. * @param {string} width, the width of the menu
  933. * @param {string} height, the height of the menu
  934. * @returns {void}
  935. *
  936. * This function is part of SqueeJS.
  937. */
  938. function mycreateAppMenu(icoURI, menuURL, contentContId, top, left, width, height) {
  939. if (typeof jQuery === 'undefined') {
  940. throw new Error('This SqueeJS\'s function requires jQuery');
  941. }
  942. var D = document;
  943. //w = gfSQJZDocWidth();
  944. //h = gfSQJZDocHeight();
  945. this.appmenuContentContId = contentContId
  946. menuico = "";
  947. menuico = "<img src='"+icoURI+"' style='width:48px;height:48px;' alt='app menu'>";
  948. newdiv=D.createElement("div");
  949. newdiv.id = "SQJSappMenuIco";
  950. newdiv.style.width = "48px";
  951. newdiv.style.height = "48px";
  952. newdiv.innerHTML = menuico;
  953. //D.body.appendChild(newdiv);
  954. D.write(newdiv.outerHTML);
  955. $("#SQJSappMenuIco").on("click",function(){SQJS.appmenuPopUp();});
  956. $("#SQJSappMenuIco").on("mouseover",function(){SQJS.appmenuCheckFlagIco();});
  957. $("#SQJSappMenuIco").on("mouseout",function(){SQJS.appmenuUnCheckFlagIco();});
  958. menu = "";
  959. menu += "<!-- Here goes the content of the AppMenu -->";
  960. newdiv=D.createElement("div");
  961. newdiv.id = "SQJSappMenu";
  962. newdiv.style.top = top+"px";
  963. newdiv.style.left = left+"px";
  964. newdiv.style.width = width+"px";
  965. newdiv.style.height = height+"px";
  966. newdiv.innerHTML = menu;
  967. D.body.appendChild(newdiv);
  968. //D.write(newdiv.outerHTML);
  969. $("#SQJSappMenu").on("mouseover",function(){SQJS.appmenuCheckFlagIco();});
  970. $("#SQJSappMenu").on("mouseout",function(){SQJS.appmenuUnCheckFlagIco();});
  971. $("#SQJSappMenu").load(menuURL+"?rrnd="+ gfSQJZrnd(50000, 99999));
  972. $(document.body).on("click", function() {SQJS.appmenuBodyOnClick();});
  973. }
  974. // --- AppMenu
  975. /**
  976. *
  977. * GeoLocation
  978. */
  979. /**
  980. * myretrieveGeoLocation
  981. *
  982. * Retreive the geolocation (country name)
  983. *
  984. * Context:
  985. * - this function is for internal use
  986. *
  987. * @returns {void}
  988. *
  989. * This function is part of SqueeJS.
  990. */
  991. function myretrieveGeoLocation() {
  992. if (!this.geoLocation || this.geoLocation=="") {
  993. var xhttp = new XMLHttpRequest();
  994. var xmluri = SQJS_GEOURL;
  995. //alert(xmluri);
  996. xhttp.open("GET", xmluri, false);
  997. xhttp.send();
  998. this.geoLocation = xhttp.responseText;
  999. }
  1000. }
  1001. /**
  1002. * myhideElByGeoLocation
  1003. *
  1004. * Hide the given web page Element for the specified geolocation
  1005. *
  1006. * Context:
  1007. * - Call it in the body of your webpage
  1008. *
  1009. * @param {string} id, the id of the element to hide
  1010. * @param {string} geoloc, the geolocation (country name) to hide the el for
  1011. * @returns {void}
  1012. *
  1013. * This function is part of SqueeJS.
  1014. */
  1015. function myhideElByGeoLocation(id, geoloc) {
  1016. this.retrieveGeoLocation();
  1017. //alert("debug#2"+this.geoLocation);
  1018. if (this.geoLocation) {
  1019. if (geoloc.toLowerCase() === this.geoLocation.toLowerCase()) {
  1020. document.getElementById(id).style.display="none";
  1021. }
  1022. }
  1023. }
  1024. /**
  1025. * myshowElByGeoLocation
  1026. *
  1027. * Show the given web page Element for the specified geolocation
  1028. *
  1029. * Context:
  1030. * - Call it in the body of your webpage
  1031. *
  1032. * @param {string} id, the id of the element to show
  1033. * @param {string} geoloc, the geolocation (country name) to show the el for
  1034. * @returns {void}
  1035. *
  1036. * This function is part of SqueeJS.
  1037. */
  1038. function myshowElByGeoLocation(id, geoloc) {
  1039. this.retrieveGeoLocation();
  1040. //alert("debug#3"+this.geoLocation);
  1041. if (this.geoLocation) {
  1042. if (geoloc.toLowerCase() === this.geoLocation.toLowerCase()) {
  1043. document.getElementById(id).style.display="inline";
  1044. }
  1045. }
  1046. }
  1047. // --- GeoLocation
  1048. /**
  1049. *
  1050. * UserTranslation
  1051. */
  1052. /**
  1053. * myusertransPopUp
  1054. *
  1055. * Display/hide the user trans menu
  1056. *
  1057. * Context:
  1058. * - this function is for internal use
  1059. *
  1060. * @returns {void}
  1061. *
  1062. * This function is part of SqueeJS.
  1063. */
  1064. function myusertransPopUp() {
  1065. if (!this.usertransVisible) {
  1066. document.getElementById("SQJSuserTransMenu").style.display = "inline";
  1067. document.getElementById("SQJSuserTransMenu").style.zIndex = "99998";
  1068. document.getElementById(this.usertransContentContId).style.zIndex = "99997";
  1069. document.getElementById(this.usertransContentContId ).style.opacity = "0.3";
  1070. } else {
  1071. document.getElementById("SQJSuserTransMenu").style.display = "none";
  1072. document.getElementById("SQJSuserTransMenu").style.zIndex = "99992";
  1073. document.getElementById(this.usertransContentContId).style.zIndex = "99993";
  1074. document.getElementById(this.usertransContentContId).style.opacity = "1.0";
  1075. }
  1076. this.usertransVisible=!this.usertransVisible;
  1077. }
  1078. /**
  1079. * myusertransHide
  1080. *
  1081. * Hide the client trans menu
  1082. *
  1083. * Context:
  1084. * - this function is for internal use
  1085. *
  1086. * @returns {void}
  1087. *
  1088. * This function is part of SqueeJS.
  1089. */
  1090. function myusertransHide() {
  1091. document.getElementById("SQJSuserTransMenu").style.display = "none";
  1092. this.usertransVisible=false;
  1093. document.getElementById(this.usertransContentContId).style.opacity = "1.0";
  1094. }
  1095. /**
  1096. * myusertransCheckFlagIco
  1097. *
  1098. * Check to true the menu icon flag
  1099. *
  1100. * Context:
  1101. * - this function is for internal use
  1102. *
  1103. * @returns {void}
  1104. *
  1105. * This function is part of SqueeJS.
  1106. */
  1107. function myusertransCheckFlagIco() {
  1108. this.usertransOnIco = true;
  1109. }
  1110. /**
  1111. * myusertransUnCheckFlagIco
  1112. *
  1113. * Check to false the menu icon flag
  1114. *
  1115. * Context:
  1116. * - this function is for internal use
  1117. *
  1118. * @returns {void}
  1119. *
  1120. * This function is part of SqueeJS.
  1121. */
  1122. function myusertransUnCheckFlagIco() {
  1123. this.usertransOnIco = false;
  1124. }
  1125. /**
  1126. * myusertransBodyOnClick
  1127. *
  1128. * Body click event function: if open, hide the menu
  1129. *
  1130. * Context:
  1131. * - this function is for internal use
  1132. *
  1133. * @returns {void}
  1134. *
  1135. * This function is part of SqueeJS.
  1136. */
  1137. function myusertransBodyOnClick() {
  1138. if (!this.usertransOnIco) {
  1139. this.usertransHide();
  1140. }
  1141. }
  1142. /**
  1143. * mygetTranslitarates
  1144. *
  1145. * Get the transliterates to use in the translation
  1146. *
  1147. * Context:
  1148. * - this function is for internal use
  1149. *
  1150. * @returns {void}
  1151. *
  1152. * This function is part of SqueeJS.
  1153. */
  1154. function mygetTranslitarates() {
  1155. v=document.getElementById("SQJSuserTransTB").value.trim();
  1156. if (v!=="") {
  1157. if (v.substr(0,4).toLowerCase() === "http") {
  1158. transURL = v;
  1159. var xhttp = new XMLHttpRequest();
  1160. var xmluri = transURL;
  1161. //alert(xmluri);
  1162. xhttp.open("GET", xmluri, false);
  1163. xhttp.send();
  1164. xml = xhttp.responseText;
  1165. } else {
  1166. xml = v;
  1167. }
  1168. //cleaning
  1169. xml = xml.trim("\n");
  1170. xml = xml.trim();
  1171. xml = xml.trim("\n");
  1172. xml = xml.trim();
  1173. // parsing text
  1174. tl = xml.split("\n");
  1175. it=0;
  1176. for (t of tl) {
  1177. curt = t.split("|||");
  1178. if (curt[0] && curt[0]!=="") {
  1179. this.tranSource[it] = curt[0];
  1180. this.tranDest[it] = curt[1];
  1181. }
  1182. it++;
  1183. }
  1184. }
  1185. }
  1186. /**
  1187. * mytranslate
  1188. *
  1189. * Make the client translation of the current web page
  1190. *
  1191. * Context:
  1192. * - this function is for internal use
  1193. *
  1194. * @returns {void}
  1195. *
  1196. * This function is part of SqueeJS.
  1197. */
  1198. function mytranslate() {
  1199. this.getTranslitarates();
  1200. it=0;
  1201. for (ts of this.tranSource) {
  1202. nl = document.getElementsByTagName("H1");
  1203. for (n of nl) {
  1204. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1205. }
  1206. nl = document.getElementsByTagName("H2");
  1207. for (n of nl) {
  1208. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1209. }
  1210. nl = document.getElementsByTagName("H3");
  1211. for (n of nl) {
  1212. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1213. }
  1214. nl = document.getElementsByTagName("A");
  1215. for (n of nl) {
  1216. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1217. }
  1218. nl = document.getElementsByTagName("DIV");
  1219. for (n of nl) {
  1220. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1221. }
  1222. nl = document.getElementsByTagName("LABEL");
  1223. for (n of nl) {
  1224. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1225. }
  1226. nl = document.getElementsByTagName("SPAN");
  1227. for (n of nl) {
  1228. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1229. }
  1230. nl = document.getElementsByTagName("INPUT");
  1231. for (n of nl) {
  1232. n.value = n.value.replace(ts, this.tranDest[it]);
  1233. n.setAttribute("placeholder", n.getAttribute("placeholder").replace(ts, this.tranDest[it]));
  1234. }
  1235. nl = document.getElementsByTagName("TEXTAREA");
  1236. for (n of nl) {
  1237. if (n.id !== "SQJSuserTransTB") {
  1238. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1239. }
  1240. }
  1241. it++;
  1242. }
  1243. }
  1244. /**
  1245. * mycreateUserTrans
  1246. *
  1247. * Create the tag DIV of user trans icon and user trans menu
  1248. *
  1249. * Context:
  1250. * - Call it in the body of your webpage
  1251. *
  1252. * @param {string} icoURI, the URI of the menu icon
  1253. * @param {string} contentContId, the container of the body content (the menu will disable it)
  1254. * @param {string} top, the y coord of the menu position
  1255. * @param {string} left, the x coord of the menu position
  1256. * @returns {void}
  1257. *
  1258. * This function is part of SqueeJS.
  1259. */
  1260. function mycreateUserTrans(icoURI, contentContId, top, left) {
  1261. //if (typeof jQuery === 'undefined') {
  1262. // throw new Error('This SqueeJS\'s function requires jQuery');
  1263. //}
  1264. var D = document;
  1265. //w = gfSQJZDocWidth();
  1266. //h = gfSQJZDocHeight();
  1267. this.usertransContentContId = contentContId
  1268. menuico = "";
  1269. menuico = "<img src='"+icoURI+"' style='width:48px;height:48px;' alt='user translation'>";
  1270. newdiv=D.createElement("div");
  1271. newdiv.id = "SQJSuserTransIco";
  1272. newdiv.style.width = "48px";
  1273. newdiv.style.height = "48px";
  1274. newdiv.innerHTML = menuico;
  1275. //D.body.appendChild(newdiv);
  1276. D.write(newdiv.outerHTML);
  1277. document.getElementById("SQJSuserTransIco").onclick = function(){SQJS.usertransPopUp();};
  1278. document.getElementById("SQJSuserTransIco").onmouseover = function(){SQJS.usertransCheckFlagIco();};
  1279. document.getElementById("SQJSuserTransIco").onmouseout = function(){SQJS.usertransUnCheckFlagIco();};
  1280. menu = "";
  1281. menu += "<span style='font-size:10px;'>text or link, use ||| to separate source from translation:</span>";
  1282. menu += "<textarea id='SQJSuserTransTB'></textarea><br>";
  1283. menu += "<button id='SQJSuserTransBUT' onclick='SQJS.translate();'><img src='//squeejs.com/res/trans.png' style='height:70px'></button><br>";
  1284. menu += "<br>";
  1285. newdiv=D.createElement("div");
  1286. newdiv.id = "SQJSuserTransMenu";
  1287. newdiv.style.top = top+"px";
  1288. newdiv.style.left = left+"px";
  1289. newdiv.style.width = "380px";
  1290. newdiv.style.height = "515px";
  1291. newdiv.innerHTML = menu;
  1292. D.body.appendChild(newdiv);
  1293. //D.write(newdiv.outerHTML);
  1294. document.getElementById("SQJSuserTransMenu").onmouseover = function(){SQJS.usertransCheckFlagIco();};
  1295. document.getElementById("SQJSuserTransMenu").onmouseout = function(){SQJS.usertransUnCheckFlagIco();};
  1296. //document.body.onclick = function(){SQJS.usertransBodyOnClick();};
  1297. }
  1298. }
  1299. window.SQJS = window.SqueeJS = new SqueeJS();
  1300. window.addEventListener("load", function() {
  1301. nl = document.getElementsByTagName("DIV");
  1302. i=0;
  1303. for (n of nl) {
  1304. n.setAttribute("highlightIndex", i);
  1305. i++;
  1306. }
  1307. nl = document.getElementsByTagName("INPUT");
  1308. for (n of nl) {
  1309. n.setAttribute("highlightIndex", i);
  1310. i++;
  1311. }
  1312. nl = document.getElementsByTagName("TEXTAREA");
  1313. for (n of nl) {
  1314. n.setAttribute("highlightIndex", i);
  1315. i++;
  1316. }
  1317. },true);