Skip to content

Commit 6915450

Browse files
committed
suabthon
1 parent 370120a commit 6915450

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

subathon/control-panel-main.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ window.controlPanel.serviceModules.registerServiceModuleProvider({
2424
"t2": [true, 480],
2525
"t3": [true, 600],
2626
"sub": [true, 360],
27-
"tip": [true, 600],
28-
"cheer": [true, 240],
27+
"tip": [true, 40],
28+
"cheer": [true, 20],
2929
"follow": [true, 60],
3030

3131
},
@@ -114,6 +114,8 @@ window.controlPanel.serviceModules.registerServiceModuleProvider({
114114
managedData.timeAdditions.follow=[document.getElementById("follow-enabled").checked,formatTime2sec(document.getElementById("follow-duration").value)];
115115
managedData.commands.pause=document.getElementById("pause-command").value;
116116
managedData.commands.resume=document.getElementById("resume-command").value;
117+
managedData.commands.addTime=document.getElementById("addtime-command").value;
118+
117119
managedData.messages.pasueMessage=document.getElementById("pause-message").value;
118120
managedData.messages.endMessage=document.getElementById("end-message").value;
119121
console.log(managedData.timeAdditions);

subathon/controller.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ <h3>Time Additions</h3><br />
114114
<div class="row g-2 mb-3">
115115

116116
<div class="form-check form-switch col">
117-
<label class="form-label" for="tip-duration">Tips</label>
117+
<label class="form-label" for="tip-duration">Tips (per $1)</label>
118118
<input class="form-check-input durationToggle" type="checkbox" role="switch" id="tip-enabled">
119119

120120
</div>
@@ -123,7 +123,7 @@ <h3>Time Additions</h3><br />
123123
<div class="row g-2 mb-3">
124124

125125
<div class="form-check form-switch col">
126-
<label class="form-label" for="cheer-duration">Cheers</label>
126+
<label class="form-label" for="cheer-duration">Cheers (per x500)</label>
127127
<input class="form-check-input durationToggle" type="checkbox" role="switch" id="cheer-enabled">
128128

129129
</div>

subathon/widget-main.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ window.widget.serviceModules.registerServiceModuleProvider({
7171
"t1": [true, 360],
7272
"t2": [true, 480],
7373
"t3": [true, 600],
74-
"tip": [true, 600],
75-
"cheer": [true, 600],
74+
"tip": [true, 40],
75+
"cheer": [true, 20],
7676
"follow": [true, 60],
7777

7878
},
@@ -200,6 +200,7 @@ window.widget.serviceModules.registerServiceModuleProvider({
200200

201201
// Define what happens when we receive an Activity]
202202
async function handle_activityReceived({activity}) {
203+
if (activity.isMock)return;
203204
if (window.widget.persistentStorage.getValue({ key: "state" })!="play") return; // only get events when the timer is running
204205
let str = "";
205206
// Update subathon end timestamp
@@ -225,15 +226,21 @@ window.widget.serviceModules.registerServiceModuleProvider({
225226
break;
226227
case 'tip':
227228
str = managedData.timeAdditions.tip[1];
228-
if (isInt(str) && managedData.timeAdditions.tip[0]) addTime(parseInt(str, 10));
229+
var amount=Math.floor(parseInt(str, 10)*activity.data.amount);
230+
window.widget.bindableData.setValue({key:"subathon_tipAddition",value:amount});
231+
console.log(amount);
232+
if (isInt(str) && managedData.timeAdditions.tip[0]) addTime(amount);
229233
break;
230234
case 'follow':
231235
str = managedData.timeAdditions.follow[1];
232236
if (isInt(str) && managedData.timeAdditions.follow[0]) addTime(parseInt(str, 10));
233237
break;
234238
case 'cheer':
235239
str = managedData.timeAdditions.cheer[1];
236-
if (isInt(str) && managedData.timeAdditions.cheer[0]) addTime(parseInt(str, 10));
240+
var amount=Math.floor(parseInt(str, 10)*activity.data.amount/500);
241+
console.log(amount);
242+
window.widget.bindableData.setValue({key:"subathon_tipAddition",value:amount});
243+
if (isInt(str) && managedData.timeAdditions.cheer[0]) addTime(amount);
237244
break;
238245
}
239246
}

0 commit comments

Comments
 (0)