Apps Home
|
Create an App
Room Manager
Author:
pornlesque1
Description
Source Code
Launch App
Current Users
Created by:
Pornlesque1
/* Name: Pornlesque Room Manager Author: Pornlesque Version: 0.1 Created: 2020.02.25 Last Modified: 2020.02.25 For support enquiries, or for custom work, contact pornlesque@gmail.com The moral right of "Pornlesque" to be identified as the author of this work has been asserted. The above line was "borrowed" from mx2k6. Version History ====================================================================== 0.1 The beginning. Basic functionality */ /* variable declarations */ // ======================== /* class definitions */ // ===================== class Application { constructor() { this.name = "Pornlesque Room Manager"; this.modules = []; } addModule(module) { this.modules.push(module); } } class Module { constructor(mName) { this.name = mName; } } class Tip { constructor(tGroup, tName, amt) { this.index; this.group = tGroup; this._name = tName; this.amount = amt; this.message = "Thank you"; } get name() { if (this.group.length) { return this.group + " " + this._name; } else { return this._name; } } matchAmount(value) { return (value == amount); } } class CustomerTip { constructor (cbTip) { this.amount = parseInt(cbTip['amount']); this.message = cbTip[message]; this.toUser = cbTip[to_user]; this.fromUser = cbTip[from_user]; this.userInFanclub = cbTip[from_user_in_fanclub]; this.userHasTokens = cbTip[from_user_has_tokens]; this.userIsMod = cbTip[from_user_is_mod]; this.userTipLevel1 = cbTip[from_user_tipped_recently]; this.userTipLevel2 = cbTip[from_user_tipped_alot_recently]; this.userTipLevel3 = cbTip[from_user_tipped_tons_recently]; this.userGender = cbTip[from_user_gender]; } } class TipMenu { constructor() { this.tipList = []; } addTipItem(tip) { this.tipList.push(tip); tip.index = this.tipList.count; } getTipItemFromAmount(amt) { var rtn = this.tipList.find(item => { item.matchAmount(amt); }); if (typeof(rtn) != undefined) { return (rtn); } else { return false; } } sortMenu() { let sortedMenu = this.tipList.sort(function(a, b) { let i = 0; let result = 0; // let sortTipsBy = [ // { // prop: 'name', // direction: 1 // }, { // prop: 'amount', // direction: 1 // } // ]; // while(i < sortTipsBy.length && result === 0) { // result = sortTipsBy[i].direction * (a[ sortTipsBy[i].prop ].toString() < b[ sortTipsBy[i].prop ].toString() ? -1 : (a[ sortTipsBy[i].prop ].toString() > b[ sortTipsBy[i].prop ].toString() ? 1 : 0)); // i++; // } result = a.name - b.name return result; }) this.tipList = sortedMenu; } displayMenu(msg) { // this.sortMenu(); for (var i = 0; i < this.tipList.length; i++) { cb.sendNotice(this.tipList[i].name + ": " + this.tipList[i].amount, msg['user']); } } } class User { constructor(uName) { this.userName = uName; this.tips = []; } } /* setup */ // ======== var tipMenu = new TipMenu(); tipMenu.addTipItem(new Tip("Lush","Level 1", 1)); tipMenu.addTipItem(new Tip("Lush","Level 2", 5)); tipMenu.addTipItem(new Tip("Lush","Level 3", 20)); tipMenu.addTipItem(new Tip("Lush","Level 4", 100)); tipMenu.addTipItem(new Tip("Lush","Level 5", 500)); tipMenu.addTipItem(new Tip("","If you like us", 25)); /* chat commands */ // ================ cb.onMessage(function(msg) { if (msg['m'] == '/menu') { cb.sendNotice('-----' + cb.room_slug + 's Tip Menu -----', msg['user']); tipMenu.displayMenu(msg); //cb.sendNotice(tipMenu.tipList) } });
© Copyright Chaturbate 2011- 2025. All Rights Reserved.