Apps Home
|
Create an App
Ktest
Author:
kayleighhhtest
Description
Source Code
Launch App
Current Users
Created by:
Kayleighhhtest
/************************************************************************ * Title: "Font & Color Changer" * * Author: K. de Haan * * Version: 3.0-alpha1 (31 Jul 2015) ************************************************************************/ "use strict"; var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var App = function App(name, mini_name, type, version) { _classCallCheck(this, App); this.name = name; // script name this.mini_name = mini_name; // script abbreviated name this.type = type; // script type: bot or app this.version = version; // internal: script version number this.version_extra = "alpha1"; // internal: script version - extra info (e.g. alpha1, beta1, rc1, dev/techpreview, experimental). set to null if stable this.version_type = "alpha"; // internal: script version type (stable, alpha, beta, release candidate, dev preview, or experimental) this.revision = null; // internal: script revision (null if none). Don't use with staging versions this.rc_version = null; // internal: script RC version number. Use only with release candidates this.build_date = "July 31, 2015"; // internal: script build date this.author = "dehaan__"; // developer }; var FontColorChanger = (function (_App) { _inherits(FontColorChanger, _App); function FontColorChanger() { _classCallCheck(this, FontColorChanger); _get(Object.getPrototypeOf(FontColorChanger.prototype), "constructor", this).call(this, "\"Font & Color Changer\"", "FCC", "bot", "3.0"); this.color = { info: "#144d8c", // blue gray; used for neutral notices notice: "#6900cc", // purple; used for chat notices mred: "#dc0000", // moderator red red: "#ff0000", // red; used for important notices syntax: "#995b00", // syntax color; brown-ish error: "#b94a48" // dark-ish red; used for errors }; this.command = { fontlist: "/fontlist", colorlist: "/colorlist", font: "/font", color: "/color" }; this.devcommand = { dump: "/dump" }; this.flag = { dev: false }; this.list = { availableFonts: ["default", "Arial, Helvetica", "Bookman Old Style", "\"Comic Sans MS\", cursive", "\"Courier New\"", "Lucida", "Palantino", "Tahoma, Geneva", "\"Times New Roman\""], changeableFonts: { "arial": "Arial, Helvetica", "bookman": "Bookman Old Style", "comic": "\"Comic Sans MS\", cursive", "courier": "\"Courier New\"", "lucida": "Lucida", "palantino": "Palantino", "tahoma": "Tahoma, Geneva", // Chaturbate default "times": "\"Times New Roman\"" }, colors: [], dev: [], fonts: [], presetColors: { "red": "#ff0000", "green": "#00aa00", "blue": "#0000ff", "pink": "#ff00ff", "yellow": "#aa0000", "cyan": "#008888", "purple": "#990099", "bluegray": "#263238", "modred": "#dc0000", "black": "#000000", "gray": "#494949", "armygreen": "#4b5320", "bloodred": "#8a0707", "navyblue": "#008080" } }; this.misc = { broadcaster: cb.room_slug, dashLine: new Array(36).join("\u2014"), start_time: new Date(), gamma: 0.1, minLevel: 0.5 }; } _createClass(FontColorChanger, [{ key: "printRegularNotice", value: function printRegularNotice(notice) { cb.sendNotice(notice, "", "", color.notice, "bold"); } }, { key: "printNoticeBc", value: function printNoticeBc(notice) { cb.sendNotice(notice, cb.room_slug, "", color.info, "bold"); } }, { key: "main", value: function main() { this.callCbHandlers = (function () { cb.onEnter(function (user) { SysCore.onEnter(user); }); cb.onMessage(function (msg) { SysCore.onMessage(msg); }); })(); this.printNoticeBc(this.misc.dashLine + "\n* " + this.name + " by K. de Haan"); if (this.revision != null) { this.printNoticeBc("* Version: " + this.version + " (" + this.revision + ")"); } else if (this.version_type == "release_candidate") { this.printNoticeBc("* Version: " + this.version + "-" + this.version_extra + " (" + this.rc_version + ")"); } else if (this.version_type == "alpha" || this.version_type == "beta" || this.version_type == "experimental" || this.version_type == "devpreview") { this.printNoticeBc("* Version: " + this.version + "-" + this.version_extra); } else { this.printNoticeBc("\* Version: " + this.version); } this.printNoticeBc("* SystemCore version: " + SysCore.version); this.printNoticeBc("* Build date: " + this.build_date); // the lines below vary by script this.printNoticeBc("\* Type /colorlist to see all color options or /fontlist to see all font options."); this.printNoticeBc("* Type /color and /font to change. Or type \"/color code\" (followed by valid HTML color code) to set a custom color.\n" + this.misc.dashLine); if (this.revision != null) { cb.sendNotice(this.name + " version " + this.version + " (" + this.revision + ") (" + this.build_date + ") has started.", "", "", this.color.info, "bold"); } else if (this.version_type == "release_candidate") { cb.sendNotice(this.name + " version " + this.version + "-" + this.version_extra + " (" + this.rc_version + ") (" + this.build_date + ") has started.", "", "", this.color.info, "bold"); } else if (this.version_type == "alpha" || this.version_type == "beta" || this.version_type == "experimental" || this.version_type == "devpreview") { cb.sendNotice(this.name + " version " + this.version + "-" + this.version_extra + " (" + this.build_date + ") has started.", "", "", this.color.info, "bold"); } else { cb.sendNotice(this.name + " version " + this.version + " (" + this.build_date + ") has started.", "", "", this.color.info, "bold"); } } }, { key: "dump", value: function dump(user) { var date = new Date(); var dump_info = this.misc.dashLine + "\n* Dev dump"; dump_info += "\n\n* App info:"; dump_info += "\n* Name: " + this.name + " / Type: " + this.type + " / Version number: " + this.version + " / Version type: " + this.version_type; dump_info += "\n* Time started: " + this.misc.start_time + "\n* Time now: " + date; dump_info += "\n* Flags: (FCC.flag.dev: " + this.flag.dev + ")" + "\n" + this.misc.dashLine; return cb.sendNotice(dump_info, user, "", this.color.info, "bold"); } }, { key: "getUserColor", value: function getUserColor(user) { if (typeof this.list.colors[user] == "undefined") { this.setUserColor(user); } return this.list.colors[user]; } }, { key: "getUserFont", value: function getUserFont(user) { if (typeof this.list.fonts[user] == "undefined") { this.setUserFont(user); } return this.list.fonts[user]; } }, { key: "htmlColor", value: function htmlColor(r, g, b) { return "#" + this.toHex(r) + this.toHex(g) + this.toHex(b); } }, { key: "hueStrength", value: function hueStrength(hue) { return Math.pow(0.5 * (1 + Math.cos(2 * Math.PI * hue / 120.)), this.misc.gamma); } }, { key: "pickColor", value: function pickColor() { var t = Math.random() * 360; var ti = Math.floor(t / 60); var v = 255 * (this.misc.minLevel + (1.0 - this.misc.minLevel) * Math.random() * this.hueStrength(t)); var f = t / 60 - ti; var m = Math.floor(v * (1 - f)); var n = Math.floor(v * f); v = Math.floor(v); var r = 0; var g = 0; var b = 0; if (ti == 0) { r = v; g = n; b = 0; } else if (ti == 1) { r = m; g = v; b = 0; } else if (ti == 2) { r = 0; g = v; b = n; } else if (ti == 3) { r = 0; g = m; b = v; } else if (ti == 4) { r = n; g = 0; b = v; } else if (ti == 5) { r = v; g = 0; b = m; }return this.htmlColor(r, g, b); } }, { key: "pickFont", value: function pickFont() { var i = Math.floor(Math.random() * this.list.availableFonts.length); return this.list.availableFonts[i]; } }, { key: "setUserColor", value: function setUserColor(user) { this.list.colors[user] = this.pickColor(); } }, { key: "setUserFont", value: function setUserFont(user) { this.list.fonts[user] = this.pickFont(); } }, { key: "showColorList", value: function showColorList(user) { var clrlist = "------- Font & Color Changer - Color Codes List -------"; clrlist += "\n* Switch between colors by using /color followed by one of these options (without quotes)."; clrlist += "\n* Or use \"/color code\" followed by a valid HTML color code (format #RRGGBB or #RGB)."; clrlist += "\n* Random color - \"random\""; clrlist += "\n* Red - \"red\""; clrlist += "\n* Green - \"green\""; clrlist += "\n* Blue - \"blue\""; clrlist += "\n* Pink - \"pink\""; clrlist += "\n* Yellow - \"yellow\""; clrlist += "\n* Cyan - \"cyan\""; clrlist += "\n* Purple - \"purple\""; clrlist += "\n* Blue Gray - \"bluegray\""; clrlist += "\n* Moderator Red - \"modred\""; clrlist += "\n* Black - \"black\""; clrlist += "\n* Gray (Chaturbate default) - \"gray\""; clrlist += "\n* Army Green - \"armygreen\""; clrlist += "\n* Blood Red - \"bloodred\""; clrlist += "\n* Navy Blue - \"navyblue\"\n" + this.misc.dashLine; return cb.sendNotice(clrlist, user, "", this.color.info, "bold"); } }, { key: "showFontList", value: function showFontList(user) { var fntlist = "------- Font & Color Changer - Font Codes List -------\n"; fntlist += "\n* Switch between fonts by using /font followed by one of these options (without quotes)."; fntlist += "\n* Random font - \"random\""; fntlist += "\n* Arial - \"arial\""; fntlist += "\n* Bookman Old Style - \"bookman\""; fntlist += "\n* Comic Sans MS - \"comic\""; fntlist += "\n* Courier New - \"courier\""; fntlist += "\n* Lucida - \"lucida\""; fntlist += "\n* Palantino - \"palantino\""; fntlist += "\n* Tahoma (Chaturbate default) - \"tahoma\""; fntlist += "\n* Times New Roman - \"times\"\n" + this.misc.dashLine; return cb.sendNotice(fntlist, user, "", this.color.info, "bold"); } }, { key: "showWelcomeMessage", value: function showWelcomeMessage(user) { if (user != null) { var welcome_message = this.misc.dashLine + "\n* Welcome, \"" + user + "\"! " + this.name + " is running." + "\n* You've been assigned a random color and font for chat, but both are changeable via commands." + "\n* Type /colorlist to see all available colors or /fontlist to see all available fonts." + "\n* Type /color and /font to change them. Type \"/color code\" (followed by a valid HTML color code) to set a custom color.\n" + this.misc.dashLine; return cb.sendNotice(welcome_message, user, "", this.color.notice, "bold"); } else return cb.sendNotice(this.name + " - by " + this.author, user, "", this.color.notice, "bold"); } }, { key: "toHex", value: function toHex(value) { var str = value.toString(16); if (str.length == 1) { str = "0" + str; } return str; } }]); return FontColorChanger; })(App); /* ----------------------------------------------------------------------- var total_tipped = 0; cb.onTip(function (tip)) { var viewer = tip['from_user']; var tipMsg = tip['message']; total_tipped += parseInt(tip['amount']) cb.chatNotice("Total Tipped: " + total_tipped); cb.chatNotice(tip); if (tipMsg in FCC.list.presetColors) { FCC.list.colors[msg.viewer] = FCC.list.presetColors[tipMsg]; msg["c"] = FCC.getUserColor(viewer); } else { cb.sendNotice("* \"" + [tipMsg] + "\" is not a valid argument." + "\n* Type /colorlist for all valid options.", viewer, "", color.error, "bold"); } }); ---------------------------------------------------------------------*/ var FCC = new FontColorChanger(); var color = FCC.color; var command = FCC.command; var devcommand = FCC.devcommand; var SystemCore = (function () { function SystemCore() { _classCallCheck(this, SystemCore); this.name = "FCC System Core"; this.version = "0.91.0001a-DevPreview-FCC"; this.parent = FCC; } _createClass(SystemCore, [{ key: "onEnter", value: function onEnter(viewer) { var user = viewer.user; FCC.showWelcomeMessage(user); } }, { key: "onMessage", value: function onMessage(msg) { var user = msg.user; var m = msg.m.split(" "); var colorCode_RegExp = /[A-F0-9]+$/i; if ((user in FCC.list.colors || (msg["c"] = "#494949")) && (user in FCC.list.fonts || (msg["f"] = "default"))) { msg["c"] = FCC.getUserColor(user); msg["f"] = FCC.getUserFont(user); } if (m[0].charAt(0) == "/") { msg["X-Spam"] = true; switch (m[0]) { case command.fontlist: FCC.showFontList(user); break; case command.colorlist: FCC.showColorList(user); break; case command.font: if (m[1] != null) { if (m[1] == "random") { FCC.setUserFont(user); msg["f"] = FCC.getUserFont(user); } else if (m[1] in FCC.list.changeableFonts) { FCC.list.fonts[msg.user] = FCC.list.changeableFonts[m[1]]; msg["f"] = FCC.getUserFont(user); } else { cb.sendNotice("* \"" + m[1] + "\" is not a valid argument." + "\n* Type /fontlist for all valid options.", user, "", color.error, "bold"); } } else { cb.sendNotice("* Syntax: /font <option>", user, "", color.syntax, "bold"); } break; case command.color: if (m[1] != null) { if (m[1] == "random") { FCC.setUserColor(user); msg["c"] = FCC.getUserColor(user); } else if (m[1] == "code") { if (m[2] != null) { if (m[2].charAt(0) == "#" && (m[2].length == 4 || m[2].length == 7)) { if (colorCode_RegExp.exec(m[2])) { FCC.list.colors[msg.user] = m[2]; msg["c"] = FCC.getUserColor(user); } else { cb.sendNotice("* \"" + m[2] + "\" is not a valid HTML color code.", user, "", color.error, "bold"); } } else { cb.sendNotice("* \"" + m[2] + "\" is not a valid HTML color code.", user, "", color.error, "bold"); } } else { cb.sendNotice("* Syntax: /color code <HTML color code>.", user, "", color.syntax, "bold"); } } else if (m[1] in FCC.list.presetColors) { FCC.list.colors[msg.user] = FCC.list.presetColors[m[1]]; msg["c"] = FCC.getUserColor(user); } else { cb.sendNotice("* \"" + m[1] + "\" is not a valid argument." + "\n* Type /colorlist for all valid options.", user, "", color.error, "bold"); } } else { cb.sendNotice("* Syntax: /color <option>.\n* You can also use an HTML color code\n* by typing \"/color code <HTML code>\".", user, "", color.syntax, "bold"); } break; case devcommand.dump: if (user == FCC.author) { if (m[1] == "dev") { if (!cbjs.arrayContains(FCC.list.dev, user)) { FCC.list.dev.push(user); FCC.flag.dev = true; } else { cbjs.arrayRemove(FCC.list.dev, user); FCC.flag.dev = false; } } else { FCC.dump(user); } } else { cb.sendNotice("* This command is restricted to the developer.", user, "", color.error, "bold"); } break; } } return msg; } }]); return SystemCore; })(); var SysCore = new SystemCore(); FCC.main();
© Copyright Chaturbate 2011- 2025. All Rights Reserved.