jekyll-attendease 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/jekyll-attendease.rb +79 -21
  2. metadata +15 -14
@@ -228,35 +228,93 @@ layout: layout
228
228
 
229
229
  content = <<-eos
230
230
  <script type="text/javascript">
231
- function handleAuthState()
232
- {
233
- var xmlhttp;
234
- if (window.XMLHttpRequest)
231
+ var JekyllAttendease = {
232
+
233
+ attendease_logged_in: false,
234
+
235
+ addEvent: function(obj, eventType, targetFunction, useCapture)
235
236
  {
236
- xmlhttp=new XMLHttpRequest();
237
- xmlhttp.onreadystatechange=function()
237
+ if (obj.addEventListener)
238
238
  {
239
- if (xmlhttp.readyState==4 && xmlhttp.status==200)
240
- {
241
- logout = '<a class="attendease-auth-logout" href="/attendease/logout">Logout</a>';
242
- document.getElementById("attendease-auth-action").innerHTML = logout;
239
+ obj.addEventListener(eventType, targetFunction, false);
240
+ }
241
+ else if (obj.attachEvent)
242
+ {
243
+ obj.attachEvent('on' + eventType, targetFunction);
244
+ }
245
+ else
246
+ {
247
+ obj['on' + eventType] = targetFunction;
248
+ }
249
+ },
243
250
 
244
- account = JSON.parse(xmlhttp.responseText);
245
- account = '<a class="attendease-auth-account" href="/attendease/account">' + account.name + '</a>';
246
- document.getElementById("attendease-auth-account").innerHTML = account;
247
- }
248
- else
251
+ onLoginCheck: function(callback) {
252
+ this.addEvent(document, "attendease.loggedin", callback);
253
+ },
254
+
255
+ isLoggedIn: function() {
256
+ return this.attendease_logged_in;
257
+ },
258
+
259
+ handleAuthState: function() {
260
+ var xmlhttp;
261
+ if (window.XMLHttpRequest)
262
+ {
263
+ xmlhttp=new XMLHttpRequest();
264
+ xmlhttp.onreadystatechange=function()
249
265
  {
250
- login = '<a class="attendease-auth-logout" href="/attendease/login">Login</a>';
251
- document.getElementById("attendease-auth-action").innerHTML = login;
266
+ if (xmlhttp.readyState==4)
267
+ {
268
+ var accountObject = false;
269
+
270
+ if (xmlhttp.status==200)
271
+ {
272
+ authActionElement = document.getElementById("attendease-auth-action");
273
+ if (authActionElement)
274
+ {
275
+ authActionElement.innerHTML = '<a class="attendease-auth-logout" href="/attendease/logout">Logout</a>';
276
+ }
277
+
278
+ accountObject = JSON.parse(xmlhttp.responseText);
279
+
280
+ authAccountElement = document.getElementById("attendease-auth-account");
281
+ if (authAccountElement)
282
+ {
283
+ authAccountElement.innerHTML = '<a class="attendease-auth-account" href="/attendease/account">' + accountObject.name + '</a>';
284
+ }
285
+
286
+ this.attendease_logged_in = true;
287
+ }
288
+ else
289
+ {
290
+ document.getElementById("attendease-auth-action").innerHTML = '<a class="attendease-auth-logout" href="/attendease/login">Login</a>';
291
+ }
292
+
293
+ data = { loggedin: this.attendease_logged_in, account: accountObject, loginURL: "/attendease/login", logoutURL: "/attendease/logout", accountURL: "/attendease/account" };
294
+
295
+ if (document.createEvent)
296
+ {
297
+ event = document.createEvent("HTMLEvents");
298
+ event.initEvent("attendease.loggedin", true, true);
299
+ event.data = data;
300
+ document.dispatchEvent(event);
301
+ }
302
+ else
303
+ {
304
+ event = document.createEventObject();
305
+ event.eventType = "attendease.loggedin";
306
+ event.memo = data;
307
+ document.fireEvent("on" + event.eventType, event);
308
+ }
309
+ }
252
310
  }
311
+ xmlhttp.open("GET","/attendease/verify_credentials.json",true);
312
+ xmlhttp.send();
253
313
  }
254
- xmlhttp.open("GET","/attendease/verify_credentials.json",true);
255
- xmlhttp.send();
256
314
  }
257
- }
315
+ };
258
316
 
259
- document.addEventListener('DOMContentLoaded', handleAuthState);
317
+ document.addEventListener('DOMContentLoaded', JekyllAttendease.handleAuthState);
260
318
  </script>
261
319
  eos
262
320
 
metadata CHANGED
@@ -1,49 +1,50 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-attendease
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.3.6
4
5
  prerelease:
5
- version: 0.3.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Wood
9
9
  - Patrick Gibson
10
+ - Jamie Lubiner
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2013-06-12 00:00:00.000000000 Z
14
+ date: 2013-08-22 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- version_requirements: !ruby/object:Gem::Requirement
17
+ name: httparty
18
+ requirement: !ruby/object:Gem::Requirement
19
+ none: false
17
20
  requirements:
18
21
  - - ! '>='
19
22
  - !ruby/object:Gem::Version
20
23
  version: '0'
21
- none: false
22
- name: httparty
23
24
  type: :runtime
24
25
  prerelease: false
25
- requirement: !ruby/object:Gem::Requirement
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
26
28
  requirements:
27
29
  - - ! '>='
28
30
  - !ruby/object:Gem::Version
29
31
  version: '0'
30
- none: false
31
32
  - !ruby/object:Gem::Dependency
32
- version_requirements: !ruby/object:Gem::Requirement
33
+ name: json
34
+ requirement: !ruby/object:Gem::Requirement
35
+ none: false
33
36
  requirements:
34
37
  - - ! '>='
35
38
  - !ruby/object:Gem::Version
36
39
  version: '0'
37
- none: false
38
- name: json
39
40
  type: :runtime
40
41
  prerelease: false
41
- requirement: !ruby/object:Gem::Requirement
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
42
44
  requirements:
43
45
  - - ! '>='
44
46
  - !ruby/object:Gem::Version
45
47
  version: '0'
46
- none: false
47
48
  description: Bring your event data into Jekyll for amazing event websites.
48
49
  email: support@attendease.com
49
50
  executables: []
@@ -59,17 +60,17 @@ rdoc_options: []
59
60
  require_paths:
60
61
  - lib
61
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
62
64
  requirements:
63
65
  - - ! '>='
64
66
  - !ruby/object:Gem::Version
65
67
  version: '0'
66
- none: false
67
68
  required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
68
70
  requirements:
69
71
  - - ! '>='
70
72
  - !ruby/object:Gem::Version
71
73
  version: '0'
72
- none: false
73
74
  requirements: []
74
75
  rubyforge_project:
75
76
  rubygems_version: 1.8.23