diff --git a/deployment.php b/deployment.php index 3f3a9de..b35cf8b 100644 --- a/deployment.php +++ b/deployment.php @@ -75,7 +75,7 @@ foreach ($remotes as $key => $value) { $config[$key]["before"] = []; } else { $env = isset($config[$key]["sentry_env"]) ? $config[$key]["sentry_env"] : "prod"; - $config[$key]["before"][] = "local: cd server/resources && npm i && npm run prod -- --env sentry_environment=".$env; + $config[$key]["before"][] = "local: cd server/resources && npm i && npm run prod -- --env sentryEnvironment=".$env; } if(isset($value["after"]) && $value["after"] === false){ $config[$key]["after"] = []; diff --git a/server/resources/config_sample.json b/server/resources/config_sample.json index 4148525..99b09d2 100644 --- a/server/resources/config_sample.json +++ b/server/resources/config_sample.json @@ -1,8 +1,8 @@ { - "sentry_enabled": false, - "sentry_dsn": "", - "sentry_environment": "prod", - "sentry_auth_token": "", - "sentry_organization": "", - "sentry_project": "" + "sentryEnabled": false, + "sentryDsn": "", + "sentryEnvironment": "prod", + "sentryAuthToken": "", + "sentryOrganization": "", + "sentryProject": "" } \ No newline at end of file diff --git a/server/resources/src/games.js b/server/resources/src/games.js index 14dd3ad..e2cd4a4 100644 --- a/server/resources/src/games.js +++ b/server/resources/src/games.js @@ -8,7 +8,7 @@ async function play (game) { const game = new Game(); $("body").append("
"); $("#modal_game_content").append(``); - $("#modal_game_body").append(`

Game by ${game.author}

`); + $("#modal_game_body").append(`

Game by ${game.author}

`); $("#modal_game").modal("show"); game.initialize($("#game_content")); }); diff --git a/server/resources/src/games/empty/game.js b/server/resources/src/games/empty/game.js index 2431c3f..19d38ff 100644 --- a/server/resources/src/games/empty/game.js +++ b/server/resources/src/games/empty/game.js @@ -2,7 +2,7 @@ export default class { constructor(){ this.title = "Empty game"; this.author = "Prova"; - this.author_url = "https://example.com/"; + this.authorUrl = "https://example.com/"; } initialize(container){ diff --git a/server/resources/src/games/ld46/game.js b/server/resources/src/games/ld46/game.js index 78aa95a..c6b3d6b 100644 --- a/server/resources/src/games/ld46/game.js +++ b/server/resources/src/games/ld46/game.js @@ -2,17 +2,17 @@ import {default as createUnityInstance} from './ld46.loader.js'; import build_size_data from './ld46.data.gz'; import buildSizeFramework from './ld46.framework.js.gz'; -import build_size_wasm from './ld46.wasm.gz'; +import buildSizeWasm from './ld46.wasm.gz'; console.log("data "+build_size_data); console.log("framework "+buildSizeFramework); -console.log("wasm "+build_size_wasm); +console.log("wasm "+buildSizeWasm); export default class { constructor(){ this.title = "What the firetruck"; this.author = "dvdfu"; - this.author_url = "https://github.com/dvdfu"; + this.authorUrl = "https://github.com/dvdfu"; } initialize(container){ diff --git a/server/resources/src/main.js b/server/resources/src/main.js index 709e03b..8bae0eb 100644 --- a/server/resources/src/main.js +++ b/server/resources/src/main.js @@ -150,10 +150,10 @@ var oldData = "null"; var tableEngine = "datatables"; var fillTable = undefined; -async function loadTable ({ tablePage, set_interval = true, interval = 10000, onlineReload = false, use_custom_tableEngine = false, callback = false }) { +async function loadTable ({ tablePage, setInterval = true, interval = 10000, onlineReload = false, useCustomTableEngine = false, callback = false }) { if (typeof fillTable === "undefined") { - if (use_custom_tableEngine !== false) { - tableEngine = use_custom_tableEngine; + if (useCustomTableEngine !== false) { + tableEngine = useCustomTableEngine; } else if ("connection" in navigator && navigator.connection.saveData) { tableEngine = "default"; } @@ -200,7 +200,7 @@ async function loadTable ({ tablePage, set_interval = true, interval = 10000, on }).fail(function (data, status) { if (status === "parsererror") { if ($("#table_body").children().length === 0) { // this is a server-side authentication error on some cheap hosting providers - loadTable(tablePage, set_interval, interval); // retry + loadTable(tablePage, setInterval, interval); // retry } // else nothing } else { caches.open("tables-1").then(cache => { @@ -218,13 +218,13 @@ async function loadTable ({ tablePage, set_interval = true, interval = 10000, on } } }); - if (set_interval) { + if (setInterval) { if ("connection" in navigator && navigator.connection.saveData) { interval += 5000; } console.log("table_load interval " + interval); window.loadTableInterval = setInterval(function () { - window.loadTable({ tablePage, set_interval: false, interval, onlineReload, use_custom_tableEngine, callback: false }); + window.loadTable({ tablePage, setInterval: false, interval, onlineReload, useCustomTableEngine, callback: false }); }, interval); } } diff --git a/server/resources/src/maps.js b/server/resources/src/maps.js index eacc066..4506aa1 100644 --- a/server/resources/src/maps.js +++ b/server/resources/src/maps.js @@ -22,7 +22,7 @@ let marker; let feature; let map; -function set_marker (LatLng) { +function setMarker (LatLng) { if (marker) { console.log("Marker exists"); // console.log(marker); @@ -35,17 +35,17 @@ function set_marker (LatLng) { marker = L.marker(LatLng, { icon: iconDefault }).addTo(map); } -function load_map (lat = undefined, lng = undefined, selector_id = undefined, select = true) { +function loadMap (lat = undefined, lng = undefined, selectorId = undefined, select = true) { if (lat === undefined && lng === undefined) { lat = 45.5285; // TODO: replace hard-coded into cookie reading lng = 10.2956; } - if (selector_id === undefined) { - selector_id = "map"; + if (selectorId === undefined) { + selectorId = "map"; } const zoom = select ? 10 : 17; const latLng = new L.LatLng(lat, lng); - map = new L.Map(selector_id, { zoomControl: true }); + map = new L.Map(selectorId, { zoomControl: true }); const osmUrl = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"; const osmAttribution = "Map data © 2012 OpenStreetMap contributors"; @@ -55,12 +55,12 @@ function load_map (lat = undefined, lng = undefined, selector_id = undefined, se if (select) { map.on("click", function (e) { - set_marker(e.latlng); + setMarker(e.latlng); }); L.Control.CustomLocate = L.Control.Locate.extend({ _drawMarker: function () { - set_marker(this._event.latlng); + setMarker(this._event.latlng); }, _onDrag: function () {}, _onZoom: function () {}, @@ -87,7 +87,7 @@ function load_map (lat = undefined, lng = undefined, selector_id = undefined, se console.log("Loading location from clipboard"); navigator.clipboard.readText().then(text => { $("#addr").val(text); - if (!addr_search()) { + if (!addrSearch()) { $("#addr").val(""); } }).catch(err => { @@ -97,25 +97,25 @@ function load_map (lat = undefined, lng = undefined, selector_id = undefined, se }); } } else { - set_marker(latLng); + setMarker(latLng); } map.invalidateSize(); } // from unknown source in the Internet -function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1 = undefined, lat2 = undefined, lng2 = undefined, osm_type = undefined) { +function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1 = undefined, lat2 = undefined, lng2 = undefined, osmType = undefined) { addrLat = addrLat.replace(",", "."); addrLng = addrLng.replace(",", "."); - if (lat1 !== undefined && lng1 !== undefined && lat2 !== undefined && lng2 !== undefined && osm_type !== undefined) { + if (lat1 !== undefined && lng1 !== undefined && lat2 !== undefined && lng2 !== undefined && osmType !== undefined) { const loc1 = new L.LatLng(lat1, lng1); const loc2 = new L.LatLng(lat2, lng2); const bounds = new L.LatLngBounds(loc1, loc2); - console.log(lat1, lng1, lat2, lng2, osm_type); - set_marker(new L.LatLng(addrLat, addrLng)); + console.log(lat1, lng1, lat2, lng2, osmType); + setMarker(new L.LatLng(addrLat, addrLng)); if (feature) { map.removeLayer(feature); } - if (osm_type === "node") { + if (osmType === "node") { map.fitBounds(bounds); map.setZoom(18); } else { @@ -127,7 +127,7 @@ function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1 } else if (addrLat !== undefined && addrLng !== undefined) { const loc = new L.LatLng(addrLat, addrLng); console.log(loc); - set_marker(loc); + setMarker(loc); if (zoom !== undefined) { map.setView(loc, zoom); } else { @@ -137,17 +137,17 @@ function chooseAddr (addrLat, addrLng, zoom = undefined, lat1 = undefined, lng1 } // started from https://derickrethans.nl/leaflet-and-nominatim.html -function addr_search (string_results_found = undefined, string_results_not_found = undefined) { +function addrSearch (string_results_found = undefined, stringResultsNotFound = undefined) { function searchError (error, checkClipboard) { if (!checkClipboard) { - $("

", { html: string_results_not_found }).appendTo("#results"); + $("

", { html: stringResultsNotFound }).appendTo("#results"); console.error(error); } return false; } let inp = document.getElementById("addr").value; // if translation strings are not defined, skip the nominatim step and don't log errors (no console.error) - const checkClipboard = string_results_found === undefined && string_results_not_found === undefined; + const checkClipboard = string_results_found === undefined && stringResultsNotFound === undefined; $("#results").empty(); if (inp.match("\@(-?[\d\.]*)")) { // Google Maps @@ -197,7 +197,7 @@ function addr_search (string_results_found = undefined, string_results_not_found html: items.join("") }).appendTo("#results"); } else { - $("

", { html: string_results_not_found }).appendTo("#results"); + $("

", { html: stringResultsNotFound }).appendTo("#results"); } }); } else { @@ -205,6 +205,6 @@ function addr_search (string_results_found = undefined, string_results_not_found } } -window.load_map = load_map; -window.addr_search = addr_search; +window.loadMap = loadMap; +window.addrSearch = addrSearch; window.chooseAddr = chooseAddr; diff --git a/server/resources/src/sentry.js b/server/resources/src/sentry.js index b4a5ba2..7923dc0 100644 --- a/server/resources/src/sentry.js +++ b/server/resources/src/sentry.js @@ -1,16 +1,16 @@ import * as Sentry from "@sentry/browser"; import { Integrations } from "@sentry/tracing"; -if (process.env.config && process.env.config.sentry_enabled) { +if (process.env.config && process.env.config.sentryEnabled) { if ("connection" in navigator && navigator.connection.saveData) { console.log("Skipping Sentry init because data save is enabled"); } else { Sentry.init({ - dsn: process.env.config.sentry_dsn, + dsn: process.env.config.sentryDsn, integrations: [new Integrations.BrowserTracing()], tracesSampleRate: 0.6, release: "allerta-vvf-frontend@" + process.env.GIT_VERSION, - environment: process.env.config.sentry_environment + environment: process.env.config.sentryEnvironment }); } } diff --git a/server/resources/src/sw.js b/server/resources/src/sw.js index 72fd029..5f5d81e 100644 --- a/server/resources/src/sw.js +++ b/server/resources/src/sw.js @@ -4,7 +4,7 @@ const expectedCaches = [cacheName, "tables-1"]; const urls = ["offline.php", "manifest.webmanifest", "resources/images/favicon.ico", "resources/dist/marker-icon.png", "resources/dist/layers.png", "resources/dist/layers-2x.png", "resources/images/android-chrome-192x192.png", "resources/images/android-chrome-384x384.png", "resources/images/black_helmet.png", "resources/images/red_helmet.png", "resources/images/wheel.png", "resources/images/logo.png", "resources/images/owner.png", "resources/dist/fonts/fontawesome-webfont.woff2"]; -function fetchHandler (event, content_type, not_found_message) { +function fetchHandler (event, contentType, notFoundMessage) { // TODO: refactoring console.log(event); @@ -79,10 +79,10 @@ self.addEventListener("install", (event) => { .then((response) => response.json()) .then((manifest) => { const scripts_required = ["main.js", "maps.js"]; - scripts_required.map((script_name) => { + scripts_required.map((scriptName) => { console.log(manifest); - console.log(script_name); - cache.add("resources/dist/" + manifest[script_name]); + console.log(scriptName); + cache.add("resources/dist/" + manifest[scriptName]); }); }); }) diff --git a/server/resources/src/table_engine_datatables.js b/server/resources/src/table_engine_datatables.js index 10cb821..23a1cce 100644 --- a/server/resources/src/table_engine_datatables.js +++ b/server/resources/src/table_engine_datatables.js @@ -15,9 +15,9 @@ pdfMake.vfs = pdfFonts.pdfMake.vfs; export default async function fillTable ({ data, replaceLatLngWithMap = false, callback = false }) { $("#table_body").empty(); - $.each(data, function (row_num, item) { + $.each(data, function (rowNum, item) { const row = document.createElement("tr"); - row.id = "row-" + row_num; + row.id = "row-" + rowNum; $.each(item, function (cell_num, i) { if (i !== null) { if (replaceLatLngWithMap && i.match(/[+-]?\d+([.]\d+)?[;][+-]?\d+([.]\d+)?/gm)) { /* credits to @visoom https://github.com/visoom */ @@ -25,9 +25,9 @@ export default async function fillTable ({ data, replaceLatLngWithMap = false, c const lng = i.split(";")[1]; const mapDiv = document.createElement("div"); mapDiv.className = "map"; - mapDiv.id = "map-" + row_num; + mapDiv.id = "map-" + rowNum; const mapScript = document.createElement("script"); - mapScript.appendChild(document.createTextNode("load_map(" + lat + ", " + lng + ", \"map-" + row_num + "\", false)")); + mapScript.appendChild(document.createTextNode("loadMap(" + lat + ", " + lng + ", \"map-" + rowNum + "\", false)")); mapDiv.appendChild(mapScript); const cell = document.createElement("td"); cell.appendChild(mapDiv); @@ -56,19 +56,19 @@ export default async function fillTable ({ data, replaceLatLngWithMap = false, c loadedLanguage = {}; } if (!$.fn.DataTable.isDataTable("#table")) { - var table_dt = $("#table").DataTable({ + var setableDt = $("#table").DataTable({ responsive: true, language: loadedLanguage, buttons: ["excel", "pdf", "csv"] }); - table_dt.buttons().container() + setableDt.buttons().container() .appendTo("#table_wrapper :nth-child(1):eq(0)"); if (callback !== false) { - callback(table_dt); + callback(setableDt); } } else { - table_dt.rows().invalidate(); + setableDt.rows().invalidate(); } - window.table_dt = table_dt; + window.setableDt = setableDt; } diff --git a/server/resources/src/table_engine_default.js b/server/resources/src/table_engine_default.js index 6a0f8f0..d39558e 100644 --- a/server/resources/src/table_engine_default.js +++ b/server/resources/src/table_engine_default.js @@ -1,8 +1,8 @@ export default async function fillTable ({ data, replaceLatLngWithMap = false, callback = false }) { $("#table_body").empty(); - $.each(data, function (row_num, item) { + $.each(data, function (rowNum, item) { const row = document.createElement("tr"); - row.id = "row-" + row_num; + row.id = "row-" + rowNum; $.each(item, function (cell_num, i) { if (i !== null) { if (replaceLatLngWithMap && i.match(/[+-]?\d+([.]\d+)?[;][+-]?\d+([.]\d+)?/gm)) { /* credits to @visoom https://github.com/visoom */ @@ -10,9 +10,9 @@ export default async function fillTable ({ data, replaceLatLngWithMap = false, c const lng = i.split(";")[1]; const mapDiv = document.createElement("div"); mapDiv.className = "map"; - mapDiv.id = "map-" + row_num; + mapDiv.id = "map-" + rowNum; const mapScript = document.createElement("script"); - mapScript.appendChild(document.createTextNode("load_map(" + lat + ", " + lng + ", \"map-" + row_num + "\", false)")); + mapScript.appendChild(document.createTextNode("loadMap(" + lat + ", " + lng + ", \"map-" + rowNum + "\", false)")); mapDiv.appendChild(mapScript); const cell = document.createElement("td"); cell.appendChild(mapDiv); diff --git a/server/resources/webpack.prod.js b/server/resources/webpack.prod.js index b24e183..fd23ebf 100644 --- a/server/resources/webpack.prod.js +++ b/server/resources/webpack.prod.js @@ -3,14 +3,14 @@ const common = require("./webpack.common.js"); const TerserPlugin = require("terser-webpack-plugin"); const SentryWebpackPlugin = require("@sentry/webpack-plugin"); const AfterBuildPlugin = require("@fiverr/afterbuild-webpack-plugin"); -const child_process = require("child_process"); +const childProcess = require("childProcess"); const InjectPlugin = require("webpack-inject-plugin").default; const colors = require("colors/safe"); const fs = require("fs"); const glob = require("glob"); function git(command) { - return child_process.execSync(`git ${command}`, { encoding: "utf8" }).trim(); + return childProcess.execSync(`git ${command}`, { encoding: "utf8" }).trim(); } var webpack = require("webpack"); @@ -45,12 +45,12 @@ const removeSourceMapUrlAfterBuild = () => { } var configFile = require("./config.json"); -const sentry_enabled = configFile.sentry_enabled && - configFile.sentry_auth_token && - configFile.sentry_organization && - configFile.sentry_project; +const sentryEnabled = configFile.sentryEnabled && + configFile.sentryAuthToken && + configFile.sentryOrganization && + configFile.sentryProject; -var prod_config = { +var prodConfig = { mode: "production", devtool: false, module: { @@ -75,31 +75,31 @@ var prod_config = { minimizer: [new TerserPlugin({ parallel: true, extractComments: true, - sourceMap: sentry_enabled ? true : false + sourceMap: sentryEnabled ? true : false })] } }; module.exports = (env) => { - //run webpack build with "--env sentry_environment=custom-sentry-env" to replace Sentry environment - if(env.sentry_environment){ - console.log(colors.green("INFO using custom sentry_environment "+env.sentry_environment)); - configFile.sentry_environment = env.sentry_environment; + //run webpack build with "--env sentryEnvironment=custom-sentry-env" to replace Sentry environment + if(env.sentryEnvironment){ + console.log(colors.green("INFO using custom sentryEnvironment "+env.sentryEnvironment)); + configFile.sentryEnvironment = env.sentryEnvironment; } - if(!configFile.sentry_environment){ - configFile.sentry_environment = "prod"; + if(!configFile.sentryEnvironment){ + configFile.sentryEnvironment = "prod"; } - if(sentry_enabled){ - prod_config.plugins.push( + if(sentryEnabled){ + prodConfig.plugins.push( new webpack.SourceMapDevToolPlugin({ filename: "[file].map" }), new SentryWebpackPlugin({ - authToken: configFile.sentry_auth_token, - org: configFile.sentry_organization, - project: configFile.sentry_project, + authToken: configFile.sentryAuthToken, + org: configFile.sentryOrganization, + project: configFile.sentryProject, urlPrefix: "~/dist", include: "./dist", setCommits: { @@ -117,7 +117,7 @@ module.exports = (env) => { console.log(colors.green("INFO Sentry Webpack plugins enabled")); } - prod_config.plugins.push( + prodConfig.plugins.push( new webpack.EnvironmentPlugin({ GIT_VERSION: git("describe --always"), GIT_AUTHOR_DATE: git("log -1 --format=%aI"), @@ -126,5 +126,5 @@ module.exports = (env) => { config: configFile }) ); - return merge(common, prod_config); + return merge(common, prodConfig); } \ No newline at end of file diff --git a/server/templates/edit_service.html b/server/templates/edit_service.html index 879db29..6a3bf14 100644 --- a/server/templates/edit_service.html +++ b/server/templates/edit_service.html @@ -82,12 +82,12 @@

- + {% else %} diff --git a/server/templates/edit_training.html b/server/templates/edit_training.html index 143613b..981b239 100644 --- a/server/templates/edit_training.html +++ b/server/templates/edit_training.html @@ -67,12 +67,12 @@
- + {% else %} diff --git a/server/templates/list.html b/server/templates/list.html index 130a5d3..3f08ba2 100644 --- a/server/templates/list.html +++ b/server/templates/list.html @@ -68,7 +68,7 @@ success: function (data) { toastr.success(`{{ 'Thanks, %s, you have given %s in case of alert.'|t|format(user.name, '${generate_alert_string(id)}') }}`); clearInterval(window.loadTableInterval); //stop reloading - loadTable({tablePage: "list", use_custom_tableEngine: "default"}); + loadTable({tablePage: "list", useCustomTableEngine: "default"}); } }); } @@ -85,7 +85,7 @@ success: function (data) { toastr.success(`{{ 'Thanks, %s, you have removed %s in case of alert.'|t|format(user.name, '${generate_alert_string(id)}') }}`); clearInterval(window.loadTableInterval); //stop reloading - loadTable({tablePage: "list", use_custom_tableEngine: "default"}); + loadTable({tablePage: "list", useCustomTableEngine: "default"}); } }); } @@ -114,7 +114,7 @@ diff --git a/server/templates/log.html b/server/templates/log.html index 517b666..b12f076 100644 --- a/server/templates/log.html +++ b/server/templates/log.html @@ -19,8 +19,8 @@