|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + |
| 4 | +<head> |
| 5 | + <meta charset="utf-8" /> |
| 6 | + <meta |
| 7 | + name="viewport" |
| 8 | + content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,minimal-ui,viewport-fit=cover" /> |
| 9 | + <meta name="apple-mobile-web-app-capable" content="yes" /> |
| 10 | + <meta name="apple-mobile-web-app-status-bar-style" content="black" /> |
| 11 | + <title>de.tml-studios.telemetry Custom Button Property Inspector</title> |
| 12 | + <link rel="stylesheet" href="../../libs/css/sdpi.css" /> |
| 13 | +</head> |
| 14 | + |
| 15 | +<body> |
| 16 | + <!-- Global Settings --> |
| 17 | + <div class="sdpi-wrapper"> |
| 18 | + <form id="property-inspector-global"> |
| 19 | + <div class="sdpi-heading">Global Settings</div> |
| 20 | + <div class="sdpi-item"> |
| 21 | + <div data-localize class="sdpi-item-label" title="TargetIp">Target IP</div> |
| 22 | + <input id="TargetIp" data-localize class="sdpi-item-value" name="TargetIp" type="text" value="" placeholder="127.0.0.1" /> |
| 23 | + </div> |
| 24 | + <div class="sdpi-item"> |
| 25 | + <div data-localize class="sdpi-item-label" title="TargetPort">Target Port</div> |
| 26 | + <input id="TargetPort" data-localize class="sdpi-item-value" name="TargetPort" type="text" value="37337"/> |
| 27 | + </div> |
| 28 | + </form> |
| 29 | + <!-- Local Settings --> |
| 30 | + <form id="property-inspector-local"> |
| 31 | + <div class="sdpi-heading">Control Settings</div> |
| 32 | + <div type="radio" class="sdpi-item" id="Function"> |
| 33 | + <div class="sdpi-item-label">Function</div> |
| 34 | + <div class="sdpi-item-value "> |
| 35 | + <span class="sdpi-item-child"> |
| 36 | + <input id="button" type="radio" value="button" name="ButtonFunctionType" > |
| 37 | + <label for="button" class="sdpi-item-label"><span></span>Button</label> |
| 38 | + </span> |
| 39 | + <span class="sdpi-item-child"> |
| 40 | + <input id="event" type="radio" value="event" name="ButtonFunctionType" checked> |
| 41 | + <label for="event" class="sdpi-item-label"><span></span>Event</label> |
| 42 | + </span> |
| 43 | + </div> |
| 44 | + </div> |
| 45 | + <div type="textarea" class="sdpi-item" id="ActionPress"> |
| 46 | + <div data-localize class="sdpi-item-label" title="OnPressAction">On Press</div> |
| 47 | + <input id="OnPressActionData" data-localize class="sdpi-item-value" name="OnPressAction" type="text" placeholder='Event: MotorStartStop'/> |
| 48 | + </div> |
| 49 | + <div type="textarea" class="sdpi-item" id="ActionRelease"> |
| 50 | + <div data-localize class="sdpi-item-label" title="OnReleaseAction">On Release</div> |
| 51 | + <input id="OnReleaseActionData" data-localize class="sdpi-item-value" name="OnReleaseAction" type="text" placeholder='Button: {"button":"GearSwitch", "state":"0"}'/> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div class="sdpi-heading">Icon Settings</div> |
| 55 | + |
| 56 | + <div type="radio" class="sdpi-item" id="FeedbackSourceType"> |
| 57 | + <div class="sdpi-item-label">Feedback Source</div> |
| 58 | + <div class="sdpi-item-value"> |
| 59 | + <span class="sdpi-item-child"> |
| 60 | + <input id="off" type="radio" value="off" name="ButtonFeedbackType" > |
| 61 | + <label for="off" class="sdpi-item-label"><span></span>Off</label> |
| 62 | + </span> |
| 63 | + <span class="sdpi-item-child"> |
| 64 | + <input id="buttonstate" type="radio" value="button" name="ButtonFeedbackType" checked> |
| 65 | + <label for="buttonstate" class="sdpi-item-label"><span></span>Button State</label> |
| 66 | + </span> |
| 67 | + <span class="sdpi-item-child"> |
| 68 | + <input id="light" type="radio" value="light" name="ButtonFeedbackType" checked> |
| 69 | + <label for="light" class="sdpi-item-label"><span></span>Light State</label> |
| 70 | + </span> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + <div type="textarea" class="sdpi-item" id="SourceName"> |
| 74 | + <div data-localize class="sdpi-item-label" title="SourceName">Source</div> |
| 75 | + <input id="SourceName" data-localize class="sdpi-item-value" name="SourceName" type="text"/> |
| 76 | + </div> |
| 77 | + <div type="textarea" class="sdpi-item" id="TrueState"> |
| 78 | + <div data-localize class="sdpi-item-label" title="TrueState">True State</div> |
| 79 | + <input id="TrueState" data-localize class="sdpi-item-value" name="TrueState" type="text"/> |
| 80 | + </div> |
| 81 | + </form> |
| 82 | + <hr> |
| 83 | + <form id="property-inspector-iconDefault"> |
| 84 | + <div class="sdpi-item" id="DefaultIconSelector"> |
| 85 | + <div class="sdpi-item-label">Default Icon</div> |
| 86 | + <input class="sdpi-item-value" id="DefaultIcon" type="file" accept=".jpg, .jpeg, .png"> |
| 87 | + </div> |
| 88 | + <div class="sdpi-item"> |
| 89 | + <div class="sdpi-item-label">Selected File</div> |
| 90 | + <div class="sdpi-item-item" id="DefaultIconLabel">no file</div> |
| 91 | + </div> |
| 92 | + </form> |
| 93 | + <form id="property-inspector-iconTrue"> |
| 94 | + <div class="sdpi-item" id="TrueIconSelector"> |
| 95 | + <div class="sdpi-item-label">True Icon</div> |
| 96 | + <input class="sdpi-item-value" id="TrueIcon" type="file" accept=".jpg, .jpeg, .png"> |
| 97 | + </div> |
| 98 | + <div class="sdpi-item"> |
| 99 | + <div class="sdpi-item-label">Selected File</div> |
| 100 | + <div class="sdpi-item-item" id="TrueIconLabel">no file</div> |
| 101 | + </div> |
| 102 | + |
| 103 | + |
| 104 | + </form> |
| 105 | + </div> |
| 106 | + |
| 107 | + <div class="sdpi-info-label hidden" style="top: -1000" value=""></div> |
| 108 | + |
| 109 | + <!-- Stream Deck Libs --> |
| 110 | + <script src="../../libs/js/constants.js"></script> |
| 111 | + <script src="../../libs/js/prototypes.js"></script> |
| 112 | + <script src="../../libs/js/timers.js"></script> |
| 113 | + <script src="../../libs/js/utils.js"></script> |
| 114 | + <script src="../../libs/js/events.js"></script> |
| 115 | + <script src="../../libs/js/api.js"></script> |
| 116 | + <script src="../../libs/js/property-inspector.js"></script> |
| 117 | + <script src="../../libs/js/dynamic-styles.js"></script> |
| 118 | + |
| 119 | + <script> |
| 120 | + |
| 121 | + var globalDefaultIcon = ""; |
| 122 | + var globalTrueIcon = ""; |
| 123 | + |
| 124 | + $PI.onConnected((jsn) => { |
| 125 | + const formGlobal = document.querySelector('#property-inspector-global'); |
| 126 | + const formLocal = document.querySelector('#property-inspector-local'); |
| 127 | + const formLocalIconTrue = document.querySelector('#property-inspector-iconTrue'); |
| 128 | + const formLocalIconDefault = document.querySelector('#property-inspector-iconDefault'); |
| 129 | + const {actionInfo, appInfo, connection, messageType, port, uuid} = jsn; |
| 130 | + const {payload, context} = actionInfo; |
| 131 | + const {settings} = payload; |
| 132 | + |
| 133 | + |
| 134 | + Utils.setFormValue(settings, formLocal); |
| 135 | + console.log(settings); |
| 136 | + |
| 137 | + if(settings["TrueIcon"] === undefined) |
| 138 | + { |
| 139 | + settings["TrueIcon"] = ""; |
| 140 | + } |
| 141 | + |
| 142 | + if(settings["DefaultIcon"] === undefined) |
| 143 | + { |
| 144 | + settings["DefaultIcon"] = ""; |
| 145 | + } |
| 146 | + |
| 147 | + globalTrueIcon = settings["TrueIcon"].toString(); |
| 148 | + globalDefaultIcon = settings["DefaultIcon"].toString(); |
| 149 | + document.getElementById("TrueIconLabel").textContent = makeFileLabel(globalTrueIcon); |
| 150 | + document.getElementById("DefaultIconLabel").textContent = makeFileLabel(globalDefaultIcon); |
| 151 | + |
| 152 | + function makeFileLabel(file) |
| 153 | + { |
| 154 | + if(file == "") |
| 155 | + { |
| 156 | + return("no file selected"); |
| 157 | + } |
| 158 | + |
| 159 | + return(file.replace(/^.*[\\/]/, '')); |
| 160 | + } |
| 161 | + |
| 162 | + $PI.getGlobalSettings(); |
| 163 | + |
| 164 | + formGlobal.addEventListener( 'input', Utils.debounce(150, () => { |
| 165 | + const value = Utils.getFormValue(formGlobal); |
| 166 | + console.log('SetGlobalSettings', value); |
| 167 | + $PI.setGlobalSettings(value); |
| 168 | + }) |
| 169 | + ); |
| 170 | + |
| 171 | + formLocal.addEventListener('input', Utils.debounce(150, () => { |
| 172 | + UpdateSettings(); |
| 173 | + })); |
| 174 | + |
| 175 | + function UpdateSettings() |
| 176 | + { |
| 177 | + const value = Utils.getFormValue(formLocal); |
| 178 | + |
| 179 | + var TrueIconPath = document.getElementById("TrueIcon").value; |
| 180 | + TrueIconPath = decodeURIComponent(TrueIconPath.replace(/^C:\\fakepath\\/, '')); |
| 181 | + |
| 182 | + value["TrueIcon"] = globalTrueIcon; |
| 183 | + value["DefaultIcon"] = globalDefaultIcon; |
| 184 | + |
| 185 | + console.log(value); |
| 186 | + $PI.setSettings(value); |
| 187 | + } |
| 188 | + |
| 189 | + formLocalIconDefault.addEventListener('input', Utils.debounce(150, () => { |
| 190 | + var IconPath = document.getElementById("DefaultIcon").value; |
| 191 | + globalDefaultIcon = decodeURIComponent(IconPath.replace(/^C:\\fakepath\\/, '')); |
| 192 | + document.getElementById("DefaultIconLabel").textContent = makeFileLabel(globalDefaultIcon); |
| 193 | + UpdateSettings(); |
| 194 | + })); |
| 195 | + |
| 196 | + formLocalIconTrue.addEventListener('input', Utils.debounce(150, () => { |
| 197 | + var IconPath = document.getElementById("TrueIcon").value; |
| 198 | + globalTrueIcon = decodeURIComponent(IconPath.replace(/^C:\\fakepath\\/, '')); |
| 199 | + document.getElementById("TrueIconLabel").textContent = makeFileLabel(globalTrueIcon); |
| 200 | + UpdateSettings(); |
| 201 | + })); |
| 202 | + }); |
| 203 | + |
| 204 | + $PI.onDidReceiveGlobalSettings(({payload}) => { |
| 205 | + console.log('onDidReceiveGlobalSettings', payload); |
| 206 | + document.getElementById("TargetIp").value = payload.settings.TargetIp; |
| 207 | + document.getElementById("TargetPort").value = payload.settings.TargetPort; |
| 208 | + }) |
| 209 | + |
| 210 | + </script> |
| 211 | + |
| 212 | +</body> |
| 213 | + |
| 214 | +</html> |
0 commit comments