Additional Code-Cleanup

closes #2
- removed constant cache variable in server.js
- renamed second data variable in script.js
- removed variable vueApp in data.js
pull/4/head
Trivernis 6 years ago
parent 2b7c88596a
commit 3a0cfef640

@ -7,7 +7,7 @@ function bindData(){
let mods = $('model'); let mods = $('model');
mods.each(function(){ mods.each(function(){
let model = $(this); let model = $(this);
if (model.attr('refresh-interval') != undefined) { if (model.attr('refresh-interval') !== undefined) {
bindModelData(model); bindModelData(model);
setInterval(()=> { bindModelData(model) }, model.attr('refresh-interval')); setInterval(()=> { bindModelData(model) }, model.attr('refresh-interval'));
} }
@ -19,8 +19,8 @@ function bindModelData(model) {
$.get(model.attr('src'), function(data) { $.get(model.attr('src'), function(data) {
$('*[model='+model.attr('name')+']').each(function() { $('*[model='+model.attr('name')+']').each(function() {
let elem = $(this); let elem = $(this);
let data = getDataByPath(JSON.parse(data), elem.attr('datapath')); let dat = getDataByPath(JSON.parse(data), elem.attr('datapath'));
this.setAttribute(":data", data); this.setAttribute(":data", dat);
//elem.html(); //elem.html();
}) })
}); });
@ -28,7 +28,7 @@ function bindModelData(model) {
/** /**
* Returns the data of an array by accessing the given path-string * Returns the data of an array by accessing the given path-string
* @param {JSON-Object} array Contains the data. * @param {Object} array Contains the data.
* @param {String} path The path to the wanted data. * @param {String} path The path to the wanted data.
* @return {Object} Returns anything that the path points to. * @return {Object} Returns anything that the path points to.
*/ */

@ -1,14 +1,12 @@
{ {
"license": "GPL-v3", "license": "GPL-v3",
"dependencies": [ "dependencies": {
"args-parser", "args-parser": "^1.1.0",
"https", "jquery": "^3.3.1",
"jquery", "jsdom": "^12.2.0",
"jsdom", "node-sass": "^4.9.3",
"node-sass", "perfy": "^1.1.5",
"perfy", "winston-daily-rotate-file": "^3.3.3",
"vuejs", "winston": "^3.1.0"
"winston-daily-rotate-file", }
"winston"
]
} }

@ -1,13 +1,13 @@
function getFormattedData(dataArray) { function getFormattedData(dataArray) {
let arrData = ["0,100"]; let arrData = ["0,100"];
for (d of dataArray) { for (let d of dataArray) {
arrData.push(d[0]+","+(100-d[1])); arrData.push(d[0]+","+(100-d[1]));
} }
arrData.push("100,100"); arrData.push("100,100");
return arrData.join(" "); return arrData.join(" ");
} }
var vueApp = new Vue({ new Vue({
el: '#app', el: '#app',
data: { data: {
temperatureData: [1,2,3,4], temperatureData: [1,2,3,4],

@ -74,8 +74,7 @@ const https = require('https'),
"mime": "text/javascript" "mime": "text/javascript"
} }
}, },
mounts = config.mounts, // mounts are more important than routes. mounts = config.mounts; // mounts are more important than routes.
cache = {}; // cache stores filenames for cached processed files
// --- functional declaration part --- // --- functional declaration part ---

Loading…
Cancel
Save