split scripts and update to es6

This commit is contained in:
grafixeyehero 2021-05-13 22:21:00 +03:00
parent 02466ede4b
commit 4a873aa42d
5 changed files with 125 additions and 128 deletions

View File

@ -1,123 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>TVHeadEnd</title>
</head>
<body>
<div data-role="page" class="page type-interior pluginConfigurationPage TVHclientConfigurationPage">
<div data-role="content">
<div class="content-primary">
<form class="TVHclientConfigurationForm">
<div class="inputContainer">
<input is="emby-input" type="text" id="txtTVH_ServerName" label="TVHeadend Hostname or IP Address" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtHTTP_Port" label="HTTP Port" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtHTSP_Port" label="HTSP Port" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtWebRoot" label="Web Root" />
<div class="fieldDescription">This path will be added to HOSTNAME:PORT on the end of the URL. It should be '/' if you don't have a custom setup.</div>
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtUserName" label="Username" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtPassword" label="Password" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtPriority" label="Priority of Recordings" />
<div class="fieldDescription">0 = Important, 1 = High, 2 = Normal, 3 = Low, 4 = Unimportant</div>
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtProfile" label="Profile for Recordings" />
</div>
<div class="selectContainer">
<select is="emby-select" id="selChannelType" label="Use this channel type for channels tagged with Other">
<option>TV</option>
<option>Radio</option>
<option>Ignore</option>
</select>
</div>
<div class="checkboxContainer">
<label>
<input is="emby-checkbox" type="checkbox" id="chkHideRecordingsChannel" />
<span>Hide TVHeadEnd Recordings channel</span>
</label>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input is="emby-checkbox" type="checkbox" id="chkEnableSubsMaudios" />
<span>Enable live TV subtitles and multiple audio tracks (Experimental)</span>
</label>
<div class="fieldDescription checkboxFieldDescription">Note: Enabling this feature has security implications and will require a server restart. (TVH username and password will appear in server logs and will be transmitted in cleartext over the network)</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input is="emby-checkbox" type="checkbox" id="chkForceDeinterlace" />
<span>Force video deinterlacing for all channels and recordings. (Experimental)</span>
</label>
<div class="fieldDescription checkboxFieldDescription">Note: Changing this requires a server restart.</div>
</div>
<div>
<button is="emby-button" type="submit" class="raised button-submit block">
<span>Save</span>
</button>
</div>
</form>
</div>
</div>
<script type="text/javascript">
var TVHclientConfigurationPageVar = {
pluginUniqueId: "3fd018e5-5e78-4e58-b280-a0c068febee0"
};
document.querySelector('.TVHclientConfigurationPage').addEventListener('pageshow', function (event) {
Dashboard.showLoadingMsg();
var page = this;
ApiClient.getPluginConfiguration(TVHclientConfigurationPageVar.pluginUniqueId).then(function(config) {
page.querySelector('#txtTVH_ServerName').value = config.TVH_ServerName || "";
page.querySelector('#txtHTTP_Port').value = config.HTTP_Port || "9981";
page.querySelector('#txtHTSP_Port').value = config.HTSP_Port || "9982";
page.querySelector('#txtWebRoot').value = config.WebRoot || "/";
page.querySelector('#txtUserName').value = config.Username || "";
page.querySelector('#txtPassword').value = config.Password || "";
page.querySelector('#txtPriority').value = config.Priority || "5";
page.querySelector('#txtProfile').value = config.Profile || "";
page.querySelector('#selChannelType').value = config.ChannelType || "Ignore";
page.querySelector('#chkHideRecordingsChannel').checked = config.HideRecordingsChannel || false;
page.querySelector('#chkEnableSubsMaudios').checked = config.EnableSubsMaudios || false;
page.querySelector('#chkForceDeinterlace').checked = config.ForceDeinterlace || false;
Dashboard.hideLoadingMsg();
});
});
document.querySelector('.TVHclientConfigurationForm').addEventListener('submit', function (e) {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getPluginConfiguration(TVHclientConfigurationPageVar.pluginUniqueId).then(function(config) {
config.TVH_ServerName = form.querySelector('#txtTVH_ServerName').value;
config.HTTP_Port = form.querySelector('#txtHTTP_Port').value;
config.HTSP_Port = form.querySelector('#txtHTSP_Port').value;
config.WebRoot = form.querySelector('#txtWebRoot').value;
config.Username = form.querySelector('#txtUserName').value;
config.Password = form.querySelector('#txtPassword').value;
config.Priority = form.querySelector('#txtPriority').value;
config.Profile = form.querySelector('#txtProfile').value;
config.ChannelType = form.querySelector('#selChannelType').value;
config.HideRecordingsChannel = form.querySelector('#chkHideRecordingsChannel').checked;
config.EnableSubsMaudios = form.querySelector('#chkEnableSubsMaudios').checked;
config.ForceDeinterlace = form.querySelector('#chkForceDeinterlace').checked;
ApiClient.updatePluginConfiguration(TVHclientConfigurationPageVar.pluginUniqueId, config).then(Dashboard.processPluginConfigurationUpdateResult);
});
return false;
});
</script>
</div>
</body>
</html>

View File

@ -27,8 +27,13 @@ namespace TVHeadEnd
{
new PluginPageInfo
{
Name = Name,
EmbeddedResourcePath = GetType().Namespace + ".Configuration.configPage.html"
Name = "tvheadend",
EmbeddedResourcePath = GetType().Namespace + ".Web.tvheadend.html",
},
new PluginPageInfo
{
Name = "tvheadendjs",
EmbeddedResourcePath = GetType().Namespace + ".Web.tvheadend.js"
}
};
}
@ -66,5 +71,5 @@ namespace TVHeadEnd
/// <value>The instance.</value>
public static Plugin Instance { get; private set; }
}
}

View File

@ -7,8 +7,10 @@
</PropertyGroup>
<ItemGroup>
<None Remove="Configuration\configPage.html" />
<EmbeddedResource Include="Configuration\configPage.html" />
<None Remove="Web\tvheadend.html" />
<None Remove="Web\tvheadend.js" />
<EmbeddedResource Include="Web\tvheadend.html" />
<EmbeddedResource Include="Web\tvheadend.js" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,67 @@
<div id="TVHclientConfigurationPage" data-role="page" class="page type-interior pluginConfigurationPage" data-controller="__plugin/tvheadendjs">
<div data-role="content">
<div class="content-primary">
<form class="TVHclientConfigurationForm">
<div class="inputContainer">
<input is="emby-input" type="text" id="txtTVH_ServerName" label="TVHeadend Hostname or IP Address" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtHTTP_Port" label="HTTP Port" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtHTSP_Port" label="HTSP Port" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtWebRoot" label="Web Root" />
<div class="fieldDescription">This path will be added to HOSTNAME:PORT on the end of the URL. It should be '/' if you don't have a custom setup.</div>
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtUserName" label="Username" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtPassword" label="Password" />
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtPriority" label="Priority of Recordings" />
<div class="fieldDescription">0 = Important, 1 = High, 2 = Normal, 3 = Low, 4 = Unimportant</div>
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtProfile" label="Profile for Recordings" />
</div>
<div class="selectContainer">
<select is="emby-select" id="selChannelType" label="Use this channel type for channels tagged with Other">
<option>TV</option>
<option>Radio</option>
<option>Ignore</option>
</select>
</div>
<div class="checkboxContainer">
<label>
<input is="emby-checkbox" type="checkbox" id="chkHideRecordingsChannel" />
<span>Hide TVHeadEnd Recordings channel</span>
</label>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input is="emby-checkbox" type="checkbox" id="chkEnableSubsMaudios" />
<span>Enable live TV subtitles and multiple audio tracks (Experimental)</span>
</label>
<div class="fieldDescription checkboxFieldDescription">Note: Enabling this feature has security implications and will require a server restart. (TVH username and password will appear in server logs and will be transmitted in cleartext over the network)</div>
</div>
<div class="checkboxContainer checkboxContainer-withDescription">
<label>
<input is="emby-checkbox" type="checkbox" id="chkForceDeinterlace" />
<span>Force video deinterlacing for all channels and recordings. (Experimental)</span>
</label>
<div class="fieldDescription checkboxFieldDescription">Note: Changing this requires a server restart.</div>
</div>
<div>
<button is="emby-button" type="submit" class="raised button-submit block">
<span>Save</span>
</button>
</div>
</form>
</div>
</div>
</div>

View File

@ -0,0 +1,46 @@
const TVHclientConfigurationPageVar = {
pluginUniqueId: '3fd018e5-5e78-4e58-b280-a0c068febee0'
};
export default function (view, params) {
view.addEventListener('viewshow', function () {
Dashboard.showLoadingMsg();
const page = this;
ApiClient.getPluginConfiguration(TVHclientConfigurationPageVar.pluginUniqueId).then(function(config) {
page.querySelector('#txtTVH_ServerName').value = config.TVH_ServerName || '';
page.querySelector('#txtHTTP_Port').value = config.HTTP_Port || '9981';
page.querySelector('#txtHTSP_Port').value = config.HTSP_Port || '9982';
page.querySelector('#txtWebRoot').value = config.WebRoot || '/';
page.querySelector('#txtUserName').value = config.Username || '';
page.querySelector('#txtPassword').value = config.Password || '';
page.querySelector('#txtPriority').value = config.Priority || '5';
page.querySelector('#txtProfile').value = config.Profile || '';
page.querySelector('#selChannelType').value = config.ChannelType || 'Ignore';
page.querySelector('#chkHideRecordingsChannel').checked = config.HideRecordingsChannel || false;
page.querySelector('#chkEnableSubsMaudios').checked = config.EnableSubsMaudios || false;
page.querySelector('#chkForceDeinterlace').checked = config.ForceDeinterlace || false;
Dashboard.hideLoadingMsg();
});
});
view.querySelector('.TVHclientConfigurationForm').addEventListener('submit', function (e) {
e.preventDefault();
Dashboard.showLoadingMsg();
const form = this;
ApiClient.getPluginConfiguration(TVHclientConfigurationPageVar.pluginUniqueId).then(function(config) {
config.TVH_ServerName = form.querySelector('#txtTVH_ServerName').value;
config.HTTP_Port = form.querySelector('#txtHTTP_Port').value;
config.HTSP_Port = form.querySelector('#txtHTSP_Port').value;
config.WebRoot = form.querySelector('#txtWebRoot').value;
config.Username = form.querySelector('#txtUserName').value;
config.Password = form.querySelector('#txtPassword').value;
config.Priority = form.querySelector('#txtPriority').value;
config.Profile = form.querySelector('#txtProfile').value;
config.ChannelType = form.querySelector('#selChannelType').value;
config.HideRecordingsChannel = form.querySelector('#chkHideRecordingsChannel').checked;
config.EnableSubsMaudios = form.querySelector('#chkEnableSubsMaudios').checked;
config.ForceDeinterlace = form.querySelector('#chkForceDeinterlace').checked;
ApiClient.updatePluginConfiguration(TVHclientConfigurationPageVar.pluginUniqueId, config).then(Dashboard.processPluginConfigurationUpdateResult);
});
return false;
});
}