From eaeaf47374e6a368c598743d7bcbf6477911e87d Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Sun, 29 Sep 2013 00:32:51 +0100 Subject: [PATCH] make login, signup and logout available on all pages --- assets/html/author.html | 49 ++++++++++++++++++++++++++++++++-- assets/html/documentation.html | 48 ++++++++++++++++++++++++++++++++- assets/html/download.html | 48 ++++++++++++++++++++++++++++++++- assets/html/main.html | 6 ++--- assets/js/init.js | 11 ++++++-- assets/js/session.js | 13 ++++++--- assets/style/common.css | 5 ++-- 7 files changed, 166 insertions(+), 14 deletions(-) diff --git a/assets/html/author.html b/assets/html/author.html index 061ee07..8c36983 100644 --- a/assets/html/author.html +++ b/assets/html/author.html @@ -5,12 +5,30 @@ Taskrambler - Author + + + + +
+
+
    +
  • +
    + Session: +
    +
  • +
  • +
  • +
+
Session ID: +
+
@@ -80,6 +99,32 @@ contact-email
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+ +
+ +
+
diff --git a/assets/html/documentation.html b/assets/html/documentation.html index c09ce00..da9861d 100644 --- a/assets/html/documentation.html +++ b/assets/html/documentation.html @@ -5,12 +5,30 @@ Taskrambler - Documentation + + + + +
+
+
    +
  • +
    + Session: +
    +
  • +
  • +
  • +
+
Session ID: +
+
@@ -29,7 +47,9 @@
  • author
  • documentation
  • download
  • -
  • example
  • + + +
  • logout
  • @@ -55,6 +75,32 @@ contact-email
    + +
    +
    + +
    + +
    + +
    +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    diff --git a/assets/html/download.html b/assets/html/download.html index 5688284..f6729aa 100644 --- a/assets/html/download.html +++ b/assets/html/download.html @@ -5,12 +5,30 @@ Taskrambler - Download + + + + +
    +
    +
      +
    • +
      + Session: +
      +
    • +
    • +
    • +
    +
    Session ID: +
    +
    @@ -29,7 +47,9 @@
  • author
  • documentation
  • download
  • -
  • example
  • + + +
  • logout
  • @@ -85,6 +105,32 @@ contact-email
    + +
    +
    + +
    + +
    + +
    +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    diff --git a/assets/html/main.html b/assets/html/main.html index c1a69b5..30afc74 100644 --- a/assets/html/main.html +++ b/assets/html/main.html @@ -47,9 +47,9 @@
  • author
  • documentation
  • download
  • -
  • example
  • -
  • signup
  • -
  • login
  • + + +
  • logout
  • diff --git a/assets/js/init.js b/assets/js/init.js index d93cc00..b94f280 100644 --- a/assets/js/init.js +++ b/assets/js/init.js @@ -19,14 +19,19 @@ $(document).ready(function() { $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); }); - $("div#menu ul li:eq(5)").click(function() { + $("div#menu ul li.signup").click(function() { $("#signup").removeClass("hide"); }); - $("div#menu ul li:eq(6)").click(function() { + $("div#menu ul li.login").click(function() { $("#login").removeClass("hide"); }); + $("div#menu ul li.logout").click(function() { + $.getJSON("/logout/", $.proxy(sess.loadUserJSON, sess)); + $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); + }); + $("#randval").click(function() { sval.stop(); }); @@ -37,6 +42,7 @@ $(document).ready(function() { $("#login form").serialize(), $.proxy(sess.loadUserJSON, sess)); $("#login").addClass("hide"); + $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); }); $("#signup form").submit(function(event) { @@ -45,6 +51,7 @@ $(document).ready(function() { $("#signup form").serialize(), $.proxy(sess.loadUserJSON, sess)); $("#signup").addClass("hide"); + $.getJSON("/sessinfo/", $.proxy(sess.loadJSON, sess)); }); }); diff --git a/assets/js/session.js b/assets/js/session.js index 9e695ca..4f4b09d 100644 --- a/assets/js/session.js +++ b/assets/js/session.js @@ -13,7 +13,7 @@ function Session(sInfo, sId, sUser) this.surname = ""; this.interval = null; - this.draw(); + //this.draw(); } Session.prototype.loadUserJSON = function(data) @@ -25,13 +25,20 @@ Session.prototype.loadUserJSON = function(data) name = ""; if ('' == this.email) { name = "not logged in"; + $("li.signup").removeClass("hide"); + $("li.login").removeClass("hide"); + $("li.logout").addClass("hide"); } else { if ('' == this.firstname || '' == this.surname) { name += this.email; } else { name += this.firstname + " " + this.surname; } + $("li.signup").addClass("hide"); + $("li.login").addClass("hide"); + $("li.logout").removeClass("hide"); } + this.eUser.empty().append(name); } @@ -64,7 +71,7 @@ Session.prototype.draw = function() Session.prototype.start = function() { if (null === this.interval) { - this.interval = setInterval($.proxy(this.process, this), 500); + this.interval = setInterval($.proxy(this.process, this), 1000); } } @@ -75,7 +82,7 @@ Session.prototype.process = function() } else { - this.timeleft-=5; + this.timeleft -= 10; this.draw(); } } diff --git a/assets/style/common.css b/assets/style/common.css index ad9c38b..9254406 100644 --- a/assets/style/common.css +++ b/assets/style/common.css @@ -28,8 +28,9 @@ div#login { border-radius: 10px; } -div.hide { - top: -500px !important; +.hide { + top: -500px !important; + display: none !important; } .small {