Sha256: adda94f924116caedf5bf1be14af9e166f966a58eb5fbb19d0219d713758c999
Contents?: true
Size: 1.71 KB
Versions: 7
Compression:
Stored size: 1.71 KB
Contents
JsChat.SignOnController = Class.create({ initialize: function() { this.retries = 0; setTimeout(function() { $('name').activate(); }, 500); $('sign-on').observe('submit', this.submitEvent.bindAsEventListener(this)); }, submitEvent: function(e) { this.signOn(); Event.stop(e); return false; }, showError: function(message) { $('feedback').innerHTML = '<div class="error">#{message}</div>'.interpolate({ message: message }); $('feedback').show(); $('sign-on-submit').enable(); }, signOn: function() { $('loading').show(); $('sign-on-submit').disable(); this.retries += 1; new Ajax.Request('/identify', { parameters: $('sign-on').serialize(true), onSuccess: function(transport) { try { var json = transport.responseText.evalJSON(true); if (json['action'] == 'reload' && this.retries < 4) { setTimeout(function() { this.signOn() }.bind(this), 50); } else if (json['action'] == 'redirect') { if (window.location.toString().match(new RegExp(json['to'] + '$'))) { window.location.reload(); } else { window.location = json['to']; } } else if (json['error']) { this.showError(json['error']['message']); $('loading').hide(); } else { this.showError('Connection error'); } } catch (exception) { this.showError('Connection error: #{error}'.interpolate({ error: exception })); } }.bind(this), onFailure: function() { this.showError('Connection error'); }.bind(this), onComplete: function() { $('loading').hide(); } }); } });
Version data entries
7 entries across 7 versions & 1 rubygems