2022-03-19 15:45:05 +00:00
|
|
|
const cheerio = require("cheerio");
|
2022-03-19 19:06:14 +00:00
|
|
|
const mustache = require("./js/mustache.4.1.0.js");
|
2022-03-19 15:45:05 +00:00
|
|
|
const fs = require("fs");
|
|
|
|
const stores = require("./stores.json");
|
2017-05-28 22:54:01 +00:00
|
|
|
|
2022-03-19 15:45:05 +00:00
|
|
|
fs.readFile("./index.html", function (err, data) {
|
|
|
|
if (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
2017-05-28 22:54:01 +00:00
|
|
|
const $ = cheerio.load(data);
|
|
|
|
|
2022-03-19 15:45:05 +00:00
|
|
|
stores.sort(function (a, b) {
|
|
|
|
var aname = a.name.toLowerCase();
|
|
|
|
var bname = b.name.toLowerCase();
|
|
|
|
return aname === bname ? 0 : +(aname > bname) || -1;
|
|
|
|
});
|
2017-05-28 22:54:01 +00:00
|
|
|
|
2022-03-19 15:45:05 +00:00
|
|
|
$("#Stores").html(mustache.render($("#Table").html(), { rows: stores }));
|
|
|
|
$("#storeCount").html(stores.length);
|
2022-03-19 20:28:26 +00:00
|
|
|
$("#updatedOn").html(
|
|
|
|
new Date().toLocaleDateString("en-US", {
|
|
|
|
year: "numeric",
|
|
|
|
month: "long",
|
|
|
|
day: "numeric",
|
|
|
|
})
|
|
|
|
);
|
2022-03-20 14:43:25 +00:00
|
|
|
const cssurl = $("link[type='text/css']").attr("href");
|
|
|
|
$("link[type='text/css']").attr("href", cssurl + "?" + new Date().getTime());
|
2022-03-19 15:45:05 +00:00
|
|
|
fs.writeFile("./index.html", $.html(), (err) => {
|
2017-05-28 22:54:01 +00:00
|
|
|
if (err) throw err;
|
2022-03-19 15:45:05 +00:00
|
|
|
console.log("Default view updated.");
|
2017-05-28 22:54:01 +00:00
|
|
|
});
|
2022-03-19 15:45:05 +00:00
|
|
|
});
|