Add bookmarklet support, clean up hashSwitch()
<p>Here, take a look at the <a href="/doc/#design">design docs</a>.</p>
+ <h2>I'm a social media whore and I want to share links!</h2>
+
+ <p>I've created a bookmarklet just for you: <a href="javascript:location.href='http://blerg.dominionofawesome.com/?post/'+encodeURIComponent(document.title)+'/'+encodeURIComponent(location.href)">Blërg it!</a></p>
+
</div>
<div id="navigation">
'<div class="record">#{data}<div class="info">Posted #{date}</div></div>'
);
var tagRecordTemplate = new Template(
- '<div class="record">#{data}<div class="info">Posted by <a href="\##{author}">@#{author}</a> on #{date}</div></div>'
+ '<div class="record">#{data}<div class="info">Posted by <a href="/\##{author}">@#{author}</a> on #{date}</div></div>'
);
// Page elements
LoginStatus.prototype.update = function() {
if (this.loggedIn) {
- $('userlink').href = '#' + this.username;
+ $('userlink').href = '/#' + this.username;
$('userlink').update('@' + this.username);
$('login').hide();
$('logout').show();
$$('[name=section]').each(function(v) { v.update(' @' + this.username) }.bind(this));
$('welcome').hide();
items.show();
- $('reflink').href = '#ref/' + this.username;
+ $('reflink').href = '/#ref/' + this.username;
$('rss').show();
$('rsslink').href = '/rss/' + this.username;
}
}
function hashSwitch() {
- var m = location.hash.match(/^#((ref|tag)\/)?(\w+)(:(\d+))?/);
- if (m) {
- if (m[1]) {
- currentPager = new Tag(m[2], m[3]);
- currentPager.show();
- } else {
- if (!currentPager || currentPager.username != m[3])
- currentPager = new User(m[3]);
- currentPager.show();
- loginStatus.update();
-
- if (m[5]) {
- var r = parseInt(m[5]);
- currentPager.showRecord = r;
- if (currentPager.recordCache[r]) {
- currentPager.displayItems();
- } else {
- currentPager.loadItems((r >= 49 ? r - 49 : 0), r);
- }
+ var m;
+ if (m = location.search.match(/^\?post\/([^/]+)\/(.+)/)) {
+ $('post').show();
+ $('post.content').value = '[' + decodeURIComponent(m[1]).replace(']','').replace('[','') + '](' + decodeURIComponent(m[2]) + ')';
+ } else if (m = location.hash.match(/^#(ref|tag)\/(\w+)$/)) {
+ currentPager = new Tag(m[1], m[2]);
+ currentPager.show();
+ } else if (m = location.hash.match(/^#(\w+)(:(\d+))?$/)) {
+ if (!currentPager || currentPager.username != m[1])
+ currentPager = new User(m[1]);
+ currentPager.show();
+ loginStatus.update();
+
+ if (m[3]) {
+ var r = parseInt(m[3]);
+ currentPager.showRecord = r;
+ if (currentPager.recordCache[r]) {
+ currentPager.displayItems();
} else {
- currentPager.pageStart = currentPager.itemCount - 1;
- currentPager.loadItems();
+ currentPager.loadItems((r >= 49 ? r - 49 : 0), r);
}
+ } else {
+ currentPager.pageStart = currentPager.itemCount - 1;
+ currentPager.loadItems();
}
} else {
$$('[name=section]').each(function(v) { v.update('Welcome') });