Fix page loading scheme; fix User switching
[blerg.git] / www / jssrc / blerg / Util.js
index 1bfab4c..b3f5369 100644 (file)
@@ -2,6 +2,15 @@ blerg = window.blerg || {};
 
 blerg.Util = {};
 
+// Dirty, terrible shim for rewritten links below
+blerg.Util.qlink = function() {
+       try {
+               location.href = event.target.href;
+       } catch(e) { }
+       enyo.$.blerg.bubble('onNavigate');
+       return false;
+}
+
 blerg.Util.blergFormat = function(text) {
        var lines = text.split(/\r?\n/);
        if (lines[lines.length - 1] == '')
@@ -67,8 +76,8 @@ blerg.Util.blergFormat = function(text) {
                l = l.replace(/([^\w\\]|^)\*(\w[^*]*)\*(\W|$)/g, '$1<i>$2</i>$3');
 
                // Turn refs and tags into links
-               l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1<a href="#/tag/$2" class="ref" onclick="return qlink()">#$2</a>');
-               l = l.replace(/(\s|^)@([A-Za-z0-9_-]+)(\/\d+)?/g, '$1<a href="#$2$3" class="ref" onclick="return qlink()">@$2</a>');
+               l = l.replace(/(\s|^)#([A-Za-z0-9_-]+)/g, '$1<a href="#/tag/$2" class="ref" onclick="return blerg.Util.qlink()">#$2</a>');
+               l = l.replace(/(\s|^)@([A-Za-z0-9_-]+)(\/\d+)?/g, '$1<a href="#$2$3" class="ref" onclick="return blerg.Util.qlink()">@$2</a>');
 
                // Create lists when lines begin with *
                if (l[0] == '*') {