/**
* Twitter - http://www.twitter.com
* Copyright (C) 2009 Twitter
* Author: Dustin Diaz (dustin@twitter.com)
*
* V 2.0.1 Twitter search/profile/faves/list widget
* http://twitter.com/widgets
*/
if (!"console" in window) { window.console = { log: function() { } } } TWTR = window.TWTR || {}; if (!Array.forEach) { Array.prototype.forEach = function(D, E) { var C = E || window; for (var B = 0, A = this.length; B < A; ++B) { D.call(C, this[B], B, this) } }; Array.prototype.filter = function(E, F) { var D = F || window; var A = []; for (var C = 0, B = this.length; C < B; ++C) { if (!E.call(D, this[C], C, this)) { continue } A.push(this[C]) } return A }; Array.prototype.indexOf = function(B, C) { var C = C || 0; for (var A = 0; A < this.length; ++A) { if (this[A] === B) { return A } } return -1 } } (function() { if (TWTR && TWTR.Widget) { return } function A(B, D, C) { this.el = B; this.prop = D; this.from = C.from; this.to = C.to; this.time = C.time; this.callback = C.callback; this.animDiff = this.to - this.from } A.canTransition = function() { var B = document.createElement("twitter"); B.style.cssText = "-webkit-transition: all .5s linear;"; return !!B.style.webkitTransitionProperty } (); A.prototype._setStyle = function(B) { switch (this.prop) { case "opacity": this.el.style[this.prop] = B; this.el.style.filter = "alpha(opacity=" + B * 100 + ")"; break; default: this.el.style[this.prop] = B + "px"; break } }; A.prototype._animate = function() { var B = this; this.now = new Date(); this.diff = this.now - this.startTime; if (this.diff > this.time) { this._setStyle(this.to); if (this.callback) { this.callback.call(this) } clearInterval(this.timer); return } this.percentage = (Math.floor((this.diff / this.time) * 100) / 100); this.val = (this.animDiff * this.percentage) + this.from; this._setStyle(this.val) }; A.prototype.start = function() { var B = this; this.startTime = new Date(); this.timer = setInterval(function() { B._animate.call(B) }, 15) }; TWTR.Widget = function(B) { this.init(B) }; (function() { var M = {}; var Y = {}; var W = function(a) { var Z = Y[a]; if (!Z) { Z = new RegExp("(?:^|\\s+)" + a + "(?:\\s+|$)"); Y[a] = Z } return Z }; var C = function(e, j, f, g) { var j = j || "*"; var f = f || document; var a = [], Z = f.getElementsByTagName(j), h = W(e); for (var b = 0, d = Z.length; b < d; ++b) { if (h.test(Z[b].className)) { a[a.length] = Z[b]; if (g) { g.call(Z[b], Z[b]) } } } return a }; var X = function() { var Z = navigator.userAgent; return { ie: Z.match(/MSIE\s([^;]*)/)} } (); var G = function(Z) { if (typeof Z == "string") { return document.getElementById(Z) } return Z }; var Q = function(Z) { return Z.replace(/^\s+|\s+$/g, "") }; var P = function() { var Z = self.innerHeight; var a = document.compatMode; if ((a || X.ie)) { Z = (a == "CSS1Compat") ? document.documentElement.clientHeight : document.body.clientHeight } return Z }; var V = function(b, Z) { var a = b.target || b.srcElement; return Z(a) }; var N = function(a) { try { if (a && 3 == a.nodeType) { return a.parentNode } else { return a } } catch (Z) { } }; var O = function(a) { var Z = a.relatedTarget; if (!Z) { if (a.type == "mouseout") { Z = a.toElement } else { if (a.type == "mouseover") { Z = a.fromElement } } } return N(Z) }; var S = function(a, Z) { Z.parentNode.insertBefore(a, Z.nextSibling) }; var T = function(a) { try { a.parentNode.removeChild(a) } catch (Z) { } }; var R = function(Z) { return Z.firstChild }; var B = function(b) { var a = O(b); while (a && a != this) { try { a = a.parentNode } catch (Z) { a = this } } if (a != this) { return true } return false }; var F = function() { if (document.defaultView && document.defaultView.getComputedStyle) { return function(a, d) { var c = null; var b = document.defaultView.getComputedStyle(a, ""); if (b) { c = b[d] } var Z = a.style[d] || c; return Z } } else { if (document.documentElement.currentStyle && X.ie) { return function(Z, b) { var a = Z.currentStyle ? Z.currentStyle[b] : null; return (Z.style[b] || a) } } } } (); var U = { has: function(Z, a) { return new RegExp("(^|\\s)" + a + "(\\s|$)").test(G(Z).className) }, add: function(Z, a) { if (!this.has(Z, a)) { G(Z).className = Q(G(Z).className) + " " + a } }, remove: function(Z, a) { if (this.has(Z, a)) { G(Z).className = G(Z).className.replace(new RegExp("(^|\\s)" + a + "(\\s|$)", "g"), "") } } }; var D = { add: function(b, a, Z) { if (b.addEventListener) { b.addEventListener(a, Z, false) } else { b.attachEvent("on" + a, function() { Z.call(b, window.event) }) } }, remove: function(b, a, Z) { if (b.removeEventListener) { b.removeEventListener(a, Z, false) } else { b.detachEvent("on" + a, Z) } } }; var H = { bool: function(Z) { return typeof Z === "boolean" }, def: function(Z) { return !(typeof Z === "undefined") }, number: function(Z) { return typeof Z === "number" && isFinite(Z) }, string: function(Z) { return typeof Z === "string" }, fn: function(Z) { return typeof Z === "function" }, array: function(Z) { if (Z) { return H.number(Z.length) && H.fn(Z.splice) } return false } }; var J = function(f) { var h = new Date(); var d = new Date(f); if (X.ie) { d = Date.parse(f.replace(/( \+)/, " UTC$1")) } var g = h - d; var a = 1000, b = a * 60, c = b * 60, e = c * 24, Z = e * 7; if (isNaN(g) || g < 0) { return "" } if (g < a * 7) { return "right now" } if (g < b) { return Math.floor(g / a) + " seconds ago" } if (g < b * 2) { return "about 1 minute ago" } if (g < c) { return Math.floor(g / b) + " minutes ago" } if (g < c * 2) { return "about 1 hour ago" } if (g < e) { return Math.floor(g / c) + " hours ago" } if (g > e && g < e * 2) { return "yesterday" } if (g < e * 365) { return Math.floor(g / e) + " days ago" } else { return "over a year ago" } }; var E = { link: function(Z) { return Z.replace(/\b(((https*\:\/\/)|www\.).+?)(([!?,.\)]+)?(\s|$))/g, function(f, e, c, b, a) { var d = c.match(/w/) ? "http://" : ""; return '<a class="twtr-hyperlink" target="_blank" href="' + d + e + '">' + ((e.length > 25) ? e.substr(0, 24) + "..." : e) + "</a>" + a }) }, at: function(Z) { return Z.replace(/\B\@(\w{1,20})/g, function(a, b) { return '@<a target="_blank" class="twtr-atreply" href="http://twitter.com/' + b + '">' + b + "</a>" }) }, list: function(Z) { return Z.replace(/\B\@(\w{1,20}\/[a-zA-Z0-9_-]+)/g, function(a, b) { return '@<a target="_blank" class="twtr-atreply" href="http://twitter.com/' + b + '">' + b + "</a>" }) }, hash: function(Z) { return Z.replace(/\B\#(\w+)/gi, function(a, b) { return '<a target="_blank" class="twtr-hashtag" href="http://twitter.com/search?q=%23' + b + '">#' + b + "</a>" }) }, clean: function(Z) { return this.hash(this.at(this.list(this.link(Z)))) } }; function L(a, b, Z) { this.job = a; this.decayFn = b; this.interval = Z; this.decayRate = 1; this.decayMultiplier = 1.25; this.maxDecayTime = 3 * 60 * 1000 } L.prototype = { start: function() { this.stop().run(); return this }, stop: function() { if (this.worker) { window.clearTimeout(this.worker) } return this }, run: function() { var Z = this; this.job(function() { Z.decayRate = Z.decayFn() ? Math.max(1, Z.decayRate / Z.decayMultiplier) : Z.decayRate * Z.decayMultiplier; var a = Z.interval * Z.decayRate; a = (a >= Z.maxDecayTime) ? Z.maxDecayTime : a; a = Math.floor(a); Z.worker = window.setTimeout(function() { Z.run.call(Z) }, a) }) }, destroy: function() { this.stop(); this.decayRate = 1; return this } }; function I(a, b, Z, c) { this.time = b || 6000; this.loop = Z || false; this.repeated = 0; this.total = a.length; this.callback = c; this.haystack = a } I.prototype = { start: function(Z) { var a = this; if (Z) { this.repeated = 0 } this.stop()._job(); this.timer = window.setInterval(function() { a._job.call(a) }, this.time); return this }, stop: function() { if (this.timer) { window.clearInterval(this.timer) } return this }, _job: function() { if (this.repeated === this.total) { if (this.loop) { this.repeated = 0 } else { this.stop(); return } } this.callback(this.haystack[this.repeated]); this.repeated++; return this } }; function K(a) { var Z = '<div class="twtr-tweet-wrap" style="background-color:#FFF;  ">         <div class="twtr-avatar">           <div class="twtr-img"><a target="_blank" href="http://twitter.com/' + a.user + '"><img alt="' + a.user + ' profile" src="' + a.avatar + '"></a></div>         </div>         <div class="twtr-tweet-text">           <p style="font-size:14px;">             <a target="_blank" href="http://twitter.com/' + a.user + '" class="twtr-user">' + a.user + "</a> " + a.tweet + '             <i>            <a target="_blank" href="http://twitter.com/' + a.user + "/status/" + a.id + '" >' + J(a.created_at) + '</a>             <a target="_blank" class="twtr-reply" href="http://twitter.com/?status=@' + a.user + "%20&in_reply_to_status_id=" + a.id + "&in_reply_to=" + a.user + '">reply</a>             </i>           </p>         </div>       </div>'; var b = document.createElement("div"); b.id = "tweet-id-" + ++K._tweetCount; b.className = "twtr-tweet"; b.innerHTML = Z; this.element = b } K._tweetCount = 0; M.loadStyleSheet = function(b, a) { if (!TWTR.Widget.loadingStyleSheet) { TWTR.Widget.loadingStyleSheet = true; var Z = document.createElement("link"); Z.href = b; Z.rel = "stylesheet"; Z.type = "text/css"; document.getElementsByTagName("head")[0].appendChild(Z); var c = setInterval(function() { var d = F(a, "position"); if (d == "relative") { clearInterval(c); TWTR.Widget.hasLoadedStyleSheet = true } }, 50) } }; (function() { var Z = false; M.css = function(c) { var b = document.createElement("style"); b.type = "text/css"; if (X.ie) { b.styleSheet.cssText = c } else { var d = document.createDocumentFragment(); d.appendChild(document.createTextNode(c)); b.appendChild(d) } function a() { document.getElementsByTagName("head")[0].appendChild(b) } if (!X.ie || Z) { a() } else { window.attachEvent("onload", function() { Z = true; a() }) } } })(); TWTR.Widget.isLoaded = false; TWTR.Widget.loadingStyleSheet = false; TWTR.Widget.hasLoadedStyleSheet = false; TWTR.Widget.WIDGET_NUMBER = 0; TWTR.Widget.matches = { mentions: /^@\w{1,20}\b/, any_mentions: /\b@\w{1,20}\b/ }; TWTR.Widget.jsonP = function(a, b) { var Z = document.createElement("script"); Z.type = "text/javascript"; Z.src = a; document.getElementsByTagName("head")[0].appendChild(Z); b(Z); return Z }; TWTR.Widget.prototype = function() { var d = "http://search.twitter.com/search."; var e = "http://twitter.com/statuses/user_timeline."; var b = "http://twitter.com/favorites/"; var c = "http://twitter.com/"; var a = 20000; var Z = "http://widgets.twimg.com/j/1/default.gif"; return { init: function(g) { var f = this; this._widgetNumber = ++TWTR.Widget.WIDGET_NUMBER; TWTR.Widget["receiveCallback_" + this._widgetNumber] = function(h) { f._prePlay.call(f, h) }; this._cb = "TWTR.Widget.receiveCallback_" + this._widgetNumber; this.opts = g; this._base = d; this._isRunning = false; this._hasOfficiallyStarted = false; this._rendered = false; this._profileImage = false; this._isCreator = !!g.creator; this._setWidgetType(g.type); this.timesRequested = 0; this.runOnce = false; this.newResults = false; this.results = []; this.jsonMaxRequestTimeOut = 19000; this.showedResults = []; this.sinceId = 1; this.source = "TWITTERINC_WIDGET"; this.id = g.id || "twtr-widget-" + this._widgetNumber; this.tweets = 0; this.setDimensions(g.width, g.height); this.interval = g.interval || 6000; this.format = "json"; this.rpp = g.rpp || 50; this.subject = g.subject || ""; this.title = g.title || ""; this.setSearch(g.search); this._setUrl(); this.theme = g.theme ? g.theme : this._getDefaultTheme(); if (!g.id) { document.write('<div class="twtr-widget" id="' + this.id + '"></div>') } this.widgetEl = G(this.id); if (g.id) { U.add(this.widgetEl, "twtr-widget") } if (g.version >= 2 && !TWTR.Widget.hasLoadedStyleSheet) { M.loadStyleSheet("http://www.fineholm.co.uk/App_Themes/widget.css", this.widgetEl) } this.occasionalJob = new L(function(h) { f.decay = h; f._getResults.call(f) }, function() { return f._decayDecider.call(f) }, a); this._ready = H.fn(g.ready) ? g.ready : function() { }; this._tweetFilter = false; this._avatars = true; this._isFullScreen = false; this._isLive = true; this._isScroll = false; this._loop = true; this._behavior = "default"; this.setFeatures(this.opts.features); return this }, setDimensions: function(f, g) { this.wh = (f && g) ? [f, g] : [250, 300]; if (f == "auto" || f == "100%") { this.wh[0] = "100%" } else { this.wh[0] = ((this.wh[0] < 150) ? 150 : this.wh[0]) + "px" } this.wh[1] = ((this.wh[1] < 100) ? 100 : this.wh[1]) + "px"; return this }, setRpp: function(f) { var f = parseInt(f); this.rpp = (H.number(f) && (f > 0 && f <= 100)) ? f : 30; return this }, _setWidgetType: function(f) { this._isSearchWidget = false, this._isProfileWidget = false, this._isFavsWidget = false, this._isListWidget = false; switch (f) { case "profile": this._isProfileWidget = true; break; case "search": this._isSearchWidget = true, this.search = this.opts.search; break; case "faves": case "favs": this._isFavsWidget = true; break; case "list": case "lists": this._isListWidget = true; break } return this }, setFeatures: function(f) { if (f) { if (H.def(f.filters)) { this._tweetFilter = f.filters } if (H.def(f.fullscreen) && H.bool(f.fullscreen)) { if (f.fullscreen) { this._isFullScreen = true; this.wh[0] = "60%"; this.wh[1] = (P() - 90) + "px" } } if (H.def(f.loop) && H.bool(f.loop)) { this._loop = f.loop } if (H.def(f.behavior) && H.string(f.behavior)) { switch (f.behavior) { case "all": this._behavior = "all"; break; default: this._behavior = "default"; break } } if (H.def(f.avatars) && H.bool(f.avatars)) { if (!f.avatars) { M.css("#" + this.id + " .twtr-avatar, #" + this.id + " .twtr-user { display: none; } #" + this.id + " .twtr-tweet-text { margin-left: 0; }"); this._avatars = false } else { var g = (this._isFullScreen) ? "90px" : "40px"; M.css("#" + this.id + " .twtr-avatar { display: block; } #" + this.id + " .twtr-user { display: inline; } #" + this.id + " .twtr-tweet-text { margin-left: " + g + "; }"); this._avatars = true } } else { if (this._isProfileWidget) { this.setFeatures({ avatars: false }); this._avatars = false } else { this.setFeatures({ avatars: true }); this._avatars = true } } if (H.def(f.hashtags) && H.bool(f.hashtags)) { (!f.hashtags) ? M.css("#" + this.id + " a.twtr-hashtag { display: none; }") : "" } if (H.def(f.timestamp) && H.bool(f.timestamp)) { var h = f.timestamp ? "block" : "none"; M.css("#" + this.id + " i { display: " + h + "; }") } if (H.def(f.live) && H.bool(f.live)) { this._isLive = f.live } if (H.def(f.scrollbar) && H.bool(f.scrollbar)) { this._isScroll = f.scrollbar } } else { if (this._isProfileWidget) { this.setFeatures({ avatars: false }); this._avatars = false } if (this._isProfileWidget || this._isFavsWidget) { this.setFeatures({ behavior: "all" }) } } return this }, setTweetInterval: function(f) { this.interval = f; return this }, setBase: function(f) { this._base = f; return this }, setUser: function(g, f) { this.username = g; this.realname = f || " "; if (this._isFavsWidget) { this.setBase(b + g + ".") } else { if (this._isProfileWidget) { this.setBase(e + this.format + "?screen_name=" + g) } } this.setSearch(" "); return this }, setList: function(g, f) { this.listslug = f.replace(/ /g, "-").toLowerCase(); this.username = g; this.setBase(c + g + "/lists/" + this.listslug + "/statuses."); this.setSearch(" "); return this }, setProfileImage: function(f) { this._profileImage = f; this.byClass("twtr-profile-img", "img").src = f; this.byClass("twtr-profile-img-anchor", "a").href = "http://twitter.com/" + this.username; return this }, setTitle: function(f) { this.title = f; this.widgetEl.getElementsByTagName("h3")[0].innerHTML = this.title; return this }, setCaption: function(f) { this.subject = f; this.widgetEl.getElementsByTagName("h4")[0].innerHTML = this.subject; return this }, setSearch: function(g) { g = g || ""; if (this._isSearchWidget && this._isFullscreen) { document.title = "Twitter search: " + escape(g) } g = g.replace(" ", "+"); this.search = escape("-RT " + g); this._setUrl(); if (this._rendered) { var f = this.byClass("twtr-join-conv", "a"); f.href = "http://twitter.com/" + this._getWidgetPath() } return this }, _getWidgetPath: function() { if (this._isProfileWidget) { return this.username } else { if (this._isFavsWidget) { return this.username + "/favorites" } else { if (this._isListWidget) { return this.username + "/lists/" + this.listslug } else { return "#search?q=" + this.search } } } }, _setUrl: function() { var f = this; function g() { return (f.sinceId == 1) ? "" : "&since_id=" + f.sinceId + "&refresh=true" } if (this._isProfileWidget) { this.url = this._base + "&callback=" + this._cb + "&count=" + this.rpp + g() + "&clientsource=" + this.source } else { if (this._isFavsWidget || this._isListWidget) { this.url = this._base + this.format + "?callback=" + this._cb + g() + "&clientsource=" + this.source } else { this.url = this._base + this.format + "?q=" + this.search + "&callback=" + this._cb + "&rpp=" + this.rpp + g() + "&clientsource=" + this.source } } return this }, setTheme: function(k, f) { var i = this; var g = " !important"; var j = ((window.location.hostname.match(/twitter\.com/)) && (window.location.pathname.match(/goodies/))); if (f || j) { g = "" } this.theme = { shell: { background: function() { return k.shell.background || i._getDefaultTheme().shell.background } (), color: function() { return k.shell.color || i._getDefaultTheme().shell.color } () }, tweets: { background: function() { return k.tweets.background || i._getDefaultTheme().tweets.background } (), color: function() { return k.tweets.color || i._getDefaultTheme().tweets.color } (), links: function() { return k.tweets.links || i._getDefaultTheme().tweets.links } ()} }; var h = "#" + this.id + " .twtr-doc,                      #" + this.id + " .twtr-hd a {   background: " + this.theme.shell.background + g + ";            color: " + this.theme.shell.color + g + ";          }          #" + this.id + " .twtr-tweet a {      font-size:12px;            color: " + this.theme.tweets.links + g + ";          }          #" + this.id + " .twtr-bd, #" + this.id + " .twtr-timeline i a {            color: " + this.theme.tweets.color + g + ";          }          #" + this.id + " .twtr-new-results,           #" + this.id + " .twtr-results-inner,           #" + this.id + " .twtr-timeline {   background: " + this.theme.tweets.background + g + ";          }"; if (X.ie) { h += "#" + this.id + " .twtr-tweet { background: " + this.theme.tweets.background + g + ";     }" } M.css(h); return this }, byClass: function(i, f, g) { var h = C(i, f, G(this.id)); return (g) ? h : h[0] }, render: function() { var h = this; if (!TWTR.Widget.hasLoadedStyleSheet) { window.setTimeout(function() { h.render.call(h) }, 50); return this } this.setTheme(this.theme, this._isCreator); if (this._isProfileWidget) { U.add(this.widgetEl, "twtr-widget-profile") } if (this._isScroll) { U.add(this.widgetEl, "twtr-scroll") } if (!this._isLive && !this._isScroll) { this.wh[1] = "auto" } this.widgetEl.innerHTML = this._getWidgetHtml(); this.spinner = this.byClass("twtr-spinner", "div"); var g = this.byClass("twtr-timeline", "div"); if (this._isLive && !this._isFullscreen) { var i = function(j) { if (B.call(this, j)) { h.pause.call(h) } }; var f = function(j) { if (B.call(this, j)) { h.resume.call(h) } }; this.removeEvents = function() { D.remove(g, "mouseover", i); D.remove(g, "mouseout", f) }; D.add(g, "mouseover", i); D.add(g, "mouseout", f) } this._rendered = true; this._ready(); return this }, removeEvents: function() { }, _getDefaultTheme: function() { return { shell: { background: "#8ec1da", color: "#ffffff" }, tweets: { background: "#ffffff", color: "#444444", links: "#1985b5"}} }, _getWidgetHtml: function() { var i = this; function j() { if (i._isProfileWidget) { return '<a target="_blank" href="http://twitter.com/" class="twtr-profile-img-anchor"><img alt="profile" class="twtr-profile-img" src="' + Z + '"></a>                      <h3></h3>                      <h4></h4>' } else { return "<h3>" + i.title + "</h3><h4>" + i.subject + "</h4>" } } function h() { if (!i._isFullScreen) { return ' height="15"' } return "" } function g() { return i._isFullScreen ? " twtr-fullscreen" : "" } var f = '<div class="twtr-doc' + g() + '" style="width: ' + this.wh[0] + ';">            <div class="twtr-hd" style="display:none;">' + j() + '               <div class="twtr-spinner twtr-inactive"></div>            </div>            <div class="twtr-bd">              <div class="twtr-timeline" style="height: ' + this.wh[1] + ';">                <div class="twtr-tweets">                  <div class="twtr-reference-tweet"></div>                  <!-- tweets show here -->                </div>              </div>            </div>            <div class="twtr-ft">              <div> <a target="_blank" class="twtr-join-conv" style="color:#ffffff" href="http://twitter.com/' + this._getWidgetPath() + '"><img src="http://www.fineholm.co.uk/images/twitterad.jpg" alt="Be the first to know - follow Fineholm" /></a>          </div>            </div>          </div>'; return f }, _appendTweet: function(f) { S(f, this.byClass("twtr-reference-tweet", "div")); return this }, _slide: function(g) { var h = this; var f = R(g).offsetHeight; if (this.runOnce) { new A(g, "height", { from: 0, to: f, time: 500, callback: function() { h._fade.call(h, g) } }).start() } return this }, _fade: function(f) { var g = this; if (A.canTransition) { f.style.webkitTransition = "opacity 0.5s ease-out"; f.style.opacity = 1; return this } new A(f, "opacity", { from: 0, to: 1, time: 500 }).start(); return this }, _chop: function() { if (this._isScroll) { return this } var l = this.byClass("twtr-tweet", "div", true); var m = this.byClass("twtr-new-results", "div", true); if (l.length) { for (var h = l.length - 1; h >= 0; h--) { var k = l[h]; var j = parseInt(k.offsetTop); if (j > parseInt(this.wh[1])) { T(k) } else { break } } if (m.length > 0) { var f = m[m.length - 1]; var g = parseInt(f.offsetTop); if (g > parseInt(this.wh[1])) { T(f) } } } return this }, _appendSlideFade: function(g) { var f = g || this.tweet.element; this._chop()._appendTweet(f)._slide(f); return this }, _createTweet: function(f) { this.tweet = new K(f); if (this._isLive && this.runOnce) { this.tweet.element.style.opacity = 0; this.tweet.element.style.filter = "alpha(opacity:0)"; this.tweet.element.style.height = "0" } return this }, _getResults: function() { var f = this; this.timesRequested++; this.jsonRequestRunning = true; this.jsonRequestTimer = window.setTimeout(function() { if (f.jsonRequestRunning) { clearTimeout(f.jsonRequestTimer); U.add(f.spinner, "twtr-inactive") } f.jsonRequestRunning = false; T(f.scriptElement); f.newResults = false; f.decay() }, this.jsonMaxRequestTimeOut); U.remove(this.spinner, "twtr-inactive"); TWTR.Widget.jsonP(f.url, function(g) { f.scriptElement = g }) }, clear: function() { var g = this.byClass("twtr-tweet", "div", true); var f = this.byClass("twtr-new-results", "div", true); g = g.concat(f); g.forEach(function(h) { T(h) }); return this }, _sortByLatest: function(f) { this.results = f; this.results = this.results.slice(0, this.rpp); this.results.reverse(); return this }, _sortByMagic: function(f) { var f = f; var g = this; if (this._tweetFilter) { if (this._tweetFilter.negatives) { f = f.filter(function(h) { if (!g._tweetFilter.negatives.test(h.text)) { return h } }) } if (this._tweetFilter.positives) { f = f.filter(function(h) { if (g._tweetFilter.positives.test(h.text)) { return h } }) } } switch (this._behavior) { case "all": this._sortByLatest(f); break; default: this._sortByDefault(f); break } return this }, _sortByDefault: function(g) { var h = this; var f = function() { if (X.ie) { return function(i) { return Date.parse(i.replace(/( \+)/, " UTC$1")) } } else { return function(i) { return new Date(i) } } } (); this.results.unshift.apply(this.results, g); this.results.forEach(function(i) { if (!i.views) { i.views = 0 } }); this.results.sort(function(j, i) { if (f(j.created_at) < f(i.created_at)) { return 1 } else { if (f(j.created_at) > f(i.created_at)) { return -1 } else { return 0 } } }); this.results = this.results.slice(0, this.rpp); if (!this._isLive) { this.results.reverse() } this.results.sort(function(j, i) { if (j.views > i.views) { return 1 } else { if (j.views < i.views) { return -1 } } return 0 }) }, _prePlay: function(g) { if (this.jsonRequestTimer) { clearTimeout(this.jsonRequestTimer) } if (!X.ie) { T(this.scriptElement) } if (g.error) { this.newResults = false } else { if (g.results && g.results.length > 0) { this.response = g; if (this.intervalJob) { this.intervalJob.stop() } this.newResults = true; this.sinceId = g.max_id; this._sortByMagic(g.results); if (this.isRunning()) { this._play() } } else { if ((this._isProfileWidget || this._isFavsWidget || this._isListWidget) && H.array(g) && g.length > 0) { if (this.intervalJob) { this.intervalJob.stop() } this.newResults = true; if (!this._profileImage && this._isProfileWidget) { var f = g[0].user.screen_name; this.setProfileImage(g[0].user.profile_image_url); this.setTitle(g[0].user.name); this.setCaption('<a target="_blank" href="http://twitter.com/' + f + '" style="position: relative; right: 40px; ">' + f + "</a>") } this.sinceId = g[0].id; this._sortByMagic(g); if (this.isRunning()) { this._play() } } else { this.newResults = false } } } this._setUrl(); if (this._isLive) { this.decay() } U.add(this.spinner, "twtr-inactive") }, _play: function() { var f = this; if (this._avatars) { this._preloadImages(this.results) } if (!this._isLive || this._behavior == "all") { this.results.forEach(function(h) { if (f._isProfileWidget) { h.from_user = f.username; h.profile_image_url = h.user.profile_image_url } if (f._isFavsWidget || f._isListWidget) { h.from_user = h.user.screen_name; h.profile_image_url = h.user.profile_image_url } f._createTweet({ id: h.id, user: h.from_user, tweet: E.clean(h.text), avatar: h.profile_image_url, created_at: h.created_at }); var g = f.tweet.element; (f._behavior == "all") ? f._appendSlideFade(g) : f._appendTweet(g) }); return this } this._insertNewResultsNumber(); this.intervalJob = new I(this.results, this.interval, this._loop, function(g) { g.views++; if (f._isProfileWidget) { g.from_user = f.username; g.profile_image_url = g.user.profile_image_url } if (f._isFavsWidget || f._isListWidget) { g.from_user = g.user.screen_name; g.profile_image_url = g.user.profile_image_url } if (f._isFullScreen) { g.profile_image_url = g.profile_image_url.replace(/_normal\./, "_bigger.") } f._createTweet({ id: g.id, user: g.from_user, tweet: E.clean(g.text), avatar: g.profile_image_url, created_at: g.created_at })._appendSlideFade() }).start(true); return this }, _insertNewResultsNumber: function() { if (this.runOnce && this._isSearchWidget) { var i = this.response.total > this.rpp ? this.response.total : this.response.results.length; var f = i > 1 ? "s" : ""; var h = (this.response.warning && this.response.warning.match(/adjusted since_id/)) ? "more than" : ""; var g = document.createElement("div"); U.add(g, "twtr-new-results"); g.innerHTML = '<div class="twtr-results-inner"> &nbsp; </div><div class="twtr-results-hr"> &nbsp; </div><span>' + h + " <strong>" + i + "</strong> new tweet" + f + "</span>"; S(g, this.byClass("twtr-reference-tweet", "div")) } }, _preloadImages: function(f) { if (this._isProfileWidget || this._isFavsWidget || this._isListWidget) { f.forEach(function(h) { var g = new Image(); g.src = h.user.profile_image_url }) } else { f.forEach(function(g) { (new Image()).src = g.profile_image_url }) } }, _decayDecider: function() { var f = false; if (!this.runOnce) { this.runOnce = true; f = true } else { if (this.newResults) { f = true } } return f }, start: function() { var f = this; if (!this._rendered) { setTimeout(function() { f.start.call(f) }, 50); return this } if (!this._isLive) { this._getResults() } else { this.occasionalJob.start() } this._isRunning = true; this._hasOfficiallyStarted = true; return this }, stop: function() { this.occasionalJob.stop(); if (this.intervalJob) { this.intervalJob.stop() } this._isRunning = false; return this }, pause: function() { if (this.isRunning() && this.intervalJob) { this.intervalJob.stop(); U.add(this.widgetEl, "twtr-paused"); this._isRunning = false } if (this._resumeTimer) { clearTimeout(this._resumeTimer) } return this }, resume: function() { var f = this; if (!this.isRunning() && this._hasOfficiallyStarted && this.intervalJob) { this._resumeTimer = window.setTimeout(function() { f.intervalJob.start(); f._isRunning = true; U.remove(f.widgetEl, "twtr-paused") }, 2000) } return this }, isRunning: function() { return this._isRunning }, destroy: function() { this.stop(); this.clear(); this.runOnce = false; this._hasOfficiallyStarted = false; this.intervalJob = false; this._profileImage = false; this._isLive = true; this._tweetFilter = false; this._isScroll = false; this.newResults = false; this._isRunning = false; this.sinceId = 1; this.results = []; this.showedResults = []; this.occasionalJob.destroy(); if (this.jsonRequestRunning) { clearTimeout(this.jsonRequestTimer); U.add(this.spinner, "twtr-inactive") } U.remove(this.widgetEl, "twtr-scroll"); this.removeEvents(); return this } } } () })() })();
