|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
const cheerio = require("cheerio");
|
|
|
|
|
const fs = require("fs");
|
|
|
|
|
const stores = require("./stores.json");
|
|
|
|
|
import { load } from "cheerio";
|
|
|
|
|
import { readFile, writeFile } from "fs";
|
|
|
|
|
import stores from "./stores.json" assert { type: "json" };
|
|
|
|
|
|
|
|
|
|
function TableViewTemplate(rows) {
|
|
|
|
|
table = "<table>";
|
|
|
|
|
let table = "<table>";
|
|
|
|
|
rows.forEach((row, key) => {
|
|
|
|
|
row.rowNumber = key;
|
|
|
|
|
table = table + TableRowTemplate(row);
|
|
|
|
@ -19,11 +19,11 @@ function TableRowTemplate({ rowNumber, name, address, city }) {
|
|
|
|
|
</tr>`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs.readFile("./index.html", function (err, data) {
|
|
|
|
|
readFile("./index.html", function (err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
throw err;
|
|
|
|
|
}
|
|
|
|
|
const $ = cheerio.load(data);
|
|
|
|
|
const $ = load(data);
|
|
|
|
|
|
|
|
|
|
stores.sort(function (a, b) {
|
|
|
|
|
var aname = a.name.toLowerCase();
|
|
|
|
@ -42,7 +42,7 @@ fs.readFile("./index.html", function (err, data) {
|
|
|
|
|
);
|
|
|
|
|
const cssurl = $("link[type='text/css']").attr("href").split("?")[0];
|
|
|
|
|
$("link[type='text/css']").attr("href", cssurl + "?" + new Date().getTime());
|
|
|
|
|
fs.writeFile("./index.html", $.html(), (err) => {
|
|
|
|
|
writeFile("./index.html", $.html(), (err) => {
|
|
|
|
|
if (err) throw err;
|
|
|
|
|
console.log("Default view updated.");
|
|
|
|
|
});
|
|
|
|
|