Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/aphlict/Aphlict.js
| Show All 22 Lines | |||||
| * | * | ||||
| * You do not have to handle any of them in any specific way. | * You do not have to handle any of them in any specific way. | ||||
| */ | */ | ||||
| JX.install('Aphlict', { | JX.install('Aphlict', { | ||||
| construct: function(id, server, port, subscriptions) { | construct: function(id, server, port, subscriptions) { | ||||
| if (__DEV__) { | if (__DEV__) { | ||||
| if (JX.Aphlict._instance) { | if (JX.Aphlict._instance) { | ||||
| JX.$E('Aphlict object is a singleton!'); | JX.$E('Aphlict object is a singleton.'); | ||||
| } | } | ||||
| } | } | ||||
| this._id = id; | this._id = id; | ||||
| this._server = server; | this._server = server; | ||||
| this._port = port; | this._port = port; | ||||
| this._subscriptions = subscriptions; | this._subscriptions = subscriptions; | ||||
| this._setStatus('setup'); | |||||
| JX.Aphlict._instance = this; | JX.Aphlict._instance = this; | ||||
| }, | }, | ||||
| events: ['didChangeStatus'], | |||||
| members: { | members: { | ||||
| _id: null, | _id: null, | ||||
| _server: null, | _server: null, | ||||
| _port: null, | _port: null, | ||||
| _subscriptions: null, | _subscriptions: null, | ||||
| _status: null, | |||||
| _statusCode: null, | |||||
| start: function(node, uri) { | start: function(node, uri) { | ||||
| this._setStatus('start'); | |||||
| // NOTE: This is grotesque, but seems to work everywhere. | // NOTE: This is grotesque, but seems to work everywhere. | ||||
| node.innerHTML = | node.innerHTML = | ||||
| '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' + | '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">' + | ||||
| '<param name="movie" value="' + uri + '" />' + | '<param name="movie" value="' + uri + '" />' + | ||||
| '<param name="allowScriptAccess" value="always" />' + | '<param name="allowScriptAccess" value="always" />' + | ||||
| '<param name="wmode" value="opaque" />' + | '<param name="wmode" value="opaque" />' + | ||||
| '<embed src="' + uri + '" wmode="opaque"' + | '<embed src="' + uri + '" wmode="opaque"' + | ||||
| 'width="0" height="0" id="' + this._id + '">' + | 'width="0" height="0" id="' + this._id + '">' + | ||||
| Show All 9 Lines | _didStartFlash: function() { | ||||
| // didn't support other scopes since global scope is the best anyway. | // didn't support other scopes since global scope is the best anyway. | ||||
| var container = document[id] || window[id]; | var container = document[id] || window[id]; | ||||
| this._flashContainer = container; | this._flashContainer = container; | ||||
| this._flashContainer.connect( | this._flashContainer.connect( | ||||
| this._server, | this._server, | ||||
| this._port, | this._port, | ||||
| this._subscriptions); | this._subscriptions); | ||||
| }, | |||||
| getStatus: function() { | |||||
| return this._status; | |||||
| }, | |||||
| getStatusCode: function() { | |||||
| return this._statusCode; | |||||
| }, | |||||
| _setStatus: function(status, code) { | |||||
| this._status = status; | |||||
| this._statusCode = code || null; | |||||
| this.invoke('didChangeStatus'); | |||||
| } | } | ||||
| }, | }, | ||||
| properties: { | properties: { | ||||
| handler: null | handler: null | ||||
| }, | }, | ||||
| Show All 10 Lines | statics: { | ||||
| didReceiveEvent: function(type, message) { | didReceiveEvent: function(type, message) { | ||||
| var client = JX.Aphlict.getInstance(); | var client = JX.Aphlict.getInstance(); | ||||
| if (!client) { | if (!client) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (type == 'status') { | if (type == 'status') { | ||||
| client._setStatus(message.type, message.code); | |||||
| switch (message.type) { | switch (message.type) { | ||||
| case 'ready': | case 'ready': | ||||
| client._didStartFlash(); | client._didStartFlash(); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| var handler = client.getHandler(); | var handler = client.getHandler(); | ||||
| if (handler) { | if (handler) { | ||||
| handler(type, message); | handler(type, message); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||