-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:pre-martin/StreamDeckSimHubPlugin
- Loading branch information
Showing
10 changed files
with
64 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Iterates over all elements in the array "settingIds", retrieves the values of their corresponding HTML elements, and stores | ||
* them in a payload structure. This structure can be saved by the Property Inspector. | ||
*/ | ||
const buildSettings = (settingIds) => { | ||
let settings = {}; | ||
for (const id of settingIds) { | ||
const element = document.getElementById(id); | ||
if (!element) { | ||
console.log('buildSettings: Could not find element ' + id + ' on page'); | ||
$PI.logMessage('buildSettings: Could not find element ' + id + ' on page'); | ||
continue; | ||
} | ||
if (element.getAttribute('type') === 'checkbox') { | ||
settings[id] = element.checked; | ||
} else { | ||
settings[id] = element.value; | ||
} | ||
} | ||
|
||
return settings; | ||
} | ||
|
||
/** | ||
* Iterates over the structure "settings". The keys are used to find corresponding HTML elements, the value is then set | ||
* as value of the HTML element. | ||
*/ | ||
const restoreSettings = (settings) => { | ||
for (const id in settings) { | ||
try { | ||
const element = document.getElementById(id); | ||
if (element.getAttribute('type') === 'checkbox') { | ||
element.checked = settings[id]; | ||
} else { | ||
element.value = settings[id]; | ||
} | ||
} catch (err) { | ||
console.log('loadSettings failed for id ' + id + ': ' + err); | ||
$PI.logMessage('loadSettings failed for id ' + id + ': ' + err); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters