X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;f=www%2Fjs%2Fblerg.js;h=fc93a5ee08573afdf87cceb3867252e6b44836aa;hb=55431b133192e59138a51591d7ef4ef20b6ceb52;hp=2ef48d94dca48183e5b6cab10326f3d95dfd303c;hpb=25d05f5f2c444ca67199b7108fe74fb728cf8554;p=blerg.git diff --git a/www/js/blerg.js b/www/js/blerg.js index 2ef48d9..fc93a5e 100644 --- a/www/js/blerg.js +++ b/www/js/blerg.js @@ -721,25 +721,6 @@ function unsubscribe() { }); } -var resizePostContentTimeout = null; -function resizePostContent() { - if (resizePostContentTimeout) - clearTimeout(resizePostContentTimeout); - resizePostContentTimeout = setTimeout(function() { - var c = $('post.content'); - var lines = Math.floor(c.value.length / (100 * (c.clientWidth / 1000))) + 1; - var m = c.value.match(/\r?\n/g); - if (m) - lines += m.length; - if (lines <= 3) { - c.style.height = ""; - } else { - c.style.height = (lines * 17) + "pt"; - } - resizePostContentTimeout = null; - }, 150); -} - var tickerTimer = null; var tickerHead, tickerTail; @@ -816,38 +797,6 @@ function loadLatest() { }); } -function qlink(loc) { - if (loc) { - location.hash = loc; - } else if (event && event.target) { - location.href = event.target.href; - } else { - // Bogus qlink - return; - } - lastHash = location.hash; - urlSwitch(); - return false; -} - -function Welcome() { - loadLatest(); -} - -Welcome.prototype.show = function() { - $$('[name=section]').each(function(v) { v.update('Welcome') }); - $('welcome').show(); -} - -Welcome.prototype.hide = function() { - stopTicker(); - $('welcome').hide(); -} - -Welcome.prototype.updateState = function() { - this.show(); -} - function ExternalURLPost(m) { this.title = decodeURIComponent(m[1]).replace(']','').replace('[',''); this.url = decodeURIComponent(m[2]); @@ -857,66 +806,3 @@ ExternalURLPost.prototype.show = function() { $('post.content').value = '[' + this.title + '](' + this.url + ')'; $('post').show(); } - -var urlmap = [ - ['search', /^\?post\/([^/]+)\/(.+)/, ExternalURLPost], - ['hash', /^#\/(ref|tag)\/([A-Za-z0-9_-]+)(?:\/p(\d+))?$/, Tag], - ['hash', /^#\/feed(?:\/p(\d+))?$/, Feed], - ['hash', /^#([A-Za-z0-9_-]+)(?:\/(p)?(\d+))?$/, User] -]; - -function urlSwitch() { - var m; - var pageconstructor; - - for (var i = 0; i < urlmap.length; i++) { - if (m = location[urlmap[i][0]].match(urlmap[i][1])) { - pageconstructor = urlmap[i][2]; - break; - } - } - if (i == urlmap.length) - pageconstructor = Welcome; - - if (currentPager && currentPager instanceof pageconstructor) { - // updateState returns true if the state has been successfully updated. - // Otherwise, we continue and create a new instance. - if (currentPager.updateState(m)) - return; - } - - if (currentPager && currentPager.hide) - currentPager.hide(); - - currentPager = new pageconstructor(m); - if (currentPager.show) - currentPager.show(); -} - -var lastHash; -function hashCheck() { - if (location.hash != lastHash) { - lastHash = location.hash; - urlSwitch(); - } -} - -function init() { - items = $('items'); - loginStatus = new LoginStatus(); - - lastHash = location.hash; - urlSwitch(); - - setInterval(hashCheck, 250); - - document.body.observe('keyup', function(event) { - if (event.shiftKey && event.keyCode == 32) { - postPopup(); - event.stop(); - } - }); - $('post.content').addEventListener('keyup', function(event) { - event.stopPropagation(); - }, true); -}