This commit is contained in:
2023-10-15 22:14:32 -04:00
parent a3ee24800c
commit 7f0dbc610f
4 changed files with 29 additions and 3 deletions

26
filechunker.js Normal file
View File

@@ -0,0 +1,26 @@
fs=require("fs")
class FileChunker {
constructor(fname) {
this.Chunks=[];
let Template=fs.readFileSync(fname).toString();
let pattern="<!-- INJECT -->";
let offset=0;
do {
let nextOffset=Template.indexOf(pattern,offset);
console.log("Nextoffset:"+nextOffset);
if (nextOffset>=0) {
this.Chunks.push(Template.substring(offset,nextOffset));
offset=nextOffset+pattern.length;
console.log("Offset:"+offset);
}
else {
this.Chunks.push(Template.substring(offset));
offset=-1;
}
} while (offset>0);
}
}
module.exports=FileChunker;

View File

@@ -26,7 +26,7 @@
<th> </th>
<th>Candidate</th>
</tr>
<!-- INJECT0 -->
<!-- INJECT -->
</table>
<br>

View File

@@ -27,7 +27,7 @@
<th style="width:50%"><span id="spanid"> </th>
<th>Happiness</th>
</tr>
<!-- INJECT0 -->
<!-- INJECT -->
</table>
<br>

View File

@@ -2,10 +2,10 @@ var express = require('express')
var bodyParser = require('body-parser')
var fs=require('fs')
var hashindex=require('hash-index')
var fc=require("./filechunker.js");
var app = express()
var Candidates=[
"Chris Christie",
"Donald Trump",