This repository has been archived by the owner on Aug 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
otto.client.templates.coffee
1330 lines (1162 loc) · 50.3 KB
/
otto.client.templates.coffee
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
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
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
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
####
#### client side (body of otto.client.templates.coffee served as /otto.templates.js)
####
# binds to otto.templates (on the client side), not otto.client.templates
# for historical reasons (and brevity)
global.otto.client.templates = ->
$('head').append '<script src="static/js/coffeecup.js">' if not window['coffeecup']?
window.otto = window.otto || {}
window.otto.client = window.otto.client || {}
window.otto.client.templates = true # for otto.load_module's benefit
window.otto.templates = do ->
templates = {}
t = otto.t = templates
ccc = coffeecup.compile
# you can't reference 'templates' or 't' in the compiled functions scope
# (i'm guessing because they are 'eval'ed), use otto.templates instead
add = templates: templates, t: t
t.body_welcome = ccc ->
div '#welcome', otto.t.welcome @
t.body = ccc ->
nav '.channellist-container', ''
div '#mainpage', ''
div '.ouroboros-container', ''
#div '.footer-container', otto.t.footer()
div '.cursor-hider', ''
t.body_reset = ->
$('.channellist-container').empty()
$('#mainpage').empty()
$('.ouroboros-container').empty()
#$('.footer-container').html otto.t.footer()
$('.cursor-hider').empty()
t.welcome = ccc ->
div '.wecome-container', ->
div '.welcome', ->
text otto.t.logo()
div '.greeting', ->
div '.hi', 'hello!'
div '.explain', 'I love to play your music for you, but first I need to scan it'
div '.explain', 'don\'t worry, I won\'t move it or anything like that'
br()
br()
div '.explain', 'I\'ll scan for music in this folder'
div ->
div '.folder', ->
button '.control.medium2.selectfolder', otto.t.icon 'folder'
input '#selectFolder', type: 'file', style: 'display: none' #must match UIDelegate in Otto.py
span '.path', contenteditable: '', @musicroot
div '.explain.note', ->
text '(press '
button '.control.small.selectfolder.', otto.t.icon 'folder'
text ' to change this)'
button '.control.large.wide.loadmusic', 'scan'
div '.footer-container', ''
t.initialload = ccc ->
div '.welcome-container', ->
div '.welcome', ->
text otto.t.logo()
div '.initialload-container', otto.t.cubesloader @
t.cubeswithload = ccc ->
div '.cubeswithload-container', otto.t.cubesloader @
t.cubesloader = ccc ->
div '.loadingstatus', otto.t.loadingstatuses @
div '.loadingprogress', ''
div '.loadingcurrent', ''
div '.loadingcubes-container', ->
div '.loadingcubes', ''
t.loadingstatuses = ccc ->
div '.status.begin', ->
button '.control.large.wide.loadmusic2', 'scan'
div '.status.searching', ->
div '.loadingspinner', ->
div otto.t.ouroboros size: 'medium', direction: 'cw', speed: 'fast'
div '.note', 'searching'
div '.status.loading', ->
div '.loadingspinner', ->
div otto.t.ouroboros size: 'medium', direction: 'cw', speed: 'slow'
div '.note', 'scanning'
div '.status.finished', ->
div ->
text 'all finished! press '
button '.control.small.begin', otto.t.icon 'play'
text ' to begin.'
button '.control.medium2.begin', otto.t.icon 'play'
div '.status.nonefound', ->
div ->
div 'sorry, I was unable to find any music I can play'
br()
if @folder
div 'in folder ' + @folder
else
div 'in that folder'
br()
br()
button '.control.large.wide.restartload', 'restart'
div '.status.error', ->
div ->
text 'sorry, I encountered an error while scanning'
button '.control.large.wide.begin.continue', 'continue'
t.cubes = ccc ->
div '.cubes-container', ->
div '.landscape-right', ''
div '.landscape-left', ''
div '.cubes', ->
div '.scene', ''
#div '.resort.control.medium2', otto.t.icon 'cubes'
t.cubelink = ccc ->
div '.cubelink.'+@rowclass, 'data-id': @id, title: @title, ->
div '.cube', style: @style
t.stacklabel = ccc ->
div '.stacklabel', style: @style, @letter
t.countprogress = ccc ->
if @total or @count
div '.countprogress-binder', ->
s = @total
sizePercent = 100
progressPercent = Math.min((@count / @total * 100), 100)
div '.progress-maximum', ->
div '.progress-container', style: "width: #{sizePercent}%;", ->
div '.progress', ->
div '.progress-indicator', style: "width: #{progressPercent}%;", ''
div '.count-container', otto.t.count_widget(@)
t.logo = ccc ->
div '.logo-container', ->
#span '.logo', ''
a '.logo', href: 'http://ottoaudiojukebox.com/', target: '_blank', ->
t.mainpage = ccc ->
if @channel.layout is 'webcast'
text otto.t.channelbar channel: @channel
text otto.t.console()
text otto.t.webcast()
else if @channel.layout is 'featured'
text otto.t.channelbar channel: @channel
text otto.t.console()
text otto.t.featured()
#else if @channel.layout is 'holidays'
# happy holidays
else
text otto.t.channelbar channel: @channel
text otto.t.login()
text otto.t.playing @
text otto.t.thealbum()
div '.ondeckchattoggle-container', ->
div '.ondeck-container', ''
div '.chattoggle-container', ->
button '.control.medium.chattoggle.shy', {title: 'chat'}, otto.t.icon 'chat'
text otto.t.console()
text otto.t.browse @
#div '.footer-backer', ''
templates.console = coffeecup.compile ->
div '.console-container', tabindex: -1, ->
button '.control.medium.chattoggle.shy', otto.t.icon 'close'
div '.output-container', ->
div '.output.scrollkiller', ''
div '.input-container', ->
div '.inputl', ->
#pre '#prompt', ''
div '#prompt', ''
div '.inputr-container', ->
div '#inputr', -> # must be an id, not class
div '#terminal', ->
#textarea '.input', spellcheck: 'false'
#div '.inputcopy', ''
t.chathelp = ccc ->
div '.chathelp', ->
div '/cls - clear screen'
div '/next - next track'
div '/pause - pause playing'
div '/play - resume playing'
div '/nick <name> - change username'
div '/part - leave chat'
div '/help - show commands'
t.chatunknowncommand = ccc ->
div '.chatunknowncommand', ->
'unknown command ' + @prefix + @command
t.channelbar = ccc ->
console.log 'channelbar', @
div '.channelbar-container.reveal', ->
div '.channelbar', ->
div '.channelbar-left', ->
button '.control.medium.channeltoggle.shy', {title: 'channels'}, otto.t.icon 'menu'
div '.channelbar-center', ->
div '.channelname-container', ->
div '.channelname', @channel.fullname
div '.hostname', ->
#host = @host
#if host and host.indexOf(':') > 0
# host = host.substr(0, host.indexOf ':') || @host
#'http://' + host
r = /^(http:\/\/)?([^\/]*)/.exec(document.URL)
host = if r and r.length is 3 then r[2] else ''
host
text otto.t.logo()
div '.topcontrols-container', ->
#input '#fxtoggle', type: 'checkbox', checked: false
#label '#fx.shy', for: 'fxtoggle', ->
# span 'sound cues'
button '.control.medium2.soundfxtoggle.shy', {title: 'sound cues'}, otto.t.icon 'soundfx'
if Notification?
#input '#notificationstoggle', type: 'checkbox', checked: false
#label '#notifications.shy', for: 'notificationstoggle', ->
# span 'notifications'
button '.control.medium2.notificationstoggle.shy', {title: 'notifications'}, otto.t.icon 'notifications'
div '.channelbar-right', ->
#div '.chattoggle-container', ->
# button '.control.medium.chattoggle.shy', otto.t.icon 'chat'
div '.channelbar-lower', ->
div '.listeners-container', ''
templates.webcast = coffeecup.compile ->
div '#webcast-container', ->
div '#webcast-background', ->
img src: '/static/images/8013980828_82a933115b_k.jpg', title: '', alt: ''
div '#webcast-background-attribution', ->
a '#webcast-background-link', href: 'http://www.flickr.com/photos/joi/8013980828', target: '_blank',
"DJ Aaron by Joi Ito"
div '#webcast-overlay', ->
div '.autosizeX', 'data-autosize-max': 34, 'data-autosize-min': 19, 'data-autosize-right-margin': 56, ->
otto.autosize_clear_cache()
div ->
span '.webcast-title', "Live Webcast"
#div '#webcast-compatability', ->
# "live broadcast currently works in Chrome and Firefox only"
div '#webcast-chatpointer', ->
"there is a chat button in the upper right"
templates.featuredX = coffeecup.compile ->
div '#archive-container', ->
div '#archive-background', ->
img src: '/static/images/webcast.png', title: '', alt: ''
div '#archive-background-attribution', ->
a '#archive-background-link', href: 'https://www.facebook.com/photo.php?fbid=10150666518958461&set=o.406990045995364&type=1&theater', ->
"photo by [AttributionHere]"
div '#archive-overlay', ->
div '.autosize', 'data-autosize-max': 34, 'data-autosize-min': 19, 'data-autosize-right-margin': 56, ->
otto.autosize_clear_cache()
div ->
span '.archive-title', "Archives"
templates.featured = coffeecup.compile ->
div '#playlist.featured.reveal', ->
t.play_widget = ccc ->
button '#play.control.medium2', {title: 'play/pause'}, otto.t.icon 'play'
t.next_widget = ccc ->
button '#next.control.medium2.shy', {title: 'next'}, otto.t.icon 'kill'
# no longer used
t.lineout_widget = ccc ->
input '#lineouttoggle', type: 'checkbox', checked: false
label '#lineout.shy', for: 'lineouttoggle', ->
span 'server output'
text otto.t.volumelineout_widget
t.volume_widget = ccc ->
div '.volume-container', {title: 'local volume'}, ->
div '.volume', ''
t.volumelineout_widget = ccc ->
div '.volumelineout-container', {title: 'lineout volume'}, ->
div '.volumelineout', ''
t.size_widget = ccc ->
div '.size-widget.shy', ->
button '#size.smaller.control.small', {title: 'smaller'}, otto.t.icon 'smaller'
button '#size.bigger.control.small', {title: 'bigger'}, otto.t.icon 'bigger'
t.currentsong_widget = ccc ->
div '.currenttrack.autosize', {
'data-autosize-max': 34,
'data-autosize-min': 19,
'data-autosize-right-margin': 56 }, ->
otto.autosize_clear_cache()
if @song
span '.gotothere', 'data-id': @song._id, ->
@song.song || 'unknown'
if otto.myusername
button '.stars.control.teeny.shy.n0', 'data-id': @song._id
t.currentalbum_widget = ccc ->
if @song?.album
div '.album.gotothere', 'data-id': @song.albums[0]._id, ->
span @song.album
t.currentyear_widget = ccc ->
span '.year', @song?.year or ''
t.currentartist_widget = ccc ->
if @song?.artist
artist_id = @song.artists[0]?._id or 0
div '.artist.gotothere', 'data-id': artist_id, 'data-albumid': @song.albums[0]._id, ->
# data-albumid is a hack. see artist->fileunder note in gotothere code
@song.artist
t.count_widget = ccc ->
span '#count', ->
if @total or @count
totalstr = "#{@total}"
countstr = "#{@count}"
if countstr.length < totalstr.length
less = totalstr.length - countstr.length
for i in [1..less]
countstr = ' ' + countstr
span '#current-count', countstr
span '#total-count.sep', totalstr
t.time_widget = ccc ->
span '#time', ->
if @total or @current
totalstr = otto.t.format_time @total
currentstr = otto.t.format_time @current, totalstr.length
span '#current-time', currentstr
span '#total-time.sep', totalstr
t.timeprogress_widgets = ccc ->
if @total or @current
div '.timeprogress-binder', ->
s = @total
if s < 10 then s = 10
if s > 3600 then s = 3600
# fun fact: 2397 = 39:57, longest single to reach the UK charts!
#x = s / 2397 * 0.58
#x = s / 3600 * 0.58
x = s / 3600 * 1.718
scale = Math.sqrt( Math.log( x+1 ) )
sizePercent = scale * 100
progressPercent = Math.min((@current / @total * 100), 100)
div '.progress-maximum', {title: 'seek'}, ->
div '.progress-container', style: "width: #{sizePercent}%;", ->
div '.progress', ->
div '.progress-indicator', style: "width: #{progressPercent}%;", ''
div '.time-container', otto.t.time_widget(@)
t.channel_status_errata_widget = ccc ->
div '.time-container', ->
div '.time', ->
if @status.time
times = @status.time.split ':'
text otto.t.time_widget current: times[0], total: times[1]
#div '.audio', @status.audio || ''
div '.bitrate', if @status.bitrate then @status.bitrate + 'kbps' else ''
t.owner_widget = ccc ->
owner = ''
if @song? and @song.owners? and @song.owners[0]? and @song.owners[0].owner?
owner = @song.owners[0].owner
span '.owner', owner
t.requestor_widget = ccc ->
classstr = ''
if @nodecorations
if @song?.requestor
span '.requestor', @song.requestor.split('@')[0]
else
if @song? and @song.owners? and @song.owners[0]? and @song.owners[0].owner?
classstr = '.sep'
if @song?.requestor
span classstr, 'requested by '
span '.requestor', @song.requestor
t.filename_widget = ccc ->
if @song?.filename
span '.filename.shy', @song.filename
t.currentcover_widget = ccc ->
if @song
div '.thumb.px300.gotothere', { 'data-id': @song._id }, ->
if @song.cover
img
height: 300
width: 300
#src: "/image/300?id=#{@song.cover}"
src: "/image/orig?id=#{@song.cover}"
title: @song.album
else
div '.noimg.px300', ->
div @song.album
div '.noimgspacer', ''
div @song.artist
else
div '.thumb.px300', {}, ->
t.enqueue_widget = ccc ->
button '.enqueue.control.teeny.shy', ''
t.unqueue_widget = ccc ->
addtoclassstr = @addtoclassstr || ''
button '.btn.teeny.control.unqueue'+addtoclassstr, ''
t.currenttrack = ccc ->
div '.currenttrack-binder', ->
div '.currentsong-container', otto.t.currentsong_widget(@)
div '.timeprogress-container', otto.t.timeprogress_widgets(@)
div '.currentalbum-container', otto.t.currentalbum_widget(@)
div '.currentyear-container', otto.t.currentyear_widget(@)
div '.currentartist-container', otto.t.currentartist_widget(@)
div '.currenterrata-container', ->
div '.owner-container', otto.t.owner_widget(@)
div '.requestor-container', otto.t.requestor_widget(@)
div '.currentcover-container', otto.t.currentcover_widget(@)
div '.filename-container', ->
div '.filename-clipper', otto.t.filename_widget(@)
t.playing = ccc ->
div '.playing-container.reveal', ->
if otto.haslineout and otto.localhost
div '.play-container', otto.t.play_widget
div '.shy', otto.t.volumelineout_widget
else
#button '#connect.control.large.'+@channel.type, otto.t.icon 'disconnected'
#button '#connect.control.large.'+@channel.type, ->
div '.connect-container', ->
button '#connect.control.large', { title: 'connect/disconnect' }, ->
#img src: 'static/images/disconnected.svg', height: 20, width: 20
text otto.t.icon 'connect'
div '.shy', otto.t.volume_widget
size = @size || 'size1'
div ".size-container.#{size}", otto.t.size_widget
div ".next-container.#{size}", otto.t.next_widget
div ".currenttrack-container.#{size}", otto.t.currenttrack(@)
t.thealbum = ccc ->
div '.thealbum-container.reveal', ->
''
templates.browse = coffeecup.compile ->
div '.browse-container', ->
div '.browsecontrols-container', ->
div '.search-container', ->
form '#searchform.searchform', method:'get', action:'', ->
input '#searchtext.searchtext', type:'text', name:'search', placeholder: 'search', autocorrect: 'off', autocapitalize: 'off'
input '.search_button.buttonless', type:'submit', value:'Search'
div '.letterbar-container', ->
ul '.letterbar', ->
#bigwarning = if @largedatabase then '.warn.big' else '' # bzzz! not passed in FIXME
bigwarning = ''
li '.letter.control.shownewest.gap', {title: 'newest'}, otto.t.icon 'newest'
li '.letter.control.showall.gap'+bigwarning, {title: 'all'}, otto.t.icon 'all'
if not @largedatabase # need to make it faster, times out on very large databases FIXME
li '.letter.control.showusers.gap', {title: 'users'}, otto.t.icon 'users'
li '.letter.control.showstars.gap', {title: 'starred'}, otto.t.icon 'star'
li '.letter.control.showcubes.gap'+bigwarning, {title: 'cubes'}, otto.t.icon 'cubes'
# other fun character considerations: ⁂ ? № ⁕ ⁖ ⁝ ⁞ ⃛ ⋯ +⚂ ⚐ ⚑
# someday add back: st va
li '.letter.gap', 'A'
for letter in 'B C D E F G H I J K L M N O P Q R S T U V W X Y Z # ⋯'.split(' ')
if letter is '#'
li '.letter', {title: 'numbers'}, letter
else if letter is '⋯'
li '.letter', {title: 'other'}, letter
else
li '.letter', letter
#li '.letter.gap.warn.beta', '/'
#li '.letter.showlists.gap', '✓'
div '.browseresults-container', ''
t.footer = ccc ->
div '.logo-container.footer-logo-container', ->
span '.logo.footer-logo', ''
templates.login = coffeecup.compile ->
div '.login-container', ->
div '.login', ->
form '#loginform.loginform', method:'get', action:'', ->
span '.loginlabel', 'To browse and select songs '
# note the homograph unicode cryillic 'a' in 'email' in the placeholder string
# this is to keep safari from prompting for an auto fill. sigh.
input '#logintext.logintext', type:'text', placeholder: 'enter your emаil / username here', autocorrect: 'off', autocapitalize: 'off', autocomplete: 'off', autofill: 'off'
input '.login_button.buttonless', type:'submit', value:'Search'
templates.listeners = coffeecup.compile ->
span '.listeners', ->
count=0
othercount=0
for id in @listeners
if @listeners[id].socketids or @listeners[id].streams
#console.log @listeners[id].channelname
if @listeners[id].channelname and @listeners[id].channelname == otto.mychannel
count++
else
othercount++
if not count
label = 'no listeners'
else
label = count + ' ' + 'listener' + otto.t.plural(count)
span '.count', label
if count
span '.sep', ''
first = true
us = null
for id in @listeners
if @listeners[id].socketids or @listeners[id].streams
for sid of @listeners[id].socketids
if sid is @socketid
us = id
if us and @listeners[us]
text otto.t.format_listener listener: @listeners[us], first: first, me: true
first = false
for id in @listeners
if id is us
continue
if @listeners[id].socketids or @listeners[id].streams
if @listeners[id].channelname and @listeners[id].channelname == otto.mychannel
text otto.t.format_listener listener: @listeners[id], first: first, me: false
first = false
if othercount
label = othercount + ' ' + 'other listener' + otto.t.plural(othercount)
span '', ' | '
span '.count', label
for id in @listeners
if id is us
continue
if @listeners[id].socketids or @listeners[id].streams
if @listeners[id].channelname and @listeners[id].channelname != otto.mychannel
text otto.t.format_listener listener: @listeners[id], first: first, me: false, showchannel: true
first = false
templates.format_listener = coffeecup.compile ->
name = @listener.user || @listener.host || @listener.address
if @shortname
name = name.split('@')[0]
inchat = no
typing = no
focus = no
idle = yes
for id of @listener.socketids
socket = @listener.socketids[id]
if socket
inchat = yes if socket.inchat? and socket.inchat
typing = yes if socket.typing? and socket.typing
focus = yes if socket.focus? and socket.focus
if socket.idle?
idle = no if not socket.idle
if idle
idle = 1
for id of @listener.socketids
socket = @listener.socketids[id]
if socket
idle = socket.idle if socket.idle > idle
classes = ''
classes += '.streaming' if @listener.streams
classes += '.inchat' if inchat
classes += '.typing' if typing
classes += '.idle' if idle or not focus
classes += '.thisisme' if @me
classes += '.sep' if not @first
title = ''
title += 'Streaming' if @listener.streams
if @listener.streams > 1
title += "X#{@listener.streams}"
if inchat
title += ', ' if title != ''
title += 'In chat' if inchat
if typing
title += ', ' if title != ''
title += 'Typing'
if idle or not focus
title += ', ' if title != ''
if idle
minutes = Math.floor( (Date.now() - parseInt(idle)) / (60 * 1000) )
if minutes < 120
title += "Idle for #{minutes} minutes"
else
title += 'Idle since ' + Date(idle).toString()
else
title += 'Window not focused'
if @listener.host || @listener.address # i guess these are not being set? FIXME
title += ', ' if title != ''
title += 'Connected from ' + @listener.host || @listener.address
div '.listener'+classes, title: title, ->
text name
if @showchannel
span '.channel', ' (' + @listener.channelname + ')'
if @me
if @listener.user
span '.thisisme', ->
span '.you', '(you)'
button '.control.small.logout', {title: 'logout'}, otto.t.icon 'logout'
t.format_listeners_for_channel_in_channelbar = ccc ->
span '.listeners', ->
first = true
for id in @listeners
if @listeners[id].socketids or @listeners[id].streams
if @listeners[id].channelname and @listeners[id].channelname == @channelname
text otto.t.format_listener listener: @listeners[id], first: first, me: false, shortname: true
first = false
templates.channellist = coffeecup.compile ->
div '.channellistheader', ->
button '.control.medium.channeltoggle', otto.t.icon 'close'
ul ->
for i in [1..1]
for channel in @channellist
classes = '.changechannel'
classes = classes + '.currentchannel.open' if channel.name is otto.mychannel
li classes, 'data-channelname': channel.name, ->
button '.channelsettings.control.small.shy', {title: 'more info'}, otto.t.icon 'info'
div '.channelselect', ->
div '.channelname.autosize', {
'data-autosize-max': 20,
'data-autosize-min': 12,
'data-autosize-right-margin': 0 }, ->
otto.autosize_clear_cache()
channel.fullname
div '.channellisteners', ->
if @listeners
# if we reactive the count we should consider omitting if it's 1
#span '.listeners.count', count || ''
text otto.t.format_listeners_for_channel_in_channelbar listeners: @listeners, channelname: channel.name
button '.channeloutput.control.small.shy', {title: 'toggle lineout'}, otto.t.icon 'output'
div '.settings', ->
#button '.channelsettings.control.small', otto.t.icon 'close'
button '.channelplay.control.medium2', {title: 'play/pause'}, otto.t.icon 'play'
text otto.t.volumelineout_widget()
div '.channelerrata-container', ''
#button '.channelfork.control.small', {title: 'fork'}, otto.t.icon 'fork'
button '.crossfade.control.small', {title: 'crossfade'}, 'CF'
button '.replaygain.control.small', {title: 'replay gain'}, 'RG'
templates.page_it_out = (items, pagesize, lazychunksize, element, render) ->
pages = 0
pagestart = 0
# someday we should get clever here about not making pages with too few items
# we could also consider waiting to construct pages until they are scrolled to
while pagestart < items.length
pageitems = items.slice(pagestart, pagestart+pagesize)
chunkstart = 0
# further break the page into chunks to make it easier for lazyload searching
element '.page', ->
while chunkstart < pageitems.length
element '.lazychunk', ->
chunk = pageitems.slice(chunkstart, chunkstart+lazychunksize)
for item in chunk
# call the supplied render routine on each item
render item
chunkstart += lazychunksize
pagestart += pagesize
pages += 1
templates.startswith = coffeecup.compile ->
empty = true
otto.t.page_it_out @data, 200, 10, div, (item) ->
empty = false
text otto.t.artist item: item
if empty
div '.none', 'Nothing filed under ' + @params.value
templates.allalbums = coffeecup.compile ->
div '.thumbnails', ->
empty = true
otto.t.page_it_out @data, 300, 100, span, (album) ->
empty = false
div '.albumall', ->
div '.thumb.px120.expand', 'data-id': album._id, ->
if album.cover
img '.albumimg.lazy', height: 120, width: 120, \
#src: 'static/images/gray.gif', \
#src: 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==', \
#src: 'static/images/clear.gif', \
src: 'static/images/clear.png', \
'data-original': "/image/120?id=#{album.cover}", \
title: album.album
else
div '.noimg.px120', -> album.album + '<br>' + album.fileunder[0].name + '<br>' + album.owners[0].owner + '<br>' + album.year #+ album.genre
if otto.myusername
button '.stars.control.teeny.shy.n0', 'data-id': album._id
if empty
div '.none', 'No albums loaded'
templates.artist = coffeecup.compile ->
div '.artistlist', ->
if not @nostars
if otto.myusername
button '.stars.control.teeny.shy.n0', 'data-id': @item._id
div '.artistname-container', ->
span '.artistname.expand', {'data-id': @item._id }, @item.name # was @item.artist before fileunder
ul '.thumbnails', ->
if @item.albums?
albumorder = otto.t.orderalbums @item.albums
for album in albumorder
li '.h.thumb.px40.expand', 'data-id': album._id, 'data-container': @item._id, ->
if album.cover
img '.albumimg.lazy', src: 'static/images/clear.png', height: 40, width: 40, 'data-original': "/image/40?id=#{album.cover}", title: album.album
else
div '.noimg.px40', -> album.album
templates.album = coffeecup.compile ->
expand = if @noexpand then '' else '.expand'
div '.albumlist', ->
div '.thumbnails', ->
div '.thumb.px40'+expand, 'data-id': @item._id, 'data-container': @item._id, ->
if @item.cover
if @nolazy
img '.albumimg', src: "/image/40?id=#{@item.cover}", height: 40, width: 40, title: @item.album
else
img '.albumimg.lazy', src: 'static/images/clear.png', height: 40, width: 40, 'data-original': "/image/40?id=#{@item.cover}", title: @item.album
else
div '.noimg.px40', -> @item.album
span '.albumname'+expand, 'data-id': @item._id, ->
artistinfo = otto.compute_artistinfo @item
span @item.album
if artistinfo.single
span '.artist.sep', artistinfo.single
if @item.year?
span '.sep', @item.year
if otto.myusername and not @nostars
button '.stars.control.teeny.shy.n0', 'data-id': @item._id
templates.orderalbums = (albums) ->
albumorder = []
variousorder = []
for album in albums
if not album.artistinfo?
album.artistinfo = otto.compute_artistinfo album
if album.artistinfo.various
variousorder.push album
else
albumorder.push album
sorter = (a, b) ->
#if a.songs?[0]?.year? and b.songs?[0].year?
if a.year? and b.year?
ayear = Number(a.year)
byear = Number(b.year)
if ayear < byear
return -1
else if ayear > byear
return 1
else
if a.album? and b.album?
return a.album.localeCompare b.album, {sensitivity: "base", numeric: true}
else if a.album?
return -1
else if b.album?
return 1
else return 0
else if a.year?
return -1
else if b.year?
return 1
else
if a.album? and b.album?
return a.album.localeCompare b.album, {sensitivity: "base", numeric: true}
else if a.album?
return -1
else if b.album?
return 1
else return 0
albumorder.sort(sorter)
variousorder.sort(sorter)
return albumorder.concat(variousorder)
templates.albums_details = coffeecup.compile ->
div '.albumlist-container', { 'data-id': @_id }, ->
button '.close.control.tiny.shy', otto.t.icon 'close'
#if @data.length > 1
button '.close.lower.control.tiny.shy', otto.t.icon 'close'
div '.albumlist', ->
albumorder = otto.t.orderalbums @data
had_various = false
had_nonvarious = false
for album in albumorder
if album.artistinfo.various
if had_nonvarious and not had_various
div '.varioussep', ''
had_various = true
else
had_nonvarious = true
text otto.t.album_details album: album, fileunder: @fileunder
templates.album_details = coffeecup.compile ->
if not @album.artistinfo?
@album.artistinfo = otto.compute_artistinfo @album
div '.albumdetails', ->
div '.albumcover-container', ->
if @album.cover
div '.thumb.px200', ->
#img src: "/image/300?id=#{@album.cover}", alt: @album.album, title: @album.album
img src: "/image/orig?id=#{@album.cover}", alt: @album.album, title: @album.album
else
div '.noimg.px200', ->
if @album.artistinfo.various
span @album.artistinfo.various
else
for artist in @album.artistinfo.all
span -> artist
br()
span @album.album
div '.stars-container', ->
if otto.myusername
button '.stars.control.teeny.shy.n0', 'data-id': @album._id
div '.year-container', ->
if @album.years?
format_years = @album.years[0]
for year in @album.years[1..]
format_years += ', '+year
div '.year', format_years
else if @album.year?
div '.year', @album.year
div '.albuminfo', ->
div '.album', ->
span ".id#{@album._id}", 'data-id': @album._id, ->
span @album.album
if otto.myusername
button '.stars.control.teeny.shy.n0', 'data-id': @album._id
if @album.artistinfo.various
div '.artist', @album.artistinfo.various
else
for artist in @album.artistinfo.all
div '.artist', -> artist
if @album.owners?[0]?.owner
div '.owner', -> @album.owners[0].owner
div '.albumsongs.cf', ->
table ->
for song in @album.songs
tr -> td ->
text otto.t.enqueue_widget()
span ".id#{song._id}", {'data-id': song._id}, song.song
if @album.artistinfo.various or song.artist is not @album.artistinfo.primary
# this doesn't work when the fileunder name has been transformed in any way FIXME
if @album.artistinfo.various and @fileunder and song.artist is @fileunder.name
span '.subartist.highlight.sepgray', song.artist
else
span '.subartist.sep', song.artist
if otto.myusername
button '.stars.control.teeny.shy.n0', 'data-id': song._id
#button '.stars.control.teeny.shy.n0', {'data-id': song._id}, otto.t.icon 'star'
span '.time.sep.shy', otto.t.format_time(song.length)
div '.albumdir.dirpath.shy', ->
@album.dirpath
templates.ondeck = coffeecup.compile ->
table '.ondeck', ->
# the rest of the queue, on deck
for song in @songs
tr ->
td '.requestor-container', otto.t.requestor_widget( song: song, nodecorations: true )
td ->
text otto.t.unqueue_widget( addtoclassstr: '.shy' )
addtoclassstr = ''
if song.requestor
addtoclassstr='.requested'
span ".song.id#{song._id}#{addtoclassstr}", { 'data-id': song._id, 'data-mpdqueueid': song.mpdqueueid }, song.song
span '.album.sep', song.album
span '.artist.sep', song.artist
span '.sep', otto.t.format_time(song.length)
span '.shy', ->
if song.owners
owner = song.owners[0].owner
else
owner = ''
span '.owner.sep', -> owner
span '.filename.sep', -> song.filename
templates.featured = coffeecup.compile ->
ul '.ondeck', ->
# the rest of the queue, on deck
for song, n in @songs
li ->
if song.requestor
span '.requestor', ->
div -> song.requestor
else
span '.requestor', -> ''
if song.nowplaying
span '.playing.control.teeny', otto.t.icon 'play'
span '.song.currenttrack', -> song.song
else
button '.play.control.teeny.shy', id: song.mpdqueueid, 'data-position': n, ->
text otto.t.icon 'play'
span '.song', song.song
span '.album.sep', song.album
span '.artist.sep', song.artist
span '.sep', otto.t.format_time(song.length)
span '.shy', ->
if song.owners
owner = song.owners[0].owner
else
owner = ''
span '.owner.sep', -> owner
span '.filename.sep', -> song.filename
templates.alert = coffeecup.compile ->
div class: 'alert alert-info', ->
span @message
br()
br()
button '#ok.runself.control.large', 'ok'
text ' '
button '#cancel.runself.control.large', 'cancel'
templates.search = coffeecup.compile ->
div '.search', ->
if not @data.fileunders.length and not @data.albums.length and not @data.songs.length
div class: 'noresults'
else
if @data.fileunders.length
div class: 'section', 'Artists'
div ->
for fileunder in @data.fileunders
#li -> fileunder.name
div -> otto.t.artist item: fileunder
if @data.albums.length
div class: 'section', 'Albums'
div class: 'albums', ->
for album in @data.albums
div -> otto.t.album item: album
if @data.songcomposers? and @data.songcomposers.length
div '.section', 'Composers'
ul class: 'songs', ->
for song in @data.songcomposers
filename = song.filename
li ->
button '.enqueue.control.teeny.shy', 'data-oid': song.oid
composers = ''
if song.tags['©wrt']