Mercurial > hg > nodescore
changeset 12:d2eda8be1fca
add phantomjs dependency for thumbnail preview generation
author | tzara <rc-web@kiben.net> |
---|---|
date | Sun, 08 Jul 2012 23:51:17 +0100 |
parents | 0a8133490050 |
children | 471303a5af32 |
files | rasterize.js www/m/js/client.js www/m/js/nodescore-client.js |
diffstat | 3 files changed, 128 insertions(+), 95 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rasterize.js Sun Jul 08 23:51:17 2012 +0100 @@ -0,0 +1,33 @@ +var page = require('webpage').create(), + system = require('system'), + address, output, size; + +page.clipRect = { top: 70, left: 0, width: 1280, height: 800 } + +if (system.args.length < 3 || system.args.length > 5) { + console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]'); + console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"'); + phantom.exit(1); +} else { + address = system.args[1]; + output = system.args[2]; + page.viewportSize = { width: 800, height: 800 }; + if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") { + size = system.args[3].split('*'); + page.paperSize = size.length === 2 ? { width: size[0], height: size[1], margin: '0px' } + : { format: system.args[3], orientation: 'portrait', margin: '1cm' }; + } + if (system.args.length > 4) { + page.zoomFactor = system.args[4]; + } + page.open(address, function (status) { + if (status !== 'success') { + console.log('Unable to load the address!'); + } else { + window.setTimeout(function () { + page.render(output); + phantom.exit(); + }, 200); + } + }); +}
--- a/www/m/js/client.js Sat Jul 07 07:10:56 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -///////////////////////////////////////////////// -// connect to websocket - -var socket = io.connect(); - -//socket.on("metroPulse", metronomeTick); -///////////////////////////////////////////////// -socket.on("metroPulse", pulseInClient); -function pulseInClient(pulse,groupID,metrobeat){ - var groupPage=document.getElementById('group').value - if (groupID == groupPage) { - metronomeTick(1000, groupID, metrobeat); - } -} -///////////////////////////////////////////////// -function metroCss(beat, beatcolor,text){ - var color = beatcolor; - - $(".metrocase > div").each(function(){$(this).stop()}); - $(".metrocase > div").each(function(){$(this).css('background-color', beatcolor)}); - $(".metrocase > div").each(function(){$(this).text(" ")}); - $(".metrocase > div").each(function(){$(this).animate({opacity: 0.5}, - 50, - function() { $(this).animate({opacity:0.0}); } - ); - }) - } - - - -function metronomeTick(pulse, voice,metrobeat) { - console.log( voice+ " metronome tick" + metrobeat) - var color = "gray" - - metroCss(0, "red", "4") - -//if (metrobeat == 0) { -// metroCss(0, "gray", "1") - // } - - //if (metrobeat == 3) { -// metroCss(0, "white", "4") - // } - -// if (metrobeat == 1||metrobeat == 2){ -// $("#metronome"+metrobeat).stop(); -// $("#metronome"+metrobeat).css('background-color', color); -// $("#metronome"+metrobeat).text(" "); - //$("#metronome"+metrobeat).text(metrobeat+1); -// $("#metronome"+metrobeat).animate({opacity: 1}, -// 50, - // function() { $(this).animate({opacity:0.0}); } -// ); - // } -}; - -///////////////////////////////////////////////// - -// update the stopwatch value on the client page in line with server -socket.on("chronFromServer", function(chron) { - $("div#client_chronometer").text(chron); -}); - -///////////////////////////////////////////////// - -function pageFlip(unit) { - console.log("flipping page:"+ unit); - $('#sections').trigger('goto', [parseFloat(unit)]); - //metroStart(1000); - //document.getElementById("countdowncase").style.visibility="hidden"; -} - -///////////////////////////////////////////////// -// call the fancy jquery functions - -function slideTo (target) { $('#sections').trigger('goto', [target]); } -function pad2(number) { return (number < 10 ? '0' : '') + number } - -///////////////////////////////////////////////// - -socket.on("pageFlipfromserver", pageTurn); -function pageTurn (group,unit,time,mm) { - var groupPage=document.getElementById('group').value; - console.log("fromservercommand has been executed on client"); - if (group == groupPage) { - var g= pad2(group); - var p= pad2(unit); - pageFlip(unit); - } - else { - console.log("not for this group... ignoring... for group:" + group ); - } -} - -///////////////////////////////////////////////// \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/m/js/nodescore-client.js Sun Jul 08 23:51:17 2012 +0100 @@ -0,0 +1,95 @@ +///////////////////////////////////////////////// +// connect to websocket + +var socket = io.connect(); + +//socket.on("metroPulse", metronomeTick); +///////////////////////////////////////////////// +socket.on("metroPulse", pulseInClient); +function pulseInClient(pulse,groupID,metrobeat){ + var groupPage=document.getElementById('group').value + if (groupID == groupPage) { + metronomeTick(1000, groupID, metrobeat); + } +} +///////////////////////////////////////////////// +function metroCss(beat, beatcolor,text){ + var color = beatcolor; + + $(".metrocase > div").each(function(){$(this).stop()}); + $(".metrocase > div").each(function(){$(this).css('background-color', beatcolor)}); + $(".metrocase > div").each(function(){$(this).text(" ")}); + $(".metrocase > div").each(function(){$(this).animate({opacity: 0.5}, + 50, + function() { $(this).animate({opacity:0.0}); } + ); + }) + } + + + +function metronomeTick(pulse, voice,metrobeat) { + console.log( voice+ " metronome tick" + metrobeat) + var color = "gray" + + metroCss(0, "red", "4") + +//if (metrobeat == 0) { +// metroCss(0, "gray", "1") + // } + + //if (metrobeat == 3) { +// metroCss(0, "white", "4") + // } + +// if (metrobeat == 1||metrobeat == 2){ +// $("#metronome"+metrobeat).stop(); +// $("#metronome"+metrobeat).css('background-color', color); +// $("#metronome"+metrobeat).text(" "); + //$("#metronome"+metrobeat).text(metrobeat+1); +// $("#metronome"+metrobeat).animate({opacity: 1}, +// 50, + // function() { $(this).animate({opacity:0.0}); } +// ); + // } +}; + +///////////////////////////////////////////////// + +// update the stopwatch value on the client page in line with server +socket.on("chronFromServer", function(chron) { + $("div#client_chronometer").text(chron); +}); + +///////////////////////////////////////////////// + +function pageFlip(unit) { + console.log("flipping page:"+ unit); + $('#sections').trigger('goto', [parseFloat(unit)]); + //metroStart(1000); + //document.getElementById("countdowncase").style.visibility="hidden"; +} + +///////////////////////////////////////////////// +// call the fancy jquery functions + +function slideTo (target) { $('#sections').trigger('goto', [target]); } +function pad2(number) { return (number < 10 ? '0' : '') + number } + +///////////////////////////////////////////////// + +socket.on("pageFlipfromserver", pageTurn); +function pageTurn (group,unit,time,mm) { + var groupPage=document.getElementById('group').value; + console.log("fromservercommand has been executed on client"); + if (group == groupPage) { + var g= pad2(group); + var p= pad2(unit); + pageFlip(unit); + } + else { + console.log("not for this group... ignoring... for group:" + group ); + } +} + +///////////////////////////////////////////////// \ No newline at end of file