2015-01-20 01:53:18 -05:00
|
|
|
// Modify Array and others.
|
|
|
|
require('./shims');
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------
|
|
|
|
// The Constructor
|
|
|
|
// ----------------
|
|
|
|
|
|
|
|
var FFZ = window.FrankerFaceZ = function() {
|
|
|
|
FFZ.instance = this;
|
|
|
|
|
2015-02-10 01:34:23 -05:00
|
|
|
// Logging
|
|
|
|
this._log_data = [];
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
// Get things started.
|
|
|
|
this.initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FFZ.get = function() { return FFZ.instance; }
|
|
|
|
|
|
|
|
|
|
|
|
// Version
|
|
|
|
var VER = FFZ.version_info = {
|
2015-02-10 01:34:23 -05:00
|
|
|
major: 3, minor: 1, revision: 0,
|
2015-01-20 01:53:18 -05:00
|
|
|
toString: function() {
|
|
|
|
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Logging
|
|
|
|
|
|
|
|
FFZ.prototype.log = function(msg, data, to_json) {
|
|
|
|
msg = "FFZ: " + msg + (to_json ? " -- " + JSON.stringify(data) : "");
|
2015-02-10 01:34:23 -05:00
|
|
|
this._log_data.push(msg);
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
if ( data !== undefined && console.groupCollapsed && console.dir ) {
|
|
|
|
console.groupCollapsed(msg);
|
|
|
|
if ( navigator.userAgent.indexOf("Firefox/") !== -1 )
|
|
|
|
console.log(data);
|
|
|
|
else
|
|
|
|
console.dir(data);
|
|
|
|
|
|
|
|
console.groupEnd(msg);
|
|
|
|
} else
|
|
|
|
console.log(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-02-10 01:34:23 -05:00
|
|
|
FFZ.prototype.error = function(msg, data, to_json) {
|
|
|
|
msg = "FFZ Error: " + msg + (to_json ? " -- " + JSON.stringify(data) : "");
|
|
|
|
this._log_data.push(msg);
|
|
|
|
|
|
|
|
if ( data !== undefined && console.groupCollapsed && console.dir ) {
|
|
|
|
console.groupCollapsed(msg);
|
|
|
|
if ( navigator.userAgent.indexOf("Firefox/") !== -1 )
|
|
|
|
console.log(data);
|
|
|
|
else
|
|
|
|
console.dir(data);
|
|
|
|
|
|
|
|
console.groupEnd(msg);
|
|
|
|
} else
|
|
|
|
console.assert(false, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
callback.bind(this)(e.trim() + ".log");
|
|
|
|
}).fail(function(e) {
|
|
|
|
callback.bind(this)(null);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
// -------------------
|
|
|
|
// User Data
|
|
|
|
// -------------------
|
|
|
|
|
|
|
|
FFZ.prototype.get_user = function() {
|
|
|
|
if ( window.PP && PP.login ) {
|
|
|
|
return PP;
|
|
|
|
} else if ( window.App ) {
|
|
|
|
var nc = App.__container__.lookup("controller:navigation");
|
|
|
|
return nc ? nc.get("userData") : undefined;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------
|
|
|
|
// Import Everything!
|
|
|
|
// -------------------
|
|
|
|
|
2015-02-08 02:01:09 -05:00
|
|
|
//require('./templates');
|
|
|
|
|
|
|
|
require('./settings');
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./socket');
|
|
|
|
require('./emoticons');
|
|
|
|
require('./badges');
|
|
|
|
|
2015-02-10 01:34:23 -05:00
|
|
|
// Analytics: require('./ember/router');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ember/room');
|
|
|
|
require('./ember/line');
|
|
|
|
require('./ember/chatview');
|
|
|
|
require('./ember/viewers');
|
2015-02-10 01:34:23 -05:00
|
|
|
require('./ember/moderation-card');
|
2015-01-20 01:53:18 -05:00
|
|
|
//require('./ember/teams');
|
|
|
|
|
2015-02-10 01:34:23 -05:00
|
|
|
// Analytics: require('./tracking');
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
require('./debug');
|
|
|
|
|
|
|
|
require('./ext/betterttv');
|
|
|
|
require('./ext/emote_menu');
|
|
|
|
|
|
|
|
require('./featurefriday');
|
|
|
|
|
|
|
|
require('./ui/styles');
|
2015-02-08 02:01:09 -05:00
|
|
|
//require('./ui/dark');
|
2015-01-20 01:53:18 -05:00
|
|
|
require('./ui/notifications');
|
|
|
|
require('./ui/viewer_count');
|
|
|
|
|
|
|
|
require('./ui/menu_button');
|
|
|
|
require('./ui/menu');
|
2015-02-08 02:01:09 -05:00
|
|
|
require('./ui/races');
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
require('./commands');
|
|
|
|
|
|
|
|
|
|
|
|
// ---------------
|
|
|
|
// Initialization
|
|
|
|
// ---------------
|
|
|
|
|
|
|
|
FFZ.prototype.initialize = function(increment, delay) {
|
|
|
|
// Make sure that FrankerFaceZ doesn't start setting itself up until the
|
|
|
|
// Twitch ember application is ready.
|
|
|
|
|
|
|
|
// TODO: Special Dashboard check.
|
|
|
|
|
|
|
|
var loaded = window.App != undefined &&
|
|
|
|
App.__container__ != undefined &&
|
|
|
|
App.__container__.resolve('model:room') != undefined;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setup_ember(delay);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FFZ.prototype.setup_ember = function(delay) {
|
|
|
|
var start = (window.performance && performance.now) ? performance.now() : Date.now();
|
|
|
|
this.log("Found Twitch application after " + (delay||0) + " ms in \"" + location + "\". Initializing FrankerFaceZ version " + FFZ.version_info);
|
|
|
|
|
|
|
|
this.users = {};
|
|
|
|
|
|
|
|
// Initialize all the modules.
|
2015-02-08 02:01:09 -05:00
|
|
|
this.load_settings();
|
|
|
|
|
|
|
|
// Start this early, for quick loading.
|
|
|
|
//this.setup_dark();
|
|
|
|
|
2015-01-20 01:53:18 -05:00
|
|
|
this.ws_create();
|
|
|
|
this.setup_emoticons();
|
|
|
|
this.setup_badges();
|
|
|
|
|
2015-02-10 01:34:23 -05:00
|
|
|
//this.setup_piwik();
|
2015-01-20 01:53:18 -05:00
|
|
|
|
2015-02-10 01:34:23 -05:00
|
|
|
//this.setup_router();
|
2015-01-20 01:53:18 -05:00
|
|
|
this.setup_room();
|
|
|
|
this.setup_line();
|
|
|
|
this.setup_chatview();
|
|
|
|
this.setup_viewers();
|
2015-02-10 01:34:23 -05:00
|
|
|
this.setup_mod_card();
|
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_css();
|
|
|
|
this.setup_menu();
|
2015-02-08 02:01:09 -05:00
|
|
|
this.setup_races();
|
2015-01-20 01:53:18 -05:00
|
|
|
|
|
|
|
this.find_bttv(10);
|
|
|
|
this.find_emote_menu(10);
|
|
|
|
|
|
|
|
this.check_ff();
|
|
|
|
|
|
|
|
var end = (window.performance && performance.now) ? performance.now() : Date.now(),
|
|
|
|
duration = end - start;
|
|
|
|
|
|
|
|
this.log("Initialization complete in " + duration + "ms");
|
2015-01-12 17:58:07 -05:00
|
|
|
}
|