From 874de7965682c49ccc189730adbfbda26ff92526 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 30 Jul 2015 16:51:53 +0100 Subject: [PATCH] zprogress and updates tech.js --- bower.json | 16 +++++ html/feeds.html | 4 +- html/js/app.prod.js | 8 +-- html/js/app.prod.min.js | 2 +- html/js/app.prod.min.js.map | 2 +- html/js/fx.js | 123 +++++++++++++++++++++++++++++++++++ html/js/fx_methods.js | 71 ++++++++++++++++++++ html/js/zprogress.js | 74 +++++++++++++++++++++ html/js/zprogress.min.js | 2 + html/js/zprogress.min.js.map | 1 + tech.js | 4 ++ tech.min.js | 2 + tech.min.js.map | 1 + 13 files changed, 303 insertions(+), 7 deletions(-) create mode 100644 bower.json create mode 100644 html/js/fx.js create mode 100644 html/js/fx_methods.js create mode 100644 html/js/zprogress.js create mode 100644 html/js/zprogress.min.js create mode 100644 html/js/zprogress.min.js.map create mode 100644 tech.min.js create mode 100644 tech.min.js.map diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..5585a61 --- /dev/null +++ b/bower.json @@ -0,0 +1,16 @@ +{ + "name": "rinser", + "version": "0.0.0", + "main": "app.js", + "moduleType": [ + "node" + ], + "license": "MIT", + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests" + ] +} diff --git a/html/feeds.html b/html/feeds.html index af0bf81..77233b3 100644 --- a/html/feeds.html +++ b/html/feeds.html @@ -67,7 +67,9 @@ --> - + + + diff --git a/html/js/app.prod.js b/html/js/app.prod.js index 52efe28..ac03dee 100644 --- a/html/js/app.prod.js +++ b/html/js/app.prod.js @@ -45,7 +45,7 @@ var APP = { console.log(this); console.log('get ' + this.feeds[this.refreshStep]); $('#lastupdate').empty().append('Refreshing...'); - NProgress.start(); + $.zprogress.start(); this.doRefresh(); }, @@ -61,7 +61,7 @@ var APP = { }); } else { console.log('Done'); - NProgress.inc(0.2); + $.zprogress.inc(0.2); this.doSave(); } }, @@ -72,7 +72,7 @@ var APP = { console.log(this._storage); this.refreshStep++; - NProgress.inc(0.2); + $.zprogress.inc(0.2); this.doRefresh(); }, doSave: function() { @@ -82,7 +82,7 @@ var APP = { localStorage.setItem('lastUpdated', this.lastUpdated); localStorage.setItem('_storage', JSON.stringify(this._storage)); this.getLastUpdateDate(); - NProgress.done(true); + $.zprogress.done(true); }, doLoad: function() { diff --git a/html/js/app.prod.min.js b/html/js/app.prod.min.js index e266b76..9811e8b 100644 --- a/html/js/app.prod.min.js +++ b/html/js/app.prod.min.js @@ -1,2 +1,2 @@ -var APP={refreshStep:0,preUrl:"/",_storage:{lastupdated:null,feeds:{}},_list:null,_feed:null,feeds:["paleo","lifestyle"],lastUpdated:null,preCache:function(){this._list=new EJS({url:"ejs/list.ejs"}),this._feed=new EJS({url:"ejs/test.ejs"})},init:function(){$("#refresh").on("click",$.proxy(this.refresh,this)),console.log("app starting..."),this.preCache(),this.doLoad(),this.getLastUpdateDate(),console.log("Last updated: "+this.lastUpdated)},getLastUpdateDate:function(){var e,t;null==this.lastUpdated?$("#lastupdate").empty().append("Never"):(t=new Date(this.lastUpdated),e=moment(t).startOf("minute").fromNow(),console.log(e),$("#lastupdate").empty().append(e))},refresh:function(){this.refreshStep=0,console.log("refresh"),console.log(this),console.log("get "+this.feeds[this.refreshStep]),$("#lastupdate").empty().append("Refreshing..."),NProgress.start(),this.doRefresh()},doRefresh:function(){var e=this;if(this.refreshStep 0 && typeof properties === 'object') { + cssValues[transitionProperty] = cssProperties.join(', ') + cssValues[transitionDuration] = duration + 's' + cssValues[transitionDelay] = delay + 's' + cssValues[transitionTiming] = (ease || 'linear') + } + } + + wrappedCallback = function(event){ + if (typeof event !== 'undefined') { + if (event.target !== event.currentTarget) return // makes sure the event didn't bubble from "below" + $(event.target).unbind(endEvent, wrappedCallback) + } else + $(this).unbind(endEvent, wrappedCallback) // triggered by setTimeout + + fired = true + $(this).css(cssReset) + callback && callback.call(this) + } + if (duration > 0){ + this.bind(endEvent, wrappedCallback) + // transitionEnd is not always firing on older Android phones + // so make sure it gets fired + setTimeout(function(){ + if (fired) return + wrappedCallback.call(that) + }, ((duration + delay) * 1000) + 25) + } + + // trigger page reflow so new elements can animate + this.size() && this.get(0).clientLeft + + this.css(cssValues) + + if (duration <= 0) setTimeout(function() { + that.each(function(){ wrappedCallback.call(this) }) + }, 0) + + return this + } + + testEl = null +})(Zepto) diff --git a/html/js/fx_methods.js b/html/js/fx_methods.js new file mode 100644 index 0000000..7503f3d --- /dev/null +++ b/html/js/fx_methods.js @@ -0,0 +1,71 @@ +// Zepto.js +// (c) 2010-2015 Thomas Fuchs +// Zepto.js may be freely distributed under the MIT license. + +;(function($, undefined){ + var document = window.document, docElem = document.documentElement, + origShow = $.fn.show, origHide = $.fn.hide, origToggle = $.fn.toggle + + function anim(el, speed, opacity, scale, callback) { + if (typeof speed == 'function' && !callback) callback = speed, speed = undefined + var props = { opacity: opacity } + if (scale) { + props.scale = scale + el.css($.fx.cssPrefix + 'transform-origin', '0 0') + } + return el.animate(props, speed, null, callback) + } + + function hide(el, speed, scale, callback) { + return anim(el, speed, 0, scale, function(){ + origHide.call($(this)) + callback && callback.call(this) + }) + } + + $.fn.show = function(speed, callback) { + origShow.call(this) + if (speed === undefined) speed = 0 + else this.css('opacity', 0) + return anim(this, speed, 1, '1,1', callback) + } + + $.fn.hide = function(speed, callback) { + if (speed === undefined) return origHide.call(this) + else return hide(this, speed, '0,0', callback) + } + + $.fn.toggle = function(speed, callback) { + if (speed === undefined || typeof speed == 'boolean') + return origToggle.call(this, speed) + else return this.each(function(){ + var el = $(this) + el[el.css('display') == 'none' ? 'show' : 'hide'](speed, callback) + }) + } + + $.fn.fadeTo = function(speed, opacity, callback) { + return anim(this, speed, opacity, null, callback) + } + + $.fn.fadeIn = function(speed, callback) { + var target = this.css('opacity') + if (target > 0) this.css('opacity', 0) + else target = 1 + return origShow.call(this).fadeTo(speed, target, callback) + } + + $.fn.fadeOut = function(speed, callback) { + return hide(this, speed, null, callback) + } + + $.fn.fadeToggle = function(speed, callback) { + return this.each(function(){ + var el = $(this) + el[ + (el.css('opacity') == 0 || el.css('display') == 'none') ? 'fadeIn' : 'fadeOut' + ](speed, callback) + }) + } + +})(Zepto) diff --git a/html/js/zprogress.js b/html/js/zprogress.js new file mode 100644 index 0000000..ee3ed93 --- /dev/null +++ b/html/js/zprogress.js @@ -0,0 +1,74 @@ +// zprogress (c) 2013 Thomas Fuchs +// MIT-licensed - https://github.com/madrobby/zprogress + +;(function($){ + var html = + ''+ + '
', + $wrapper, $indicator, value, timeout, + MARGIN = 12.5, + LMARGIN = MARGIN/100, + RMARGIN = 1 - LMARGIN + + function init(){ + if($wrapper) return + + $('body').append(html) + $wrapper = $('#zprogress') + $indicator = $('#zprogress_indicator') + } + + function anim(){ + $indicator.animate({ translateX: value*100+'%' }, 200) + } + + function clear(){ + if(timeout) clearTimeout(timeout) + timeout = undefined + } + + function trickle(){ + timeout = setTimeout(function(){ + $.zprogress.inc((RMARGIN-value)*.035*Math.random()) + trickle() + }, 350+(400*Math.random())) + } + + $.zprogress = { + start: function(){ + init() + clear() + value = LMARGIN + $wrapper.animate({ opacity: 1 }) + $indicator.animate({ translateX: '0%' }, 0) + setTimeout(function(){ + anim() + trickle() + },0) + }, + inc: function(delta){ + if(valuer&&(r+=e||.05),s()},set:function(e){t(),o(),r=e,s(),a()},done:function(){t(),o(),r=1,s(),setTimeout(function(){i.animate({opacity:0})},100)},color:function(e){t(),n.css({backgroundColor:e})}}}(Zepto); +//# sourceMappingURL=zprogress.min.js.map diff --git a/html/js/zprogress.min.js.map b/html/js/zprogress.min.js.map new file mode 100644 index 0000000..b4e9fa7 --- /dev/null +++ b/html/js/zprogress.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["zprogress.js"],"names":["$","init","$wrapper","append","html","$indicator","anim","animate","translateX","value","clear","timeout","clearTimeout","undefined","trickle","setTimeout","zprogress","inc","RMARGIN","Math","random","MARGIN","LMARGIN","start","opacity","delta","set","newValue","done","color","css","backgroundColor","Zepto"],"mappings":"CAGC,SAAUA,GAWT,QAASC,KACJC,IAEHF,EAAE,QAAQG,OAAOC,GACjBF,EAAWF,EAAE,cACbK,EAAaL,EAAE,yBAGjB,QAASM,KACPD,EAAWE,SAAUC,WAAkB,IAANC,EAAU,KAAO,KAGpD,QAASC,KACJC,GAASC,aAAaD,GACzBA,EAAUE,OAGZ,QAASC,KACPH,EAAUI,WAAW,WACnBf,EAAEgB,UAAUC,IAAoB,MAAfC,EAAQT,GAAYU,KAAKC,UAC1CN,KACC,IAAK,IAAIK,KAAKC,UA/BnB,GAKElB,GAAUG,EAAYI,EAAOE,EAL3BP,EACF,iSAKAiB,EAAS,KACTC,EAAUD,EAAO,IACjBH,EAAU,EAAII,CA0BhBtB,GAAEgB,WACAO,MAAO,WACLtB,IACAS,IACAD,EAAQa,EACRpB,EAASK,SAAUiB,QAAS,IAC5BnB,EAAWE,SAAUC,WAAY,MAAQ,GACzCO,WAAW,WACTT,IACAQ,KACA,IAEJG,IAAK,SAASQ,GACHP,EAANT,IAAeA,GAAOgB,GAAO,KAChCnB,KAEFoB,IAAK,SAASC,GACZ1B,IACAS,IACAD,EAAQkB,EACRrB,IACAQ,KAEFc,KAAM,WACJ3B,IACAS,IACAD,EAAQ,EACRH,IACAS,WAAW,WAAWb,EAASK,SAAUiB,QAAS,KAAO,MAE3DK,MAAO,SAASA,GACd5B,IACAI,EAAWyB,KAAMC,gBAAiBF,OAGrCG"} \ No newline at end of file diff --git a/tech.js b/tech.js index ea9a46a..c2f98d1 100644 --- a/tech.js +++ b/tech.js @@ -69,6 +69,10 @@ feeds.simple_test_feed = { { "count": 100, "feed_url": "http://feed.androidauthority.com/" + }, + { + "count": 100, + "feed_url": "https://feeds.feedburner.com/codinghorror" } ] }; diff --git a/tech.min.js b/tech.min.js new file mode 100644 index 0000000..abd6316 --- /dev/null +++ b/tech.min.js @@ -0,0 +1,2 @@ +var outputFile="tech",RssBraider=require("rss-braider"),fs=require("fs"),ejs=require("ejs"),read=require("fs").readFileSync,join=require("path").join,str=read(join(__dirname,"/templates/rss.ejs"),"utf8"),feeds={};feeds.simple_test_feed={feed_name:"feed",default_count:1,no_cdata_fields:[],meta:{title:"Technology",description:"Combined Tech Feed",site_url:"http://pipes.silvrtree.co.uk/tech.xml"},sources:[{count:100,feed_url:"http://feeds.feedburner.com/lenovoblogs/designmatters"},{count:100,feed_url:"http://www.engadget.com/rss.xml"},{count:100,feed_url:"http://www.computerweekly.com/rss/All-Computer-Weekly-content.xml"},{count:100,feed_url:"http://winsupersite.com/rss.xml"},{count:100,feed_url:"https://feeds.feedburner.com/TheGadgeteer"},{count:100,feed_url:"http://www.wired.com/category/gear/feed/"},{count:100,feed_url:"https://feeds2.feedburner.com/AndroidCommunity"},{count:100,feed_url:"https://feeds.feedburner.com/AndroidPolice"},{count:100,feed_url:"https://feeds.feedburner.com/AndroidPolice"},{count:100,feed_url:"https://feeds2.feedburner.com/PlanetAndroidCom"},{count:100,feed_url:"http://www.theverge.com/rss/frontpage"},{count:100,feed_url:"http://feed.androidauthority.com/"},{count:100,feed_url:"https://feeds.feedburner.com/codinghorror"}]};var braider_options={feeds:feeds,indent:" ",date_sort_order:"desc",log_level:"warn",dedupe_fields:["link","guid"]},rss_braider=RssBraider.createClient(braider_options);rss_braider.logger.level("off"),rss_braider.processFeed("simple_test_feed","json",function(e,t){if(e)return console.log(e);var s=JSON.parse(t),o=ejs.compile(str)(s);fs.writeFile(__dirname+"/html/"+outputFile+".html",o,function(e){return e?console.log(e):void console.log("The file was saved!")}),fs.writeFile(__dirname+"/html/"+outputFile+".json",t,function(e){return e?console.log(e):void console.log("The file was saved!")})}),rss_braider.processFeed("simple_test_feed","rss",function(e,t){return e?console.log(e):void fs.writeFile(__dirname+"/html/"+outputFile+".xml",t,function(e){return e?console.log(e):void console.log("The file was saved!")})}); +//# sourceMappingURL=tech.min.js.map diff --git a/tech.min.js.map b/tech.min.js.map new file mode 100644 index 0000000..ee24937 --- /dev/null +++ b/tech.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["tech.js"],"names":["outputFile","RssBraider","require","fs","ejs","read","readFileSync","join","str","__dirname","feeds","simple_test_feed","feed_name","default_count","no_cdata_fields","meta","title","description","site_url","sources","count","feed_url","braider_options","indent","date_sort_order","log_level","dedupe_fields","rss_braider","createClient","logger","level","processFeed","err","data","console","log","j","JSON","parse","ejsOutput","compile","writeFile"],"mappings":"AAAA,GAAIA,YAAa,OACbC,WAAaC,QAAQ,eACrBC,GAAKD,QAAQ,MACbE,IAAMF,QAAQ,OACdG,KAAOH,QAAQ,MAAMI,aACrBC,KAAOL,QAAQ,QAAQK,KACvBC,IAAMH,KAAKE,KAAKE,UAAW,sBAAuB,QAClDC,QAMJA,OAAMC,kBACFC,UAAa,OACbC,cAAiB,EACjBC,mBACAC,MACIC,MAAS,aACTC,YAAe,qBACfC,SAAY,yCAEhBC,UAEQC,MAAS,IACTC,SAAY,0DAGZD,MAAS,IACTC,SAAY,oCAIZD,MAAS,IACTC,SAAY,sEAGZD,MAAS,IACTC,SAAY,oCAGZD,MAAS,IACTC,SAAY,8CAGZD,MAAS,IACTC,SAAY,6CAGZD,MAAS,IACTC,SAAY,mDAGZD,MAAS,IACTC,SAAY,+CAGZD,MAAS,IACTC,SAAY,+CAGZD,MAAS,IACTC,SAAY,mDAGZD,MAAS,IACTC,SAAY,0CAGZD,MAAS,IACTC,SAAY,sCAGZD,MAAS,IACTC,SAAY,8CAIxB,IAAIC,kBACAZ,MAAOA,MACPa,OAAQ,OACRC,gBAAiB,OACjBC,UAAW,OACXC,eAAgB,OAAQ,SAExBC,YAAc1B,WAAW2B,aAAaN,gBAG1CK,aAAYE,OAAOC,MAAM,OAEzBH,YAAYI,YAAY,mBAAoB,OAAQ,SAAUC,EAAKC,GAC/D,GAAID,EACA,MAAOE,SAAQC,IAAIH,EAGvB,IAAII,GAAIC,KAAKC,MAAML,GACfM,EAAYnC,IAAIoC,QAAQhC,KAAK4B,EAEjCjC,IAAGsC,UAAUhC,UAAY,SAAWT,WAAa,QAASuC,EAAW,SAAUP,GAE3E,MAAIA,GACOE,QAAQC,IAAIH,OAGvBE,SAAQC,IAAI,yBAGfhC,GAAGsC,UAAUhC,UAAY,SAAWT,WAAa,QAASiC,EAAM,SAAUD,GACvE,MAAIA,GACOE,QAAQC,IAAIH,OAGvBE,SAAQC,IAAI,2BAIpBR,YAAYI,YAAY,mBAAoB,MAAO,SAAUC,EAAKC,GAC9D,MAAID,GACOE,QAAQC,IAAIH,OAEvB7B,IAAGsC,UAAUhC,UAAY,SAAWT,WAAa,OAAQiC,EAAM,SAAUD,GACrE,MAAIA,GACOE,QAAQC,IAAIH,OAGvBE,SAAQC,IAAI"} \ No newline at end of file