Commit e8952a96 authored by Neil Gershenfeld's avatar Neil Gershenfeld
Browse files

wip

parent 2ebe75cb
......@@ -34,7 +34,11 @@ function update() {
// name image by month, day, hour, minute
//
var date = new Date()
var name = ('0'+(1+parseInt(date.getMonth()))).slice(-2)+'-'+('0'+(1+parseInt(date.getDay()))).slice(-2)+'-'+('0'+date.getHours()).slice(-2)+'-'+('0'+date.getMinutes()).slice(-2)+'.jpg'
var month = 1+parseInt(date.getMonth())
var day = 1+parseInt(date.getDay())
var hour = parseInt(date.getHours())
var minute = parseInt(date.getMinutes())
var name = ('0'+month).slice(-2)+'-'+('0'+day).slice(-2)+'-'+('0'+hour).slice(-2)+'-'+('0'+minute).slice(-2)+'.jpg'
//
// remove prior image if it exists
//
......@@ -57,29 +61,22 @@ function update() {
else
console.log('no activity detected, delete image')
//
// rebuild index (could be done more efficiently incrementally)
// rebuild day's index
//
console.log('index')
execSync("rm -f index/*")
execSync("echo '<html><body>' > newindex.html")
for (var month = 1; month <= 12; ++month) {
for (var day = 1; day <= 31; ++day) {
execSync("echo '<a href=index/"+
('0'+month).slice(-2)+"-"+('0'+day).slice(-2)+".html>"+
('0'+month).slice(-2)+"-"+('0'+day).slice(-2)+
"</a>' >> newindex.html")
execSync("echo '<html><body>' > index/newindex.html")
execSync('ls images | awk \'/jpg/ { print "<a href=../images/"$1 "><img src=../thumbnails/" $1 "></a>" }\' >> index/newindex.html')
execSync("mv index/newindex.html index/"+
('0'+month).slice(-2)+"-"+('0'+day).slice(-2)+".html")
}
}
execSync('mv newindex.html index.html')
execSync("echo '<a href=index/"+
('0'+month).slice(-2)+"-"+('0'+day).slice(-2)+".html>"+
('0'+month).slice(-2)+"-"+('0'+day).slice(-2)+
"</a>' >> newindex.html")
execSync("echo '<html><body>' > index/newindex.html")
execSync('ls images | awk \'/jpg/ { print "<a href=../images/"$1 "><img src=../thumbnails/" $1 "></a>" }\' >> index/newindex.html')
execSync("mv index/newindex.html index/"+
('0'+month).slice(-2)+"-"+('0'+day).slice(-2)+".html")
oldsize = newsize
console.log('wait for next image')
}
//
// set one minute update interval
//
setInterval(update,60000)
setInterval(update,6000)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment