diff --git a/app.js b/app.js new file mode 100644 index 0000000..66a6652 --- /dev/null +++ b/app.js @@ -0,0 +1,38 @@ +/*var app = require('express').createServer(); +app.get('/', function(req, res) { + res.send('Hello from AppFog.com'); +}); +app.listen(process.env.VCAP_APP_PORT || 3000);*/ + + +var express = require('express'), path = require('path'), http = require('http'); +var app = express(); +app.configure(function() { + app.set('port', process.env.VCAP_APP_PORT || 3000); + app.use(express.logger('dev')); + /* 'default', 'short', 'tiny', 'dev' */ + app.use(express.methodOverride()); + app.use(express.bodyParser()); + app.use(function(req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "X-Requested-With"); + next(); + }); + app.use(app.router); + app.use(express.static(path.join(__dirname, 'www'))); +app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); +}); + + +/** + * Routing handlers + */ + + +/** + * create the server + */ +http.createServer(app).listen(app.get('port'), function() { + console.log("Express server listening on port " + app.get('port')); +}); + diff --git a/app/Robots.txt b/app/Robots.txt new file mode 100644 index 0000000..4e0bfc5 --- /dev/null +++ b/app/Robots.txt @@ -0,0 +1,2 @@ +User-Agent: * +Disallow: / \ No newline at end of file diff --git a/app/app.js b/app/app.js new file mode 100644 index 0000000..db9ccdb --- /dev/null +++ b/app/app.js @@ -0,0 +1,301 @@ +(function () { + + var lastGBP = 0.0, + lastUSD = 0.0, + _fasttimer, _slowTimer, myBTC =3.49524333; + var lows = { + gbp: 0, + usd: 0 + }, + highs = { + gbp: 0, + usd: 0 + }; + + + var list = [{ + title: '101B ends', + y: 2013, + m: 9, + d: 24, + add: 1001 + }, + { + title: 'Ends', + y: 2015, + m: 4, + d: 10 + }]; + var addDays = function (myDate, days) { + return new Date(myDate.getTime() + days * 24 * 60 * 60 * 1000); + }; + + var getDays = function (startdate, enddate) { + var r, s, e; + s = startdate.getTime(); + e = enddate.getTime(); + r = (e - s) / (24 * 60 * 60 * 1000); + return r; + }; + var tick = function () { + var today = new Date(); + var start101 = new Date(); + var end101 = new Date(); + var endContract = new Date(); + var third = new Date(); + start101.setFullYear(2013, 9, 24); + end101 = addDays(start101, 1001); + endContract.setFullYear(2015, 4, 10); + third.setFullYear(2013, 7, 25); + $('#one').text('101B ends: ' + Math.ceil(getDays(today, + end101)) + " days / " + Math.ceil(getDays(today, + end101) / 7) + " weeks"); + $('#two').text('Ends: ' + Math.ceil(getDays(today, + endContract)) + " days / " + Math.ceil(getDays(today, + endContract) / 7) + " weeks"); + $('#three').hide(); + }; + + var get_weather = function () { + navigator.geolocation.getCurrentPosition(show_weather); + }; + var show_weather = function (position) { + var latitude = position.coords.latitude; + var longitude = position.coords.longitude; + // let's show a map or do something interesting! + $.ajax({ + type: 'GET', + url: 'https://api.forecast.io/forecast/0657dc0d81c037cbc89ca88e383b6bbf/' + latitude.toString() + ',' + longitude.toString(), + data: '', + dataType: 'jsonp', + timeout: 10000, + context: $('body'), + contentType: ('application/json'), + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type' + + }, + success: function (data) { + // console.log(data); + + var calc = ((5.0 / 9.0 * (data.currently.temperature - 32))); + $('#weather').html(data.currently.summary + " " + parseInt(calc) + '°c ' + '' + data.daily.summary + ''); + + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + + var updateBTC = function (g, u) { + var title, total, elm = $('#btc'); + if (lastGBP !== 0) { + + elm.removeClass(); + if (g > lastGBP) { + elm.addClass('up'); + } else if (g < lastGBP) { + elm.addClass('down'); + } + + } else { + lows.gbp = g; + lows.usd = u; + + highs.gbp = g; + highs.usd = u; + } + + lastGBP = g; + lastUSD = u; + + if (g < lows.gbp) lows.gbp = g; + if (u < lows.usd) lows.usd = u; + + if (highs.gbp < g) highs.gbp = g; + if (highs.usd < u) highs.usd = u; + + total = myBTC * g; + + title = "High: $" + parseFloat(highs.usd.toFixed(2)) + " / Low $" + parseFloat(lows.usd.toFixed(2)); + elm.html("$" + parseFloat(u.toFixed(2)) + " / £" + parseFloat(g.toFixed(2)) + " (£" + parseFloat(total.toFixed(2)) + ")"); + + elm.prop('title', title); + }; + + + var updateFX = function (data) { + var title, total, elm = $('#fx'); + //title = "High: $" + parseFloat(highs.usd.toFixed(2)) + " / Low $" + parseFloat(lows.usd.toFixed(2)); + elm.html("£1 = $" + parseFloat(data.gpbe.toFixed(2)) + " = " + parseFloat(data.sekex.toFixed(2)) + " SEK"); + + // elm.prop('title', title); + }; + + + var btcValue = function () { + var url = '/btc'; + + $.ajax({ + type: 'GET', + url: url, + data: '', + dataType: 'json', + + timeout: 10000, + + //contentType: ('application/json'), + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type' + + }, + success: function (data) { + // console.log(data); + var gbp = data.bpi.GBP.rate_float, + usd = data.bpi.USD.rate_float; + + updateBTC(gbp, usd); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + + + var getFX = function () { + var url = '/fx'; + + $.ajax({ + type: 'GET', + url: url, + data: '', + dataType: 'json', + + timeout: 10000, + + //contentType: ('application/json'), + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type' + + }, + success: function (data) { + //console.log(data); + var gpbex = (1 / data.rates.GBP); + var sekex = (gpbex * data.rates.SEK); + var fxdata = { + usd: 1, + gbp: data.rates.GBP, + sek: data.rates.SEK, + gpbe: gpbex, + sekex: sekex + }; + // console.log(fxdata); + //var fxdata = data.bpi.GBP.rate_float, usd = data.bpi.USD.rate_float; + + updateFX(fxdata); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + + + var getDBEGLQ = function () { + + var url = '/dbeglq'; + + $.ajax({ + type: 'GET', + url: url, + data: '', + dataType: 'json', + + timeout: 10000, + + //contentType: ('application/json'), + headers: { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS', + 'Access-Control-Allow-Headers': 'Content-Type' + + }, + success: function (data) { + console.log(data); + + updateTrain('dbeglq',data); + //updateFX(fxdata); + }, + error: function (xhr, type) { + console.log("ajax error"); + console.log(xhr); + console.log(type); + } + }); + }; + + var updateTrain = function (n, obj) { + var elm = $('#'+n); + + var output, status; + + + output = (obj.eta == "On Time") ? obj.eta : obj.sta; + status = (obj.eta == "On Time") ? 'delayed' : 'ontime'; + + elm.html(output); + + elm.prop('class', status); + }; + + + tick(); + get_weather(); + btcValue(); + getFX(); + getDBEGLQ(); + + // start 15 minute timer + + _fastTimer = setInterval(function () { + btcValue(); + getDBEGLQ(); + }, (60000)); + + _slowTimer = setInterval(function () { + + getFX(); + get_weather(); + }, (60000 * 15)); + +})(); + +var popitout = function (url) { + newwindow = window.open(url, 'name', 'height=600,width=570'); + if (window.focus) { + newwindow.focus() + } + return false; +}; + +var popitoutSmall = function (url) { + newwindow = window.open(url, 'name', 'height=400,width=520'); + if (window.focus) { + newwindow.focus() + } + return false; +}; diff --git a/app/app.min.js b/app/app.min.js new file mode 100644 index 0000000..9f04c86 --- /dev/null +++ b/app/app.min.js @@ -0,0 +1,2 @@ +!function(){var e,t=0,o=0,n=3.49524333,a={gbp:0,usd:0},s={gbp:0,usd:0},r=function(e,t){return new Date(e.getTime()+24*t*60*60*1e3)},c=function(e,t){var o,n,a;return n=e.getTime(),a=t.getTime(),o=(a-n)/864e5},l=function(){var e=new Date,t=new Date,o=new Date,n=new Date,a=new Date;t.setFullYear(2013,9,24),o=r(t,1001),n.setFullYear(2015,4,10),a.setFullYear(2013,7,25),$("#one").text("101B ends: "+Math.ceil(c(e,o))+" days / "+Math.ceil(c(e,o)/7)+" weeks"),$("#two").text("Ends: "+Math.ceil(c(e,n))+" days / "+Math.ceil(c(e,n)/7)+" weeks"),$("#three").hide()},p=function(){navigator.geolocation.getCurrentPosition(i)},i=function(e){var t=e.coords.latitude,o=e.coords.longitude;$.ajax({type:"GET",url:"https://api.forecast.io/forecast/0657dc0d81c037cbc89ca88e383b6bbf/"+t.toString()+","+o.toString(),data:"",dataType:"jsonp",timeout:1e4,context:$("body"),contentType:"application/json",headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"PUT, GET, POST, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type"},success:function(e){var t=5/9*(e.currently.temperature-32);$("#weather").html(e.currently.summary+" "+parseInt(t)+"°c "+e.daily.summary+"")},error:function(e,t){console.log("ajax error"),console.log(e),console.log(t)}})},u=function(e,r){var c,l,p=$("#btc");0!==t?(p.removeClass(),e>t?p.addClass("up"):t>e&&p.addClass("down")):(a.gbp=e,a.usd=r,s.gbp=e,s.usd=r),t=e,o=r,e + + + Silvrtree + + + + + +silvrtree + + diff --git a/app/libs/ejs.js b/app/libs/ejs.js new file mode 100644 index 0000000..1dd0ba4 --- /dev/null +++ b/app/libs/ejs.js @@ -0,0 +1,505 @@ +(function(){ + + +var rsplit = function(string, regex) { + var result = regex.exec(string),retArr = new Array(), first_idx, last_idx, first_bit; + while (result != null) + { + first_idx = result.index; last_idx = regex.lastIndex; + if ((first_idx) != 0) + { + first_bit = string.substring(0,first_idx); + retArr.push(string.substring(0,first_idx)); + string = string.slice(first_idx); + } + retArr.push(result[0]); + string = string.slice(result[0].length); + result = regex.exec(string); + } + if (! string == '') + { + retArr.push(string); + } + return retArr; +}, +chop = function(string){ + return string.substr(0, string.length - 1); +}, +extend = function(d, s){ + for(var n in s){ + if(s.hasOwnProperty(n)) d[n] = s[n] + } +} + + +EJS = function( options ){ + options = typeof options == "string" ? {view: options} : options + this.set_options(options); + if(options.precompiled){ + this.template = {}; + this.template.process = options.precompiled; + EJS.update(this.name, this); + return; + } + if(options.element) + { + if(typeof options.element == 'string'){ + var name = options.element + options.element = document.getElementById( options.element ) + if(options.element == null) throw name+'does not exist!' + } + if(options.element.value){ + this.text = options.element.value + }else{ + this.text = options.element.innerHTML + } + this.name = options.element.id + this.type = '[' + }else if(options.url){ + options.url = EJS.endExt(options.url, this.extMatch); + this.name = this.name ? this.name : options.url; + var url = options.url + //options.view = options.absolute_url || options.view || options.; + var template = EJS.get(this.name /*url*/, this.cache); + if (template) return template; + if (template == EJS.INVALID_PATH) return null; + try{ + this.text = EJS.request( url+(this.cache ? '' : '?'+Math.random() )); + }catch(e){} + + if(this.text == null){ + throw( {type: 'EJS', message: 'There is no template at '+url} ); + } + //this.name = url; + } + var template = new EJS.Compiler(this.text, this.type); + + template.compile(options, this.name); + + + EJS.update(this.name, this); + this.template = template; +}; +/* @Prototype*/ +EJS.prototype = { + /** + * Renders an object with extra view helpers attached to the view. + * @param {Object} object data to be rendered + * @param {Object} extra_helpers an object with additonal view helpers + * @return {String} returns the result of the string + */ + render : function(object, extra_helpers){ + object = object || {}; + this._extra_helpers = extra_helpers; + var v = new EJS.Helpers(object, extra_helpers || {}); + return this.template.process.call(object, object,v); + }, + update : function(element, options){ + if(typeof element == 'string'){ + element = document.getElementById(element) + } + if(options == null){ + _template = this; + return function(object){ + EJS.prototype.update.call(_template, element, object) + } + } + if(typeof options == 'string'){ + params = {} + params.url = options + _template = this; + params.onComplete = function(request){ + var object = eval( request.responseText ) + EJS.prototype.update.call(_template, element, object) + } + EJS.ajax_request(params) + }else + { + element.innerHTML = this.render(options) + } + }, + out : function(){ + return this.template.out; + }, + /** + * Sets options on this view to be rendered with. + * @param {Object} options + */ + set_options : function(options){ + this.type = options.type || EJS.type; + this.cache = options.cache != null ? options.cache : EJS.cache; + this.text = options.text || null; + this.name = options.name || null; + this.ext = options.ext || EJS.ext; + this.extMatch = new RegExp(this.ext.replace(/\./, '\.')); + } +}; +EJS.endExt = function(path, match){ + if(!path) return null; + match.lastIndex = 0 + return path+ (match.test(path) ? '' : this.ext ) +} + + + + +/* @Static*/ +EJS.Scanner = function(source, left, right) { + + extend(this, + {left_delimiter: left +'%', + right_delimiter: '%'+right, + double_left: left+'%%', + double_right: '%%'+right, + left_equal: left+'%=', + left_comment: left+'%#'}) + + this.SplitRegexp = left=='[' ? /(\[%%)|(%%\])|(\[%=)|(\[%#)|(\[%)|(%\]\n)|(%\])|(\n)/ : new RegExp('('+this.double_left+')|(%%'+this.double_right+')|('+this.left_equal+')|('+this.left_comment+')|('+this.left_delimiter+')|('+this.right_delimiter+'\n)|('+this.right_delimiter+')|(\n)') ; + + this.source = source; + this.stag = null; + this.lines = 0; +}; + +EJS.Scanner.to_text = function(input){ + if(input == null || input === undefined) + return ''; + if(input instanceof Date) + return input.toDateString(); + if(input.toString) + return input.toString(); + return ''; +}; + +EJS.Scanner.prototype = { + scan: function(block) { + scanline = this.scanline; + regex = this.SplitRegexp; + if (! this.source == '') + { + var source_split = rsplit(this.source, /\n/); + for(var i=0; i 0) + { + for (var i=0; i 0) + { + buff.push(put_cmd + '"' + clean(content) + '")'); + } + content = ''; + break; + case scanner.double_left: + content = content + scanner.left_delimiter; + break; + default: + content = content + token; + break; + } + } + else { + switch(token) { + case scanner.right_delimiter: + switch(scanner.stag) { + case scanner.left_delimiter: + if (content[content.length - 1] == '\n') + { + content = chop(content); + buff.push(content); + buff.cr(); + } + else { + buff.push(content); + } + break; + case scanner.left_equal: + buff.push(insert_cmd + "(EJS.Scanner.to_text(" + content + ")))"); + break; + } + scanner.stag = null; + content = ''; + break; + case scanner.double_right: + content = content + scanner.right_delimiter; + break; + default: + content = content + token; + break; + } + } + }); + if (content.length > 0) + { + // Chould be content.dump in Ruby + buff.push(put_cmd + '"' + clean(content) + '")'); + } + buff.close(); + this.out = buff.script + ";"; + var to_be_evaled = '/*'+name+'*/this.process = function(_CONTEXT,_VIEW) { try { with(_VIEW) { with (_CONTEXT) {'+this.out+" return ___ViewO.join('');}}}catch(e){e.lineNumber=null;throw e;}};"; + + try{ + eval(to_be_evaled); + }catch(e){ + if(typeof JSLINT != 'undefined'){ + JSLINT(this.out); + for(var i = 0; i < JSLINT.errors.length; i++){ + var error = JSLINT.errors[i]; + if(error.reason != "Unnecessary semicolon."){ + error.line++; + var e = new Error(); + e.lineNumber = error.line; + e.message = error.reason; + if(options.view) + e.fileName = options.view; + throw e; + } + } + }else{ + throw e; + } + } + } +}; + + +//type, cache, folder +/** + * Sets default options for all views + * @param {Object} options Set view with the following options + * + + + + + + + + + + + +
OptionDefaultDescription
type'<'type of magic tags. Options are '<' or '[' +
cachetrue in production mode, false in other modestrue to cache template. +
+ * + */ +EJS.config = function(options){ + EJS.cache = options.cache != null ? options.cache : EJS.cache; + EJS.type = options.type != null ? options.type : EJS.type; + EJS.ext = options.ext != null ? options.ext : EJS.ext; + + var templates_directory = EJS.templates_directory || {}; //nice and private container + EJS.templates_directory = templates_directory; + EJS.get = function(path, cache){ + if(cache == false) return null; + if(templates_directory[path]) return templates_directory[path]; + return null; + }; + + EJS.update = function(path, template) { + if(path == null) return; + templates_directory[path] = template ; + }; + + EJS.INVALID_PATH = -1; +}; +EJS.config( {cache: true, type: '<', ext: '.ejs' } ); + + + +/** + * @constructor + * By adding functions to EJS.Helpers.prototype, those functions will be available in the + * views. + * @init Creates a view helper. This function is called internally. You should never call it. + * @param {Object} data The data passed to the view. Helpers have access to it through this._data + */ +EJS.Helpers = function(data, extras){ + this._data = data; + this._extras = extras; + extend(this, extras ); +}; +/* @prototype*/ +EJS.Helpers.prototype = { + /** + * Renders a new view. If data is passed in, uses that to render the view. + * @param {Object} options standard options passed to a new view. + * @param {optional:Object} data + * @return {String} + */ + view: function(options, data, helpers){ + if(!helpers) helpers = this._extras + if(!data) data = this._data; + return new EJS(options).render(data, helpers); + }, + /** + * For a given value, tries to create a human representation. + * @param {Object} input the value being converted. + * @param {Object} null_text what text should be present if input == null or undefined, defaults to '' + * @return {String} + */ + to_text: function(input, null_text) { + if(input == null || input === undefined) return null_text || ''; + if(input instanceof Date) return input.toDateString(); + if(input.toString) return input.toString().replace(/\n/g, '
').replace(/''/g, "'"); + return ''; + } +}; + EJS.newRequest = function(){ + var factories = [function() { return new ActiveXObject("Msxml2.XMLHTTP"); },function() { return new XMLHttpRequest(); },function() { return new ActiveXObject("Microsoft.XMLHTTP"); }]; + for(var i = 0; i < factories.length; i++) { + try { + var request = factories[i](); + if (request != null) return request; + } + catch(e) { continue;} + } + } + + EJS.request = function(path){ + var request = new EJS.newRequest() + request.open("GET", path, false); + + try{request.send(null);} + catch(e){return null;} + + if ( request.status == 404 || request.status == 2 ||(request.status == 0 && request.responseText == '') ) return null; + + return request.responseText + } + EJS.ajax_request = function(params){ + params.method = ( params.method ? params.method : 'GET') + + var request = new EJS.newRequest(); + request.onreadystatechange = function(){ + if(request.readyState == 4){ + if(request.status == 200){ + params.onComplete(request) + }else + { + params.onComplete(request) + } + } + } + request.open(params.method, params.url) + request.send(null) + } + + +})(); diff --git a/app/libs/ejs_production.js b/app/libs/ejs_production.js new file mode 100644 index 0000000..01a4181 --- /dev/null +++ b/app/libs/ejs_production.js @@ -0,0 +1 @@ +(function(){var rsplit=function(string,regex){var result=regex.exec(string),retArr=new Array(),first_idx,last_idx,first_bit;while(result!=null){first_idx=result.index;last_idx=regex.lastIndex;if((first_idx)!=0){first_bit=string.substring(0,first_idx);retArr.push(string.substring(0,first_idx));string=string.slice(first_idx)}retArr.push(result[0]);string=string.slice(result[0].length);result=regex.exec(string)}if(!string==""){retArr.push(string)}return retArr},chop=function(string){return string.substr(0,string.length-1)},extend=function(d,s){for(var n in s){if(s.hasOwnProperty(n)){d[n]=s[n]}}};EJS=function(options){options=typeof options=="string"?{view:options}:options;this.set_options(options);if(options.precompiled){this.template={};this.template.process=options.precompiled;EJS.update(this.name,this);return }if(options.element){if(typeof options.element=="string"){var name=options.element;options.element=document.getElementById(options.element);if(options.element==null){throw name+"does not exist!"}}if(options.element.value){this.text=options.element.value}else{this.text=options.element.innerHTML}this.name=options.element.id;this.type="["}else{if(options.url){options.url=EJS.endExt(options.url,this.extMatch);this.name=this.name?this.name:options.url;var url=options.url;var template=EJS.get(this.name,this.cache);if(template){return template}if(template==EJS.INVALID_PATH){return null}try{this.text=EJS.request(url+(this.cache?"":"?"+Math.random()))}catch(e){}if(this.text==null){throw ({type:"EJS",message:"There is no template at "+url})}}}var template=new EJS.Compiler(this.text,this.type);template.compile(options,this.name);EJS.update(this.name,this);this.template=template};EJS.prototype={render:function(object,extra_helpers){object=object||{};this._extra_helpers=extra_helpers;var v=new EJS.Helpers(object,extra_helpers||{});return this.template.process.call(object,object,v)},update:function(element,options){if(typeof element=="string"){element=document.getElementById(element)}if(options==null){_template=this;return function(object){EJS.prototype.update.call(_template,element,object)}}if(typeof options=="string"){params={};params.url=options;_template=this;params.onComplete=function(request){var object=eval(request.responseText);EJS.prototype.update.call(_template,element,object)};EJS.ajax_request(params)}else{element.innerHTML=this.render(options)}},out:function(){return this.template.out},set_options:function(options){this.type=options.type||EJS.type;this.cache=options.cache!=null?options.cache:EJS.cache;this.text=options.text||null;this.name=options.name||null;this.ext=options.ext||EJS.ext;this.extMatch=new RegExp(this.ext.replace(/\./,"."))}};EJS.endExt=function(path,match){if(!path){return null}match.lastIndex=0;return path+(match.test(path)?"":this.ext)};EJS.Scanner=function(source,left,right){extend(this,{left_delimiter:left+"%",right_delimiter:"%"+right,double_left:left+"%%",double_right:"%%"+right,left_equal:left+"%=",left_comment:left+"%#"});this.SplitRegexp=left=="["?/(\[%%)|(%%\])|(\[%=)|(\[%#)|(\[%)|(%\]\n)|(%\])|(\n)/:new RegExp("("+this.double_left+")|(%%"+this.double_right+")|("+this.left_equal+")|("+this.left_comment+")|("+this.left_delimiter+")|("+this.right_delimiter+"\n)|("+this.right_delimiter+")|(\n)");this.source=source;this.stag=null;this.lines=0};EJS.Scanner.to_text=function(input){if(input==null||input===undefined){return""}if(input instanceof Date){return input.toDateString()}if(input.toString){return input.toString()}return""};EJS.Scanner.prototype={scan:function(block){scanline=this.scanline;regex=this.SplitRegexp;if(!this.source==""){var source_split=rsplit(this.source,/\n/);for(var i=0;i0){for(var i=0;i0){buff.push(put_cmd+'"'+clean(content)+'")')}content="";break;case scanner.double_left:content=content+scanner.left_delimiter;break;default:content=content+token;break}}else{switch(token){case scanner.right_delimiter:switch(scanner.stag){case scanner.left_delimiter:if(content[content.length-1]=="\n"){content=chop(content);buff.push(content);buff.cr()}else{buff.push(content)}break;case scanner.left_equal:buff.push(insert_cmd+"(EJS.Scanner.to_text("+content+")))");break}scanner.stag=null;content="";break;case scanner.double_right:content=content+scanner.right_delimiter;break;default:content=content+token;break}}});if(content.length>0){buff.push(put_cmd+'"'+clean(content)+'")')}buff.close();this.out=buff.script+";";var to_be_evaled="/*"+name+"*/this.process = function(_CONTEXT,_VIEW) { try { with(_VIEW) { with (_CONTEXT) {"+this.out+" return ___ViewO.join('');}}}catch(e){e.lineNumber=null;throw e;}};";try{eval(to_be_evaled)}catch(e){if(typeof JSLINT!="undefined"){JSLINT(this.out);for(var i=0;i").replace(/''/g,"'")}return""}};EJS.newRequest=function(){var factories=[function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];for(var i=0;i")};EJS.Helpers.prototype.start_tag_for=function(A,B){return this.tag(A,B)};EJS.Helpers.prototype.submit_tag=function(A,B){B=B||{};B.type=B.type||"submit";B.value=A||"Submit";return this.single_tag_for("input",B)};EJS.Helpers.prototype.tag=function(C,E,D){if(!D){var D=">"}var B=" ";for(var A in E){if(E[A]!=null){var F=E[A].toString()}else{var F=""}if(A=="Class"){A="class"}if(F.indexOf("'")!=-1){B+=A+'="'+F+'" '}else{B+=A+"='"+F+"' "}}return"<"+C+B+D};EJS.Helpers.prototype.tag_end=function(A){return""};EJS.Helpers.prototype.text_area_tag=function(A,C,B){B=B||{};B.id=B.id||A;B.name=B.name||A;C=C||"";if(B.size){B.cols=B.size.split("x")[0];B.rows=B.size.split("x")[1];delete B.size}B.cols=B.cols||50;B.rows=B.rows||4;return this.start_tag_for("textarea",B)+C+this.tag_end("textarea")};EJS.Helpers.prototype.text_tag=EJS.Helpers.prototype.text_area_tag;EJS.Helpers.prototype.text_field_tag=function(A,C,B){return this.input_field_tag(A,C,"text",B)};EJS.Helpers.prototype.url_for=function(A){return'window.location="'+A+'";'};EJS.Helpers.prototype.img_tag=function(B,C,A){A=A||{};A.src=B;A.alt=C;return this.single_tag_for("img",A)} diff --git a/app/libs/view.js b/app/libs/view.js new file mode 100644 index 0000000..ef3ea7e --- /dev/null +++ b/app/libs/view.js @@ -0,0 +1,200 @@ +EJS.Helpers.prototype.date_tag = function(name, value , html_options) { + if(! (value instanceof Date)) + value = new Date() + + var month_names = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; + var years = [], months = [], days =[]; + var year = value.getFullYear(); + var month = value.getMonth(); + var day = value.getDate(); + for(var y = year - 15; y < year+15 ; y++) + { + years.push({value: y, text: y}) + } + for(var m = 0; m < 12; m++) + { + months.push({value: (m), text: month_names[m]}) + } + for(var d = 0; d < 31; d++) + { + days.push({value: (d+1), text: (d+1)}) + } + var year_select = this.select_tag(name+'[year]', year, years, {id: name+'[year]'} ) + var month_select = this.select_tag(name+'[month]', month, months, {id: name+'[month]'}) + var day_select = this.select_tag(name+'[day]', day, days, {id: name+'[day]'}) + + return year_select+month_select+day_select; +} + +EJS.Helpers.prototype.form_tag = function(action, html_options) { + + + html_options = html_options || {}; + html_options.action = action + if(html_options.multipart == true) { + html_options.method = 'post'; + html_options.enctype = 'multipart/form-data'; + } + + return this.start_tag_for('form', html_options) +} + +EJS.Helpers.prototype.form_tag_end = function() { return this.tag_end('form'); } + +EJS.Helpers.prototype.hidden_field_tag = function(name, value, html_options) { + return this.input_field_tag(name, value, 'hidden', html_options); +} + +EJS.Helpers.prototype.input_field_tag = function(name, value , inputType, html_options) { + + html_options = html_options || {}; + html_options.id = html_options.id || name; + html_options.value = value || ''; + html_options.type = inputType || 'text'; + html_options.name = name; + + return this.single_tag_for('input', html_options) +} + +EJS.Helpers.prototype.is_current_page = function(url) { + return (window.location.href == url || window.location.pathname == url ? true : false); +} + +EJS.Helpers.prototype.link_to = function(name, url, html_options) { + if(!name) var name = 'null'; + if(!html_options) var html_options = {} + + if(html_options.confirm){ + html_options.onclick = + " var ret_confirm = confirm(\""+html_options.confirm+"\"); if(!ret_confirm){ return false;} " + html_options.confirm = null; + } + html_options.href=url + return this.start_tag_for('a', html_options)+name+ this.tag_end('a'); +} + +EJS.Helpers.prototype.submit_link_to = function(name, url, html_options){ + if(!name) var name = 'null'; + if(!html_options) var html_options = {} + html_options.onclick = html_options.onclick || '' ; + + if(html_options.confirm){ + html_options.onclick = + " var ret_confirm = confirm(\""+html_options.confirm+"\"); if(!ret_confirm){ return false;} " + html_options.confirm = null; + } + + html_options.value = name; + html_options.type = 'submit' + html_options.onclick=html_options.onclick+ + (url ? this.url_for(url) : '')+'return false;'; + //html_options.href='#'+(options ? Routes.url_for(options) : '') + return this.start_tag_for('input', html_options) +} + +EJS.Helpers.prototype.link_to_if = function(condition, name, url, html_options, post, block) { + return this.link_to_unless((condition == false), name, url, html_options, post, block); +} + +EJS.Helpers.prototype.link_to_unless = function(condition, name, url, html_options, block) { + html_options = html_options || {}; + if(condition) { + if(block && typeof block == 'function') { + return block(name, url, html_options, block); + } else { + return name; + } + } else + return this.link_to(name, url, html_options); +} + +EJS.Helpers.prototype.link_to_unless_current = function(name, url, html_options, block) { + html_options = html_options || {}; + return this.link_to_unless(this.is_current_page(url), name, url, html_options, block) +} + + +EJS.Helpers.prototype.password_field_tag = function(name, value, html_options) { return this.input_field_tag(name, value, 'password', html_options); } + +EJS.Helpers.prototype.select_tag = function(name, value, choices, html_options) { + html_options = html_options || {}; + html_options.id = html_options.id || name; + html_options.value = value; + html_options.name = name; + + var txt = '' + txt += this.start_tag_for('select', html_options) + + for(var i = 0; i < choices.length; i++) + { + var choice = choices[i]; + var optionOptions = {value: choice.value} + if(choice.value == value) + optionOptions.selected ='selected' + txt += this.start_tag_for('option', optionOptions )+choice.text+this.tag_end('option') + } + txt += this.tag_end('select'); + return txt; +} + +EJS.Helpers.prototype.single_tag_for = function(tag, html_options) { return this.tag(tag, html_options, '/>');} + +EJS.Helpers.prototype.start_tag_for = function(tag, html_options) { return this.tag(tag, html_options); } + +EJS.Helpers.prototype.submit_tag = function(name, html_options) { + html_options = html_options || {}; + //html_options.name = html_options.id || 'commit'; + html_options.type = html_options.type || 'submit'; + html_options.value = name || 'Submit'; + return this.single_tag_for('input', html_options); +} + +EJS.Helpers.prototype.tag = function(tag, html_options, end) { + if(!end) var end = '>' + var txt = ' ' + for(var attr in html_options) { + if(html_options[attr] != null) + var value = html_options[attr].toString(); + else + var value='' + if(attr == "Class") // special case because "class" is a reserved word in IE + attr = "class"; + if( value.indexOf("'") != -1 ) + txt += attr+'=\"'+value+'\" ' + else + txt += attr+"='"+value+"' " + } + return '<'+tag+txt+end; +} + +EJS.Helpers.prototype.tag_end = function(tag) { return ''; } + +EJS.Helpers.prototype.text_area_tag = function(name, value, html_options) { + html_options = html_options || {}; + html_options.id = html_options.id || name; + html_options.name = html_options.name || name; + value = value || '' + if(html_options.size) { + html_options.cols = html_options.size.split('x')[0] + html_options.rows = html_options.size.split('x')[1]; + delete html_options.size + } + + html_options.cols = html_options.cols || 50; + html_options.rows = html_options.rows || 4; + + return this.start_tag_for('textarea', html_options)+value+this.tag_end('textarea') +} +EJS.Helpers.prototype.text_tag = EJS.Helpers.prototype.text_area_tag + +EJS.Helpers.prototype.text_field_tag = function(name, value, html_options) { return this.input_field_tag(name, value, 'text', html_options); } + +EJS.Helpers.prototype.url_for = function(url) { + return 'window.location="'+url+'";' +} +EJS.Helpers.prototype.img_tag = function(image_location, alt, options){ + options = options || {}; + options.src = image_location + options.alt = alt + return this.single_tag_for('img', options) +} diff --git a/app/lot.csv b/app/lot.csv new file mode 100644 index 0000000..c0ded99 --- /dev/null +++ b/app/lot.csv @@ -0,0 +1,184 @@ +14-Nov-2014,36,32,38,48,17,8,5 +11-Nov-2014,46,14,36,2,21,11,7 +07-Nov-2014,32,13,38,46,25,10,1 +04-Nov-2014,1,13,6,26,17,3,5 +31-Oct-2014,10,41,13,20,33,9,3 +28-Oct-2014,45,17,40,10,15,1,2 +24-Oct-2014,42,20,3,30,9,6,1 +21-Oct-2014,40,33,27,20,21,3,10 +17-Oct-2014,49,13,48,1,40,8,10 +14-Oct-2014,15,23,32,4,5,7,3 +10-Oct-2014,29,42,47,45,6,9,10 +07-Oct-2014,38,30,21,9,28,8,1 +03-Oct-2014,13,23,50,48,4,10,5 +30-Sep-2014,33,13,15,3,42,5,7 +26-Sep-2014,46,35,47,13,27,1,2 +23-Sep-2014,13,35,14,29,12,1,7 +19-Sep-2014,6,34,8,38,48,9,3 +16-Sep-2014,4,30,35,50,29,4,2 +12-Sep-2014,31,9,33,26,13,7,11 +09-Sep-2014,15,35,19,8,24,10,8 +05-Sep-2014,18,50,23,46,1,9,3 +02-Sep-2014,39,45,25,31,5,8,1 +29-Aug-2014,32,38,26,9,2,3,6 +26-Aug-2014,36,48,45,10,22,11,4 +22-Aug-2014,29,17,49,35,4,1,2 +19-Aug-2014,11,34,47,4,7,7,8 +15-Aug-2014,4,21,30,5,23,10,8 +12-Aug-2014,22,19,7,16,33,5,2 +08-Aug-2014,29,21,35,46,43,1,9 +05-Aug-2014,5,21,42,7,19,11,5 +01-Aug-2014,50,44,46,48,24,10,5 +29-Jul-2014,40,23,35,10,43,9,3 +25-Jul-2014,10,24,9,12,43,5,9 +22-Jul-2014,1,43,50,45,24,5,8 +18-Jul-2014,1,41,43,11,29,3,11 +15-Jul-2014,18,27,15,34,20,1,3 +11-Jul-2014,38,35,5,49,22,7,4 +08-Jul-2014,24,18,22,8,27,11,4 +04-Jul-2014,47,18,43,39,4,6,2 +01-Jul-2014,39,25,18,22,27,5,10 +27-Jun-2014,39,34,45,33,31,2,10 +24-Jun-2014,20,1,7,21,48,4,7 +20-Jun-2014,5,38,49,15,25,1,2 +17-Jun-2014,48,13,37,40,11,8,9 +13-Jun-2014,16,22,28,46,18,11,9 +10-Jun-2014,12,18,21,33,32,1,11 +06-Jun-2014,34,40,25,7,49,9,11 +03-Jun-2014,2,39,32,15,44,5,10 +30-May-2014,27,41,24,45,5,7,6 +27-May-2014,16,13,26,25,7,1,6 +23-May-2014,31,3,47,8,34,11,9 +'20-May-2014', 5, 33, 36, 38, 47, 4, 9 +'16-May-2014', 23, 26, 29, 37, 40, 3, 4 +'13-May-2014', 4, 13, 30, 34, 47, 2, 6 +'09-May-2014', 3, 21, 26, 28, 45, 7, 10 +'06-May-2014', 5, 19, 24, 31, 37, 1, 9 +'02-May-2014', 4, 30, 31, 38, 42, 2, 11 +'29-Apr-2014', 18, 23, 26, 35, 44, 3, 11 +'25-Apr-2014', 13, 21, 24, 44, 49, 1, 9 +'22-Apr-2014', 13, 15, 20, 24, 46, 1, 8 +'18-Apr-2014', 21, 24, 31, 39, 47, 3, 7 +'15-Apr-2014', 3, 14, 26, 47, 50, 7, 11 +'11-Apr-2014', 8, 12, 19, 30, 33, 4, 11 +'08-Apr-2014', 11, 18, 29, 42, 49, 4, 11 +'04-Apr-2014', 6, 10, 28, 45, 50, 10, 11 +'01-Apr-2014', 16, 18, 26, 38, 44, 8, 10 +'28-Mar-2014', 3, 4, 19, 28, 43, 3, 7 +'25-Mar-2014', 7, 20, 26, 28, 50, 2, 8 +'21-Mar-2014', 7, 30, 37, 39, 42, 5, 7 +'18-Mar-2014', 8, 27, 34, 36, 39, 5, 10 +'14-Mar-2014', 6, 24, 25, 27, 30, 5, 9 +'11-Mar-2014', 1, 4, 23, 33, 44, 7, 8 +'07-Mar-2014', 5, 10, 38, 40, 41, 1, 8 +'04-Mar-2014', 3, 5, 22, 27, 44, 1, 6 +'28-Feb-2014', 12, 32, 38, 43, 44, 2, 7 +'25-Feb-2014', 21, 25, 28, 35, 42, 4, 6 +'21-Feb-2014', 13, 17, 28, 30, 32, 5, 7 +'18-Feb-2014', 23, 26, 36, 37, 49, 6, 7 +'14-Feb-2014', 19, 39, 4, 2, 6, 2, 7 +'11-Feb-2014', 47, 25, 8, 17, 41, 1, 2 +'07-Feb-2014', 17, 19, 47, 3, 46, 9, 10 +'04-Feb-2014', 37, 1, 33, 21, 38, 8, 4 +'31-Jan-2014', 10, 15, 31, 8, 16, 8, 9 +'28-Jan-2014', 18, 23, 48, 20, 42, 2, 9 +'24-Jan-2014', 19, 41, 35, 34, 5, 1, 5 +'21-Jan-2014', 4, 42, 35, 48, 12, 5, 8 +'17-Jan-2014', 26, 19, 33, 42, 32, 10, 4 +'14-Jan-2014', 25, 18, 20, 26, 37, 11, 10 +'10-Jan-2014', 1, 27, 2, 11, 29, 10, 1 +'07-Jan-2014', 2, 45, 20, 27, 33, 6, 10 +'03-Jan-2014', 3, 44, 27, 38, 31, 3, 8 +'31-Dec-2013', 29, 45, 24, 20, 13, 7, 3 +'27-Dec-2013', 1, 22, 6, 13, 28, 10, 5 +'24-Dec-2013', 5, 31, 43, 50, 19, 6, 2 +'20-Dec-2013', 13, 22, 17, 43, 12, 10, 3 +'17-Dec-2013', 41, 6, 8, 37, 27, 7, 10 +'13-Dec-2013', 24, 22, 23, 1, 31, 6, 11 +'10-Dec-2013', 49, 50, 24, 6, 35, 7, 1 +'06-Dec-2013', 18, 31, 36, 2, 1, 7, 10 +'03-Dec-2013', 32, 6, 29, 15, 13, 2, 9 +'29-Nov-2013', 2, 7, 10, 23, 43, 4, 7 +'26-Nov-2013', 19, 23, 27, 42, 44, 3, 5 +'22-Nov-2013', 13, 25, 26, 40, 50, 8, 9 +'19-Nov-2013', 14, 15, 19, 36, 45, 1, 10 +'15-Nov-2013', 3, 13, 15, 29, 42, 1, 4 +'12-Nov-2013', 14, 29, 37, 40, 48, 2, 11 +'08-Nov-2013', 20, 28, 35, 42, 43, 8, 10 +'05-Nov-2013', 6, 12, 13, 35, 38, 2, 3 +'01-Nov-2013', 7, 19, 29, 30, 33, 3, 8 +'29-Oct-2013', 9, 10, 30, 32, 37, 2, 6 +'25-Oct-2013', 2, 3, 10, 31, 38, 6, 10 +'22-Oct-2013', 29, 33, 39, 41, 44, 9, 11 +'18-Oct-2013', 5, 25, 36, 46, 47, 2, 6 +'15-Sep-2013', 18, 27, 39, 43, 47, 4, 7 +'11-Oct-2013', 6, 12, 17, 23, 43, 5, 9 +'08-Oct-2013', 23, 24, 26, 33, 42, 3, 5 +'04-Oct-2013', 6, 20, 24, 35, 50, 5, 10 +'01-Oct-2013', 19, 23, 25, 44, 48, 8, 9 +'27-Sep-2013', 11, 15, 38, 41, 43, 2, 6 +'24-Sep-2013', 10, 20, 26, 28, 43, 9, 11 +'20-Sep-2013', 5, 11, 35, 38, 45, 2, 3 +'17-Sep-2013', 13, 17, 21, 42, 44, 9, 11 +'13-Sep-2013', 4, 6, 14, 27, 33, 5, 10 +'10-Sep-2013', 7, 11, 14, 28, 30, 2, 10 +'06-Sep-2013', 11, 23, 25, 32, 37, 4, 7 +'03-Sep-2013', 5, 9, 16, 18, 42, 7, 9 +'30-Aug-2013', 2, 17, 25, 36, 45, 5, 9 +'27-Aug-2013', 7, 30, 38, 40, 43, 2, 6 +'23-Aug-2013', 1, 6, 26, 30, 37, 5, 8 +'20-Aug-2013', 5, 11, 42, 49, 50, 8, 11 +'16-Aug-2013', 20, 24, 27, 37, 39, 5, 10 +'13-Aug-2013', 5, 17, 20, 47, 50, 1, 4 +'09-Aug-2013', 4, 7, 9, 23, 24, 8, 9 +'06-Aug-2013', 17, 47, 16, 49, 31, 3, 11 +'02-Aug-2013', 42, 36, 48, 37, 21, 7, 4 +'30-Jul-2013', 3, 14, 4, 11, 43, 1, 6 +'26-Jul-2013', 23, 38, 29, 12, 49, 4, 3 +'23-Jul-2013', 19, 14, 44, 16, 15, 4, 5 +'19-Jul-2013', 24, 35, 13, 26, 16, 5, 2 +'16-Jul-2013', 50, 34, 47, 19, 23, 4, 6 +'12-Jul-2013', 26, 42, 33, 18, 32, 3, 2 +'09-Jul-2013', 18, 16, 38, 49, 31, 10, 4 +'05-Jul-2013', 28, 4, 33, 12, 15, 1, 10 +'02-Jul-2013', 14, 13, 11, 28, 30, 4, 5 +'28-Jun-2013', 15, 1, 47, 28, 35, 7, 1 +'25-Jun-2013', 4, 13, 35, 27, 5, 2, 1 +'21-Jun-2013', 30, 11, 36, 45, 10, 1, 2 +'18-Jun-2013', 24, 33, 17, 41, 44, 11, 1 +'14-Jun-2013', 41, 25, 48, 10, 47, 6, 10 +'11-Jun-2013', 7, 9, 25, 5, 41, 5, 1 +'07-Jun-2013', 14, 26, 45, 50, 7, 2, 7 +'04-Jun-2013', 34, 33, 40, 31, 37, 6, 1 +'31-May-2013', 29, 43, 28, 34, 27, 10, 5 +'28-May-2013', 34, 38, 13, 8, 26, 3, 11 +'24-May-2013', 22, 17, 40, 7, 27, 2, 3 +'21-May-2013', 29, 19, 8, 28, 7, 9, 5 +'17-May-2013', 25, 24, 50, 6, 20, 9, 10 +'14-May-2013', 24, 7, 8, 36, 27, 11, 5 +'10-May-2013', 48, 35, 45, 1, 32, 4, 11 +'07-May-2013', 43, 27, 13, 28, 42, 4, 6 +'03-May-2013', 5, 49, 34, 3, 40, 2, 3 +'30-Apr-2013', 13, 50, 40, 43, 36, 9, 5 +'26-Apr-2013', 40, 38, 16, 24, 11, 2, 5 +'23-Apr-2013', 50, 4, 1, 7, 10, 4, 11 +'19-Apr-2013', 1, 46, 8, 42, 48, 4, 7 +'16-Apr-2013', 33, 50, 22, 1, 11, 4, 6 +'12-Apr-2013', 28, 45, 15, 5, 10, 3, 9 +'09-Apr-2013', 15, 44, 48, 38, 35, 10, 5 +'05-Apr-2013', 32, 1, 17, 39, 11, 7, 2 +'02-Apr-2013', 17, 12, 41, 29, 25, 1, 4 +'29-Mar-2013', 44, 30, 46, 43, 13, 9, 5 +'26-Mar-2013', 44, 30, 26, 42, 4, 6, 11 +'22-Mar-2013', 27, 32, 12, 34, 49, 9, 8 +'19-Mar-2013', 44, 32, 19, 37, 35, 9, 1 +'15-Mar-2013', 24, 14, 39, 4, 21, 10, 3 +'12-Mar-2013', 50, 4, 10, 2, 22, 5, 8 +'08-Mar-2013', 20, 42, 23, 28, 3, 8, 11 +'05-Mar-2013', 33, 31, 19, 8, 39, 7, 2 +'01-Mar-2013', 1, 11, 36, 29, 42, 4, 5 +'26-Feb-2013', 12, 13, 17, 3, 30, 6, 2 +'22-Feb-2013', 15, 37, 36, 16, 28, 2, 11 +'19-Feb-2013', 28, 30, 44, 12, 15, 9, 8 +'15-Feb-2013', 2, 4, 42, 28, 22, 4, 9 +'12-Feb-2013', 28, 25, 5, 11, 16, 7, 9 \ No newline at end of file diff --git a/app/newermobile.htm b/app/newermobile.htm new file mode 100644 index 0000000..6ef36bc --- /dev/null +++ b/app/newermobile.htm @@ -0,0 +1 @@ +Slack
Slack - I have plenty of talent and vision I just don't give a damn
Starting Points/Metasites
News
Travel
Weather Reports
Job Searching
Entertainment
Personal / Money
diff --git a/app/newmobile.htm b/app/newmobile.htm new file mode 100644 index 0000000..586f998 --- /dev/null +++ b/app/newmobile.htm @@ -0,0 +1,64 @@ +Slack + + + + + + + + +
Slack - I have plenty of talent and vision I just don't give a damn
+ + + +
Starting Points/Metasites
+ + +
News
+ + + +
Travel
+ + +
Weather Reports
+ + +
Job Searching
+ +
Entertainment
+ + + + +
Personal / Money
+ + + + diff --git a/app/slack.htm b/app/slack.htm new file mode 100644 index 0000000..123ea0d --- /dev/null +++ b/app/slack.htm @@ -0,0 +1,518 @@ + + + + Slack + + + + + +
+

Slack - I have plenty of talent and vision I just don't give a damn

+ +
+

----  ----   ---- +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Starting Points/MetasitesToolsBitcoin
+ + + + + + + + +
Computer NewsWeather ReportsFree Email WEBpages
+ + + + + + + + +
Job SearchingEntertainmentTravel
+ + + + + + + + DBEGLQ: --- + + +
Computer Software, etc.Reference & Special sitesEarth and Beyond
+ + + + + + + + +
+
+
+ + + diff --git a/app/template/watchlist.ejs b/app/template/watchlist.ejs new file mode 100644 index 0000000..892ad92 --- /dev/null +++ b/app/template/watchlist.ejs @@ -0,0 +1,33 @@ +<% + var d = new Date(); + %> + + + + + + + + <% for( var i=0;i + + + + + + + + <% + + } + + + + %> + +
ItemCostBTCValue
<%=link_to(items[i].title, items[i].url)%>$<%=items[i].usd.toFixed(2) %><%=coins.toFixed(4) %>£<%=v.toFixed(2) %>
+Last Update <%=d.toLocaleString()%> diff --git a/app/watch.html b/app/watch.html new file mode 100644 index 0000000..026d2fc --- /dev/null +++ b/app/watch.html @@ -0,0 +1,222 @@ + + + + + + + + + + + + +
+ +
+ + + + diff --git a/app/watchlist.json.js b/app/watchlist.json.js new file mode 100644 index 0000000..027e908 --- /dev/null +++ b/app/watchlist.json.js @@ -0,0 +1,36 @@ +var list={ + + items:[ + { + title:'DMC-GM1', + url:'http://coinsfortech.com/shop/panasonic-lumix-dmc-gm1-with-12-32mm-lens/', + usd:508.00 + }, + { + title:'Intel NUC D54250WYK', + url:'http://coinsfortech.com/shop/intel-nuc-kit-d54250wyk-mini-desktop-pc/', + usd:496.00 + }, + { + title:'Moto 360 Smart Watch', + url:'http://coinsfortech.com/shop/moto-360-smart-watch/', + usd:355.00 + }, + { + title:'Nikon D600 24-85mm lens kit', + url:'http://coinsfortech.com/shop/nikon-d600-24-85mm-lens-ki/', + usd:2048.00 + }, + { + title:'Nikon D5300 18-55mm and 55-200mm Twin Lens Kit', + url:'http://coinsfortech.com/shop/nikon-d5300-18-55mm-and-55-200mm-twin-lens-kit/', + usd:882.00 + }, + { + title:'Full NUC @ e4btc.com', + url:'https://e4btc.com/cart', + usd:668.542 + + } + ] +}; diff --git a/lib/btc.js b/lib/btc.js new file mode 100644 index 0000000..b4ee5e9 --- /dev/null +++ b/lib/btc.js @@ -0,0 +1,45 @@ + var http = require('http'); +var btcCache = {}; +exports.doBTC = function (req,res) { + console.log('Bitcoin request'); + function btcQuery(callback, r) { + var req = r; + var options = { + host: 'api.coindesk.com', + // port: 80, + path: '/v1/bpi/currentprice.json', + // method: 'GET', + headers: { + /* 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(data)*/ + + } + }; + + http.request(options).on('response', function (response) { + var data = ''; + response.on("data", function (chunk) { + data += chunk; + }); + response.on('end', function () { + callback(JSON.parse(data), r); + }); + }).end(); + } + + var now = new Date(); + if (now - GLOBAL.lastcheck > (59000 )) { + btcQuery(function (a, b) { + console.log(a); + btcCache = a; + GLOBAL.lastcheck = now; + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(btcCache)); + }, res) + } + else { + console.log("Using cache"); + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(btcCache)); + } + }; diff --git a/lib/btc.min.js b/lib/btc.min.js new file mode 100644 index 0000000..1a4ccf9 --- /dev/null +++ b/lib/btc.min.js @@ -0,0 +1,2 @@ +var http=require("http"),btcCache={};exports.doBTC=function(e,o){function n(e,o){var n={host:"api.coindesk.com",path:"/v1/bpi/currentprice.json",headers:{}};http.request(n).on("response",function(n){var r="";n.on("data",function(e){r+=e}),n.on("end",function(){e(JSON.parse(r),o)})}).end()}console.log("Bitcoin request");var r=new Date;r-GLOBAL.lastcheck>59e3?n(function(e){console.log(e),btcCache=e,GLOBAL.lastcheck=r,o.setHeader("Content-Type","application/json"),o.end(JSON.stringify(btcCache))},o):(console.log("Using cache"),o.setHeader("Content-Type","application/json"),o.end(JSON.stringify(btcCache)))}; +//# sourceMappingURL=btc.min.js.map diff --git a/lib/btc.min.js.map b/lib/btc.min.js.map new file mode 100644 index 0000000..b6a9db2 --- /dev/null +++ b/lib/btc.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["btc.js"],"names":["http","require","btcCache","exports","doBTC","req","res","btcQuery","callback","r","options","host","path","headers","request","on","response","data","chunk","JSON","parse","end","console","log","now","Date","GLOBAL","lastcheck","a","setHeader","stringify"],"mappings":"AAAC,GAAIA,MAAOC,QAAQ,QAChBC,WACJC,SAAQC,MAAQ,SAAUC,EAAIC,GAEtB,QAASC,GAASC,EAAUC,GACxB,GACIC,IACAC,KAAM,mBAENC,KAAM,4BAENC,WAOJb,MAAKc,QAAQJ,GAASK,GAAG,WAAY,SAAUC,GAC3C,GAAIC,GAAO,EACXD,GAASD,GAAG,OAAQ,SAAUG,GAC1BD,GAAQC,IAEZF,EAASD,GAAG,MAAO,WACfP,EAASW,KAAKC,MAAMH,GAAOR,OAEhCY,MAvBPC,QAAQC,IAAI,kBA0BZ,IAAIC,GAAM,GAAIC,KACVD,GAAME,OAAOC,UAAY,KACzBpB,EAAS,SAAUqB,GACfN,QAAQC,IAAIK,GACZ1B,SAAW0B,EACXF,OAAOC,UAAYH,EACnBlB,EAAIuB,UAAU,eAAgB,oBAC9BvB,EAAIe,IAAIF,KAAKW,UAAU5B,YACxBI,IAGHgB,QAAQC,IAAI,eACZjB,EAAIuB,UAAU,eAAgB,oBAC9BvB,EAAIe,IAAIF,KAAKW,UAAU5B"} \ No newline at end of file diff --git a/lib/fx.js b/lib/fx.js new file mode 100644 index 0000000..cc418e1 --- /dev/null +++ b/lib/fx.js @@ -0,0 +1,46 @@ + var http = require('http'); +var fxCache = {}; +exports.doFx = function (req,res) { + console.log('FX request'); + function fxQuery(callback, r) { + var req = r; + var options = { + host: 'openexchangerates.org', + // port: 80, + path: '/api/latest.json?app_id=0eb932cee3bc40259f824d4b4c96c7d2', + // method: 'GET', + headers: { + /* 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(data)*/ + + } + }; + + http.request(options).on('response', function (response) { + var data = ''; + response.on("data", function (chunk) { + data += chunk; + }); + response.on('end', function () { + callback(JSON.parse(data), r); + }); + }).end(); + } + + var now = new Date(); + if (now - GLOBAL.lastcheck > (60000 * 14)) { + fxQuery(function (a, b) { + console.log(a); + fxCache = a; + GLOBAL.lastcheck = now; + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(fxCache)); + }, res); + } + else { + console.log("Using cache"); + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(fxCache)); + } + +}; diff --git a/lib/fx.min.js b/lib/fx.min.js new file mode 100644 index 0000000..700f597 --- /dev/null +++ b/lib/fx.min.js @@ -0,0 +1,2 @@ +var http=require("http"),fxCache={};exports.doFx=function(e,o){function n(e,o){var n={host:"openexchangerates.org",path:"/api/latest.json?app_id=0eb932cee3bc40259f824d4b4c96c7d2",headers:{}};http.request(n).on("response",function(n){var r="";n.on("data",function(e){r+=e}),n.on("end",function(){e(JSON.parse(r),o)})}).end()}console.log("FX request");var r=new Date;r-GLOBAL.lastcheck>84e4?n(function(e){console.log(e),fxCache=e,GLOBAL.lastcheck=r,o.setHeader("Content-Type","application/json"),o.end(JSON.stringify(fxCache))},o):(console.log("Using cache"),o.setHeader("Content-Type","application/json"),o.end(JSON.stringify(fxCache)))}; +//# sourceMappingURL=fx.min.js.map diff --git a/lib/fx.min.js.map b/lib/fx.min.js.map new file mode 100644 index 0000000..949864b --- /dev/null +++ b/lib/fx.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["fx.js"],"names":["http","require","fxCache","exports","doFx","req","res","fxQuery","callback","r","options","host","path","headers","request","on","response","data","chunk","JSON","parse","end","console","log","now","Date","GLOBAL","lastcheck","a","setHeader","stringify"],"mappings":"AAAC,GAAIA,MAAOC,QAAQ,QAChBC,UACJC,SAAQC,KAAO,SAAUC,EAAIC,GAErB,QAASC,GAAQC,EAAUC,GACvB,GACIC,IACAC,KAAM,wBAENC,KAAM,2DAENC,WAOJb,MAAKc,QAAQJ,GAASK,GAAG,WAAY,SAAUC,GAC3C,GAAIC,GAAO,EACXD,GAASD,GAAG,OAAQ,SAAUG,GAC1BD,GAAQC,IAEZF,EAASD,GAAG,MAAO,WACfP,EAASW,KAAKC,MAAMH,GAAOR,OAEhCY,MAvBPC,QAAQC,IAAI,aA0BZ,IAAIC,GAAM,GAAIC,KACVD,GAAME,OAAOC,UAAY,KACzBpB,EAAQ,SAAUqB,GACdN,QAAQC,IAAIK,GACZ1B,QAAU0B,EACVF,OAAOC,UAAYH,EACnBlB,EAAIuB,UAAU,eAAgB,oBAC9BvB,EAAIe,IAAIF,KAAKW,UAAU5B,WACxBI,IAGHgB,QAAQC,IAAI,eACZjB,EAAIuB,UAAU,eAAgB,oBAC9BvB,EAAIe,IAAIF,KAAKW,UAAU5B"} \ No newline at end of file diff --git a/lib/train.js b/lib/train.js new file mode 100644 index 0000000..ac3d5f8 --- /dev/null +++ b/lib/train.js @@ -0,0 +1,130 @@ +// train.js +var http = require('http'); +var trainCache = { + last: {}, + data: {} +}; + +module.exports = { + + + dbe_glq: function(req, res) { + + // http://huxley.apphb.com/all/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 + // http://huxley.apphb.com/all/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 + + console.log('DBE:GLQ request'); + + function Query(callback, r) { + var req = r; + var options = { + host: 'huxley.apphb.com', + // port: 80, + path: '/next/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8', + //method: 'GET', + headers: { + } + }; + + try { + http.request(options).on('response', function(response) { + var data = ''; + response.on("data", function(chunk) { + data += chunk; + }); + response.on('end', function() { + callback(JSON.parse(data), r); + }); + }).end(); + } catch (e) { + console.log(e); + } + } + + var now = new Date(); + var nowSeconds = (now.getHours() * (60 * 60)) + (now.getMinutes() * 60); + console.log('Now Seconds: ' + nowSeconds); + if (trainCache.last.dbeglq == null || nowSeconds != trainCache.last.dbeglq) { + Query(function(a, b) { + //console.log(a); + var ts = a.departures[0].service; + var output = {}; + //GLOBAL.lastcheck = now; + console.log(ts.sta); + // console.log(toSeconds(ts.sta)); + + output.sta = ts.sta; + output.eta = ts.eta; + trainCache.data.dbeglq = output; + // trainCache.last.dbeglq = toSeconds(ts.sta); + // console.log(ts); + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(trainCache.data.dbeglq)); + }, res); + + } + }, + glq_dbe: function(req, res) { + + // http://huxley.apphb.com/all/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 + // http://huxley.apphb.com/all/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8 + + console.log('GLQ:DBE request'); + + function Query(callback, r) { + var req = r; + var options = { + host: 'huxley.apphb.com', + // port: 80, + path: '/next/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8', + //method: 'GET', + headers: { + } + }; + + try { + http.request(options).on('response', function(response) { + var data = ''; + response.on("data", function(chunk) { + data += chunk; + }); + response.on('end', function() { + callback(JSON.parse(data), r); + }); + }).end(); + } catch (e) { + console.log(e); + } + } + + var now = new Date(); + var nowSeconds = (now.getHours() * (60 * 60)) + (now.getMinutes() * 60); + console.log('Now Seconds: ' + nowSeconds); + if (trainCache.last.glqdbe == null || nowSeconds != trainCache.last.dbeglq) { + Query(function(a, b) { + //console.log(a); + var ts = a.departures[0].service; + var output = {}; + //GLOBAL.lastcheck = now; + console.log(ts.sta); + console.log(toSeconds(ts.sta)); + + output.sta = ts.sta; + output.eta = ts.eta; + trainCache.data.glqdbe = output; + // trainCache.last.glqdbe = toSeconds(ts.sta); + // console.log(ts); + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(trainCache.data.glqdbe)); + }, res); + + } + } + +}; + +function toSeconds(inval) { + var a = inval.split(':'); + return ((parseInt(a[0]) * (60 * 60)) + (parseInt(a[1]) * 60)); + +} diff --git a/lib/train.min.js b/lib/train.min.js new file mode 100644 index 0000000..56916c8 --- /dev/null +++ b/lib/train.min.js @@ -0,0 +1,2 @@ +function toSeconds(e){var t=e.split(":");return 3600*parseInt(t[0])+60*parseInt(t[1])}var http=require("http"),trainCache={last:{},data:{}};module.exports={dbe_glq:function(e,t){function n(e,t){var n={host:"huxley.apphb.com",path:"/next/dbe/to/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8",headers:{}};try{http.request(n).on("response",function(n){var o="";n.on("data",function(e){o+=e}),n.on("end",function(){e(JSON.parse(o),t)})}).end()}catch(o){console.log(o)}}console.log("DBE:GLQ request");var o=new Date,a=3600*o.getHours()+60*o.getMinutes();console.log("Now Seconds: "+a),(null==trainCache.last.dbeglq||a!=trainCache.last.dbeglq)&&n(function(e){var n=e.departures[0].service,o={};console.log(n.sta),o.sta=n.sta,o.eta=n.eta,trainCache.data.dbeglq=o,t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(trainCache.data.dbeglq))},t)},glq_dbe:function(e,t){function n(e,t){var n={host:"huxley.apphb.com",path:"/next/dbe/from/glq/1?accessToken=215b99fe-b237-4a01-aadc-cf315d6756d8",headers:{}};try{http.request(n).on("response",function(n){var o="";n.on("data",function(e){o+=e}),n.on("end",function(){e(JSON.parse(o),t)})}).end()}catch(o){console.log(o)}}console.log("GLQ:DBE request");var o=new Date,a=3600*o.getHours()+60*o.getMinutes();console.log("Now Seconds: "+a),(null==trainCache.last.glqdbe||a!=trainCache.last.dbeglq)&&n(function(e){var n=e.departures[0].service,o={};console.log(n.sta),console.log(toSeconds(n.sta)),o.sta=n.sta,o.eta=n.eta,trainCache.data.glqdbe=o,t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(trainCache.data.glqdbe))},t)}}; +//# sourceMappingURL=train.min.js.map diff --git a/lib/train.min.js.map b/lib/train.min.js.map new file mode 100644 index 0000000..ac2d061 --- /dev/null +++ b/lib/train.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["train.js"],"names":["toSeconds","inval","a","split","parseInt","http","require","trainCache","last","data","module","exports","dbe_glq","req","res","Query","callback","r","options","host","path","headers","request","on","response","chunk","JSON","parse","end","e","console","log","now","Date","nowSeconds","getHours","getMinutes","dbeglq","ts","departures","service","output","sta","eta","setHeader","stringify","glq_dbe","glqdbe"],"mappings":"AA6HA,QAASA,WAAUC,GACf,GAAIC,GAAID,EAAME,MAAM,IACpB,OAA0B,MAAjBC,SAASF,EAAE,IAAqC,GAAjBE,SAASF,EAAE,IA9HvD,GAAIG,MAAOC,QAAQ,QACfC,YACAC,QACAC,QAGJC,QAAOC,SAGHC,QAAS,SAASC,EAAKC,GAOnB,QAASC,GAAMC,EAAUC,GACrB,GACIC,IACAC,KAAM,mBAENC,KAAM,sEAENC,WAIJ,KACIhB,KAAKiB,QAAQJ,GAASK,GAAG,WAAY,SAASC,GAC1C,GAAIf,GAAO,EACXe,GAASD,GAAG,OAAQ,SAASE,GACzBhB,GAAQgB,IAEZD,EAASD,GAAG,MAAO,WACfP,EAASU,KAAKC,MAAMlB,GAAOQ,OAEhCW,MACL,MAAOC,GACLC,QAAQC,IAAIF,IAxBpBC,QAAQC,IAAI,kBA4BZ,IAAIC,GAAM,GAAIC,MACVC,EAA+B,KAAjBF,EAAIG,WAA8C,GAAnBH,EAAII,YACrDN,SAAQC,IAAI,gBAAkBG,IACA,MAA1B3B,WAAWC,KAAK6B,QAAkBH,GAAc3B,WAAWC,KAAK6B,SAChEtB,EAAM,SAASb,GAEX,GAAIoC,GAAKpC,EAAEqC,WAAW,GAAGC,QACrBC,IAEJX,SAAQC,IAAIO,EAAGI,KAGfD,EAAOC,IAAMJ,EAAGI,IAChBD,EAAOE,IAAML,EAAGK,IAChBpC,WAAWE,KAAK4B,OAASI,EAGzB3B,EAAI8B,UAAU,eAAgB,oBAC9B9B,EAAIc,IAAIF,KAAKmB,UAAUtC,WAAWE,KAAK4B,UACxCvB,IAIXgC,QAAS,SAASjC,EAAKC,GAOnB,QAASC,GAAMC,EAAUC,GACrB,GACIC,IACAC,KAAM,mBAENC,KAAM,wEAENC,WAIJ,KACIhB,KAAKiB,QAAQJ,GAASK,GAAG,WAAY,SAASC,GAC1C,GAAIf,GAAO,EACXe,GAASD,GAAG,OAAQ,SAASE,GACzBhB,GAAQgB,IAEZD,EAASD,GAAG,MAAO,WACfP,EAASU,KAAKC,MAAMlB,GAAOQ,OAEhCW,MACL,MAAOC,GACLC,QAAQC,IAAIF,IAxBpBC,QAAQC,IAAI,kBA4BZ,IAAIC,GAAM,GAAIC,MACVC,EAA+B,KAAjBF,EAAIG,WAA8C,GAAnBH,EAAII,YACrDN,SAAQC,IAAI,gBAAkBG,IACA,MAA1B3B,WAAWC,KAAKuC,QAAkBb,GAAc3B,WAAWC,KAAK6B,SAChEtB,EAAM,SAASb,GAEX,GAAIoC,GAAKpC,EAAEqC,WAAW,GAAGC,QACrBC,IAEJX,SAAQC,IAAIO,EAAGI,KACfZ,QAAQC,IAAI/B,UAAUsC,EAAGI,MAEzBD,EAAOC,IAAMJ,EAAGI,IAChBD,EAAOE,IAAML,EAAGK,IAChBpC,WAAWE,KAAKsC,OAASN,EAGzB3B,EAAI8B,UAAU,eAAgB,oBAC9B9B,EAAIc,IAAIF,KAAKmB,UAAUtC,WAAWE,KAAKsC,UACxCjC"} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..11ab6df --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "silvrtree", + "version": "0.1.1", + "devDependencies": { + "mongodb": "*", + "node-rss": "^1.0.1", + "pg": "*" + }, + "dependencies": { + "express": "3.x" + } +} diff --git a/routes/btc.js b/routes/btc.js new file mode 100644 index 0000000..411e661 --- /dev/null +++ b/routes/btc.js @@ -0,0 +1,3 @@ +/** + * Created by martind on 14/11/14. + */ diff --git a/web-server.js b/web-server.js new file mode 100644 index 0000000..cccb84d --- /dev/null +++ b/web-server.js @@ -0,0 +1,66 @@ +var express = require('express'), path = require('path'), http = require('http'), fx = require('./lib/fx'), btc = require('./lib/btc'), train = require('./lib/train') + //train = require('lib/train') +/* ,submit = require('./routes/mongo/submit') */ + ; +var app = express(); +GLOBAL.lastcheck = 0; +var btcCache = {}, fxCache = {} , trainCache = {}; + +app.configure(function () { + app.set('port', process.env.PORT || 4545); + app.use(express.logger('dev')); + app.use(express.cookieParser()); + app.use(express.session({secret: '1234567890QWERTY'})); + /* 'default', 'short', 'tiny', 'dev' */ + app.use(express.methodOverride()); + + app.use(express.bodyParser()); + + app.use(function (req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "X-Requested-With"); + next(); + }); + app.use(app.router); + app.use(express.static(path.join(__dirname, 'app'))); + app.use(express.errorHandler({dumpExceptions: true, showStack: true})); + + app.use('/btc', btc.doBTC); + + app.use('/fx', fx.doFx); + + app.use('/dbeglq', train.dbe_glq); + + app.use('/glqdbe', train.glq_dbe); + + app.use('/lot', function (req, res) { + var pg = require('pg'); + + var conString = "postgres://pguser:1V3D4m526i@localhost/silver"; + console.log(conString); + + + var client = new pg.Client(conString); + var q = 'select * from lot order by d desc'; + client.connect(function(err) { + if(err) { + return console.error('could not connect to postgres', err); + } + client.query(q, function(err, result) { + if(err) { + return console.error('error running query', err); + } + console.log(result.rows[0].theTime); + //output: Tue Jan 15 2013 19:12:47 GMT-600 (CST) + client.end(); + }); + }); + }); +}); + +/** + * create the server + */ +http.createServer(app).listen(app.get('port'), function () { + console.log("Express server listening on port " + app.get('port')); +}); diff --git a/web-server.min.js b/web-server.min.js new file mode 100644 index 0000000..e471089 --- /dev/null +++ b/web-server.min.js @@ -0,0 +1,2 @@ +var express=require("express"),path=require("path"),http=require("http"),fx=require("./lib/fx"),btc=require("./lib/btc"),train=require("./lib/train"),app=express();GLOBAL.lastcheck=0;var btcCache={},fxCache={},trainCache={};app.configure(function(){app.set("port",process.env.PORT||4545),app.use(express.logger("dev")),app.use(express.cookieParser()),app.use(express.session({secret:"1234567890QWERTY"})),app.use(express.methodOverride()),app.use(express.bodyParser()),app.use(function(e,t,o){t.header("Access-Control-Allow-Origin","*"),t.header("Access-Control-Allow-Headers","X-Requested-With"),o()}),app.use(app.router),app.use(express.static(path.join(__dirname,"app"))),app.use(express.errorHandler({dumpExceptions:!0,showStack:!0})),app.use("/btc",btc.doBTC),app.use("/fx",fx.doFx),app.use("/dbeglq",train.dbe_glq),app.use("/glqdbe",train.glq_dbe),app.use("/lot",function(){var e=require("pg"),t="postgres://pguser:1V3D4m526i@localhost/silver";console.log(t);var o=new e.Client(t),n="select * from lot order by d desc";o.connect(function(e){return e?console.error("could not connect to postgres",e):void o.query(n,function(e,t){return e?console.error("error running query",e):(console.log(t.rows[0].theTime),void o.end())})})})}),http.createServer(app).listen(app.get("port"),function(){console.log("Express server listening on port "+app.get("port"))}); +//# sourceMappingURL=web-server.min.js.map diff --git a/web-server.min.js.map b/web-server.min.js.map new file mode 100644 index 0000000..0255b81 --- /dev/null +++ b/web-server.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["web-server.js"],"names":["express","require","path","http","fx","btc","train","app","GLOBAL","lastcheck","btcCache","fxCache","trainCache","configure","set","process","env","PORT","use","logger","cookieParser","session","secret","methodOverride","bodyParser","req","res","next","header","router","static","join","__dirname","errorHandler","dumpExceptions","showStack","doBTC","doFx","dbe_glq","glq_dbe","pg","conString","console","log","client","Client","q","connect","err","error","query","result","rows","theTime","end","createServer","listen","get"],"mappings":"AAAA,GAAIA,SAAUC,QAAQ,WAAYC,KAAOD,QAAQ,QAASE,KAAOF,QAAQ,QAASG,GAAKH,QAAQ,YAAaI,IAAMJ,QAAQ,aAAcK,MAAQL,QAAQ,eAIpJM,IAAMP,SACVQ,QAAOC,UAAY,CACnB,IAAIC,aAAeC,WAAeC,aAElCL,KAAIM,UAAU,WACVN,IAAIO,IAAI,OAAQC,QAAQC,IAAIC,MAAQ,MACpCV,IAAIW,IAAIlB,QAAQmB,OAAO,QACvBZ,IAAIW,IAAIlB,QAAQoB,gBAChBb,IAAIW,IAAIlB,QAAQqB,SAASC,OAAQ,sBAEjCf,IAAIW,IAAIlB,QAAQuB,kBAEhBhB,IAAIW,IAAIlB,QAAQwB,cAEhBjB,IAAIW,IAAI,SAAUO,EAAKC,EAAKC,GACxBD,EAAIE,OAAO,8BAA+B,KAC1CF,EAAIE,OAAO,+BAAgC,oBAC3CD,MAEJpB,IAAIW,IAAIX,IAAIsB,QACZtB,IAAIW,IAAIlB,QAAQ8B,OAAO5B,KAAK6B,KAAKC,UAAW,SAC5CzB,IAAIW,IAAIlB,QAAQiC,cAAcC,gBAAgB,EAAMC,WAAW,KAE/D5B,IAAIW,IAAI,OAAQb,IAAI+B,OAEpB7B,IAAIW,IAAI,MAAOd,GAAGiC,MAElB9B,IAAIW,IAAI,UAAWZ,MAAMgC,SAEzB/B,IAAIW,IAAI,UAAWZ,MAAMiC,SAEzBhC,IAAIW,IAAI,OAAQ,WACZ,GAAIsB,GAAKvC,QAAQ,MAEbwC,EAAY,+CAChBC,SAAQC,IAAIF,EAGZ,IAAIG,GAAS,GAAIJ,GAAGK,OAAOJ,GACvBK,EAAI,mCACRF,GAAOG,QAAQ,SAASC,GACpB,MAAGA,GACQN,QAAQO,MAAM,gCAAiCD,OAE1DJ,GAAOM,MAAMJ,EAAG,SAASE,EAAKG,GAC1B,MAAGH,GACQN,QAAQO,MAAM,sBAAuBD,IAEhDN,QAAQC,IAAIQ,EAAOC,KAAK,GAAGC,aAE3BT,GAAOU,eASvBnD,KAAKoD,aAAahD,KAAKiD,OAAOjD,IAAIkD,IAAI,QAAS,WAC3Cf,QAAQC,IAAI,oCAAsCpC,IAAIkD,IAAI"} \ No newline at end of file diff --git a/web-server.old.js b/web-server.old.js new file mode 100644 index 0000000..e9d37f9 --- /dev/null +++ b/web-server.old.js @@ -0,0 +1,145 @@ +var express = require('express'), path = require('path'), http = require('http') +/* ,submit = require('./routes/mongo/submit') */ + ; +var app = express(); +var lastcheck = 0; +var btcCache = {}, fxCache = {} , trainCache = {}; + +app.configure(function () { + app.set('port', process.env.PORT || 9000); + app.use(express.logger('dev')); + app.use(express.cookieParser()); + app.use(express.session({secret: '1234567890QWERTY'})); + /* 'default', 'short', 'tiny', 'dev' */ + app.use(express.methodOverride()); + + app.use(express.bodyParser()); + + app.use(function (req, res, next) { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "X-Requested-With"); + next(); + }); + app.use(app.router); + app.use(express.static(path.join(__dirname, 'app'))); + app.use(express.errorHandler({dumpExceptions: true, showStack: true})); + + app.use('/btc', function (req, res) { + console.log('Bitcoin request'); + function btcQuery(callback, r) { + var req = r; + var options = { + host: 'api.coindesk.com', + // port: 80, + path: '/v1/bpi/currentprice.json', + // method: 'GET', + headers: { + /* 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(data)*/ + + } + }; + + http.request(options).on('response', function (response) { + var data = ''; + response.on("data", function (chunk) { + data += chunk; + }); + response.on('end', function () { + callback(JSON.parse(data), r); + }); + }).end(); + } + + var now = new Date(); + if (now - lastcheck > (59000 )) { + btcQuery(function (a, b) { + console.log(a); + btcCache = a; + lastcheck = now; + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(btcCache)); + }, res) + } + else { + console.log("Using cache"); + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(btcCache)); + } + }); + + app.use('/fx', function (req, res) { + console.log('FX request'); + function fxQuery(callback, r) { + var req = r; + var options = { + host: 'openexchangerates.org', + // port: 80, + path: '/api/latest.json?app_id=0eb932cee3bc40259f824d4b4c96c7d2', + // method: 'GET', + headers: { + /* 'Content-Type': 'application/json', + 'Content-Length': Buffer.byteLength(data)*/ + + } + }; + + http.request(options).on('response', function (response) { + var data = ''; + response.on("data", function (chunk) { + data += chunk; + }); + response.on('end', function () { + callback(JSON.parse(data), r); + }); + }).end(); + } + + var now = new Date(); + if (now - lastcheck > (60000 * 14)) { + fxQuery(function (a, b) { + console.log(a); + fxCache = a; + lastcheck = now; + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(fxCache)); + }, res); + } + else { + console.log("Using cache"); + res.setHeader('Content-Type', 'application/json'); + res.end(JSON.stringify(fxCache)); + } + }); + + app.use('/lot', function (req, res) { + var pg = require('pg'); + + var conString = "postgres://pguser:1V3D4m526i@localhost/silver"; + console.log(conString); + + + var client = new pg.Client(conString); + var q = 'select * from lot order by d desc'; + client.connect(function(err) { + if(err) { + return console.error('could not connect to postgres', err); + } + client.query(q, function(err, result) { + if(err) { + return console.error('error running query', err); + } + console.log(result.rows[0].theTime); + //output: Tue Jan 15 2013 19:12:47 GMT-600 (CST) + client.end(); + }); + }); + }); +}); + +/** + * create the server + */ +http.createServer(app).listen(app.get('port'), function () { + console.log("Express server listening on port " + app.get('port')); +}); diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..c172f60 --- /dev/null +++ b/www/index.html @@ -0,0 +1,7 @@ + + + + + +hello + diff --git a/www/slack.htm b/www/slack.htm new file mode 100644 index 0000000..bc95838 --- /dev/null +++ b/www/slack.htm @@ -0,0 +1,487 @@ + + + + Slack + + + + +
+

Slack - I have plenty of talent and vision I just don't give a damn

+ +
+

----  ----   ---- +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Starting Points/MetasitesToolsBitcoin
+ + + + + + + + +
Computer NewsWeather ReportsFree Email WEBpages
+ + + + + + + + +
Job SearchingEntertainmentTravel
+ + + + + + + + +
Computer Software, etc.Reference & Special sitesInternet Money
+ + + + + + + + +
+
+
+ + +