├── runtime ├── emotes │ ├── cry.gif │ ├── grin.gif │ ├── frown.gif │ └── smile.gif ├── main.html ├── main.css └── ObjCB.js ├── Docs ├── drawPanel.txt ├── setTimeout.txt ├── chatNotice.txt ├── tipOptions.txt ├── onTip.txt ├── settings_choices.txt ├── onMessage.txt └── onDrawPanel.txt ├── Useful Stuff └── ColorPalette.js ├── README.txt └── LICENSE.txt /runtime/emotes/cry.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brandonxavier/CB-AppDevKit/HEAD/runtime/emotes/cry.gif -------------------------------------------------------------------------------- /runtime/emotes/grin.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brandonxavier/CB-AppDevKit/HEAD/runtime/emotes/grin.gif -------------------------------------------------------------------------------- /runtime/emotes/frown.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brandonxavier/CB-AppDevKit/HEAD/runtime/emotes/frown.gif -------------------------------------------------------------------------------- /runtime/emotes/smile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brandonxavier/CB-AppDevKit/HEAD/runtime/emotes/smile.gif -------------------------------------------------------------------------------- /Docs/drawPanel.txt: -------------------------------------------------------------------------------- 1 | cb.drawPanel() 2 | This function is only available to apps, not bots. 3 | 4 | Requests that all users reload the panel (the HTML info area below the cam). 5 | The contents of the panel are controlled by cb.onDrawPanel(func). 6 | -------------------------------------------------------------------------------- /Docs/setTimeout.txt: -------------------------------------------------------------------------------- 1 | cb.setTimeout(func, msecs) 2 | Example Code 3 | This example will print “hello world” in the chat every 10 seconds. 4 | 5 | function callme() { 6 | cb.chatNotice("hello world"); 7 | cb.setTimeout(callme, 10000) 8 | } 9 | cb.setTimeout(callme, 10000) 10 | -------------------------------------------------------------------------------- /Docs/chatNotice.txt: -------------------------------------------------------------------------------- 1 | cb.chatNotice(message, [to_user], [background], [foreground], [weight]) 2 | Send a message to the room. If to_user is given, the message will only be seen by 3 | that user. You can also use the optional params background, foreground, and weight 4 | to style your message. Only HTML color codes (such as #FF0000) may be given for the 5 | color stying, and the font weight will only accept the options normal, bold, or 6 | bolder. If you want to provide styling options, but not a to_user, just pass an 7 | empty string to to_user. 8 | 9 | You can use a \n inside the message to send a multi-line notice. 10 | 11 | You may use :emoticons in the notice. 12 | 13 | -------------------------------------------------------------------------------- /Docs/tipOptions.txt: -------------------------------------------------------------------------------- 1 | cb.tipOptions(func) 2 | This function is only available to apps, not bots. 3 | 4 | When users send a tip, present them with a list of messages to send with their tip. These messages can be received and processed later by cb.onTip(func). 5 | 6 | Example Code 7 | cb.tipOptions(function(user) { 8 | return {options:[{label: 'choice1'}, {label: 'choice2'}, {label: 'choice3'}], 9 | label:"Select a choice:"}; 10 | }); 11 | When a tip is received, the object will look like this: 12 | 13 | {u'to_user': u'testuser', u'amount': 5, u'message': u'choice1', 14 | u'from_user': u'testuser2'} 15 | Disabling tip options 16 | If you no longer wish to display custom tip options and would prefer the user type his own message, simply return nothing. 17 | 18 | cb.tipOptions(function(user) { 19 | // If we determine we want to show no custom tip options, do this . . . 20 | return; 21 | }); 22 | -------------------------------------------------------------------------------- /Docs/onTip.txt: -------------------------------------------------------------------------------- 1 | cb.onTip(func) 2 | Receive a notification when a tip is sent. The func argument should be a function that receives 1 argument itself, tip. 3 | 4 | These fields are available: 5 | 6 | amount: amount of tip 7 | message: message in tip 8 | to_user: user who received tip 9 | from_user: user who sent tip 10 | from_user_in_fanclub: is the user in the broadcasters fan club 11 | from_user_has_tokens: does the user have at least 1 token 12 | from_user_is_mod: is the user a moderator 13 | from_user_tipped_recently: is the user a “dark blue”? 14 | from_user_gender: “m” (male), “f” (female), “s” (shemale), or “c” (couple) 15 | Example Usage 16 | var total_tipped = 0; 17 | cb.onTip(function (tip) { 18 | total_tipped += parseInt(tip['amount']) 19 | cb.chatNotice("Total Tipped: " + total_tipped); 20 | cb.chatNotice(tip); 21 | }); 22 | Example Output 23 | Notice: Total Tipped: 5 24 | Notice: {u'to_user': u'testuser', u'amount': 5, u'message': u'', 25 | u'from_user': u'testuser2', u'from_user_in_fanclub': False, 26 | u'from_user_has_tokens': False, u'from_user_is_mod': False, 27 | u'from_user_gender': u'm', u'from_user_tipped_recently': True} 28 | -------------------------------------------------------------------------------- /Docs/settings_choices.txt: -------------------------------------------------------------------------------- 1 | Example Usage 2 | cb.settings_choices = [ 3 | {name:'tokens_per_minute_to_be_king', type:'int', 4 | minValue:1, maxValue:99, defaultValue:5, label: "Tokens per Minute"}, 5 | {name:'remove_king_when', type:'choice', 6 | choice1:'someone else outbids', 7 | choice2:'score decays to 0', defaultValue:'someone else outbids'} 8 | ]; 9 | Accessing the initialized variables 10 | For each name in cb.settings_choices, there will be a value loaded in cb.settings. For the example above, there will be a cb.settings.remove_king_when variable. 11 | 12 | Field Types 13 | int 14 | {name:'somefield', type:'int', minValue:1, maxValue:99}, 15 | str 16 | {name: 'somefield', type: 'str', minLength: 1, maxLength: 255} 17 | choice 18 | {name:'remove_king_when', type:'choice', 19 | choice1:'foo', 20 | choice2:'bar', defaultValue: 'foo'} 21 | You may add as many choices as needed. The next choice would be choice3, followed by choice4, etc. 22 | 23 | Optional fields 24 | All fields accept a required: false parameter which makes them become optional. 25 | 26 | All fields accept a label: "Some String" field. This will be the display name for the field as shown in the final rendered form. 27 | 28 | Default values 29 | All fields accept a defaultValue: parameter. -------------------------------------------------------------------------------- /Docs/onMessage.txt: -------------------------------------------------------------------------------- 1 | cb.onMessage(func) 2 | Receive a notification when a message is sent. The func argument should be a function that receives 1 argument 3 | itself, message. 4 | 5 | Your app can manipulate the message. 6 | 7 | You must return the original message object. 8 | 9 | The message variable passed to the function has these fields: 10 | 11 | c: message color 12 | m: the message text 13 | user: username of message sender 14 | f: message font 15 | in_fanclub: is the user in the broadcasters fan club 16 | has_tokens: does the user have at least 1 token 17 | is_mod: is the user a moderator 18 | tipped_recently: is the user a “dark blue”? 19 | gender: “m” (male), “f” (female), “s” (shemale), or “c” (couple) 20 | Example Usage 21 | cb.onMessage(function (message) { 22 | cb.chatNotice(message); 23 | }); 24 | Example Output 25 | Notice: {u'c': u'#494949', u'm': u'hello', u'user': u'testuser', 26 | u'f': u'default', u'in_fanclub': False, u'has_tokens': False, 27 | u'is_mod': False, u'gender': u'm', u'tipped_recently': True} 28 | Changing the background color of a message 29 | cb.onMessage(function (msg) { 30 | msg['background'] = '#9F9'; 31 | return msg; 32 | }); 33 | Hiding a message from chat 34 | Accomplished by setting the ‘X-Spam’ attribute on the message. 35 | 36 | cb.onMessage(function (msg) { 37 | if (msg['m'] == '/stats') { 38 | msg['X-Spam'] = true; 39 | } 40 | return msg; 41 | }); 42 | -------------------------------------------------------------------------------- /Docs/onDrawPanel.txt: -------------------------------------------------------------------------------- 1 | cb.onDrawPanel(func) 2 | This function is only available to apps, not bots. 3 | 4 | Return data needed to display the info panel for a user. The func function 5 | takes 1 argument, the username. 6 | The return value is a key-value set with a template key. Depending on the template chosen, additional 7 | keys should be passed in. For more information, see Available Templates 8 | 9 | Available Templates 10 | These are the supported templates with examples of how to use them. 11 | 12 | 3_rows_of_labels 13 | /* Layout is roughly 14 | {row1_label}: {row1_value} 15 | {row2_label}: {row2_value} 16 | {row3_label}: {row3_value} 17 | */ 18 | cb.onDrawPanel(function(user) { 19 | return { 20 | 'template': '3_rows_of_labels', 21 | 'row1_label': 'Tip Received / Goal :', 22 | 'row1_value': '0', 23 | 'row2_label': 'Highest Tip:', 24 | 'row2_value': 'username', 25 | 'row3_label': 'Latest Tip Received:', 26 | 'row3_value': '0' 27 | }; 28 | }); 29 | 3_rows_11_21_31 30 | /* Layout is roughly 31 | {row1_value} 32 | {row2_value} 33 | {row3_value} 34 | */ 35 | 36 | cb.onDrawPanel(function(user) { 37 | return { 38 | 'template': '3_rows_11_21_31', 39 | 'row1_value': '0', 40 | 'row2_value': 'username', 41 | 'row3_value': '0' 42 | }; 43 | }); 44 | 3_rows_12_21_31 45 | /* Layout is roughly 46 | {row1_label}: {row1_value} 47 | {row2_value} 48 | {row3_value} 49 | */ 50 | 51 | cb.onDrawPanel(function(user) { 52 | return { 53 | 'template': '3_rows_12_21_31', 54 | 'row1_label': 'Tip Received / Goal :', 55 | 'row1_value': '0', 56 | 'row2_value': 'username', 57 | 'row3_value': '0' 58 | }; 59 | }); 60 | 3_rows_12_22_31 61 | /* Layout is roughly 62 | {row1_label}: {row1_value} 63 | {row2_label}: {row2_value} 64 | {row3_value} 65 | */ 66 | 67 | cb.onDrawPanel(function(user) { 68 | return { 69 | 'template': '3_rows_12_22_31', 70 | 'row1_label': 'Tip Received / Goal :', 71 | 'row1_value': '0', 72 | 'row2_label': 'Highest Tip:', 73 | 'row2_value': 'username', 74 | 'row3_value': '0' 75 | }; 76 | }); 77 | Additional templates 78 | If nothing here works for you, please email support and request an additional template to suit your needs. 79 | Let us know what you’re looking for and we’ll try to accomidate you. -------------------------------------------------------------------------------- /Useful Stuff/ColorPalette.js: -------------------------------------------------------------------------------- 1 | // Standard CSS color names gathered from various freely available sources 2 | 3 | var colorPalette = { 4 | aliceblue: "#F0F8FF", 5 | antiquewhite: "#FAEBD7", 6 | aqua: "#00FFFF", 7 | aquamarine: "#7FFFD4", 8 | azure: "#F0FFFF", 9 | beige: "#F5F5DC", 10 | bisque: "#FFE4C4", 11 | black: "#000000", 12 | blanchedalmond: "#FFEBCD", 13 | blue: "#0000FF", 14 | blueviolet: "#8A2BE2", 15 | brown: "#A52A2A", 16 | burlywood: "#DEB887", 17 | cadetblue: "#5F9EA0", 18 | chartreuse: "#7FFF00", 19 | chocolate: "#D2691E", 20 | coral: "#FF7F50", 21 | cornflowerblue: "#6495ED", 22 | cornsilk: "#FFF8DC", 23 | crimson: "#DC143C", 24 | cyan: "#00FFFF", 25 | darkblue: "#00008B", 26 | darkcyan: "#008B8B", 27 | darkgoldenrod: "#B8860B", 28 | darkgray: "#A9A9A9", 29 | darkgrey: "#A9A9A9", 30 | darkgreen: "#006400", 31 | darkkhaki: "#BDB76B", 32 | darkmagenta: "#8B008B", 33 | darkolivegreen: "#556B2F", 34 | darkorange: "#FF8C00", 35 | darkorchid: "#9932CC", 36 | darkred: "#8B0000", 37 | darksalmon: "#E9967A", 38 | darkseagreen: "#8FBC8F", 39 | darkslateblue: "#483D8B", 40 | darkslategray: "#2F4F4F", 41 | darkslategrey: "#2F4F4F", 42 | darkturquoise: "#00CED1", 43 | darkviolet: "#9400D3", 44 | deeppink: "#FF1493", 45 | deepskyblue: "#00BFFF", 46 | dimgray: "#696969", 47 | dimgrey: "#696969", 48 | dodgerblue: "#1E90FF", 49 | firebrick: "#B22222", 50 | floralwhite: "#FFFAF0", 51 | forestgreen: "#228B22", 52 | fuchsia: "#FF00FF", 53 | gainsboro: "#DCDCDC", 54 | ghostwhite: "#F8F8FF", 55 | gold: "#FFD700", 56 | goldenrod: "#DAA520", 57 | gray: "#808080", 58 | grey: "#808080", 59 | green: "#008000", 60 | greenyellow: "#ADFF2F", 61 | honeydew: "#F0FFF0", 62 | hotpink: "#FF69B4", 63 | indianred: "#CD5C5C", 64 | indigo: "#4B0082", 65 | ivory: "#FFFFF0", 66 | khaki: "#F0E68C", 67 | lavender: "#E6E6FA", 68 | lavenderblush: "#FFF0F5", 69 | lawngreen: "#7CFC00", 70 | lemonchiffon: "#FFFACD", 71 | lightblue: "#ADD8E6", 72 | lightcoral: "#F08080", 73 | lightcyan: "#E0FFFF", 74 | lightgoldenrodyellow: "#FAFAD2", 75 | lightgreen: "#90EE90", 76 | lightgrey: "#D3D3D3", 77 | lightpink: "#FFB6C1", 78 | lightsalmon: "#FFA07A", 79 | lightseagreen: "#20B2AA", 80 | lightskyblue: "#87CEFA", 81 | lightslategray: "#778899", 82 | lightslategrey: "#778899", 83 | lightsteelblue: "#B0C4DE", 84 | lightyellow: "#FFFFE0", 85 | lime: "#00FF00", 86 | limegreen: "#32CD32", 87 | linen: "#FAF0E6", 88 | magenta: "#FF00FF", 89 | maroon: "#800000", 90 | mediumaquamarine: "#66CDAA", 91 | mediumblue: "#0000CD", 92 | mediumorchid: "#BA55D3", 93 | mediumpurple: "#9370DB", 94 | mediumseagreen: "#3CB371", 95 | mediumslateblue: "#7B68EE", 96 | mediumspringgreen: "#00FA9A", 97 | mediumturquoise: "#48D1CC", 98 | mediumvioletred: "#C71585", 99 | midnightblue: "#191970", 100 | mintcream: "#F5FFFA", 101 | mistyrose: "#FFE4E1", 102 | moccasin: "#FFE4B5", 103 | navajowhite: "#FFDEAD", 104 | navy: "#000080", 105 | oldlace: "#FDF5E6", 106 | olive: "#808000", 107 | olivedrab: "#6B8E23", 108 | orange: "#FFA500", 109 | orangered: "#FF4500", 110 | orchid: "#DA70D6", 111 | palegoldenrod: "#EEE8AA", 112 | palegreen: "#98FB98", 113 | paleturquoise: "#AFEEEE", 114 | palevioletred: "#DB7093", 115 | papayawhip: "#FFEFD5", 116 | peachpuff: "#FFDAB9", 117 | peru: "#CD853F", 118 | pink: "#FFC0CB", 119 | plum: "#DDA0DD", 120 | powderblue: "#B0E0E6", 121 | purple: "#800080", 122 | red: "#FF0000", 123 | rosybrown: "#BC8F8F", 124 | royalblue: "#4169E1", 125 | saddlebrown: "#8B4513", 126 | salmon: "#FA8072", 127 | sandybrown: "#F4A460", 128 | seagreen: "#2E8B57", 129 | seashell: "#FFF5EE", 130 | sienna: "#A0522D", 131 | silver: "#C0C0C0", 132 | skyblue: "#87CEEB", 133 | slateblue: "#6A5ACD", 134 | slategray: "#708090", 135 | slategrey: "#708090", 136 | snow: "#FFFAFA", 137 | springgreen: "#00FF7F", 138 | steelblue: "#4682B4", 139 | tan: "#D2B48C", 140 | teal: "#008080", 141 | thistle: "#D8BFD8", 142 | tomato: "#FF6347", 143 | turquoise: "#40E0D0", 144 | violet: "#EE82EE", 145 | wheat: "#F5DEB3", 146 | white: "#FFFFFF", 147 | whitesmoke: "#F5F5F5", 148 | yellow: "#FFFF00", 149 | yellowgreen: "#9ACD32" 150 | }; 151 | 152 | -------------------------------------------------------------------------------- /runtime/main.html: -------------------------------------------------------------------------------- 1 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | CB App Dev 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
41 | 42 | 43 | 44 | 45 |
46 | 47 |
48 |
49 | 50 |
51 |
52 |
53 | 54 |
55 |
56 |
57 | 58 |
59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 82 | 83 | 93 | 94 | 95 |
Broadcaster Panel:User Panel:
73 |
74 | 75 | 76 | 77 | 78 |
79 |
80 | 81 |
84 |
85 | 86 | 87 | 88 | 89 |
90 |
91 | 92 |
96 |
97 | 98 |
99 |
100 | 101 | 102 | 104 | 105 |
106 | 107 |
108 |
109 | 110 | 111 | 112 |
113 | 114 |
115 |
116 |
117 |
118 |
119 | 120 |
121 |
122 |
123 | 124 |
125 |
126 |
127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /runtime/main.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Created with JetBrains WebStorm 3 | * User: brandonxavier (brandonxavier421@gmail.com) 4 | * Date: 6/20/13 5 | * 6 | 7 | Copyright 2013 Brandon Xavier (brandonxavier421@gmail.com) 8 | 9 | This file is part of CB-AppDevKit. 10 | 11 | CB-AppDevKit is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | CB-AppDevKit is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with CB-AppDevKit. If not, see . 23 | 24 | */ 25 | 26 | /* 27 | 28 | TODO: Cleanup and simplify the css -- unfortunately, css 29 | just doesn't come naturally to me. Maybe someday 30 | I'll take a few days, throw away everything I think 31 | I know about css and relearn it from scratch. But 32 | not today . . . 33 | 34 | */ 35 | 36 | html { 37 | height: 100%; 38 | width: 100%; 39 | } 40 | 41 | body { 42 | height: 100%; 43 | width: 100%; 44 | } 45 | 46 | div { 47 | border: 1px solid black; 48 | float: left; 49 | width: 48%; 50 | height: 30%; 51 | margin: 5px; 52 | } 53 | 54 | #Settings, #Tipping { 55 | width: 84%; 56 | height: 95%; 57 | overflow-y: scroll; 58 | border: 0; 59 | margin: 0; 60 | padding-top: 10px; 61 | } 62 | 63 | #Activate, #SendTip { 64 | width: 14%; 65 | height: 100%; 66 | border: 0; 67 | margin: 0; 68 | padding: 4px; 69 | float: none; 70 | vertical-align: middle; 71 | display: table; 72 | } 73 | 74 | #Subject { 75 | overflow-y: scroll; 76 | overflow-x: scroll; 77 | } 78 | 79 | #Script { 80 | width: 48%; 81 | height: 25px; 82 | margin: 5px; 83 | margin-right: 125px; 84 | } 85 | 86 | .textareas { 87 | resize: none; 88 | width: 95%; 89 | height: 65%; 90 | margin: 13px; 91 | overflow-y: scroll; 92 | display: block; 93 | font-family: monospace; 94 | 95 | } 96 | 97 | #panelTable { 98 | font-family: 'UbuntuRegular', Arial, Helvetica, sans-serif; 99 | width: 660px; 100 | height: 117px; 101 | border: 1px solid black; 102 | border-collapse: collapse; 103 | padding: 13px; 104 | margin: 13px; 105 | text-align: center; 106 | font-size: 62.5%; 107 | 108 | } 109 | 110 | #panelTable th, .panelColumn { 111 | width: 311px; 112 | height: 18px; 113 | border: 1px solid black; 114 | padding: 2px; 115 | margin: 5px; 116 | margin-bottom: 0; 117 | text-align: center; 118 | vertical-align: middle; 119 | display: inline-block; 120 | text-align: center; 121 | } 122 | 123 | .panelHeadings { 124 | width: 45%; 125 | height: 20%; 126 | border: 1px solid black; 127 | padding: 0; 128 | margin: 0; 129 | text-align: center; 130 | display: inline-block; 131 | text-align: center; 132 | font-weight: normal; 133 | 134 | } 135 | 136 | .panelColumn { 137 | height: 80px; 138 | margin-top: 0; 139 | overflow-y: hidden; 140 | } 141 | 142 | .panelOddRow { 143 | min-width: 270px; 144 | height: 23px; 145 | margin: 0; 146 | background-color: #d5ebf8; 147 | border: 0; 148 | display: table-row; 149 | } 150 | 151 | .panelEvenRow { 152 | min-width: 270px; 153 | height: 23px; 154 | max-height: 46px; 155 | margin: 0; 156 | background-color: #f2f9fd; 157 | border: 0; 158 | } 159 | 160 | .innerTable { 161 | width: 267px; 162 | height: 70px; 163 | border: 0; 164 | text-align: center; 165 | margin: 0 auto; 166 | display: inline-table; 167 | float: none; 168 | padding: 0; 169 | vertical-align: middle; 170 | } 171 | 172 | /* .leftColumn, .rightColumn, .topLeftColumn, .singleColumn { */ 173 | .leftColumn, .rightColumn, .topLeftColumn { 174 | font-size: 100.01%; 175 | height: 16px; 176 | line-height: 16px; 177 | width: 130px; 178 | max-width: 130px; 179 | vertical-align: middle; 180 | padding: 0; 181 | float: none; 182 | } 183 | 184 | .leftColumn { 185 | text-align: right; 186 | font-weight: bold; 187 | padding-right: 0; 188 | } 189 | 190 | .topLeftColumn { 191 | text-align: right; 192 | font-weight: bold; 193 | padding-right: 0; 194 | color: #057205; 195 | font-size: 94%; 196 | } 197 | 198 | .rightColumn { 199 | width: 130px; 200 | /* display: inline-table; */ 201 | text-align: left; 202 | vertical-align: middle; 203 | padding-left: 2px; 204 | } 205 | 206 | .singleColumn, .singleTopColumn { 207 | padding: 0; 208 | margin: 0; 209 | max-width: 267px; 210 | max-height: 46px; 211 | width: 255px; 212 | text-align: center; 213 | border: 0; 214 | word-wrap: normal; 215 | overflow-y: visible; 216 | font-weight: normal; 217 | } 218 | 219 | .singleTopColumn { 220 | font-weight: bold; 221 | max-height: 23px; 222 | overflow-y: hidden; 223 | } 224 | 225 | .inputAreas { 226 | resize: none; 227 | width: 80%; 228 | height: 10%; 229 | margin: 13px; 230 | } 231 | 232 | .button { 233 | font-size: 12px; 234 | width: 60px; 235 | margin: 13px auto; 236 | } 237 | 238 | #txtSubject { 239 | resize: none; 240 | margin: 13px; 241 | width: 80%; 242 | height: 20%; 243 | color: black; 244 | } 245 | 246 | #txtUserChat { 247 | color: green; 248 | } 249 | 250 | #txtLog { 251 | width: 95%; 252 | height: 90%; 253 | color: red; 254 | } 255 | 256 | #txtBroadcaster { 257 | color: blue; 258 | } 259 | 260 | #btnSubject { 261 | vertical-align: top; 262 | } 263 | 264 | #btnActivate { 265 | vertical-align: middle; 266 | float: none; 267 | text-align: center; 268 | margin: 0 auto; 269 | 270 | } 271 | 272 | #btnSendTip { 273 | vertical-align: bottom; 274 | text-align: center; 275 | margin: 0 auto; 276 | display: block; 277 | position: relative; 278 | } 279 | 280 | #lstUsers { 281 | float: left; 282 | margin: 13px; 283 | } 284 | 285 | #lstTipping { 286 | width: 125px; 287 | } 288 | 289 | #inUser { 290 | width: 65%; 291 | } 292 | 293 | .settingLabel, .tipLabel { 294 | width: 47%; 295 | height: 48px; 296 | border: 0; 297 | padding: 0; 298 | margin: 0; 299 | padding-right: 2px; 300 | text-align: right; 301 | display: block; 302 | 303 | } 304 | 305 | .settingInput { 306 | /* Just an empty class for selector purposes */ 307 | } 308 | 309 | .settingField, .errorLabel, .tipField { 310 | width: 47%; 311 | height: 48px; 312 | border: 0; 313 | margin: 0; 314 | padding: 0; 315 | padding-left: 2px; 316 | text-align: left; 317 | float: right; 318 | } 319 | 320 | .tipField, #inTipNote { 321 | height: 20px; 322 | width: 80px; 323 | float: none; 324 | display: block; 325 | border: 1px solid black; 326 | margin: 5px; 327 | } 328 | 329 | .tipLabel { 330 | height: 20px; 331 | margin: 5px; 332 | } 333 | 334 | #inTipNote { 335 | width: 242px; 336 | height: 69px; 337 | display: block; 338 | resize: none; 339 | float: none; 340 | } 341 | 342 | .errorLabel { 343 | height: 16px; 344 | width: 90%; 345 | color: red; 346 | display: block; 347 | float: none; 348 | font-size: 11px; 349 | } -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | 2 | Chaturbate App Developer Kit (ADK) 3 | 4 | 5 | ******************************************************************************* 6 | ******************************************************************************* 7 | 8 | What the ADK IS: 9 | 10 | - An extremely simple offline (i.e. runs in a standalone browser) way to 11 | run/test/debug apps without having to utilize the testbed server (per- 12 | haps your employer, like mine, frowns upon visiting adult-oriented 13 | sites while at work?) 14 | - A way to utilize your favorite debuggers/IDEs in your development (getting 15 | tired of spending 30+ minutes chasing down a bug that would take 30 seconds 16 | to find in a debugger?) 17 | - Mostly free of any external dependencies -- only the most generic JS is 18 | used plus JQuery (included) -- no other additional libraries/frameworks are 19 | used. (Yes! This is a departure from my original stance of NO external 20 | libraries - but circumstances change, and the code was becoming a bit too 21 | unruly). The minimal set of software required is a browser and a text 22 | editor - although you probably almost always want to use some sort of IDE 23 | (at the risk of sounding like a shill, I'm quite happy with Webstorm) 24 | - Released under GPLv3 license. Within the (quite liberal) constraints of 25 | the license, you're free to do with it as you please. 26 | - A convenient way for the real Chaturbate devs to prototype/test changes 27 | to the API. 28 | - Maintained at github (as are all my CB projects). If you'd like to help 29 | improve this project, feel free to send me pull requests or contact me 30 | about rw access to the repository. 31 | 32 | ******************************************************************************* 33 | ******************************************************************************* 34 | 35 | What the ADK is NOT: 36 | 37 | - A SUBSTITUTE FOR TESTING ON THE TESTBED!!!!! NEVER assume that just because 38 | an app/bot runs correctly in the ADK, that it's ready to go on the live 39 | server. Always, ALWAYS do your final testing on the testbed! 40 | - A basis for a clone of Chaturbate. Not even remotely possible. If you 41 | even think this, your web development skills are in SERIOUS need of a 42 | reality check! :-) 43 | - Production ready code. Nothing has been optimized for speed/performance, 44 | no runtime checking is performed, and no security best practices are 45 | followed (remember, it's intended to run offline). So, of course, there 46 | are almost always "better" ways to do things . . . but again, I wanted to 47 | keep this to as much simple JavaScript as possible. 48 | - An exact copy of how Chaturbate works. The goal is for the ADK to produce 49 | the same results Chaturbate does - the code/means used to produce those 50 | results will almost certainly be different (I ain't psychic! LOL). In 51 | addition, some objects are available in the ADK that are NOT available in 52 | the real Chaturbate -- most notably the "window" object (so be wary of 53 | using things like alert(), confirm(), etc. in your app/bot code) 54 | - Pretty! If you want "pretty", visit your local art museum! LOL Seriously 55 | though, it's primarily meant to be functional, not pleasing to the eye. 56 | To that end, I'll fix anything, or accept pull requests (hint, hint) for 57 | things, that may be affecting functionality (form elements overlapping, 58 | stuff not displaying correctly, etc.) but requests for things like "can 59 | you change the background to blue?" are likely to be graciously ignored 60 | 61 | ******************************************************************************* 62 | ******************************************************************************* 63 | 64 | Usage: 65 | 66 | The ADK runtime system is composed of 4 files: 67 | 68 | objCB.js - This provides the cb object. Generally you should not have 69 | to modify this. 70 | main.html - Basic HTML to display the ADK screen and load objCB.js along 71 | with your app/bot script. You MAY have to modify this to 72 | specify the name of your app/bot script and it's Init function. 73 | main.css - All the basic formatting is done via css, so change it here 74 | to suit your preferences. Some formatting of generated elements 75 | (such as the settings_choices) is done with style attributes 76 | within the JavaScript code (Hint: Search for "STYLE=") Note: 77 | Unless you're fixing some functional issue, main.css should 78 | NOT be included in pull requests. 79 | jquery - This is included in the runtime to continue the ability to 80 | run the ADK completely offline. The current version is 81 | jquery-2.0.3.js 82 | 83 | Put these 4 files along with YOUR app/bot script in a folder/directory, and then 84 | simply point your IDE/browser/debugger to main.html! 85 | 86 | When the window opens in the browser, you should have 7 panels: 87 | 88 | Script & Init - See below 89 | Startup - (Top left) Processes the cb.settings_choices and provides 90 | a (de)activate button 91 | Subject & Panel - (Top right) Shows/Sets the Room Subject and also displays 92 | the Panels 93 | Broadcaster - (Middle Left) Show the chat as the broadcaster sees it, 94 | and allows you to chat as the broadcaster. 95 | User - (Middle Right) Shows the chat as users see it. Note: Messages 96 | sent to a specific user are suffixed with " to ". 97 | You can chat as different users by selecting one in the 98 | dropdown list. (No more having to open different browsers!) 99 | The currently selected user is also assumed to be the one 100 | sending tips and receiving customized panels. 101 | Tip - (Bottom Left) The tip window laid out according to 102 | cb.tipOptions. 103 | Log - (Bottom Right) cb.log messages are displayed here rather 104 | than the user/bcast areas. No /debug required to see them. 105 | 106 | 107 | ******************************************************************************* 108 | ******************************************************************************* 109 | 110 | Specifying Your Script File & Init Function: 111 | 112 | As of v1.4, there is one preferred way of specifying your script name and 113 | init function: via the "Script & Init Function" panel. 114 | 115 | **NOTE: Debugging is MUCH more reliable if your source .js file exists in 116 | the same directory/folder as the ADK. This is due to the way the File object 117 | doesn't make the path to the file available - if I load the file as a blob (no 118 | path required), then debuggers don't work -- but if it's loaded via a file 119 | name, debugging miraculously works** 120 | 121 | Simply use the "Browse" or "Choose File" (label is browser dependent) button 122 | to locate and select your script file. The ADK will then try to parse your 123 | file to locate the "cb.settings_choices = " line(s) and eval them. This 124 | imitates the behavior of the "real" CB (i.e. the settings choices are set 125 | BEFORE code executes). NOTE: YOU WILL HAVE TO CHOOSE YOUR SCRIPT FILE EVERY 126 | TIME IF YOU USE THIS METHOD! No way around this! JS will not permit access 127 | to files on your computer without some sort of direct user interaction. The 128 | act of "choosing a file" is considered by JS to be permission to access that 129 | file (even though it's a nuisance here in this very limited case, as a general 130 | security precaution it's probably an EXCELLENT thing JS does this) 131 | 132 | Next, the ADK parses the function names from your script file and populates 133 | the "Init function" dropdown box. If it finds a function name matching 134 | "init" (case-insensitive) it will pre-select that function for you. Other- 135 | wise it assumes you are working without an init function and preselects 136 | "(none)". I'm tempted to go into an old-school rant about the wisdom of 137 | executing code outside of functions . . . but JS permits it . . . so I'll 138 | just have to accept it as "valid" . . . and leave it at that. 139 | 140 | Note: Pre v1.4 users who are accustomed to specifying BOTH their script 141 | name AND init function via HTML may continue to do so, but this should be 142 | considered a deprecated feature. 143 | 144 | ******************************************************************************* 145 | ******************************************************************************* 146 | 147 | Emote Support: 148 | 149 | Emote support is now available in a limited form for testing purposes. All 150 | emotes are stored in the "emotes" folder located under "runtime". The filename 151 | of the emotes should match your emote tag, less the extension. No attempt is 152 | made to maintain mappings of tags to filenames. So, for example, to show the 153 | smile.gif file, you would use ":smile" 154 | 155 | Note: There is a long-standing Webkit bug in Chrome wherein the alt text of 156 | an img tag will not display (instead you see a broken image graphic). While 157 | this bug COULD be worked around, it's outside the current scope of this project 158 | to do so. Sorry. 159 | 160 | ******************************************************************************* 161 | ******************************************************************************* 162 | 163 | Panel Revamp: 164 | 165 | Panels now should behave very nearly identically to real CB panels. In 166 | addition, customized panels are now supported. So for example, the broadcaster, 167 | Bob, Carol and every other user could be shown a completely different panel. 168 | This has some interesting possibilities for some multiplayer games (Texas Hold 169 | 'Em comes to mind offhand (thinking players 2 cards on top row, flop/turn/river 170 | cards on second, other info on third). For ADK purposes, only the currently 171 | selected users' panel is displayed. 172 | 173 | ******************************************************************************* 174 | ******************************************************************************* 175 | 176 | JQuery Support: 177 | 178 | All the DOM handling is being transitioned to JQuery. Version 2.x was chosen 179 | over the slightly more browser compatible 1.x versions mainly because the 180 | only additional compatibility 1.x would give us is IE versions <= 8.0. Well, 181 | guess what? Those IE versions don't have the HTML5 File API support we need 182 | anyway. So no point in going out of our way to support them. 183 | 184 | The included jquery is, and should be, unmodified from the distribution. It 185 | is only included to maintain the completely offline usability goal. 186 | 187 | ******************************************************************************* 188 | ******************************************************************************* 189 | 190 | Problem Reporting: 191 | 192 | If you come across a situation where a script is not working under the ADK as 193 | it does on the live/testbed servers, by all means please let me know. I can be 194 | reached (in general order of preference) via github (issues), email at 195 | brandonxavier421@gmail.com, or the Chaturbate API DISQUS discussions (my access 196 | there during normal US business hours is effectively zero though ;) I will need 197 | the following: name and location (testbed or live server)of your script, init 198 | function you use (or none, if you don't use one), what browser version you use, 199 | and a general description of what the problem is unless it's obvious (like the 200 | ADK crashes). 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | -------------------------------------------------------------------------------- /runtime/ObjCB.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created with JetBrains WebStorm 3 | * User: brandonxavier (brandonxavier421@gmail.com) 4 | * Date: 6/20/13 5 | * 6 | 7 | Copyright 2013 Brandon Xavier (brandonxavier421@gmail.com) 8 | 9 | This file is part of CB-AppDevKit. 10 | 11 | CB-AppDevKit is free software: you can redistribute it and/or modify 12 | it under the terms of the GNU General Public License as published by 13 | the Free Software Foundation, either version 3 of the License, or 14 | (at your option) any later version. 15 | 16 | CB-AppDevKit is distributed in the hope that it will be useful, 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | GNU General Public License for more details. 20 | 21 | You should have received a copy of the GNU General Public License 22 | along with CB-AppDevKit. If not, see . 23 | 24 | */ 25 | 26 | var AppDevKit = true; 27 | var ADK = {'readyToRun': false, 28 | 'scriptName': "", 29 | 'initFunction': "", 30 | 'settingsChoices': "", 31 | 'trueScriptName': "" 32 | }; 33 | 34 | // Standard CSS color names gathered from various freely available sources 35 | 36 | var cp = { // I like being able to use symbolic names rather than hex codes :-) 37 | aliceblue: "#F0F8FF", 38 | antiquewhite: "#FAEBD7", 39 | aqua: "#00FFFF", 40 | aquamarine: "#7FFFD4", 41 | azure: "#F0FFFF", 42 | beige: "#F5F5DC", 43 | bisque: "#FFE4C4", 44 | black: "#000000", 45 | blanchedalmond: "#FFEBCD", 46 | blue: "#0000FF", 47 | blueviolet: "#8A2BE2", 48 | brown: "#A52A2A", 49 | burlywood: "#DEB887", 50 | cadetblue: "#5F9EA0", 51 | chartreuse: "#7FFF00", 52 | chocolate: "#D2691E", 53 | coral: "#FF7F50", 54 | cornflowerblue: "#6495ED", 55 | cornsilk: "#FFF8DC", 56 | crimson: "#DC143C", 57 | cyan: "#00FFFF", 58 | darkblue: "#00008B", 59 | darkcyan: "#008B8B", 60 | darkgoldenrod: "#B8860B", 61 | darkgray: "#A9A9A9", 62 | darkgrey: "#A9A9A9", 63 | darkgreen: "#006400", 64 | darkkhaki: "#BDB76B", 65 | darkmagenta: "#8B008B", 66 | darkolivegreen: "#556B2F", 67 | darkorange: "#FF8C00", 68 | darkorchid: "#9932CC", 69 | darkred: "#8B0000", 70 | darksalmon: "#E9967A", 71 | darkseagreen: "#8FBC8F", 72 | darkslateblue: "#483D8B", 73 | darkslategray: "#2F4F4F", 74 | darkslategrey: "#2F4F4F", 75 | darkturquoise: "#00CED1", 76 | darkviolet: "#9400D3", 77 | deeppink: "#FF1493", 78 | deepskyblue: "#00BFFF", 79 | dimgray: "#696969", 80 | dimgrey: "#696969", 81 | dodgerblue: "#1E90FF", 82 | firebrick: "#B22222", 83 | floralwhite: "#FFFAF0", 84 | forestgreen: "#228B22", 85 | fuchsia: "#FF00FF", 86 | gainsboro: "#DCDCDC", 87 | ghostwhite: "#F8F8FF", 88 | gold: "#FFD700", 89 | goldenrod: "#DAA520", 90 | gray: "#808080", 91 | grey: "#808080", 92 | green: "#008000", 93 | greenyellow: "#ADFF2F", 94 | honeydew: "#F0FFF0", 95 | hotpink: "#FF69B4", 96 | indianred: "#CD5C5C", 97 | indigo: "#4B0082", 98 | ivory: "#FFFFF0", 99 | khaki: "#F0E68C", 100 | lavender: "#E6E6FA", 101 | lavenderblush: "#FFF0F5", 102 | lawngreen: "#7CFC00", 103 | lemonchiffon: "#FFFACD", 104 | lightblue: "#ADD8E6", 105 | lightcoral: "#F08080", 106 | lightcyan: "#E0FFFF", 107 | lightgoldenrodyellow: "#FAFAD2", 108 | lightgreen: "#90EE90", 109 | lightgrey: "#D3D3D3", 110 | lightpink: "#FFB6C1", 111 | lightsalmon: "#FFA07A", 112 | lightseagreen: "#20B2AA", 113 | lightskyblue: "#87CEFA", 114 | lightslategray: "#778899", 115 | lightslategrey: "#778899", 116 | lightsteelblue: "#B0C4DE", 117 | lightyellow: "#FFFFE0", 118 | lime: "#00FF00", 119 | limegreen: "#32CD32", 120 | linen: "#FAF0E6", 121 | magenta: "#FF00FF", 122 | maroon: "#800000", 123 | mediumaquamarine: "#66CDAA", 124 | mediumblue: "#0000CD", 125 | mediumorchid: "#BA55D3", 126 | mediumpurple: "#9370DB", 127 | mediumseagreen: "#3CB371", 128 | mediumslateblue: "#7B68EE", 129 | mediumspringgreen: "#00FA9A", 130 | mediumturquoise: "#48D1CC", 131 | mediumvioletred: "#C71585", 132 | midnightblue: "#191970", 133 | mintcream: "#F5FFFA", 134 | mistyrose: "#FFE4E1", 135 | moccasin: "#FFE4B5", 136 | navajowhite: "#FFDEAD", 137 | navy: "#000080", 138 | oldlace: "#FDF5E6", 139 | olive: "#808000", 140 | olivedrab: "#6B8E23", 141 | orange: "#FFA500", 142 | orangered: "#FF4500", 143 | orchid: "#DA70D6", 144 | palegoldenrod: "#EEE8AA", 145 | palegreen: "#98FB98", 146 | paleturquoise: "#AFEEEE", 147 | palevioletred: "#DB7093", 148 | papayawhip: "#FFEFD5", 149 | peachpuff: "#FFDAB9", 150 | peru: "#CD853F", 151 | pink: "#FFC0CB", 152 | plum: "#DDA0DD", 153 | powderblue: "#B0E0E6", 154 | purple: "#800080", 155 | red: "#FF0000", 156 | rosybrown: "#BC8F8F", 157 | royalblue: "#4169E1", 158 | saddlebrown: "#8B4513", 159 | salmon: "#FA8072", 160 | sandybrown: "#F4A460", 161 | seagreen: "#2E8B57", 162 | seashell: "#FFF5EE", 163 | sienna: "#A0522D", 164 | silver: "#C0C0C0", 165 | skyblue: "#87CEEB", 166 | slateblue: "#6A5ACD", 167 | slategray: "#708090", 168 | slategrey: "#708090", 169 | snow: "#FFFAFA", 170 | springgreen: "#00FF7F", 171 | steelblue: "#4682B4", 172 | tan: "#D2B48C", 173 | teal: "#008080", 174 | thistle: "#D8BFD8", 175 | tomato: "#FF6347", 176 | turquoise: "#40E0D0", 177 | violet: "#EE82EE", 178 | wheat: "#F5DEB3", 179 | white: "#FFFFFF", 180 | whitesmoke: "#F5F5F5", 181 | yellow: "#FFFF00", 182 | yellowgreen: "#9ACD32" 183 | }; 184 | 185 | 186 | var cb; 187 | 188 | $( document ).ready( function () { 189 | 190 | // do some jquery stuff here 191 | 192 | } ); 193 | 194 | function objCB() { 195 | 196 | this.room_slug = "Betty Broadcaster"; // Just a random name I picked 197 | this.cbUsers = []; // An array of logged in (dummy) users 198 | 199 | this.changeRoomSubject = changeRoomSubject; 200 | this.subjectChangeClicked = subjectChangeClicked; 201 | this.chatNotice = chatNotice; 202 | this.drawPanel = drawPanel; 203 | this.log = log; 204 | this.onDrawPanel = onDrawPanel; 205 | this.onMessage = onMessage; 206 | this.onTip = onTip; 207 | this.setTimeout = setTimeout; 208 | 209 | this.sendMsg = sendMsg; 210 | this.writeToTextarea = writeToTextarea; 211 | this.writeToChatArea = writeToChatArea; 212 | this.sendClicked = sendClicked; 213 | this.populateUserDropdown = populateUserDropdown; 214 | this.scriptName = ADK.scriptName; 215 | this.initFunction = ADK.initFunction; 216 | 217 | if ( ADK.settingsChoices != "" ) { 218 | this.settings_choices = eval( ADK.settingsChoices ); 219 | showSettings( "#Settings", this.settings_choices ); 220 | // createValidationCode( this.settings_choices ); 221 | } else { 222 | this.settings_choices = []; 223 | } 224 | this.settings = []; 225 | 226 | this.panelHandler = function () { 227 | }; 228 | this.mesgHandler = function () { 229 | }; 230 | this.tipHandler = function () { 231 | }; 232 | 233 | this.tipOptions = tipOptions; 234 | 235 | this.tipOptionsHandler = function () { 236 | }; 237 | 238 | // Seed some dummy users; 239 | // 240 | // (name, gender, fan_club, has_tokens, is_mod, recent_tipper) 241 | // 242 | this.cbUsers[this.room_slug] = new objCBUser( this.room_slug, "f", true, true, true, true ); 243 | this.cbUsers['Notice'] = new objCBUser( "Notice", "m", false, false, false, false ); // Cheesy way to set formatting for notices 244 | this.cbUsers['Bob'] = new objCBUser( "Bob", "m", false, true, false, false ); 245 | this.cbUsers['Carol'] = new objCBUser( "Carol", "f", false, true, true, true ); 246 | this.cbUsers['Ted'] = new objCBUser( "Ted", "m", true, false, false, false ); 247 | this.cbUsers['Alice'] = new objCBUser( "Alice", "f", false, false, false, true ); 248 | 249 | this.populateUserDropdown(); 250 | 251 | if ( ADK.scriptName.match( /^blob:/ ) == null ) { // The script was specified via HTML 252 | loadScript(); 253 | } 254 | 255 | function populateUserDropdown() { 256 | 257 | /** 258 | * it seemed like a good idea at the time to encapsulate this function with 259 | * the user object . . . but it wasn't . . . 260 | */ 261 | var dropdownList, newentry, i; 262 | 263 | dropdownList = document.getElementById( "lstUsers" ); 264 | for ( i in this.cbUsers ) { 265 | if ( i != this.room_slug && i != "Notice" ) { 266 | newentry = document.createElement( "option" ); 267 | newentry.value = this.cbUsers[i].u; 268 | newentry.textContent = this.cbUsers[i].u; 269 | dropdownList.appendChild( newentry ); 270 | } 271 | } 272 | 273 | } 274 | 275 | function changeRoomSubject(new_subject) { 276 | document.getElementById( "txtSubject" ).value = new_subject; 277 | this.writeToTextarea( "txtSubject", new_subject, true ); 278 | var area = document.getElementById( "txtUserChat" ); 279 | area.innerHTML += "" + 280 | "room subject changed to \"" + new_subject + "\"
"; 281 | area.scrollTop = area.scrollHeight; 282 | 283 | area = document.getElementById( "txtBroadcaster" ); 284 | area.innerHTML += "" + 285 | "room subject changed to \"" + new_subject + "\"
"; 286 | area.scrollTop = area.scrollHeight; 287 | } 288 | 289 | 290 | /** 291 | * 292 | * 293 | * 294 | * @param message 295 | * @param to_user optional Defaults to all users 296 | * @param bg_color optional Defaults to #000000 (white) 297 | * @param fg_color optional Defaults to #ffffff (black) 298 | * @param weight optional {'normal', 'bold', 'bolder'} 299 | */ 300 | function chatNotice(message, to_user, bg_color, fg_color, weight) { 301 | 302 | var msgObj; 303 | 304 | // replace newlines in message with
305 | while ( message.indexOf( "\n" ) >= 0 ) 306 | message = message.replace( "\n", "
Notice: " ); 307 | 308 | if ( bg_color == null || bg_color == "" ) { 309 | bg_color = cp.white; 310 | } 311 | if ( fg_color == null || fg_color == "" ) { 312 | fg_color = cp.black; 313 | } 314 | if ( weight == null || weight == "" ) { 315 | weight = "normal"; 316 | } 317 | 318 | if ( to_user == null || to_user == "" ) { 319 | // area = document.getElementById(this.cbDiv['Main'].txtMainChat); 320 | 321 | msgObj = createMesg( "Notice", message, bg_color, fg_color, weight ); 322 | this.writeToChatArea( "txtUserChat", msgObj ); 323 | this.writeToChatArea( "txtBroadcaster", msgObj ); 324 | } 325 | else { 326 | msgObj = createMesg( "Notice", message + " to " + to_user, bg_color, fg_color, weight ); 327 | if ( to_user == cb.room_slug ) 328 | this.writeToChatArea( "txtBroadcaster", msgObj ); 329 | else 330 | this.writeToChatArea( "txtUserChat", msgObj ); 331 | } 332 | 333 | } 334 | 335 | function drawPanel() { 336 | 337 | /** 338 | * 339 | * This should be considered an immutable function -- don't attempt to redefine it 340 | * 341 | */ 342 | 343 | /** 344 | * 345 | * In theory, we should loop thru all the users logged in and give them each 346 | * a shot at having their own personalized panel (that could make for some really 347 | * interesting games -- like a Texas Hold'Em with the players cards being shown to 348 | * them in their panel). But since this is for testing, and we have only the one 349 | * user display panel, we'll just do the broadcaster and selected user 350 | * 351 | */ 352 | 353 | var tgtUsers = [cb.room_slug, getSelectedUser()]; 354 | for ( var z = 0; z < tgtUsers.length; z++ ) { 355 | var tData = []; 356 | 357 | var t = cb.panelHandler( tgtUsers[z] ); 358 | 359 | if ( typeof t == "undefined" ) // No custom panel defined 360 | return; 361 | 362 | var e; 363 | 364 | switch (t['template']) { 365 | case "3_rows_11_21_31": 366 | tData['row1_value'] = t.row1_value; 367 | tData['row2_value'] = t.row2_value; 368 | tData['row3_value'] = t.row3_value; 369 | break; 370 | case "3_rows_11_22_32": 371 | tData['row1_value'] = t.row1_value; 372 | tData['row2_label'] = t.row2_label; 373 | tData['row2_value'] = t.row2_value; 374 | tData['row3_label'] = t.row3_label; 375 | tData['row3_value'] = t.row3_value; 376 | break; 377 | case "3_rows_12_22_32": 378 | case "3_rows_of_labels": 379 | tData['row1_label'] = t.row1_label; 380 | tData['row1_value'] = t.row1_value; 381 | tData['row2_label'] = t.row2_label; 382 | tData['row2_value'] = t.row2_value; 383 | tData['row3_label'] = t.row3_label; 384 | tData['row3_value'] = t.row3_value; 385 | break; 386 | case "3_rows_12_21_31": 387 | tData['row1_label'] = t.row1_label; 388 | tData['row1_value'] = t.row1_value; 389 | tData['row2_value'] = t.row2_value; 390 | tData['row3_value'] = t.row3_value; 391 | break; 392 | case "3_rows_12_22_31": 393 | tData['row1_label'] = t.row1_label; 394 | tData['row1_value'] = t.row1_value; 395 | tData['row2_label'] = t.row2_label; 396 | tData['row2_value'] = t.row2_value; 397 | tData['row3_value'] = t.row3_value; 398 | break; 399 | default: 400 | cb.log( "Invalid template" + t.template ); 401 | break; 402 | 403 | } 404 | 405 | 406 | /** 407 | * This is a horribly bad way to do this . . . but honestly there 408 | * aren't really enough variations in the templates to justify much 409 | * more effort than this quick-n-dirty solution requires 410 | * 411 | */ 412 | if ( tgtUsers[z] == cb.room_slug ) { 413 | var elemArray = ["brow1", "brow2", "brow3"]; 414 | 415 | } else { 416 | var elemArray = ["urow1", "urow2", "urow3"]; 417 | } 418 | 419 | e = document.getElementById( elemArray[0] ); 420 | if ( typeof tData['row1_label'] == "undefined" ) 421 | e.innerHTML = "" + tData['row1_value'] + ""; 422 | else { 423 | e.innerHTML = "" + tData['row1_label'] + "" + 424 | "" + tData['row1_value'] + ""; 425 | } 426 | 427 | e = document.getElementById( elemArray[1] ); 428 | if ( typeof tData['row2_label'] == "undefined" ) 429 | e.innerHTML = "" + tData['row2_value'] + ""; 430 | else { 431 | e.innerHTML = "" + tData['row2_label'] + "" + 432 | "" + tData['row2_value'] + ""; 433 | } 434 | 435 | e = document.getElementById( elemArray[2] ); 436 | if ( typeof tData['row3_label'] == "undefined" ) 437 | e.innerHTML = "" + tData['row3_value'] + ""; 438 | else { 439 | e.innerHTML = "" + tData['row3_label'] + "" + 440 | "" + tData['row3_value'] + ""; 441 | } 442 | 443 | } 444 | 445 | } 446 | 447 | function log(message) { 448 | 449 | /** 450 | * 451 | * This should be considered an immutable function -- don't attempt to redefine it 452 | * 453 | */ 454 | document.getElementById( "txtLog" ).innerHTML += message + "
"; 455 | document.getElementById( "txtLog" ).scrollTop = document.getElementById( "txtLog" ).scrollHeight; 456 | 457 | } 458 | 459 | function tipOptions(func) { 460 | this.tipOptionsHandler = func; 461 | return(func); 462 | } 463 | 464 | function onDrawPanel(func) { 465 | 466 | // cb.log(func); 467 | this.panelHandler = func; 468 | 469 | return(func); 470 | } 471 | 472 | function onMessage(func) { 473 | 474 | this.mesgHandler = func; 475 | 476 | return func; 477 | 478 | } 479 | 480 | 481 | /** 482 | * 483 | * Avoid changing this 484 | * 485 | * @param func 486 | * @param msecs 487 | */ 488 | function setTimeout(func, msecs) { 489 | 490 | window.setTimeout( func, msecs ); 491 | 492 | } 493 | 494 | function subjectChangeClicked() { 495 | 496 | this.changeRoomSubject( document.getElementById( "txtSubject" ).value ); 497 | 498 | var area = document.getElementById( "txtUserChat" ); 499 | area.innerHTML += "" + 500 | "Room subject changed to: " + document.getElementById( "txtSubject" ).value + "
"; 501 | area.scrollTop = area.scrollHeight; 502 | 503 | area = document.getElementById( "txtBroadcaster" ); 504 | area.innerHTML += "" + 505 | "Room subject changed to: " + document.getElementById( "txtSubject" ).value + "
"; 506 | area.scrollTop = area.scrollHeight; 507 | 508 | 509 | } 510 | 511 | /** 512 | * 513 | * @param toUser 514 | * @param msg1 515 | */ 516 | function sendMsg(toUser, msg1) { 517 | 518 | 519 | this.writeToChatArea( "txtBroadcaster", msg1 ); 520 | this.writeToChatArea( "txtUserChat", msg1 ); 521 | } 522 | 523 | /** 524 | * 525 | * @param targetArea 526 | * @param msg 527 | */ 528 | function writeToChatArea(targetArea, msg) { 529 | 530 | var mstr = ""; 531 | 532 | // 533 | // Check spam flag first and simply return if true 534 | // 535 | if ( msg['X-Spam'] == true ) 536 | return; 537 | 538 | // Handle emotes - the regexes become MUCH easier if this is done before 539 | // any other HTML tagging is done (lot of damn ":"s in HTML) 540 | msg['m'] = insertEmotes( msg['m'] ); 541 | 542 | // 543 | // First set the color of the name 544 | // 545 | // Note: I *intentionally* don't format this with background 546 | // colors - just a personal preference, I find it harder 547 | // to discern the colors on a non-white background. 548 | // 549 | // var cls = " CLASS='class" + msg['user'] + "' "; 550 | if ( msg['user'] == "Notice" ) { 551 | mstr = "" + msg['user'] + ": " 552 | } else if ( msg['user'] == cb.room_slug ) { 553 | mstr = "" + msg['user'] + ": " 554 | } else if ( msg['is_mod'] == true ) { 555 | mstr = "" + msg['user'] + ": " 556 | } else if ( msg['in_fanclub'] == true ) { 557 | mstr = "" + msg['user'] + ": " 558 | } else if ( msg['has_tokens'] == true ) { 559 | mstr = "" + msg['user'] + ": " 560 | } else if ( msg['tipped_recently'] == true ) { 561 | mstr = "" + msg['user'] + ": " 562 | } else 563 | mstr = "" + msg['user'] + ": "; 564 | 565 | mstr = mstr + "" + msg['m'] + ""; 566 | 567 | // End with a newline 568 | mstr = mstr + "
"; 569 | 570 | var area = document.getElementById( targetArea ); 571 | area.innerHTML += mstr; 572 | area.scrollTop = area.scrollHeight; 573 | 574 | } 575 | 576 | function writeToTextarea(targetArea, msg, overWrite) { 577 | 578 | if ( msg.trim() != "" ) { 579 | var area = document.getElementById( targetArea ); 580 | if ( overWrite == true ) { 581 | area.innerHTML = msg.trim() + "\n"; 582 | // area.value = msg.trim() + "\n"; 583 | } else { 584 | area.value += msg.trim() + "\n"; 585 | area.scrollTop = area.scrollHeight; 586 | } 587 | } 588 | } 589 | 590 | function sendClicked(targetField) { 591 | 592 | var msgObj = []; 593 | 594 | if ( document.getElementById( targetField ).value.trim() != "" ) { 595 | if ( targetField == "inBroadcaster" ) { 596 | msgObj = createMesg( this.room_slug, document.getElementById( "inBroadcaster" ).value ); 597 | cb.mesgHandler( msgObj ); 598 | this.sendMsg( this.room_slug, msgObj ); 599 | document.getElementById( targetField ).value = ""; 600 | } else { 601 | var m = document.getElementById( "inUser" ).value; 602 | if ( m.length > 4 ) { 603 | if ( m.search( /^\/tip /i ) == 0 ) { // We have a tip! 604 | var t = parseInt( m.substr( 5 ) ); 605 | var p = (m.substr( 5 )).indexOf( " " ); 606 | var tm = ( p != -1 ? m.substr( p + 6 ) : "" ); 607 | createTippingHTML( t, tm ); 608 | // 609 | // Terminate msg processing and allow onTip to take over after Send Tip clicked 610 | document.getElementById( targetField ).value = ""; 611 | return; 612 | } 613 | } 614 | 615 | 616 | msgObj = createMesg( getSelectedUser(), document.getElementById( "inUser" ).value ); 617 | cb.mesgHandler( msgObj ); 618 | this.sendMsg( getSelectedUser(), msgObj ); 619 | document.getElementById( targetField ).value = ""; 620 | } 621 | 622 | 623 | } 624 | } 625 | 626 | 627 | } 628 | 629 | function objCBUser(username, gender, fanclub, has_tokens, is_mod, tipped_recently) { 630 | 631 | this['u'] = username; 632 | this['gender'] = gender; 633 | this['in_fanclub'] = !!(fanclub == true); // !! ensures true/false value (no nulls) 634 | this['has_tokens'] = !!(has_tokens == true); 635 | this['is_mod'] = !!(is_mod == true); 636 | this['tipped_recently'] = !!(tipped_recently); 637 | 638 | } 639 | 640 | 641 | /** 642 | * 643 | * @param whichDiv 644 | * @param currSettings 645 | */ 646 | function showSettings(whichDiv, currSettings) { 647 | 648 | var str, vStr, currId, f, e, s, selectDefaults = []; 649 | 650 | str = ""; 651 | 652 | /** 653 | * 654 | * Generate the validation functions now . . . 655 | * 656 | * I find it seems to be more reliable to generate 657 | * and " ); 667 | /* var scrpt = document.createElement( "script" ); 668 | scrpt.innerHTML = vStr; 669 | document.body.appendChild( scrpt ); 670 | */ 671 | 672 | for ( s = 0; s < currSettings.length; s++ ) { 673 | if ( currSettings[s].label != undefined ) { 674 | $( whichDiv ).append( "
" + currSettings[s].label + "
" ); 675 | } else { 676 | $( whichDiv ).append( "
" + currSettings[s].name + "
" ); 677 | } 678 | 679 | 680 | // 681 | // For HTML DISPLAY purposes, there's little difference between a string and an int 682 | // 683 | if ( currSettings[s].type == "int" || currSettings[s].type == "str" ) { 684 | 685 | currId = "in" + currSettings[s].name; 686 | 687 | // vStr = createValidationCode( currSettings[s] ); 688 | 689 | str = "
" ); 701 | } else { 702 | if ( currSettings[s].type == "choice" ) { 703 | 704 | currId = "lst" + currSettings[s].name; 705 | 706 | str = "
" 719 | $( whichDiv ).append( str ); 720 | } 721 | } 722 | // f=eval("validate"+currId); 723 | // $("#"+currId ).on("change", f()); 724 | } 725 | 726 | // Now that the "form" is created, set the default for the selects 727 | for ( s = 0; s < selectDefaults.length; s++ ) { 728 | 729 | $( selectDefaults[s].name + " option" ).each( function () { 730 | this.selected = (this.text == selectDefaults[s].defaultValue); 731 | } ); 732 | 733 | } 734 | 735 | 736 | } 737 | 738 | /** 739 | * 740 | * createValidationCode - Takes a single settings object and returns 741 | * a function in string form that can be later used for something useful 742 | * 743 | * @param sc single settings object 744 | * @returns {string} function 745 | */ 746 | function createValidationCode(sc) { 747 | 748 | var fstr, idName, idSelector; 749 | 750 | fstr = ""; 751 | 752 | /** 753 | * 754 | * JS gobbles up the backslash used to escape 755 | * single quotes . . . which causes JQuery to 756 | * choke . . . but here's the kicker: JQuery 757 | * doesn't handle the \ . . . so without it 758 | * the eval fails . . . with it, the string 759 | * is displayed WITH the \ (example: "can\'t") 760 | * . . . so we just punt and replace it with 761 | * a space. 762 | * 763 | */ 764 | if ( typeof sc.label != "undefined" ) { 765 | sc.label = sc.label.replace( /\'/g, " " ); 766 | } 767 | 768 | switch (sc.type) { 769 | case "int": 770 | idName = "in" + sc.name; 771 | idSelector = "#" + idName; 772 | // Eliminate a few JQuery calls 773 | fstr = " var x = " + makeJQS( idSelector ) + ".val().trim(); "; 774 | if ( sc.required == true || typeof sc.required == "undefined" ) { 775 | fstr += " if ( x == '') { " + 776 | " validationError('" + idSelector + "', '" + 777 | useLabel( sc.name, sc.label ) + " is required'); return false;}" 778 | } 779 | // Not a settings_choice . . . just common sense 780 | fstr += " if ( x != '' && isNaN(parseInt( x )) == true ) { " + 781 | " validationError('" + idSelector + "', '" + 782 | useLabel( sc.name, sc.label ) + " must be numeric'); return false;}"; 783 | if ( typeof sc.minValue != "undefined" ) { 784 | fstr += " if (parseInt( x ) < " + sc.minValue + ") { " + 785 | " validationError('" + idSelector + "', '" + useLabel( sc.name, sc.label ) + 786 | " below min. value " + sc.minValue + "'); return false;}" 787 | } 788 | if ( typeof sc.maxValue != "undefined" ) { 789 | fstr += " if (parseInt( x ) > " + sc.maxValue + ") { " + 790 | " validationError('" + idSelector + "', '" + useLabel( sc.name, sc.label ) + 791 | " above max. value " + sc.maxValue + "'); return false;}" 792 | } 793 | fstr += "{ cb.settings['" + sc.name + "'] = parseInt(" + makeJQS( idSelector ) + 794 | ".val());}"; 795 | // alert(fstr); 796 | break; 797 | case "str": 798 | idName = "in" + sc.name; 799 | idSelector = "#" + idName; 800 | // Eliminate a few JQuery calls 801 | fstr = " var x = " + makeJQS( idSelector ) + ".val().trim(); "; 802 | if ( sc.required == true || typeof sc.required == "undefined" ) { 803 | fstr += "if ( x == '') { " + 804 | " validationError('" + idSelector + "', '" + useLabel( sc.name, sc.label ) + 805 | " is required '); return false;}"; 806 | } 807 | if ( sc.minLength != "undefined" ) { 808 | fstr += "if ( x.length < " + sc.minLength + ") { " + 809 | " validationError('" + idSelector + "', '" + useLabel( sc.name, sc.label ) + 810 | " min. length is " + sc.minLength + " '); return false;}"; 811 | } 812 | if ( sc.maxLength != "undefined" ) { 813 | fstr += "if ( x.length > " + sc.maxLength + ") { " + 814 | " validationError('" + idSelector + "', '" + useLabel( sc.name, sc.label ) + 815 | " max. length is " + sc.maxLength + " '); return false;}"; 816 | } 817 | fstr += "{ cb.settings['" + sc.name + "'] = x;}"; 818 | break; 819 | case "choice": 820 | idName = "lst" + sc.name; 821 | idSelector = "#" + idName; 822 | // No error checking here, just add whatever is selected 823 | fstr = "{ cb.settings['" + sc.name + "'] = " + makeJQS( idSelector ) + ".val(); }"; 824 | break; 825 | default: 826 | break; 827 | } 828 | // } 829 | 830 | // fstr = fstr + " return ''; }"; 831 | // alert(fstr); 832 | return "function validate" + idName + "() {" + fstr + "}"; 833 | 834 | } 835 | 836 | function validationError(id, mesg) { 837 | 838 | $( id ).after( "
" + mesg + "
" ); 839 | setTimeout( function () { 840 | $( id ).focus(); 841 | }, 50 ); 842 | } 843 | 844 | function clearErrors() { 845 | 846 | $( ".errorLabel" ).remove(); 847 | 848 | } 849 | 850 | /** 851 | * 852 | * makeJQS - just wraps a JQ selector in "$(' . . . ')" 853 | * to make the sources a little cleaner in 854 | * generated code. 855 | * 856 | * @param tgt 857 | * @returns {string} 858 | */ 859 | function makeJQS(tgt) { 860 | 861 | return "$('" + tgt + "')"; 862 | 863 | } 864 | 865 | function useLabel(sname, slabel) { 866 | 867 | return (typeof slabel == 'undefined' ? sname : slabel); 868 | 869 | } 870 | function btnActivateClicked() { 871 | 872 | //noinspection JSUnresolvedFunction 873 | clearErrors(); 874 | 875 | $( ".settingInput" ).change(); 876 | 877 | if ( $( ".errorLabel" ).length == 0 ) { 878 | $( "#btnActivate" ).prop( "disabled", true ); 879 | $( ".settingInput" ).prop( "disabled", true ); 880 | cb.log( "Validation successful" ); 881 | cb.changeRoomSubject( cb.room_slug + "'s room" ); 882 | if ( ADK.initFunction != "" ) { 883 | /** 884 | * I have mixed feelings about doing this here 885 | * but it *IS* an effective way to seed at least 886 | * some of the settings[] array 887 | * 888 | */ 889 | $( ".settingInput" ).change(); 890 | clearErrors(); 891 | window[ADK.initFunction](); 892 | } 893 | else { 894 | // NOW, it's safe to load the script after the settings_choices have 895 | // been input and validated 896 | loadScript(); 897 | } 898 | 899 | cb.drawPanel(); 900 | 901 | } 902 | else { //noinspection JSUnresolvedFunction 903 | // cb.log( "Validation failed: " + validateSettings() ); 904 | } 905 | 906 | } 907 | 908 | function createTippingHTML(defaultTip, defaultNote) { 909 | 910 | var currTipOptions = cb.tipOptionsHandler( getSelectedUser() ); 911 | 912 | // clear panel first 913 | $( ".tipLabel" ).remove(); 914 | $( ".tipField" ).remove(); 915 | 916 | var hstr; 917 | 918 | // Massage the optional variables 919 | if ( typeof defaultTip == "undefined" ) { 920 | defaultTip = 1; 921 | } 922 | if ( typeof defaultNote == "undefined" ) { 923 | defaultNote = ""; 924 | } 925 | 926 | $( "#Tipping" ).append( "
Tip Amount from " + getSelectedUser() + "
" ) 927 | .append( "" ); 929 | 930 | if ( currTipOptions == null ) { // Display the default note box 931 | $( "#Tipping" ).append( "
Tip Note
" ) 932 | .append( "" ); 934 | } else { 935 | $( "#Tipping" ).append( "
" + currTipOptions['label'] + "
" ) 936 | .append( "