Resolve a few property inspector issues
This commit is contained in:
parent
e5aec34450
commit
4a7f7eef5f
@ -38,7 +38,7 @@
|
|||||||
"Name": "Remote",
|
"Name": "Remote",
|
||||||
"Icon": "images/pluginIcon",
|
"Icon": "images/pluginIcon",
|
||||||
"URL": "https://www.elgato.com/gaming/stream-deck",
|
"URL": "https://www.elgato.com/gaming/stream-deck",
|
||||||
"Version": "1.2",
|
"Version": "1.2.1",
|
||||||
"SDKVersion": 2,
|
"SDKVersion": 2,
|
||||||
"OS": [
|
"OS": [
|
||||||
{
|
{
|
||||||
|
@ -4,8 +4,11 @@ var websocket = null,
|
|||||||
uuid = null,
|
uuid = null,
|
||||||
actionInfo = {},
|
actionInfo = {},
|
||||||
settings = {},
|
settings = {},
|
||||||
|
globalSettings = {},
|
||||||
isQT = navigator.appVersion.includes('QtWebEngine'); // 'oninput'; // change this, if you want interactive elements act on any change, or while they're modified
|
isQT = navigator.appVersion.includes('QtWebEngine'); // 'oninput'; // change this, if you want interactive elements act on any change, or while they're modified
|
||||||
|
|
||||||
|
const websiteAction = 'tf.meow.remote.website';
|
||||||
|
|
||||||
function connectSocket (
|
function connectSocket (
|
||||||
inPort,
|
inPort,
|
||||||
inUUID,
|
inUUID,
|
||||||
@ -50,12 +53,25 @@ function connectElgatoStreamDeckSocket (inPort, inUUID, inRegisterEvent, inInfo,
|
|||||||
};
|
};
|
||||||
|
|
||||||
websocket.send(JSON.stringify(json));
|
websocket.send(JSON.stringify(json));
|
||||||
|
|
||||||
|
if (isAction(websiteAction)) {
|
||||||
|
getGlobalSettings();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
websocket.onmessage = function (evt) {
|
websocket.onmessage = function (evt) {
|
||||||
// Received message from Stream Deck
|
// Received message from Stream Deck
|
||||||
var jsonObj = JSON.parse(evt.data);
|
let jsonObj = JSON.parse(evt.data);
|
||||||
var event = jsonObj['event'];
|
|
||||||
|
let event = jsonObj['event'];
|
||||||
|
|
||||||
|
console.log('Got event', event);
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case 'didReceiveGlobalSettings':
|
||||||
|
didReceiveGlobalSettings(jsonObj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,43 +82,71 @@ function initPropertyInspector(initDelay) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(settings).forEach(function (item) {
|
Object.keys(settings).forEach(function (item) {
|
||||||
$('#' + item).val(settings[item]);
|
let $item = $('#' + item),
|
||||||
|
value = settings[item];
|
||||||
|
|
||||||
|
console.log('Load setting', item, 'value', value);
|
||||||
|
|
||||||
|
switch ($item.attr('type')) {
|
||||||
|
case 'checkbox':
|
||||||
|
let itemVal = $item.attr('value');
|
||||||
|
|
||||||
|
if (itemVal == 'false' || itemVal == 'true') {
|
||||||
|
itemVal = (/^true$/i).test(itemVal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemVal === value) {
|
||||||
|
$item.prop('checked', true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$item.val(value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('input').each(function() {
|
$('input').each(function() {
|
||||||
var $this = $(this),
|
let $this = $(this),
|
||||||
id = $this.attr('id');
|
id = $this.attr('id');
|
||||||
|
|
||||||
let $item = $this.closest('.sdpi-item');
|
let $item = $this.closest('.sdpi-item');
|
||||||
|
|
||||||
$this.on('change', function(e) {
|
$this.on('change', function() {
|
||||||
const type = $this.attr('type');
|
const type = $this.attr('type');
|
||||||
|
|
||||||
if (type) {
|
|
||||||
const info = $item.find('.sdpi-file-info');
|
|
||||||
|
|
||||||
if (info) {
|
|
||||||
const s = decodeURIComponent($this.val().replace(/^C:\\fakepath\\/, '')).split('/').pop();
|
|
||||||
|
|
||||||
info.text(s.length > 28
|
|
||||||
? s.substr(0, 10)
|
|
||||||
+ '...'
|
|
||||||
+ s.substr(s.length - 10, s.length)
|
|
||||||
: s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let val = $this.val();
|
let val = $this.val();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'checkbox':
|
case 'checkbox':
|
||||||
|
// If unchecked, unset the setting
|
||||||
|
if (!this.checked) {
|
||||||
|
removeSetting(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (val == 'false' || val == 'true') {
|
if (val == 'false' || val == 'true') {
|
||||||
val = (/^true$/i).test(val);
|
val = (/^true$/i).test(val);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'file':
|
||||||
|
const info = $item.find('.sdpi-file-info');
|
||||||
|
|
||||||
|
if (info) {
|
||||||
|
const s = decodeURIComponent($this.val().replace(/^C:\\fakepath\\/, '')).split('/').pop();
|
||||||
|
|
||||||
|
info.text(s.length > 28
|
||||||
|
? s.substr(0, 10)
|
||||||
|
+ '...'
|
||||||
|
+ s.substr(s.length - 10, s.length)
|
||||||
|
: s);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSetting(id, val);
|
updateSetting(id, val);
|
||||||
|
|
||||||
|
if (isAction(websiteAction) && (id == 'remote_host' || id == 'remote_token')) {
|
||||||
|
updateGlobalSetting(id, val);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -111,19 +155,20 @@ function initPropertyInspector(initDelay) {
|
|||||||
// Hide passphrase field
|
// Hide passphrase field
|
||||||
$('#ssh_key_passphrase_container').hide();
|
$('#ssh_key_passphrase_container').hide();
|
||||||
$('#ssh_password_container').show();
|
$('#ssh_password_container').show();
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
$('#ssh_password_container').hide();
|
$('#ssh_password_container').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
var f = e.target.files[0];
|
let f = e.target.files[0];
|
||||||
|
|
||||||
var reader = new FileReader();
|
let reader = new FileReader();
|
||||||
|
|
||||||
// Closure to capture the file information.
|
// Closure to capture the file information.
|
||||||
reader.onload = function(e) {
|
reader.onload = function(e) {
|
||||||
var result = e.target.result;
|
let result = e.target.result;
|
||||||
|
|
||||||
var pki = forge.pki;
|
let pki = forge.pki;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pki.privateKeyFromPem(result);
|
pki.privateKeyFromPem(result);
|
||||||
@ -259,8 +304,18 @@ function updateSetting(setting, value) {
|
|||||||
setSettings(settings);
|
setSettings(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeSetting(setting) {
|
||||||
|
if (!settings) {
|
||||||
|
settings = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
delete settings[setting];
|
||||||
|
|
||||||
|
setSettings(settings);
|
||||||
|
}
|
||||||
|
|
||||||
function setSettings(settings) {
|
function setSettings(settings) {
|
||||||
var json = {
|
let json = {
|
||||||
"event": "setSettings",
|
"event": "setSettings",
|
||||||
"context": uuid,
|
"context": uuid,
|
||||||
"payload": settings
|
"payload": settings
|
||||||
@ -268,7 +323,49 @@ function setSettings(settings) {
|
|||||||
|
|
||||||
if (websocket) {
|
if (websocket) {
|
||||||
websocket.send(JSON.stringify(json));
|
websocket.send(JSON.stringify(json));
|
||||||
} else {
|
|
||||||
console.log('Update:', json);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateGlobalSetting(id, val) {
|
||||||
|
globalSettings[id] = val;
|
||||||
|
|
||||||
|
setGlobalSettings(globalSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGlobalSettings() {
|
||||||
|
let json = {
|
||||||
|
"event": "getGlobalSettings",
|
||||||
|
"context": uuid
|
||||||
|
};
|
||||||
|
|
||||||
|
if (websocket) {
|
||||||
|
websocket.send(JSON.stringify(json));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setGlobalSettings(settings) {
|
||||||
|
let json = {
|
||||||
|
"event": "setGlobalSettings",
|
||||||
|
"context": uuid,
|
||||||
|
"payload": settings
|
||||||
|
};
|
||||||
|
|
||||||
|
if (websocket) {
|
||||||
|
websocket.send(JSON.stringify(json));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function didReceiveGlobalSettings(obj) {
|
||||||
|
globalSettings = getPropFromString(obj, 'payload.settings');
|
||||||
|
|
||||||
|
// Load defaults for fields not set
|
||||||
|
Object.keys(globalSettings).forEach(function(item) {
|
||||||
|
if (!(item in settings)) {
|
||||||
|
$('#' + item).val(globalSettings[item]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function isAction(action) {
|
||||||
|
return actionInfo['action'] === action;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user