X-Git-Url: http://git.bytex64.net/?a=blobdiff_plain;ds=sidebyside;f=www%2Fjs%2Fblerg.js;h=f5ef4316c601a5b55a9c3552c8990c8e0ea902af;hb=51121cd67db2faf393862fd50a0807342a5395da;hp=21d7d34b407f7274852ec97167a83340e2187db1;hpb=7c28f5b05e6c67858a46795e42d41b9ac1aa7716;p=blerg.git
diff --git a/www/js/blerg.js b/www/js/blerg.js
index 21d7d34..f5ef431 100644
--- a/www/js/blerg.js
+++ b/www/js/blerg.js
@@ -215,6 +215,24 @@ function User(username) {
this.initPager();
this.username = username;
this.baseFrag = username;
+}
+User.prototype = new Pager();
+User.prototype.constructor = User;
+
+User.prototype.show = function() {
+ $$('[name=section]').each(function(v) { v.update(' @' + this.username) }.bind(this));
+ $('welcome').hide();
+ items.show();
+ $('rss').show();
+ $('rsslink').href = '/rss/' + this.username;
+ $$('[name=user.reflink]').each(function(e) {
+ e.href = '/#/ref/' + this.username;
+ }.bind(this));
+ $('usercontrols').show();
+}
+
+User.prototype.reload = function() {
+ this.pageStart = null;
$$('[name=user.subscribelink]').each(Element.hide);
$$('[name=user.unsubscribelink]').each(Element.hide);
@@ -238,7 +256,7 @@ function User(username) {
});
}
- new Ajax.Request(baseURL + '/info/' + username, {
+ new Ajax.Request(baseURL + '/info/' + this.username, {
method: 'get',
onSuccess: function(r) {
var j = r.responseText.evalJSON();
@@ -250,20 +268,6 @@ function User(username) {
}.bind(this)
});
}
-User.prototype = new Pager();
-User.prototype.constructor = User;
-
-User.prototype.show = function() {
- $$('[name=section]').each(function(v) { v.update(' @' + this.username) }.bind(this));
- $('welcome').hide();
- items.show();
- $('rss').show();
- $('rsslink').href = '/rss/' + this.username;
- $$('[name=user.reflink]').each(function(e) {
- e.href = '/#/ref/' + this.username;
- }.bind(this));
- $('usercontrols').show();
-}
User.prototype.loadItems = function(from, to, continuation) {
var url;
@@ -341,8 +345,11 @@ function mangleRecord(record, template) {
l = l.replace(/(\s|^)\[([^\]]+)\]\((https?:\/\/[a-zA-Z0-9.-]*[a-zA-Z0-9](\/[^)"]*?)?)\)/g, '$1$2');
// Turn *foo* into italics and **foo** into bold
- l = l.replace(/(\W|^)\*\*(\w[^*]*)\*\*(\W|$)/g, '$1$2$3');
- l = l.replace(/(\W|^)\*(\w[^*]*)\*(\W|$)/g, '$1$2$3');
+ l = l.replace(/([^\w\\]|^)\*\*(\w[^*]*)\*\*(\W|$)/g, '$1$2$3');
+ l = l.replace(/([^\w\\]|^)\*(\w[^*]*)\*(\W|$)/g, '$1$2$3');
+
+ // Remove backslashes from escaped metachars
+ l = l.replace(/\\([*\[\]])/g, '$1');
// Turn refs and tags into links
l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1#$2');
@@ -360,12 +367,12 @@ function mangleRecord(record, template) {
endpush = '';
}
- // Create headers when lines begin with =
- if (l[0] == '=') {
- var m = l.match(/^(=+)/);
+ // Create headers when lines begin with = or #
+ if (l[0] == '=' || l[0] == '#') {
+ var m = l.match(/^([=#]+)/);
var depth = m[1].length;
if (depth <= 5) {
- l = l.replace(/^=+\s*/, '').replace(/\s*=+$/, '');
+ l = l.replace(/^[=#]+\s*/, '').replace(/\s*[=#]+$/, '');
out.push('');
endpush = '';
}
@@ -737,8 +744,9 @@ function hashSwitch() {
} else {
currentPager.showRecord(r);
}
+ } else {
+ currentPager.reload();
}
- // Do nothing otherwise, the User constructor takes care of it
} else {
$$('[name=section]').each(function(v) { v.update('Welcome') });
$('signup').hide();