MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / incrementSetting

Method incrementSetting

contributed/modClock/main.js:1035–1125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1033 drawYesNo(d) { 1 == d ? this.display.value(" yes") : this.display.value(" no"); }
1034
1035 incrementSetting() {
1036 let b;
1037 switch (this.uiState) {
1038 case STATE_SET_DST:
1039 this.prefs.dst = this.prefs.dst ? 0 : 1;
1040 this.drawOnOff(this.prefs.dst);
1041 break;
1042 case STATE_SET_2412:
1043 this.prefs.twelve = this.prefs.twelve ? 0 : 1;
1044 this.draw2412(this.prefs.twelve);
1045 break;
1046 case STATE_SET_BRIGHT:
1047 b = this.prefs.brightness;
1048 b += 10;
1049 if (b > 255) b = 5;
1050 this.prefs.brightness = b;
1051 this.display.value(b);
1052 break;
1053 case STATE_SET_TAIL_BRIGHT:
1054 b = this.prefs.tail_brightness;
1055 b += 10;
1056 if (b > 255) b = 0;
1057 this.prefs.tail_brightness = b;
1058 this.display.value(b);
1059 break;
1060 case STATE_SET_TAIL:
1061 this.confirm = this.confirm ? 0 : 1;
1062 this.drawYesNo(this.confirm);
1063 this.prefs.tail_on = this.confirm;
1064 break;
1065 case STATE_CLEAR_CONFIRM:
1066 case STATE_BOOT_CONFIRM:
1067 case STATE_SET_DONE:
1068 this.confirm = this.confirm ? 0 : 1;
1069 this.drawYesNo(this.confirm);
1070 break;
1071 case STATE_SHOW_TIME:
1072 this.currentStyle.next_kind();
1073 this.display.showTime(this.currentStyle);
1074 this.prefs.savePref(this.currentStyle);
1075 break;
1076 case STATE_SET_HOURS:
1077 case STATE_SET_10MINUTES:
1078 case STATE_SET_MINUTES:
1079 let nowTime = Date.now() / 1000;
1080 let d = new Date();
1081 let timeVal = d.getHours() * 100 + d.getMinutes();
1082 let h = (timeVal / 100) | 0;
1083 let m10 = ((timeVal % 100) / 10) | 0;
1084 let m1 = (timeVal % 10) | 0;
1085 if (STATE_SET_HOURS === this.uiState) {
1086 h += 1;
1087 if (h > 23) {
1088 h = 0;
1089 nowTime -= (60 * 60) * 23;
1090 }
1091 else
1092 nowTime += 60 * 60;

Callers 2

rightReleasedMethod · 0.80
rightStillDownMethod · 0.80

Calls 11

drawOnOffMethod · 0.95
draw2412Method · 0.95
drawYesNoMethod · 0.95
drawHoursMethod · 0.95
draw10MinMethod · 0.95
drawMinMethod · 0.95
next_kindMethod · 0.80
showTimeMethod · 0.80
savePrefMethod · 0.80
setMethod · 0.65
valueMethod · 0.45

Tested by

no test coverage detected