From 64d26557a090b4f5bccb2d0d15c03e148f04f454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Fri, 6 Mar 2020 14:22:03 +0100 Subject: neki i18n js --- js/messaging.js | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'js/messaging.js') diff --git a/js/messaging.js b/js/messaging.js index 300da1b..9ec9410 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -1,7 +1,5 @@ const API_ENDPOINT = "https://gimb.tk/test.php"; const DIRECTORY_URL = "/directory.json"; -// const API_ENDPOINT = "http://localhost:5000/test.php"; - // "Global" object for name directory var directory = null; @@ -53,7 +51,7 @@ function loadDirectory() { localforage.getItem("directory").then((stored_directory) => { if (stored_directory === null) { // If unable, set directory to null (so other functions know that we don't have it) - M.toast({ html: "Name directory not set, sending unavailable" }); + UIAlert( D("nameDirectoryNotSet"), "loadDirectory(): stored_directory === null" ); directory = null; // Disable send button document.getElementById("msg-send").disabled = true; @@ -135,7 +133,7 @@ async function loadMessages(force_refresh = true, katera = 0) { success: (data) => { // If data is null, the request failed if (data === null) { - M.toast({ html: "Request failed!" }); + UIAlert( D("requestFailed") ); setLoading(false); } else { // Save messages & populate view @@ -149,7 +147,7 @@ async function loadMessages(force_refresh = true, katera = 0) { }, error: () => { - M.toast({ html: "Error fetching messages!" }); + UIAlert( D("errorFetchingMessages") ); setLoading(false); } @@ -189,7 +187,7 @@ async function loadMsg(id) { success: (data) => { // If data is null, the request failed if (data === null) { - M.toast({ html: "Unable to receive the message, Request failed!" }); + UIAlert( D("unableToReceiveTheMessage") + " " + D("requestFailed") ); setLoading(false); } else { displayMessage(id, data); @@ -198,7 +196,7 @@ async function loadMsg(id) { }, error: () => { - M.toast({ html: "Error fetching message, No Internet connnection?" }); + UIAlert( D("unableToReceiveTheMessage") + " " + D("noInternetConnection") ); setLoading(false); } @@ -233,7 +231,7 @@ async function deleteMsg(id) { success: (data) => { // If data is null, the request failed if (data === null) { - M.toast({ html: "Unable to delete the message, Request failed!" }); + UIAlert( D("unableToDeleteTheMessage") + " " + D("requestFailed") ); setLoading(false); } else { document.getElementById("msg_box-" + id).remove(); @@ -242,7 +240,7 @@ async function deleteMsg(id) { }, error: () => { - M.toast({ html: "Unable to delete the message, No Internet connnection?" }); + UIAlert( D("unableToDeleteTheMessage") + " " + D("noInternetConnection") ); setLoading(false); } @@ -254,12 +252,12 @@ function displayMessage(id, data) { if(data["telo"].substring(0, 21) == "