Add subscription management features
[blerg.git] / www / js / blerg.js
index 8da3872..fac5371 100644 (file)
@@ -241,130 +241,6 @@ Pager.prototype.showRecord = function(r) {
 
 Pager.prototype.loadItems = function(from, to, continuation) { }
 
-
-// Object to render user pages
-function User(m) {
-    Pager.call(this);
-    this.username = m[1];
-    this.baseFrag = m[1];
-    this.permalink = (m[2] != 'p');
-    this.pageStart = parseInt(m[3]);
-}
-User.prototype = new Pager();
-User.prototype.constructor = User;
-
-User.prototype.updateState = function(m) {
-    if (m[1] != this.username)
-        return false;
-    
-    this.permalink = (m[2] != 'p');
-    this.pageStart = parseInt(m[3]);
-    this.show();
-
-    return true;
-}
-
-User.prototype.show = function() {
-    Pager.prototype.show.call(this);
-
-    $$('[name=section]').each(function(v) { v.update(' @' + this.username) }.bind(this));
-    $('rss').show();
-    $('rsslink').href = '/rss/' + this.username;
-    $$('[name=user.reflink]').each(function(e) {
-        e.href = baseURL + '/#/ref/' + this.username;
-    }.bind(this));
-    $('usercontrols').show();
-
-    if (this.permalink && this.pageStart >= 0) {
-        this.showRecord(this.pageStart);
-    } else if (this.pageStart >= 0) {
-        this.showPageAt(this.pageStart);
-    } else {
-        this.reload();
-    }
-}
-
-User.prototype.hide = function() {
-    Pager.prototype.hide.call(this);
-    $('signup').hide();
-    $('rss').hide();
-    $('usercontrols').hide();
-}
-
-User.prototype.reload = function() {
-    this.pageStart = null;
-
-    $$('[name=user.subscribelink]').each(Element.hide);
-    $$('[name=user.unsubscribelink]').each(Element.hide);
-
-    if (loginStatus.loggedIn) {
-        new Ajax.Request(baseURL + '/feedinfo/' + this.username, {
-            method: 'post',
-            parameters: {
-                username: loginStatus.username
-            },
-            onSuccess: function(r) {
-                var json = r.responseText.evalJSON();
-                if (json.subscribed) {
-                    $$('[name=user.subscribelink]').each(Element.hide);
-                    $$('[name=user.unsubscribelink]').each(Element.show);
-                } else {
-                    $$('[name=user.subscribelink]').each(Element.show);
-                    $$('[name=user.unsubscribelink]').each(Element.hide);
-                }
-            }
-        });
-    }
-
-    new Ajax.Request(baseURL + '/info/' + this.username, {
-        method: 'get',
-        onSuccess: function(r) {
-            var response = r.responseText.evalJSON();
-            if (response) {
-                this.itemCount = parseInt(response.record_count);
-                this.showPageAt(this.itemCount - 1);
-            }
-        }.bind(this)
-    });
-}
-
-User.prototype.loadItems = function(from, to, continuation) {
-    if (to < 0)
-        return;
-
-    var url;
-    if (from != undefined && to != undefined) {
-        url = baseURL + '/get/' + this.username + '/' + from + '-' + to;
-        this.pageStart = to;
-    } else {
-        url = baseURL + '/get/' + this.username;
-    }
-
-    new Ajax.Request(url, {
-        method: 'get',
-        onSuccess: function(r) {
-            var records = r.responseText.evalJSON();
-            if (records && records.length > 0) {
-                records.each(function(v) {
-                    v.id = v.record;
-                    v.author = this.username;
-                    mangleRecord(v, recordTemplate);
-                }.bind(this));
-                this.addItems(records);
-                if (!this.pageStart)
-                    this.pageStart = records[0].recInt;
-            }
-            continuation();
-        }.bind(this),
-        onFailure: function(r) {
-            this.displayItems();
-        }.bind(this),
-        on404: function(r) {
-            displayError('User not found');
-        }
-    });
-}
-
 function displayError(msg) {
     items.innerText = msg;
 }