123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830 |
- /**
- * Copyright (c) 2021, 2024, 5 Mode and other contributors
- * Released under the MIT license
- *
- * This file is part of Squeejs.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * squeejs.js
- *
- * Squeejs production release.
- *
- * @version 1.1.2
- * @author Daniele Bonini <my25mb@aol.com>
- * @copyrights (c) 2016, 2024, 5 Mode
- * @license https://opensource.org/licenses/MIT
- */
- function SqueeJS() {
- const SQJS_GEOURL = "https://ss.squeejs.5mode-lab.com/";
- // Highlight
- this.highlightOriTop=[];
- this.highlightOriLeft=[];
- this.highlightOriHeight=[];
- this.highlightOriWidth=[];
- this.highlightOriFontSize=[];
- this.highlightOriBorder=[];
- this.highlightOriPosition=[];
-
- this.highlightDiv = myhighlightDiv;
- this.unlightDiv = myunlightDiv;
- this.highlightInput = myhighlightInput;
- this.unlightInput = myunlightInput;
- this.highlightTextArea = myhighlightTextArea;
- this.unlightTextArea = myunlightTextArea;
- // Splash
- this.splashMainContainerId = "";
- this.splashMainContainerOriHeight = 0;
- this.splashTitle = "";
- this.splashLogoURI = "";
- this.splashBG = "";
- this.splashTimeout = 6000;
-
- this.createSplash = mycreateSplash;
- this.splashStartApp = mySplashStartApp;
- this.initAppWithSplash = myinitAppWithSplash;
- this.initAppWithoutSplash = myinitAppWithoutSplash;
-
- // Work In Progress
- this.wipMainContainerId = "";
- this.wipMainContainerOriHeight = 0;
- this.wipBG = "";
- this.wipStartApp = myWIPStartApp;
- this.initAppWithWIP = myinitAppWithWIP;
- this.initAppWithoutWIP = myinitAppWithoutWIP;
-
- //Banners
- this.bannerIndex = 0;
- this.bannerIMG = [];
- this.bannerURL = [];
-
- this.createBanner = mycreateBanner;
- this.closeBanner = mycloseBanner;
-
- //Footer
- this.footerHTML = "";
- this.footerBG = "";
-
- this.createFooter = mycreateFooter;
-
- //AppMenu
- this.appmenuContentContId = "";
- this.appmenuVisible = false;
- this.appmenuOnIco = false;
- this.appmenuPopUp = myappmenuPopUp;
- this.appmenuHide = myappmenuHide;
- this.appmenuCheckFlagIco = myappmenuCheckFlagIco;
- this.appmenuUnCheckFlagIco = myappmenuUnCheckFlagIco;
- this.appmenuBodyOnClick = myappmenuBodyOnClick;
- this.createAppMenu = mycreateAppMenu;
-
- //GeoLocation
- this.geoLocation = "";
-
- this.retrieveGeoLocation = myretrieveGeoLocation;
- this.hideElByGeoLocation = myhideElByGeoLocation;
- this.showElByGeoLocation = myshowElByGeoLocation;
-
- //UserTranslation
- this.usertransContentContId = "";
- this.usertransVisible = false;
- this.usertransOnIco = false;
- this.tranSource = [];
- this.tranDest = [];
-
- this.usertransPopUp=myusertransPopUp;
- this.usertransHide=myusertransHide;
- this.usertransCheckFlagIco=myusertransCheckFlagIco;
- this.usertransUnCheckFlagIco=myusertransUnCheckFlagIco;
- this.usertransBodyOnClick=myusertransBodyOnClick;
- this.getTranslitarates = mygetTranslitarates;
- this.translate = mytranslate;
- this.createUserTrans = mycreateUserTrans;
-
- //Sideabar
- this.sidebarContentContId = "";
- this.sidebarVisible = false;
- this.sidebarOnIT = false;
-
- this.sidebarClose = mysidebarClose;
- this.sidebarShow = mysidebarShow;
- this.sidebarCheckFlag=mysidebarCheckFlag;
- this.sidebarUnCheckFlag=mysidebarUnCheckFlag;
- this.sidebarBodyOnClick=mysidebarBodyOnClick;
- this.createSidebar = mycreateSidebar;
-
- /**
- * gfSQJZDocWidth
- *
- * Get the width of the whole document
- *
- * @returns {int} the document width
- *
- * This function is part of SqueeJS.
- */
- function gfSQJZDocWidth() {
- var D = document;
- var scrollMaxX;
- if (window.scrollMaxX) {
- scrollMaxX = window.scrollMaxX;
- } else {
- scrollMaxX = D.documentElement.scrollWidth;
- }
- return Math.max(
- D.body.scrollWidth, scrollMaxX,
- D.body.offsetWidth, D.documentElement.offsetWidth,
- D.body.clientWidth, D.documentElement.clientWidth
- );
- }
- /**
- * gfSQJZgetAttrById
- *
- * Get the value of the given element attribute
- *
- * @param {string} id, the id selector of the document element
- * @param {string} attributeName, the attribute to retrieve
- * @returns {string} the attribute value
- */
- function gfSQJZgetAttrById(id, attributeName) {
- if (document.getElementById(id)) {
- return document.getElementById(id).getAttribute(attributeName);
- } else {
- return "";
- }
- }
- /**
- * gfSQJZsetAttrById
- *
- * Set the value of the given element attribute
- *
- * @param {string} id, the id selector of the document element
- * @param {string} attributeName, the attribute to retrieve
- * @param {string} value, the new attribute value
- * @returns {string} the attribute value
- */
- function gfSQJZsetAttrById(id, attributeName, value) {
- if (document.getElementById(id)) {
- document.getElementById(id).setAttribute(attributeName, value);
- }
- }
- /**
- * gfSQJZgetCSSById
- *
- * Get the value for the given element style property
- *
- * @param {string} id, the id selector of the document element
- * @param {string} cssName, the css property to retrieve
- * @returns {string} the property value
- */
- function gfSQJZgetCSSById(id, cssName) {
- if (document.getElementById(id)) {
- return document.getElementById(id).style[cssName];
- } else {
- return "";
- }
- }
- /**
- * gfSQJZsetCSSById
- *
- * Set the value for the given element style property
- *
- * @param {string} id, the id selector of the document element
- * @param {string} cssName, the css property to retrieve
- * @returns {string} the property value
- */
- function gfSQJZsetCSSById(id, cssName, value) {
- if (document.getElementById(id)) {
- document.getElementById(id).style[cssName] = value;
- }
- }
- /**
- * gfSQJZDocHeight
- *
- * Get the height of the whole document
- *
- * @returns {int} the document height
- *
- * This function is part of SqueeJS.
- */
- function gfSQJZDocHeight() {
- var D = document;
- var scrollMaxY;
- if (window.scrollMaxY) {
- scrollMaxY = window.scrollMaxY;
- } else {
- scrollMaxY = D.documentElement.scrollHeight;
- }
- var height = Math.max(
- D.body.scrollHeight, scrollMaxY,
- D.body.offsetHeight, D.documentElement.offsetHeight,
- D.body.clientHeight, D.documentElement.clientHeight
- );
- return height;
- }
- /**
- * gfSQJZLoad
- *
- * Load the content of <url> in the given DIV element
- *
- * @param {string} id, the DIV id to fill
- * @param {string} url, the url of the content to load
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function gfSQJZLoad(id, url) {
- try {
- var xhttp = new XMLHttpRequest();
- var xmluri = url;
- //alert(xmluri);
- xhttp.open("GET", xmluri, false);
- xhttp.send();
- document.getElementById(id).innerHTML = xhttp.responseText;
- } catch(e) {
- throw new Error("404 or CORS error: check the resource availability and Access-Control-Allow-Origin of your site.");
- }
- }
- /**
- * gfSQJZrnd
- *
- * Generate a random number between the given limits
- *
- * @param {int} min, the starting limit
- * @param {int} max, the max limit
- * @returns {int} the generated random value
- *
- * This function is part of SqueeJS.
- */
- function gfSQJZrnd(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min +1)) + min;
- }
- /**
- *
- * Highlight
- *
- */
- /**
- * highlightDiv
- *
- * Highlight the current DIV element
- *
- * Context:
- * - call this function in the onmouseenter event
- *
- * @param {Element} tthis, the current DIV element (this on the function call)
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myhighlightDiv(tthis) {
- if (tthis.tagName !== "DIV") {
- return;
- }
- // --- saving original data
- myR = tthis.getBoundingClientRect();
- highlightIndex = tthis.getAttribute("highlightIndex");
- this.highlightOriTop[highlightIndex] = parseInt(myR.top);
- this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
- this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
- this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
- this.highlightOriBorder[highlightIndex] = tthis.style.border;
- this.highlightOriPosition[highlightIndex] = tthis.style.position;
- // ---
- tthis.style.position = "absolute";
- tthis.style.height = "480px";
- tthis.style.width = "650px";
- tthis.style.border = "3px dashed darkcyan";
- tthis.style.fontSize = "25px";
- //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
- }
- /**
- * unlightDiv
- *
- * Unlight the current DIV element
- *
- * Context:
- * - call this function in the onmouseleave event
- *
- * @param {Element} tthis, the current DIV element (this on the function call)
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myunlightDiv(tthis) {
- if (tthis.tagName !== "DIV") {
- return;
- }
- // --- restoring original data
- highlightIndex = tthis.getAttribute("highlightIndex");
- if (this.highlightOriTop[highlightIndex]===null) {
- return;
- }
- tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
- tthis.style.border = this.highlightOriBorder[highlightIndex];
- tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
- tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
- tthis.style.position = this.highlightOriPosition[highlightIndex];
- // ---
- //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
- }
- /**
- * highlightInput
- *
- * Highlight the current INPUT element
- *
- * Context:
- * - call this function in the onmouseenter event
- *
- * @param {Element} tthis, the current INPUT element (this on the function call)
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myhighlightInput(tthis) {
- if (tthis.tagName !== "INPUT") {
- return;
- }
- // --- saving original data
- myR = tthis.getBoundingClientRect();
- highlightIndex = tthis.getAttribute("highlightIndex");
- this.highlightOriTop[highlightIndex] = parseInt(myR.top);
- this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
- this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
- this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
- this.highlightOriBorder[highlightIndex] = tthis.style.border;
- this.highlightOriPosition[highlightIndex] = tthis.style.position;
- // ---
- tthis.style.position = "absolute";
- tthis.style.height = "40px";
- tthis.style.width = "400px";
- tthis.style.border = "3px solid lightblue";
- tthis.style.fontSize = "25px";
- //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
- }
- /**
- * unlightInput
- *
- * Unlight the current INPUT element
- *
- * Context:
- * - call this function in the onmouseleave event
- *
- * @param {Element} tthis, the current INPUT element (this on the function call)
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myunlightInput(tthis) {
- if (tthis.tagName !== "INPUT") {
- return;
- }
- // --- restoring original data
- highlightIndex = tthis.getAttribute("highlightIndex");
- if (this.highlightOriTop[highlightIndex]===null) {
- return;
- }
- tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
- tthis.style.border = this.highlightOriBorder[highlightIndex];
- tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
- tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
- tthis.style.position = this.highlightOriPosition[highlightIndex];
- // ---
- //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
- }
- /**
- * highlightTextArea
- *
- * Highlight the current TEXTAREA element
- *
- * Context:
- * - call this function in the onmouseenter event
- *
- * @param {Element} tthis, the current TEXTAREA element (this on the function call)
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myhighlightTextArea(tthis) {
- if (tthis.tagName !== "TEXTAREA") {
- return;
- }
- // --- saving original data
- myR = tthis.getBoundingClientRect();
- highlightIndex = tthis.getAttribute("highlightIndex");
- this.highlightOriTop[highlightIndex] = parseInt(myR.top);
- this.highlightOriHeight[highlightIndex] = parseInt(myR.height);
- this.highlightOriWidth[highlightIndex] = parseInt(myR.width);
- this.highlightOriFontSize[highlightIndex] = tthis.style.fontSize;
- this.highlightOriBorder[highlightIndex] = tthis.style.border;
- this.highlightOriPosition[highlightIndex] = tthis.style.position;
- // ---
- tthis.style.position = "absolute";
- tthis.style.height = "240px";
- tthis.style.width = "400px";
- tthis.style.border = "3px solid lightblue";
- tthis.style.fontSize = "25px";
- //document.getElementById("debug1").value=tthis.id+"-100px-"+tthis.tabIndex+" Enter";
- }
- /**
- * unlightTextArea
- *
- * Unlight the current TEXTAREA element
- *
- * Context:
- * - call this function in the onmouseleave event
- *
- * @param {Element} tthis, the current TEXTAREA element (this on the function call)
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myunlightTextArea(tthis) {
- if (tthis.tagName !== "TEXTAREA") {
- return;
- }
- // --- restoring original data
- highlightIndex = tthis.getAttribute("highlightIndex");
- if (this.highlightOriTop[highlightIndex]===null) {
- return;
- }
- tthis.style.fontSize = this.highlightOriFontSize[highlightIndex];
- tthis.style.border = this.highlightOriBorder[highlightIndex];
- tthis.style.width = (this.highlightOriWidth[highlightIndex]-6)+"px";
- tthis.style.height = (this.highlightOriHeight[highlightIndex]-6)+"px";
- tthis.style.position = this.highlightOriPosition[highlightIndex];
- // ---
- //document.getElementById("debug1").value=tthis.id+"-30-"+tthis.tabIndex+"Leave";
- }
- // --- End Highlight
- /**
- *
- * Splash Screen
- */
- /**
- * createSplash
- *
- * Create the tag DIV for the splash screen
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mycreateSplash() {
- var D = document;
- w = gfSQJZDocWidth();
- splashLeft = parseInt((w - 265) / 2);
- h = gfSQJZDocHeight();
- title = this.splashTitle;
- logoURI = this.splashLogoURI;
- BG = this.splashBG;
- //alert(this.splashTitle);
- //alert(this.splashLogoURI);
- //alert(this.splashBG);
- splash = "";
- splash += "<br><br><br><br>";
- splash += "<div style='width:267px;margin:auto;text-align:center;'>"+title+"</div><br>";
- splash += "<div style='width:267px;margin:auto;'><img src='"+logoURI+"' style='width:265px;'></div>";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSsplash";
- newdiv.style.background = BG;
- newdiv.style.width = w;
- newdiv.style.height = h;
- newdiv.style.textAlign = 'left';
- newdiv.style.fontFamily = 'Arial,Sans,Verdana';
- newdiv.style.fontSize = '35px';
- newdiv.style.fontWeight = '900';
- newdiv.style.paddingLeft = splashLeft+"px";
- newdiv.innerHTML = splash;
- D.body.appendChild(newdiv);
- }
- /**
- * SPALSHstartApp
- *
- * Start the web app just after the Splash
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mySplashStartApp() {
- //alert("hello");
- //Splash
- //if (document.getElementById("SQJSsplash")) {
- // document.getElementById("SQJSsplash").style.display = "none";
- //}
- gfSQJZsetCSSById("SQJSsplash", "display", "none");
- //Main Container
- //document.getElementById(this.splashMainContainerId).style.height = this.splashMainContainerOriHeight;
- gfSQJZsetCSSById(this.splashMainContainerId, "height", this.splashMainContainerOriHeight);
- //document.getElementById(this.splashMainContainerId).style.display = "inline";
- gfSQJZsetCSSById(this.splashMainContainerId, "display", "inline");
- window.scrollTo(0,0);
- }
- /**
- * _SPLASHstartApp
- *
- * Set the timeout to start the web app just after the Splash
- *
- * Context:
- * - this function is for internal use
- *
- * @param {int} time, the interval of time to wait before to start the webapp
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- //function _SPLASHstartApp(time) {
- // Fisnished the Intro with the Splash we load the app..
- // setTimeout("SPLASHstartApp()", time);
- //}
- /**
- * _initAppWithSplash
- *
- * Init the web app to start with the Splash
- *
- * Context:
- * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
- *
- * @param {string} mainContainerId, the container ID for the webpage content
- * @param {string} title, the title of the splash screen
- * @param {string} logoURI, the logo to display in the splash screen
- * @param {string} BG, the background for the splash screen
- * @param {int} timeout, the splash screen timeout
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myinitAppWithSplash(mainContainerId, title, logoURI, BG, timeout) {
- this.splashMainContainerId = mainContainerId;
- this.splashTitle = title;
- this.splashLogoURI = logoURI;
- this.splashBG = BG;
- if (timeout!==null) {
- this.splashTimeout = timeout;
- }
- //Main Container
- //document.getElementById(this.splashMainContainerId).style.display = "none";
- gfSQJZsetCSSById(this.splashMainContainerId, "display", "none");
-
- //Splash
- this.createSplash();
- document.getElementById("SQJSsplash").style.display = "inline";
- //window.scrollTo(1,1);
- document.body.style.height = parseInt(window.innerHeight) + "px";
- //this.splashMainContainerOriHeight = document.getElementById(this.splashMainContainerId).style.height;
- this.splashMainContainerOriHeight = gfSQJZgetCSSById(this.splashMainContainerId, "height");
- //document.getElementById(this.splashMainContainerId).style.height = parseInt(window.innerHeight) + "px";
- gfSQJZsetCSSById(this.splashMainContainerId, "height", parseInt(window.innerHeight) + "px");
-
- setTimeout("SQJS.splashStartApp()", this.splashTimeout);
- }
- /**
- * _initAppWithoutSplash
- *
- * Init the web app to start withOUT the Splash
- *
- * Context:
- * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
- *
- * @param {string} mainContainerId, the container ID for the webpage content
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myinitAppWithoutSplash(mainContainerId) {
- this.splashMainContainerId = mainContainerId;
- //Main Container
- //document.getElementById(this.splashMainContainerId).style.display = "inline";
- gfSQJZsetCSSById(this.splashMainContainerId, "display", "inline");
- //Splash
- //document.getElementById("SQJSsplash").style.display = "none";
- setTimeout("SQJS.splashStartApp()", 1);
- }
- // --- End Splash Screen
- /**
- *
- * Work in Progress
- */
- /**
- * createWIP
- *
- * Create the tag DIV for the Work In Progress Banner
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function _createWIP() {
- var D = document;
- w = gfSQJZDocWidth();
- wipLeft = parseInt((w - 450) / 2);
- h = gfSQJZDocHeight();
- bannerURI = "//squeejs.com/res/work-in-progress.png";
- BG = this.wipBG;
- wip = "";
- wip += "<br><br><br><br><br><br><br>";
- wip += "<div style='width:450px;margin:auto;'><img src='"+bannerURI+"' style='width:450px;'></div>";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSWIP";
- newdiv.style.background = BG;
- newdiv.style.width = w;
- newdiv.style.height = h;
- newdiv.style.textAlign = 'left';
- newdiv.style.fontFamily = 'Arial,Sans,Verdana';
- newdiv.style.fontSize = '35px';
- newdiv.style.fontWeight = '900';
- newdiv.style.paddingLeft = wipLeft+"px";
- newdiv.innerHTML = wip;
- D.body.appendChild(newdiv);
- }
- /**
- * WIPstartApp
- *
- * Start the web app just after the WIP banner
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myWIPStartApp() {
- //Splash
- //if (document.getElementById("SQJSWIP")) {
- // document.getElementById("SQJSWIP").style.display = "none";
- //}
- gfSQJZsetCSSById("SQJSWIP", "display", "none");
- //Main Container
- //document.getElementById(this.wipMainContainerId).style.height = this.wipMainContainerOriHeight;
- gfSQJZsetCSSById(this.wipMainContainerId, "height", this.wipMainContainerOriHeight);
- //document.getElementById(this.wipMainContainerId).style.display = "inline";
- gfSQJZsetCSSById(this.wipMainContainerId, "display", "inline");
-
- window.scrollTo(0,0);
- }
- /**
- * _WIPstartApp
- *
- * Set the timeout to start the web app just after the Splash
- *
- * Context:
- * - this function is for internal use
- *
- * @param {int} time, the interval of time to wait before to start the webapp
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- //function _WIPstartApp(time) {
- // Fisnished the Intro with the Splash we load the app..
- // setTimeout("WIPstartApp()", time);
- //}
- /**
- * _initAppWithWIP
- *
- * Init the web app to start with the work in progress banner
- *
- * Context:
- * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
- *
- * @param {string} mainContainerId, the container ID for the webpage content
- * @param {string} BG, the background for the wip banner
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myinitAppWithWIP(mainContainerId, BG) {
- this.wipMainContainerId = mainContainerId;
- this.wipBG = BG;
- //Main Container
- //document.getElementById(this.wipMainContainerId).style.display = "none";
- gfSQJZsetCSSById(this.wipMainContainerId, "display", "none");
- //Banner
- _createWIP();
- document.getElementById("SQJSWIP").style.display = "inline";
- //window.scrollTo(1,1);
- document.body.style.height = parseInt(window.innerHeight) + "px";
- //this.wipMainContainerOriHeight = document.getElementById(this.wipMainContainerId).style.height;
- this.wipMainContainerOriHeight = gfSQJZgetCSSById(this.wipMainContainerId, "height");
- //document.getElementById(this.wipMainContainerId).style.height = parseInt(window.innerHeight) + "px";
- gfSQJZsetCSSById(this.wipMainContainerId, "height", parseInt(window.innerHeight) + "px");
- }
- /**
- * _initAppWithoutWIP
- *
- * Init the web app to start withOUT the WIP banner
- *
- * Context:
- * - Call this function in the load event (ie. by a window.AddEventListener) of the webpage
- *
- * @param {string} mainContainerId, the container ID for the webpage content
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myinitAppWithoutWIP(mainContainerId) {
- this.wipMainContainerId = mainContainerId;
- //Main Container
- //document.getElementById(this.wipMainContainerId).style.display = "inline";
- gfSQJZsetCSSById(this.wipMainContainerId, "display", "inline");
-
- //Splash
- //document.getElementById("SQJSWIP").style.display = "none";
- setTimeout("SQJS.wipStartApp()", 1);
- }
- // --- Work in Progress
- /**
- *
- * Banner
- */
- /**
- * createBanner
- *
- * Create a new Banner
- *
- * Context:
- * - Call in the body of your webpage
- *
- * @param {string} img, the banner img (471px width)
- * @param {string} url, the banner target url
- * @param {string} align, the banner horizontal alignment [left|middle|right]
- * @param {string} display, the banner display [fixed|absolute|relative|none]
- * @param {int} minScreenWidth, min screen width to display the banner
- * @returns {string} the id of the resulting banner
- *
- * This function is part of SqueeJS.
- */
- function mycreateBanner(img, url, align, display, minScreenWidth) {
- this.bannerIndex++;
- this.bannerIMG[this.bannerIndex] = img;
- this.bannerURL[this.bannerIndex] = url;
- var D = document;
- w = gfSQJZDocWidth();
- switch (align) {
- case "middle":
- bannerLeft = parseInt((w - 473) / 2);
- break;
- case "left":
- bannerLeft = 0;
- break;
- case "right":
- bannerLeft = parseInt(w - 473);
- break;
- default:
- bannerLeft = parseInt((w - 473) / 2);
- break;
- }
- bbannerIMG = this.bannerIMG[this.bannerIndex];
- bbannerURL = this.bannerURL[this.bannerIndex];
- banner = "";
- banner += "<button type='button' class='SQJSclose-button' onclick='SQJS.closeBanner(this);'>";
- banner += "<span style='font-weight:900;'>×</span>";
- banner += "</button>";
- banner += "<a href='"+bbannerURL+"' target='_blank'><img src='"+bbannerIMG+"' style='width:471px;'></a>";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSBANNER" + this.bannerIndex;
- //newdiv.style.width = w;
- //newdiv.style.height = h;
- newdiv.style.textAlign = 'left';
- //newdiv.style.fontFamily = 'Arial,Sans,Verdana';
- //newdiv.style.fontSize = '35px';
- //newdiv.style.fontWeight = '900';
- newdiv.style.marginLeft = bannerLeft+"px";
- bannerDisplay = true;
- switch (display) {
- case "fixed":
- newdiv.className = "SQJSbanner-fixed";
- newdiv.style.top = (((35 +62) * (this.bannerIndex-1))) + "px";
- break;
- case "absolute":
- newdiv.className = "SQJSbanner-absolute";
- newdiv.style.top = (((35 +62) * (this.bannerIndex-1))) + "px";
- break;
- case "relative":
- newdiv.className = "SQJSbanner-relative";
- break;
- case "none":
- bannerDisplay = false;
- break;
- }
- if (window.innerWidth < minScreenWidth) {
- bannerDisplay = false;
- }
- if (!bannerDisplay) {
- newdiv.style.display = "none";
- }
- newdiv.innerHTML = banner;
- //D.body.appendChild(newdiv);
- D.write(newdiv.outerHTML);
- return "SQJSBANNER"+this.bannerIndex;
- }
- function mycloseBanner(tthis) {
- tthis.parentNode.style.display = "none";
- }
- // --- Banner
- /**
- *
- * Footer
- */
-
- /**
- * createFooter
- *
- * Create the tag DIV for the footer
- *
- * Context:
- * - Call it in the body of your webpage
- *
- * @param {string} html, the html to insert as footer
- * @param {string} BG, the background of the footer
- * @param {string} align, the banner horizontal alignment [left|middle|right]
- * @param {string} display, the banner display [fixed|relative|none]
- * @returns {string} the id of the footer DIV element
- *
- * This function is part of SqueeJS.
- */
- function mycreateFooter(html, BG, align, display) {
- htollerance = 12;
- htollerance = 12;
- footerContHeight = 35;
- footerHeight = 32;
- footerFloat = "";
-
- this.footerHTML = html;
- this.BG = BG;
-
- var D = document;
- w = gfSQJZDocWidth();
- h = window.innerHeight;
- footerDisplay = true;
- footerContClassName = "";
- footerClassName = "";
- switch (display) {
- case "fixed":
- footerContClassName = "SQJSfooterCont";
- footerClassName = "SQJSfooter";
- break;
- case "relative":
- footerContClassName = "SQJSfooterCont";
- footerClassName = "SQJSfooter";
- break;
- case "none":
- footerContClassName = "SQJSfooterCont";
- footerClassName = "SQJSfooter";
- footerDisplay = false;
- break;
- default:
- display="relative";
- footerContClassName = "SQJSfooterCont";
- footerClassName = "SQJSfooter";
- break;
- }
- footer = "";
- footer += "<div class='"+footerContClassName+"'> </div>";
- footer += "<div class='"+footerClassName+"'>"+html+"</div> ";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSfooter";
- newdiv.className = "footer";
- //newdiv.style.textAlign = 'left';
- newdiv.innerHTML = footer;
- D.body.appendChild(newdiv);
-
- document.getElementsByClassName(footerClassName)[0].style.background = BG;
-
- switch (align) {
- case "middle":
- footerLeft = parseInt((w - document.getElementsByClassName(footerClassName)[0].getBoundingClientRect().width) / 2);
- break;
- case "left":
- footerLeft = 0;
- footerFloat = "left";
- break;
- case "right":
- footerLeft = parseInt(w - document.getElementsByClassName(footerClassName)[0].getBoundingClientRect().width);
- footerFloat = "right";
- break;
- default:
- align="left";
- footerLeft = 0;
- footerFloat = "left";
- break;
- }
- document.getElementsByClassName(footerClassName)[0].style.float = footerFloat;
- if (display === "relative") {
- //document.getElementsByClassName(footerClassName)[0].style.top = "-" + footerContHeight + "px";
- } else if (display === "fixed") {
- document.getElementsByClassName("footer")[0].style.marginLeft = (footerLeft-wtollerance)+"px";
- document.getElementsByClassName("footer")[0].style.position = "fixed";
- document.getElementsByClassName("footer")[0].style.top = ""+parseInt(h - footerContHeight - htollerance) + "px";
- if (align === "right") {
- //document.getElementsByClassName("footer")[0].style.textAlign = "right";
- } else if (align === "middle") {
- //document.getElementsByClassName(footerClassName)[0].style.width = "800px";
- document.getElementsByClassName("footer")[0].style.textAlign = "center";
- }
- } else {
- newdiv.style.display = "none";
- }
- return newdiv.id;
- }
- // --- Footer
- /**
- *
- * AppMenu
- */
-
- /**
- * myappmenuPopUp
- *
- * Display/hide the appmenu
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myappmenuPopUp() {
- if (!this.appmenuVisible) {
- document.getElementById("SQJSappMenu").style.display = "inline";
- document.getElementById("SQJSappMenu").style.zIndex = "99998";
- //document.getElementById(this.appmenuContentContId).style.zIndex = "99997";
- gfSQJZsetCSSById(this.appmenuContentContId, "zIndex", "99997");
- //document.getElementById(this.appmenuContentContId ).style.opacity = "0.3";
- gfSQJZsetCSSById(this.appmenuContentContId, "opacity", "0.3");
- } else {
- document.getElementById("SQJSappMenu").style.display = "none";
- document.getElementById("SQJSappMenu").style.zIndex = "99992";
- //document.getElementById(this.appmenuContentContId).style.zIndex = "99993";
- gfSQJZsetCSSById(this.appmenuContentContId, "zIndex", "99993");
- //document.getElementById(this.appmenuContentContId).style.opacity = "1.0";
- gfSQJZsetCSSById(this.appmenuContentContId, "opacity", "1.0");
- }
- this.appmenuVisible=!this.appmenuVisible;
- }
-
- /**
- * myappmenuHide
- *
- * Hide the appmenu
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myappmenuHide() {
- document.getElementById("SQJSappMenu").style.display = "none";
- this.appmenuVisible=false;
- //document.getElementById(this.appmenuContentContId).style.opacity = "1.0";
- gfSQJZsetCSSById(this.appmenuContentContId, "opacity", "1.0");
- }
- /**
- * myappmenuCheckFlagIco
- *
- * Check to true the menu icon flag
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myappmenuCheckFlagIco() {
- this.appmenuOnIco = true;
- }
- /**
- * myappmenuUnCheckFlagIco
- *
- * Check to false the menu icon flag
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myappmenuUnCheckFlagIco() {
- this.appmenuOnIco = false;
- }
-
- /**
- * myappmenuBodyOnClick
- *
- * Body click event function: if open, hide the menu
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myappmenuBodyOnClick() {
- if (!this.appmenuOnIco) {
- this.appmenuHide();
- }
- }
-
- /**
- * mycreateAppMenu
- *
- * Create the tag DIV of menu icon and app menu
- *
- * Context:
- * - Call it in the body of your webpage
- *
- * @param {string} icoURI, the URI of the menu icon
- * @param {string} menuURL, the URL of the menu web page
- * @param {string} contentContId, the container of the body content (the menu will disable it)
- * @param {string} top, the y coord of the menu position
- * @param {string} left, the x coord of the menu position
- * @param {string} width, the width of the menu
- * @param {string} height, the height of the menu
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mycreateAppMenu(icoURI, menuURL, contentContId, top, left, width, height) {
-
- if (typeof jQuery === 'undefined') {
- throw new Error('This SqueeJS\'s function requires jQuery');
- }
-
- var D = document;
- //w = gfSQJZDocWidth();
- //h = gfSQJZDocHeight();
- this.appmenuContentContId = contentContId
- menuico = "";
- menuico = "<img src='"+icoURI+"' style='width:48px;height:48px;' alt='app menu'>";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSappMenuIco";
- newdiv.style.width = "48px";
- newdiv.style.height = "48px";
- newdiv.innerHTML = menuico;
- //D.body.appendChild(newdiv);
- D.write(newdiv.outerHTML);
- //$("#SQJSappMenuIco").on("click",function(){SQJS.appmenuPopUp();});
- //$("#SQJSappMenuIco").on("mouseover",function(){SQJS.appmenuCheckFlagIco();});
- //$("#SQJSappMenuIco").on("mouseout",function(){SQJS.appmenuUnCheckFlagIco();});
- document.getElementById("SQJSappMenuIco").addEventListener("click", function() {
- SQJS.appmenuPopUp();
- });
- document.getElementById("SQJSappMenuIco").addEventListener("mouseover", function() {
- SQJS.appmenuCheckFlagIco();
- });
- document.getElementById("SQJSappMenuIco").addEventListener("mouseout", function() {
- SQJS.appmenuUnCheckFlagIco();
- });
-
- menu = "";
- menu += "<!-- Here goes the content of the AppMenu -->";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSappMenu";
- newdiv.style.top = top+"px";
- newdiv.style.left = left+"px";
- newdiv.style.width = width+"px";
- newdiv.style.height = height+"px";
- newdiv.innerHTML = menu;
- D.body.appendChild(newdiv);
- //D.write(newdiv.outerHTML);
- //$("#SQJSappMenu").on("mouseover",function(){SQJS.appmenuCheckFlagIco();});
- //$("#SQJSappMenu").on("mouseout",function(){SQJS.appmenuUnCheckFlagIco();});
- document.getElementById("SQJSappMenu").addEventListener("mouseover", function() {
- SQJS.appmenuCheckFlagIco();
- });
- document.getElementById("SQJSappMenu").addEventListener("mouseout", function() {
- SQJS.appmenuUnCheckFlagIco();
- });
- //$("#SQJSappMenu").load(menuURL+"?rrnd=" + gfSQJZrnd(50000, 99999));
-
- gfSQJZLoad("SQJSappMenu", menuURL+"?rrnd=" + gfSQJZrnd(50000, 99999));
-
- //$(document.body).on("click", function() {SQJS.appmenuBodyOnClick();});
-
- document.body.addEventListener("click", function() {
- SQJS.appmenuBodyOnClick();
- });
- }
- // --- AppMenu
-
- /**
- *
- * GeoLocation
- */
-
- /**
- * myretrieveGeoLocation
- *
- * Retreive the geolocation (country name)
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myretrieveGeoLocation() {
- if (!this.geoLocation || this.geoLocation=="") {
- try {
- var xhttp = new XMLHttpRequest();
- var xmluri = SQJS_GEOURL;
- //alert(xmluri);
- xhttp.open("GET", xmluri, false);
- xhttp.send();
- this.geoLocation = xhttp.responseText;
- } catch(e) {
- throw new Error("CORS error: check the resource availability and Access-Control-Allow-Origin of your site.");
- }
- }
- }
-
- /**
- * myhideElByGeoLocation
- *
- * Hide the given web page Element for the specified geolocation
- *
- * Context:
- * - Call it in the body of your webpage
- *
- * @param {string} id, the id of the element to hide
- * @param {string} geoloc, the geolocation (country name) to hide the el for
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myhideElByGeoLocation(id, geoloc) {
- this.retrieveGeoLocation();
- //alert("debug#2"+this.geoLocation);
- if (this.geoLocation) {
- if (geoloc.toLowerCase() === this.geoLocation.toLowerCase()) {
- //document.getElementById(id).style.display="none";
- gfSQJZsetCSSById(id, "display", "none");
- }
- }
- }
-
- /**
- * myshowElByGeoLocation
- *
- * Show the given web page Element for the specified geolocation
- *
- * Context:
- * - Call it in the body of your webpage
- *
- * @param {string} id, the id of the element to show
- * @param {string} geoloc, the geolocation (country name) to show the el for
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myshowElByGeoLocation(id, geoloc) {
- this.retrieveGeoLocation();
- //alert("debug#3"+this.geoLocation);
- if (this.geoLocation) {
- if (geoloc.toLowerCase() === this.geoLocation.toLowerCase()) {
- //document.getElementById(id).style.display="inline";
- gfSQJZsetCSSById(id, "display", "inline");
- }
- }
- }
- // --- GeoLocation
-
- /**
- *
- * UserTranslation
- */
-
- /**
- * myusertransPopUp
- *
- * Display/hide the user trans menu
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myusertransPopUp() {
- if (!this.usertransVisible) {
- document.getElementById("SQJSuserTransMenu").style.display = "inline";
- document.getElementById("SQJSuserTransMenu").style.zIndex = "99998";
- document.getElementById(this.usertransContentContId).style.zIndex = "99997";
- gfSQJZsetCSSById(this.usertransContentContId, "zIndex", "99997");
- //document.getElementById(this.usertransContentContId ).style.opacity = "0.3";
- gfSQJZsetCSSById(this.usertransContentContId, "opacity", "0.3");
- } else {
- document.getElementById("SQJSuserTransMenu").style.display = "none";
- document.getElementById("SQJSuserTransMenu").style.zIndex = "99992";
- //document.getElementById(this.usertransContentContId).style.zIndex = "99993";
- gfSQJZsetCSSById(this.usertransContentContId, "zIndex", "99993");
- //document.getElementById(this.usertransContentContId).style.opacity = "1.0";
- gfSQJZsetCSSById(this.usertransContentContId, "opacity", "1.0");
- }
- this.usertransVisible=!this.usertransVisible;
- }
-
- /**
- * myusertransHide
- *
- * Hide the client trans menu
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myusertransHide() {
- //document.getElementById("SQJSuserTransMenu").style.display = "none";
- gfSQJZsetCSSById("SQJSuserTransMenu", "display", "none");
- this.usertransVisible=false;
- //document.getElementById(this.usertransContentContId).style.opacity = "1.0";
- gfSQJZsetCSSById(this.usertransContentContId, "opacity", "1.0");
- }
- /**
- * myusertransCheckFlagIco
- *
- * Check to true the menu icon flag
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myusertransCheckFlagIco() {
- this.usertransOnIco = true;
- }
- /**
- * myusertransUnCheckFlagIco
- *
- * Check to false the menu icon flag
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myusertransUnCheckFlagIco() {
- this.usertransOnIco = false;
- }
-
- /**
- * myusertransBodyOnClick
- *
- * Body click event function: if open, hide the menu
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function myusertransBodyOnClick() {
- if (!this.usertransOnIco) {
- this.usertransHide();
- }
- }
-
- /**
- * mygetTranslitarates
- *
- * Get the transliterates to use in the translation
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mygetTranslitarates() {
- v=document.getElementById("SQJSuserTransTB").value.trim();
- if (v!=="") {
- if (v.substr(0,4).toLowerCase() === "http") {
- transURL = v;
- try {
- var xhttp = new XMLHttpRequest();
- var xmluri = transURL;
- //alert(xmluri);
- xhttp.open("GET", xmluri, false);
- xhttp.send();
- xml = xhttp.responseText;
- } catch(e) {
- throw new Error("404 or CORS error: check the resource availability and Access-Control-Allow-Origin of your site.");
- }
- } else {
- xml = v;
- }
- //cleaning
- xml = xml.trim("\n");
- xml = xml.trim();
- xml = xml.trim("\n");
- xml = xml.trim();
- // parsing text
- tl = xml.split("\n");
- it=0;
- for (t of tl) {
- curt = t.split("|||");
- if (curt[0] && curt[0]!=="") {
- this.tranSource[it] = curt[0];
- this.tranDest[it] = curt[1];
- }
- it++;
- }
- }
- }
-
- /**
- * mytranslate
- *
- * Make the client translation of the current web page
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mytranslate() {
- this.getTranslitarates();
- it=0;
- for (ts of this.tranSource) {
- nl = document.getElementsByTagName("H1");
- for (n of nl) {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- nl = document.getElementsByTagName("H2");
- for (n of nl) {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- nl = document.getElementsByTagName("H3");
- for (n of nl) {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- nl = document.getElementsByTagName("A");
- for (n of nl) {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- nl = document.getElementsByTagName("DIV");
- for (n of nl) {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- nl = document.getElementsByTagName("LABEL");
- for (n of nl) {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- nl = document.getElementsByTagName("SPAN");
- for (n of nl) {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- nl = document.getElementsByTagName("INPUT");
- for (n of nl) {
- n.value = n.value.replace(ts, this.tranDest[it]);
- n.setAttribute("placeholder", n.getAttribute("placeholder").replace(ts, this.tranDest[it]));
- }
- nl = document.getElementsByTagName("TEXTAREA");
- for (n of nl) {
- if (n.id !== "SQJSuserTransTB") {
- n.innerHTML = n.innerHTML.replace(ts, this.tranDest[it]);
- }
- }
- it++;
- }
- }
- /**
- * mycreateUserTrans
- *
- * Create the tag DIV of user trans icon and user trans menu
- *
- * Context:
- * - Call it in the body of your webpage
- *
- * @param {string} icoURI, the URI of the menu icon
- * @param {string} contentContId, the container of the body content (the menu will disable it)
- * @param {string} top, the y coord of the menu position
- * @param {string} left, the x coord of the menu position
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mycreateUserTrans(icoURI, contentContId, top, left) {
-
- //if (typeof jQuery === 'undefined') {
- // throw new Error('This SqueeJS\'s function requires jQuery');
- //}
-
- var D = document;
- //w = gfSQJZDocWidth();
- //h = gfSQJZDocHeight();
- this.usertransContentContId = contentContId;
- menuico = "";
- menuico = "<img src='"+icoURI+"' style='width:48px;height:48px;' alt='user translation'>";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSuserTransIco";
- newdiv.style.width = "48px";
- newdiv.style.height = "48px";
- newdiv.innerHTML = menuico;
- //D.body.appendChild(newdiv);
- D.write(newdiv.outerHTML);
- //document.getElementById("SQJSuserTransIco").onclick = function(){SQJS.usertransPopUp();};
- //document.getElementById("SQJSuserTransIco").onmouseover = function(){SQJS.usertransCheckFlagIco();};
- //document.getElementById("SQJSuserTransIco").onmouseout = function(){SQJS.usertransUnCheckFlagIco();};
- document.getElementById("SQJSuserTransIco").addEventListener("click", function() {
- SQJS.usertransPopUp();
- });
- document.getElementById("SQJSuserTransIco").addEventListener("mouseover", function() {
- SQJS.usertransCheckFlagIco();
- });
- document.getElementById("SQJSuserTransIco").addEventListener("mouseout", function() {
- SQJS.usertransUnCheckFlagIco();
- });
-
- menu = "";
- menu += "<span style='font-size:10px;'>text or link, use ||| to separate source from translation:</span>";
- menu += "<textarea id='SQJSuserTransTB'></textarea><br>";
- menu += "<button id='SQJSuserTransBUT' onclick='SQJS.translate();'><img src='//squeejs.com/res/trans.png' style='height:70px'></button><br>";
- menu += "<br>";
-
- newdiv=D.createElement("div");
- newdiv.id = "SQJSuserTransMenu";
- newdiv.style.top = top+"px";
- newdiv.style.left = left+"px";
- newdiv.style.width = "380px";
- newdiv.style.height = "515px";
- newdiv.innerHTML = menu;
- D.body.appendChild(newdiv);
- //D.write(newdiv.outerHTML);
- //document.getElementById("SQJSuserTransMenu").onmouseover = function(){SQJS.usertransCheckFlagIco();};
- //document.getElementById("SQJSuserTransMenu").onmouseout = function(){SQJS.usertransUnCheckFlagIco();};
-
- document.getElementById("SQJSuserTransMenu").addEventListener("mouseover", function() {
- SQJS.usertransCheckFlagIco();
- });
- document.getElementById("SQJSuserTransMenu").addEventListener("mouseout", function() {
- SQJS.usertransUnCheckFlagIco();
- });
-
- //document.body.onclick = function(){SQJS.usertransBodyOnClick();};
-
- document.body.addEventListener("click", function() {
- SQJS.usertransBodyOnClick();
- });
-
- }
- // --- UserTranslation
-
- /**
- *
- * Sidebar
- */
-
- /**
- * mysidebarCheckFlag
- *
- * Check to true the sideabr flag
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mysidebarCheckFlag() {
- this.sidebarOnIT = true;
- }
- /**
- * mysidebarUnCheckFlag
- *
- * Check to false the sidebar flag
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mysidebarUnCheckFlag() {
- this.sidebarOnIT = false;
- }
-
- /**
- * myusertransBodyOnClick
- *
- * Body click event function: if open, hide the menu
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mysidebarBodyOnClick() {
- if (!this.sidebarOnIT) {
- this.sidebarClose();
- }
- }
-
- /**
- * mysidebarShow
- *
- * Show the sidebar
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mysidebarShow() {
- if (!this.sidebarVisible) {
- //if (document.getElementById(this.sidebarContentContId)) {
- // document.getElementById(this.sidebarContentContId).style.width = "100%";
- //}
- gfSQJZsetCSSById(this.sidebarContentContId, "width", "100%");
- //$("#SQJSsidebar").show("slow");
- document.getElementById("SQJSsidebar").style.display = "inline";
- }
- this.sidebarVisible = true;
- }
- /**
- * mysidebarClose
- *
- * Close the sidebar
- *
- * Context:
- * - this function is for internal use
- *
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mysidebarClose() {
- document.getElementById("SQJSsidebar").style.display = "none";
- //if (document.getElementById(this.sidebarContentContId)) {
- // document.getElementById(this.sidebarContentContId).style.width = "100%";
- //}
- gfSQJZsetCSSById(this.sidebarContentContId, "width", "100%");
- this.sidebarVisible = false;
- }
-
- /**
- * mycreateSidebar
- *
- * Create the tag DIV of sidebar
- *
- * Context:
- * - Call it in the body of your webpage
- *
- * @param {string} sidebarURL, the URI of the of the sidebar
- * @param {string} contentContId, the container of the body content
- * @param {string} width, the width of the sidebar
- * @param {string} height, the height of the sidebar
- * @returns {void}
- *
- * This function is part of SqueeJS.
- */
- function mycreateSidebar(sidebarURL, contentContId, width, height) {
-
- if (typeof jQuery === 'undefined') {
- throw new Error('This SqueeJS\'s function requires jQuery');
- }
-
- var D = document;
- //w = gfSQJZDocWidth();
- //h = gfSQJZDocHeight();
- this.sidebarContentContId = contentContId;
- barcall = "";
- barcall = " ";
- newdiv=D.createElement("div");
- newdiv.id = "SQJSsidebarCall";
- newdiv.innerHTML = barcall;
- D.body.appendChild(newdiv);
- //D.write(newdiv.outerHTML);
- //document.getElementById("SQJSsidebarCall").onmouseover = function(){SQJS.sidebarShow();};
- document.getElementById("SQJSsidebarCall").addEventListener("mouseover", function() {
- SQJS.sidebarShow();
- });
- document.getElementById("SQJSsidebarCall").addEventListener("touchstart", function() {
- SQJS.sidebarShow();
- });
-
- sidebar = "";
- sidebar += "<div style='text-align:right;'>";
- sidebar += "<button type='button' class='SQJSclose-button' style='position:relative; left:-10px' onclick='SQJS.sidebarClose();'>";
- sidebar += "<span style='font-size:45px; font-weight:900;'>×</span>";
- sidebar += "</button>";
- sidebar += "</div>";
- sidebar += "<div id='SQJSsidebarContent'>";
- sidebar += "</div>";
-
- newdiv=D.createElement("div");
- newdiv.id = "SQJSsidebar";
- newdiv.style.width = width + "px";
- newdiv.style.height = height + "px";
- newdiv.innerHTML = sidebar;
- D.body.appendChild(newdiv);
- //D.write(newdiv.outerHTML);
- document.getElementById("SQJSsidebar").addEventListener("mouseover", function() {
- SQJS.sidebarCheckFlag();
- });
- document.getElementById("SQJSsidebar").addEventListener("mouseout", function() {
- SQJS.sidebarUnCheckFlag();
- });
- document.getElementById("SQJSsidebar").addEventListener("touchstart", function() {
- SQJS.sidebarCheckFlag();
- });
- document.getElementById("SQJSsidebar").addEventListener("touchend", function() {
- SQJS.sidebarUnCheckFlag();
- });
-
- //$("#SQJSsidebarContent").load(sidebarURL+"?rrnd="+ gfSQJZrnd(50000, 99999));
- gfSQJZLoad("SQJSsidebarContent", sidebarURL+"?rrnd="+ gfSQJZrnd(50000, 99999))
-
- document.body.addEventListener("click", function() {
- SQJS.sidebarBodyOnClick();
- });
- }
- // --- Sidebar
-
- }
- window.SQJS = window.SqueeJS = new SqueeJS();
- window.addEventListener("load", function() {
- nl = document.getElementsByTagName("DIV");
- i=0;
- for (n of nl) {
- n.setAttribute("highlightIndex", i);
- i++;
- }
- nl = document.getElementsByTagName("INPUT");
- for (n of nl) {
- n.setAttribute("highlightIndex", i);
- i++;
- }
- nl = document.getElementsByTagName("TEXTAREA");
- for (n of nl) {
- n.setAttribute("highlightIndex", i);
- i++;
- }
- },true);
|