new web page added and weather api key save added
This commit is contained in:
242
static/app.js
242
static/app.js
@@ -345,11 +345,11 @@ const addEventOnFeaturesList = () => {
|
||||
availableFeature.setAttribute("class", "");
|
||||
} else {
|
||||
availableFeature.setAttribute("class", "active");
|
||||
let getCustomImages = JSON.parse(
|
||||
localStorage.getItem("customImages")
|
||||
);
|
||||
let getCustomGifs = JSON.parse(localStorage.getItem("customGifs"));
|
||||
let getCustomMsg = JSON.parse(localStorage.getItem("customMsg"));
|
||||
// let getCustomImages = JSON.parse(
|
||||
// localStorage.getItem("customImages")
|
||||
// );
|
||||
// let getCustomGifs = JSON.parse(localStorage.getItem("customGifs"));
|
||||
// let getCustomMsg = JSON.parse(localStorage.getItem("customMsg"));
|
||||
|
||||
getCustomImages.map((value) => {
|
||||
let scrollSpeed1 = document.getElementById("inputScrollSpeed11");
|
||||
@@ -484,32 +484,35 @@ allFeaturesRemoveBtns.map((value, index) => {
|
||||
value.addEventListener("click", () => {
|
||||
for (let i = 0; i < allFeaturesList[index].length; i++) {
|
||||
var item = allFeaturesList[index][i];
|
||||
console.log(item);
|
||||
if (item.getAttribute("class") == "active") {
|
||||
if (item.parentElement.getAttribute("id") == "images-features") {
|
||||
let getImages = JSON.parse(localStorage.getItem("customImages"));
|
||||
// let getImages = JSON.parse(localStorage.getItem("customImages"));
|
||||
|
||||
let filter = getImages.filter(
|
||||
(value) => value.fileName !== item.innerText
|
||||
);
|
||||
localStorage.setItem("customImages", JSON.stringify(filter));
|
||||
// localStorage.setItem("customImages", JSON.stringify(filter));
|
||||
} else if (item.parentElement.getAttribute("id") == "gifs-features") {
|
||||
let getGifs = JSON.parse(localStorage.getItem("customGifs"));
|
||||
// let getGifs = JSON.parse(localStorage.getItem("customGifs"));
|
||||
|
||||
let filter = getGifs.filter(
|
||||
(value) => value.fileName !== item.innerText
|
||||
);
|
||||
localStorage.setItem("customGifs", JSON.stringify(filter));
|
||||
// localStorage.setItem("customGifs", JSON.stringify(filter));
|
||||
} else if (
|
||||
item.parentElement.getAttribute("id") == "messages-features"
|
||||
) {
|
||||
let getMsgs = JSON.parse(localStorage.getItem("customMsg"));
|
||||
// let getMsgs = JSON.parse(localStorage.getItem("customMsg"));
|
||||
|
||||
let filter = getMsgs.filter(
|
||||
(value) => value.messageName !== item.innerText
|
||||
);
|
||||
localStorage.setItem("customMsg", JSON.stringify(filter));
|
||||
// localStorage.setItem("customMsg", JSON.stringify(filter));
|
||||
}
|
||||
else {
|
||||
item.remove();
|
||||
}
|
||||
item.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -727,6 +730,26 @@ var allFeaturesTextAddBtn = [
|
||||
messagesTextAddBtn,
|
||||
];
|
||||
|
||||
|
||||
var allFeaturesLimit = [
|
||||
200,
|
||||
100,
|
||||
100,
|
||||
20,
|
||||
20,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
20,
|
||||
20,
|
||||
20,
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
allFeaturesTextAddBtn.map((value, index) => {
|
||||
if (value !== null) {
|
||||
value.addEventListener("click", () => {
|
||||
@@ -766,27 +789,45 @@ allFeaturesTextAddBtn.map((value, index) => {
|
||||
displayCheck,
|
||||
};
|
||||
|
||||
let getCustomMsg = localStorage.getItem("customMsg");
|
||||
// let getCustomMsg = localStorage.getItem("customMsg");
|
||||
|
||||
let newValues = getCustomMsg && JSON.parse(getCustomMsg);
|
||||
getCustomMsg && newValues.push(values);
|
||||
|
||||
getCustomMsg
|
||||
? localStorage.setItem("customMsg", JSON.stringify(newValues))
|
||||
: localStorage.setItem("customMsg", JSON.stringify([values]));
|
||||
// getCustomMsg
|
||||
// ? localStorage.setItem("customMsg", JSON.stringify(newValues))
|
||||
// : localStorage.setItem("customMsg", JSON.stringify([values]));
|
||||
var tag = document.createElement("li");
|
||||
tag.innerHTML = allFeaturesText[index].value;
|
||||
allFeatures[index].appendChild(tag);
|
||||
var msg = "You've reached the maximum limit of items to add for this feature";
|
||||
|
||||
// if the list length exceeds the limit
|
||||
if (allFeatures[index].getElementsByTagName("li").length == allFeaturesLimit[index]){
|
||||
document.getElementById("limit-msg").innerHTML = msg;
|
||||
}
|
||||
|
||||
else{
|
||||
tag.innerHTML = allFeaturesText[index].value;
|
||||
allFeatures[index].appendChild(tag);
|
||||
changeVarValue();
|
||||
addEventOnFeaturesList();
|
||||
}
|
||||
}
|
||||
changeVarValue();
|
||||
addEventOnFeaturesList();
|
||||
} else {
|
||||
var tag = document.createElement("li");
|
||||
tag.innerHTML = allFeaturesText[index].value;
|
||||
allFeatures[index].appendChild(tag);
|
||||
changeVarValue();
|
||||
addEventOnFeaturesList();
|
||||
}
|
||||
var msg = "You've reached the maximum limit of items to add for this feature";
|
||||
|
||||
// if the list length exceeds the limit
|
||||
if (allFeatures[index].getElementsByTagName("li").length > allFeaturesLimit[index]){
|
||||
document.getElementById("limit-msg").innerHTML = msg;
|
||||
}
|
||||
|
||||
else{
|
||||
var tag = document.createElement("li");
|
||||
tag.innerHTML = allFeaturesText[index].value;
|
||||
allFeatures[index].appendChild(tag);
|
||||
changeVarValue();
|
||||
addEventOnFeaturesList();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -794,11 +835,9 @@ allFeaturesTextAddBtn.map((value, index) => {
|
||||
var startButton = document.getElementById("start-btn");
|
||||
// start the display
|
||||
startButton.addEventListener("click", () => {
|
||||
|
||||
fetch("/start", {
|
||||
method: "PUT",
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
var brightnessButton = document.getElementById("brightness-btn");
|
||||
@@ -819,6 +858,16 @@ shutdownButton.addEventListener("click", () => {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var restartButton = document.getElementById("restart-btn");
|
||||
|
||||
restartButton.addEventListener("click", () => {
|
||||
fetch("/restart", {
|
||||
method: "GET",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var stopButton = document.getElementById("stop-btn");
|
||||
stopButton.addEventListener("click", () => {
|
||||
fetch("/stop", {
|
||||
@@ -910,13 +959,9 @@ function getDisplaying(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
// gets feature specific settings
|
||||
function getFeatureSettings() {
|
||||
|
||||
function get_page(){
|
||||
let featureSelector = document.getElementById("drop");
|
||||
feature = getSelected(featureSelector);
|
||||
|
||||
let features = [
|
||||
"Stocks",
|
||||
"Crypto",
|
||||
@@ -936,6 +981,13 @@ function getFeatureSettings() {
|
||||
let pageSelector = "Page" + pageNum.toString();
|
||||
|
||||
let page = document.getElementById(pageSelector);
|
||||
return page;
|
||||
}
|
||||
|
||||
// gets feature specific settings
|
||||
function getFeatureSettings() {
|
||||
|
||||
let page = get_page();
|
||||
|
||||
// these common to all settings
|
||||
let speed = getSelected(page.querySelectorAll(".speed-select")[0]);
|
||||
@@ -1021,7 +1073,7 @@ function saveSettings() {
|
||||
}
|
||||
|
||||
|
||||
let saveSettingsButtons = document.querySelectorAll(".save-btn-div").forEach((button) => button.addEventListener("click", saveSettings));
|
||||
let saveSettingsButtons = document.querySelectorAll(".save-btn").forEach((button) => button.addEventListener("click", saveSettings));
|
||||
|
||||
// gets the stock, crypto or forex specific settings
|
||||
function getTradingSettings(page) {
|
||||
@@ -1029,7 +1081,6 @@ function getTradingSettings(page) {
|
||||
let percent = page.querySelectorAll(".percent-select")[0].checked;
|
||||
let point = page.querySelectorAll(".point-select")[0].checked;
|
||||
let no_logos = page.querySelectorAll(".logo-select")[0].checked;
|
||||
let chart = page.querySelectorAll(".chart-select")[0].checked;
|
||||
let title = page.querySelectorAll(".title-select")[0].checked;
|
||||
|
||||
let symbols_el = page.querySelectorAll(".symbol-list")[0];
|
||||
@@ -1039,7 +1090,6 @@ function getTradingSettings(page) {
|
||||
percent: percent,
|
||||
point: point,
|
||||
logos: no_logos,
|
||||
chart: chart,
|
||||
title: title,
|
||||
symbols: symbols,
|
||||
};
|
||||
@@ -1053,11 +1103,14 @@ function getWeatherSettings(page) {
|
||||
let speed = getSelected(page.querySelectorAll(".wind-speed-select")[0]);
|
||||
|
||||
let title = page.querySelectorAll(".title-select")[0].checked;
|
||||
let api_key = page.querySelectorAll(".api-key")[0];
|
||||
|
||||
let
|
||||
settings = {
|
||||
temp: temp,
|
||||
wind_speed: speed,
|
||||
title: title,
|
||||
api_key:api_key
|
||||
};
|
||||
|
||||
//only for daily weather
|
||||
@@ -1074,19 +1127,41 @@ function getWeatherSettings(page) {
|
||||
return settings;
|
||||
}
|
||||
|
||||
function saveWeatherAPIKey(){
|
||||
let page = get_page();
|
||||
|
||||
let api_key = page.querySelectorAll(".api-key")[0].value;
|
||||
let settings = {
|
||||
api_key:api_key
|
||||
};
|
||||
|
||||
console.log(settings);
|
||||
|
||||
fetch("/saveWeatherAPIKey", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(settings),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var weatherAPIbtn = document.getElementById("weather-api-btn");
|
||||
weatherAPIbtn.addEventListener("click", saveWeatherAPIKey);
|
||||
|
||||
function getNewsSettings(page) {
|
||||
let country = getSelected(page.querySelectorAll(".country-select")[0]);
|
||||
let category = getSelected(page.querySelectorAll(".category-select")[0]);
|
||||
let title = page.querySelectorAll(".title-select")[0].checked;
|
||||
let use_sources = page.querySelectorAll(".sources-select")[0].checked;
|
||||
// let use_sources = page.querySelectorAll(".sources-select")[0].checked;
|
||||
|
||||
let sources_el = page.querySelectorAll(".sources-list")[0];
|
||||
let sources = getListItems(sources_el);
|
||||
// let sources_el = page.querySelectorAll(".sources-list")[0];
|
||||
// let sources = getListItems(sources_el);
|
||||
settings = {
|
||||
country: country,
|
||||
category: category,
|
||||
title: title,
|
||||
use_sources: use_sources,
|
||||
// use_sources: use_sources,
|
||||
sources: sources,
|
||||
};
|
||||
return settings;
|
||||
@@ -1111,7 +1186,7 @@ allFeaturesFileAddBtn.map((value, index) => {
|
||||
var tag = document.createElement("li");
|
||||
tag.innerHTML = allFeaturesFile[index].files[0].name;
|
||||
if (index == 10) {
|
||||
let getCustomImg = localStorage.getItem("customImages");
|
||||
// let getCustomImg = localStorage.getItem("customImages");
|
||||
let fileName = imagesFile.files[0].name;
|
||||
let scrollSpeed = document.getElementById("inputScrollSpeed11").value;
|
||||
let scrollSpeed2 = document.getElementById(
|
||||
@@ -1141,15 +1216,15 @@ allFeaturesFileAddBtn.map((value, index) => {
|
||||
let newValues = getCustomImg && JSON.parse(getCustomImg);
|
||||
getCustomImg && newValues.push(values);
|
||||
|
||||
getCustomImg
|
||||
? localStorage.setItem("customImages", JSON.stringify(newValues))
|
||||
: localStorage.setItem("customImages", JSON.stringify([values]));
|
||||
// getCustomImg
|
||||
// ? localStorage.setItem("customImages", JSON.stringify(newValues))
|
||||
// : localStorage.setItem("customImages", JSON.stringify([values]));
|
||||
|
||||
uploaded_images.push(allFeaturesFile[index].files[0]);
|
||||
allFeatures[index].appendChild(tag);
|
||||
}
|
||||
} else if (index == 11) {
|
||||
let getCustomGifs = localStorage.getItem("customGifs");
|
||||
// let getCustomGifs = localStorage.getItem("customGifs");
|
||||
let fileName = allFeaturesFile[index].files[0].name;
|
||||
let scrollSpeed = document.getElementById("inputScrollSpeed12").value;
|
||||
let scrollSpeed2 = document.getElementById(
|
||||
@@ -1179,15 +1254,15 @@ allFeaturesFileAddBtn.map((value, index) => {
|
||||
let newValues = getCustomGifs && JSON.parse(getCustomGifs);
|
||||
getCustomGifs && newValues.push(values);
|
||||
|
||||
getCustomGifs
|
||||
? localStorage.setItem("customGifs", JSON.stringify(newValues))
|
||||
: localStorage.setItem("customGifs", JSON.stringify([values]));
|
||||
// getCustomGifs
|
||||
// ? localStorage.setItem("customGifs", JSON.stringify(newValues))
|
||||
// : localStorage.setItem("customGifs", JSON.stringify([values]));
|
||||
|
||||
uploaded_GIFs.push(allFeaturesFile[index].files[0]);
|
||||
allFeatures[index].appendChild(tag);
|
||||
}
|
||||
}
|
||||
|
||||
imagesFile.value = "";
|
||||
changeVarValue();
|
||||
addEventOnFeaturesList();
|
||||
});
|
||||
@@ -1273,23 +1348,23 @@ let countryCodeInput = document.getElementById("country-code-input");
|
||||
let joinNetworkBtn = document.querySelector("#join-network-btn");
|
||||
let connectedText = document.querySelector("#connected-text");
|
||||
|
||||
joinNetworkBtn.addEventListener("click", () => {
|
||||
localStorage.setItem("wifiSsid", wifiSsidInput.value);
|
||||
localStorage.setItem("wifiPass", wifiPassInput.value);
|
||||
localStorage.setItem("countryCode", countryCodeInput.value);
|
||||
// joinNetworkBtn.addEventListener("click", () => {
|
||||
// localStorage.setItem("wifiSsid", wifiSsidInput.value);
|
||||
// localStorage.setItem("wifiPass", wifiPassInput.value);
|
||||
// localStorage.setItem("countryCode", countryCodeInput.value);
|
||||
|
||||
connectedText.style.display = "block";
|
||||
setTimeout(() => {
|
||||
connectedText.style.display = "none";
|
||||
}, 2000);
|
||||
// connectedText.style.display = "block";
|
||||
// setTimeout(() => {
|
||||
// connectedText.style.display = "none";
|
||||
// }, 2000);
|
||||
|
||||
data = {country:countryCodeInput.value, ssid:wifiSsidInput.value, pwd:wifiPassInput.value}
|
||||
// data = {country:countryCodeInput.value, ssid:wifiSsidInput.value, pwd:wifiPassInput.value}
|
||||
|
||||
fetch("/wifi", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
});
|
||||
// fetch("/wifi", {
|
||||
// method: "POST",
|
||||
// body: JSON.stringify(data),
|
||||
// });
|
||||
// });
|
||||
|
||||
// change display format
|
||||
let displayFormatDropDown = document.querySelector("#inputDisplayFormat");
|
||||
@@ -1332,7 +1407,7 @@ let hostNameText = document.getElementById("host-name");
|
||||
|
||||
hostNameBtn.addEventListener("click", () => {
|
||||
hostNameText.innerText = hostNameInput.value;
|
||||
localStorage.setItem("hostName", hostNameText.innerText);
|
||||
// localStorage.setItem("hostName", hostNameText.innerText);
|
||||
|
||||
data = {hostname:hostNameText.innerText}
|
||||
|
||||
@@ -1342,13 +1417,30 @@ hostNameBtn.addEventListener("click", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Add Weather API Key
|
||||
|
||||
// let weatherKeyInput = document.getElementById("api-key");
|
||||
// let weatherKeyBtn = document.getElementById("weather-api-button");
|
||||
// let inputTextWeather = document.getElementById("inputText-weather");
|
||||
|
||||
// weatherKeyBtn.addEventListener("click", () => {
|
||||
// inputTextWeather.innerText = weatherKeyInput.value;
|
||||
// data = {api-key:inputTextWeather.innerText}
|
||||
|
||||
// fetch("/weatherAPI", {
|
||||
// method: "POST",
|
||||
// body: JSON.stringify(data),
|
||||
// });
|
||||
// });
|
||||
|
||||
|
||||
// change brightness
|
||||
|
||||
let brightnessInput = document.getElementById("brightness-input");
|
||||
let brightnessBtn = document.getElementById("brightness-btn");
|
||||
|
||||
brightnessBtn.addEventListener("click", () => {
|
||||
localStorage.setItem("brightness", brightnessInput.value);
|
||||
// localStorage.setItem("brightness", brightnessInput.value);
|
||||
});
|
||||
|
||||
// change input animation
|
||||
@@ -1372,16 +1464,16 @@ for (let i = 1; i <= 13; i++) {
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
let getHostName = localStorage.getItem("hostName");
|
||||
let getBrightness = localStorage.getItem("brightness");
|
||||
let getWifiSsid = localStorage.getItem("wifiSsid");
|
||||
let getWifiPass = localStorage.getItem("wifiPass");
|
||||
let getCountryCode = localStorage.getItem("countryCode");
|
||||
let getInputAnimation = localStorage.getItem("inputAnimation");
|
||||
// let getHostName = localStorage.getItem("hostName");
|
||||
// let getBrightness = localStorage.getItem("brightness");
|
||||
// let getWifiSsid = localStorage.getItem("wifiSsid");
|
||||
// let getWifiPass = localStorage.getItem("wifiPass");
|
||||
// let getCountryCode = localStorage.getItem("countryCode");
|
||||
// let getInputAnimation = localStorage.getItem("inputAnimation");
|
||||
|
||||
getHostName &&
|
||||
(hostNameText.innerText = getHostName) &&
|
||||
(hostNameInput.value = getHostName);
|
||||
// getHostName &&
|
||||
// (hostNameText.innerText = getHostName) &&
|
||||
// (hostNameInput.value = getHostName);
|
||||
|
||||
//getBrightness && (brightnessInput.value = getBrightness);
|
||||
//getWifiSsid && (wifiSsidInput.value = getWifiSsid);
|
||||
|
Reference in New Issue
Block a user