aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Providers/Plugins/MusicBrainz/Configuration/config.html
blob: 88c7c7d935a48496cffee2ed8cb1f234dd567f39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
    <title>MusicBrainz</title>
</head>
<body>
    <div id="configPage" data-role="page" class="page type-interior pluginConfigurationPage configPage" data-require="emby-input,emby-button,emby-checkbox">
        <div data-role="content">
            <div class="content-primary">
                <h1>MusicBrainz</h1>
                <form class="configForm">
                    <div class="inputContainer">
                        <input is="emby-input" type="text" id="server" required label="Server" />
                        <div class="fieldDescription">This can be a mirror of the official server or even a custom server.</div>
                    </div>
                    <div class="inputContainer">
                        <input is="emby-input" type="number" id="rateLimit" required pattern="[0-9]*" min="0" max="10" step=".01" label="Rate Limit" />
                        <div class="fieldDescription">Span of time between requests in seconds. The official server is limited to one request every seconds.</div>
                    </div>
                    <label class="checkboxContainer">
                        <input is="emby-checkbox" type="checkbox" id="replaceArtistName" />
                        <span>When an artist is found during a metadata search, replace the artist name with the value on the server.</span>
                    </label>
                    <br />
                    <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 MusicBrainzPluginConfig = {
                uniquePluginId: "8c95c4d2-e50c-4fb0-a4f3-6c06ff0f9a1a"
            };

            document.querySelector('.configPage')
                .addEventListener('pageshow', function () {
                    Dashboard.showLoadingMsg();
                    ApiClient.getPluginConfiguration(MusicBrainzPluginConfig.uniquePluginId).then(function (config) {
                        var server = document.querySelector('#server');
                        server.value = config.Server;
                        server.dispatchEvent(new Event('change', {
                            bubbles: true,
                            cancelable: false
                        }));

                        var rateLimit = document.querySelector('#rateLimit');
                        rateLimit.value = config.RateLimit;
                        rateLimit.dispatchEvent(new Event('change', {
                            bubbles: true,
                            cancelable: false
                        }));

                        document.querySelector('#replaceArtistName').checked = config.ReplaceArtistName;

                        Dashboard.hideLoadingMsg();
                    });
                });

            document.querySelector('.configForm')
                .addEventListener('submit', function (e) {
                    Dashboard.showLoadingMsg();

                    ApiClient.getPluginConfiguration(MusicBrainzPluginConfig.uniquePluginId).then(function (config) {
                        config.Server = document.querySelector('#server').value;
                        config.RateLimit = document.querySelector('#rateLimit').value;
                        config.ReplaceArtistName = document.querySelector('#replaceArtistName').checked;

                        ApiClient.updatePluginConfiguration(MusicBrainzPluginConfig.uniquePluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
                    });

                    e.preventDefault();
                    return false;
                });
        </script>
    </div>
</body>
</html>