squeejs.js 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830
  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.1.2
  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.5mode-lab.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. //Sideabar
  106. this.sidebarContentContId = "";
  107. this.sidebarVisible = false;
  108. this.sidebarOnIT = false;
  109. this.sidebarClose = mysidebarClose;
  110. this.sidebarShow = mysidebarShow;
  111. this.sidebarCheckFlag=mysidebarCheckFlag;
  112. this.sidebarUnCheckFlag=mysidebarUnCheckFlag;
  113. this.sidebarBodyOnClick=mysidebarBodyOnClick;
  114. this.createSidebar = mycreateSidebar;
  115. /**
  116. * gfSQJZDocWidth
  117. *
  118. * Get the width of the whole document
  119. *
  120. * @returns {int} the document width
  121. *
  122. * This function is part of SqueeJS.
  123. */
  124. function gfSQJZDocWidth() {
  125. var D = document;
  126. var scrollMaxX;
  127. if (window.scrollMaxX) {
  128. scrollMaxX = window.scrollMaxX;
  129. } else {
  130. scrollMaxX = D.documentElement.scrollWidth;
  131. }
  132. return Math.max(
  133. D.body.scrollWidth, scrollMaxX,
  134. D.body.offsetWidth, D.documentElement.offsetWidth,
  135. D.body.clientWidth, D.documentElement.clientWidth
  136. );
  137. }
  138. /**
  139. * gfSQJZgetAttrById
  140. *
  141. * Get the value of the given element attribute
  142. *
  143. * @param {string} id, the id selector of the document element
  144. * @param {string} attributeName, the attribute to retrieve
  145. * @returns {string} the attribute value
  146. */
  147. function gfSQJZgetAttrById(id, attributeName) {
  148. if (document.getElementById(id)) {
  149. return document.getElementById(id).getAttribute(attributeName);
  150. } else {
  151. return "";
  152. }
  153. }
  154. /**
  155. * gfSQJZsetAttrById
  156. *
  157. * Set the value of the given element attribute
  158. *
  159. * @param {string} id, the id selector of the document element
  160. * @param {string} attributeName, the attribute to retrieve
  161. * @param {string} value, the new attribute value
  162. * @returns {string} the attribute value
  163. */
  164. function gfSQJZsetAttrById(id, attributeName, value) {
  165. if (document.getElementById(id)) {
  166. document.getElementById(id).setAttribute(attributeName, value);
  167. }
  168. }
  169. /**
  170. * gfSQJZgetCSSById
  171. *
  172. * Get the value for the given element style property
  173. *
  174. * @param {string} id, the id selector of the document element
  175. * @param {string} cssName, the css property to retrieve
  176. * @returns {string} the property value
  177. */
  178. function gfSQJZgetCSSById(id, cssName) {
  179. if (document.getElementById(id)) {
  180. return document.getElementById(id).style[cssName];
  181. } else {
  182. return "";
  183. }
  184. }
  185. /**
  186. * gfSQJZsetCSSById
  187. *
  188. * Set the value for the given element style property
  189. *
  190. * @param {string} id, the id selector of the document element
  191. * @param {string} cssName, the css property to retrieve
  192. * @returns {string} the property value
  193. */
  194. function gfSQJZsetCSSById(id, cssName, value) {
  195. if (document.getElementById(id)) {
  196. document.getElementById(id).style[cssName] = value;
  197. }
  198. }
  199. /**
  200. * gfSQJZDocHeight
  201. *
  202. * Get the height of the whole document
  203. *
  204. * @returns {int} the document height
  205. *
  206. * This function is part of SqueeJS.
  207. */
  208. function gfSQJZDocHeight() {
  209. var D = document;
  210. var scrollMaxY;
  211. if (window.scrollMaxY) {
  212. scrollMaxY = window.scrollMaxY;
  213. } else {
  214. scrollMaxY = D.documentElement.scrollHeight;
  215. }
  216. var height = Math.max(
  217. D.body.scrollHeight, scrollMaxY,
  218. D.body.offsetHeight, D.documentElement.offsetHeight,
  219. D.body.clientHeight, D.documentElement.clientHeight
  220. );
  221. return height;
  222. }
  223. /**
  224. * gfSQJZLoad
  225. *
  226. * Load the content of <url> in the given DIV element
  227. *
  228. * @param {string} id, the DIV id to fill
  229. * @param {string} url, the url of the content to load
  230. * @returns {void}
  231. *
  232. * This function is part of SqueeJS.
  233. */
  234. function gfSQJZLoad(id, url) {
  235. try {
  236. var xhttp = new XMLHttpRequest();
  237. var xmluri = url;
  238. //alert(xmluri);
  239. xhttp.open("GET", xmluri, false);
  240. xhttp.send();
  241. document.getElementById(id).innerHTML = xhttp.responseText;
  242. } catch(e) {
  243. throw new Error("404 or CORS error: check the resource availability and Access-Control-Allow-Origin of your site.");
  244. }
  245. }
  246. /**
  247. * gfSQJZrnd
  248. *
  249. * Generate a random number between the given limits
  250. *
  251. * @param {int} min, the starting limit
  252. * @param {int} max, the max limit
  253. * @returns {int} the generated random value
  254. *
  255. * This function is part of SqueeJS.
  256. */
  257. function gfSQJZrnd(min, max) {
  258. min = Math.ceil(min);
  259. max = Math.floor(max);
  260. return Math.floor(Math.random() * (max - min +1)) + min;
  261. }
  262. /**
  263. *
  264. * Highlight
  265. *
  266. */
  267. /**
  268. * highlightDiv
  269. *
  270. * Highlight the current DIV element
  271. *
  272. * Context:
  273. * - call this function in the onmouseenter event
  274. *
  275. * @param {Element} tthis, the current DIV element (this on the function call)
  276. * @returns {void}
  277. *
  278. * This function is part of SqueeJS.
  279. */
  280. function myhighlightDiv(tthis) {
  281. if (tthis.tagName !== "DIV") {
  282. return;
  283. }
  284. // --- saving original data
  285. myR = tthis.getBoundingClientRect();
  286. highlightIndex = tthis.getAttribute("highlightIndex");
  287. this.highlightOriTop[highlightIndex] = parseInt(myR.top);
  288. this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
  289. this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
  290. this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
  291. this.highlightOriBorder[highlightIndex] = tthis.style.border;
  292. this.highlightOriPosition[highlightIndex] = tthis.style.position;
  293. // ---
  294. tthis.style.position = "absolute";
  295. tthis.style.height = "480px";
  296. tthis.style.width = "650px";
  297. tthis.style.border = "3px dashed darkcyan";
  298. tthis.style.fontSize = "25px";
  299. //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
  300. }
  301. /**
  302. * unlightDiv
  303. *
  304. * Unlight the current DIV element
  305. *
  306. * Context:
  307. * - call this function in the onmouseleave event
  308. *
  309. * @param {Element} tthis, the current DIV element (this on the function call)
  310. * @returns {void}
  311. *
  312. * This function is part of SqueeJS.
  313. */
  314. function myunlightDiv(tthis) {
  315. if (tthis.tagName !== "DIV") {
  316. return;
  317. }
  318. // --- restoring original data
  319. highlightIndex = tthis.getAttribute("highlightIndex");
  320. if (this.highlightOriTop[highlightIndex]===null) {
  321. return;
  322. }
  323. tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
  324. tthis.style.border = this.highlightOriBorder[highlightIndex];
  325. tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
  326. tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
  327. tthis.style.position = this.highlightOriPosition[highlightIndex];
  328. // ---
  329. //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
  330. }
  331. /**
  332. * highlightInput
  333. *
  334. * Highlight the current INPUT element
  335. *
  336. * Context:
  337. * - call this function in the onmouseenter event
  338. *
  339. * @param {Element} tthis, the current INPUT element (this on the function call)
  340. * @returns {void}
  341. *
  342. * This function is part of SqueeJS.
  343. */
  344. function myhighlightInput(tthis) {
  345. if (tthis.tagName !== "INPUT") {
  346. return;
  347. }
  348. // --- saving original data
  349. myR = tthis.getBoundingClientRect();
  350. highlightIndex = tthis.getAttribute("highlightIndex");
  351. this.highlightOriTop[highlightIndex] = parseInt(myR.top);
  352. this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
  353. this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
  354. this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
  355. this.highlightOriBorder[highlightIndex] = tthis.style.border;
  356. this.highlightOriPosition[highlightIndex] = tthis.style.position;
  357. // ---
  358. tthis.style.position = "absolute";
  359. tthis.style.height = "40px";
  360. tthis.style.width = "400px";
  361. tthis.style.border = "3px solid lightblue";
  362. tthis.style.fontSize = "25px";
  363. //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
  364. }
  365. /**
  366. * unlightInput
  367. *
  368. * Unlight the current INPUT element
  369. *
  370. * Context:
  371. * - call this function in the onmouseleave event
  372. *
  373. * @param {Element} tthis, the current INPUT element (this on the function call)
  374. * @returns {void}
  375. *
  376. * This function is part of SqueeJS.
  377. */
  378. function myunlightInput(tthis) {
  379. if (tthis.tagName !== "INPUT") {
  380. return;
  381. }
  382. // --- restoring original data
  383. highlightIndex = tthis.getAttribute("highlightIndex");
  384. if (this.highlightOriTop[highlightIndex]===null) {
  385. return;
  386. }
  387. tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
  388. tthis.style.border = this.highlightOriBorder[highlightIndex];
  389. tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
  390. tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
  391. tthis.style.position = this.highlightOriPosition[highlightIndex];
  392. // ---
  393. //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
  394. }
  395. /**
  396. * highlightTextArea
  397. *
  398. * Highlight the current TEXTAREA element
  399. *
  400. * Context:
  401. * - call this function in the onmouseenter event
  402. *
  403. * @param {Element} tthis, the current TEXTAREA element (this on the function call)
  404. * @returns {void}
  405. *
  406. * This function is part of SqueeJS.
  407. */
  408. function myhighlightTextArea(tthis) {
  409. if (tthis.tagName !== "TEXTAREA") {
  410. return;
  411. }
  412. // --- saving original data
  413. myR = tthis.getBoundingClientRect();
  414. highlightIndex = tthis.getAttribute("highlightIndex");
  415. this.highlightOriTop[highlightIndex] = parseInt(myR.top);
  416. this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
  417. this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
  418. this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
  419. this.highlightOriBorder[highlightIndex] = tthis.style.border;
  420. this.highlightOriPosition[highlightIndex] = tthis.style.position;
  421. // ---
  422. tthis.style.position = "absolute";
  423. tthis.style.height = "240px";
  424. tthis.style.width = "400px";
  425. tthis.style.border = "3px solid lightblue";
  426. tthis.style.fontSize = "25px";
  427. //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
  428. }
  429. /**
  430. * unlightTextArea
  431. *
  432. * Unlight the current TEXTAREA element
  433. *
  434. * Context:
  435. * - call this function in the onmouseleave event
  436. *
  437. * @param {Element} tthis, the current TEXTAREA element (this on the function call)
  438. * @returns {void}
  439. *
  440. * This function is part of SqueeJS.
  441. */
  442. function myunlightTextArea(tthis) {
  443. if (tthis.tagName !== "TEXTAREA") {
  444. return;
  445. }
  446. // --- restoring original data
  447. highlightIndex = tthis.getAttribute("highlightIndex");
  448. if (this.highlightOriTop[highlightIndex]===null) {
  449. return;
  450. }
  451. tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
  452. tthis.style.border = this.highlightOriBorder[highlightIndex];
  453. tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
  454. tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
  455. tthis.style.position = this.highlightOriPosition[highlightIndex];
  456. // ---
  457. //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
  458. }
  459. // --- End Highlight
  460. /**
  461. *
  462. * Splash Screen
  463. */
  464. /**
  465. * createSplash
  466. *
  467. * Create the tag DIV for the splash screen
  468. *
  469. * Context:
  470. * - this function is for internal use
  471. *
  472. * @returns {void}
  473. *
  474. * This function is part of SqueeJS.
  475. */
  476. function mycreateSplash() {
  477. var D = document;
  478. w = gfSQJZDocWidth();
  479. splashLeft = parseInt((w - 265) / 2);
  480. h = gfSQJZDocHeight();
  481. title = this.splashTitle;
  482. logoURI = this.splashLogoURI;
  483. BG = this.splashBG;
  484. //alert(this.splashTitle);
  485. //alert(this.splashLogoURI);
  486. //alert(this.splashBG);
  487. splash = "";
  488. splash += "<br><br><br><br>";
  489. splash += "<div style='width:267px;margin:auto;text-align:center;'>"+title+"</div><br>";
  490. splash += "<div style='width:267px;margin:auto;'><img src='"+logoURI+"' style='width:265px;'></div>";
  491. newdiv=D.createElement("div");
  492. newdiv.id = "SQJSsplash";
  493. newdiv.style.background = BG;
  494. newdiv.style.width = w;
  495. newdiv.style.height = h;
  496. newdiv.style.textAlign = 'left';
  497. newdiv.style.fontFamily = 'Arial,Sans,Verdana';
  498. newdiv.style.fontSize = '35px';
  499. newdiv.style.fontWeight = '900';
  500. newdiv.style.paddingLeft = splashLeft+"px";
  501. newdiv.innerHTML = splash;
  502. D.body.appendChild(newdiv);
  503. }
  504. /**
  505. * SPALSHstartApp
  506. *
  507. * Start the web app just after the Splash
  508. *
  509. * Context:
  510. * - this function is for internal use
  511. *
  512. * @returns {void}
  513. *
  514. * This function is part of SqueeJS.
  515. */
  516. function mySplashStartApp() {
  517. //alert("hello");
  518. //Splash
  519. //if (document.getElementById("SQJSsplash")) {
  520. // document.getElementById("SQJSsplash").style.display = "none";
  521. //}
  522. gfSQJZsetCSSById("SQJSsplash", "display", "none");
  523. //Main Container
  524. //document.getElementById(this.splashMainContainerId).style.height = this.splashMainContainerOriHeight;
  525. gfSQJZsetCSSById(this.splashMainContainerId, "height", this.splashMainContainerOriHeight);
  526. //document.getElementById(this.splashMainContainerId).style.display = "inline";
  527. gfSQJZsetCSSById(this.splashMainContainerId, "display", "inline");
  528. window.scrollTo(0,0);
  529. }
  530. /**
  531. * _SPLASHstartApp
  532. *
  533. * Set the timeout to start the web app just after the Splash
  534. *
  535. * Context:
  536. * - this function is for internal use
  537. *
  538. * @param {int} time, the interval of time to wait before to start the webapp
  539. * @returns {void}
  540. *
  541. * This function is part of SqueeJS.
  542. */
  543. //function _SPLASHstartApp(time) {
  544. // Fisnished the Intro with the Splash we load the app..
  545. // setTimeout("SPLASHstartApp()", time);
  546. //}
  547. /**
  548. * _initAppWithSplash
  549. *
  550. * Init the web app to start with the Splash
  551. *
  552. * Context:
  553. * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
  554. *
  555. * @param {string} mainContainerId, the container ID for the webpage content
  556. * @param {string} title, the title of the splash screen
  557. * @param {string} logoURI, the logo to display in the splash screen
  558. * @param {string} BG, the background for the splash screen
  559. * @param {int} timeout, the splash screen timeout
  560. * @returns {void}
  561. *
  562. * This function is part of SqueeJS.
  563. */
  564. function myinitAppWithSplash(mainContainerId, title, logoURI, BG, timeout) {
  565. this.splashMainContainerId = mainContainerId;
  566. this.splashTitle = title;
  567. this.splashLogoURI = logoURI;
  568. this.splashBG = BG;
  569. if (timeout!==null) {
  570. this.splashTimeout = timeout;
  571. }
  572. //Main Container
  573. //document.getElementById(this.splashMainContainerId).style.display = "none";
  574. gfSQJZsetCSSById(this.splashMainContainerId, "display", "none");
  575. //Splash
  576. this.createSplash();
  577. document.getElementById("SQJSsplash").style.display = "inline";
  578. //window.scrollTo(1,1);
  579. document.body.style.height = parseInt(window.innerHeight) + "px";
  580. //this.splashMainContainerOriHeight = document.getElementById(this.splashMainContainerId).style.height;
  581. this.splashMainContainerOriHeight = gfSQJZgetCSSById(this.splashMainContainerId, "height");
  582. //document.getElementById(this.splashMainContainerId).style.height = parseInt(window.innerHeight) + "px";
  583. gfSQJZsetCSSById(this.splashMainContainerId, "height", parseInt(window.innerHeight) + "px");
  584. setTimeout("SQJS.splashStartApp()", this.splashTimeout);
  585. }
  586. /**
  587. * _initAppWithoutSplash
  588. *
  589. * Init the web app to start withOUT the Splash
  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. * @returns {void}
  596. *
  597. * This function is part of SqueeJS.
  598. */
  599. function myinitAppWithoutSplash(mainContainerId) {
  600. this.splashMainContainerId = mainContainerId;
  601. //Main Container
  602. //document.getElementById(this.splashMainContainerId).style.display = "inline";
  603. gfSQJZsetCSSById(this.splashMainContainerId, "display", "inline");
  604. //Splash
  605. //document.getElementById("SQJSsplash").style.display = "none";
  606. setTimeout("SQJS.splashStartApp()", 1);
  607. }
  608. // --- End Splash Screen
  609. /**
  610. *
  611. * Work in Progress
  612. */
  613. /**
  614. * createWIP
  615. *
  616. * Create the tag DIV for the Work In Progress Banner
  617. *
  618. * Context:
  619. * - this function is for internal use
  620. *
  621. * @returns {void}
  622. *
  623. * This function is part of SqueeJS.
  624. */
  625. function _createWIP() {
  626. var D = document;
  627. w = gfSQJZDocWidth();
  628. wipLeft = parseInt((w - 450) / 2);
  629. h = gfSQJZDocHeight();
  630. bannerURI = "//squeejs.com/res/work-in-progress.png";
  631. BG = this.wipBG;
  632. wip = "";
  633. wip += "<br><br><br><br><br><br><br>";
  634. wip += "<div style='width:450px;margin:auto;'><img src='"+bannerURI+"' style='width:450px;'></div>";
  635. newdiv=D.createElement("div");
  636. newdiv.id = "SQJSWIP";
  637. newdiv.style.background = BG;
  638. newdiv.style.width = w;
  639. newdiv.style.height = h;
  640. newdiv.style.textAlign = 'left';
  641. newdiv.style.fontFamily = 'Arial,Sans,Verdana';
  642. newdiv.style.fontSize = '35px';
  643. newdiv.style.fontWeight = '900';
  644. newdiv.style.paddingLeft = wipLeft+"px";
  645. newdiv.innerHTML = wip;
  646. D.body.appendChild(newdiv);
  647. }
  648. /**
  649. * WIPstartApp
  650. *
  651. * Start the web app just after the WIP banner
  652. *
  653. * Context:
  654. * - this function is for internal use
  655. *
  656. * @returns {void}
  657. *
  658. * This function is part of SqueeJS.
  659. */
  660. function myWIPStartApp() {
  661. //Splash
  662. //if (document.getElementById("SQJSWIP")) {
  663. // document.getElementById("SQJSWIP").style.display = "none";
  664. //}
  665. gfSQJZsetCSSById("SQJSWIP", "display", "none");
  666. //Main Container
  667. //document.getElementById(this.wipMainContainerId).style.height = this.wipMainContainerOriHeight;
  668. gfSQJZsetCSSById(this.wipMainContainerId, "height", this.wipMainContainerOriHeight);
  669. //document.getElementById(this.wipMainContainerId).style.display = "inline";
  670. gfSQJZsetCSSById(this.wipMainContainerId, "display", "inline");
  671. window.scrollTo(0,0);
  672. }
  673. /**
  674. * _WIPstartApp
  675. *
  676. * Set the timeout to start the web app just after the Splash
  677. *
  678. * Context:
  679. * - this function is for internal use
  680. *
  681. * @param {int} time, the interval of time to wait before to start the webapp
  682. * @returns {void}
  683. *
  684. * This function is part of SqueeJS.
  685. */
  686. //function _WIPstartApp(time) {
  687. // Fisnished the Intro with the Splash we load the app..
  688. // setTimeout("WIPstartApp()", time);
  689. //}
  690. /**
  691. * _initAppWithWIP
  692. *
  693. * Init the web app to start with the work in progress banner
  694. *
  695. * Context:
  696. * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
  697. *
  698. * @param {string} mainContainerId, the container ID for the webpage content
  699. * @param {string} BG, the background for the wip banner
  700. * @returns {void}
  701. *
  702. * This function is part of SqueeJS.
  703. */
  704. function myinitAppWithWIP(mainContainerId, BG) {
  705. this.wipMainContainerId = mainContainerId;
  706. this.wipBG = BG;
  707. //Main Container
  708. //document.getElementById(this.wipMainContainerId).style.display = "none";
  709. gfSQJZsetCSSById(this.wipMainContainerId, "display", "none");
  710. //Banner
  711. _createWIP();
  712. document.getElementById("SQJSWIP").style.display = "inline";
  713. //window.scrollTo(1,1);
  714. document.body.style.height = parseInt(window.innerHeight) + "px";
  715. //this.wipMainContainerOriHeight = document.getElementById(this.wipMainContainerId).style.height;
  716. this.wipMainContainerOriHeight = gfSQJZgetCSSById(this.wipMainContainerId, "height");
  717. //document.getElementById(this.wipMainContainerId).style.height = parseInt(window.innerHeight) + "px";
  718. gfSQJZsetCSSById(this.wipMainContainerId, "height", parseInt(window.innerHeight) + "px");
  719. }
  720. /**
  721. * _initAppWithoutWIP
  722. *
  723. * Init the web app to start withOUT the WIP banner
  724. *
  725. * Context:
  726. * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
  727. *
  728. * @param {string} mainContainerId, the container ID for the webpage content
  729. * @returns {void}
  730. *
  731. * This function is part of SqueeJS.
  732. */
  733. function myinitAppWithoutWIP(mainContainerId) {
  734. this.wipMainContainerId = mainContainerId;
  735. //Main Container
  736. //document.getElementById(this.wipMainContainerId).style.display = "inline";
  737. gfSQJZsetCSSById(this.wipMainContainerId, "display", "inline");
  738. //Splash
  739. //document.getElementById("SQJSWIP").style.display = "none";
  740. setTimeout("SQJS.wipStartApp()", 1);
  741. }
  742. // --- Work in Progress
  743. /**
  744. *
  745. * Banner
  746. */
  747. /**
  748. * createBanner
  749. *
  750. * Create a new Banner
  751. *
  752. * Context:
  753. * - Call in the body of your webpage
  754. *
  755. * @param {string} img, the banner img (471px width)
  756. * @param {string} url, the banner target url
  757. * @param {string} align, the banner horizontal alignment [left|middle|right]
  758. * @param {string} display, the banner display [fixed|absolute|relative|none]
  759. * @param {int} minScreenWidth, min screen width to display the banner
  760. * @returns {string} the id of the resulting banner
  761. *
  762. * This function is part of SqueeJS.
  763. */
  764. function mycreateBanner(img, url, align, display, minScreenWidth) {
  765. this.bannerIndex++;
  766. this.bannerIMG[this.bannerIndex] = img;
  767. this.bannerURL[this.bannerIndex] = url;
  768. var D = document;
  769. w = gfSQJZDocWidth();
  770. switch (align) {
  771. case "middle":
  772. bannerLeft = parseInt((w - 473) / 2);
  773. break;
  774. case "left":
  775. bannerLeft = 0;
  776. break;
  777. case "right":
  778. bannerLeft = parseInt(w - 473);
  779. break;
  780. default:
  781. bannerLeft = parseInt((w - 473) / 2);
  782. break;
  783. }
  784. bbannerIMG = this.bannerIMG[this.bannerIndex];
  785. bbannerURL = this.bannerURL[this.bannerIndex];
  786. banner = "";
  787. banner += "<button type='button' class='SQJSclose-button' onclick='SQJS.closeBanner(this);'>";
  788. banner += "<span style='font-weight:900;'>&times;</span>";
  789. banner += "</button>";
  790. banner += "<a href='"+bbannerURL+"' target='_blank'><img src='"+bbannerIMG+"' style='width:471px;'></a>";
  791. newdiv=D.createElement("div");
  792. newdiv.id = "SQJSBANNER" + this.bannerIndex;
  793. //newdiv.style.width = w;
  794. //newdiv.style.height = h;
  795. newdiv.style.textAlign = 'left';
  796. //newdiv.style.fontFamily = 'Arial,Sans,Verdana';
  797. //newdiv.style.fontSize = '35px';
  798. //newdiv.style.fontWeight = '900';
  799. newdiv.style.marginLeft = bannerLeft+"px";
  800. bannerDisplay = true;
  801. switch (display) {
  802. case "fixed":
  803. newdiv.className = "SQJSbanner-fixed";
  804. newdiv.style.top = (((35 +62) * (this.bannerIndex-1))) + "px";
  805. break;
  806. case "absolute":
  807. newdiv.className = "SQJSbanner-absolute";
  808. newdiv.style.top = (((35 +62) * (this.bannerIndex-1))) + "px";
  809. break;
  810. case "relative":
  811. newdiv.className = "SQJSbanner-relative";
  812. break;
  813. case "none":
  814. bannerDisplay = false;
  815. break;
  816. }
  817. if (window.innerWidth < minScreenWidth) {
  818. bannerDisplay = false;
  819. }
  820. if (!bannerDisplay) {
  821. newdiv.style.display = "none";
  822. }
  823. newdiv.innerHTML = banner;
  824. //D.body.appendChild(newdiv);
  825. D.write(newdiv.outerHTML);
  826. return "SQJSBANNER"+this.bannerIndex;
  827. }
  828. function mycloseBanner(tthis) {
  829. tthis.parentNode.style.display = "none";
  830. }
  831. // --- Banner
  832. /**
  833. *
  834. * Footer
  835. */
  836. /**
  837. * createFooter
  838. *
  839. * Create the tag DIV for the footer
  840. *
  841. * Context:
  842. * - Call it in the body of your webpage
  843. *
  844. * @param {string} html, the html to insert as footer
  845. * @param {string} BG, the background of the footer
  846. * @param {string} align, the banner horizontal alignment [left|middle|right]
  847. * @param {string} display, the banner display [fixed|relative|none]
  848. * @returns {string} the id of the footer DIV element
  849. *
  850. * This function is part of SqueeJS.
  851. */
  852. function mycreateFooter(html, BG, align, display) {
  853. htollerance = 12;
  854. htollerance = 12;
  855. footerContHeight = 35;
  856. footerHeight = 32;
  857. footerFloat = "";
  858. this.footerHTML = html;
  859. this.BG = BG;
  860. var D = document;
  861. w = gfSQJZDocWidth();
  862. h = window.innerHeight;
  863. footerDisplay = true;
  864. footerContClassName = "";
  865. footerClassName = "";
  866. switch (display) {
  867. case "fixed":
  868. footerContClassName = "SQJSfooterCont";
  869. footerClassName = "SQJSfooter";
  870. break;
  871. case "relative":
  872. footerContClassName = "SQJSfooterCont";
  873. footerClassName = "SQJSfooter";
  874. break;
  875. case "none":
  876. footerContClassName = "SQJSfooterCont";
  877. footerClassName = "SQJSfooter";
  878. footerDisplay = false;
  879. break;
  880. default:
  881. display="relative";
  882. footerContClassName = "SQJSfooterCont";
  883. footerClassName = "SQJSfooter";
  884. break;
  885. }
  886. footer = "";
  887. footer += "<div class='"+footerContClassName+"'>&nbsp;</div>";
  888. footer += "<div class='"+footerClassName+"'>"+html+"</div> ";
  889. newdiv=D.createElement("div");
  890. newdiv.id = "SQJSfooter";
  891. newdiv.className = "footer";
  892. //newdiv.style.textAlign = 'left';
  893. newdiv.innerHTML = footer;
  894. D.body.appendChild(newdiv);
  895. document.getElementsByClassName(footerClassName)[0].style.background = BG;
  896. switch (align) {
  897. case "middle":
  898. footerLeft = parseInt((w - document.getElementsByClassName(footerClassName)[0].getBoundingClientRect().width) / 2);
  899. break;
  900. case "left":
  901. footerLeft = 0;
  902. footerFloat = "left";
  903. break;
  904. case "right":
  905. footerLeft = parseInt(w - document.getElementsByClassName(footerClassName)[0].getBoundingClientRect().width);
  906. footerFloat = "right";
  907. break;
  908. default:
  909. align="left";
  910. footerLeft = 0;
  911. footerFloat = "left";
  912. break;
  913. }
  914. document.getElementsByClassName(footerClassName)[0].style.float = footerFloat;
  915. if (display === "relative") {
  916. //document.getElementsByClassName(footerClassName)[0].style.top = "-" + footerContHeight + "px";
  917. } else if (display === "fixed") {
  918. document.getElementsByClassName("footer")[0].style.marginLeft = (footerLeft-wtollerance)+"px";
  919. document.getElementsByClassName("footer")[0].style.position = "fixed";
  920. document.getElementsByClassName("footer")[0].style.top = ""+parseInt(h - footerContHeight - htollerance) + "px";
  921. if (align === "right") {
  922. //document.getElementsByClassName("footer")[0].style.textAlign = "right";
  923. } else if (align === "middle") {
  924. //document.getElementsByClassName(footerClassName)[0].style.width = "800px";
  925. document.getElementsByClassName("footer")[0].style.textAlign = "center";
  926. }
  927. } else {
  928. newdiv.style.display = "none";
  929. }
  930. return newdiv.id;
  931. }
  932. // --- Footer
  933. /**
  934. *
  935. * AppMenu
  936. */
  937. /**
  938. * myappmenuPopUp
  939. *
  940. * Display/hide the appmenu
  941. *
  942. * Context:
  943. * - this function is for internal use
  944. *
  945. * @returns {void}
  946. *
  947. * This function is part of SqueeJS.
  948. */
  949. function myappmenuPopUp() {
  950. if (!this.appmenuVisible) {
  951. document.getElementById("SQJSappMenu").style.display = "inline";
  952. document.getElementById("SQJSappMenu").style.zIndex = "99998";
  953. //document.getElementById(this.appmenuContentContId).style.zIndex = "99997";
  954. gfSQJZsetCSSById(this.appmenuContentContId, "zIndex", "99997");
  955. //document.getElementById(this.appmenuContentContId ).style.opacity = "0.3";
  956. gfSQJZsetCSSById(this.appmenuContentContId, "opacity", "0.3");
  957. } else {
  958. document.getElementById("SQJSappMenu").style.display = "none";
  959. document.getElementById("SQJSappMenu").style.zIndex = "99992";
  960. //document.getElementById(this.appmenuContentContId).style.zIndex = "99993";
  961. gfSQJZsetCSSById(this.appmenuContentContId, "zIndex", "99993");
  962. //document.getElementById(this.appmenuContentContId).style.opacity = "1.0";
  963. gfSQJZsetCSSById(this.appmenuContentContId, "opacity", "1.0");
  964. }
  965. this.appmenuVisible=!this.appmenuVisible;
  966. }
  967. /**
  968. * myappmenuHide
  969. *
  970. * Hide the appmenu
  971. *
  972. * Context:
  973. * - this function is for internal use
  974. *
  975. * @returns {void}
  976. *
  977. * This function is part of SqueeJS.
  978. */
  979. function myappmenuHide() {
  980. document.getElementById("SQJSappMenu").style.display = "none";
  981. this.appmenuVisible=false;
  982. //document.getElementById(this.appmenuContentContId).style.opacity = "1.0";
  983. gfSQJZsetCSSById(this.appmenuContentContId, "opacity", "1.0");
  984. }
  985. /**
  986. * myappmenuCheckFlagIco
  987. *
  988. * Check to true the menu icon flag
  989. *
  990. * Context:
  991. * - this function is for internal use
  992. *
  993. * @returns {void}
  994. *
  995. * This function is part of SqueeJS.
  996. */
  997. function myappmenuCheckFlagIco() {
  998. this.appmenuOnIco = true;
  999. }
  1000. /**
  1001. * myappmenuUnCheckFlagIco
  1002. *
  1003. * Check to false the menu icon flag
  1004. *
  1005. * Context:
  1006. * - this function is for internal use
  1007. *
  1008. * @returns {void}
  1009. *
  1010. * This function is part of SqueeJS.
  1011. */
  1012. function myappmenuUnCheckFlagIco() {
  1013. this.appmenuOnIco = false;
  1014. }
  1015. /**
  1016. * myappmenuBodyOnClick
  1017. *
  1018. * Body click event function: if open, hide the menu
  1019. *
  1020. * Context:
  1021. * - this function is for internal use
  1022. *
  1023. * @returns {void}
  1024. *
  1025. * This function is part of SqueeJS.
  1026. */
  1027. function myappmenuBodyOnClick() {
  1028. if (!this.appmenuOnIco) {
  1029. this.appmenuHide();
  1030. }
  1031. }
  1032. /**
  1033. * mycreateAppMenu
  1034. *
  1035. * Create the tag DIV of menu icon and app menu
  1036. *
  1037. * Context:
  1038. * - Call it in the body of your webpage
  1039. *
  1040. * @param {string} icoURI, the URI of the menu icon
  1041. * @param {string} menuURL, the URL of the menu web page
  1042. * @param {string} contentContId, the container of the body content (the menu will disable it)
  1043. * @param {string} top, the y coord of the menu position
  1044. * @param {string} left, the x coord of the menu position
  1045. * @param {string} width, the width of the menu
  1046. * @param {string} height, the height of the menu
  1047. * @returns {void}
  1048. *
  1049. * This function is part of SqueeJS.
  1050. */
  1051. function mycreateAppMenu(icoURI, menuURL, contentContId, top, left, width, height) {
  1052. if (typeof jQuery === 'undefined') {
  1053. throw new Error('This SqueeJS\'s function requires jQuery');
  1054. }
  1055. var D = document;
  1056. //w = gfSQJZDocWidth();
  1057. //h = gfSQJZDocHeight();
  1058. this.appmenuContentContId = contentContId
  1059. menuico = "";
  1060. menuico = "<img src='"+icoURI+"' style='width:48px;height:48px;' alt='app menu'>";
  1061. newdiv=D.createElement("div");
  1062. newdiv.id = "SQJSappMenuIco";
  1063. newdiv.style.width = "48px";
  1064. newdiv.style.height = "48px";
  1065. newdiv.innerHTML = menuico;
  1066. //D.body.appendChild(newdiv);
  1067. D.write(newdiv.outerHTML);
  1068. //$("#SQJSappMenuIco").on("click",function(){SQJS.appmenuPopUp();});
  1069. //$("#SQJSappMenuIco").on("mouseover",function(){SQJS.appmenuCheckFlagIco();});
  1070. //$("#SQJSappMenuIco").on("mouseout",function(){SQJS.appmenuUnCheckFlagIco();});
  1071. document.getElementById("SQJSappMenuIco").addEventListener("click", function() {
  1072. SQJS.appmenuPopUp();
  1073. });
  1074. document.getElementById("SQJSappMenuIco").addEventListener("mouseover", function() {
  1075. SQJS.appmenuCheckFlagIco();
  1076. });
  1077. document.getElementById("SQJSappMenuIco").addEventListener("mouseout", function() {
  1078. SQJS.appmenuUnCheckFlagIco();
  1079. });
  1080. menu = "";
  1081. menu += "<!-- Here goes the content of the AppMenu -->";
  1082. newdiv=D.createElement("div");
  1083. newdiv.id = "SQJSappMenu";
  1084. newdiv.style.top = top+"px";
  1085. newdiv.style.left = left+"px";
  1086. newdiv.style.width = width+"px";
  1087. newdiv.style.height = height+"px";
  1088. newdiv.innerHTML = menu;
  1089. D.body.appendChild(newdiv);
  1090. //D.write(newdiv.outerHTML);
  1091. //$("#SQJSappMenu").on("mouseover",function(){SQJS.appmenuCheckFlagIco();});
  1092. //$("#SQJSappMenu").on("mouseout",function(){SQJS.appmenuUnCheckFlagIco();});
  1093. document.getElementById("SQJSappMenu").addEventListener("mouseover", function() {
  1094. SQJS.appmenuCheckFlagIco();
  1095. });
  1096. document.getElementById("SQJSappMenu").addEventListener("mouseout", function() {
  1097. SQJS.appmenuUnCheckFlagIco();
  1098. });
  1099. //$("#SQJSappMenu").load(menuURL+"?rrnd=" + gfSQJZrnd(50000, 99999));
  1100. gfSQJZLoad("SQJSappMenu", menuURL+"?rrnd=" + gfSQJZrnd(50000, 99999));
  1101. //$(document.body).on("click", function() {SQJS.appmenuBodyOnClick();});
  1102. document.body.addEventListener("click", function() {
  1103. SQJS.appmenuBodyOnClick();
  1104. });
  1105. }
  1106. // --- AppMenu
  1107. /**
  1108. *
  1109. * GeoLocation
  1110. */
  1111. /**
  1112. * myretrieveGeoLocation
  1113. *
  1114. * Retreive the geolocation (country name)
  1115. *
  1116. * Context:
  1117. * - this function is for internal use
  1118. *
  1119. * @returns {void}
  1120. *
  1121. * This function is part of SqueeJS.
  1122. */
  1123. function myretrieveGeoLocation() {
  1124. if (!this.geoLocation || this.geoLocation=="") {
  1125. try {
  1126. var xhttp = new XMLHttpRequest();
  1127. var xmluri = SQJS_GEOURL;
  1128. //alert(xmluri);
  1129. xhttp.open("GET", xmluri, false);
  1130. xhttp.send();
  1131. this.geoLocation = xhttp.responseText;
  1132. } catch(e) {
  1133. throw new Error("CORS error: check the resource availability and Access-Control-Allow-Origin of your site.");
  1134. }
  1135. }
  1136. }
  1137. /**
  1138. * myhideElByGeoLocation
  1139. *
  1140. * Hide the given web page Element for the specified geolocation
  1141. *
  1142. * Context:
  1143. * - Call it in the body of your webpage
  1144. *
  1145. * @param {string} id, the id of the element to hide
  1146. * @param {string} geoloc, the geolocation (country name) to hide the el for
  1147. * @returns {void}
  1148. *
  1149. * This function is part of SqueeJS.
  1150. */
  1151. function myhideElByGeoLocation(id, geoloc) {
  1152. this.retrieveGeoLocation();
  1153. //alert("debug#2"+this.geoLocation);
  1154. if (this.geoLocation) {
  1155. if (geoloc.toLowerCase() === this.geoLocation.toLowerCase()) {
  1156. //document.getElementById(id).style.display="none";
  1157. gfSQJZsetCSSById(id, "display", "none");
  1158. }
  1159. }
  1160. }
  1161. /**
  1162. * myshowElByGeoLocation
  1163. *
  1164. * Show the given web page Element for the specified geolocation
  1165. *
  1166. * Context:
  1167. * - Call it in the body of your webpage
  1168. *
  1169. * @param {string} id, the id of the element to show
  1170. * @param {string} geoloc, the geolocation (country name) to show the el for
  1171. * @returns {void}
  1172. *
  1173. * This function is part of SqueeJS.
  1174. */
  1175. function myshowElByGeoLocation(id, geoloc) {
  1176. this.retrieveGeoLocation();
  1177. //alert("debug#3"+this.geoLocation);
  1178. if (this.geoLocation) {
  1179. if (geoloc.toLowerCase() === this.geoLocation.toLowerCase()) {
  1180. //document.getElementById(id).style.display="inline";
  1181. gfSQJZsetCSSById(id, "display", "inline");
  1182. }
  1183. }
  1184. }
  1185. // --- GeoLocation
  1186. /**
  1187. *
  1188. * UserTranslation
  1189. */
  1190. /**
  1191. * myusertransPopUp
  1192. *
  1193. * Display/hide the user trans menu
  1194. *
  1195. * Context:
  1196. * - this function is for internal use
  1197. *
  1198. * @returns {void}
  1199. *
  1200. * This function is part of SqueeJS.
  1201. */
  1202. function myusertransPopUp() {
  1203. if (!this.usertransVisible) {
  1204. document.getElementById("SQJSuserTransMenu").style.display = "inline";
  1205. document.getElementById("SQJSuserTransMenu").style.zIndex = "99998";
  1206. document.getElementById(this.usertransContentContId).style.zIndex = "99997";
  1207. gfSQJZsetCSSById(this.usertransContentContId, "zIndex", "99997");
  1208. //document.getElementById(this.usertransContentContId ).style.opacity = "0.3";
  1209. gfSQJZsetCSSById(this.usertransContentContId, "opacity", "0.3");
  1210. } else {
  1211. document.getElementById("SQJSuserTransMenu").style.display = "none";
  1212. document.getElementById("SQJSuserTransMenu").style.zIndex = "99992";
  1213. //document.getElementById(this.usertransContentContId).style.zIndex = "99993";
  1214. gfSQJZsetCSSById(this.usertransContentContId, "zIndex", "99993");
  1215. //document.getElementById(this.usertransContentContId).style.opacity = "1.0";
  1216. gfSQJZsetCSSById(this.usertransContentContId, "opacity", "1.0");
  1217. }
  1218. this.usertransVisible=!this.usertransVisible;
  1219. }
  1220. /**
  1221. * myusertransHide
  1222. *
  1223. * Hide the client trans menu
  1224. *
  1225. * Context:
  1226. * - this function is for internal use
  1227. *
  1228. * @returns {void}
  1229. *
  1230. * This function is part of SqueeJS.
  1231. */
  1232. function myusertransHide() {
  1233. //document.getElementById("SQJSuserTransMenu").style.display = "none";
  1234. gfSQJZsetCSSById("SQJSuserTransMenu", "display", "none");
  1235. this.usertransVisible=false;
  1236. //document.getElementById(this.usertransContentContId).style.opacity = "1.0";
  1237. gfSQJZsetCSSById(this.usertransContentContId, "opacity", "1.0");
  1238. }
  1239. /**
  1240. * myusertransCheckFlagIco
  1241. *
  1242. * Check to true the menu icon flag
  1243. *
  1244. * Context:
  1245. * - this function is for internal use
  1246. *
  1247. * @returns {void}
  1248. *
  1249. * This function is part of SqueeJS.
  1250. */
  1251. function myusertransCheckFlagIco() {
  1252. this.usertransOnIco = true;
  1253. }
  1254. /**
  1255. * myusertransUnCheckFlagIco
  1256. *
  1257. * Check to false the menu icon flag
  1258. *
  1259. * Context:
  1260. * - this function is for internal use
  1261. *
  1262. * @returns {void}
  1263. *
  1264. * This function is part of SqueeJS.
  1265. */
  1266. function myusertransUnCheckFlagIco() {
  1267. this.usertransOnIco = false;
  1268. }
  1269. /**
  1270. * myusertransBodyOnClick
  1271. *
  1272. * Body click event function: if open, hide the menu
  1273. *
  1274. * Context:
  1275. * - this function is for internal use
  1276. *
  1277. * @returns {void}
  1278. *
  1279. * This function is part of SqueeJS.
  1280. */
  1281. function myusertransBodyOnClick() {
  1282. if (!this.usertransOnIco) {
  1283. this.usertransHide();
  1284. }
  1285. }
  1286. /**
  1287. * mygetTranslitarates
  1288. *
  1289. * Get the transliterates to use in the translation
  1290. *
  1291. * Context:
  1292. * - this function is for internal use
  1293. *
  1294. * @returns {void}
  1295. *
  1296. * This function is part of SqueeJS.
  1297. */
  1298. function mygetTranslitarates() {
  1299. v=document.getElementById("SQJSuserTransTB").value.trim();
  1300. if (v!=="") {
  1301. if (v.substr(0,4).toLowerCase() === "http") {
  1302. transURL = v;
  1303. try {
  1304. var xhttp = new XMLHttpRequest();
  1305. var xmluri = transURL;
  1306. //alert(xmluri);
  1307. xhttp.open("GET", xmluri, false);
  1308. xhttp.send();
  1309. xml = xhttp.responseText;
  1310. } catch(e) {
  1311. throw new Error("404 or CORS error: check the resource availability and Access-Control-Allow-Origin of your site.");
  1312. }
  1313. } else {
  1314. xml = v;
  1315. }
  1316. //cleaning
  1317. xml = xml.trim("\n");
  1318. xml = xml.trim();
  1319. xml = xml.trim("\n");
  1320. xml = xml.trim();
  1321. // parsing text
  1322. tl = xml.split("\n");
  1323. it=0;
  1324. for (t of tl) {
  1325. curt = t.split("|||");
  1326. if (curt[0] && curt[0]!=="") {
  1327. this.tranSource[it] = curt[0];
  1328. this.tranDest[it] = curt[1];
  1329. }
  1330. it++;
  1331. }
  1332. }
  1333. }
  1334. /**
  1335. * mytranslate
  1336. *
  1337. * Make the client translation of the current web page
  1338. *
  1339. * Context:
  1340. * - this function is for internal use
  1341. *
  1342. * @returns {void}
  1343. *
  1344. * This function is part of SqueeJS.
  1345. */
  1346. function mytranslate() {
  1347. this.getTranslitarates();
  1348. it=0;
  1349. for (ts of this.tranSource) {
  1350. nl = document.getElementsByTagName("H1");
  1351. for (n of nl) {
  1352. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1353. }
  1354. nl = document.getElementsByTagName("H2");
  1355. for (n of nl) {
  1356. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1357. }
  1358. nl = document.getElementsByTagName("H3");
  1359. for (n of nl) {
  1360. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1361. }
  1362. nl = document.getElementsByTagName("A");
  1363. for (n of nl) {
  1364. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1365. }
  1366. nl = document.getElementsByTagName("DIV");
  1367. for (n of nl) {
  1368. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1369. }
  1370. nl = document.getElementsByTagName("LABEL");
  1371. for (n of nl) {
  1372. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1373. }
  1374. nl = document.getElementsByTagName("SPAN");
  1375. for (n of nl) {
  1376. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1377. }
  1378. nl = document.getElementsByTagName("INPUT");
  1379. for (n of nl) {
  1380. n.value = n.value.replace(ts, this.tranDest[it]);
  1381. n.setAttribute("placeholder", n.getAttribute("placeholder").replace(ts, this.tranDest[it]));
  1382. }
  1383. nl = document.getElementsByTagName("TEXTAREA");
  1384. for (n of nl) {
  1385. if (n.id !== "SQJSuserTransTB") {
  1386. n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
  1387. }
  1388. }
  1389. it++;
  1390. }
  1391. }
  1392. /**
  1393. * mycreateUserTrans
  1394. *
  1395. * Create the tag DIV of user trans icon and user trans menu
  1396. *
  1397. * Context:
  1398. * - Call it in the body of your webpage
  1399. *
  1400. * @param {string} icoURI, the URI of the menu icon
  1401. * @param {string} contentContId, the container of the body content (the menu will disable it)
  1402. * @param {string} top, the y coord of the menu position
  1403. * @param {string} left, the x coord of the menu position
  1404. * @returns {void}
  1405. *
  1406. * This function is part of SqueeJS.
  1407. */
  1408. function mycreateUserTrans(icoURI, contentContId, top, left) {
  1409. //if (typeof jQuery === 'undefined') {
  1410. // throw new Error('This SqueeJS\'s function requires jQuery');
  1411. //}
  1412. var D = document;
  1413. //w = gfSQJZDocWidth();
  1414. //h = gfSQJZDocHeight();
  1415. this.usertransContentContId = contentContId;
  1416. menuico = "";
  1417. menuico = "<img src='"+icoURI+"' style='width:48px;height:48px;' alt='user translation'>";
  1418. newdiv=D.createElement("div");
  1419. newdiv.id = "SQJSuserTransIco";
  1420. newdiv.style.width = "48px";
  1421. newdiv.style.height = "48px";
  1422. newdiv.innerHTML = menuico;
  1423. //D.body.appendChild(newdiv);
  1424. D.write(newdiv.outerHTML);
  1425. //document.getElementById("SQJSuserTransIco").onclick = function(){SQJS.usertransPopUp();};
  1426. //document.getElementById("SQJSuserTransIco").onmouseover = function(){SQJS.usertransCheckFlagIco();};
  1427. //document.getElementById("SQJSuserTransIco").onmouseout = function(){SQJS.usertransUnCheckFlagIco();};
  1428. document.getElementById("SQJSuserTransIco").addEventListener("click", function() {
  1429. SQJS.usertransPopUp();
  1430. });
  1431. document.getElementById("SQJSuserTransIco").addEventListener("mouseover", function() {
  1432. SQJS.usertransCheckFlagIco();
  1433. });
  1434. document.getElementById("SQJSuserTransIco").addEventListener("mouseout", function() {
  1435. SQJS.usertransUnCheckFlagIco();
  1436. });
  1437. menu = "";
  1438. menu += "<span style='font-size:10px;'>text or link, use ||| to separate source from translation:</span>";
  1439. menu += "<textarea id='SQJSuserTransTB'></textarea><br>";
  1440. menu += "<button id='SQJSuserTransBUT' onclick='SQJS.translate();'><img src='//squeejs.com/res/trans.png' style='height:70px'></button><br>";
  1441. menu += "<br>";
  1442. newdiv=D.createElement("div");
  1443. newdiv.id = "SQJSuserTransMenu";
  1444. newdiv.style.top = top+"px";
  1445. newdiv.style.left = left+"px";
  1446. newdiv.style.width = "380px";
  1447. newdiv.style.height = "515px";
  1448. newdiv.innerHTML = menu;
  1449. D.body.appendChild(newdiv);
  1450. //D.write(newdiv.outerHTML);
  1451. //document.getElementById("SQJSuserTransMenu").onmouseover = function(){SQJS.usertransCheckFlagIco();};
  1452. //document.getElementById("SQJSuserTransMenu").onmouseout = function(){SQJS.usertransUnCheckFlagIco();};
  1453. document.getElementById("SQJSuserTransMenu").addEventListener("mouseover", function() {
  1454. SQJS.usertransCheckFlagIco();
  1455. });
  1456. document.getElementById("SQJSuserTransMenu").addEventListener("mouseout", function() {
  1457. SQJS.usertransUnCheckFlagIco();
  1458. });
  1459. //document.body.onclick = function(){SQJS.usertransBodyOnClick();};
  1460. document.body.addEventListener("click", function() {
  1461. SQJS.usertransBodyOnClick();
  1462. });
  1463. }
  1464. // --- UserTranslation
  1465. /**
  1466. *
  1467. * Sidebar
  1468. */
  1469. /**
  1470. * mysidebarCheckFlag
  1471. *
  1472. * Check to true the sideabr flag
  1473. *
  1474. * Context:
  1475. * - this function is for internal use
  1476. *
  1477. * @returns {void}
  1478. *
  1479. * This function is part of SqueeJS.
  1480. */
  1481. function mysidebarCheckFlag() {
  1482. this.sidebarOnIT = true;
  1483. }
  1484. /**
  1485. * mysidebarUnCheckFlag
  1486. *
  1487. * Check to false the sidebar flag
  1488. *
  1489. * Context:
  1490. * - this function is for internal use
  1491. *
  1492. * @returns {void}
  1493. *
  1494. * This function is part of SqueeJS.
  1495. */
  1496. function mysidebarUnCheckFlag() {
  1497. this.sidebarOnIT = false;
  1498. }
  1499. /**
  1500. * myusertransBodyOnClick
  1501. *
  1502. * Body click event function: if open, hide the menu
  1503. *
  1504. * Context:
  1505. * - this function is for internal use
  1506. *
  1507. * @returns {void}
  1508. *
  1509. * This function is part of SqueeJS.
  1510. */
  1511. function mysidebarBodyOnClick() {
  1512. if (!this.sidebarOnIT) {
  1513. this.sidebarClose();
  1514. }
  1515. }
  1516. /**
  1517. * mysidebarShow
  1518. *
  1519. * Show the sidebar
  1520. *
  1521. * Context:
  1522. * - this function is for internal use
  1523. *
  1524. * @returns {void}
  1525. *
  1526. * This function is part of SqueeJS.
  1527. */
  1528. function mysidebarShow() {
  1529. if (!this.sidebarVisible) {
  1530. //if (document.getElementById(this.sidebarContentContId)) {
  1531. // document.getElementById(this.sidebarContentContId).style.width = "100%";
  1532. //}
  1533. gfSQJZsetCSSById(this.sidebarContentContId, "width", "100%");
  1534. //$("#SQJSsidebar").show("slow");
  1535. document.getElementById("SQJSsidebar").style.display = "inline";
  1536. }
  1537. this.sidebarVisible = true;
  1538. }
  1539. /**
  1540. * mysidebarClose
  1541. *
  1542. * Close the sidebar
  1543. *
  1544. * Context:
  1545. * - this function is for internal use
  1546. *
  1547. * @returns {void}
  1548. *
  1549. * This function is part of SqueeJS.
  1550. */
  1551. function mysidebarClose() {
  1552. document.getElementById("SQJSsidebar").style.display = "none";
  1553. //if (document.getElementById(this.sidebarContentContId)) {
  1554. // document.getElementById(this.sidebarContentContId).style.width = "100%";
  1555. //}
  1556. gfSQJZsetCSSById(this.sidebarContentContId, "width", "100%");
  1557. this.sidebarVisible = false;
  1558. }
  1559. /**
  1560. * mycreateSidebar
  1561. *
  1562. * Create the tag DIV of sidebar
  1563. *
  1564. * Context:
  1565. * - Call it in the body of your webpage
  1566. *
  1567. * @param {string} sidebarURL, the URI of the of the sidebar
  1568. * @param {string} contentContId, the container of the body content
  1569. * @param {string} width, the width of the sidebar
  1570. * @param {string} height, the height of the sidebar
  1571. * @returns {void}
  1572. *
  1573. * This function is part of SqueeJS.
  1574. */
  1575. function mycreateSidebar(sidebarURL, contentContId, width, height) {
  1576. if (typeof jQuery === 'undefined') {
  1577. throw new Error('This SqueeJS\'s function requires jQuery');
  1578. }
  1579. var D = document;
  1580. //w = gfSQJZDocWidth();
  1581. //h = gfSQJZDocHeight();
  1582. this.sidebarContentContId = contentContId;
  1583. barcall = "";
  1584. barcall = "&nbsp;";
  1585. newdiv=D.createElement("div");
  1586. newdiv.id = "SQJSsidebarCall";
  1587. newdiv.innerHTML = barcall;
  1588. D.body.appendChild(newdiv);
  1589. //D.write(newdiv.outerHTML);
  1590. //document.getElementById("SQJSsidebarCall").onmouseover = function(){SQJS.sidebarShow();};
  1591. document.getElementById("SQJSsidebarCall").addEventListener("mouseover", function() {
  1592. SQJS.sidebarShow();
  1593. });
  1594. document.getElementById("SQJSsidebarCall").addEventListener("touchstart", function() {
  1595. SQJS.sidebarShow();
  1596. });
  1597. sidebar = "";
  1598. sidebar += "<div style='text-align:right;'>";
  1599. sidebar += "<button type='button' class='SQJSclose-button' style='position:relative; left:-10px' onclick='SQJS.sidebarClose();'>";
  1600. sidebar += "<span style='font-size:45px; font-weight:900;'>&times;</span>";
  1601. sidebar += "</button>";
  1602. sidebar += "</div>";
  1603. sidebar += "<div id='SQJSsidebarContent'>";
  1604. sidebar += "</div>";
  1605. newdiv=D.createElement("div");
  1606. newdiv.id = "SQJSsidebar";
  1607. newdiv.style.width = width + "px";
  1608. newdiv.style.height = height + "px";
  1609. newdiv.innerHTML = sidebar;
  1610. D.body.appendChild(newdiv);
  1611. //D.write(newdiv.outerHTML);
  1612. document.getElementById("SQJSsidebar").addEventListener("mouseover", function() {
  1613. SQJS.sidebarCheckFlag();
  1614. });
  1615. document.getElementById("SQJSsidebar").addEventListener("mouseout", function() {
  1616. SQJS.sidebarUnCheckFlag();
  1617. });
  1618. document.getElementById("SQJSsidebar").addEventListener("touchstart", function() {
  1619. SQJS.sidebarCheckFlag();
  1620. });
  1621. document.getElementById("SQJSsidebar").addEventListener("touchend", function() {
  1622. SQJS.sidebarUnCheckFlag();
  1623. });
  1624. //$("#SQJSsidebarContent").load(sidebarURL+"?rrnd="+ gfSQJZrnd(50000, 99999));
  1625. gfSQJZLoad("SQJSsidebarContent", sidebarURL+"?rrnd="+ gfSQJZrnd(50000, 99999))
  1626. document.body.addEventListener("click", function() {
  1627. SQJS.sidebarBodyOnClick();
  1628. });
  1629. }
  1630. // --- Sidebar
  1631. }
  1632. window.SQJS = window.SqueeJS = new SqueeJS();
  1633. window.addEventListener("load", function() {
  1634. nl = document.getElementsByTagName("DIV");
  1635. i=0;
  1636. for (n of nl) {
  1637. n.setAttribute("highlightIndex", i);
  1638. i++;
  1639. }
  1640. nl = document.getElementsByTagName("INPUT");
  1641. for (n of nl) {
  1642. n.setAttribute("highlightIndex", i);
  1643. i++;
  1644. }
  1645. nl = document.getElementsByTagName("TEXTAREA");
  1646. for (n of nl) {
  1647. n.setAttribute("highlightIndex", i);
  1648. i++;
  1649. }
  1650. },true);