dialog_prefs.html 20.8 KB
Newer Older
pokergaming's avatar
pokergaming committed
1
2
3
<!DOCTYPE html>
<html>
  <head>
4
    <link id="page_style" rel="stylesheet" type="text/css" href="css/default.css">
pokergaming's avatar
pokergaming committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  </head>
  <body>
    <div class="container noselect">
      <div class="menu">
        <span data-i18n="[title]prefs.heading.audio_tt">
          <a onclick="display_pref('audio');"
             data-i18n="prefs.heading.audio">
          </a> 
        </span>
        <span data-i18n="[title]prefs.heading.midi_tt">
          <a onclick="display_pref('midi');"
             data-i18n="prefs.heading.midi"></a> 
        </span>
        <span data-i18n="[title]prefs.heading.gui_tt">
          <a onclick="display_pref('gui');"
             data-i18n="prefs.heading.gui"></a> 
        </span>
      </div>

      <fieldset id="audio">
        <legend data-i18n="prefs.heading.audio"></legend>
26
        <select id="audio_api" onchange="change_api(this);">
27
28
        </select>
        <br/>
29
        <label data-i18n="[title]prefs.audio.sr_tt">
30
          <span data-i18n="prefs.audio.sr"></span>
31
32
33
34
          <input type="text"
                 id="rate"
                 name="rate"
                 onchange="attr_change(this);">
35
36
        </label>
        <br/>
37
        <label data-i18n="[title]prefs.audio.advance_tt">
38
          <span data-i18n="prefs.audio.advance"></span>
39
40
41
42
          <input type="text"
                 id="advance"
                 name="advance"
                 onchange="attr_change(this);">
43
        </label>
44
45
46
47
48
49
50
        <br/>
        <div id="callback_container" class="hidden">
          <label data-i18n="[title]prefs.audio.callback_tt">
            <span data-i18n="prefs.audio.callback"></span>
            <input type="checkbox" id="callback" name="callback">
          </label>
        </div>
51

52
53
        <select id="blocksize"
                onchange="attr_change(this);">
54
55
56
57
58
59
          <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>
pokergaming's avatar
pokergaming committed
60
        </select>
61
        <br/>
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
        <table>
          <tr>
            <td>
              Input Devices
            </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"
78
79
80
                 id="inchans1"
                 name="inchans1"
                 onchange="dev_change(this);">
81
82
83
84
85
86
87
88
89
90
              </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"
91
92
93
                 id="inchans2"
                 name="inchans2"
                 onchange="dev_change(this);">
94
95
96
97
98
99
100
101
102
103
              </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"
104
105
106
                 id="inchans3"
                 name="inchans3"
                 onchange="dev_change(this);">
107
108
109
110
111
112
113
114
115
116
              </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"
117
118
119
                 id="inchans4"
                 name="inchans4"
                 onchange="dev_change(this);">
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
              </label>
            </td>
          </tr>
          <tr>
            <td>
              Output Devices
            </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"
138
139
140
                 id="outchans1"
                 name="outchans1"
                 onchange="dev_change(this);">
141
142
143
144
145
146
147
148
149
150
              </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"
151
152
153
                 id="outchans2"
                 name="outchans2"
                 onchange="dev_change(this);">
154
155
156
157
158
159
160
161
162
163
              </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"
164
165
166
                 id="outchans3"
                 name="outchans3"
                 onchange="dev_change(this);">
167
168
169
170
171
172
173
174
175
176
              </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"
177
178
179
                 id="outchans4"
                 name="outchans4"
                 onchange="dev_change(this);">
180
181
182
183
              </label>
            </td>
          </tr>
        </table>
184

pokergaming's avatar
pokergaming committed
185
186
187
188
      </fieldset>

      <fieldset id="midi">
        <legend data-i18n="prefs.heading.midi"></legend>
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
        <select id="midi_api" onchange="change_api(this);">
        </select>
        <br/>
        <select id="midi_in1" onchange="dev_change(this);"></select>
        <br/>
        <select id="midi_in2" onchange="dev_change(this);"></select>
        <br/>
        <select id="midi_in3" onchange="dev_change(this);"></select>
        <br/>
        <select id="midi_in4" onchange="dev_change(this);"></select>
        <br/>

        <select id="midi_out1" onchange="dev_change(this);"></select>
        <br/>
        <select id="midi_out2" onchange="dev_change(this);"></select>
        <br/>
        <select id="midi_out3" onchange="dev_change(this);"></select>
        <br/>
        <select id="midi_out4" onchange="dev_change(this);"></select>
        <br/>

pokergaming's avatar
pokergaming committed
210
211
212
213
214
215
216
217
      </fieldset>

      <fieldset id="gui">
        <legend data-i18n="prefs.heading.gui"></legend>

          <label data-i18n="[title]prefs.gui.presets.gui_preset_tt">
            <span data-i18n="prefs.gui.presets.gui_preset"></span>
          </label>
218
219
          <select id="gui_preset" onchange="gui_preset_change(this);">
            <option data-i18n="prefs.gui.presets.default" value="default">
pokergaming's avatar
pokergaming committed
220
            </option>
221
222
            <option data-i18n="prefs.gui.presets.inverted" value="inverted">
            </option>
223
            <option data-i18n="prefs.gui.presets.vanilla" value="vanilla">
pokergaming's avatar
pokergaming committed
224
            </option>
225
226
            <option data-i18n="prefs.gui.presets.vanilla_inverted" value="vanilla_inverted">
            </option>
227
            <option data-i18n="prefs.gui.presets.extended" value="extended">
pokergaming's avatar
pokergaming committed
228
            </option>
Jonathan Wilkes's avatar
Jonathan Wilkes committed
229
            <option data-i18n="prefs.gui.presets.c64" value="c64">
230
            </option>
Jonathan Wilkes's avatar
Jonathan Wilkes committed
231
232
            <option data-i18n="prefs.gui.presets.subdued" value="subdued">
            </option>
Jonathan Wilkes's avatar
Jonathan Wilkes committed
233
234
            <option data-i18n="prefs.gui.presets.strongbad" value="strongbad">
            </option>
pokergaming's avatar
pokergaming committed
235
236
237
238
          </select>

      </fieldset>

239
240
241
242
243
244
245
246

    <div class="submit_buttons">
      <button type="button" onClick="ok()" data-i18n="[title]prefs.ok_tt">
        <span data-i18n="prefs.ok"></span>
      </button>
      <button type="button" onClick="apply()" data-i18n="[title]prefs.apply_tt">
      <span data-i18n="prefs.apply"></span>
      </button>
Jonathan Wilkes's avatar
Jonathan Wilkes committed
247
248
      <button type="button" onClick="cancel()" data-i18n="[title]prefs.close_tt">
      <span data-i18n="prefs.close"></span>
249
250
251
      </button>
      </div>

pokergaming's avatar
pokergaming committed
252
253
    </div>
  <script>
254
"use strict";
255
var gui = require("nw.gui"); 
256
var pdgui = require("./pdgui.js");
pokergaming's avatar
pokergaming committed
257

258
259
// For translations
var l = pdgui.get_local_string;
pokergaming's avatar
pokergaming committed
260

261
// Gui presets
262
pdgui.skin.apply(window);
pokergaming's avatar
pokergaming committed
263

264
var pd_object_callback;
pokergaming's avatar
pokergaming committed
265

266
267
var pd_audio_attrs;
var pd_midi_attrs;
pokergaming's avatar
pokergaming committed
268

269
270
271
272
function ok() {
    apply();
    cancel();
}
pokergaming's avatar
pokergaming committed
273

274
function display_pref(type) {
275
    pdgui.post("here i am with " + type);
276
    var all, i, this_elem;
277
    all = document.getElementsByTagName("fieldset");
278
279
    this_elem = document.getElementById(type);
    for (i = 0; i < all.length; i++) {
280
        all[i].style.setProperty("display", "none");
pokergaming's avatar
pokergaming committed
281
    }
282
        this_elem.style.setProperty("display", "inline");
283
}
pokergaming's avatar
pokergaming committed
284

285
286
287
function gui_preset_change(elem) {
    pdgui.skin.set(elem.value);
}
pokergaming's avatar
pokergaming committed
288

289
290
291
292
293
294
295
296
// 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
    var type;
    id = elem.id;
297
298
    direction = id.slice(0,2) === "in" ? "in" : "out";
    type = id.indexOf("chans") !== -1 ? "chans" : "devs";
299
300
301
    // This would need to change if there could ever be more than
    // 9 devices
    index = +(id.slice(-1)) - 1;
302
    pdgui.post("direction is " + direction);
303
    attrs = get_attr("pd-" + direction + type, pd_audio_attrs);
304
    attrs[index] = elem.value;
305
306
    pdgui.post("id is " + elem.id);
    pdgui.post("new chan attrs is " + attrs);
307
}
308

309
310
311
312
313
function attr_change(elem) {
    var attr, id;
    attr = pd_audio_attrs;
    id = elem.id;
    attr[attr.indexOf(id) + 1] = elem.value;
314
315
    pdgui.post("id is " + elem.id);
    pdgui.post("value is " + elem.value);
316
}
pokergaming's avatar
pokergaming committed
317

318
319
function get_input(name) {
    var val = document.getElementsByName(name)[0].value;
320
    return val === 0 ? "0" : val;
321
}
pokergaming's avatar
pokergaming committed
322

323
324
325
326
// 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
327

328
329
330
// 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) {
331
    var dev = get_attr("pd-" + type + "devs", attrs)[index];
332
333
334
    if (dev < 0) { dev = 0; }
    return dev;
}
pokergaming's avatar
pokergaming committed
335

336
337
338
339
340
// If the device is -1 ('None'), make the number of channels negative.
// This is the way Pd's audio back end turns off the device. (It works
// this way so you can remember your number of channels even if
// you turn off the device.)
function kludge_chans(type, attrs, index) {
341
342
    var dev = get_attr("pd-" + type + "devs", attrs)[index],
        chans = get_attr("pd-" + type + "chans", attrs)[index];
343
344
345
    if (dev < 0 && chans >= 0) { chans *= -1; }
    return chans;
}
pokergaming's avatar
pokergaming committed
346

347
348
function apply() {
    var attrs = pd_audio_attrs;
349
    pdgui.post("applying preferences");
350
351

    // Audio dialog
352
    pdgui.pdsend(
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
        "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)
374
    );
pokergaming's avatar
pokergaming committed
375

376
377
    attrs = pd_midi_attrs;
    // Midi dialog
378
    pdgui.pdsend(
379
380
381
382
383
384
385
386
387
        "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],
        get_attr("pd-outdevs", attrs)[0],
        get_attr("pd-outdevs", attrs)[1],
        get_attr("pd-outdevs", attrs)[2],
        get_attr("pd-outdevs", attrs)[3],
388
389
        0, // midi_alsain
        0  // midi_alsaout
390
    );
391
}
pokergaming's avatar
pokergaming committed
392

393
394
function cancel() {
    var i, attrs, gfxstub;
395
    pdgui.post("closing the window at this point");
396
397
398
399
400
401
    // 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);
402
    window.close(true);
403
    //pdgui.pdsend(pd_object_callback, "cancel");
404
}
405

406
function change_api(elem) {
407
408
409
    var id = elem.getAttribute("id"),
        value = elem.getAttribute("value");
    if (id === "audio_api") {
410
        pdgui.pdsend("pd audio-setapi", value);
411
    } else {
412
        pdgui.pdsend("pd midi-setapi", value);
413
    }
414
}
415

416
417
418
419
420
function get_attr(name, attrs) {
    return attrs[attrs.indexOf(name) + 1];
}

function populate_apis(elem, apis, current_api) {
421
    pdgui.post("curent api is " + current_api);
422
    var i, opt, api_select = elem;
423
    pdgui.post("apis are " + apis);
424
    for (i = 0; i < apis.length; i += 2) {
425
        opt = document.createElement("option");
426
        opt.textContent = apis[i];
427
        opt.setAttribute("value", apis[i+1]);
428
        api_select.appendChild(opt);
pokergaming's avatar
pokergaming committed
429
    }
430
431
    api_select.value = current_api;
}
pokergaming's avatar
pokergaming committed
432

433
function populate_devs(type, attrs) {
434
    var devs = get_attr(type === "in" ? "sys-indevs" : "sys-outdevs", attrs);
435
    var i, j, opt, elem, chan_elem, chans;
436
437
    pdgui.post("devs are " + devs);
    pdgui.post("type is " + type + 1);
438
    chans = get_attr("pd-" + type + "chans", attrs);
439
440
    for (i = 0; i < 4; i++) {
        elem = document.getElementById(type + (i+1));
441
        chan_elem = document.getElementById(type + "chans" + (i+1));
442
        chan_elem.value = chans[i];
pokergaming's avatar
pokergaming committed
443
        // if the user changed the API, we need to remove the old devs
444
445
        while (elem.firstChild) {
            elem.removeChild(elem.firstChild);
446
        }
pokergaming's avatar
pokergaming committed
447
        // make a dummy device named 'None' with value -1
448
        opt = document.createElement("option");
pokergaming's avatar
pokergaming committed
449
        opt.value = -1;
450
        opt.textContent = "None";
pokergaming's avatar
pokergaming committed
451
        elem.appendChild(opt);
452
        for (j = 0; j < devs.length; j++) {
453
            opt = document.createElement("option");
454
455
456
457
458
            opt.value = j; 
            opt.textContent = devs[j];
            elem.appendChild(opt);
        }
    }
459
460
}

461
function populate_midi_devs(type, attrs) {
462
    var devs = get_attr(type === "in" ? "sys-indevs" : "sys-outdevs", attrs);
463
    var i, j, opt, elem, chan_elem, chans;
464
465
    pdgui.post("devs are " + devs);
    pdgui.post("type is " + type + 1);
466
    chans = get_attr("pd-" + type + "chans", attrs);
467
468
    for (i = 0; i < 4; i++) {
        elem = document.getElementById(type + (i+1));
469
        chan_elem = document.getElementById(type + "chans" + (i+1));
470
471
472
473
474
475
        chan_elem.value = chans[i];
        // if the user changed the API, we need to remove the old devs
        while (elem.firstChild) {
            elem.removeChild(elem.firstChild);
        }
        // make a dummy device named 'None' with value -1
476
        opt = document.createElement("option");
477
        opt.value = -1;
478
        opt.textContent = "None";
479
480
        elem.appendChild(opt);
        for (j = 0; j < devs.length; j++) {
481
            opt = document.createElement("option");
482
483
484
485
486
487
488
            opt.value = j; 
            opt.textContent = devs[j];
            elem.appendChild(opt);
        }
    }
}

489
490
function audio_prefs_callback(attrs) {
    pd_audio_attrs = attrs;
491
    var api_select = document.getElementById("audio_api");
492
    var callback, i, j, elem, devs, opt;
493
494
    pdgui.post("audio attrs are " + attrs);
    pdgui.post("attrs length " + attrs.length);
495
496
497
498
    // 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
499
    if (api_select.getElementsByTagName("option").length < 1) {
500
501
        populate_apis(
            api_select,
502
503
            attrs[attrs.indexOf("audio-apis") + 1],
            attrs[attrs.indexOf("current-api") + 1]);
504
    }
505

506
507
508
    document.getElementById("rate").value = get_attr("rate", attrs);
    document.getElementById("blocksize").value = get_attr("blocksize", attrs);
    document.getElementById("advance").value = get_attr("advance", attrs);
509

510
    var callback = get_attr("cancallback", attrs);
511
512
    //show the checkbox if the API allows 
    if (callback !== -1) {
513
514
515
        document.getElementById("callback_container")
            .classList.remove("hidden");
        document.getElementById("callback").checked = !!callback;
516
    }
517

518
519
    populate_devs("in", attrs);
    populate_devs("out", attrs);
520

521
522
    set_devs("in", get_attr("pd-indevs", attrs));
    set_devs("out", get_attr("pd-outdevs", attrs));
pokergaming's avatar
pokergaming committed
523

524
525
    // Set chans after the devs (because they may
    // have the side-effect of setting the dev to 'None')
526
527
    set_chans("in", get_attr("pd-inchans", attrs));
    set_chans("out", get_attr("pd-outchans", attrs));
528
529

    pdgui.resize_window(pd_object_callback);
530
}
pokergaming's avatar
pokergaming committed
531

532
533
534
535
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
536
    }
537
}
pokergaming's avatar
pokergaming committed
538

539
540
541
function set_chans(type, chans_array) {
    var i;
    for (i = 0; i < chans_array.length; i++) {
542
        document.getElementById(type + "chans" + (i+1)).value = chans_array[i];
543
544
545
        // 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
546
        }
pokergaming's avatar
pokergaming committed
547
    }
548
}
pokergaming's avatar
pokergaming committed
549

550
551
function midi_prefs_callback(attrs) {
    pd_midi_attrs = attrs;
552
    var api_select = document.getElementById("midi_api");
553
554
    pdgui.post("midi attrs are " + attrs);
    pdgui.post("attrs length " + attrs.length);
555

556
    if (api_select.getElementsByTagName("option").length < 1) {
557
558
        populate_apis(
            api_select,
559
560
            get_attr("midi-apis", attrs),
            get_attr("current-api", attrs)
561
562
        );
    }
563
564

    pdgui.resize_window(pd_object_callback);
565
}
566
567


568
569
570
// 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
571
function register_window_id(gfxstub, attr_arrays) {
572
573
574
575
576
    pd_object_callback = gfxstub;
    add_events(gfxstub);
    translate_form();

    // default to audio preference panel
577
    display_pref("audio");
578
579
580
581
582
583
584
585
586
    // 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
587
    document.getElementsByClassName("container")[0].style.setProperty("display", "inline");
588
}
pokergaming's avatar
pokergaming committed
589
590

function tr_text(id) {
591
592
    var elem = document.getElementById("iem.prop." + id);
    elem.textContent = l("iem.prop." + id);
pokergaming's avatar
pokergaming committed
593
594
595
596
}

// Stop-gap translator
function translate_form() {
Jonathan Wilkes's avatar
Jonathan Wilkes committed
597
    var i;
598
    var elements = document.querySelectorAll("[data-i18n]");
pokergaming's avatar
pokergaming committed
599
600
    for (i = 0; i < elements.length; i++) {
        var data = elements[i].dataset.i18n;
601
        if (data.slice(0,7) === "[title]") {
pokergaming's avatar
pokergaming committed
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
            elements[i].title = l(data.slice(7));
        } else {
            elements[i].textContent = l(data);
        }
    }
}

function populate_form(attr_array) {
    // First, let's put the translated text for the form labels:

    for(var i = 0; i < attr_array.length; i+=2) {
        // Unhide the span with the class with the same name as the id
        var prop_group = document.getElementsByClassName(attr_array[i])[0];
        if (prop_group !== undefined) {
            console.log("the thing here is " + attr_array[i]);
617
            prop_group.classList.remove("hidden");
pokergaming's avatar
pokergaming committed
618
        } else {
619
            pdgui.post("Error: couldn't find iemgui prop group for " + attr_array[i]);
pokergaming's avatar
pokergaming committed
620
621
622
623
        }

        var elem = document.getElementsByName(attr_array[i]);
        if (elem.length > 0) {
624
            if (elem[0].type === "checkbox") {
pokergaming's avatar
pokergaming committed
625
626
                // The attr here is a string, so we need to
                // force it to number, hence the "+" below
627
                pdgui.post("found a CHECKED ITEM!!!");
pokergaming's avatar
pokergaming committed
628
629
630
631
632
633
634
635
636
637
638
639
                elem[0].checked = +attr_array[i+1];
            } else {
                elem[0].value = attr_array[i+1];
            }
        }
    }
}

function add_events(name) {
    // let's handle some events for this window...

    // closing the Window
640
    gui.Window.get().on("close", function() {
pokergaming's avatar
pokergaming committed
641
642
        // this needs to do whatever the "cancel" button does
        pdgui.remove_dialogwin(pd_object_callback);
643
        gui.Window.get().close(true);
pokergaming's avatar
pokergaming committed
644
    });
645
    pdgui.dialog_bindings(name);
pokergaming's avatar
pokergaming committed
646
647
648
649
650
}

  </script>
  </body>
</html>