diff options
author | marvin-borner@live.com | 2018-04-12 19:21:00 +0200 |
---|---|---|
committer | marvin-borner@live.com | 2018-04-12 19:21:00 +0200 |
commit | f79f7d062ad8dcf89116da8faba456c4519d3d2a (patch) | |
tree | 140b026ee64d8a1407de819a6dc0b79ecc40452c | |
parent | 2a221f180ebf6f86e3709401804108fcda65184f (diff) |
Finalized multilanguage support -- need to add text etc
-rw-r--r-- | TestEncryption.php | 39 | ||||
-rw-r--r-- | assets/js/chat.js | 2 | ||||
-rw-r--r-- | assets/js/language.js | 36 | ||||
-rw-r--r-- | assets/js/main.js | 47 | ||||
-rw-r--r-- | assets/languages/ExcelFile.xls | bin | 0 -> 54784 bytes | |||
-rw-r--r-- | assets/languages/json/Translations.json | 12 | ||||
-rw-r--r-- | assets/languages/json/de.json | 12 | ||||
-rw-r--r-- | assets/languages/json/en.json | 12 | ||||
-rw-r--r--[-rwxr-xr-x] | assets/php/vendor/nubs/random-name-generator/build.php | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | assets/php/vendor/paragonie/random_compat/build-phar.sh | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | assets/php/vendor/react/event-loop/travis-init.sh | 0 | ||||
-rw-r--r-- | index.php | 12 |
12 files changed, 109 insertions, 63 deletions
diff --git a/TestEncryption.php b/TestEncryption.php deleted file mode 100644 index 097b727..0000000 --- a/TestEncryption.php +++ /dev/null @@ -1,39 +0,0 @@ -<!doctype html>
-<html lang="en">
-<head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Document</title>
-</head>
-<body>
-
-
-
-<script src="assets/js/encryption.js"></script>
-<script>
- // The passphrase used to repeatably generate this RSA key.
- var PassPhrase = randomString(16);
- // The length of the RSA key, in bits.
- var Bits = 1024;
- var MattsRSAkey = cryptico.generateRSAKey(PassPhrase, Bits);
- var MattsPublicKeyString = cryptico.publicKeyString(MattsRSAkey);
-
- var PlainText = "Hello Bro";
- var EncryptionResult = cryptico.encrypt(PlainText, MattsPublicKeyString);
- console.log(EncryptionResult.cipher);
-
- function randomString(len, charSet) {
- charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- var randomString = '';
- for (var i = 0; i < len; i++) {
- var randomPoz = Math.floor(Math.random() * charSet.length);
- randomString += charSet.substring(randomPoz,randomPoz+1);
- }
- return randomString;
- }
-
-</script>
-</body>
-</html>
\ No newline at end of file diff --git a/assets/js/chat.js b/assets/js/chat.js index 9acff1d..96be014 100644 --- a/assets/js/chat.js +++ b/assets/js/chat.js @@ -2,7 +2,7 @@ GENERATE KEYS
************/
if (localStorage.getItem('KeysGenerated') === null || localStorage.getItem('KeysGenerated') !== "true") {
- // GENERATE
+ // GENERATE -- LATER ON LOGIN!
var EncryptionPhrase = "PASSWORD 123"; // THE USERS PASSWORD
var RSABitLength = 1024;
var PrivateKeyString = cryptico.generateRSAKey(EncryptionPhrase, RSABitLength);
diff --git a/assets/js/language.js b/assets/js/language.js new file mode 100644 index 0000000..9448ae3 --- /dev/null +++ b/assets/js/language.js @@ -0,0 +1,36 @@ +function Translate() {
+ //initialization
+ this.init = function (lng) {
+ this.attribute = 'data-lang';
+ this.lng = lng;
+ };
+ //translate
+ this.process = function () {
+ var _self = this;
+ var xrhFile = new XMLHttpRequest();
+ //load content data
+ xrhFile.open("GET", "assets/languages/json/Translations.json", true);
+ xrhFile.onreadystatechange = function () {
+ if (xrhFile.readyState === 4) {
+ if (xrhFile.status === 200 || xrhFile.status === 0) {
+ var LngObject = JSON.parse(xrhFile.responseText);
+ var allDom = document.getElementsByTagName("*");
+ for (var i = 0; i < allDom.length; i++) {
+ var elem = allDom[i];
+ var key = elem.getAttribute(_self.attribute);
+
+ if (key != null) {
+ console.log("Language initialized with language pack: " + _self.lng);
+ elem.innerHTML = LngObject[_self.lng][key];
+ }
+ }
+ }
+ }
+ };
+ xrhFile.send();
+ }
+}
+
+$(document).ready(function () {
+ initiateLanguage();
+});
diff --git a/assets/js/main.js b/assets/js/main.js index aa0f76b..1aefdf4 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1,33 +1,34 @@ -/*****
-NAVBAR
-*****/
-var $el, leftPos, newWidth,
- $mainNav = $(".Navbar");
-$mainNav.append("<span class='NavbarLine'></span>");
-var $magicLine = $(".NavbarLine");
-$magicLine
+var MainTabWindows = $(".MainTabWindows");
+var NavbarIconWrap = $(".NavbarIconWrap");
+var Navbar = $(".Navbar");
+var NavbarLine = $(".NavbarLine");
+
+/******
+ NAVBAR
+ *****/
+var $el, leftPos, newWidth;
+NavbarLine
.css("left", $(".ActiveTab").position().left)
- .data("origLeft", $magicLine.position().left)
- .data("origWidth", $magicLine.width());
-$(".NavbarIconWrap").on("click", function () {
- $(".NavbarIconWrap").removeClass("ActiveTab");
+ .data("origLeft", NavbarLine.position().left)
+ .data("origWidth", NavbarLine.width());
+NavbarIconWrap.on("click", function () {
+ NavbarIconWrap.removeClass("ActiveTab");
$(this).addClass("ActiveTab");
var index = $(this).attr('id');
- $('.MainTabWindows').slick('slickGoTo',index);
+ MainTabWindows.slick('slickGoTo', index);
//$('.MainTabWindows').flickity().flickity('select', index);
-
$el = $(this);
leftPos = $el.position().left;
- $magicLine.stop().animate({
+ NavbarLine.stop().animate({
left: leftPos,
- width: newWidth,
+ width: newWidth
}, 300);
});
-/*******
-FLICKITY
-*******/
-$('.MainTabWindows').slick({
+/********
+ FLICKITY
+ *******/
+MainTabWindows.slick({
initialSlide: 2,
mobileFirst: true,
nextArrow: "",
@@ -36,13 +37,13 @@ $('.MainTabWindows').slick({ zIndex: 500
});
-$('.MainTabWindows').on('beforeChange', function(event, slick, currentSlide, nextSlide){
+MainTabWindows.on('beforeChange', function (event, slick, currentSlide, nextSlide) {
//console.log(nextSlide);
- $(".NavbarIconWrap").removeClass("ActiveTab");
+ NavbarIconWrap.removeClass("ActiveTab");
$el = $("#" + nextSlide);
$el.addClass("ActiveTab");
leftPos = $el.position().left;
- $magicLine.stop().animate({
+ NavbarLine.stop().animate({
left: leftPos,
width: newWidth
}, 300);
diff --git a/assets/languages/ExcelFile.xls b/assets/languages/ExcelFile.xls Binary files differnew file mode 100644 index 0000000..98cfe1d --- /dev/null +++ b/assets/languages/ExcelFile.xls diff --git a/assets/languages/json/Translations.json b/assets/languages/json/Translations.json new file mode 100644 index 0000000..400ab01 --- /dev/null +++ b/assets/languages/json/Translations.json @@ -0,0 +1,12 @@ +{ + "en": { + "langcode": "en", + "Hello": "Hello World!", + "Yes": "Yes" + }, + "fr": { + "langcode": "fr", + "Hello": "Bonjour à tous!", + "Yes": "Oui" + } +}
\ No newline at end of file diff --git a/assets/languages/json/de.json b/assets/languages/json/de.json new file mode 100644 index 0000000..443ad74 --- /dev/null +++ b/assets/languages/json/de.json @@ -0,0 +1,12 @@ +{ + "de": { + "Translator": "Marvin Borner", + "Reset all values": "Möchten Sie alle Angaben zurücksetzen?", + "Yes": "Ja", + "No": "Nein", + "Room temperature": "Raum Temperatur", + "Length": "Länge", + "Width": "Breite", + "Height": "Width" + } +} diff --git a/assets/languages/json/en.json b/assets/languages/json/en.json new file mode 100644 index 0000000..fc066df --- /dev/null +++ b/assets/languages/json/en.json @@ -0,0 +1,12 @@ +{ + "en": { + "Translator": "Marvin Borner", + "Reset all values": "Reset all values to default values?", + "Yes": "Yes", + "No": "No", + "Room temperature": "Room temperature", + "Length": "Length", + "Width": "Width", + "Height": "Height" + } +} diff --git a/assets/php/vendor/nubs/random-name-generator/build.php b/assets/php/vendor/nubs/random-name-generator/build.php index f285d55..f285d55 100755..100644 --- a/assets/php/vendor/nubs/random-name-generator/build.php +++ b/assets/php/vendor/nubs/random-name-generator/build.php diff --git a/assets/php/vendor/paragonie/random_compat/build-phar.sh b/assets/php/vendor/paragonie/random_compat/build-phar.sh index b4a5ba3..b4a5ba3 100755..100644 --- a/assets/php/vendor/paragonie/random_compat/build-phar.sh +++ b/assets/php/vendor/paragonie/random_compat/build-phar.sh diff --git a/assets/php/vendor/react/event-loop/travis-init.sh b/assets/php/vendor/react/event-loop/travis-init.sh index 29ce884..29ce884 100755..100644 --- a/assets/php/vendor/react/event-loop/travis-init.sh +++ b/assets/php/vendor/react/event-loop/travis-init.sh @@ -54,6 +54,7 @@ </div>
<div class="MainInTab">
<div class="ChatWindow">
+ <span data-lang='Hello'></span>
<div id="ChatResponses" class="ChatResponses"></div>
<input title="ChatTextInput" id="ChatTextInput" class="ChatInput" type="text"/>
<input title="SubscribeTextInput" id="SubscribeTextInput" class="ChatInput" type="text"/>
@@ -101,10 +102,21 @@ <img draggable="false" ondragstart="return false;" src="assets/icons/UserOutline.svg">
</span>
</div>
+ <span class='NavbarLine'></span>
</div>
+<script>
+ function initiateLanguage() {
+ var translate = new Translate();
+ var currentLng = 'fr'; // <- PHP IP LOCATION
+ translate.init(currentLng);
+ translate.process();
+ }
+</script>
+
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
+<script src="assets/js/language.js"></script>
<script src="assets/js/encryption.js"></script>
<script src="assets/js/chat.js"></script>
<script src="assets/js/main.js"></script>
|