dialog_prefs.html 46.5 KB
Newer Older
pokergaming's avatar
pokergaming committed
1
<!DOCTYPE html>
2
<html id="prefs_html_element">
pokergaming's avatar
pokergaming committed
3
  <head>
4
    <link id="page_style" rel="stylesheet" type="text/css" href="css/default.css">
pokergaming's avatar
pokergaming committed
5
  </head>
6
  <body class="dialog_body prefs_body">
7
8
9
10
11
12
13
14
15
    <div class="container noselect prefs_container">
      <div class="prefs_tab_group">
        <input type="radio"
               name="prefs_radio_group"
               id="audio_tab_radio"
               class="tab1 prefs_tab"
               checked="checked" />
        <label for="audio_tab_radio" data-i18n="[title]prefs.heading.audio_tt">
          <span data-i18n="prefs.heading.audio"></span>
16
        </label>
17
18
19
20
21
22
23

        <input type="radio"
               name="prefs_radio_group"
               id="midi_tab_radio"
               class="tab2 prefs_tab"/>
        <label for="midi_tab_radio" data-i18n="[title]prefs.heading.midi_tt">
          <span data-i18n="prefs.heading.midi"></span>
24
        </label>
25
26
27
28
29
30
31

        <input type="radio"
               name="prefs_radio_group"
               id="gui_tab_radio"
               class="tab3 prefs_tab"/>
        <label for="gui_tab_radio" data-i18n="[title]prefs.heading.gui_tt">
          <span data-i18n="prefs.heading.gui"></span>
32
        </label>
33

34
35
36
37
38
39
40
41
        <input type="radio"
               name="prefs_radio_group"
               id="startup_tab_radio"
               class="tab4 prefs_tab"/>
        <label for="startup_tab_radio" data-i18n="[title]prefs.heading.startup_tt">
          <span data-i18n="prefs.heading.startup"></span>
        </label>

42
        <div class="tab1">
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
          <table class="tab_settings">
            <tr data-i18n="[title]prefs.audio.api_tt">
              <td>
                <span data-i18n="prefs.audio.api"></span>
              </td>
              <td>
                <select id="audio_api" onchange="change_api(this);">
                </select>
              </td>
            </tr>
            <tr data-i18n="[title]prefs.audio.sr_tt">
              <td>
                <span data-i18n="prefs.audio.sr"></span>
              </td>
              <td>
                <input type="text"
                       id="rate"
                       name="rate"
                       onchange="attr_change(this);">
              </td>
            </tr>
            <tr data-i18n="[title]prefs.audio.blocksize_tt">
              <td>
                <span data-i18n="prefs.audio.blocksize"></span>
              </td>
              <td>
                <select id="blocksize"
                        onchange="attr_change(this);">
                  <option value="64">64</option>
                  <option value="128">128</option>
                  <option value="256">256</option>
                  <option value="512">512</option>
                  <option value="1024">1024</option>
                  <option value="2048">2048</option>
                </select>
              </td>
            <tr data-i18n="[title]prefs.audio.advance_tt">
              <td>
                <span data-i18n="prefs.audio.advance"></span>
              </td>
              <td>
                <input type="text"
                       id="advance"
                       name="advance"
                       onchange="attr_change(this);">
              </td>
            </tr>
            <tr id="callback_container" class="hidden"
                data-i18n="[title]prefs.audio.callback_tt">
              <td>
93
                <span data-i18n="prefs.audio.callback"></span>
94
95
              </td>
              <td>
96
                <input type="checkbox" id="callback" name="callback">
97
98
99
100
101
              </td>
            </tr>
            <tr id="multi_dev_container" class="hidden"
                data-i18n="[title]prefs.audio.callback_tt">
              <td>
102
                <span data-i18n="prefs.audio.callback"></span>
103
104
              </td>
              <td>
105
                <input type="checkbox" id="multi-dev" name="multi-dev">
106
107
108
              </td>
            </tr>
          </table>
109
          <table class="tab_settings">
110
            <tr>
111
112
              <td data-i18n="[title]prefs.audio.input_title_tt">
                <span data-i18n="prefs.audio.input_title"></span>
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
              </td>
              <td>
                <span data-i18n="prefs.audio.channels"></span>
              </td>
            </tr>
            <tr>
              <td>
                <select id="in1" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="inchans1"
                   name="inchans1"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
            <tr>
              <td>
                <select id="in2" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="inchans2"
                   name="inchans2"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
            <tr>
              <td>
                <select id="in3" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="inchans3"
                   name="inchans3"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
            <tr>
              <td>
                <select id="in4" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="inchans4"
                   name="inchans4"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
            <tr>
171
172
              <td data-i18n="[title]prefs.audio.output_title_tt">
                <span data-i18n="prefs.audio.output_title"></span>
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
              </td>
              <td>
                <span data-i18n="prefs.audio.channels"></span>
              </td>
            </tr>
            <tr>
              <td>
                <select id="out1" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="outchans1"
                   name="outchans1"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
            <tr>
              <td>
                <select id="out2" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="outchans2"
                   name="outchans2"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
            <tr>
              <td>
                <select id="out3" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="outchans3"
                   name="outchans3"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
            <tr>
              <td>
                <select id="out4" onchange="dev_change(this);"></select>
              </td>
              <td>
                <label data-i18n="[title]prefs.audio.channels_tt">
                  <input type="text"
                   id="outchans4"
                   name="outchans4"
                   onchange="dev_change(this);">
                </label>
              </td>
            </tr>
          </table>
231
232
        </div>

233
        <div class="tab2">
234
          <div class="tab_settings midi_api_container">
235
236
237
238
239
240
            <label data-i18n="[title]prefs.midi.api_tt">
              <span data-i18n="prefs.midi.api"></span>
              <select id="midi_api" onchange="change_api(this);">
              </select>
            </label>
          </div>
241
242
243
244
245
246
          <div class="tab_settings alsa_midi">
            <label data-i18n="[title]prefs.midi.alsa_in_ports_tt">
              <span data-i18n="prefs.midi.alsa_in_ports"></span>
              <input type="text"
                     id="alsa_in_ports"
                     name="alsa_in_ports"
247
                     onchange="alsa_in_ports_change(this);">
248
249
250
251
252
253
            </label>
            <label data-i18n="[title]prefs.midi.alsa_out_ports_tt">
              <span data-i18n="prefs.midi.alsa_out_ports"></span>
              <input type="text"
                     id="alsa_out_ports"
                     name="alsa_out_ports"
254
                     onchange="alsa_out_ports_change(this);">
255
256
            </label>
          </div>
257

258
259
260
261
          <div class="tab_settings midi_devices">
            <span data-i18n="[title]prefs.midi.input_title_tt">
              <span data-i18n="prefs.midi.input_title"></span>
            </span>
262
263
            <table class="tab_settings">
              <tr>
264
                <td>1</td><td>
265
266
                  <select id="midi_in1" onchange="dev_change(this);"></select>
                </td>
267
                <td align="right">6</td><td>
268
269
270
271
                  <select id="midi_in6" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
272
                <td>2</td><td>
273
274
                  <select id="midi_in2" onchange="dev_change(this);"></select>
                </td>
275
                <td align="right">7</td><td>
276
277
278
279
                  <select id="midi_in7" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
280
                <td>3</td><td>
281
282
                  <select id="midi_in3" onchange="dev_change(this);"></select>
                </td>
283
                <td align="right">8</td><td>
284
285
286
287
                  <select id="midi_in8" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
288
                <td>4</td><td>
289
290
                  <select id="midi_in4" onchange="dev_change(this);"></select>
                </td>
291
                <td align="right">9</td><td>
292
293
294
295
                  <select id="midi_in9" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
296
                <td>5</td><td>
297
298
                  <select id="midi_in5" onchange="dev_change(this);"></select>
                </td>
299
                <td align="right">10</td><td>
300
301
302
303
                  <select id="midi_in10" onchange="dev_change(this);"></select>
                </td>
              </tr>
            </table>
304
            <br/>
305
306
307
            <span data-i18n="[title]prefs.midi.output_title_tt">
              <span data-i18n="prefs.midi.output_title"></span>
            </span>
308
309
            <table class="tab_settings">
              <tr>
310
                <td>1</td><td>
311
312
                  <select id="midi_out1" onchange="dev_change(this);"></select>
                </td>
313
                <td align="right">6</td><td>
314
315
316
317
                  <select id="midi_out6" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
318
                <td>2</td><td>
319
320
                  <select id="midi_out2" onchange="dev_change(this);"></select>
                </td>
321
                <td align="right">7</td><td>
322
323
324
325
                  <select id="midi_out7" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
326
                <td>3</td><td>
327
328
                  <select id="midi_out3" onchange="dev_change(this);"></select>
                </td>
329
                <td align="right">8</td><td>
330
331
332
333
                  <select id="midi_out8" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
334
                <td>4</td><td>
335
336
                  <select id="midi_out4" onchange="dev_change(this);"></select>
                </td>
337
                <td align="right">9</td><td>
338
339
340
341
                  <select id="midi_out9" onchange="dev_change(this);"></select>
                </td>
              </tr>
              <tr>
342
                <td>5</td><td>
343
344
                  <select id="midi_out5" onchange="dev_change(this);"></select>
                </td>
345
                <td align="right">10</td><td>
346
347
348
349
                  <select id="midi_out10" onchange="dev_change(this);"></select>
                </td>
              </tr>
            </table>
350
          </div>
351
        </div>
352

353
        <div class="tab3">
354
          <div class="tab_settings">
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
            <label data-i18n="[title]prefs.gui.presets.gui_preset_tt">
              <span data-i18n="prefs.gui.presets.gui_preset"></span>
            </label>
            <select id="gui_preset" onchange="gui_preset_change(this);">
              <option data-i18n="prefs.gui.presets.default" value="default">
              </option>
              <option data-i18n="prefs.gui.presets.inverted" value="inverted">
              </option>
              <option data-i18n="prefs.gui.presets.vanilla" value="vanilla">
              </option>
              <option data-i18n="prefs.gui.presets.vanilla_inverted" value="vanilla_inverted">
              </option>
              <option data-i18n="prefs.gui.presets.extended" value="extended">
              </option>
              <option data-i18n="prefs.gui.presets.c64" value="c64">
              </option>
              <option data-i18n="prefs.gui.presets.subdued" value="subdued">
              </option>
              <option data-i18n="prefs.gui.presets.strongbad" value="strongbad">
Jonathan Wilkes's avatar
Jonathan Wilkes committed
374
375
              </option>
              <option data-i18n="prefs.gui.presets.solarized" value="solarized">
376
377
378
              </option>
              <option data-i18n="prefs.gui.presets.solarized_inverted"
                      value="solarized_inverted">
379
              </option>
380
381
              <option data-i18n="prefs.gui.presets.footgun" value="footgun">
              </option>
382
            </select>
383
384
385
386
387
            <br/>
            <label data-i18n="[title]prefs.gui.zoom.save_zoom_tt">
              <input type="checkbox" id="save_zoom" name="save_zoom">
              <span data-i18n="prefs.gui.zoom.save_zoom"></span>
            </label>
388
389
390
391
392
393
394
395
396
397
398
            <br/>
            <label data-i18n="[title]prefs.gui.autopatch_yoffset_checkbox_tt">
              <input type="checkbox" id="autopatch_yoffset"
                     name="autopatch_yoffset"
                     onchange="autopatch_yoffset_toggle(this.checked);">
            <span data-i18n="prefs.gui.autopatch_yoffset"></span></span>:
            </label>
            <input type="text"
                   id="autopatch_yoffset_value"
                   name="autopatch_yoffset_value"
                   data-i18n="[title]prefs.gui.autopatch_yoffset_tt">
399
400
            <br/><br/>
            <span data-i18n="prefs.gui.browser.browser_title"></span>
401
402
403
404
405
406
407
408
409
410
            <br/>
            <label data-i18n="[title]prefs.gui.browser.browser_doc_tt">
              <input type="checkbox" id="browser_doc" name="browser_doc">
              <span data-i18n="prefs.gui.browser.browser_doc"></span>
            </label>
            <br/>
            <label data-i18n="[title]prefs.gui.browser.browser_path_tt">
              <input type="checkbox" id="browser_path" name="browser_path">
              <span data-i18n="prefs.gui.browser.browser_path"></span>
            </label>
411
412
413
414
415
            <br/>
            <label data-i18n="[title]prefs.gui.browser.browser_init_tt">
              <input type="checkbox" id="browser_init" name="browser_init">
              <span data-i18n="prefs.gui.browser.browser_init"></span>
            </label>
416
          </div>
417
        </div>
418
419
420
421
422
423

        <div class="tab4">
          <div class="tab_settings">
            <label data-i18n="[title]prefs.startup.paths_tt">
              <span data-i18n="prefs.startup.paths"></span>
            </label>
424
            <div style="height:24vh; width:100%; background:white; border: 1px solid #bbb; overflow-y:auto; overflow-x:auto; padding:0px;">
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
              <table id="startup_paths" style="width:100%; background:white;">
              </table>
            </div>
            <div class="submit_buttons">
              <button type="button" onClick="startup_path_new()" data-i18n="[title]prefs.startup.new_tt">
                <span data-i18n="prefs.startup.new"></span>
              </button>
              <button type="button" id="startup_path_edit" onClick="startup_path_edit()" data-i18n="[title]prefs.startup.edit_tt">
                <span data-i18n="prefs.startup.edit"></span>
              </button>
              <button type="button" id="startup_path_delete" onClick="startup_path_delete()" data-i18n="[title]prefs.startup.del_tt">
                <span data-i18n="prefs.startup.del"></span>
              </button>
            </div>
            <label data-i18n="[title]prefs.startup.libs_tt">
              <span data-i18n="prefs.startup.libs"></span>
            </label>
442
            <div style="height:24vh; width:100%; background:white; border: 1px solid #bbb; overflow-y:auto; overflow-x:auto; padding:0px;">
443
444
445
446
447
448
449
450
451
452
453
454
455
456
              <table id="startup_libs" style="width:100%; background:white;">
              </table>
            </div>
            <div class="submit_buttons">
              <button type="button" onClick="startup_lib_new()" data-i18n="[title]prefs.startup.new_tt">
                <span data-i18n="prefs.startup.new"></span>
              </button>
              <button type="button" id="startup_lib_edit" onClick="startup_lib_edit()" data-i18n="[title]prefs.startup.edit_tt">
                <span data-i18n="prefs.startup.edit"></span>
              </button>
              <button type="button" id="startup_lib_delete" onClick="startup_lib_delete()" data-i18n="[title]prefs.startup.del_tt">
                <span data-i18n="prefs.startup.del"></span>
              </button>
            </div>
457
            <label data-i18n="[title]prefs.startup.flags_tt" style="width:100%; text-align: left;">
458
              <span data-i18n="prefs.startup.flags"></span>
459
              <br/>
460
461
              <input type="text"
                     id="startup_flags"
462
                     name="startup_flags"
463
                     style="width:100%">
464
465
466
            </label>
          </div>
        </div>
467
      </div>
468

469
470
471
472
      <div class="submit_buttons prefs_buttons">
        <button type="button" onClick="ok()" data-i18n="[title]prefs.ok_tt">
          <span data-i18n="prefs.ok"></span>
        </button>
473
        <button type="button" onClick="apply(false)" data-i18n="[title]prefs.apply_tt">
474
475
476
477
478
        <span data-i18n="prefs.apply"></span>
        </button>
        <button type="button" onClick="cancel()" data-i18n="[title]prefs.close_tt">
        <span data-i18n="prefs.close"></span>
        </button>
479
      </div>
480
    </div>
pokergaming's avatar
pokergaming committed
481
  <script>
482
"use strict";
Hugo Neves de Carvalho's avatar
Hugo Neves de Carvalho committed
483
484
485
486
487
488
489

if (typeof(pdbundle) !== "undefined"){
    var pdgui = pdbundle.pdgui
  }else{
    var gui = require("nw.gui");
    var pdgui = require("./pdgui.js");
}
pokergaming's avatar
pokergaming committed
490

491
492
// For translations
var l = pdgui.get_local_string;
pokergaming's avatar
pokergaming committed
493

494
// Gui presets
495
pdgui.skin.apply(window);
pokergaming's avatar
pokergaming committed
496

497
var pd_object_callback;
pokergaming's avatar
pokergaming committed
498

499
500
var pd_audio_attrs;
var pd_midi_attrs;
pokergaming's avatar
pokergaming committed
501

502
function ok() {
503
    apply(true);
504
505
    cancel();
}
pokergaming's avatar
pokergaming committed
506

507
508
509
function gui_preset_change(elem) {
    pdgui.skin.set(elem.value);
}
pokergaming's avatar
pokergaming committed
510

511
512
513
514
function get_gui_preset() {
    return document.getElementById("gui_preset").selectedOptions[0].value;
}

515
516
function get_bool_elem(elem) {
    return +document.getElementById(elem).checked;
517
518
}

519
520
521
522
523
524
525
526
function get_autopatch_yoffset() {
    if (get_bool_elem("autopatch_yoffset")) {
        return document.getElementById("autopatch_yoffset_value").value;
    } else {
        return "0";
    }
}

527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
// startup config data

// XXXTODO: We should maybe include these in the dialog, but the startup tab
// is already crowded enough as it is, so currently we just record them in
// global variables and then resubmit them unchanged. Note that all of these
// options are rarely used by the average user, and they can also be entered
// using the startup flags field if needed.
var startup_use_stdpath = 1;
var startup_verbose = 0;
var startup_defeat_rt = 0;

function get_startup_flags() {
    return pdgui.encode_for_dialog(document.getElementById("startup_flags").value);
}

// Kludge alert: The user may create invalid empty entries in the paths and
// libs tables during editing. The easiest way to deal with these would be to
// just ignore them, but the table editor currently won't let us do that, so
// instead we flag them using the special text "N/A" in red. These invalid
// entries can be checked for with the valid_startup_item function below and
// are filtered out when submitting the data to Pd. If anyone has a better
// idea to deal with this corner case then please be my guest. -ag

function valid_startup_item(item)
{
    return item.textContent != "N/A" || item.style.color != "red";
}

function finalize_startup_entry(item)
{
    if (!item.textContent) {
        // flag empty entry as invalid
        item.textContent = "N/A";
        item.style.color = "red";
    }
}

function prepare_startup_entry(item)
{
    if (!valid_startup_item(item)) {
        // prepare an invalid entry for editing by turning it back into an
        // empty string
        item.textContent = "";
        item.style.color = "black";
    }
}

// retrieve the path and lib lists from the corresponding tables in the dialog
// and encode them in a form which can be safely transmitted via FUDI

function get_path_array() {
    var table = document.getElementById("startup_paths");
    var arr = [];
    if (table != null) {
        for (var i = 0; i < table.rows.length; i++) {
            var cell = table.rows[i].cells[0];
            // filter out empty items
            if (valid_startup_item(cell)) {
                arr.push(pdgui.encode_for_dialog(cell.textContent));
            }
        }
    }
    return arr;
}

function get_lib_array() {
    var table = document.getElementById("startup_libs");
    var arr = [];
    if (table != null) {
        for (var i = 0; i < table.rows.length; i++) {
            var cell = table.rows[i].cells[0];
            // filter out empty items
            if (valid_startup_item(cell)) {
                arr.push(pdgui.encode_for_dialog(cell.textContent));
            }
        }
    }
    return arr;
}

607
608
609
610
611
612
// callbacks for devices and/or their number of channels
function dev_change(elem) {
    var attrs, id, direction, index;
    // the same logic works for both channels and
    // devices-- we use the variable 'type' to
    // choose the parameter acoordingly
613
    var type, midi;
614
    id = elem.id;
615
616
    midi = id.slice(0, 4) === "midi" ? true : false;
    direction = id.replace("midi_", "").slice(0,2) === "in" ? "in" : "out";
617
    type = id.indexOf("chans") !== -1 ? "chans" : "devs";
618
619
620
    // This would need to change if there could ever be more than
    // 9 devices
    index = +(id.slice(-1)) - 1;
621
622
    attrs = get_attr("pd-" + direction + type,
        midi ?  pd_midi_attrs : pd_audio_attrs);
623
    attrs[index] = elem.value;
624
625
626

    disable_unused_chans("in");
    disable_unused_chans("out");
627
}
628

629
630
631
632
633
634
function attr_change(elem) {
    var attr, id;
    attr = pd_audio_attrs;
    id = elem.id;
    attr[attr.indexOf(id) + 1] = elem.value;
}
pokergaming's avatar
pokergaming committed
635

636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
function alsa_ports_change(elem, type) {
    var attr, dummy, i, len;
    attr = pd_midi_attrs;
    dummy = [];
    len = Number(elem.value);
    if (len.isNan) {
        len = 0;
    }
    for (i = 0; i < len; i++) {
        dummy.push("dummy");
    }
    attr[attr.indexOf("midi-" + type + "dev-names") + 1] = dummy;
}

function alsa_in_ports_change(elem) {
    alsa_ports_change(elem, "in");
}

function alsa_out_ports_change(elem) {
    alsa_ports_change(elem, "out");
}

658
659
function get_input(name) {
    var val = document.getElementsByName(name)[0].value;
660
    return val === 0 ? "0" : val;
661
}
pokergaming's avatar
pokergaming committed
662

663
664
665
666
// get a value from the garray attr array
function get_array_value(name, attrs) {
    return attrs[attrs.indexOf(name) + 1];
}
pokergaming's avatar
pokergaming committed
667

668
669
670
// If dev is -1, just change it to 0. Not sure if the Pd audio
// backend requires this, but it's how it works currently.
function kludge_dev(type, attrs, index) {
671
    var dev = get_attr("pd-" + type + "devs", attrs)[index];
672
673
674
    if (dev < 0) { dev = 0; }
    return dev;
}
pokergaming's avatar
pokergaming committed
675

676
// If the device is -1 ('None'), make the number of channels negative.
677
// This is the way Pd's audio backend turns off the device. (It works
678
679
680
// this way so you can remember your number of channels even if
// you turn off the device.)
function kludge_chans(type, attrs, index) {
681
682
    var dev = get_attr("pd-" + type + "devs", attrs)[index],
        chans = get_attr("pd-" + type + "chans", attrs)[index];
683
684
685
    if (dev < 0 && chans >= 0) { chans *= -1; }
    return chans;
}
pokergaming's avatar
pokergaming committed
686

687
function apply(save_prefs) {
688
689
    var attrs = pd_audio_attrs,
        midi_use_alsa;
690
691

    // Audio dialog
692
    pdgui.pdsend(
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
        "pd audio-dialog",
        kludge_dev("in", attrs, 0),
        kludge_dev("in", attrs, 1),
        kludge_dev("in", attrs, 2),
        kludge_dev("in", attrs, 3),
        kludge_chans("in", attrs, 0),
        kludge_chans("in", attrs, 1),
        kludge_chans("in", attrs, 2),
        kludge_chans("in", attrs, 3),
        kludge_dev("out", attrs, 0),
        kludge_dev("out", attrs, 1),
        kludge_dev("out", attrs, 2),
        kludge_dev("out", attrs, 3),
        kludge_chans("out", attrs, 0),
        kludge_chans("out", attrs, 1),
        kludge_chans("out", attrs, 2),
        kludge_chans("out", attrs, 3),
        get_attr("rate", attrs),
        get_attr("advance", attrs),
        get_attr("cancallback", attrs),
        get_attr("blocksize", attrs)
714
    );
pokergaming's avatar
pokergaming committed
715

716
    attrs = pd_midi_attrs;
717
    midi_use_alsa = !!get_attr("use_alsa", attrs);
718
    // Midi dialog
719
    pdgui.pdsend(
720
721
722
723
724
        "pd midi-dialog",
        get_attr("pd-indevs", attrs)[0],
        get_attr("pd-indevs", attrs)[1],
        get_attr("pd-indevs", attrs)[2],
        get_attr("pd-indevs", attrs)[3],
725
726
727
728
729
730
        get_attr("pd-indevs", attrs)[4],
        get_attr("pd-indevs", attrs)[5],
        get_attr("pd-indevs", attrs)[6],
        get_attr("pd-indevs", attrs)[7],
        get_attr("pd-indevs", attrs)[8],
        get_attr("pd-indevs", attrs)[9],
731
732
733
734
        get_attr("pd-outdevs", attrs)[0],
        get_attr("pd-outdevs", attrs)[1],
        get_attr("pd-outdevs", attrs)[2],
        get_attr("pd-outdevs", attrs)[3],
735
736
737
738
739
740
        get_attr("pd-outdevs", attrs)[4],
        get_attr("pd-outdevs", attrs)[5],
        get_attr("pd-outdevs", attrs)[6],
        get_attr("pd-outdevs", attrs)[7],
        get_attr("pd-outdevs", attrs)[8],
        get_attr("pd-outdevs", attrs)[9],
741
742
        midi_use_alsa ? get_attr("midi-indev-names", attrs).length : 0,
        midi_use_alsa ? get_attr("midi-outdev-names", attrs).length : 0
743
    );
744

745
746
747
    // Send the gui prefs (currently just the name of the gui preset, the
    // status of the save-zoom toggle and various options related to the help
    // browser) to Pd
748
749
750
751
752
753
754
755
    pdgui.pdsend("pd gui-prefs",
        get_gui_preset(),
        get_bool_elem("save_zoom"),
        get_bool_elem("browser_doc"),
        get_bool_elem("browser_path"),
        get_bool_elem("browser_init"),
        get_autopatch_yoffset()
    );
756

757
758
759
760
    // Send the startup config data to Pd
    pdgui.pdsend.apply(null, ["pd path-dialog", startup_use_stdpath, startup_verbose].concat(get_path_array()));
    pdgui.pdsend.apply(null, ["pd startup-dialog", startup_defeat_rt, get_startup_flags()].concat(get_lib_array()));

761
762
763
764
    if (save_prefs) {
        // save the prefs in Pd...
        pdgui.pdsend("pd save-preferences");
    }
765
}
pokergaming's avatar
pokergaming committed
766

767
768
function cancel() {
    var i, attrs, gfxstub;
769
770
771
772
773
774
    // There seems to be a bug in nwjs 0.13 beta3 that doesn't call the
    // "close" event below. This has the symptom of making it impossible
    // to click the "Ok" button and open the preferences dialog again after
    // that. To see if the bug is gone, try removing the next line and see
    // if you can open the Prefs dialog after clicking "Ok".
    pdgui.remove_dialogwin(pd_object_callback);
Hugo Neves de Carvalho's avatar
Hugo Neves de Carvalho committed
775
    if(pdgui.is_webapp()){
Prakhar Agarwal's avatar
Prakhar Agarwal committed
776
        $("#dialog-modal").modal("hide");
Hugo Neves de Carvalho's avatar
Hugo Neves de Carvalho committed
777
778
779
    }else{
        window.close(true);
    }
780
    //pdgui.pdsend(pd_object_callback, "cancel");
781
}
782

783
function change_api(elem) {
784
    var id = elem.getAttribute("id"),
785
        value = elem.value; // need js object property, DOM Attribute won't work
786
    if (id === "audio_api") {
787
        pdgui.pdsend("pd audio-setapi", value);
788
    } else {
789
        pdgui.pdsend("pd midi-setapi", value);
790
    }
791
}
792

793
794
795
796
797
798
799
function get_attr(name, attrs) {
    return attrs[attrs.indexOf(name) + 1];
}

function populate_apis(elem, apis, current_api) {
    var i, opt, api_select = elem;
    for (i = 0; i < apis.length; i += 2) {
800
        opt = document.createElement("option");
801
        opt.textContent = apis[i];
802
        opt.setAttribute("value", apis[i+1]);
803
        api_select.appendChild(opt);
pokergaming's avatar
pokergaming committed
804
    }
805
806
    api_select.value = current_api;
}
pokergaming's avatar
pokergaming committed
807

808
function populate_devs(type, attrs) {
809
    var devs = get_attr(type === "in" ? "sys-indevs" : "sys-outdevs", attrs);
810
    var i, j, opt, elem, chan_elem, chans;
811
    chans = get_attr("pd-" + type + "chans", attrs);
812
813
    for (i = 0; i < 4; i++) {
        elem = document.getElementById(type + (i+1));
814
        chan_elem = document.getElementById(type + "chans" + (i+1));
815
        chan_elem.value = chans[i];
pokergaming's avatar
pokergaming committed
816
        // if the user changed the API, we need to remove the old devs
817
818
        while (elem.firstChild) {
            elem.removeChild(elem.firstChild);
819
        }
pokergaming's avatar
pokergaming committed
820
        // make a dummy device named 'None' with value -1
821
        opt = document.createElement("option");
pokergaming's avatar
pokergaming committed
822
        opt.value = -1;
823
        opt.textContent = "None";
pokergaming's avatar
pokergaming committed
824
        elem.appendChild(opt);
825
        for (j = 0; j < devs.length; j++) {
826
            opt = document.createElement("option");
827
            opt.value = j;
828
829
830
831
            opt.textContent = devs[j];
            elem.appendChild(opt);
        }
    }
832
833
}

834
function populate_midi_devs(type, attrs) {
835
836
837
    var dev_names = get_attr(type === "in" ?
        "midi-indev-names" : "midi-outdev-names", attrs);
    var i, j, opt, elem;
838
    for (i = 0; i < 10; i++) {
839
        elem = document.getElementById("midi_" + type + (i+1));
840
841
842
843
        // if the user changed the API, we need to remove the old devs
        while (elem.firstChild) {
            elem.removeChild(elem.firstChild);
        }
844
        // make a dummy device named 'None' with value 0
845
        opt = document.createElement("option");
846
        opt.value = 0;
847
        opt.textContent = "None";
848
        elem.appendChild(opt);
849
        for (j = 0; j < dev_names.length; j++) {
850
            opt = document.createElement("option");
851
            opt.value = j+1;
852
            opt.textContent = dev_names[j];
853
854
855
856
857
            elem.appendChild(opt);
        }
    }
}

858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
function disable_unused_chans(type) {
    var i, chan_elem;
    for (i = 0; i < 4; i++) {
        chan_elem = document.getElementById(type + "chans" + (i+1));
        if (+document.getElementById(type + (i+1)).value === -1) {
            chan_elem.disabled = true;
        } else {
            chan_elem.disabled = false;
        }
    }
}

function disable_unused_devs(type, canmulti) {
    var i;
    if (+canmulti < 2) {
        for (i = 0; i < 3; i++) {
            document.getElementById(type + (i+2)).disabled = true;
        }
    } else {
        for (i = 0; i < 4; i++) {
            document.getElementById(type + (i+1)).disabled = false;
        }
    }
}

883
884
function audio_prefs_callback(attrs) {
    pd_audio_attrs = attrs;
885
    var api_select = document.getElementById("audio_api");
886
887
888
889
890
    var callback, i, j, elem, devs, opt;
    // We can get this callback multiple times while the dialog
    // is open.  This is because an API change requires a query
    // for new properties. So we only populate the api options
    // if they don't already exist
891
    if (api_select.getElementsByTagName("option").length < 1) {
892
893
        populate_apis(
            api_select,
894
895
            attrs[attrs.indexOf("audio-apis") + 1],
            attrs[attrs.indexOf("current-api") + 1]);
896
    }
897

898
899
900
    document.getElementById("rate").value = get_attr("rate", attrs);
    document.getElementById("blocksize").value = get_attr("blocksize", attrs);
    document.getElementById("advance").value = get_attr("advance", attrs);
901

902
903
    callback = get_attr("cancallback", attrs);
    //show the checkbox if the API allows
904
    if (callback !== -1) {
905
906
907
        document.getElementById("callback_container")
            .classList.remove("hidden");
        document.getElementById("callback").checked = !!callback;
908
    }
909

910
911
    populate_devs("in", attrs);
    populate_devs("out", attrs);
912

913
914
    set_devs("in", get_attr("pd-indevs", attrs));
    set_devs("out", get_attr("pd-outdevs", attrs));
pokergaming's avatar
pokergaming committed
915

916
917
    // Set chans after the devs (because they may
    // have the side-effect of setting the dev to 'None')
918
919
    set_chans("in", get_attr("pd-inchans", attrs));
    set_chans("out", get_attr("pd-outchans", attrs));
920

921
922
923
924
925
926
    disable_unused_chans("in");
    disable_unused_chans("out");

    disable_unused_devs("in", get_attr("canmulti", attrs));
    disable_unused_devs("out", get_attr("canmulti", attrs));

927
    pdgui.resize_window(pd_object_callback);
Hugo Neves de Carvalho's avatar
Hugo Neves de Carvalho committed
928
929
}	
window.audio_prefs_callback = audio_prefs_callback;
pokergaming's avatar
pokergaming committed
930

931
932
933
934
function set_devs(type, devs) {
    var i;
    for (i = 0; i < devs.length; i++) {
        document.getElementById(type + (i+1)).value = devs[i];
pokergaming's avatar
pokergaming committed
935
    }
936
}
pokergaming's avatar
pokergaming committed
937

938
939
940
function set_chans(type, chans_array) {
    var i;
    for (i = 0; i < chans_array.length; i++) {
941
        document.getElementById(type + "chans" + (i+1)).value = chans_array[i];
942
943
944
        // If no chans, set device to -1 (None)
        if (chans_array[i] < 1) {
            document.getElementById(type + (i+1)).value = -1;
pokergaming's avatar
pokergaming committed
945
        }
pokergaming's avatar
pokergaming committed
946
    }
947
}
pokergaming's avatar
pokergaming committed
948

949
950
function midi_prefs_callback(attrs) {
    pd_midi_attrs = attrs;
951
    var api_select = document.getElementById("midi_api");
952

953
    if (api_select.getElementsByTagName("option").length < 1) {
954
955
        populate_apis(
            api_select,
956
957
            get_attr("midi-apis", attrs),
            get_attr("current-api", attrs)
958
959
        );
    }
960
961
962
963
964
965
966
967
968
    // If we still haven't gotten any apis, just assume that the
    // only option is a generic "system" midi and hide the select widget.
    // This should really be taken care of in Pd-- I don't know why, for
    // example, it doesn't just send "MMIO" on Windows when that's the
    // only API available...
    if (api_select.getElementsByTagName("option").length < 1) {
        document.getElementsByClassName("midi_api_container")[0].
            style.setProperty("display", "none");
    }
969
970
971
972
973
974
975
976
977
    // Hide devs and only show the alsa in/out boxes. In the future
    // we need an additional user friendly alsa interface here-- one that
    // just lets the user pick a single input device and single output
    // device, like LMMS does.
    if (+get_attr("current-api", attrs) === 1) { // ALSA API
        document.getElementsByClassName("midi_devices")[0]
            .style.setProperty("display", "none");
        document.getElementsByClassName("alsa_midi")[0]
            .style.setProperty("display", "inherit");
978
979
980
981
982
        // For ALSA, we just set the number of ports we want
        // for input and output. The tcl/tk interface just reused
        // the first of the "indevs" for this value, so (for now)
        // we repeat that mistake here...
        document.getElementById("alsa_in_ports").value =
983
            get_attr("midi-indev-names", attrs).length;
984
        document.getElementById("alsa_out_ports").value =
985
            get_attr("midi-outdev-names", attrs).length;
986
987
988
989
990
991
992
    } else {
        document.getElementsByClassName("midi_devices")[0]
            .style.setProperty("display", "inherit");
        document.getElementsByClassName("alsa_midi")[0]
            .style.setProperty("display", "none");
        populate_midi_devs("in", attrs);
        populate_midi_devs("out", attrs);
993
994
        set_devs("midi_in", get_attr("pd-indevs", attrs));
        set_devs("midi_out", get_attr("pd-outdevs", attrs));
995
    }
996
    pdgui.resize_window(pd_object_callback);
997
}
Hugo Neves de Carvalho's avatar
Hugo Neves de Carvalho committed
998
window.midi_prefs_callback = midi_prefs_callback;
999

1000
1001
1002
1003
1004
1005
1006
function autopatch_yoffset_toggle(checked) {
    document.getElementById("autopatch_yoffset_value").disabled = !checked;
    document.getElementById("autopatch_yoffset").checked = checked;
}

function gui_prefs_callback(name, save_zoom, browser_doc, browser_path,
    browser_init, autopatch_yoffset) {
1007
1008
1009
1010
1011
1012
1013
1014
    var s = document.getElementById("gui_preset"),
        i;
    for (i = 0; i < s.options.length; i++) {
        if (s.options[i].value.toLowerCase() === name.toLowerCase()) {
            s.selectedIndex = i;
            break;
        }
    }
1015
    document.getElementById("save_zoom").checked = !!save_zoom;
1016
1017
    document.getElementById("browser_doc").checked = !!browser_doc;
    document.getElementById("browser_path").checked = !!browser_path;
1018
    document.getElementById("browser_init").checked = !!browser_init;
1019
1020
1021
1022
1023
1024
1025
1026

    if (+autopatch_yoffset !== 0) {
        document.getElementById("autopatch_yoffset_value").value =
            autopatch_yoffset;
        autopatch_yoffset_toggle(true);
    } else {
        autopatch_yoffset_toggle(false);
    }
1027
}
1028

1029
1030
// startup settings

1031
function path_prefs_callback(use_stdpath, verbose, path_array) {
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
    //pdgui.post("path callback: " + path_array.join("\n"));
    // XXXTODO
    startup_use_stdpath = use_stdpath;
    startup_verbose = verbose;
    var table = document.getElementById("startup_paths");
    if (table != null) {
        // Add the path_array elements to the table.
        for (var i = 0; i < path_array.length; i++) {
            var row = table.insertRow(i);
            var cell = row.insertCell(0);
            cell.textContent = path_array[i];
            // install the requisite handlers
            startup_paths_handlers(cell);
        }
    }
    selected_startup_path = -1;
    update_path_buttons();
1049
1050
1051
}

function lib_prefs_callback(defeat_rt, flag_string, lib_array) {
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
    //pdgui.post("lib callback: " + lib_array.join("\n"));
    // XXXTODO
    startup_defeat_rt = defeat_rt;
    document.getElementById("startup_flags").value = flag_string;
    var table = document.getElementById("startup_libs");
    if (table != null) {
        // Add the lib_array elements to the table.
        for (var i = 0; i < lib_array.length; i++) {
            var row = table.insertRow(i);
            var cell = row.insertCell(0);
            cell.textContent = lib_array[i];
            // install the requisite handlers
            startup_libs_handlers(cell);
        }
    }
    selected_startup_lib = -1;
    update_lib_buttons();
}

var selected_startup_lib = -1;
var selected_startup_path = -1;

function current_startup_lib()
{
    var table = document.getElementById("startup_libs");
    return table.rows[selected_startup_lib].cells[0];
}

function current_startup_path()
{
    var table = document.getElementById("startup_paths");
    return table.rows[selected_startup_path].cells[0];
}

function update_lib_buttons()
{
    var val = selected_startup_lib < 0;
    var edit_button = document.getElementById("startup_lib_edit");
    var del_button = document.getElementById("startup_lib_delete");
    edit_button.disabled = val;
    del_button.disabled = val;
}

function update_path_buttons()
{
    var val = selected_startup_path < 0;
    var edit_button = document.getElementById("startup_path_edit");
    var del_button = document.getElementById("startup_path_delete");
    edit_button.disabled = val;
    del_button.disabled = val;
}

function startup_libs_handlers(item)
{
    item.style = "white-space: nowrap";
    item.onclick = function () {
        startup_lib_click(this);
    };
    item.onblur = function () {
        startup_lib_blur(this);
    };
}

function startup_paths_handlers(item)
{
    item.style = "white-space: nowrap";
    item.onclick = function () {
        startup_path_click(this);
    };
    item.onblur = function () {
        startup_path_blur(this);
    };
}

function startup_lib_click(item) {
    var i = item.parentElement.rowIndex;
    if (i != selected_startup_lib) {
        if (selected_startup_lib >= 0) {
            current_startup_lib().style.background = "white";
            current_startup_lib().setAttribute("contenteditable", "false");
        }
        item.style.background = "#ddd";
        selected_startup_lib = i;
    } else if (item.getAttribute("contenteditable") != "true") {
        item.style.background = "white";
        item.contenteditable = "false";
        selected_startup_lib = -1;
    }
    update_lib_buttons();
}

function startup_lib_new() {
    var table = document.getElementById("startup_libs");
    var row = table.insertRow(selected_startup_lib+1);
    var cell = row.insertCell(0);
    startup_libs_handlers(cell);
    startup_lib_click(cell);
    startup_lib_edit();
}

function startup_lib_edit() {
    if (selected_startup_lib >= 0) {
        var item = current_startup_lib();
        prepare_startup_entry(item);
        item.setAttribute("contenteditable", "true");
        item.focus();
    }
}

function startup_lib_blur(item) {
    // Kludge alert: Apparently we can't just remove an empty row
    // here, so we simply flag the entry as invalid instead.
    finalize_startup_entry(item);
    item.setAttribute("contenteditable", "false");
}

function startup_lib_delete() {
    if (selected_startup_lib >= 0) {
        var table = document.getElementById("startup_libs");
        table.deleteRow(selected_startup_lib);
        if (selected_startup_lib < table.rows.length) {
            // make sure that the following row is selected, which is
            // convenient when deleting successive items
            var item = current_startup_lib();
            selected_startup_lib = -1;
            startup_lib_click(item);
        } else {
            selected_startup_lib = -1;
            if (table.rows.length > 0)
                startup_lib_click(table.rows[table.rows.length-1].cells[0]);
        }
    }
    update_lib_buttons();
}

function startup_path_click(item) {
    var i = item.parentElement.rowIndex;
    if (i != selected_startup_path) {
        if (selected_startup_path >= 0) {
            current_startup_path().style.background = "white";
            current_startup_path().setAttribute("contenteditable", "false");
        }
        item.style.background = "#ddd";
        selected_startup_path = i;
    } else if (item.getAttribute("contenteditable") != "true") {
        item.style.background = "white";
        item.contenteditable = "false";
        selected_startup_path = -1;
    }
    update_path_buttons();
}

function startup_path_new() {
    var table = document.getElementById("startup_paths");
    var row = table.insertRow(selected_startup_path+1);
    var cell = row.insertCell(0);
    startup_paths_handlers(cell);
    startup_path_click(cell);
    startup_path_edit();
}

function startup_path_edit() {
    if (selected_startup_path >= 0) {
        var item = current_startup_path();
        prepare_startup_entry(item);
        item.setAttribute("contenteditable", "true");
        item.focus();
    }
}

function startup_path_blur(item) {
    // Kludge alert: Apparently we can't just remove an empty row
    // here, so we simply flag the entry as invalid instead.
    finalize_startup_entry(item);
    item.setAttribute("contenteditable", "false");
}

function startup_path_delete() {
    if (selected_startup_path >= 0) {
        var table = document.getElementById("startup_paths");
        table.deleteRow(selected_startup_path);
        if (selected_startup_path < table.rows.length) {
            // make sure that the following row is selected, which is
            // convenient when deleting successive items
            var item = current_startup_path();
            selected_startup_path = -1;
            startup_path_click(item);
        } else {
            selected_startup_path = -1;
            if (table.rows.length > 0)
                startup_path_click(table.rows[table.rows.length-1].cells[0]);
        }
    }
    update_path_buttons();
1246
1247
}

1248
1249
1250
// This gets called from the nw_create_window function in index.html
// It provides us with our window id from the C side.  Once we have it
// we can create the menu and register event callbacks
1251
function register_window_id(gfxstub, attr_arrays) {
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
    pd_object_callback = gfxstub;
    add_events(gfxstub);
    translate_form();

    // We don't turn on rendering of the "container" div until
    // We've finished displaying all the spans and populating the
    // labels and form elements.  That makes it more efficient and
    // snappier, at least on older machines.  However, we still have
    // to asynchronously request the form values from Pd for audio
    // and MIDI...

    pdgui.pdsend("pd audio-properties"); // request audio pref attrs
    pdgui.pdsend("pd midi-properties");  // request midi pref attrs
1265
    pdgui.pdsend("pd gui-properties");   // request saved gui properties
1266
1267
    pdgui.pdsend("pd start-path-dialog"); // request default system paths
    pdgui.pdsend("pd start-startup-dialog"); // request default loaded libs
1268
    document.getElementsByClassName("container")[0].style.setProperty("display", "inline");
1269
}
Hugo Neves de Carvalho's avatar
Hugo Neves de Carvalho committed
1270
window.register_dialog = register_window_id;
pokergaming's avatar
pokergaming committed
1271
1272

function tr_text(id) {
1273
1274
    var elem = document.getElementById("iem.prop." + id);
    elem.textContent = l("iem.prop." + id);
pokergaming's avatar
pokergaming committed
1275
1276
1277
1278
}

// Stop-gap translator
function translate_form() {
1279
1280
1281
    var elements = document.querySelectorAll("[data-i18n]"),
        data,
        i;
pokergaming's avatar
pokergaming committed
1282
    for (i = 0;