2015-01-20 01:53:18 -05:00
|
|
|
// Modify Array and others.
|
2015-06-05 03:59:28 -04:00
|
|
|
// require('./shims');
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
// ----------------
|
|
|
|
// The Constructor
|
|
|
|
// ----------------
|
|
|
|
|
|
|
|
var FFZ = window.FrankerFaceZ = function() {
|
|
|
|
FFZ.instance = this;
|
|
|
|
|
2015-02-10 01:34:23 -05:00
|
|
|
// Logging
|
|
|
|
this._log_data = [];
|
2015-10-24 22:44:00 -04:00
|
|
|
this._apis = {};
|
2015-02-10 01:34:23 -05:00
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
// Error Logging
|
|
|
|
var t = this;
|
|
|
|
window.addEventListener('error', function(event) {
|
|
|
|
if ( ! event.error )
|
|
|
|
return;
|
|
|
|
|
|
|
|
var has_stack = event.error && event.error.stack;
|
|
|
|
t.log("JavaScript Error: " + event.message + " [" + event.filename + ":" + event.lineno + ":" + event.colno + "]", has_stack ? event.error.stack : undefined, false, has_stack);
|
|
|
|
});
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
// Get things started.
|
|
|
|
this.initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FFZ.get = function() { return FFZ.instance; }
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
// TODO: This should be in a module.
|
|
|
|
FFZ.msg_commands = {};
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
// Version
|
|
|
|
var VER = FFZ.version_info = {
|
2016-04-16 17:45:25 -04:00
|
|
|
major: 3, minor: 5, revision: 159,
|
2015-01-20 01:53:18 -05:00
|
|
|
toString: function() {
|
|
|
|
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Logging
|
|
|
|
|
2015-03-30 00:52:18 -04:00
|
|
|
FFZ.prototype.log = function(msg, data, to_json, log_json) {
|
2016-03-23 19:28:22 -04:00
|
|
|
if ( to_json )
|
|
|
|
msg = msg + ' -- ' + JSON.stringify(data);
|
|
|
|
|
2015-03-30 00:52:18 -04:00
|
|
|
this._log_data.push(msg + ((!to_json && log_json) ? " -- " + JSON.stringify(data) : ""));
|
2015-02-10 01:34:23 -05:00
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
if ( data !== undefined && console.groupCollapsed && console.dir ) {
|
2016-03-23 19:28:22 -04:00
|
|
|
console.groupCollapsed("FFZ: " + msg);
|
2015-01-20 01:53:18 -05:00
|
|
|
if ( navigator.userAgent.indexOf("Firefox/") !== -1 )
|
|
|
|
console.log(data);
|
|
|
|
else
|
|
|
|
console.dir(data);
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
console.groupEnd("FFZ: " + msg);
|
2015-01-20 01:53:18 -05:00
|
|
|
} else
|
2016-03-23 19:28:22 -04:00
|
|
|
console.log("FFZ: " + msg);
|
2015-01-20 01:53:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
FFZ.prototype.error = function(msg, data, to_json, log_json) {
|
|
|
|
msg = "Error: " + msg + (to_json ? " -- " + JSON.stringify(data) : "");
|
|
|
|
this._log_data.push(msg + ((!to_json && log_json) ? " -- " + JSON.stringify(data) : ""));
|
2015-02-10 01:34:23 -05:00
|
|
|
|
|
|
|
if ( data !== undefined && console.groupCollapsed && console.dir ) {
|
2016-03-23 19:28:22 -04:00
|
|
|
console.groupCollapsed("FFZ " + msg);
|
2015-02-10 01:34:23 -05:00
|
|
|
if ( navigator.userAgent.indexOf("Firefox/") !== -1 )
|
|
|
|
console.log(data);
|
|
|
|
else
|
|
|
|
console.dir(data);
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
console.groupEnd("FFZ " + msg);
|
2015-02-10 01:34:23 -05:00
|
|
|
} else
|
2016-03-23 19:28:22 -04:00
|
|
|
console.assert(false, "FFZ " + msg);
|
2015-02-10 01:34:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FFZ.prototype.paste_logs = function() {
|
|
|
|
this._pastebin(this._log_data.join("\n"), function(url) {
|
|
|
|
if ( ! url )
|
|
|
|
return console.log("FFZ Error: Unable to upload log to pastebin.");
|
|
|
|
|
|
|
|
console.log("FFZ: Your FrankerFaceZ log has been pasted to: " + url);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FFZ.prototype._pastebin = function(data, callback) {
|
|
|
|
jQuery.ajax({url: "http://putco.de/", type: "PUT", data: data, context: this})
|
|
|
|
.success(function(e) {
|
2016-03-23 19:28:22 -04:00
|
|
|
callback.call(this, e.trim() + ".log");
|
2015-02-10 01:34:23 -05:00
|
|
|
}).fail(function(e) {
|
2016-03-23 19:28:22 -04:00
|
|
|
callback.call(this, null);
|
2015-02-10 01:34:23 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
// -------------------
|
|
|
|
// User Data
|
|
|
|
// -------------------
|
|
|
|
|
|
|
|
FFZ.prototype.get_user = function() {
|
2015-11-14 23:52:49 -05:00
|
|
|
if ( this.__user )
|
|
|
|
return this.__user;
|
|
|
|
|
2016-03-23 20:23:04 -04:00
|
|
|
var LC = FFZ.utils.ember_lookup('controller:login'),
|
|
|
|
user = LC ? LC.get('userData') : undefined;
|
2015-11-14 23:52:49 -05:00
|
|
|
|
2016-03-23 20:23:04 -04:00
|
|
|
if ( ! user && window.PP && PP.login )
|
|
|
|
user = PP;
|
2015-11-14 23:52:49 -05:00
|
|
|
|
2016-03-23 20:23:04 -04:00
|
|
|
if ( user )
|
|
|
|
this.__user = user;
|
2015-11-14 23:52:49 -05:00
|
|
|
|
2016-03-23 20:23:04 -04:00
|
|
|
return user;
|
2015-01-20 01:53:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------
|
|
|
|
// Import Everything!
|
|
|
|
// -------------------
|
|
|
|
|
2015-02-24 00:33:29 -05:00
|
|
|
// Import these first to set up data structures
|
2015-10-17 18:05:44 -04:00
|
|
|
require('./localization');
|
2015-02-24 00:33:29 -05:00
|
|
|
require('./ui/menu');
|
2015-02-08 02:01:09 -05:00
|
|
|
require('./settings');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./socket');
|
2015-02-24 00:33:29 -05:00
|
|
|
|
2015-07-18 21:10:27 -04:00
|
|
|
require('./colors');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./emoticons');
|
|
|
|
require('./badges');
|
2015-06-05 03:59:28 -04:00
|
|
|
require('./tokenize');
|
2015-10-17 18:05:44 -04:00
|
|
|
//require('./filtering');
|
2015-06-05 03:59:28 -04:00
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
|
2015-10-24 22:44:00 -04:00
|
|
|
require('./ember/router');
|
2015-05-17 19:02:57 -04:00
|
|
|
require('./ember/channel');
|
2015-10-17 18:05:44 -04:00
|
|
|
require('./ember/player');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ember/room');
|
2016-03-23 19:28:22 -04:00
|
|
|
require('./ember/vod-chat');
|
2015-07-31 17:44:20 -04:00
|
|
|
require('./ember/layout');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ember/line');
|
|
|
|
require('./ember/chatview');
|
2015-11-10 21:37:30 -05:00
|
|
|
require('./ember/conversations');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ember/viewers');
|
2015-02-10 01:34:23 -05:00
|
|
|
require('./ember/moderation-card');
|
2015-07-06 00:09:21 -04:00
|
|
|
require('./ember/chat-input');
|
2015-01-20 01:53:18 -05:00
|
|
|
//require('./ember/teams');
|
2015-10-17 18:05:44 -04:00
|
|
|
require('./ember/directory');
|
2015-11-10 21:37:30 -05:00
|
|
|
require('./ember/following');
|
2016-03-31 19:47:17 -04:00
|
|
|
require('./ember/feed-card');
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
require('./debug');
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
//require('./ext/rechat');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ext/betterttv');
|
|
|
|
require('./ext/emote_menu');
|
|
|
|
|
|
|
|
require('./featurefriday');
|
|
|
|
|
2015-11-19 02:45:56 -05:00
|
|
|
require('./ui/popups');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ui/styles');
|
2015-02-24 02:48:29 -05:00
|
|
|
require('./ui/dark');
|
2015-11-14 23:52:49 -05:00
|
|
|
require('./ui/tooltips');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ui/notifications');
|
|
|
|
require('./ui/viewer_count');
|
2015-06-05 03:59:28 -04:00
|
|
|
require('./ui/sub_count');
|
2016-03-23 19:28:22 -04:00
|
|
|
require('./ui/dash_stats');
|
2016-04-16 17:45:25 -04:00
|
|
|
require('./ui/dash_feed');
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
require('./ui/menu_button');
|
2015-07-04 17:06:36 -04:00
|
|
|
require('./ui/following');
|
2015-07-13 21:52:44 -04:00
|
|
|
require('./ui/following-count');
|
2015-02-08 02:01:09 -05:00
|
|
|
require('./ui/races');
|
2015-02-24 00:33:29 -05:00
|
|
|
require('./ui/my_emotes');
|
|
|
|
require('./ui/about_page');
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
require('./commands');
|
2015-10-24 22:44:00 -04:00
|
|
|
require('./ext/api');
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
|
|
|
|
// ---------------
|
|
|
|
// Initialization
|
|
|
|
// ---------------
|
|
|
|
|
|
|
|
FFZ.prototype.initialize = function(increment, delay) {
|
|
|
|
// Make sure that FrankerFaceZ doesn't start setting itself up until the
|
|
|
|
// Twitch ember application is ready.
|
|
|
|
|
2015-07-29 01:03:10 -04:00
|
|
|
// Check for the player
|
|
|
|
if ( location.hostname === 'player.twitch.tv' ) {
|
2015-10-17 18:05:44 -04:00
|
|
|
this.init_player(delay);
|
2015-07-29 01:03:10 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
|
|
|
|
// Check for the transfer page.
|
|
|
|
if ( location.pathname === "/crossdomain/transfer" ) {
|
|
|
|
if ( location.hash.indexOf("ffz-settings-transfer") !== -1 )
|
|
|
|
this.init_settings_transfer();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-17 19:02:57 -04:00
|
|
|
// Check for special non-ember pages.
|
2015-07-29 01:03:10 -04:00
|
|
|
if ( /^\/(?:$|search$|user\/|p\/|settings|m\/|messages?\/)/.test(location.pathname) ) {
|
|
|
|
this.init_normal(delay);
|
2015-05-17 19:02:57 -04:00
|
|
|
return;
|
|
|
|
}
|
2015-08-02 02:41:03 -04:00
|
|
|
|
2015-07-13 21:52:44 -04:00
|
|
|
if ( location.hostname === 'passport' && /^\/(?:authorize)/.test(location.pathname) ) {
|
|
|
|
this.log("Running on passport!");
|
2015-07-29 01:03:10 -04:00
|
|
|
this.init_normal(delay, true);
|
2015-07-13 21:52:44 -04:00
|
|
|
return;
|
|
|
|
}
|
2015-05-17 19:02:57 -04:00
|
|
|
|
|
|
|
// Check for the dashboard.
|
2015-06-10 18:46:04 -04:00
|
|
|
if ( /\/[^\/]+\/dashboard/.test(location.pathname) && !/bookmarks$/.test(location.pathname) ) {
|
2015-07-29 01:03:10 -04:00
|
|
|
this.init_dashboard(delay);
|
2015-05-17 19:02:57 -04:00
|
|
|
return;
|
|
|
|
}
|
2015-01-20 01:53:18 -05:00
|
|
|
|
2016-03-23 20:23:04 -04:00
|
|
|
var loaded = FFZ.utils.ember_resolve('model:room');
|
2015-01-20 01:53:18 -05:00
|
|
|
if ( !loaded ) {
|
|
|
|
increment = increment || 10;
|
|
|
|
if ( delay >= 60000 )
|
|
|
|
this.log("Twitch application not detected in \"" + location.toString() + "\". Aborting.");
|
|
|
|
else
|
|
|
|
setTimeout(this.initialize.bind(this, increment, (delay||0) + increment),
|
|
|
|
increment);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-29 01:03:10 -04:00
|
|
|
this.init_ember(delay);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
FFZ.prototype.init_settings_transfer = function() {
|
|
|
|
this.log("This is the HTTP Transfer URL. Building a settings backup and posting it to our parent.");
|
|
|
|
this.load_settings();
|
|
|
|
try { this.setup_line(); } catch(err) { }
|
|
|
|
var msg = {from_ffz: true, command: "http_settings", data: this._get_settings_object()};
|
|
|
|
window.opener.postMessage(msg, "https://www.twitch.tv");
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-29 01:03:10 -04:00
|
|
|
FFZ.prototype.init_player = function(delay) {
|
|
|
|
var start = (window.performance && performance.now) ? performance.now() : Date.now();
|
2016-03-23 19:28:22 -04:00
|
|
|
this.log("Found Twitch Player after " + (delay||0) + " ms at: " + location);
|
|
|
|
this.log("Initializing FrankerFaceZ version " + FFZ.version_info);
|
2015-07-29 01:03:10 -04:00
|
|
|
|
|
|
|
this.users = {};
|
|
|
|
this.is_dashboard = false;
|
|
|
|
try {
|
|
|
|
this.embed_in_dash = window.top !== window && /\/[^\/]+\/dashboard/.test(window.top.location.pathname) && !/bookmarks$/.test(window.top.location.pathname);
|
|
|
|
} catch(err) { this.embed_in_dash = false; }
|
|
|
|
|
|
|
|
// Literally only make it dark.
|
|
|
|
this.load_settings();
|
|
|
|
this.setup_dark();
|
2015-10-17 18:05:44 -04:00
|
|
|
this.setup_css();
|
|
|
|
this.setup_player();
|
2015-07-29 01:03:10 -04:00
|
|
|
|
|
|
|
var end = (window.performance && performance.now) ? performance.now() : Date.now(),
|
|
|
|
duration = end - start;
|
|
|
|
|
|
|
|
this.log("Initialization complete in " + duration + "ms");
|
2015-01-20 01:53:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-29 01:03:10 -04:00
|
|
|
FFZ.prototype.init_normal = function(delay, no_socket) {
|
2015-05-17 19:02:57 -04:00
|
|
|
var start = (window.performance && performance.now) ? performance.now() : Date.now();
|
2016-03-23 19:28:22 -04:00
|
|
|
this.log("Found non-Ember Twitch after " + (delay||0) + " ms at: " + location);
|
|
|
|
this.log("Initializing FrankerFaceZ version " + FFZ.version_info);
|
2015-05-17 19:02:57 -04:00
|
|
|
|
|
|
|
this.users = {};
|
2015-07-04 17:06:36 -04:00
|
|
|
this.is_dashboard = false;
|
|
|
|
try {
|
|
|
|
this.embed_in_dash = window.top !== window && /\/[^\/]+\/dashboard/.test(window.top.location.pathname) && !/bookmarks$/.test(window.top.location.pathname);
|
|
|
|
} catch(err) { this.embed_in_dash = false; }
|
2015-05-17 19:02:57 -04:00
|
|
|
|
|
|
|
// Initialize all the modules.
|
|
|
|
this.load_settings();
|
|
|
|
|
|
|
|
// Start this early, for quick loading.
|
|
|
|
this.setup_dark();
|
2015-11-11 02:06:02 -05:00
|
|
|
this.setup_css();
|
2015-11-19 02:45:56 -05:00
|
|
|
this.setup_popups();
|
2015-05-17 19:02:57 -04:00
|
|
|
|
2015-11-19 02:45:56 -05:00
|
|
|
if ( ! no_socket ) {
|
|
|
|
this.setup_time();
|
2015-07-13 21:52:44 -04:00
|
|
|
this.ws_create();
|
2015-11-19 02:45:56 -05:00
|
|
|
}
|
2015-07-13 21:52:44 -04:00
|
|
|
|
2015-07-18 21:10:27 -04:00
|
|
|
this.setup_colors();
|
2015-05-17 19:02:57 -04:00
|
|
|
this.setup_emoticons();
|
|
|
|
this.setup_badges();
|
|
|
|
|
|
|
|
this.setup_notifications();
|
2015-07-13 21:52:44 -04:00
|
|
|
this.setup_following_count(false);
|
2015-06-05 03:59:28 -04:00
|
|
|
this.setup_menu();
|
2015-05-17 19:02:57 -04:00
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
this.setup_message_event();
|
2015-11-14 23:52:49 -05:00
|
|
|
this.fix_tooltips();
|
2015-05-17 19:02:57 -04:00
|
|
|
this.find_bttv(10);
|
|
|
|
|
|
|
|
var end = (window.performance && performance.now) ? performance.now() : Date.now(),
|
|
|
|
duration = end - start;
|
|
|
|
|
|
|
|
this.log("Initialization complete in " + duration + "ms");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FFZ.prototype.is_dashboard = false;
|
|
|
|
|
2015-07-29 01:03:10 -04:00
|
|
|
FFZ.prototype.init_dashboard = function(delay) {
|
2015-05-17 19:02:57 -04:00
|
|
|
var start = (window.performance && performance.now) ? performance.now() : Date.now();
|
2016-03-23 19:28:22 -04:00
|
|
|
this.log("Found Twitch Dashboard after " + (delay||0) + " ms at: " + location);
|
|
|
|
this.log("Initializing FrankerFaceZ version " + FFZ.version_info);
|
|
|
|
|
|
|
|
var match = location.pathname.match(/\/([^\/]+)/);
|
|
|
|
this.dashboard_channel = match && match[1] || undefined;
|
2015-05-17 19:02:57 -04:00
|
|
|
|
|
|
|
this.users = {};
|
|
|
|
this.is_dashboard = true;
|
2015-07-04 17:06:36 -04:00
|
|
|
this.embed_in_dash = false;
|
2015-05-17 19:02:57 -04:00
|
|
|
|
|
|
|
// Initialize all the modules.
|
|
|
|
this.load_settings();
|
|
|
|
|
|
|
|
// Start this early, for quick loading.
|
|
|
|
this.setup_dark();
|
2015-11-11 02:06:02 -05:00
|
|
|
this.setup_css();
|
2015-11-19 02:45:56 -05:00
|
|
|
this.setup_popups();
|
2015-05-17 19:02:57 -04:00
|
|
|
|
2015-11-19 02:45:56 -05:00
|
|
|
this.setup_time();
|
2015-05-17 19:02:57 -04:00
|
|
|
this.ws_create();
|
2015-11-19 02:45:56 -05:00
|
|
|
|
2015-07-18 21:10:27 -04:00
|
|
|
this.setup_colors();
|
2015-05-17 19:02:57 -04:00
|
|
|
this.setup_emoticons();
|
|
|
|
this.setup_badges();
|
|
|
|
|
2015-07-18 21:10:27 -04:00
|
|
|
this.setup_tokenization();
|
2015-05-17 19:02:57 -04:00
|
|
|
this.setup_notifications();
|
2015-10-17 18:05:44 -04:00
|
|
|
this.setup_following_count(false);
|
|
|
|
this.setup_menu();
|
2016-03-23 19:28:22 -04:00
|
|
|
this.setup_dash_stats();
|
2016-04-16 17:45:25 -04:00
|
|
|
this.setup_dash_feed();
|
2015-05-17 19:02:57 -04:00
|
|
|
|
2015-06-05 03:59:28 -04:00
|
|
|
this._update_subscribers();
|
|
|
|
|
|
|
|
// Set up the FFZ message passer.
|
|
|
|
this.setup_message_event();
|
|
|
|
|
2015-11-14 23:52:49 -05:00
|
|
|
this.fix_tooltips();
|
2015-05-17 19:02:57 -04:00
|
|
|
this.find_bttv(10);
|
|
|
|
|
|
|
|
var end = (window.performance && performance.now) ? performance.now() : Date.now(),
|
|
|
|
duration = end - start;
|
|
|
|
|
|
|
|
this.log("Initialization complete in " + duration + "ms");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-29 01:03:10 -04:00
|
|
|
FFZ.prototype.init_ember = function(delay) {
|
2015-01-20 01:53:18 -05:00
|
|
|
var start = (window.performance && performance.now) ? performance.now() : Date.now();
|
2016-03-23 19:28:22 -04:00
|
|
|
this.log("Found Twitch application after " + (delay||0) + " ms at: " + location);
|
|
|
|
this.log("Initializing FrankerFaceZ version " + FFZ.version_info);
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
this.users = {};
|
2015-07-04 17:06:36 -04:00
|
|
|
this.is_dashboard = false;
|
2015-12-12 13:28:35 -05:00
|
|
|
|
2015-07-04 17:06:36 -04:00
|
|
|
try {
|
|
|
|
this.embed_in_dash = window.top !== window && /\/[^\/]+\/dashboard/.test(window.top.location.pathname) && !/bookmarks$/.test(window.top.location.pathname);
|
|
|
|
} catch(err) { this.embed_in_dash = false; }
|
2015-01-20 01:53:18 -05:00
|
|
|
|
2015-12-12 13:28:35 -05:00
|
|
|
|
|
|
|
// Make an alias so they STOP RENAMING THIS ON ME
|
2016-03-23 20:23:04 -04:00
|
|
|
var Settings = FFZ.utils.ember_lookup('controller:settings');
|
2015-12-12 13:28:35 -05:00
|
|
|
if ( Settings && Settings.get('settings') === undefined )
|
|
|
|
Settings.reopen({settings: Ember.computed.alias('model')});
|
|
|
|
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
// Initialize all the modules.
|
2015-02-08 02:01:09 -05:00
|
|
|
this.load_settings();
|
|
|
|
|
|
|
|
// Start this early, for quick loading.
|
2015-02-24 02:48:29 -05:00
|
|
|
this.setup_dark();
|
2015-11-11 02:06:02 -05:00
|
|
|
this.setup_css();
|
2015-11-19 02:45:56 -05:00
|
|
|
this.setup_popups();
|
2015-02-08 02:01:09 -05:00
|
|
|
|
2015-11-19 02:45:56 -05:00
|
|
|
this.setup_time();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.ws_create();
|
2015-11-19 02:45:56 -05:00
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
this.setup_emoticons();
|
|
|
|
this.setup_badges();
|
|
|
|
|
2015-10-24 22:44:00 -04:00
|
|
|
this.setup_router();
|
2015-07-18 21:10:27 -04:00
|
|
|
this.setup_colors();
|
|
|
|
this.setup_tokenization();
|
2015-10-17 18:05:44 -04:00
|
|
|
//this.setup_filtering();
|
|
|
|
|
|
|
|
this.setup_player();
|
2015-05-17 19:02:57 -04:00
|
|
|
this.setup_channel();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.setup_room();
|
2016-03-23 19:28:22 -04:00
|
|
|
this.setup_vod_chat();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.setup_line();
|
2015-07-31 17:44:20 -04:00
|
|
|
this.setup_layout();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.setup_chatview();
|
2015-11-10 21:37:30 -05:00
|
|
|
this.setup_conversations();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.setup_viewers();
|
2015-02-10 01:34:23 -05:00
|
|
|
this.setup_mod_card();
|
2015-07-06 00:09:21 -04:00
|
|
|
this.setup_chat_input();
|
2015-10-17 18:05:44 -04:00
|
|
|
this.setup_directory();
|
2015-11-10 21:37:30 -05:00
|
|
|
this.setup_profile_following();
|
2016-03-31 19:47:17 -04:00
|
|
|
this.setup_feed_cards();
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
//this.setup_teams();
|
|
|
|
|
2015-02-08 02:01:09 -05:00
|
|
|
this.setup_notifications();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.setup_menu();
|
2015-02-24 00:33:29 -05:00
|
|
|
this.setup_my_emotes();
|
2015-07-04 17:06:36 -04:00
|
|
|
this.setup_following();
|
2015-07-13 21:52:44 -04:00
|
|
|
this.setup_following_count(true);
|
2015-02-08 02:01:09 -05:00
|
|
|
this.setup_races();
|
2015-06-05 03:59:28 -04:00
|
|
|
|
2015-11-14 23:52:49 -05:00
|
|
|
this.fix_tooltips();
|
2015-06-05 03:59:28 -04:00
|
|
|
this.connect_extra_chat();
|
2015-01-20 01:53:18 -05:00
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
//this.setup_rechat();
|
|
|
|
this.setup_message_event();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.find_bttv(10);
|
|
|
|
this.find_emote_menu(10);
|
|
|
|
|
2015-08-21 19:00:48 -04:00
|
|
|
//this.check_news();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.check_ff();
|
2016-03-23 19:28:22 -04:00
|
|
|
this.refresh_chat();
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
var end = (window.performance && performance.now) ? performance.now() : Date.now(),
|
|
|
|
duration = end - start;
|
|
|
|
|
|
|
|
this.log("Initialization complete in " + duration + "ms");
|
2015-06-05 03:59:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------
|
|
|
|
// Dashboard Message Event
|
|
|
|
// ------------------------
|
|
|
|
|
|
|
|
FFZ.prototype.setup_message_event = function() {
|
|
|
|
this.log("Listening for Window Messages.");
|
|
|
|
window.addEventListener("message", this._on_window_message.bind(this), false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FFZ.prototype._on_window_message = function(e) {
|
2016-03-23 19:28:22 -04:00
|
|
|
var msg = e.data;
|
|
|
|
if ( typeof msg === "string" )
|
|
|
|
msg = JSON.parse(msg);
|
|
|
|
|
|
|
|
if ( ! msg || ! msg.from_ffz )
|
2015-06-05 03:59:28 -04:00
|
|
|
return;
|
|
|
|
|
2016-03-23 19:28:22 -04:00
|
|
|
var handler = FFZ.msg_commands[msg.command];
|
|
|
|
if ( handler )
|
|
|
|
handler.call(this, msg.data);
|
|
|
|
else
|
|
|
|
this.log("Invalid Message: " + msg.command, msg.data, false, true);
|
2015-01-12 17:58:07 -05:00
|
|
|
}
|