X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fresources%2Fstatic%2Fjavascript%2Fsone.js;h=05ab5a00480736d293510bd9e332f356d16351cd;hb=1b1f5f1907fb307abd9f94cf3a1f9a2ee247c8d1;hp=66314e1982479094f66cf3d23364fcbaa55632af;hpb=873af59aa0b0af826933e09e2843de30bdb044a8;p=Sone.git diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 66314e1..05ab5a0 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -112,6 +112,17 @@ function getSoneStatus(soneId) { } /** + * Filters the given Sone ID, replacing all “~” characters by an underscore. + * + * @param soneId + * The Sone ID to filter + * @returns The filtered Sone ID + */ +function filterSoneId(soneId) { + return soneId.replace(/[^a-zA-Z0-9-]/g, "_"); +} + +/** * Updates the status of the given Sone. * * @param soneId @@ -125,14 +136,14 @@ function getSoneStatus(soneId) { * The date and time of the last update (formatted for display) */ function updateSoneStatus(soneId, name, status, modified, lastUpdated) { - $("#sone .sone." + soneId). + $("#sone .sone." + filterSoneId(soneId)). toggleClass("unknown", status == "unknown"). toggleClass("idle", status == "idle"). toggleClass("inserting", status == "inserting"). toggleClass("downloading", status == "downloading"). toggleClass("modified", modified); - $("#sone .sone." + soneId + " .last-update span.time").text(lastUpdated); - $("#sone .sone." + soneId + " .profile-link a").text(name); + $("#sone .sone." + filterSoneId(soneId) + " .last-update span.time").text(lastUpdated); + $("#sone .sone." + filterSoneId(soneId) + " .profile-link a").text(name); } var watchedSones = {};