Showing
1 changed file
with
0 additions
and
110 deletions
assets/js/session.orig.js
deleted
100644 → 0
1 | -function Session(sInfo, sId, sUser) | |
2 | -{ | |
3 | - this.eUser = $(sUser); | |
4 | - this.eId = $(sId); | |
5 | - this.canvas = $(sInfo + " canvas").get(0); | |
6 | - this.context = this.canvas.getContext("2d"); | |
7 | - | |
8 | - this.id = "none" | |
9 | - this.timeout = 0; | |
10 | - this.timeleft = 0; | |
11 | - this.user = null; | |
12 | - | |
13 | - //this.draw(); | |
14 | -} | |
15 | - | |
16 | -Session.prototype.isAthenticated = function(data) | |
17 | -{ | |
18 | -} | |
19 | - | |
20 | -Session.prototype.authenticate = function(data) | |
21 | -{ | |
22 | - this.username = data.username; | |
23 | - this.email = data.email; | |
24 | - this.firstname = data.firstname; | |
25 | - this.surname = data.surname; | |
26 | - | |
27 | - name = ""; | |
28 | - if ('' == this.username) { | |
29 | - name = "not logged in"; | |
30 | - $("li.signup").removeClass("hide"); | |
31 | - $("li.login").removeClass("hide"); | |
32 | - $("li.logout").addClass("hide"); | |
33 | - } else { | |
34 | - if ('' == this.firstname || '' == this.surname) { | |
35 | - name += this.username; | |
36 | - } else { | |
37 | - name += this.firstname + " " + this.surname; | |
38 | - } | |
39 | - $("li.signup").addClass("hide"); | |
40 | - $("li.login").addClass("hide"); | |
41 | - $("li.logout").removeClass("hide"); | |
42 | - } | |
43 | - | |
44 | - this.eUser.empty().append(name); | |
45 | -} | |
46 | - | |
47 | -Session.prototype.loadJSON = function(data) | |
48 | -{ | |
49 | - // this.stop(); | |
50 | - | |
51 | - this.id = ("0" == data.id)? "none" : data.id; | |
52 | - this.timeout = data.timeout * 10; | |
53 | - this.timeleft = data.timeleft * 10; | |
54 | - | |
55 | - this.eId.empty().append(this.id); | |
56 | - | |
57 | - this.draw(); | |
58 | - if (0 < this.timeleft) | |
59 | - this.start(); | |
60 | -} | |
61 | - | |
62 | -Session.prototype.draw = function() | |
63 | -{ | |
64 | - this.context.fillStyle = "rgb(255, 0, 0)"; | |
65 | - this.context.fillRect(0, 0, this.canvas.width, this.canvas.height); | |
66 | - | |
67 | - this.context.fillStyle = "rgb(0, 255, 0)"; | |
68 | - this.context.fillRect(0, 0, | |
69 | - this.canvas.width / this.timeout * this.timeleft, | |
70 | - this.canvas.height); | |
71 | -} | |
72 | - | |
73 | -Session.prototype.start = function() | |
74 | -{ | |
75 | - if (null === this.interval) { | |
76 | - this.interval = setInterval($.proxy(this.process, this), 1000); | |
77 | - } | |
78 | -} | |
79 | - | |
80 | -Session.prototype.process = function() | |
81 | -{ | |
82 | - if (0 >= this.timeleft) { | |
83 | - this.stop(); | |
84 | - } | |
85 | - | |
86 | - else { | |
87 | - this.timeleft -= 10; | |
88 | - this.draw(); | |
89 | - } | |
90 | -} | |
91 | - | |
92 | -Session.prototype.stop = function() | |
93 | -{ | |
94 | - clearInterval(this.interval); | |
95 | - this.interval = null; | |
96 | - this.id = "none"; | |
97 | - this.timeout = 0; | |
98 | - this.timeleft = 0; | |
99 | - this.username = ""; | |
100 | - this.email = ""; | |
101 | - this.firstname = ""; | |
102 | - this.surname = ""; | |
103 | - | |
104 | - this.eId.empty().append(""); | |
105 | - this.eUser.empty().append("not logged in"); | |
106 | - | |
107 | - this.draw(); | |
108 | -} | |
109 | - | |
110 | -// vim: set ts=4 sw=4: |
Please
register
or
login
to post a comment