Add hourly updates from @sifen_trackbot to event timer
This is VERY hackish, it was literally a "gee wouldn't it be cool if it could do this? *whip out editor and start coding like a madman*" things. But it works (for now). Needs a lot of future proofing (and general rewriting) though.
This commit is contained in:
parent
679ab68e2e
commit
0953aa809b
4 changed files with 398 additions and 0 deletions
333
web_app/js/external/twitterFetcher.js
vendored
Normal file
333
web_app/js/external/twitterFetcher.js
vendored
Normal file
|
@ -0,0 +1,333 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* #### Twitter Post Fetcher v13.0 ####
|
||||||
|
* Coded by Jason Mayes 2015. A present to all the developers out there.
|
||||||
|
* www.jasonmayes.com
|
||||||
|
* Please keep this disclaimer with my code if you use it. Thanks. :-)
|
||||||
|
* Got feedback or questions, ask here:
|
||||||
|
* http://www.jasonmayes.com/projects/twitterApi/
|
||||||
|
* Github: https://github.com/jasonmayes/Twitter-Post-Fetcher
|
||||||
|
* Updates will be posted to this site.
|
||||||
|
*********************************************************************/
|
||||||
|
(function(root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define([], factory);
|
||||||
|
} else if (typeof exports === 'object') {
|
||||||
|
// Node. Does not work with strict CommonJS, but
|
||||||
|
// only CommonJS-like environments that support module.exports,
|
||||||
|
// like Node.
|
||||||
|
module.exports = factory();
|
||||||
|
} else {
|
||||||
|
// Browser globals.
|
||||||
|
factory();
|
||||||
|
}
|
||||||
|
}(this, function() {
|
||||||
|
var domNode = '';
|
||||||
|
var maxTweets = 20;
|
||||||
|
var parseLinks = true;
|
||||||
|
var queue = [];
|
||||||
|
var inProgress = false;
|
||||||
|
var printTime = true;
|
||||||
|
var printUser = true;
|
||||||
|
var formatterFunction = null;
|
||||||
|
var supportsClassName = true;
|
||||||
|
var showRts = true;
|
||||||
|
var customCallbackFunction = null;
|
||||||
|
var showInteractionLinks = true;
|
||||||
|
var showImages = false;
|
||||||
|
var targetBlank = true;
|
||||||
|
var lang = 'en';
|
||||||
|
var permalinks = true;
|
||||||
|
var script = null;
|
||||||
|
var scriptAdded = false;
|
||||||
|
|
||||||
|
function handleTweets(tweets){
|
||||||
|
if (customCallbackFunction === null) {
|
||||||
|
var x = tweets.length;
|
||||||
|
var n = 0;
|
||||||
|
var element = document.getElementById(domNode);
|
||||||
|
var html = '<ul>';
|
||||||
|
while(n < x) {
|
||||||
|
html += '<li>' + tweets[n] + '</li>';
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
html += '</ul>';
|
||||||
|
element.innerHTML = html;
|
||||||
|
} else {
|
||||||
|
customCallbackFunction(tweets);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function strip(data) {
|
||||||
|
return data.replace(/<b[^>]*>(.*?)<\/b>/gi, function(a,s){return s;})
|
||||||
|
.replace(/class=".*?"|data-query-source=".*?"|dir=".*?"|rel=".*?"/gi,
|
||||||
|
'');
|
||||||
|
}
|
||||||
|
|
||||||
|
function targetLinksToNewWindow(el) {
|
||||||
|
var links = el.getElementsByTagName('a');
|
||||||
|
for (var i = links.length - 1; i >= 0; i--) {
|
||||||
|
links[i].setAttribute('target', '_blank');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getElementsByClassName (node, classname) {
|
||||||
|
var a = [];
|
||||||
|
var regex = new RegExp('(^| )' + classname + '( |$)');
|
||||||
|
var elems = node.getElementsByTagName('*');
|
||||||
|
for (var i = 0, j = elems.length; i < j; i++) {
|
||||||
|
if(regex.test(elems[i].className)){
|
||||||
|
a.push(elems[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractImageUrl(image_data) {
|
||||||
|
if (image_data !== undefined) {
|
||||||
|
var data_src = image_data.innerHTML.match(/data-srcset="([A-z0-9%_\.-]+)/i)[0];
|
||||||
|
return decodeURIComponent(data_src).split('"')[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var twitterFetcher = {
|
||||||
|
fetch: function(config) {
|
||||||
|
if (config.maxTweets === undefined) {
|
||||||
|
config.maxTweets = 20;
|
||||||
|
}
|
||||||
|
if (config.enableLinks === undefined) {
|
||||||
|
config.enableLinks = true;
|
||||||
|
}
|
||||||
|
if (config.showUser === undefined) {
|
||||||
|
config.showUser = true;
|
||||||
|
}
|
||||||
|
if (config.showTime === undefined) {
|
||||||
|
config.showTime = true;
|
||||||
|
}
|
||||||
|
if (config.dateFunction === undefined) {
|
||||||
|
config.dateFunction = 'default';
|
||||||
|
}
|
||||||
|
if (config.showRetweet === undefined) {
|
||||||
|
config.showRetweet = true;
|
||||||
|
}
|
||||||
|
if (config.customCallback === undefined) {
|
||||||
|
config.customCallback = null;
|
||||||
|
}
|
||||||
|
if (config.showInteraction === undefined) {
|
||||||
|
config.showInteraction = true;
|
||||||
|
}
|
||||||
|
if (config.showImages === undefined) {
|
||||||
|
config.showImages = false;
|
||||||
|
}
|
||||||
|
if (config.linksInNewWindow === undefined) {
|
||||||
|
config.linksInNewWindow = true;
|
||||||
|
}
|
||||||
|
if (config.showPermalinks === undefined) {
|
||||||
|
config.showPermalinks = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inProgress) {
|
||||||
|
queue.push(config);
|
||||||
|
} else {
|
||||||
|
inProgress = true;
|
||||||
|
|
||||||
|
domNode = config.domId;
|
||||||
|
maxTweets = config.maxTweets;
|
||||||
|
parseLinks = config.enableLinks;
|
||||||
|
printUser = config.showUser;
|
||||||
|
printTime = config.showTime;
|
||||||
|
showRts = config.showRetweet;
|
||||||
|
formatterFunction = config.dateFunction;
|
||||||
|
customCallbackFunction = config.customCallback;
|
||||||
|
showInteractionLinks = config.showInteraction;
|
||||||
|
showImages = config.showImages;
|
||||||
|
targetBlank = config.linksInNewWindow;
|
||||||
|
permalinks = config.showPermalinks;
|
||||||
|
|
||||||
|
var head = document.getElementsByTagName('head')[0];
|
||||||
|
if (script !== null) {
|
||||||
|
head.removeChild(script);
|
||||||
|
}
|
||||||
|
script = document.createElement('script');
|
||||||
|
script.type = 'text/javascript';
|
||||||
|
script.src = 'https://cdn.syndication.twimg.com/widgets/timelines/' +
|
||||||
|
config.id + '?&lang=' + (config.lang || lang) +
|
||||||
|
'&callback=twitterFetcher.callback&' +
|
||||||
|
'suppress_response_codes=true&rnd=' + Math.random();
|
||||||
|
head.appendChild(script);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: function(data) {
|
||||||
|
var div = document.createElement('div');
|
||||||
|
div.innerHTML = data.body;
|
||||||
|
if (typeof(div.getElementsByClassName) === 'undefined') {
|
||||||
|
supportsClassName = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var tweets = [];
|
||||||
|
var authors = [];
|
||||||
|
var times = [];
|
||||||
|
var images = [];
|
||||||
|
var rts = [];
|
||||||
|
var tids = [];
|
||||||
|
var permalinksURL = [];
|
||||||
|
var x = 0;
|
||||||
|
|
||||||
|
if (supportsClassName) {
|
||||||
|
var tmp = div.getElementsByClassName('tweet');
|
||||||
|
while (x < tmp.length) {
|
||||||
|
if (tmp[x].getElementsByClassName('retweet-credit').length > 0) {
|
||||||
|
rts.push(true);
|
||||||
|
} else {
|
||||||
|
rts.push(false);
|
||||||
|
}
|
||||||
|
if (!rts[x] || rts[x] && showRts) {
|
||||||
|
tweets.push(tmp[x].getElementsByClassName('e-entry-title')[0]);
|
||||||
|
tids.push(tmp[x].getAttribute('data-tweet-id'));
|
||||||
|
authors.push(tmp[x].getElementsByClassName('p-author')[0]);
|
||||||
|
times.push(tmp[x].getElementsByClassName('dt-updated')[0]);
|
||||||
|
permalinksURL.push(tmp[x].getElementsByClassName('permalink')[0]);
|
||||||
|
if (tmp[x].getElementsByClassName('inline-media')[0] !== undefined) {
|
||||||
|
images.push(tmp[x].getElementsByClassName('inline-media')[0]);
|
||||||
|
} else {
|
||||||
|
images.push(undefined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var tmp = getElementsByClassName(div, 'tweet');
|
||||||
|
while (x < tmp.length) {
|
||||||
|
tweets.push(getElementsByClassName(tmp[x], 'e-entry-title')[0]);
|
||||||
|
tids.push(tmp[x].getAttribute('data-tweet-id'));
|
||||||
|
authors.push(getElementsByClassName(tmp[x], 'p-author')[0]);
|
||||||
|
times.push(getElementsByClassName(tmp[x], 'dt-updated')[0]);
|
||||||
|
permalinksURL.push(getElementsByClassName(tmp[x], 'permalink')[0]);
|
||||||
|
if (getElementsByClassName(tmp[x], 'inline-media')[0] !== undefined) {
|
||||||
|
images.push(getElementsByClassName(tmp[x], 'inline-media')[0]);
|
||||||
|
} else {
|
||||||
|
images.push(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getElementsByClassName(tmp[x], 'retweet-credit').length > 0) {
|
||||||
|
rts.push(true);
|
||||||
|
} else {
|
||||||
|
rts.push(false);
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tweets.length > maxTweets) {
|
||||||
|
tweets.splice(maxTweets, (tweets.length - maxTweets));
|
||||||
|
authors.splice(maxTweets, (authors.length - maxTweets));
|
||||||
|
times.splice(maxTweets, (times.length - maxTweets));
|
||||||
|
rts.splice(maxTweets, (rts.length - maxTweets));
|
||||||
|
images.splice(maxTweets, (images.length - maxTweets));
|
||||||
|
permalinksURL.splice(maxTweets, (permalinksURL.length - maxTweets));
|
||||||
|
}
|
||||||
|
|
||||||
|
var arrayTweets = [];
|
||||||
|
var x = tweets.length;
|
||||||
|
var n = 0;
|
||||||
|
while(n < x) {
|
||||||
|
if (typeof(formatterFunction) !== 'string') {
|
||||||
|
var datetimeText = times[n].getAttribute('datetime');
|
||||||
|
var newDate = new Date(times[n].getAttribute('datetime')
|
||||||
|
.replace(/-/g,'/').replace('T', ' ').split('+')[0]);
|
||||||
|
var dateString = formatterFunction(newDate, datetimeText);
|
||||||
|
times[n].setAttribute('aria-label', dateString);
|
||||||
|
|
||||||
|
if (tweets[n].innerText) {
|
||||||
|
// IE hack.
|
||||||
|
if (supportsClassName) {
|
||||||
|
times[n].innerText = dateString;
|
||||||
|
} else {
|
||||||
|
var h = document.createElement('p');
|
||||||
|
var t = document.createTextNode(dateString);
|
||||||
|
h.appendChild(t);
|
||||||
|
h.setAttribute('aria-label', dateString);
|
||||||
|
times[n] = h;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
times[n].textContent = dateString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var op = '';
|
||||||
|
if (parseLinks) {
|
||||||
|
if (targetBlank) {
|
||||||
|
targetLinksToNewWindow(tweets[n]);
|
||||||
|
if (printUser) {
|
||||||
|
targetLinksToNewWindow(authors[n]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (printUser) {
|
||||||
|
op += '<div class="user">' + strip(authors[n].innerHTML) +
|
||||||
|
'</div>';
|
||||||
|
}
|
||||||
|
op += '<p class="tweet">' + strip(tweets[n].innerHTML) + '</p>';
|
||||||
|
if (printTime) {
|
||||||
|
if (permalinks) {
|
||||||
|
op += '<p class="timePosted"><a href="' + permalinksURL[n] +
|
||||||
|
'">' + times[n].getAttribute('aria-label') + '</a></p>';
|
||||||
|
} else {
|
||||||
|
op += '<p class="timePosted">' +
|
||||||
|
times[n].getAttribute('aria-label') + '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (tweets[n].innerText) {
|
||||||
|
if (printUser) {
|
||||||
|
op += '<p class="user">' + authors[n].innerText + '</p>';
|
||||||
|
}
|
||||||
|
op += '<p class="tweet">' + tweets[n].innerText + '</p>';
|
||||||
|
if (printTime) {
|
||||||
|
op += '<p class="timePosted">' + times[n].innerText + '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (printUser) {
|
||||||
|
op += '<p class="user">' + authors[n].textContent + '</p>';
|
||||||
|
}
|
||||||
|
op += '<p class="tweet">' + tweets[n].textContent + '</p>';
|
||||||
|
if (printTime) {
|
||||||
|
op += '<p class="timePosted">' + times[n].textContent + '</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (showInteractionLinks) {
|
||||||
|
op += '<p class="interact"><a href="https://twitter.com/intent/' +
|
||||||
|
'tweet?in_reply_to=' + tids[n] + '" class="twitter_reply_icon"' +
|
||||||
|
(targetBlank ? ' target="_blank">' : '>') +
|
||||||
|
'Reply</a><a href="https://twitter.com/intent/retweet?tweet_id=' +
|
||||||
|
tids[n] + '" class="twitter_retweet_icon"' +
|
||||||
|
(targetBlank ? ' target="_blank">' : '>') + 'Retweet</a>' +
|
||||||
|
'<a href="https://twitter.com/intent/favorite?tweet_id=' +
|
||||||
|
tids[n] + '" class="twitter_fav_icon"' +
|
||||||
|
(targetBlank ? ' target="_blank">' : '>') + 'Favorite</a></p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showImages && images[n] !== undefined) {
|
||||||
|
op += '<div class="media">' +
|
||||||
|
'<img src="' + extractImageUrl(images[n]) +
|
||||||
|
'" alt="Image from tweet" />' + '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
arrayTweets.push(op);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
handleTweets(arrayTweets);
|
||||||
|
inProgress = false;
|
||||||
|
|
||||||
|
if (queue.length > 0) {
|
||||||
|
twitterFetcher.fetch(queue[0]);
|
||||||
|
queue.splice(0,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// It must be a global variable because it will be called by JSONP.
|
||||||
|
window.twitterFetcher = twitterFetcher;
|
||||||
|
|
||||||
|
return twitterFetcher;
|
||||||
|
}));
|
20
web_app/js/external/twitterFetcher_min.js
vendored
Normal file
20
web_app/js/external/twitterFetcher_min.js
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*********************************************************************
|
||||||
|
* #### Twitter Post Fetcher v13.1 ####
|
||||||
|
* Coded by Jason Mayes 2015. A present to all the developers out there.
|
||||||
|
* www.jasonmayes.com
|
||||||
|
* Please keep this disclaimer with my code if you use it. Thanks. :-)
|
||||||
|
* Got feedback or questions, ask here:
|
||||||
|
* http://www.jasonmayes.com/projects/twitterApi/
|
||||||
|
* Github: https://github.com/jasonmayes/Twitter-Post-Fetcher
|
||||||
|
* Updates will be posted to this site.
|
||||||
|
*********************************************************************/
|
||||||
|
(function(w,p){"function"===typeof define&&define.amd?define([],p):"object"===typeof exports?module.exports=p():p()})(this,function(){function w(a){return a.replace(/<b[^>]*>(.*?)<\/b>/gi,function(a,g){return g}).replace(/class=".*?"|data-query-source=".*?"|dir=".*?"|rel=".*?"/gi,"")}function p(a){a=a.getElementsByTagName("a");for(var c=a.length-1;0<=c;c--)a[c].setAttribute("target","_blank")}function n(a,c){for(var g=[],f=new RegExp("(^| )"+c+"( |$)"),h=a.getElementsByTagName("*"),b=0,k=h.length;b<
|
||||||
|
k;b++)f.test(h[b].className)&&g.push(h[b]);return g}var B="",k=20,C=!0,u=[],x=!1,v=!0,q=!0,y=null,z=!0,D=!0,A=null,E=!0,F=!1,r=!0,G=!0,m=null,H={fetch:function(a){void 0===a.maxTweets&&(a.maxTweets=20);void 0===a.enableLinks&&(a.enableLinks=!0);void 0===a.showUser&&(a.showUser=!0);void 0===a.showTime&&(a.showTime=!0);void 0===a.dateFunction&&(a.dateFunction="default");void 0===a.showRetweet&&(a.showRetweet=!0);void 0===a.customCallback&&(a.customCallback=null);void 0===a.showInteraction&&(a.showInteraction=
|
||||||
|
!0);void 0===a.showImages&&(a.showImages=!1);void 0===a.linksInNewWindow&&(a.linksInNewWindow=!0);void 0===a.showPermalinks&&(a.showPermalinks=!0);if(x)u.push(a);else{x=!0;B=a.domId;k=a.maxTweets;C=a.enableLinks;q=a.showUser;v=a.showTime;D=a.showRetweet;y=a.dateFunction;A=a.customCallback;E=a.showInteraction;F=a.showImages;r=a.linksInNewWindow;G=a.showPermalinks;var c=document.getElementsByTagName("head")[0];null!==m&&c.removeChild(m);m=document.createElement("script");m.type="text/javascript";m.src=
|
||||||
|
"https://cdn.syndication.twimg.com/widgets/timelines/"+a.id+"?&lang="+(a.lang||"en")+"&callback=twitterFetcher.callback&suppress_response_codes=true&rnd="+Math.random();c.appendChild(m)}},callback:function(a){var c=document.createElement("div");c.innerHTML=a.body;"undefined"===typeof c.getElementsByClassName&&(z=!1);a=[];var g=[],f=[],h=[],b=[],m=[],t=[],e=0;if(z)for(c=c.getElementsByClassName("tweet");e<c.length;){0<c[e].getElementsByClassName("retweet-credit").length?b.push(!0):b.push(!1);if(!b[e]||
|
||||||
|
b[e]&&D)a.push(c[e].getElementsByClassName("e-entry-title")[0]),m.push(c[e].getAttribute("data-tweet-id")),g.push(c[e].getElementsByClassName("p-author")[0]),f.push(c[e].getElementsByClassName("dt-updated")[0]),t.push(c[e].getElementsByClassName("permalink")[0]),void 0!==c[e].getElementsByClassName("inline-media")[0]?h.push(c[e].getElementsByClassName("inline-media")[0]):h.push(void 0);e++}else for(c=n(c,"tweet");e<c.length;)a.push(n(c[e],"e-entry-title")[0]),m.push(c[e].getAttribute("data-tweet-id")),
|
||||||
|
g.push(n(c[e],"p-author")[0]),f.push(n(c[e],"dt-updated")[0]),t.push(n(c[e],"permalink")[0]),void 0!==n(c[e],"inline-media")[0]?h.push(n(c[e],"inline-media")[0]):h.push(void 0),0<n(c[e],"retweet-credit").length?b.push(!0):b.push(!1),e++;a.length>k&&(a.splice(k,a.length-k),g.splice(k,g.length-k),f.splice(k,f.length-k),b.splice(k,b.length-k),h.splice(k,h.length-k),t.splice(k,t.length-k));c=[];e=a.length;for(b=0;b<e;){if("string"!==typeof y){var d=f[b].getAttribute("datetime"),l=new Date(f[b].getAttribute("datetime").replace(/-/g,
|
||||||
|
"/").replace("T"," ").split("+")[0]),d=y(l,d);f[b].setAttribute("aria-label",d);if(a[b].innerText)if(z)f[b].innerText=d;else{var l=document.createElement("p"),I=document.createTextNode(d);l.appendChild(I);l.setAttribute("aria-label",d);f[b]=l}else f[b].textContent=d}d="";C?(r&&(p(a[b]),q&&p(g[b])),q&&(d+='<div class="user">'+w(g[b].innerHTML)+"</div>"),d+='<p class="tweet">'+w(a[b].innerHTML)+"</p>",v&&(d=G?d+('<p class="timePosted"><a href="'+t[b]+'">'+f[b].getAttribute("aria-label")+"</a></p>"):
|
||||||
|
d+('<p class="timePosted">'+f[b].getAttribute("aria-label")+"</p>"))):a[b].innerText?(q&&(d+='<p class="user">'+g[b].innerText+"</p>"),d+='<p class="tweet">'+a[b].innerText+"</p>",v&&(d+='<p class="timePosted">'+f[b].innerText+"</p>")):(q&&(d+='<p class="user">'+g[b].textContent+"</p>"),d+='<p class="tweet">'+a[b].textContent+"</p>",v&&(d+='<p class="timePosted">'+f[b].textContent+"</p>"));E&&(d+='<p class="interact"><a href="https://twitter.com/intent/tweet?in_reply_to='+m[b]+'" class="twitter_reply_icon"'+
|
||||||
|
(r?' target="_blank">':">")+'Reply</a><a href="https://twitter.com/intent/retweet?tweet_id='+m[b]+'" class="twitter_retweet_icon"'+(r?' target="_blank">':">")+'Retweet</a><a href="https://twitter.com/intent/favorite?tweet_id='+m[b]+'" class="twitter_fav_icon"'+(r?' target="_blank">':">")+"Favorite</a></p>");F&&void 0!==h[b]&&(l=h[b],void 0!==l?(l=l.innerHTML.match(/data-srcset="([A-z0-9%_\.-]+)/i)[0],l=decodeURIComponent(l).split('"')[1]):l=void 0,d+='<div class="media"><img src="'+l+'" alt="Image from tweet" /></div>');
|
||||||
|
c.push(d);b++}if(null===A){a=c.length;g=0;f=document.getElementById(B);for(h="<ul>";g<a;)h+="<li>"+c[g]+"</li>",g++;f.innerHTML=h+"</ul>"}else A(c);x=!1;0<u.length&&(H.fetch(u[0]),u.splice(0,1))}};return window.twitterFetcher=H});
|
|
@ -20,6 +20,8 @@
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
|
// <a class="twitter-timeline" data-dnt="true" href="https://twitter.com/sifen_trackbot" data-widget-id="654587648904794112">Tweets by @sifen_trackbot</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
|
||||||
|
|
||||||
// Set to 0 to disable debugging, 1+ to enable debugging (higher = more verbose)
|
// Set to 0 to disable debugging, 1+ to enable debugging (higher = more verbose)
|
||||||
var DEBUG_LEVEL = 0;
|
var DEBUG_LEVEL = 0;
|
||||||
|
|
||||||
|
@ -631,6 +633,9 @@ function start_stop_timer()
|
||||||
window.the_end = moment(dateString, "MM/DD/YYYY HH:mmZ");
|
window.the_end = moment(dateString, "MM/DD/YYYY HH:mmZ");
|
||||||
window.timerInterval = setInterval(run_timer, 1000);
|
window.timerInterval = setInterval(run_timer, 1000);
|
||||||
$("#button-start-stop-timer span").text("Stop Timer");
|
$("#button-start-stop-timer span").text("Stop Timer");
|
||||||
|
// run the first update ourselves, so that it doesn't stay blank until the timer kicks in
|
||||||
|
window.immediately_refresh_tier_cutoffs = true;
|
||||||
|
run_timer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,6 +674,43 @@ function run_timer()
|
||||||
string += "<h1>EVENT IS OVER</h1>";
|
string += "<h1>EVENT IS OVER</h1>";
|
||||||
}
|
}
|
||||||
$("#timer_output_area").html(string);
|
$("#timer_output_area").html(string);
|
||||||
|
|
||||||
|
// dumb ass way to fetch sifen tweets at 36 minutes past the hour
|
||||||
|
// actually using 40 minutes mark to allow for some slop
|
||||||
|
// using this twitter fetcher: http://jasonmayes.com/projects/twitterApi/#sthash.budgYosd.dpbs
|
||||||
|
var config5 = {
|
||||||
|
"id": '654587648904794112',
|
||||||
|
"domId": '',
|
||||||
|
"maxTweets": 1,
|
||||||
|
"enableLinks": false,
|
||||||
|
"showUser": true,
|
||||||
|
"showTime": true,
|
||||||
|
"dateFunction": '',
|
||||||
|
"showRetweet": false,
|
||||||
|
"customCallback": handleTweets,
|
||||||
|
"showInteraction": false
|
||||||
|
};
|
||||||
|
|
||||||
|
function handleTweets(tweets) {
|
||||||
|
if (tweets.length > 0) {
|
||||||
|
var tweet = tweets[0];
|
||||||
|
// parse it
|
||||||
|
console.log("GOT TWEET: " + tweet);
|
||||||
|
// this is kinda crappy
|
||||||
|
var splitTweet = tweet.split("\n");
|
||||||
|
// this is VERY LAZY
|
||||||
|
// we always assume Tier1 is on line 11, Tier2 is line 12 and Date is 13
|
||||||
|
var tier1 = splitTweet[11];
|
||||||
|
var tier2 = splitTweet[12];
|
||||||
|
var updateTime = splitTweet[13];
|
||||||
|
$("#tier_info_output_area").html("<h2>Latest Tier Cutoffs as of " + updateTime + ":<br />" + tier1 + "<br />" + tier2 + "</h2>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minute(now) == 40 || window.immediately_refresh_tier_cutoffs) {
|
||||||
|
twitterFetcher.fetch(config5);
|
||||||
|
window.immediately_refresh_tier_cutoffs = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear_timer()
|
function clear_timer()
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
<script src="js/external/jquery-ui-sliderAccess.js"></script>
|
<script src="js/external/jquery-ui-sliderAccess.js"></script>
|
||||||
<script src="js/external/moment.js"></script>
|
<script src="js/external/moment.js"></script>
|
||||||
<script src="js/external/sprintf.js"></script>
|
<script src="js/external/sprintf.js"></script>
|
||||||
|
<script src="js/external/twitterFetcher.js"></script>
|
||||||
<script src="js/sif_tools.js"></script>
|
<script src="js/sif_tools.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
@ -126,6 +127,8 @@
|
||||||
<div id="timer_output_area" align="center">
|
<div id="timer_output_area" align="center">
|
||||||
<h1>Timer Not Running</h1>
|
<h1>Timer Not Running</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="tier_info_output_area" align="center">
|
||||||
|
</div>
|
||||||
<div id="button-clear-timer">Clear Timer</div>
|
<div id="button-clear-timer">Clear Timer</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue