Apps Home
|
Create an App
Who's the favourite?
Author:
happychatter92
Description
Source Code
Launch App
Current Users
Created by:
Happychatter92
var total_tipped = 0; var new_tipped = 0; var old_tipped = 0; var team1 = 0; var team2 = 0; var tippers_team1 = []; var tippers_team2 = []; var new_team1 = 0; var old_team1 = 0; var new_team2 = 0; var old_team2 = 0; var red = '#FFCCCC', red1 = '#FF0000'; var green= '#D2FACD', green1 = '#00B050'; var blue = '#C4DAFC', blue1 = '#0000FF'; var pink= '#F6C6E6', pink1 = '#FF00FF'; var teal= '#C4F0F4', teal1 = '#008080'; var purple = '#E1C4F4', purple1 = '#800080'; var olive = '#D4D407', olive1 = '#808000'; var gray = '#d6cdc8', gray1 = '#808080'; //Settings cb.settings_choices = [ { name: 'goal', type: 'int', minValue: 1, default: 1000, label: "Goal Team:" },{ name: 'subject', type: 'str', minLength: 1, maxLength: 140, label: "Invite to play" },{ name: 'color1', type: 'choice', choice1: 'Red', choice2: 'Green', choice3: 'Blue', choice4: 'Pink', choice5: 'Teal', choice6: 'Purple', choice7: 'Olive', choice8: 'Gray', label: "Choose the color of the number ONE team" }, { name: 'color2', type: 'choice', choice1: 'Red', choice2: 'Green', choice3: 'Blue', choice4: 'Pink', choice5: 'Teal', choice6: 'Purple', choice7: 'Olive', choice8: 'Gray', label: "Choose the color of the number TWO team" } ]; cb.onTip(function (tip) { total_tipped += parseInt(tip['amount']) team1+= tipMultiplo5(tip['amount']); new_team1 = team1; if(new_team1!=old_team1){ addTippers1(tip['from_user']); old_team1 = new_team1; } team2+= tipMultiplo10(tip['amount']); new_team2 = team2; if(new_team2!=old_team2){ addTippers2(tip['from_user']); old_team2 = new_team2; } //update_subject(); cb.drawPanel(); subjectwinner(); notifier(); notifier1(); }); cb.onDrawPanel(function(user) { if(team1 < cb.settings.goal && team2 < cb.settings.goal){ return { 'template': '3_rows_12_21_31', 'row1_label': 'Goal Team: ', 'row1_value': cb.settings.goal, 'row2_value': cb.settings.color1+' Team '+'('+team1+')'+' | '+cb.settings.color2+' Team '+'('+team2+')', 'row3_value':'Remaing: '+'('+team1_remaing()+') '+' | '+'Remaing: '+'('+team2_remaing()+') ' }; } else if(team1>=cb.settings.goal){ return { 'template': '3_rows_12_21_31', 'row1_label': 'Goal Team', 'row1_value': 'Reached', 'row2_value': 'The '+cb.settings.color1+' Team is Winner', 'row3_value': 'Congratulations Guys' }; } else if(team2>=cb.settings.goal){ return { 'template': '3_rows_12_21_31', 'row1_label': 'Goal Team', 'row1_value': 'Reached', 'row2_value': 'The '+cb.settings.color1+' Team is Winner', 'row3_value': 'Congratulations Guys' }; } }); cb.onMessage(function (msg) { if(findTippers1(msg['user'])){ msg['background'] = colorMessage1(); msg['f'] = '"Comic Sans MS", cursive'; } else{ if(findTippers2(msg['user'])){ msg['background'] = colorMessage2(); msg['f'] ='"Comic Sans MS", cursive'; } else{ if(team1>team2){ msg['c'] = colorMessage1a(); msg['f'] = "Arial, Helvetica"; }else if(team1<team2){ msg['c'] = colorMessage2a(); msg['f'] = "Arial, Helvetica"; }else{msg['background'] = '#FFF'; msg['f'] = "Arial, Helvetica";} } } return msg; }); // Functions function refresh() { cb.log("Refresh called"); cb.setTimeout(refresh, 20000); cb.drawPanel(); } function tipMultiplo5(cadena){ var retornar = parseInt(cadena); var valor = 0; if(retornar%10==5){ valor = retornar; } return valor; } function tipMultiplo10(cadena){ var retornar = parseInt(cadena); var valor = 0; if(retornar%10==0){ valor = retornar; } return valor; } function update_subject() { if(team1 < cb.settings.goal && team2 < cb.settings.goal){ var new_subject = cb.settings.subject+' {Ending on 5 for '+cb.settings.color1+' | Ending on 0 for '+cb.settings.color2+' }'; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } else if(team1 >= cb.settings.goal){ var new_subject = '***** The winner team is: '+cb.settings.color1+' *****'; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } else if(team2 >= cb.settings.goal){ var new_subject = '***** The winner team is: '+cb.settings.color2+' *****'; cb.log("Changing subject to: " + new_subject); cb.changeRoomSubject(new_subject); } cb.setTimeout(update_subject, 300000); } function colorMessage1(){ var team_color = 0; if (cb.settings.color1=== "Red"){ team_color = red; }else if(cb.settings.color1=== "Green"){ team_color = green; }else if(cb.settings.color1=== "Blue"){ team_color = blue; }else if(cb.settings.color1=== "Pink"){ team_color = pink; }else if(cb.settings.color1=== "Teal"){ team_color = teal; }else if(cb.settings.color1=== "Purple"){ team_color = purple; }else if(cb.settings.color1=== "Olive"){ team_color = olive; }else if(cb.settings.color1=== "Gray"){ team_color = gray; } return team_color; } function colorMessage2(){ var team_color = 0; if (cb.settings.color2=== "Red"){ team_color = red; }else if(cb.settings.color2=== "Green"){ team_color = green; }else if(cb.settings.color2=== "Blue"){ team_color = blue; }else if(cb.settings.color2=== "Pink"){ team_color = pink; }else if(cb.settings.color2=== "Teal"){ team_color = teal; }else if(cb.settings.color2=== "Purple"){ team_color = purple; }else if(cb.settings.color2=== "Olive"){ team_color = olive; }else if(cb.settings.color2=== "Gray"){ team_color = gray; } return team_color; } function colorMessage1a(){ var team_color = 0; if (cb.settings.color1=== "Red"){ team_color = red1; }else if(cb.settings.color1=== "Green"){ team_color = green1; }else if(cb.settings.color1=== "Blue"){ team_color = blue1; }else if(cb.settings.color1=== "Pink"){ team_color = pink1; }else if(cb.settings.color1=== "Teal"){ team_color = teal1; }else if(cb.settings.color1=== "Purple"){ team_color = purple1; }else if(cb.settings.color1=== "Olive"){ team_color = olive1; }else if(cb.settings.color1=== "Gray"){ team_color = gray1; } return team_color; } function colorMessage2a(){ var team_color = 0; if (cb.settings.color2=== "Red"){ team_color = red1; }else if(cb.settings.color2=== "Green"){ team_color = green1; }else if(cb.settings.color2=== "Blue"){ team_color = blue1; }else if(cb.settings.color2=== "Pink"){ team_color = pink1; }else if(cb.settings.color2=== "Teal"){ team_color = teal1; }else if(cb.settings.color2=== "Purple"){ team_color = purple1; }else if(cb.settings.color2=== "Olive"){ team_color =olive1; }else if(cb.settings.color2=== "Gray"){ team_color = gray1; } return team_color; } function emoticon_happy_1(){ var emoticon = 0; if (cb.settings.color1=== "Red"){ emoticon = ' :redhappy '; }else if(cb.settings.color1=== "Green"){ emoticon = ' :greenhappy1 '; }else if(cb.settings.color1=== "Blue"){ emoticon = ' :bluehappy1 '; }else if(cb.settings.color1=== "Pink"){ emoticon = ' :pinkhappy '; }else if(cb.settings.color1=== "Teal"){ emoticon = ' :tealhappy '; }else if(cb.settings.color1=== "Purple"){ emoticon = ' :purplehappy '; }else if(cb.settings.color1=== "Olive"){ emoticon = ' :olivehappy '; }else if(cb.settings.color1=== "Gray"){ emoticon = ' :grayhappy '; } return emoticon; } function emoticon_sad_1(){ var emoticon = 0; if (cb.settings.color1=== "Red"){ emoticon = ' :redsad '; }else if(cb.settings.color1=== "Green"){ emoticon = ' :greensad1 '; }else if(cb.settings.color1=== "Blue"){ emoticon = ' :bluesad '; }else if(cb.settings.color1=== "Pink"){ emoticon = ' :pinksad '; }else if(cb.settings.color1=== "Teal"){ emoticon = ' :tealsad '; }else if(cb.settings.color1=== "Purple"){ emoticon = ' :purplesad '; }else if(cb.settings.color1=== "Olive"){ emoticon = ' :olivesad '; }else if(cb.settings.color1=== "Gray"){ emoticon = ' :graysad '; } return emoticon; } function emoticon_happy_2(){ var emoticon = 0; if (cb.settings.color2=== "Red"){ emoticon = ' :redhappy '; }else if(cb.settings.color2=== "Green"){ emoticon = ' :greenhappy1 '; }else if(cb.settings.color2=== "Blue"){ emoticon = ' :bluehappy1 '; }else if(cb.settings.color2=== "Pink"){ emoticon = ' :pinkhappy '; }else if(cb.settings.color2=== "Teal"){ emoticon = ' :tealhappy '; }else if(cb.settings.color2=== "Purple"){ emoticon = ' :purplehappy '; }else if(cb.settings.color2=== "Olive"){ emoticon = ' :olivehappy '; }else if(cb.settings.color2=== "Gray"){ emoticon = ' :grayhappy '; } return emoticon; } function emoticon_sad_2(){ var emoticon = 0; if (cb.settings.color2=== "Red"){ emoticon = ' :redsad '; }else if(cb.settings.color2=== "Green"){ emoticon = ' :greensad1 '; }else if(cb.settings.color2=== "Blue"){ emoticon = ' :bluesad '; }else if(cb.settings.color2=== "Pink"){ emoticon = ' :pinksad '; }else if(cb.settings.color2=== "Teal"){ emoticon = ' :tealsad '; }else if(cb.settings.color2=== "Purple"){ emoticon = ' :purplesad '; }else if(cb.settings.color2=== "Olive"){ emoticon = ' :olivesad '; }else if(cb.settings.color2=== "Gray"){ emoticon = ' :graysad '; } return emoticon; } function emoticonwinner1(){ var emoticon = 0; if (cb.settings.color1=== "Red"){ emoticon = ' :redwinner '; }else if(cb.settings.color1=== "Green"){ emoticon = ' :greenwinner '; }else if(cb.settings.color1=== "Blue"){ emoticon = ' :bluewinner '; }else if(cb.settings.color1=== "Pink"){ emoticon = ' :pinkwinner '; }else if(cb.settings.color1=== "Teal"){ emoticon = ' :tealwinner '; }else if(cb.settings.color1=== "Purple"){ emoticon = ' :purplewinner '; }else if(cb.settings.color1=== "Olive"){ emoticon = ' :olivewinner '; }else if(cb.settings.color1=== "Gray"){ emoticon = ' :graywinner '; } return emoticon; } function emoticonwinner2(){ var emoticon = 0; if (cb.settings.color2=== "Red"){ emoticon = ' :redwinner '; }else if(cb.settings.color2=== "Green"){ emoticon = ' :greenwinner '; }else if(cb.settings.color2=== "Blue"){ emoticon = ' :bluewinner '; }else if(cb.settings.color2=== "Pink"){ emoticon = ' :pinkwinner '; }else if(cb.settings.color2=== "Teal"){ emoticon = ' :tealwinner '; }else if(cb.settings.color2=== "Purple"){ emoticon = ' :purplewinner '; }else if(cb.settings.color2=== "Olive"){ emoticon = ' :olivewinner '; }else if(cb.settings.color2=== "Gray"){ emoticon = ' :graywinner '; } return emoticon; } function addTippers1(username) { if(tippers_team1.indexOf(username) < 0) { tippers_team1.push(username); } } function findTippers1(username){ var element = tippers_team1.indexOf(username); if(element!=-1){ return 1; }else {return 0;} } function addTippers2(username) { if(tippers_team2.indexOf(username) < 0) { tippers_team2.push(username); } } function findTippers2(username){ var element = tippers_team2.indexOf(username); if(element!=-1){ return 1; }else {return 0;} } function notifier(){ if(team1 != 0 || team2 != 0){ if(team1 < cb.settings.goal && team2 < cb.settings.goal){ if(team1>team2){ cb.sendNotice('SCORE'+'[***'+emoticon_happy_1()+' '+cb.settings.color1+' '+'('+team1+')'+' '+' VS '+' '+'('+team2+')'+' '+cb.settings.color2+' '+emoticon_sad_2()+'***]', '', '#FFFAFA', '', 'bold'); } else if(team2>team1){ cb.sendNotice('SCORE'+'[***'+emoticon_sad_1()+' '+cb.settings.color1+' '+'('+team1+')'+' '+' VS '+' '+'('+team2+')'+' '+cb.settings.color2+' '+emoticon_happy_2()+'***]', '', '#FFFAFA', '', 'bold'); } else{ cb.sendNotice('SCORE'+'[*** '+cb.settings.color1+' '+'('+team1+')'+' '+':teamtied'+' '+'('+team2+')'+' '+cb.settings.color2+' ***]', '', '#FFFAFA', '', 'bold'); } } } } function notifier1(){ if(team1 != 0 || team2 != 0){ if(team1 >= cb.settings.goal || team2 >= cb.settings.goal){ if(team1>team2){ cb.sendNotice('***** '+emoticonwinner1()+' *****','', '#FFFAFA', '', 'bold'); } else if(team2>team1){ cb.sendNotice('***** '+emoticonwinner2()+' *****','', '#FFFAFA', '', 'bold'); } } } cb.setTimeout(notifier1, 120000); } function notifier2(){ if(team1 < cb.settings.goal && team2 < cb.settings.goal){ cb.sendNotice('all tips ending on "5" for the '+cb.settings.color1+' team\n'+'all tips ending on "0" for the '+cb.settings.color2+' team'); } cb.setTimeout(notifier2, 120000); } function team1_remaing(){ var remaing = cb.settings.goal - team1; if(remaing<0){ return 0; } else {return remaing;} } function team2_remaing(){ var remaing = cb.settings.goal - team2; if(remaing<0){ return 0; } else {return remaing;} } function subjectwinner(){ if(team1 >= cb.settings.goal || team2 >= cb.settings.goal){ update_subject(); } cb.setTimeout(subjectwinner, 120000); } function init() { update_subject(); //notifier1(); notifier2(); //subjectwinner(); } init(); cb.setTimeout(refresh, 20000);
© Copyright Chaturbate 2011- 2026. All Rights Reserved.