aboutsummaryrefslogtreecommitdiffstats
path: root/include/main.js
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-06-16 15:27:12 -0700
committerFriendika <info@friendika.com>2011-06-16 15:27:12 -0700
commitb61a7158da4c8a0b41651a082f0ce2f9ad431f14 (patch)
tree04257f59cd49725522aee9e210ab740970ab48f4 /include/main.js
parentc92e6ed929ddb12a3020eecf419a30b680fe4240 (diff)
parenta652cd5095fcff6ed9c72063ab19107e970e2b8d (diff)
downloadvolse-hubzilla-b61a7158da4c8a0b41651a082f0ce2f9ad431f14.tar.gz
volse-hubzilla-b61a7158da4c8a0b41651a082f0ce2f9ad431f14.tar.bz2
volse-hubzilla-b61a7158da4c8a0b41651a082f0ce2f9ad431f14.zip
Merge pull request #116 from fabrixxm/admin
Admin pages
Diffstat (limited to 'include/main.js')
-rw-r--r--include/main.js56
1 files changed, 38 insertions, 18 deletions
diff --git a/include/main.js b/include/main.js
index 18cb55328..3cc607977 100644
--- a/include/main.js
+++ b/include/main.js
@@ -29,10 +29,33 @@
var langSelect = false;
var commentBusy = false;
- $(document).ready(function() {
+ $(function() {
$.ajaxSetup({cache: false});
msie = $.browser.msie ;
+
+
+ /* nav update event */
+ $('nav').bind('nav-update', function(e,data){;
+ var net = $(data).find('net').text();
+ if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() }
+ $('#net-update').html(net);
+ var home = $(data).find('home').text();
+ if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
+ $('#home-update').html(home);
+ var mail = $(data).find('mail').text();
+ if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
+ $('#mail-update').html(mail);
+ var intro = $(data).find('intro').text();
+ var register = $(data).find('register').text();
+ if(intro == 0) { intro = ''; }
+ if(register != 0 && intro != '') { intro = intro+'/'+register; }
+ if(register != 0 && intro == '') { intro = '0/'+register; }
+ if (intro == '') { $('#notify-update').hide() } else { $('#notify-update').show() }
+ $('#notify-update').html(intro);
+ });
+
+
NavUpdate();
// Allow folks to stop the ajax page updates with the pause/break key
$(document).keypress(function(event) {
@@ -70,23 +93,8 @@
if(! stopped) {
$.get("ping",function(data) {
$(data).find('result').each(function() {
- var net = $(this).find('net').text();
- if(net == 0) { net = ''; $('#net-update').hide() } else { $('#net-update').show() }
- $('#net-update').html(net);
- var home = $(this).find('home').text();
- if(home == 0) { home = ''; $('#home-update').hide() } else { $('#home-update').show() }
- $('#home-update').html(home);
- var mail = $(this).find('mail').text();
- if(mail == 0) { mail = ''; $('#mail-update').hide() } else { $('#mail-update').show() }
- $('#mail-update').html(mail);
- var intro = $(this).find('intro').text();
- var register = $(this).find('register').text();
- if(intro == 0) { intro = ''; }
- if(register != 0 && intro != '') { intro = intro+'/'+register; }
- if(register != 0 && intro == '') { intro = '0/'+register; }
- if (intro == '') { $('#notify-update').hide() } else { $('#notify-update').show() }
- $('#notify-update').html(intro);
-
+ // send nav-update event
+ $('nav').trigger('nav-update', this);
});
}) ;
}
@@ -279,3 +287,15 @@
});
}
+/**
+ * sprintf in javascript
+ * "{0} and {1}".format('zero','uno');
+ **/
+String.prototype.format = function() {
+ var formatted = this;
+ for (var i = 0; i < arguments.length; i++) {
+ var regexp = new RegExp('\\{'+i+'\\}', 'gi');
+ formatted = formatted.replace(regexp, arguments[i]);
+ }
+ return formatted;
+};