From 6d6d2b4e93599ba4cb045f2a91745e24eed2c1ea Mon Sep 17 00:00:00 2001 From: softworkz Date: Tue, 23 Aug 2016 02:15:23 +0200 Subject: [PATCH] Update MetadataViewer --- MetadataViewer/Html/metadataviewer.js | 108 +++-- .../Html/metadataviewer.template.html | 427 +++++++++--------- 2 files changed, 269 insertions(+), 266 deletions(-) diff --git a/MetadataViewer/Html/metadataviewer.js b/MetadataViewer/Html/metadataviewer.js index 6d22a745..20dec098 100644 --- a/MetadataViewer/Html/metadataviewer.js +++ b/MetadataViewer/Html/metadataviewer.js @@ -1,4 +1,4 @@ -define(['dialogHelper', 'paper-fab', 'paper-input', 'paper-checkbox', 'detailtablecss'], function (paperDialogHelper) { +define(['dialogHelper', 'detailtablecss', 'emby-button', 'emby-select', 'formDialogStyle'], function (dialogHelper) { var currentItem; var currentItemType; @@ -13,7 +13,7 @@ ApiClient.getJSON(ApiClient.getUrl('Items/' + item.Id + '/MetadataRaw', { language: lang })).then(function (table) { - var htmlLookup = ''; + var htmlLookup = '
'; for (var i = 0; i < table.LookupData.length; i++) { @@ -24,7 +24,7 @@ } else { - htmlLookup += ''; + htmlLookup += ''; htmlLookup += ''; } } @@ -32,20 +32,21 @@ htmlLookup += '
' + row.Key + '
' + row.Key + '' + row.Value + '
'; page.querySelector('#searchCriteria').innerHTML = htmlLookup; - var html = ''; + var html = '
'; html += ''; } html += ''; - html += ''; + html += ''; - for (var i = 0; i < table.Rows.length; i++) { + for (i = 0; i < table.Rows.length; i++) { - var row = table.Rows[i]; - html += ''; + row = table.Rows[i]; + html += ''; for (var n = 0; n < row.Values.length; n++) { html += ''; @@ -62,76 +63,71 @@ }); } - function onDialogClosed() { + return { + show: function (itemId) { + return new Promise(function (resolve, reject) { - Dashboard.hideLoadingMsg(); - currentDeferred.resolveWith(null, [hasChanges]); - } + var xhr = new XMLHttpRequest(); + xhr.open('GET', 'components/metadataviewer/metadataviewer.template.html', true); - function showEditor(itemId) { + xhr.onload = function (e) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', 'components/metadataviewer/metadataviewer.template.html', true); + var template = this.response; - xhr.onload = function (e) { + ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) { - var template = this.response; + var dlg = dialogHelper.createDialog({ + size: 'large' + }); - ApiClient.getItem(Dashboard.getCurrentUserId(), itemId).then(function (item) { + //dlg.classList.add('ui-body-b'); + //dlg.classList.add('background-theme-b'); + dlg.classList.add('formDialog'); - var dlg = paperDialogHelper.createDialog({ - size: 'large' - }); + var html = ''; - dlg.classList.add('ui-body-b'); - dlg.classList.add('background-theme-b'); - dlg.classList.add('popupEditor'); + html += Globalize.translateDocument(template); - var html = ''; + dlg.innerHTML = html; + document.body.appendChild(dlg); - html += '

'; - html += ''; - html += '
' + item.Name + '
'; - html += '

'; + dlg.querySelector('.formDialogHeaderTitle').innerHTML = "Raw Metadata for: " + item.Name; - html += '
'; - html += Globalize.translateDocument(template); - html += '
'; + dialogHelper.open(dlg); - dlg.innerHTML = html; - document.body.appendChild(dlg); + dlg.addEventListener('close', function () { - paperDialogHelper.open(dlg); + Dashboard.hideLoadingMsg(); - dlg.querySelector('.btnCloseDialog').addEventListener('click', function (e) { + if (dlg.submitted) { + resolve(); + } else { + reject(); + } + }); - paperDialogHelper.close(dlg); - }); + dlg.querySelector('.btnCancel').addEventListener('click', function (e) { - dlg.querySelector('#selectLanguage').addEventListener('change', function (e) { + dialogHelper.close(dlg); + }); - showMetadataTable(dlg, item); - }); + dlg.querySelector('#selectLanguage').addEventListener('change', function (e) { - dlg.addEventListener('iron-overlay-closed', function () { + showMetadataTable(dlg, item); + }); - Dashboard.hideLoadingMsg(); - }); + dlg.addEventListener('iron-overlay-closed', function () { - dlg.classList.add('metadataViewer'); + Dashboard.hideLoadingMsg(); + }); - showMetadataTable(dlg, item); - }); - } + dlg.classList.add('metadataViewer'); - xhr.send(); - } - - return { - show: function (itemId) { - return new Promise(function (resolve, reject) { + showMetadataTable(dlg, item); + }); + }; - showEditor(itemId); + xhr.send(); }); } }; diff --git a/MetadataViewer/Html/metadataviewer.template.html b/MetadataViewer/Html/metadataviewer.template.html index 80052c08..7f68361e 100644 --- a/MetadataViewer/Html/metadataviewer.template.html +++ b/MetadataViewer/Html/metadataviewer.template.html @@ -1,211 +1,218 @@ -
-

Lookup Criteria:

-
-
-
-
'; - for (var i = 0; i < table.Headers.length; i++) { + for (i = 0; i < table.Headers.length; i++) { html += '' + table.Headers[i] + '
' + row.Caption + '
'; + html += row.Caption + '' + (row.Values[n] == null ? '' : row.Values[n]) + '
- - - - -
- - - -
- - - -

-

Results:

-
-

-

+

+ +
+
+ +
+
+

Lookup Criteria:

+
+
+
+ + + + + +
+ +
+ +
+
+ +

+

Results:

+
+

+

+

+
\ No newline at end of file