Apps Home
|
Create an App
mila1
Author:
chaturapptest
Description
Source Code
Launch App
Current Users
Created by:
Chaturapptest
var answerVotes = { 1: 0, 2: 0, 3: 0, 4: 0, }; const answerCosts = { 11: 1, 12: 2, 13: 3, 14: 4, }; const game = [ { "question" : "What is my name?", "answers": ["Misha", "Oleg", "Roma", "Sergey"], "correct": 2, "prize": "Wink" }, { "question" : "What is my favourite drink?", "answers": ["Bear", "Milk", "Tea", "Coffee"], "correct": 3, "prize": "Smile" }, { "question" : "What is my favourite music instrument?", "answers": ["Piano", "Drums", "Bass", "Guitar"], "correct": 4, "prize": "Blow kiss" } ]; getTopAnswer = function () { maxVotes = 0; topAnswer = null; for (answer in answerVotes) { if (answerVotes[answer] > maxVotes) { topAnswer = answer; } } return topAnswer; } getRoundAnswer = function (num) { return game[0]['answers'][num - 1]; } getAnswersForPanel = function (panelNum) { var text = ''; for (answer in answerVotes) { if (panelNum == 1 && answer != 1 && answer != 2) { continue; } text += getRoundAnswer(answer) + ': ' + answerVotes[answer] + '\n'; } return text; } init = function () { cb.sendNotice("tes app!"); cb.drawPanel(); cb.onTip(function (tip) { var tip = parseInt(tip['amount']) var answer = answerCosts[tip] ? answerCosts[tip] : null; if (answer) { answerVotes[answer] += 1; } var answerChecked = getRoundAnswer(answer); if (answerChecked) { var noticeText = "Answer voted: " + answerChecked; } else { var noticeText = "No answer voted"; } cb.chatNotice(noticeText); //cb.chatNotice(tip); cb.drawPanel(); }); cb.onFollow(user => { cb.chatNotice(user['user'] + ' is my new follower!'); }); cb.onDrawPanel(function (user) { var topAnswer = getTopAnswer(); return { 'template': '3_rows_11_21_31', 'row1_value': topAnswer ? 'Top answer: ' + getRoundAnswer(topAnswer) : 'No votes', 'row2_value': getAnswersForPanel(1), 'row3_value': getAnswersForPanel(2) }; }); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.