changes
This commit is contained in:
26
filechunker.js
Normal file
26
filechunker.js
Normal 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;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<th> </th>
|
<th> </th>
|
||||||
<th>Candidate</th>
|
<th>Candidate</th>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- INJECT0 -->
|
<!-- INJECT -->
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
<th style="width:50%"><span id="spanid"> </th>
|
<th style="width:50%"><span id="spanid"> </th>
|
||||||
<th>Happiness</th>
|
<th>Happiness</th>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- INJECT0 -->
|
<!-- INJECT -->
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ var express = require('express')
|
|||||||
var bodyParser = require('body-parser')
|
var bodyParser = require('body-parser')
|
||||||
var fs=require('fs')
|
var fs=require('fs')
|
||||||
var hashindex=require('hash-index')
|
var hashindex=require('hash-index')
|
||||||
|
var fc=require("./filechunker.js");
|
||||||
|
|
||||||
var app = express()
|
var app = express()
|
||||||
|
|
||||||
|
|
||||||
var Candidates=[
|
var Candidates=[
|
||||||
"Chris Christie",
|
"Chris Christie",
|
||||||
"Donald Trump",
|
"Donald Trump",
|
||||||
|
|||||||
Reference in New Issue
Block a user