|
24 | 24 | <script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
25 | 25 |
|
26 | 26 |
|
27 |
| -<!-- you have to define 2 functions in the global scope: --> |
28 | 27 | <script type="text/javascript">
|
29 | 28 |
|
30 |
| - // Dictionary (systemDictionary is global variable from adapter-settings.js) |
31 | 29 | systemDictionary = {
|
32 | 30 | "samsung adapter settings": {"de": "Samsung Einstellungen", "ru": "Samsung"},
|
33 |
| - "IP": {"en": "IP", "de": "IP", "ru": "IP"}, |
34 |
| - "test2": {"en": "Test 2", "de": "Test 2", "ru": "Тест 2"}, |
| 31 | + "IP": { |
| 32 | + "en": "IP", |
| 33 | + "de": "IP", |
| 34 | + "ru": "IP" |
| 35 | + }, |
| 36 | + "Info": { |
| 37 | + "de": "Hinweis", |
| 38 | + "en": "Info" |
| 39 | + }, |
| 40 | + "Settings": { |
| 41 | + "de": "Einstellungen", |
| 42 | + "en": "Settings" |
| 43 | + }, |
35 | 44 | "on save adapter restarts with new config immediately": {
|
36 |
| - "de": "Beim Speichern von Einstellungen der Adapter wird sofort neu gestartet.", |
| 45 | + "de": "Beim Speichern der Einstellungen wird der Adapter automatisch neu gestartet.", |
37 | 46 | "ru": "Сразу после сохранения настроек драйвер перезапуститься с новыми значениями"
|
38 | 47 | }
|
39 | 48 | };
|
40 | 49 |
|
41 |
| - // the function loadSettings has to exist ... |
42 | 50 | function load(settings, onChange) {
|
43 |
| - // example: select elements with id=key and class=value and insert value |
44 | 51 | for (var key in settings) {
|
45 |
| - // example: select elements with id=key and class=value and insert value |
46 | 52 | if ($('#' + key + '.value').attr('type') == 'checkbox') {
|
47 | 53 | $('#' + key + '.value').prop('checked', settings[key]).change(function () {
|
48 |
| - onChange(); |
49 |
| - }); |
| 54 | + onChange(); |
| 55 | + }); |
50 | 56 | } else {
|
51 | 57 | $('#' + key + '.value').val(settings[key]).change(function () {
|
52 |
| - onChange(); |
53 |
| - }).keyup(function () { |
54 |
| - $(this).trigger('change'); |
55 |
| - }); |
| 58 | + onChange(); |
| 59 | + }).keyup(function () { |
| 60 | + $(this).trigger('change'); |
| 61 | + }); |
56 | 62 | }
|
57 | 63 | }
|
58 |
| - // Signal to admin, that no changes yet |
59 | 64 | onChange(false);
|
60 | 65 | }
|
61 | 66 |
|
62 |
| - // ... and the function save has to exist. |
63 |
| - // you have to make sure the callback is called with the settings object as first param! |
64 | 67 | function save(callback) {
|
65 |
| - // example: select elements with class=value and build settings object |
66 | 68 | var obj = {};
|
67 | 69 | $('.value').each(function () {
|
68 | 70 | var $this = $(this);
|
69 |
| - obj[$this.attr('id')] = $this.val(); |
| 71 | + var id = $this.attr('id'); |
| 72 | + |
| 73 | + if ($this.attr('type') == 'checkbox') { |
| 74 | + obj[$this.attr('id')] = $this.prop('checked'); |
| 75 | + } else { |
| 76 | + obj[$this.attr('id')] = $this.val(); |
| 77 | + } |
70 | 78 | });
|
71 | 79 | callback(obj);
|
72 | 80 | }
|
| 81 | + |
73 | 82 | </script>
|
74 | 83 |
|
75 |
| -<!-- you have to put your config page in a div with id adapter-container --> |
76 |
| -<div id="adapter-container"> |
| 84 | +<style> |
| 85 | + td { |
| 86 | + font-size: 13px; |
| 87 | + padding-left:1px; |
| 88 | + padding-right: 4px; |
| 89 | + padding-top: 3px; |
| 90 | + padding-bottom: 3px; |
| 91 | + } |
| 92 | + input { |
| 93 | + font-size: 13px; |
| 94 | + } |
| 95 | + h1 { |
| 96 | + font-size: 11px; |
| 97 | + color: #505050; |
| 98 | + font-weight: bold; |
| 99 | + width: 100%; |
| 100 | + padding-left:6px; |
| 101 | + padding-right: 5px; |
| 102 | + padding-top: 5px; |
| 103 | + padding-bottom: 5px; |
| 104 | + background-color: #e0e0e0; |
| 105 | + /*background-image: linear-gradient(to right, #e0e0e0, rgba(224,224,224,0.0));*/ |
| 106 | + /*background-image: linear-gradient(to right, #e0e0e0, #e8e8e8 50%, #e0e0e0);*/ |
| 107 | + } |
| 108 | +</style> |
| 109 | + |
| 110 | + |
| 111 | +<div id="adapter-container" style="padding-left: 6px; padding-right: 0px; width: 97%;"> |
| 112 | + |
| 113 | + <table> |
| 114 | + <td><img src="samsung.png" /></td> |
| 115 | + <td style="padding-top: 20px;padding-left: 10px"><h3 class="translate">samsung adapter settings</h3></td> |
| 116 | + </table> |
| 117 | + |
| 118 | + <h1 class="translate">Settings</h1> |
77 | 119 |
|
78 |
| - <table><tr> |
79 |
| - <td><img src="samsung.png"/></td> |
80 |
| - <td><h3 class="translate">samsung adapter settings</h3></td> |
81 |
| - </tr></table> |
82 |
| - <p> |
83 |
| - <span class="translate">IP</span> <input class="value" id="IP"/><br> |
84 |
| - </p> |
| 120 | + <table> |
| 121 | + <tr><td class="translate">IP</td><td><input class="value" id="ip" type="input" size="15" /></td></tr> |
| 122 | + </table> |
85 | 123 |
|
86 |
| - <p class="translate">on save adapter restarts with new config immediately</p> |
| 124 | + <div style="padding: 10px"></div> |
| 125 | + <h1 class="translate">Info</h1> |
87 | 126 |
|
| 127 | + <table> |
| 128 | + <tr><td class="translate">on save adapter restarts with new config immediately</td></tr> |
| 129 | + </table> |
88 | 130 | </div>
|
89 | 131 |
|
90 | 132 | </html>
|
0 commit comments