From 7d1bebce9c04c4205102e1d4c57026cd00856fe5 Mon Sep 17 00:00:00 2001 From: Miko Jimenez Date: Sun, 31 Oct 2021 13:42:51 -0400 Subject: [PATCH 1/4] Update CONTRIBUTING.md --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d0e0379..2f7b416 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -To contribute to this project, please check out the `dev` branch for the latest commits. +To contribute to this project, please check out the `main` branch for the latest stable release. Please name your branch `dev-YOURNAME` or `dev-YOURNAME-PROJECT`. Make a pull request when you are finished with a description of what was changed. Please tag all the relevant issues assign relevant project tasks and milestones. From fd8e217a9fd4e7116bca1bd8312c37a17502bf48 Mon Sep 17 00:00:00 2001 From: Miko Jimenez Date: Sun, 31 Oct 2021 18:02:27 -0400 Subject: [PATCH 2/4] Fix #9 --- css/styles.css | 10 +++++++--- css/styles.css.map | 2 +- css/styles.scss | 11 ++++++++--- css/variables.scss | 3 +++ scripts/app.js | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/css/styles.css b/css/styles.css index e127eb5..9cee5f8 100644 --- a/css/styles.css +++ b/css/styles.css @@ -106,7 +106,7 @@ footer { /* Dark Mode Stylings */ .darkmode, .fas.darkmode { - color: white; } + color: #ffffff; } .alert-warning.darkmode { background-color: #f9e7c950 !important; } @@ -115,9 +115,13 @@ footer { background-color: #dcf3f850 !important; } .btn.darkmode { - background-color: black; } + background-color: #000000; } + +.dropdown-menu.darkmode { + background-color: #000000; + border: 1px solid #b3b3b3; } body.darkmode { - background-color: black; } + background-color: #000000; } /*# sourceMappingURL=styles.css.map */ diff --git a/css/styles.css.map b/css/styles.css.map index 8175d00..9bc7a67 100644 --- a/css/styles.css.map +++ b/css/styles.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,YAAY;ACCJ,oBAAS;AAEjB,aAAa;AA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ExB,wBAAyB;EACrB,KAAK,EDrIM,OAAO;;ACwItB,uBAAwB;EACpB,gBAAgB,EAAE,oBAAmB;;AAGzC,oBAAqB;EACjB,gBAAgB,EAAE,oBAAmB;;AAGzC,aAAc;EACV,gBAAgB,EDlJC,OAAO;;ACqJ5B,uBAAwB;EACpB,gBAAgB,EDtJC,OAAO;ECuJxB,MAAM,EAAE,iBAAiB;;AAG7B,aAAc;EACV,gBAAgB,ED3JC,OAAO", "sources": ["variables.scss","styles.scss"], "names": [], "file": "styles.css" diff --git a/css/styles.scss b/css/styles.scss index 2b57dfc..843e95f 100644 --- a/css/styles.scss +++ b/css/styles.scss @@ -137,7 +137,7 @@ footer { /* Dark Mode Stylings */ .darkmode, .fas.darkmode { - color: white; + color: $darkModeText; } .alert-warning.darkmode { @@ -149,9 +149,14 @@ footer { } .btn.darkmode { - background-color: black; + background-color: $darkModeBackground; +} + +.dropdown-menu.darkmode { + background-color: $darkModeBackground; + border: 1px solid #b3b3b3; } body.darkmode { - background-color: black; + background-color: $darkModeBackground; } \ No newline at end of file diff --git a/css/variables.scss b/css/variables.scss index 6cb7266..e4bb82f 100644 --- a/css/variables.scss +++ b/css/variables.scss @@ -3,4 +3,7 @@ $brightGold: rgba(255,202,6,1); $brightGold50: rgba(255,202,6,0.5); $brightGold25: rgba(255,202,6,0.25); +$darkModeBackground: #000000; +$darkModeText: #ffffff; + $breakpoint-mobile: 1000px; \ No newline at end of file diff --git a/scripts/app.js b/scripts/app.js index 3e23d15..14f44b1 100644 --- a/scripts/app.js +++ b/scripts/app.js @@ -44,7 +44,7 @@ function setFontSize() { /* Get dark mode based on preferences */ function setDarkMode() { - let accessibleElements = "a, body, button, h1, h2, h3, h4, h5, h6, .alert, .fas"; + let accessibleElements = "a, body, button, h1, h2, h3, h4, h5, h6, .alert, .dropdown-menu, .fas"; if(Cookies.get('darkMode') == "true") { $("#dark-mode-toggle").addClass("btn-success"); From dbcd0f816700d17114332c8af4bac8d6d779d87c Mon Sep 17 00:00:00 2001 From: Miko Jimenez Date: Sun, 31 Oct 2021 18:02:27 -0400 Subject: [PATCH 3/4] Fixed #9 --- css/styles.css | 10 +++++++--- css/styles.css.map | 2 +- css/styles.scss | 11 ++++++++--- css/variables.scss | 3 +++ scripts/app.js | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/css/styles.css b/css/styles.css index e127eb5..9cee5f8 100644 --- a/css/styles.css +++ b/css/styles.css @@ -106,7 +106,7 @@ footer { /* Dark Mode Stylings */ .darkmode, .fas.darkmode { - color: white; } + color: #ffffff; } .alert-warning.darkmode { background-color: #f9e7c950 !important; } @@ -115,9 +115,13 @@ footer { background-color: #dcf3f850 !important; } .btn.darkmode { - background-color: black; } + background-color: #000000; } + +.dropdown-menu.darkmode { + background-color: #000000; + border: 1px solid #b3b3b3; } body.darkmode { - background-color: black; } + background-color: #000000; } /*# sourceMappingURL=styles.css.map */ diff --git a/css/styles.css.map b/css/styles.css.map index 8175d00..9bc7a67 100644 --- a/css/styles.css.map +++ b/css/styles.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAAA,YAAY;ACCJ,oBAAS;AAEjB,aAAa;AAEb,QAAS;EACL,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,MAAM;EACX,UAAU,EAAE,MAAM;;AAGtB,KAAM;EACF,KAAK,EAAE,OAAO;;AAGlB,UAAW;EACP,cAAc,EAAE,IAAI;;AAGxB,IAAK;EACD,MAAM,EAAE,KAAK;EACb,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,iBAAqB;EAC7B,aAAa,EAAE,GAAG;EAClB,OAAO,EAAE,YAAY;;AAGzB,UAAW;EACP,gBAAgB,ED5BP,OAAiB;;AC+B9B,QAAS;EACL,KAAK,EAAE,KAAK;EACZ,QAAQ,EAAE,QAAQ;EAClB,GAAG,EAAE,IAAI;;AAGb,cAAe;EACX,KAAK,EAAE,KAAK;;AAGhB,aAAc;EACV,SAAS,EAAE,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AW,EAAE,IAAI;EACjB,MAAM,EAAE,IAAI;;AAGhB,kBAAmB;EACf,OAAO,EAAE,KAAK;EACd,WAAW,EAAE,IAAI;EACjB,YAAY,EAAE,IAAI;EAClB,MAAM,EAAE,IAAI;;AAIhB,iBAAkB;EACd,KAAK,EAAE,KAAK;;AAGhB,iBAAkB;EACd,MAAM,EAAE,eAAe;;AAG3B,2BAA4B;EACxB,WAAW,EAAE,IAAI;;AAGrB,eAAgB;EACZ,WAAW,EAAE,IAAI;EACjB,WAAW,EAAE,CAAC;EACd,cAAc,EAAE,CAAC;;AAGrB,iBAAkB;EACd,WAAW,EAAE,KAAK;;AAGtB,wBAAwB;AAExB,MAAO;EACH,gBAAgB,EAAE,KAAK;EACvB,MAAM,EAAE,IAAI;EAEZ,QAAQ,EAAE,KAAK;EACf,MAAM,EAAE,CAAC;EACT,KAAK,EAAE,IAAI;EACX,OAAO,EAAE,GAAG;;AAGhB,gBAAiB;EACb,KAAK,EAAE,KAAK;;AAGhB,uBAAwB;EACpB,KAAK,EDhII,OAAiB;;ACmI9B,sBAAuB;EACnB,KAAK,EDnIM,sBAAmB;;ACsIlC,wBAAwB;AAExB,wBAAyB;EACrB,KAAK,EDrIM,OAAO;;ACwItB,uBAAwB;EACpB,gBAAgB,EAAE,oBAAmB;;AAGzC,oBAAqB;EACjB,gBAAgB,EAAE,oBAAmB;;AAGzC,aAAc;EACV,gBAAgB,EDlJC,OAAO;;ACqJ5B,uBAAwB;EACpB,gBAAgB,EDtJC,OAAO;ECuJxB,MAAM,EAAE,iBAAiB;;AAG7B,aAAc;EACV,gBAAgB,ED3JC,OAAO", "sources": ["variables.scss","styles.scss"], "names": [], "file": "styles.css" diff --git a/css/styles.scss b/css/styles.scss index 2b57dfc..843e95f 100644 --- a/css/styles.scss +++ b/css/styles.scss @@ -137,7 +137,7 @@ footer { /* Dark Mode Stylings */ .darkmode, .fas.darkmode { - color: white; + color: $darkModeText; } .alert-warning.darkmode { @@ -149,9 +149,14 @@ footer { } .btn.darkmode { - background-color: black; + background-color: $darkModeBackground; +} + +.dropdown-menu.darkmode { + background-color: $darkModeBackground; + border: 1px solid #b3b3b3; } body.darkmode { - background-color: black; + background-color: $darkModeBackground; } \ No newline at end of file diff --git a/css/variables.scss b/css/variables.scss index 6cb7266..e4bb82f 100644 --- a/css/variables.scss +++ b/css/variables.scss @@ -3,4 +3,7 @@ $brightGold: rgba(255,202,6,1); $brightGold50: rgba(255,202,6,0.5); $brightGold25: rgba(255,202,6,0.25); +$darkModeBackground: #000000; +$darkModeText: #ffffff; + $breakpoint-mobile: 1000px; \ No newline at end of file diff --git a/scripts/app.js b/scripts/app.js index 3e23d15..14f44b1 100644 --- a/scripts/app.js +++ b/scripts/app.js @@ -44,7 +44,7 @@ function setFontSize() { /* Get dark mode based on preferences */ function setDarkMode() { - let accessibleElements = "a, body, button, h1, h2, h3, h4, h5, h6, .alert, .fas"; + let accessibleElements = "a, body, button, h1, h2, h3, h4, h5, h6, .alert, .dropdown-menu, .fas"; if(Cookies.get('darkMode') == "true") { $("#dark-mode-toggle").addClass("btn-success"); From e0a9203a8f128a5feeec2b3606681c8e71efe648 Mon Sep 17 00:00:00 2001 From: Miko Jimenez Date: Tue, 2 Nov 2021 22:48:41 -0400 Subject: [PATCH 4/4] Implement page translations Close #4 Rename app.js to accessibility.js --- .DS_Store | Bin 8196 -> 8196 bytes app/home.html | 2 +- app/preferences.html | 14 +- locales/preferences.js | 154 +++++ package-lock.json | 4 +- package.json | 2 +- scripts/{app.js => accessibility.js} | 59 +- scripts/lingumania.js | 805 +++++++++++++++++++++++++++ 8 files changed, 1020 insertions(+), 20 deletions(-) create mode 100644 locales/preferences.js rename scripts/{app.js => accessibility.js} (69%) create mode 100644 scripts/lingumania.js diff --git a/.DS_Store b/.DS_Store index e0269f4ee5be2ebe6b031e9adf6f28d2cf3e098a..69e8d4bbfeb803fd3a12c84dbb111bd7ed8ef620 100644 GIT binary patch delta 255 zcmZp1XmOa}&nUJrU^hRb*km4ozl_@^>xdPyh*eh`Ol}lZVCZ~DsuB(T#|C~lYk01`rV^)cxN7V1hO$yr4XU2 zAcGIpy3GP23mEx~YIPK#jdE8 F5dampLr4Gs delta 69 zcmZp1XmOa}&nUDpU^hRb&}1Hgzms1J3QayOwrcZXK|iL=3q|HKPIeG=+*~i#!8oy@ RZ!^2ZHOctober 29 - + \ No newline at end of file diff --git a/app/preferences.html b/app/preferences.html index feb735a..8c1e694 100644 --- a/app/preferences.html +++ b/app/preferences.html @@ -96,7 +96,7 @@

Emergency Notifications

Emergency alerts and notifications.

News & Events

-

Calender alerts, new events.

+

Calendar alerts, new events.

Transit Notifications

Parking, travel time.

@@ -111,10 +111,10 @@

Language Preferences

Change Language @@ -166,5 +166,7 @@

Dark Mode

- + + + \ No newline at end of file diff --git a/locales/preferences.js b/locales/preferences.js new file mode 100644 index 0000000..b747bab --- /dev/null +++ b/locales/preferences.js @@ -0,0 +1,154 @@ +var linguJSON = { + "custom_lang_switcher_container_id": "#lingumania", + "languages": [ + { + "lang_name": "English", + "lang_code": "en", + "url_pattern": "?" + }, + { + "lang_name": "Español", + "lang_code": "es", + "url_pattern": "?" + }, + { + "lang_name": "François", + "lang_code": "fr", + "url_pattern": "?" + }, + { + "lang_name": "Deutsch", + "lang_code": "de", + "url_pattern": "?" + } + ], + "translated_segments": [ + { + "source": "Preferences", + "target_es": "Preferencias", + "target_fr": "Préférences", + "target_de": "Einstellungen" + }, + { + "source": "Change Campus", + "target_es": "Cambiar campus", + "target_fr": "Changer de campus", + "target_de": "Campus wechseln" + }, + { + "source": "Select Campus", + "target_es": "Seleccionar campus", + "target_fr": "Sélectionnez le campus", + "target_de": "Campus auswählen" + }, + { + "source": "Location Preferences", + "target_es": "Preferencias de ubicación", + "target_fr": "Préférences d'emplacement", + "target_de": "Standorteinstellungen" + }, + { + "source": "Allow location services.", + "target_es": "Permitir servicios de ubicación.", + "target_fr": "Autoriser les services de localisation.", + "target_de": "Ortungsdienste zulassen." + }, + { + "source": "Notification Preferences", + "target_es": "Preferencias de notificación", + "target_fr": "Préférences de notification", + "target_de": "Benachrichtigungseinstellungen" + }, + { + "source": "Emergency Notifications", + "target_es": "Notificaciones de emergencia", + "target_fr": "Notifications d'urgence", + "target_de": "Notfallbenachrichtigungen" + }, + { + "source": "Emergency alerts and notifications.", + "target_es": "Alertas y notificaciones de emergencia.", + "target_fr": "Alertes et notifications d'urgence.", + "target_de": "Notfallwarnungen und Benachrichtigungen." + }, + { + "source": "News & Events", + "target_es": "Noticias y Eventos", + "target_fr": "Nouvelles et événements", + "target_de": "Neuigkeiten und Veranstaltungen" + }, + { + "source": "Calendar alerts, new events.", + "target_es": "Alertas de calendario, nuevos eventos.", + "target_fr": "Alertes de calendrier, nouveaux événements.", + "target_de": "Kalenderbenachrichtigungen, neue Ereignisse." + }, + { + "source": "Parking, travel time.", + "target_es": "Aparcamiento, tiempo de viaje.", + "target_fr": "Stationnement, temps de trajet.", + "target_de": "Parking, travel time." + }, + { + "source": "Language Preferences", + "target_es": "Preferencias de idioma", + "target_fr": "Préférences de langue", + "target_de": "Sprache ändern" + },{ + "source": "Change Language", + "target_es": "Cambiar idioma", + "target_fr": "Changer de langue", + "target_de": "" + }, + { + "source": "Accessibility", + "target_es": "Accesibilidad", + "target_fr": "Accessibilité", + "target_de": "Barrierefreiheit" + }, + { + "source": "Smaller", + "target_es": "Mas pequeño", + "target_fr": "Plus petite", + "target_de": "Smaller" + }, + { + "source": "Normal", + "target_es": "Normal", + "target_fr": "Normal", + "target_de": "Normal" + }, + { + "source": "Larger", + "target_es": "Más grande", + "target_fr": "Plus grand", + "target_de": "Farben mit hohem Kontrast" + }, + { + "source": "High Contrast Colors", + "target_es": "Colores de alto contraste", + "target_fr": "Couleurs à contraste élevé", + "target_de": "" + }, + { + "source": "Dark Mode", + "target_es": "Modo oscuro", + "target_fr": "Mode sombre", + "target_de": "Dunkler Modus" + }, + { + "source": "Enabled", + "target_es": "Activado", + "target_fr": "Activé", + "target_de": "Ermöglicht" + }, + { + "source": "Disabled", + "target_es": "Discapacitado", + "target_fr": "Désactivé", + "target_de": "Behinderte" + } + + ] +}; + \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b72b419..05442f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dig4104c", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "dig4104c", - "version": "0.2.0", + "version": "0.3.0", "license": "ISC", "dependencies": { "jquery": "^3.6.0", diff --git a/package.json b/package.json index d5a52c9..d93b135 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dig4104c", - "version": "0.2.0", + "version": "0.3.0", "description": "UCF Mobile App Prototype", "main": "index.html", "scripts": { diff --git a/scripts/app.js b/scripts/accessibility.js similarity index 69% rename from scripts/app.js rename to scripts/accessibility.js index 14f44b1..e6f678f 100644 --- a/scripts/app.js +++ b/scripts/accessibility.js @@ -1,3 +1,19 @@ +let ui_locales = { + "Enabled": + { + "en": "Enabled", + "es": "Activado", + "fr": "Activé", + "de": "Ermöglicht" + }, + "Disabled": { + "en": "Disabled", + "es": "Discapacitado", + "fr": "Désactivé", + "de": "Behinderte" + } +} + /* Get font size based on preferences */ function setFontSize() { let accessibleText = "a, button:not('.text-size-toggle'), h1, h2, h3, h4, h5, h6, p"; @@ -49,13 +65,13 @@ function setDarkMode() { if(Cookies.get('darkMode') == "true") { $("#dark-mode-toggle").addClass("btn-success"); $("#dark-mode-toggle").removeClass("btn-default"); - $("#dark-mode-toggle").text("Enabled"); + $("#dark-mode-toggle").text(ui_locales['Enabled'][Cookies.get('lang')]); $(accessibleElements).addClass("darkmode"); } else { $("#dark-mode-toggle").addClass("btn-default"); $("#dark-mode-toggle").removeClass("btn-success"); - $("#dark-mode-toggle").text("Disabled"); + $("#dark-mode-toggle").text(ui_locales['Disabled'][Cookies.get('lang')]); $(accessibleElements).removeClass("darkmode"); } @@ -64,13 +80,11 @@ function setDarkMode() { /* Toggle clickable buttons */ $(".btn-toggle").on("click", function(){ if ($(this).hasClass("btn-success")) { - $(this).addClass("btn-default"); - $(this).removeClass("btn-success"); - $(this).text("Disabled"); + $(this).toggleClass("btn-default btn-success"); + $(this).text(ui_locales['Disabled'][Cookies.get('lang')]); } else { - $(this).addClass("btn-success"); - $(this).removeClass("btn-default"); - $(this).text("Enabled"); + $(this).toggleClass("btn-default btn-success"); + $(this).text(ui_locales['Enabled'][Cookies.get('lang')]); } }); @@ -99,5 +113,30 @@ $("#dark-mode-toggle").on("click", function() { } }); -setFontSize() -setDarkMode(); \ No newline at end of file +/* Set language preferences */ +$("#lang_en").on("click", function() { + Cookies.set('lang', 'en'); + location.reload(); +}); +$("#lang_es").on("click", function() { + Cookies.set('lang', 'es'); + location.reload(); +}); +$("#lang_fr").on("click", function() { + Cookies.set('lang', 'fr'); + location.reload(); +}); +$("#lang_de").on("click", function() { + Cookies.set('lang', 'de'); + location.reload(); +}); + +/* Initalize accessibility features */ +setFontSize(); +setDarkMode(); + +/* Default cookies */ +$(window).on("load", function() { + if (Cookies.get('lang') == undefined) + Cookies.set('lang', 'en'); +}); \ No newline at end of file diff --git a/scripts/lingumania.js b/scripts/lingumania.js new file mode 100644 index 0000000..f712e13 --- /dev/null +++ b/scripts/lingumania.js @@ -0,0 +1,805 @@ +/* +LICENSE AND TERMS OF USE + +Lingumania.js is licensed under the terms of https://creativecommons.org/licenses/by-nd/3.0/ license, +which means it can be used freely on commercial or non commercial websites as long as the language switcher links back to www.lingumania.com. +You may modify the code only if you use it to translate your own website. In all other cases, modifications or redistribution, +whether standalone or as part of another javascript, are not permitted without prior consent of the copyright owners. +*/ + +(function (w, d, u) { + var translationLang; + if (Cookies.get('lang') != undefined) + translationLang = Cookies.get('lang'); + else if (getQSParameterByName("lang", w.location.href)) + translationLang = getQSParameterByName("lang", w.location.href); + else if (parseURL(w.location.href, false).substring(0, 4).replace(/\//g, '').length == 2) + translationLang = parseURL(w.location.href, false).substring(0, 4).replace(/\//g, ''); + else if (parseURL(w.location.href, true).substring(0, parseURL(w.location.href, true).indexOf('.')).length == 2) + translationLang = parseURL(w.location.href, true).substring(0, parseURL(w.location.href, true).indexOf('.')); + else if (parseURL(w.location.href, true).substring(parseURL(w.location.href, true).lastIndexOf('.') + 1, parseURL(w.location.href, true).length).length == 2) + translationLang = parseURL(w.location.href, true).substring(parseURL(w.location.href, true).lastIndexOf('.') + 1, parseURL(w.location.href, true).length); + + if (translationLang) + d.body.style.visibility = "hidden"; + + + var NodeFilter = { + FILTER_ACCEPT: 1, + FILTER_REJECT: 2, + FILTER_SKIP: 3, + SHOW_ALL: -1, + SHOW_ELEMENT: 1, + SHOW_ATTRIBUTE: 2, + SHOW_TEXT: 4, + SHOW_CDATA_SECTION: 8, + SHOW_ENTITY_REFERENCE: 16, + SHOW_ENTITY: 32, + SHOW_PROCESSING_INSTRUCTIONS: 64, + SHOW_COMMENT: 128, + SHOW_DOCUMENT: 256, + SHOW_DOCUMENT_TYPE: 512, + SHOW_DOCUMENT_FRAGMENT: 1024, + SHOW_NOTATION: 2048 + }; + + var TreeWalker = function (root, whatToShow, filter, expandEntityReferences) { + this.root = root; + this.whatToShow = whatToShow; + this.filter = filter; + this.expandEntityReferences = expandEntityReferences; + this.currentNode = root; + this.NodeFilter = NodeFilter; + }; + + TreeWalker.prototype.parentNode = function () { + var testNode = this.currentNode; + + do { + if ( + testNode !== this.root && + testNode.parentNode && + testNode.parentNode !== this.root + ) { + testNode = testNode.parentNode; + } else { + return null; + } + } while (this._getFilteredStatus(testNode) !== this.NodeFilter.FILTER_ACCEPT); + (testNode) && (this.currentNode = testNode); + + return testNode; + }; + + TreeWalker.prototype.firstChild = function () { + var testNode = this.currentNode.firstChild; + + while (testNode) { + if (this._getFilteredStatus(testNode) === this.NodeFilter.FILTER_ACCEPT) { + break; + } + testNode = testNode.nextSibling; + } + (testNode) && (this.currentNode = testNode); + + return testNode; + }; + + TreeWalker.prototype.lastChild = function () { + var testNode = this.currentNode.lastChild; + + while (testNode) { + if (this._getFilteredStatus(testNode) === this.NodeFilter.FILTER_ACCEPT) { + break; + } + testNode = testNode.previousSibling; + } + (testNode) && (this.currentNode = testNode); + + return testNode; + }; + + TreeWalker.prototype.nextNode = function () { + var testNode = this.currentNode; + + while (testNode) { + if (testNode.childNodes.length !== 0) { + testNode = testNode.firstChild; + } else if (testNode.nextSibling) { + testNode = testNode.nextSibling; + } else { + while (testNode) { + if (testNode.parentNode && testNode.parentNode !== this.root) { + if (testNode.parentNode.nextSibling) { + testNode = testNode.parentNode.nextSibling; + break; + } else { + testNode = testNode.parentNode; + } + } + else return null; + } + } + if (testNode && this._getFilteredStatus(testNode) === this.NodeFilter.FILTER_ACCEPT) { + break; + } + } + (testNode) && (this.currentNode = testNode); + + return testNode; + }; + + TreeWalker.prototype.previousNode = function () { + var testNode = this.currentNode; + + while (testNode) { + if (testNode.previousSibling) { + testNode = testNode.previousSibling; + while (testNode.lastChild) { + testNode = testNode.lastChild; + } + } + else { + if (testNode.parentNode && testNode.parentNode !== this.root) { + testNode = testNode.parentNode; + } + else testNode = null; + } + if (testNode && this._getFilteredStatus(testNode) === this.NodeFilter.FILTER_ACCEPT) { + break; + } + } + (testNode) && (this.currentNode = testNode); + + return testNode; + }; + + TreeWalker.prototype.nextSibling = function () { + var testNode = this.currentNode; + + while (testNode) { + (testNode.nextSibling) && (testNode = testNode.nextSibling); + if (this._getFilteredStatus(testNode) === this.NodeFilter.FILTER_ACCEPT) { + break; + } + } + (testNode) && (this.currentNode = testNode); + + return testNode; + }; + + TreeWalker.prototype.previousSibling = function () { + var testNode = this.currentNode; + + while (testNode) { + (testNode.previousSibling) && (testNode = testNode.previousSibling); + if (this._getFilteredStatus(testNode) == this.NodeFilter.FILTER_ACCEPT) { + break; + } + } + (testNode) && (this.currentNode = testNode); + + return testNode; + }; + + TreeWalker.prototype._getFilteredStatus = function (node) { + var mask = ({ + /* ELEMENT_NODE */ 1: this.NodeFilter.SHOW_ELEMENT, + /* ATTRIBUTE_NODE */ 2: this.NodeFilter.SHOW_ATTRIBUTE, + /* TEXT_NODE */ 3: this.NodeFilter.SHOW_TEXT, + /* CDATA_SECTION_NODE */ 4: this.NodeFilter.SHOW_CDATA_SECTION, + /* ENTITY_REFERENCE_NODE */ 5: this.NodeFilter.SHOW_ENTITY_REFERENCE, + /* ENTITY_NODE */ 6: this.NodeFilter.SHOW_PROCESSING_INSTRUCTION, + /* PROCESSING_INSTRUCTION_NODE */ 7: this.NodeFilter.SHOW_PROCESSING_INSTRUCTION, + /* COMMENT_NODE */ 8: this.NodeFilter.SHOW_COMMENT, + /* DOCUMENT_NODE */ 9: this.NodeFilter.SHOW_DOCUMENT, + /* DOCUMENT_TYPE_NODE */ 10: this.NodeFilter.SHOW_DOCUMENT_TYPE, + /* DOCUMENT_FRAGMENT_NODE */ 11: this.NodeFilter.SHOW_DOCUMENT_FRAGMENT, + /* NOTATION_NODE */ 12: this.NodeFilter.SHOW_NOTATION + })[node.nodeType]; + + return ( + (mask && (this.whatToShow & mask) == 0) ? + this.NodeFilter.FILTER_REJECT : + (this.filter && this.filter.acceptNode) ? + this.filter.acceptNode(node) : + this.NodeFilter.FILTER_ACCEPT + ); + }; + + if (!d.createTreeWalker) { + d.createTreeWalker = function (root, whatToShow, filter, expandEntityReferences) { + return new TreeWalker(root, whatToShow, filter, expandEntityReferences); + }; + } + + if (typeof String.prototype.trim !== 'function') { + String.prototype.trim = function () { + return this.replace(/^\s+|\s+$/g, ''); + } + } + + + String.prototype.startsWith = function (searchString) { + return this.substr(0, searchString.length) === searchString; + }; + String.prototype.endsWith = function (suffix) { + + return this.indexOf(suffix, this.length - suffix.length) !== -1; + }; + + + function parseURL(url, domainOnly) { + var domain; + url = decodeURIComponent(url); + if (url.indexOf("://") > -1) { + domain = url.split('/')[2]; + if (!domainOnly) + domain = url.split('/')[0] + "//" + url.split('/')[2]; + } + else + domain = url.split('/')[0]; + + if (domainOnly) + return domain; + else + return url.replace(domain, ''); + } + + function getQSParameterByName(name, searchString) { + name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); + var regexS = "[\\?&]" + name + "=([^&#]*)"; + var regex = new RegExp(regexS); + var results = regex.exec(searchString); + if (results == null) + return ""; + else + return results[1]; + } + + function getElementsByTagNames(tags) { + var elements = []; + + for (var i = 0, n = tags.length; i < n; i++) { + var divs = d.getElementsByTagName(tags[i]); + for (var j = 0; j < divs.length; j++) { + elements.push(divs[j]); + } + } + + return elements; + }; + + function isTranslatableSegment(html) { + + var foundPunctuation = html.match(/^(.|,|;|:|«|»|·|&|=|\/|\$|€|£|\(|\)|\*|\-|\+|\||\$-\/:-?{-~||\t|\r|\n|\d|\s)+$/gim); + if (foundPunctuation) { + var foundNonPunctuationChars = html.match(/[^.,;:€£«»·&=\/\$\(\)\*\-\+\|\t\r\n\d\s]/gim); + if (!foundNonPunctuationChars) + return false; + } + + return true; + } + + function rewriteUrl(link, absoluteLink, translationLang, url_pattern) { + if (url_pattern == '?') { + var fragment; + if (link.attributes["href"].value.indexOf('#') != -1) { + fragment = link.attributes["href"].value.split('#')[1]; + link.attributes["href"].value = link.attributes["href"].value.replace('#' + fragment, ''); + } + + if (getQSParameterByName("lang", link.attributes["href"].value)) + link.attributes["href"].value = link.attributes["href"].value.toLowerCase().replace("lang=" + getQSParameterByName("lang", link.attributes["href"].value), "lang=" + translationLang); + else if (link.attributes["href"].value.indexOf('?') != -1) + link.attributes["href"].value += '&lang=' + translationLang; + else + link.attributes["href"].value += '?lang=' + translationLang; + + if (fragment) + link.attributes["href"].value += '#' + fragment; + } else if (url_pattern == '/') { + if (parseURL(absoluteLink, false).substring(0, 4).replace(/\//g, '').toLowerCase() == translationLang) + link.attributes["href"].value = absoluteLink.split('/')[0] + '//' + parseURL(absoluteLink, true) + parseURL(absoluteLink, false); + + else + link.attributes["href"].value = absoluteLink.split('/')[0] + '//' + parseURL(absoluteLink, true) + '/' + translationLang + parseURL(absoluteLink, false); + } else + link.attributes["href"].value = absoluteLink.split('/')[0] + '//' + url_pattern + parseURL(absoluteLink, false); + } + + function encodeAllSpecialTags(html) { + + html = html.replace(//gim, "<b>").replace(/<\/b>/gim, "</b>").replace(//gim, "<i>").replace(/<\/i>/gim, "</i>").replace(//gim, "<u>").replace(/<\/u>/gim, "</u>").replace(//gim, "<em>").replace(/<\/em>/gim, "</em>").replace(/<\/strong>/gim, "</strong>").replace(/<\/abbr>/gim, "</abbr>").replace(/<\/sub>/gim, "</sub>").replace(/<\/sup>/gim, "</sup>").replace(/<\/big>/gim, "</big>").replace(/<\/small>/gim, "</small>"); + + var searchText = /]*>/gim; + var matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + searchText = /]*>/gim; + matches = searchText.exec(html); + if (matches) { + for (var i = 0; i < matches.length; i++) { + html = html.replace(searchText, "<" + matches[i].substring(1, matches[i].length - 1).toLowerCase() + ">"); + } + } + + return html; + } + + function translateDOM() { + if (linguJSON) { + var isTranslated = false; + var url_pattern = "?"; + var langMenu = d.createElement("div"); + langMenu.id = "lingumania_langswitcher"; + langMenu.className = "notranslate"; + var customLangMenu = d.createElement("span"); + var customLangMenuHtml = linguJSON.custom_lang_switcher_html; + + var languages = linguJSON.languages; + if (languages.length > 1) { + var sourceLang = languages[0]; + if (sourceLang.url_pattern) + url_pattern = sourceLang.url_pattern; + var menuHeight = 0; + if (translationLang == undefined) + translationLang = sourceLang.lang_code; + var currlangcode = translationLang != '' ? translationLang : sourceLang.lang_code; + var j = 1; + for (var i = 0; i < languages.length; i++) { + if (languages[i].lang_code != currlangcode) { + var href = w.location.protocol + '//' + languages[i].url_pattern + parseURL(w.location.href, false); + + if (!languages[i].url_pattern || languages[i].url_pattern == '?') { + var fragment; + if (w.location.href.indexOf('#') != -1) { + fragment = w.location.href.split('#')[1]; + href = w.location.href.replace('#' + fragment, ''); + } + + if (getQSParameterByName("lang", w.location.href)) + href = w.location.href.toLowerCase().replace("lang=" + getQSParameterByName("lang", w.location.href), "lang=" + languages[i].lang_code); + else if (w.location.href.indexOf('?') != -1) + href = w.location.href + '&lang=' + languages[i].lang_code; + else + href = w.location.href + '?lang=' + languages[i].lang_code; + + } else if (languages[i].url_pattern == '/') { + if (parseURL(w.location.href, false).substring(0, 4).replace(/\//g, '').toLowerCase().length == 2) + href = w.location.protocol + '//' + parseURL(w.location.href, true) + parseURL(w.location.href, false).replace(parseURL(w.location.href, false).substring(0, 4), '/' + languages[i].lang_code + '/'); + else + href = w.location.protocol + '//' + parseURL(w.location.href, true) + '/' + languages[i].lang_code + parseURL(w.location.href, false); + } + + if (linguJSON.custom_lang_switcher_html && linguJSON.custom_lang_switcher_container_id) { + customLangMenuHtml = customLangMenuHtml.replace('[[linguTargetLang' + j + ']]', languages[i].lang_name); + customLangMenuHtml = customLangMenuHtml.replace('[[linguTargetLangHref' + j + ']]', href); + } else { + var langItem = d.createElement("a"); + langItem.innerHTML = languages[i].lang_name; + langItem.className = "lingumania_target"; + langItem.href = href; + langMenu.appendChild(langItem); + } + j++; + } else { + if (linguJSON.custom_lang_switcher_html && linguJSON.custom_lang_switcher_container_id) { + customLangMenuHtml = customLangMenuHtml.replace('[[linguCurrLang]]', languages[i].lang_name); + } else { + var currlangItem = d.createElement("a"); + currlangItem.id = "lingumania_currentlanglink"; + currlangItem.href = ""; + currlangItem.innerHTML = languages[i].lang_name; + langMenu.insertBefore(currlangItem, langMenu.firstChild); + } + if (languages[i].url_pattern) + url_pattern = languages[i].url_pattern; + } + menuHeight += 30; + } + + var translateNowItem = d.createElement("a"); + translateNowItem.className = "lingumania_poweredby"; + translateNowItem.target = "_blank"; + translateNowItem.href = "http://www.lingumania.com"; + translateNowItem.innerHTML = "Translated Websites
Powered by Lingumania"; + langMenu.appendChild(translateNowItem); + menuHeight += 30; + if (linguJSON.custom_lang_switcher_html && linguJSON.custom_lang_switcher_container_id) { + translateNowItem.id = 'lingumania_custom_id'; + + var frag = d.createDocumentFragment(); + customLangMenu.innerHTML = customLangMenuHtml; + + while (customLangMenu.firstChild) { + frag.appendChild(customLangMenu.firstChild); + } + menuHeight = 30; + } + + if (langMenu.addEventListener) { + langMenu.addEventListener("mouseover", function (event) { + d.getElementById('lingumania_langswitcher').style.height = menuHeight + 'px'; + }); + langMenu.addEventListener("mouseout", function (event) { + setTimeout(function () { d.getElementById('lingumania_langswitcher').style.height = '30px'; }, 1000) + }); + } else { + langMenu.attachEvent("onmouseover", function (event) { + d.getElementById('lingumania_langswitcher').style.height = menuHeight + 'px'; + }); + langMenu.attachEvent("onmouseout", function (event) { + setTimeout(function () { d.getElementById('lingumania_langswitcher').style.height = '30px'; }, 1000) + }); + } + var customMenuContainer = d.getElementById(linguJSON.custom_lang_switcher_container_id); + if (!linguJSON.translated_pages) { + isTranslated = true; + d.body.insertBefore(langMenu, d.body.firstChild); + + if (linguJSON.custom_lang_switcher_html && linguJSON.custom_lang_switcher_container_id && customMenuContainer) { + while (customMenuContainer.firstChild) { + customMenuContainer.removeChild(customMenuContainer.firstChild); + } + customMenuContainer.appendChild(frag); + } + } + else { + for (var i = 0; i < linguJSON.translated_pages.length; i++) { + var comparableLink = createComparableLink(w.location.href, languages); + if (comparableLink.replace(currlangcode, '').replace('//', '/') == linguJSON.translated_pages[i].slug.toLowerCase()) { + isTranslated = true; + break; + } + } + + if (isTranslated) { + d.body.insertBefore(langMenu, d.body.firstChild); + + if (linguJSON.custom_lang_switcher_html && linguJSON.custom_lang_switcher_container_id && customMenuContainer) { + while (customMenuContainer.firstChild) { + customMenuContainer.removeChild(customMenuContainer.firstChild); + } + customMenuContainer.appendChild(frag); + } + } + } + } + + if (linguJSON.translated_segments && linguJSON.translated_segments.length > 0 && isTranslated && currlangcode != sourceLang.lang_code) { + var translatedSegments = linguJSON.translated_segments; + + var specialTags = getElementsByTagNames(['b', 'u', 'i', 'strong', 'em', 'abbr', 'sub', 'sup', 'big', 'small']); + for (var i = 0; i < specialTags.length; i++) { + if (specialTags[i].parentNode) + specialTags[i].parentNode.innerHTML = encodeAllSpecialTags(specialTags[i].parentNode.innerHTML); + } + + var node, nodes = [], fragments = [], linkTranslations = []; + var domWalker = d.createTreeWalker(d.getElementsByTagName('html')[0], NodeFilter.SHOW_ALL, null, false); + + while (node = domWalker.nextNode()) { + if (node.nodeValue != null) { + if (!isTranslatableSegment(node.nodeValue.trim())) + continue; + + var canBeTranslated = true; + var current = node; + while (canBeTranslated && current.parentNode) { + current = current.parentNode; + if (current.nodeName == "STYLE") { + canBeTranslated = false; + } else if (current.attributes) { + for (var i = 0; i < current.attributes.length; i++) { + if (current.attributes[i].value == "notranslate") + canBeTranslated = false; + } + } + } + + if (canBeTranslated) { + try { + + var startingWhiteSpaceRegex = /^\s+/gim; + var startingWhiteSpaceMatches = startingWhiteSpaceRegex.exec(node.nodeValue); + var endingWhiteSpaceRegex = /\s+$/gim; + var endingWhiteSpaceMatches = endingWhiteSpaceRegex.exec(node.nodeValue); + + for (var i = 0; i < translatedSegments.length; i++) { + if (translatedSegments[i].target == undefined) { + if (eval('translatedSegments[i].target_' + currlangcode)) + translatedSegments[i].target = eval('translatedSegments[i].target_' + currlangcode); + } + + if (translatedSegments[i].source == node.nodeValue.trim() && translatedSegments[i].target) { + + var target = translatedSegments[i].target; + + if (startingWhiteSpaceMatches) + target = startingWhiteSpaceMatches[0] + target; + + if (endingWhiteSpaceMatches) + target += endingWhiteSpaceMatches[0]; + + if (target.match(/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[\^'">\s]+))?)+\s*|\s*)\/?>/gim)) { + + var wrap = d.createElement('span'); + var frag = d.createDocumentFragment(); + wrap.innerHTML = target.replace(/\\"/g, '"'); + + while (wrap.firstChild) { + frag.appendChild(wrap.firstChild); + } + nodes.push(node); + fragments.push(frag); + } + else { + node.nodeValue = target; + } + break; + } + } + + } catch (ex) { + + } + } + + + + if (node.nodeValue.match(/(<\/b|]*>|<\/u>|]*>|<\/i>|]*>|<\/strong>|]*>|<\/em>|]*>|<\/abbr>|]*>|<\/sub>|]*>|<\/sup>|]*>|<\/big>|]*>|<\/small>|]*>)/gim)) { + var wrap = d.createElement('span'); + var frag = d.createDocumentFragment(); + wrap.innerHTML = node.nodeValue; + + while (wrap.firstChild) { + frag.appendChild(wrap.firstChild); + } + nodes.push(node); + fragments.push(frag); + } + + } + } + + var inputs = d.getElementsByTagName('input'); + for (var i = 0; i < inputs.length; i++) { + var input = inputs[i]; + if (isTranslatableSegment(input.value.trim())) { + for (var j = 0; j < translatedSegments.length; j++) { + if (translatedSegments[j].source == input.value.trim()) { + input.value = translatedSegments[j].target; + break; + } + } + } + } + + var imgs = d.getElementsByTagName('img'); + for (var i = 0; i < imgs.length; i++) { + var img = imgs[i]; + if (img.attributes["alt"] && isTranslatableSegment(img.attributes["alt"].value.trim())) { + for (var j = 0; j < translatedSegments.length; j++) { + if (translatedSegments[j].source == img.attributes["alt"].value.trim()) { + img.attributes["alt"].value = translatedSegments[j].target; + break; + } + } + } + } + + var metas = d.getElementsByTagName('meta'); + for (var i = 0; i < metas.length; i++) { + var meta = metas[i]; + if (meta.attributes["content"]) { + for (var j = 0; j < translatedSegments.length; j++) { + if (translatedSegments[j].source == meta.attributes["content"].value.trim()) { + meta.attributes["content"].value = translatedSegments[j].target; + break; + } + } + } + } + + for (var i = 0; i < translatedSegments.length; i++) { + if (translatedSegments[i].target == undefined) { + if (eval('translatedSegments[i].target_' + currlangcode)) + translatedSegments[i].target = eval('translatedSegments[i].target_' + currlangcode); + } + if (translatedSegments[i].target && translatedSegments[i].target.startsWith('http')) + linkTranslations.push(translatedSegments[i]); + } + + var links = d.getElementsByTagName('a'); + for (var i = 0; i < links.length; i++) { + var link = links[i]; + if (link.attributes["href"] && link.parentNode.className != 'notranslate') { + + + for (var j = 0; j < linkTranslations.length; j++) { + if (linkTranslations[j].source.trim() == link.attributes["href"].value.trim().replace('/../', '/')) { + link.attributes["href"].value = linkTranslations[j].target; + break; + } + } + + + if (link.attributes["href"].value.indexOf(parseURL(w.location.href, true)) != -1 || link.attributes["href"].value.indexOf(sourceLang.url_pattern) != -1 || !link.attributes["href"].value.toLowerCase().startsWith('http')) { + var absoluteLink = link.attributes["href"].value; + + + if (!link.attributes["href"].value.startsWith('http') && (link.attributes["href"].value.indexOf(parseURL(w.location.href, true)) == -1 || link.attributes["href"].value.indexOf(sourceLang.url_pattern) != -1)) { + var el = d.createElement('div'); + el.innerHTML = 'x'; + absoluteLink = el.firstChild.href; + } + + for (var j = 0; j < linkTranslations.length; j++) { + var comparableLink = createComparableLink(absoluteLink.trim().replace('/../', '/'), languages); + if (parseURL(linkTranslations[j].source.trim(), false) == comparableLink) { + link.attributes["href"].value = linkTranslations[j].target; + break; + } + } + + if (!linguJSON.translated_pages) { + + rewriteUrl(link, absoluteLink, translationLang, url_pattern); + } else { + + var comparableLink = createComparableLink(absoluteLink, languages); + for (var j = 0; j < linguJSON.translated_pages.length; j++) { + if (comparableLink == linguJSON.translated_pages[j].slug.toLowerCase()) { + rewriteUrl(link, absoluteLink, translationLang, url_pattern); + break; + } + } + } + + } + } + } + + + for (var i = 0; i < nodes.length; i++) { + if (nodes[i].parentNode) + nodes[i].parentNode.replaceChild(fragments[i], nodes[i]); + } + + } + + if (linguJSON.translated_image_segments && linguJSON.translated_image_segments.length > 0 && isTranslated && currlangcode != sourceLang.lang_code) { + var translatedImageSegments = linguJSON.translated_image_segments; + + var imgs = d.getElementsByTagName('img'); + for (var i = 0; i < imgs.length; i++) { + var img = imgs[i]; + if (img.attributes["src"]) { + for (var j = 0; j < translatedImageSegments.length; j++) { + if (translatedImageSegments[j].img_target == undefined) { + if (eval('translatedImageSegments[j].img_target_' + currlangcode)) + translatedImageSegments[j].img_target = eval('translatedImageSegments[j].img_target_' + currlangcode); + } + if (translatedImageSegments[j].img_source.replace('http://', '').replace('https://', '').endsWith(img.attributes["src"].value.trim().replace('http://', '').replace('https://', ''))) { + img.attributes["src"].value = translatedImageSegments[j].img_target; + break; + } + } + } + } + } + } + + d.body.style.visibility = 'visible'; + } + + function createComparableLink(absoluteLink, languages) { + var comparableLink = absoluteLink.replace('http://', '').replace('https://', '').toLowerCase(); + + if (comparableLink == parseURL(w.location.href, true) || comparableLink == languages[0].url_pattern) + comparableLink = '/'; + + comparableLink = comparableLink.replace(parseURL(w.location.href, true), ''); + + if (languages[0].url_pattern != '?') + comparableLink = comparableLink.replace(languages[0].url_pattern, ''); + + if (comparableLink.indexOf('?') != -1) + comparableLink = comparableLink.substring(0, comparableLink.indexOf('?')); + + if (comparableLink.lastIndexOf('/') == comparableLink.length - 1) + comparableLink = comparableLink.substring(0, comparableLink.length - 1); + + if (!comparableLink.startsWith('/')) + comparableLink = '/' + comparableLink; + + return comparableLink; + } + + var linguLoader = function () { + + // var cssCode = "a.lingumania_target, a.lingumania_poweredby { display: none; background-color: #999; } #lingumania_custom_id { display: block; color: #fff; display: block; width: 160px; padding: 5px; text-decoration: none; } a.lingumania_target:hover, a.lingumania_poweredby:hover { background-color: #000; } #lingumania_langswitcher{ position: absolute; top: 0px; right: 0px; z-index: 100001; text-transform: uppercase; text-align: left; color: #fff; font-size: 12px; line-height: 18px; } #lingumania_langswitcher:hover a { display: block; position: relative; z-index: 100002; float: right; width: 160px; padding: 5px; clear: both; color: #fff; text-decoration: none; } a#lingumania_currentlanglink { display: block; width: 160px; padding: 5px; background: #999 url('//az596610.vo.msecnd.net/arrow-down-black.png') right top no-repeat; color: #fff; font-weight: bold; text-decoration: none; } .lingumania_poweredby { background: url('//az596610.vo.msecnd.net/lingumania.png') right center no-repeat; border-top: 1px solid #808080; font-size: 9px; line-height: 12px; }"; + // var style = d.createElement('style'); + // style.type = "text/css"; + // if (style.styleSheet) + // style.styleSheet.cssText = cssCode; + // else + // style.innerHTML = cssCode; + + // d.body.insertBefore(style, d.body.firstChild); + + translateDOM(); + }; + + w.addEventListener ? w.addEventListener("load", linguLoader, false) : w.attachEvent("onload", linguLoader); +}(window, document)); \ No newline at end of file