Apps Home
|
My Uploads
|
Create an App
Malejaapp
Author:
maleja69
Description
Source Code
Launch App
Current Users
Created by:
Maleja69
App Images
// vars var times_goal_reached = 0; var last_time_goal_reached = null; var current_goal_tipped = 0; var set_tokens_command = '!settok'; var set_reached_command = '!setreached'; //variables para panel var row3Time = "Not yet" var panelConfig = cb.settings.panelConfig; var imageConfig = cb.settings.imageConfig; var imageSelec = cb.settings.imageSelec; var imageConfigTrue = cb.settings.imageConfigTrue; var row1_LabelText =cb.settings.row1_LabelText; var row1_LabelColor = cb.settings.row1_LabelColor; var row1_Color = cb.settings.row1_Color; var row1_Background = cb.settings.row1_Background; var row2_LabelText = cb.settings.row2_LabelText; var row2_LabelColor = cb.settings.row2_LabelColor; var row2_Color = cb.settings.row2_Color; var row2_Background = cb.settings.row2_Background; var row3_LabelText = cb.settings.row3_LabelText; var row3_LabelColor = cb.settings.row3_LabelColor; var row3_Color = cb.settings.row3_Color; var row3_Background = cb.settings.row3_Background; cb.settings_choices = [ {name: 'tokens', type: 'int', minValue: 1, default: 100}, {name: 'goal_description', type: 'str', minLength: 1, maxLength: 255}, //Preguntas para personalizar el panel { name: "panelConfig", label:"Panel configuration", type: "choice", choice1:"classic", choice2:"table", choice3:"image", defaultValue:"image" },{ name: "imageSelec", label:"Select an image ID. You can see all the images in the top of Code Source section", type: "choice", choice1:"Image ID written in next section", choice2:"b4142a14-7c03-4f3d-ae2f-2d3222e41943", choice3:"16deb268-3ea7-43c2-bcf7-36875382dd29 ", choice4:"2332444f-c508-441f-958f-40fc81748f6a", choice5:"275986b7-37c9-4394-aa47-ea56bc1f24ff", choice6:"3822cb6e-f1c8-46bc-ac3f-ab3a8c08fdd8", choice7:"5b79bd9a-c9ad-44fc-b39e-330759cc9ec8", choice8:"a052feb5-5ed9-42d5-bd56-7f1d8b868202", choice9:"ab8797fa-3fcc-4dc9-a9d8-c6f0b910ef1b", choice10:"d082a093-0a74-4374-ba53-5a003e8847e2", choice11:"45f4643c-471a-4f66-93ed-a822f1a6232c", choice12:"519a4e23-df98-4939-b933-b35a801862ac", choice13:"9c176b2f-ae03-450d-b15a-01babaf4aa08", defaultValue:"Image ID written in next section", },{ name: "imageConfig", label:"Image Panel configuration, select: Image ID written... first, (useful if you copy these app to upload your own image)", type: 'str', minLength: 1, maxLength: 50, defaultValue:"631a0a96-7ffe-4b5e-af56-61510a1a25f8", required: true },{ name: "row1_LabelText", label:"Row1 Label Text, default:Tip Received / Goal", type: 'str', minLength: 1, maxLength: 26, defaultValue:"Received / Goal (Total):", required: true },{ name: "row1_LabelColor", label:"Color Row1 Label, only for Table or Image Panel", type: 'str', minLength: 1, maxLength: 50, defaultValue:"black", required: true },{ name: "row1_Color", label:"Row1 Text Color, only for Table or Image Panel", type: 'str', minLength: 1, maxLength: 50, defaultValue:"black", required: true },{ name: "row1_Background", label:"Row1 Background Color, only for Table", type: 'str', minLength: 1, maxLength: 50, defaultValue:"#ADD8E6", required: true },{ name: "row2_LabelText", label:"Row2 Label Text, default: Highest Tip: ", type: 'str', minLength: 1, maxLength: 26, defaultValue:'Hit Goal For:', required: true },{ name: "row2_LabelColor", label:"Row2 Label Color, only for Table or Image Panel", type: 'str', minLength: 1, maxLength: 50, defaultValue:"black", required: true },{ name: "row2_Color", label:"Row2 Tex Color, only for Table or Image Panel", type: 'str', minLength: 1, maxLength: 50, defaultValue:"black", required: true },{ name: "row2_Background", label:"Row2 Background Color, only for Table", type: 'str', minLength: 1, maxLength: 50, defaultValue:"pink", required: true },{ name: "row3_LabelText", label:"Row3 Label Text, default: Latest Tip Received: ", type: 'str', minLength: 1, maxLength: 26, defaultValue:'Last Reached:', required: true },{ name: "row3_LabelColor", label:"Row3 Label Color, only for Table or Image Panel", type: 'str', minLength: 1, maxLength: 50, defaultValue:"black", required: true },{ name: "row3_Color", label:"Row3 Color, only for Table or Image Panel", type: 'str', minLength: 1, maxLength: 50, defaultValue:"black", required: true },{ name: "row3_Background", label:"Row3 Background Color, only for Table", type: 'str', minLength: 1, maxLength: 50, defaultValue:"#ADD8E6", required: true }, ]; if(imageSelec != "Image ID written in next section"){ imageConfigTrue = imageSelec } else { imageConfigTrue = imageConfig }; if (times_goal_reached != 0){ row3Time = Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' minutes ago'; }; // handlers cb.onTip(function(tip) { current_goal_tipped += tip['amount'] if (current_goal_tipped >= cb.settings.tokens) { goalReached(tip['from_user']); } update_subject(); cb.drawPanel(); }); cb.onDrawPanel(function(user) { if (times_goal_reached != 0){ row3Time = Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' minutes ago'; }; if (cb.settings.panelConfig == "image"){ return { "template": "image_template", "layers": [ {'type': 'image', 'fileID': imageConfigTrue}, { 'type': 'text', 'text': row1_LabelText, 'top': 5, 'left': 10, 'font-size': 11, //'text-align': 'center', 'font-weight': 'bold', 'color': row1_LabelColor, }, { 'type': 'text', 'text': row2_LabelText, 'top': 29, 'left': 10, 'font-size': 11, //'text-align': 'center', 'font-weight': 'bold', 'color': row2_LabelColor, }, { 'type': 'text', 'text': row3_LabelText, 'top': 52, 'left': 10, 'font-size': 11, //'text-align': 'center', 'font-weight': 'bold', 'color': row3_LabelColor, },{ 'type': 'text', 'text': ' ' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'top': 5, 'left': 147, 'font-size': 11, //'text-align': 'center', 'font-weight': 'bold', 'color': row1_Color, }, { 'type': 'text', 'text': ' ' + times_goal_reached + ' times', 'top': 29, 'left': 147, 'font-size': 11, //'text-align': 'center', 'font-weight': 'bold', 'color': row2_Color, }, { 'type': 'text', 'text': row3Time, 'top': 52, 'left': 147, 'font-size': 11, //'text-align': 'center', 'font-weight': 'bold', 'color': row3_Color, }, ], }; } if (cb.settings.panelConfig == "table"){ return { "template": "image_template", "table": { "row_1": { "background-color": row1_Background, "col_1": { "color": row1_LabelColor, "text-align": "center", "font-weight": "bold", "value": row1_LabelText }, "col_2": { "color": row1_Color, "text-align": "center", "value": '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', }, }, "row_2": { "background-color": row2_Background, "col_1": { "color": row2_LabelColor, "text-align": "center", "font-weight": "bold", "value": row2_LabelText }, "col_2": { "color": row2_Color, "text-align": "center", "value": '' + times_goal_reached + ' times' } }, "row_3": { "background-color": row3_Background, "col_1": { "color": row3_LabelColor, "text-align": "center", "font-weight": "bold", "value": row3_LabelText }, "col_2": { "color": row3_Color, "text-align": "center", "value": row3Time, } } } }; } else { if (times_goal_reached == 0) { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': 'Never' }; } else { return { 'template': '3_rows_of_labels', 'row1_label': 'Received / Goal (Total):', 'row1_value': '' + current_goal_tipped + ' / ' + cb.settings.tokens + ' (' + ((times_goal_reached * cb.settings.tokens) + current_goal_tipped) + ')', 'row2_label': 'Hit Goal For:', 'row2_value': '' + times_goal_reached + ' times', 'row3_label': 'Last Reached:', 'row3_value': '' + Math.floor(((new Date()).getTime() - last_time_goal_reached.getTime()) / 60000) + ' minutes ago' }; } } }); cb.drawPanel(); cb.onMessage(function (msg) { if (msg['m'][0] == '!') { if (msg['user'] == cb.room_slug) { if (startsWith(msg['m'], set_tokens_command)) { msg['X-Spam'] = true; var number = msg['m'].slice(set_tokens_command.length); times_goal_reached = Math.floor(number / cb.settings.tokens); current_goal_tipped = number % cb.settings.tokens; last_time_goal_reached = new Date(); cb.drawPanel(); cb.chatNotice('The tokens received has been updated!', msg['user']); } else if (startsWith(msg['m'], set_reached_command)) { msg['X-Spam'] = true; var number = msg['m'].slice(set_reached_command.length); times_goal_reached = number; last_time_goal_reached = new Date(); current_goal_tipped = 0; cb.drawPanel(); cb.chatNotice('The number of times reached has been updated!', msg['user']); } } } }); // Functions function refresh() { cb.log("Refresh called"); cb.setTimeout(refresh, 20000); cb.drawPanel(); } function update_subject() { var new_subject = cb.settings.goal_description + " [" + tips_remaining() + " tokens remaining]"; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } function goalReached(userName) { last_time_goal_reached = new Date(); var curr_times_reached = Math.floor(current_goal_tipped / cb.settings.tokens); for (var i = 0; i < curr_times_reached; i++) { times_goal_reached++; current_goal_tipped -= cb.settings.tokens; cb.chatNotice("Goal was reached for the " + getNumberString(times_goal_reached) + " time!"); cb.chatNotice('The user ' + userName + ' has reached the goal.', cb.room_slug, "#FEF9CD", "#1A1AD7", "bold"); } } function getNumberString(number) { var numberString = null; var lastChar = String(number).charAt(String(number).length - 1); if ((lastChar == '1') && ((number % 100) != 11)) { numberString = number + "st"; } else if ((lastChar == '2') && ((number % 100) != 12)) { numberString = number + "nd"; } else if ((lastChar == '3') && ((number % 100) != 13)) { numberString = number + "rd"; } else { numberString = "" + number + "th"; } return (numberString); } function tips_remaining() { var r = cb.settings.tokens - current_goal_tipped; if (r < 0) { return 0; } else { return r; } } function startsWith(source, str) { return source.substring(0, str.length) === str; } function init() { update_subject(); } init(); cb.setTimeout(refresh, 20000);
© Copyright Freesexcam 2011- 2024. All Rights Reserved.