-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
754 lines (640 loc) · 31.1 KB
/
Copy pathadmin.html
File metadata and controls
754 lines (640 loc) · 31.1 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
171
172
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
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
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
<!DOCTYPE html>
<html>
<head>
<title>iV Daimio Prototype Admin</title>
<script type="text/javascript" src="/daimio_composite.js"></script>
<script type="text/javascript" src="/public/js/markdown.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="/public/css/bootstrap.css" rel="stylesheet">
<link href="/public/css/styles.css" rel="stylesheet">
</head>
<body style="display:none" id="admin">
<div class="container" id="editor">
<div id="header" data-daimio-template="header">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<span class="navbar-brand">{$game.name}</span>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li><a target="_blank" href="/{$game._id}" id="control-url" class="popup">Launch game</a></li>
<li><a href="/">Back to game list</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
</div>
<div class="row">
<div class="col-md-4" id="sidebar">
<!-- Nav tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#tab-rooms" data-toggle="tab">Rooms</a></li>
<li class=""><a href="#tab-game" data-toggle="tab">Game</a></li>
<li class=""><a href="#tab-global-exits" data-toggle="tab">Global Exits</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="tab-rooms">
<h2>Rooms</h2>
<form id="add-room-form" class="form-vertical">
<div class="form-group">
<input type="text" name="name" id="name" class="form-control" placeholder="Room Name">
</div>
<div class="form-group">
<select name="roomtype" class="form-control">
<option value="text">Text</option>
<option value="image">Picture</option>
<option value="video">Video</option>
</select>
</div>
<input type="submit" name="submit" value="Add Room" class="btn btn-large btn-default">
</form>
<hr />
<div id="room-list">
<script data-daimio-template="show-all-rooms" type="text/daimio">
<form id="room-filter-form" class="form-vertical">
<div class="form-group">
<input type="text" name="filter-tag" id="filter-tag" placeholder="Search by tag or room name" class="form-control" value="{$filter-tag}"/>
</div>
<input type="submit" name="submit-filter" value="Filter" class="btn btn-default"/>
<a href="#" id="clear-filter" name="clear-filter" value="Clear" class="btn btn-default">Clear</a>
</form>
{begin list | merge data {$game.rooms | filter block "{({is value $filter-tag in __.tags} {is value __.name like {"/{$filter-tag}/" | run}} {$filter-tag | not}) | or }"}}
<h5>{_name}</h5>
<div class="row">
<div class="col-md-6">
<a data-value="{_id}" class="thumbnail room-label {{_id} | is like $selected-room-id | then :selected else ""}">
<img src="{_urls.control_thumb | else "http://placehold.it/{$game.width | or 640}x{$game.height | or 480}&text={_name}" | run with {* (:name _name)}}" class="media-object img-responsive">
</a>
</div>
<div class="col-md-6">
{__in.exits | then "<p class="exits-label">Exits to:</p>"}
<ul class="list-unstyled">
{begin divs | merge data __in.exits}
<li><a href="#" data-value="{_id}" class="room-label {{_id} | is like $selected-room-id | then :selected else ""}">{$game.rooms.{_room}.name}</a></li>
{end divs}
</ul>
</div>
<div class="col-md-6">
<p class="exits-label">Actions:</p>
<ul class="list-unstyled">
<li><a href="#" data-value="{_id}" class="dupe-room">Duplicate</a></li>
</ul>
</div>
</div>
<hr>
{end list}
</script>
</div>
</div>
<div class="tab-pane" id="tab-game">
<h2>Game</h2>
<form id="game-data" class="form-horizontal">
<script data-daimio-template="game-data" type="text/daimio">
<div class="checkbox">
<label>
<input type="checkbox" name="debug" value="1" {$game.debug | then :checked else :foo}="checked"> Debug mode (Show Hotspots in Game)
</label>
</div>
<hr>
<div class="form-group">
<label for="name" class="form-label col-md-4">Name</label>
<div class="col-md-8"><input type="text" name="name" class="form-control" value="{$game.name}" /></div>
</div>
<div class="form-group">
<label for="thumb" class="form-label col-md-4">Game Thumbnail</label>
<div class="col-md-8"><input type="text" name="thumb" class="form-control" value="{$game.thumb}" /></div>
</div>
<div class="form-group">
<label for="author" class="form-label col-md-4">Author Name</label>
<div class="col-md-8"><input type="text" name="author" class="form-control" value="{$game.author}" /></div>
</div>
<div class="form-group">
<label for="email" class="form-label col-md-4">Author Email</label>
<div class="col-md-8"><input type="text" name="email" class="form-control" value="{$game.email}" /></div>
</div>
<div class="form-group">
<label for="music" class="form-label col-md-4">Background Music</label>
<div class="col-md-8">
<input type="text" name="music" class="form-control" value="{$game.music}" />
</div>
</div>
<p><small>Width and height lock image and video rooms to a particular resolution. Leave blank for adaptable content.</small></p>
<div class="form-group">
<label for="width" class="form-label col-md-4">Width</label>
<div class="col-md-8"><input type="text" name="width" class="form-control" value="{$game.width}" /></div>
</div>
<div class="form-group">
<label for="height" class="form-label col-md-4">Height</label>
<div class="col-md-8">
<input type="text" name="height" class="form-control" value="{$game.height}" />
<hr />
<input type="submit" name="submit" value="Save" class="btn btn-large btn-default">
</div>
</div>
<div class="form-group hidden">
<textarea id="rooms" name="rooms" class="form-control">{$game.rooms}</textarea>
<input type="hidden" name="_id" value="{$game._id}" id="_id">
</div>
<div class="form-group">
<label for="" class="form-label col-md-4">Embed code</label>
<div class="col-md-8">
<textarea name="" id="" cols="30" rows="6" readonly class="form-control"><iframe src="http://bentodojo.com:8808/{$game._id}" width="{$game.width | or 640}" height="{$game.height | or 480}" scrolling="no" style="border: 0px;"></iframe></textarea>
</div>
</div>
</script>
</form>
</div>
<div class="tab-pane" id="tab-global-exits">
<h2>Global Exits</h2>
<div id="global-exits">
<script data-daimio-template="global-exits" type="text/daimio">
<div class="row">
<div class="col-md-6">
<h4>Current Exits</h4>
<ul class="list-group">
{begin exits | each data {$game.exits}}
<li class="exit-listing list-group-item" data-value="{_key}">
<img src="{$game.rooms.{_value.room}.urls.control_thumb | else "http://placehold.it/{$game.width | or 640}x{$game.height | or 480}&text={_name}" | run with {* (:name _name)}}" width="40" height="40">
<a href="#" data-value="{$game.rooms.{_value.room}.id}" class="room-label">{$game.rooms.{_value.room}.name}</a>
<span class="pull-right"><a href="" class="remove-global-exit" data-value="{_key}"><span class="glyphicon glyphicon-ban-circle" style="color: red;"></span></a></span>
</li>
{end exits}
</ul>
</div>
<div class="col-md-6">
<form id="global-exits-form" class="form form-vertical">
<h4>Add an Exit To:</h4>
<div class="form-group">
<select name="exit-id" id="add-an-exit" class="form-control">
{begin rooms | each data $game.rooms}
<option value="{_value.id}">{_value.name}</option>
{end rooms}
</select>
</div>
<input type="submit" value="Add Exit" class="btn btn-large btn-default">
</form>
</div>
</div>
</script>
</div><!-- /tab-global-exits -->
</div>
</div>
</div>
<div class="col-md-8">
<div id="room-div">
<script data-daimio-template="show-room-div" type="text/daimio">
<div id="room-preview">
{__ | >room ||}
{begin image | >image-template ||}
<img id="room" src="{__in.urls.control_thumb | else "http://placehold.it/{$game.width | or 640}x{$game.height | or 480}"}" width="{$game.width}" height="{$game.height}">
{end image}
{begin text | >text-template ||}
{__in.text | string markdown | string iv_parser rooms $game.rooms}
{end text}
{ _room.type | eq :text | not
| then _image-template else _text-template
| run}
</div>
<hr>
{begin divs | merge data __in.exits}
<div id="exit-{_key}" class="hotspot" data-value="{_key}" draggable="true"
style="top: {_top | or 0}px; left: {_left | or 0}px;
height: {_height | or 100}px; width: {_width | or 100}px;
position: absolute; background-color:#00ea89; opacity: 0.4">
<p style="text-info">{$game.rooms.{_room}.name}</p>
<div class="sizer" data-value="{_key}" draggable="true" style="position: absolute; bottom: 0%; right: 0%; height: 30px; width: 30px; background-color: blue"></div>
</div>
{end divs}
{begin globaldivs | merge data $game.exits}
<div id="global-exit-{_key}" class="global-hotspot" data-value="{_key}" draggable="true"
style="top: {_top | or 0}px; left: {_left | or 0}px;
height: {_height | or 100}px; width: {_width | or 100}px;
position: absolute; background-color:#00ea89; opacity: 0.4">
<p style="text-info">{$game.rooms.{_room}.name} <br/>(Global Exit)</p>
<div class="global-sizer" data-value="{_key}" draggable="true" style="position: absolute; bottom: 0%; right: 0%; height: 30px; width: 30px; background-color: blue"></div>
</div>
{end globaldivs}
</div>
<form id="room-form" class="form form-horizontal">
<textarea id="exits" name="exits" width="60" height="3" style="display:none;">{__.exits}</textarea>
<div class="form-group">
<label class="form-label col-md-4" for="control">Room Name</label>
<div class="col-md-8">
<input type="text" name="name" value="{__.name}" id="name" class="form-control input-lg" placeholder="Room Name">
</div>
</div>
<div class="form-group">
<label class="form-label col-md-4" for="control">Room Type</label>
<div class="col-md-8">
<select name="roomtype" class="form-control">
<option value="text">Text</option>
<option value="image" {__.type | eq :image | then :selected}>Picture</option>
<option value="video" {__.type | eq :video | then :selected}>Video</option>
</select>
</div>
</div>
<div class="form-group">
<label class="form-label col-md-4" for="control">Tags</label>
<div class="col-md-8">
<input type="text" name="tags" value='{string join value {__.tags} on ", "}' id="tags" class="form-control" placeholder="Tags">
<p class="help-block">A list of tags separated by commas.</p>
</div>
</div>
<hr />
{begin image-admin | >image-admin-template ||}
<div class="form-group">
<label class="form-label col-md-4" for="control">Image URL</label>
<div class="col-md-8"><input type="text" name="control" value="{__.urls.control}" id="control" class="form-control"></div>
</div>
<div class="form-group">
<label class="form-label col-md-4" for="control_thumb">Image Thumbnail URL</label>
<div class="col-md-8"><input type="text" name="control_thumb" value="{__.urls.control_thumb}" id="control_thumb" class="form-control"></div>
</div>
<div class="form-group">
<label class="form-label col-md-4" for="control">Music URL</label>
<div class="col-md-8">
<input type="text" name="music" value="{__.urls.music}" id="music" class="form-control">
</div>
</div>
<hr>
{end image}
{begin text-admin | >text-admin-template ||}
<div class="form-group">
<label class="form-label col-md-4" for="roomtext">Room content</label>
<div class="col-md-8">
<textarea rows="10" cols="80" name="roomtext" class="form-control" id="room-content">{__.text}</textarea>
<p class="help-block">You can use <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet" target="_blank">Markdown</a> here, as well as inline HTML, CSS, and JavaScript.</p>
</div>
</div>
<div class="form-group">
<label class="form-label col-md-4" for="roomtext">Room background</label>
<div class="col-md-8">
<input name="background" value="{__.style}" class="form-control">
<p class="help-block">A URL pointing to a hosted image.</p>
</div>
</div>
<div class="form-group">
<label class="form-label col-md-4" for="control_thumb">Image Thumbnail URL</label>
<div class="col-md-8"><input type="text" name="control_thumb" value="{__.urls.control_thumb}" id="control_thumb" class="form-control"></div>
</div>
<hr>
{end text}
{ _room.type | eq :text | not
| then _image-admin-template else _text-admin-template
| run}
<div class="form-group">
<input type="submit" value="Save Changes" class="btn btn-lg btn-success pull-right">
</div>
<input type="hidden" name="index" value="{$selected-room-id}" id="room_index">
</form>
<hr />
</div>
{begin image-exits | >image-exits-template ||}
<div class="row">
<div class="col-md-6">
<h4>Current Exits</h4>
<ul class="list-group">
{begin exists | each data {__in.exits | list from-json}}
<li class="exit-listing list-group-item" data-value="{_key}">
<img src="{$game.rooms.{_value.room}.urls.control_thumb | else "http://placehold.it/{$game.width | or 640}x{$game.height | or 480}&text={_name}" | run with {* (:name _name)}}" width="40" height="40">
<a href="#" data-value="{$game.rooms.{_value.room}.id}" class="room-label">{$game.rooms.{_value.room}.name}</a>
<span class="pull-right"><a href="" class="remove-exit" data-value="{_key}"><span class="glyphicon glyphicon-ban-circle" style="color: red;"></span></a></span>
</li>
{end exists}
</ul>
</div>
<div class="col-md-6">
<form id="add-exit-form" class="form form-vertical">
<h4>Add an Exit To:</h4>
<div class="form-group">
<select name="exit-id" id="add-an-exit" class="form-control">
{begin rooms | each data $game.rooms}
<option value="{_value.id}">{_value.name}</option>
{end rooms}
</select>
</div>
<input type="submit" value="Add Exit" class="btn btn-large btn-default">
</form>
</div>
</div>
{end image}
{ _room.type | eq :text | not | then _image-exits-template | run}
</script> <!-- end show-room-div template -->
</div>
</div>
</div>
<script id="control" type="text/daml" class="spaceseeds">
outer
$game {}
$selected-room-id -1
// NETWORK
@game-data socket-in game-data
@request-data socket-out request-data
@init from-js
@init -> @request-data
changed {__}
@game-data -> {__ | >$game | 0} -> changed
// DISPLAY
show-all-rooms
header
@set-room-list dom-set-html room-list
@set-header dom-set-html header
changed -> show-all-rooms -> @set-room-list
changed -> header -> @set-header
// FILTER ROOMS
@room-filter-form dom-on-submit
@room-filter-form -> {__.filter-tag | >$filter-tag | 0} -> show-all-rooms
// CLEAR FILTER
@clear-filter dom-on-click
@clear-filter -> {$false | >$filter-tag | 0} -> show-all-rooms
// SAVE A ROOM
@save-game socket-out save-game
@room-form dom-on-submit
save-game {__}
save-game -> changed
save-game -> @save-game
eat-room-form
{ __ | >raw-info
| * (:name _raw-info.name
:id {_raw-info.index | else {$game.rooms | count}}
:type _raw-info.roomtype
:text _raw-info.roomtext
:linkcolor _raw-info.linkcolor
:style _raw-info.background
:exits {_raw-info.exits | list from-json}
:tags {"{string trim value __}" | map data {string split value {_raw-info.tags} on ","}}
:urls {_raw-info | list remove by_key (:name :exits)} )
| list poke data $game path (:rooms {_raw-info.index | else {$game.rooms | count}}) | >$game}
@room-form -> eat-room-form -> save-game
// SELECT A ROOM
show-room-div
room-changer
{ __ | >$selected-room-id}
selected-room-only
{$selected-room-id | eq -1 | else "{1 | >@good}" | run}
@change-room-text dom-on-click .link
@change-room dom-on-click .room-label
@set-room-div dom-set-html room-div
@init -> {"<div class='alert alert-info'>Select a room from the list.</div>"} -> @set-room-div
@change-room -> room-changer -> changed
@change-room-text -> room-changer
changed -> selected-room-only
selected-room-only.good -> {$game.rooms.{$selected-room-id}} -> show-room-div -> @set-room-div
// ADD A ROOM
@add-room-form dom-on-submit
@add-room-form -> eat-room-form
// @add-room-form -> {$game.rooms | count} -> room-changer
// DUPLICATE A ROOM
duplicate-room
{ __ | >$old_room_id | $game.rooms.{$old_room_id}
| list poke value {$game.rooms | count} path :id
| list poke data $game path (:rooms {$game.rooms | count})
| >$game}
@dupe-room dom-on-click .dupe-room
@dupe-room -> duplicate-room -> save-game
// LIST EXISTS
highlight-exit {__}
@tweak-style
@over-exit dom-on-mouseover .exit-listing
@out-exit dom-on-mouseout .exit-listing
@over-exit -> {* (:id {("exit-" __in) | join} :attr "background-color" :value :yellow)} -> @tweak-style
@out-exit -> {* (:id {("exit-" __in) | join} :attr "background-color" :value "#00ea89")} -> @tweak-style
// ADD AN EXIT
add-an-exit
{ $game.rooms.{$selected-room-id}.exits
| poke {* (:room __in.exit-id
:width 100 :height 100
:top 0 :left 0)}
| >$game.rooms.{$selected-room-id}.exits}
@add-exit-form dom-on-submit
@add-exit-form -> add-an-exit -> save-game
// ADD A GLOBAL EXIT
add-global-exit
{ $game.exits
| poke {* (:room __in.exit-id
:width 100 :height 100
:top 0 :left 0 :global $true)}
| >$game.exits}
@global-exits-form dom-on-submit
@global-exits-form -> add-global-exit -> save-game
// REMOVE AN EXIT
remove-an-exit
{ $game.rooms.{$selected-room-id}.exits
| list remove by_key __in
| >$game.rooms.{$selected-room-id}.exits}
@remove-exit dom-on-click .remove-exit
@remove-exit -> remove-an-exit -> save-game
// REMOVE A GLOBAL EXIT
remove-global-exit
{ $game.exits
| list remove by_key __in
| >$game.exits}
@remove-global-exit dom-on-click .remove-global-exit
@remove-global-exit -> remove-global-exit -> save-game
// MOVE AN EXIT
move-hot-spot
{ __ | >e | $game.rooms.{$selected-room-id}.exits.{_e.value} | >exit
| * (:room _exit.room :width _exit.width :height _exit.height
:top {_exit.top | add _e.offsetY | subtract _exit.height | max 0}
:left {_exit.left | add _e.offsetX | max 0})
| >$game.rooms.{$selected-room-id}.exits.{_e.value}}
@hotspot dom-on-dragend .hotspot
@hotspot -> move-hot-spot -> save-game
// MOVE A GLOBAL EXIT
move-global-hot-spot
{ __ | >e | $game.exits.{_e.value} | >exit
| * (:room _exit.room :width _exit.width :height _exit.height
:top {_exit.top | add _e.offsetY | subtract _exit.height | max 0}
:left {_exit.left | add _e.offsetX | max 0})
| >$game.exits.{_e.value}}
@global-hotspot dom-on-dragend .global-hotspot
@global-hotspot -> move-global-hot-spot -> save-game
// SIZE AN EXIT
size-hot-spot
{ __ | >e | $game.rooms.{$selected-room-id}.exits.{_e.value} | >exit
| * (:room _exit.room :top _exit.top :left _exit.left
:width {_exit.width | add _e.offsetX | max 30}
:height {_exit.height | add _e.offsetY | minus 30 | max 30})
| >$game.rooms.{$selected-room-id}.exits.{_e.value}}
@sizer dom-on-dragend .sizer
@sizer -> size-hot-spot -> save-game
// SIZE A GLOBAL EXIT
size-global-hot-spot
{ __ | >e | $game.exits.{_e.value} | >exit
| * (:room _exit.room :top _exit.top :left _exit.left
:width {_exit.width | add _e.offsetX | max 30}
:height {_exit.height | add _e.offsetY | minus 30 | max 30})
| >$game.exits.{_e.value}}
@global-sizer dom-on-dragend .global-sizer
@global-sizer -> size-global-hot-spot -> save-game
// EDIT GAME DATA
game-data
@set-game-data-form dom-set-html game-data
@submit-game-data-form dom-on-submit game-data
// EDIT GLOBAL EXITS
global-exits
// @set-global-exits dom-set-html global-exits
@set-global-exits-form dom-set-html global-exits
@set-global-exits-list dom-set-html global-exits
@submit-global-exits-form dom-on-submit global-exits
changed -> game-data -> @set-game-data-form
changed -> global-exits -> @set-global-exits-form
changed -> global-exits -> @set-global-exits-list
@submit-game-data-form -> {__ | tap | >$game | __.rooms | list from-json | >$game.rooms} -> save-game
// TODO: exits GUI
// TODO: add 'parent' to history
// TODO: munge html and daimio code in html templates separately (like {3 | >$x} -> {3 | >x})
// TODO: make run default to all local named scoped params (ORLY?) [could work for injected but not pipeline]
// TODO: only run with not if with but maybe merge with stupid state stupid alias stupid pipes
// TODO: shift to show greens in control
// YAGNI: local machine refs
// YAGNI: whitespace chomping
</script>
<script src="/socket.io/socket.io.js"></script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery.js"></script>
<script src="/public/js/jquery.textcomplete.js"></script>
<script src="/public/js/bootstrap.min.js"></script>
<script type="text/javascript">
D.import_port_flavour('dom-on-dragend', {
dir: 'in',
outside_add: function() {
var self = this
var fun = function(value, event) {
event.dataTransfer.effectAllowed = "move"
event.dataTransfer.dropEffect = 'move'
event.value = value
self.enter(D.scrub_var(event))
}
D.track_event('dragend', this.settings.thing, fun)
}
})
D.import_port_flavour('tweak-style', {
dir: 'out',
outside_exit: function(ship) {
try {
var el = document.getElementById(ship.id)
if(!el) return false
el.style[ship.attr] = ship.value
} catch(e) {}
}
})
document.addEventListener('DOMContentLoaded', function() {
D.Etc.socket = io.connect('/')
OuterSpace = D.make_me_a_space_as_fast_as_you_can()
$(document).on('click', (function () {
$('#room-content').textcomplete([
{ // html
match: /\[\[(\w*)$/,
search: function (term, callback) {
var roomnames = [];
var rooms = OuterSpace.state.game.rooms;
for(var key in rooms) roomnames.push(rooms[key].name)
callback(roomnames);
},
index: 1,
replace: function (room) {
return ['[[' + room + ':', ']]'];
}
}
]);
}))
// activate init port
var game_id = window.location.pathname.replace(/\/$/, '').split('/')[1]
D.send_value_to_js_port(OuterSpace, 'init', {game: game_id})
})
$('body').on("click",".popup",function (event) {
event.preventDefault();
var control = $('#control-url').attr('href');
window.open(control,"","directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0,scrollbars=no,resizable=no,width=" + OuterSpace.state.game.width + ",height=" + OuterSpace.state.game.height);
})
// touchy feely stuff. http://stackoverflow.com/questions/5186441/javascript-drag-and-drop-for-touch-devices
function touchHandler(event) {
var touches = event.changedTouches,
first = touches[0],
type = "";
switch(event.type) {
case "touchstart": type="mousedown"; break;
case "touchmove": type="mousemove"; break;
case "touchend": type="mouseup"; break;
default: return;
}
var simulatedEvent = document.createEvent("MouseEvent");
simulatedEvent.initMouseEvent(type, true, true, window, 1,
first.screenX, first.screenY,
first.clientX, first.clientY, false,
false, false, false, 0/*left*/, null
);
first.target.dispatchEvent(simulatedEvent);
// if(dragging) event.preventDefault();
}
~function init() {
document.addEventListener("touchstart", touchHandler, true);
document.addEventListener("touchmove", touchHandler, true);
document.addEventListener("touchend", touchHandler, true);
document.addEventListener("touchcancel", touchHandler, true);
}()
D.import_models({
string: {
methods: {
markdown: {
desc: 'Convert markdown to html',
params: [
{
key: 'value',
desc: 'A markdown string',
type: 'string',
required: true
},
],
fun: function(value) {
return markdown.toHTML(value)
}
},
iv_parser: {
desc: 'Look for special iV flags',
params: [
{
key: 'value',
desc: 'A string',
type: 'string',
required: true
},
{
key: 'rooms',
desc: 'List of rooms in game',
type: 'list',
required: true
}
],
fun: function(value, rooms) {
var roomnames = {};
for (var key in rooms) {
roomnames[rooms[key].name] = key;
};
return value.replace(/\[\[(.*?):(.*?)\]\]/g, function (match, p1, p2) {
return '<a href="" style="color:' + rooms[key].linkcolor + '" data-value="' + roomnames[p1] + '" class="link horse">' + p2 + '</a>';
});
}
}
}
}
});
// $(document).ready(function(){
// // for admin interface; keep that sidebar in check.
// function resize_sidebar() {
// var w_height = $(window).height();
// var rl_height = $('#room-list').offset().top
// var sidebar_height = w_height - rl_height;
// $('#room-list').height(sidebar_height);
// };
// $(window).resize(function() {
// resize_sidebar();
// });
// resize_sidebar();
// });
</script>
</div>
</body>
</html>