forked from JamBrain/JamBrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
old-index.php
1085 lines (959 loc) · 29.6 KB
/
old-index.php
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
<?php
require_once __DIR__ . "/../web.php";
require_once __DIR__ . "/../core/constants.php";
require_once __DIR__ . "/../core/node.php";
require_once __DIR__ . "/../core/internal/sanitize.php";
require_once __DIR__ . "/../core/internal/emoji.php";
require_once __DIR__ . "/../core/post.php";
require_once __DIR__ . "/../core/schedule.php";
require_once __DIR__ . "/../core/internal/ichart.php";
// HTML Library Configuration //
const HTML_USE_EMOJI = true;
const HTML_USE_MARKUP = true;
const HTML_USE_HIGHLIGHT = true;
const HTML_USE_CORE = true;
const HTML_USE_STARSHIP = true;
const HTML_SHOW_FOOTER = true;
user_StartEnd();
//template_SetTheme("embed");
// Modes //
const M_DEFAULT = 1; // Default State //
const M_ERROR = -255; // Other Error //
$mode = M_DEFAULT;
$args = core_ParseActionURL();
$args_count = count($args);
// Sanitize Input
foreach( $args as $arg ) {
$arg = sanitize_Slug($arg);
if ( empty($arg) ) {
$mode = M_ERROR;
break;
}
}
if ( $mode > 0 ) {
$args_merged = implode('/',$args);
$paths = [ CMW_NODE_ROOT ];
foreach( $args as $key => $slug ) {
$id = node_GetNodeIdByParentIdAndSlug($paths[$key],$slug);
if ( !empty($id) ) {
$paths[] = $id;
}
else {
$mode = M_ERROR;
break;
}
}
if ( $mode > 0 ) {
$paths_count = count($paths);
$this_node_id = &$paths[$paths_count-1];
$this_node = node_GetNodeById( $this_node_id );
$author_node = [];
if ( !empty($this_node['author']) && ($this_node['author'] > 0) ) {
$author_node = node_GetNodeById( $this_node['author'] );
}
if ( !empty($this_node['parent']) && ($this_node['parent'] > 0) ) {
$parent_node = node_GetNodeById( $this_node['parent'] );
}
$nodes = node_GetNodesByParentId( $this_node_id );
$nodes_count = count($nodes);
}
}
?>
<?php template_GetHeader(); ?>
<script>
// Cookie Functions //
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2)
return parts.pop().split(";").shift();
return parts;
}
function setCookie(name,value) {
document.cookie = name + '=' + value;
}
function removeCookie( name ) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
</script>
<style>
/* Top Navigation Bar */
#ldbar-outer {
width:100%;
height:56px;
/*position:fixed;*/
left:0;
top:0;
z-index:1000;
/* shadow */
/*border-bottom:1px solid #000;/*rgba(96,96,96,0.2);*/
box-shadow:0px -1px 8px rgba(0,0,0,0.7);
/*-webkit-animation: slidein 3s;*/
/*-moz-animation: slidein 3s;*/
/*animation: slidein 3s;*/
}
@-webkit-keyframes slidein {
from{ top: -52px; }
50% { top: -52px; }
75% { top: 8px; }
90% { top: -4px; }
to { top: 0; }
}
@-moz-keyframes slidein {
from { top: -52px; }
50% { top: -52px; }
75% { top: 8px; }
90% { top: -4px; }
to { top: 0; }
}
@keyframes slidein {
from { top: -52px; }
50% { top: -52px; }
75% { top: 8px; }
90% { top: -4px; }
to { top: 0; }
}
#ldbar-inner {
color:#fff;
background:/*#765*/ rgba(64,64,64,1.0);
line-height:56px;
position:relative;
width:100%;
}
/* Padding in the main document */
#ldbar-pad {
width:100%;
height:56px; /* plus shadow */
}
.noselect {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#ldbar img {
/*vertical-align:middle;*/
}
#ldbar-toggle {
font-family:'Inconsolata',monospace;
margin-left:32px;
cursor:pointer;
}
#ldbar-notifications {
font-size:20px;
margin-left:24px;
font-weight:bold;
border-radius:9px;
cursor:pointer;
display:inline-block !important;
width:32px;
height:32px;
line-height:32px;
text-align:center;
font-family:'Inconsolata',monospace;
position:relative;
text-shadow:0 2px rgba(0,0,0,0.5);
background:rgba(255,32,48,0.5);
border:3px solid #000;
top:0px;
-webkit-transition:all 0.125s;
transition:all 0.125s;
}
#ldbar-notifications:hover {
background:rgba(255,32,48,0.8);
border-top:1px solid #000;
border-bottom:5px solid #000;
top:-2px;
}
#ldbar-logo {
position:relative;
cursor:pointer;
top:9px;
opacity:0.7;
-webkit-transition:all 0.125s;
transition:all 0.125s;
}
#ldbar-logo:hover {
top:6px;
opacity:1.0;
}
#ldbar .leftnav {
display:inline;
padding-left:64px;
}
#ldbar .rightnav {
float:right;
display:inline;
/*padding-right:64px;*/
}
#ldbar .cell {
display:inline;
}
#ldbar .size32 {
position:relative;
width:32px;
height:32px;
top:8px;
}
#warning {
font-size:26px;
text-align:center;
padding:12px 16px;
margin:16px 0;
background:#F53;
color:#FFF;
}
</style>
<div id='ldbar' class='noselect'>
<div id='ldbar-outer' style='position:fixed;'>
<div id='ldbar-inner'>
<div class='leftnav'>
<div id='ldbar-logo' class='cell'><a href="/"><img src="<?php STATIC_URL(); ?>/logo/ludumdare/2009/LudumDareLogo80W.png" height="30" /></a></div>
<div class='is-mobile'>[Mobile]</div>
<div class='is-tablet'>[Tablet]</div>
<div class='is-normal'>[Normal]</div>
<div class='is-hires'>[HiRes]</div>
</div>
<div class='rightnav'>
<div class='cell size32' onclick='SendLogin();'><img src="<?php STATIC_URL(); ?>/logo/mike/Chicken64W.png" width="32" height="32" style="mix-blend-mode:screen" /></div>
<div id='ldbar-notifications' class='cell' onclick='SendLogout();'>0</div>
<div id='ldbar-toggle' class='cell' onclick='toggleLDBar();' title='Toggle Sticky Bar'>[x]</div>
</div>
</div>
</div>
<div id='ldbar-pad'></div>
</div>
<div id='warning' <?php if ( isset($_COOKIE['hide-warning']) ) { echo 'style="display:none;"'; } ?> >
<strong>NOTE:</strong> This WIP website is <strong>pre-alpha</strong> quality. It is buggy, glitchy, and not pretty. Feedback is welcome, but do understand that I am <strong>NOT</strong> focusing on style or look. Currently I am working on <strong>user</strong> features, function/flow, performance, and security. We'll make it pretty later. The website will be live later this year. <strong><span onclick="warning_Hide();">[close]</span></strong>
</div>
<script>
function SendLogin() {
xhr_PostJSON( "/a/user/login/", "l=testuser&p=test",
function( response, code ) {
if ( code == 200 ) {
document.getElementById("ldbar-notifications").innerHTML = response['id'];
}
else if ( code == 401 ) {
document.getElementById("ldbar-notifications").innerHTML = ":(";
}
else {
document.getElementById("ldbar-notifications").innerHTML = "x";
}
}
);
}
function SendLogout() {
xhr_PostJSON( "/a/user/logout/", "",
function( response, code ) {
if ( code == 200 ) {
document.getElementById("ldbar-notifications").innerHTML = 0;
}
else {
document.getElementById("ldbar-notifications").innerHTML = "x";
}
}
);
}
function updateLDBar() {
if ( getCookie('ldbar') === '1' ) {
document.getElementById('ldbar-outer').style.position = '';
document.getElementById('ldbar-pad').style.display = 'none';
document.getElementById('ldbar-toggle').innerHTML = '[ ]';
}
else {
document.getElementById('ldbar-outer').style.position = 'fixed';
document.getElementById('ldbar-pad').style.display = '';
document.getElementById('ldbar-toggle').innerHTML = '[x]';
}
}
function toggleLDBar() {
var val = !(getCookie('ldbar') === '1');
if ( val ) {
setCookie('ldbar',1);
}
else {
removeCookie('ldbar');
}
updateLDBar();
}
updateLDBar();
function bar_Hide( self ) {
if ( self.style.height=="8px") {
self.style.height="";
}
else {
self.style.height="8px";
}
}
function item_ShowEdit( id ) {
document.getElementById('flextext-'+id).style.display = '';
document.getElementById('preview-'+id).style.display = 'none';
// document.getElementById('item-'+id).style.maxHeight = document.getElementById('item-'+id).scrollHeight +"px";
}
function item_ShowPreview( id ) {
document.getElementById('flextext-'+id).style.display = 'none';
document.getElementById('preview-'+id).style.display = '';
// document.getElementById('item-'+id).style.maxHeight = document.getElementById('item-'+id).scrollHeight +"px";
}
function item_UpdateEdit( o ) {
var rows = o.value.split("\n").length;
o.rows = (rows > 4) ? rows : 4;
}
function warning_Hide() {
document.getElementById('warning').style.display = 'none';
document.cookie = "hide-warning=1";
}
</script>
<!-- *************** -->
<style>
body {
background: #EEE;
}
#content {
margin:0 auto;
max-width:900px;
-webkit-transition: max-width 1s;
transition: max-width 1s;
}
@media (min-width : 1600px) {
#content {
max-width:1286px; /*1300*/
}
}
#content .item {
margin:16px auto;
background:#FFF;
overflow:hidden;
box-shadow: 0 0 3px rgba(0,0,0,0.2);
/*max-height:0;*/
-moz-transition: max-height 1s;
-webkit-transition: max-height 1s;
transition: max-height 1s;
}
#content .item-post {
}
#content .item-game {
width:90%;
background:#CDF;
border: 1px solid #89C;
border-bottom: 8px solid #89C; /* Hack, until controls */
}
#content .item .header {
padding:0 1.5em;
margin:1em 0;
}
#content .item .separator {
border-top:1px dashed rgba(0,0,0,0.5);
}
#content .item .body {
padding:0 1.5em;
margin:1em 0;
}
#content .item .footer {
background:#888;/*#CCC;/*rgba(0,0,0,0.1);*/
color:#FFF;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Item Header */
#content .item .header h1 {
font-size:2em;
line-height:1.2;
margin:0;
}
#content .item .header .info {
font-size:0.7em;
line-height:1;
/* line-height is typically 1.2, so this is to compensate for the 2x top of <h1> */
padding-bottom:0.4em;
}
#content .item .header .avatar {
float:right;
width:3.1em;
max-width:64px;
height:3.1em;
max-height:64px;
background-size:cover; /* DIV only */
}
/* Item Footer */
#content .item .footer div {
padding:1em 1.5em;
}
/* On Mobile, less edge margin */
@media (max-width : 600px) {
#content .item-game {
width:95%;
}
#content .item .header {
padding:0 0.75em;
}
#content .item .body {
padding:0 0.75em;
}
#content .item .footer div {
padding:1em 0.75em;
}
}
#metas .node {
padding-left:24px;
font-family:'Inconsolata',monospace;
}
#metas .key {
display:inline;
font-weight:bold;
}
#content .item span code {
background:#EEE;/*#FDC;*/
padding:4px 8px;
margin:0 4px;
border-radius:8px;
}
/* FlexText */
.flextext {
position: relative;
*zoom: 1;
}
textarea,
.flextext {
outline: 0;
margin: 0;
border: none;
padding: 0;
*padding-bottom: 0 !important;
}
.flextext textarea,
.flextext pre {
white-space: pre-wrap;
width: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
*white-space: pre;
*word-wrap: break-word;
}
.flextext textarea {
overflow: hidden;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
resize: none;
/* IE7 box-sizing fudge factor */
*height: 94%;
*width: 94%;
}
.flextext pre {
display: block;
visibility: hidden;
}
textarea,
.flextext pre {
/*margin: 0;*/
border: 1px solid #000;
padding: 4px;
background:#EED;
/*
* Add custom styling here
* Ensure that typography, padding, border-width (and optionally min-height) are identical across textarea & pre
*/
}
</style>
<style>
/* Chicken Navigation */
#nav .row {
margin-left:16px;
padding:2px;
}
#nav .row:hover {
background:#CCF;
}
#nav .slug {
display:inline;
font-family:'Inconsolata',monospace;
}
#nav .id, #nav .name, #nav .type {
display:inline;
position:absolute;
}
#nav .id {
left:256px;
}
#nav .name {
left:360px;
}
#nav .type {
left:960px;
}
#nav .proxy {
background:#CFC;
}
#nav .link {
background:#FCC;
}
#nav .authored {
background:#FCF;
}
</style>
<?php if ( $mode === M_DEFAULT ) { ?>
<?php
echo "<!-- Debug\n";
/*
$query =
'SELECT % FROM % WHERE'.
' % in (%)' .
' AND % = ?' .
';';
$args = [
'id',4,
'type'
];
echo _db_BuildQueryString(
$query,
'*',CMW_TABLE_SCHEDULE_SUBSCRIPTION,
'id',4,
'type'
);
echo "\n";
print_r( _db_BuildArgList($args) );
global $NODE_SCHEMA;
print_r( _db_ParseArgList($args,$NODE_SCHEMA) );
*/
// $active_events = schedule_GetActiveIds();
// $events = schedule_GetByIds( $active_events ); // cacheme
//
// $active_parents = [];
// foreach ( $events as &$event ) {
// $active_parents[] = $event['parent'];
// }
// $active = array_unique(array_merge($active_parents,$active_events));
// print_r($active);
//
// $subscriptions = schedule_GetSubscriptionsByUserIds(699);
// print_r($subscriptions);
//
// $mine = array_intersect($active,$subscriptions);
// print_r($mine);
// $scheduled_events = schedule_GetActiveIds();
// print_r( $scheduled_events );
//
// $schedules = schedule_GetByIds( $scheduled_events );
// print_r( $schedules );
//
// $family = schedule_GetFamilyByIds( [55,69] );
// print_r( $family );
echo " -->";
?>
<?php if ( $this_node['type'] === 'root' ) { ?>
<div id="content">
<?php
$items = node_GetNodesByIds(node_GetPublishedNodeIdsByTypes(['post','game']));
$author_ids = [];
foreach($items as $item) {
$author_ids[] = $item['author'];
}
$author_ids = array_unique($author_ids);
$authors = node_GetNodesByIds($author_ids);
foreach($items as $item) {
echo '<div class="item item-'.$item['type'].'" id="item-'.$item['id'].'">';
if ( $item['type'] === 'post' ) {
echo '<div class="header emoji">';
if ( !empty($item['author']) && $authors[$item['author']]['slug'] == 'pov' ) {
// Image Version //
echo '<img class="avatar" src="//192.168.48.48:8080/logo/mike/Chicken64.png" />';
// Div Version //
//echo '<div class="avatar" style="background-image:url(//192.168.48.48:8080/logo/mike/Chicken64.png);"></div>';
}
echo '<h1>' . $item['name'] .'</h1>';
echo '<div class="info">';
if ( !empty($item['author']) ) {
echo "by <span class='author'><a href='/user/".$authors[$item['author']]['slug']."' title='".$authors[$item['author']]['slug']."'>" . $authors[$item['author']]['name'] . "</a></span>. ";
}
echo 'Posted <span class="date" data="'.date(DATE_W3C,$item['time_published']).'" title="'.date('l, F d, Y H:i:s (T)',$item['time_published']).'">'.date('l, F d, Y H:i:s (T)',$item['time_published']).'</span></div>';
// if ( !empty($item['author']) ) {
// echo "<h3>by <a href='/user/".$authors[$item['author']]['slug']."' title='".$authors[$item['author']]['slug']."'>" . $authors[$item['author']]['name'] . "</a></h3>";
// }
echo "</div>\n";
echo '<div class="separator"></div>';
echo '<div class="body format">';
// TODO: replace all the textarea related code with a function call for generating one. JS and PHP.
// TODO: Add TAB support (and ESC to de-focus the textbox, since otherwise keyboard can't de-focus)
// TODO: Emoji Autocompletion
// TODO: Image Autocompletion (once uploaded)
// TODO: Jumbomoji support (i.e. my *bigger* custom emoji. :key-wasd: etc)
// TODO: Jumbomoji Autocompletion
// TODO: Fix smileys surrounded by \n's (not working if an \n is on either side)
if ( !empty($item) ) {
// http://alistapart.com/article/expanding-text-areas-made-elegant
// https://github.com/alexdunphy/flexText
echo '<div class="flextext" id="flextext-'.$item['id'].'" style="display:none;">';
echo '<pre><span id="flextext-span-'.$item['id'].'"></span><br /><br /></pre>';
echo '<textarea class="edit" id="edit-'.$item['id'].'" oninput="flextext_Update('.$item['id'].');" onpropertychange="flextext_Update('.$item['id'].');" onkeyup="flextext_Update('.$item['id'].');" onchange="flextext_Update('.$item['id'].');">' . $item['body'] . '</textarea>';
echo '</div>';
echo '<div class="preview" id="preview-'.$item['id'].'"></div>';
}
echo '</div>';
echo '<div class="footer" onclick="bar_Hide(this);" style="height:8px">';
echo '<div>';
echo '<span onclick="item_ShowEdit('.$item['id'].');">PATCH</span>';
echo ' | ';
echo '<span onclick="item_Parse('.$item['id'].');item_ShowPreview('.$item['id'].');">PREVIEW</span>';
echo '</div>';
echo '</div>';
}
else if ( $item['type'] === 'game' ) {
echo '<div class="header emoji">';
echo '<h1>' . $item['name'] .'</h1>';
echo '<div class="info">';
if ( !empty($item['author']) ) {
echo "by <span class='author'><a href='/user/".$authors[$item['author']]['slug']."' title='".$authors[$item['author']]['slug']."'>" . $authors[$item['author']]['name'] . "</a></span>. ";
}
echo 'Submitted <span class="date" data="'.date(DATE_W3C,$item['time_published']).'" title="'.date('l, F d, Y H:i:s (T)',$item['time_published']).'">'.date('l, F d, Y H:i:s (T)',$item['time_published']).'</span>';
echo '</div>';
echo "</div>\n";
echo '<div class="body format">';
echo "This is a game submission part of the main timeline. Screenshots and other presentable elements go here.";
echo '</div>';
}
echo '</div>';
}
?>
<!-- <?php print_r($items); ?> -->
<!-- <?php print_r($author_ids); ?> -->
<!-- <?php print_r($authors); ?> -->
</div>
<?php } else { ?>
<div id="content">
<?php
$item = &$this_node;
if ( $item['type'] === 'page' ) {
echo '<div class="item item-'.$item['type'].'" id="item-'.$item['id'].'">';
echo '<div class="header emoji"><h1>'.$item['name'].'</h1></div>';
if ( !empty($item['body']) ) {
echo '<textarea class="body-edit" rows="24" cols="120" style="display:none;">'.$this_node['body'].'</textarea>';
echo '<div class="body format"></div>';
}
echo '</div>';
}
else if ( $item['type'] === 'user' ) {
?>
<div class="item">
<div class="title"><h1><?php echo $this_node['name']; ?></h1><?php if ( $author_node ) { echo "<h3>by <a href='/user/".$author_node['slug']."'>" . $author_node['name'] . "</a></h3>"; } ?></div>
<?php
if ( !empty($this_node['body']) ) {
?><textarea class="body-edit" rows="24" cols="120" style="display:none;"><?php echo $this_node['body']; ?></textarea>
<div class="body format"></div><?php
} ?>
<?php
if ( $this_node['type'] === 'user' ) {
echo "<br />";
?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Topping');
data.addColumn('number', 'Slices');
data.addRows([
['Mushrooms', 4],
['Onions', 3],
['Olives', 2],
['Zucchini', 1],
['Pepperoni', 7]
]);
// Set chart options
var options = {'title':'How Much Pizza I Ate Last Minute',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<div id="chart_div" style="display:inline-block;"></div><img src="<?php
echo ichart_GetPie(400,300,[10,12,15],['ham','hem','hom']);
?>" />
<?php
echo "<br>";
echo '<div id="games" class="emoji"><h3>Games:</h3>';
$games = node_GetNodesByAuthorIdAndType($this_node['id'],'game');
foreach( $games as $game ) {
echo "<a href=\"/user/" . $this_node['slug'] . "/" . $game['slug'] . "\">" . $game['name'] . "</a><br/>";
}
echo '</div>';
echo "<br />";
echo '<div id="metas"><h3>Metadata ('.$this_node['id'].'):</h3>' ;
$metas = node_GetMetasById( $this_node['id'] );
function process_meta( $meta ) {
echo "<div class='node'>";
foreach( $meta as $key => $value ) {
if ( is_array($value) ) {
if ( is_string($key) )
$key = "\"".$key."\"";
echo "<div class='key'>".$key . ":</div><br/>";
process_meta($value);
}
else {
if ( is_string($key) )
$key = "\"".$key."\"";
if ( is_string($value) )
echo "<div class='key'>".$key . ":</div> \"" . $value . "\"<br />";
else
echo "<div class='key'>".$key . ":</div> " . $value . "<br />";
}
}
echo "</div>";
}
process_meta($metas);
// print_r($metas);
echo "</div>";
}
?>
</div>
</div>
<?php } /* type */ ?>
<?php
}
?>
<div id='nav' class='emoji' style="padding:16px;display:none;">
<?php
echo "/" . $args_merged . " [".$this_node_id."]<br />\n";
if ( $args_count >= 1 ) {
echo "<div class='row'>\n";
echo "<div class='slug'><a href='../'>../</a></div><br />\n";
echo "</div>\n";
}
foreach( $nodes as $node ) {
echo "<div class='row ".$node['type'].($node['author']>0?" authored":"")."'>\n";
if ( $node['type'] === 'link' ) {
echo "<div class='slug'><a href='".$node['name']."/'>" . $node['slug'] . "/</a></div> <div class='id'>*".$node['id']."*</div> <div class='type'>(".$node['type'].")</div><br />\n";
}
else {
echo "<div class='slug'><a href='".$node['slug']."/'>" . $node['slug'] . "/</a></div> <div class='id'>[".$node['id']."]</div> <div class='name'>".$node['name']."</div> <div class='type'>(".$node['type'].")</div><br />\n";
}
echo "</div>\n";
}
?>
</div>
<div>
<img src="<?php STATIC_URL(); ?>/img/logo/mike/Chicken16.png?crop&w=256&h=128" onclick="document.getElementById('nav').style.display='';">
</div>
<?php /*
<div id="debug">
<h2>Debug S:</h2>
<?php
if ( isset($_SESSION) ) {
print_r($_SESSION);
echo "<br />";
}
echo "Login token is " . (_user_IsLoginTokenValid() ? "valid" : "invalid") . ".";
?>
<h2>Debug C:</h2>
<script>
document.getElementById('debug').innerHTML += document.cookie;
</script>
</div>
*/ ?>
<?php } else if ( $mode === M_ERROR ) { ?>
<div id="content">
<div class="title"><h1><a href=".">Nope</a></h1></div>
</div>
<?php } /* $mode */ ?>
<script>
function UpdateDate( el ) {
var PostDate = new Date(el.getAttribute('data'));
var DiffDate = (Date.now() - PostDate);
var DateString = '<span class="date-diff">';
if ( DiffDate < 0 ) {
DateString += "in the future";
}
else if ( DiffDate < 1000*60*2 ) {
DateString += "right now";
}
else if ( DiffDate < 1000*60*60 ) {
DateString += Math.floor(DiffDate/(1000*60)) + " minutes ago";
}
else if ( DiffDate < 1000*60*60*2 ) {
if ( DiffDate < 1000*60*30*3 )
DateString += "an hour ago";
else
DateString += "an hour and a half ago";
}
else if ( DiffDate < 1000*60*60*24 ) {
DateString += Math.floor(DiffDate/(1000*60*60)) + " hours ago";
}
else if ( DiffDate < 1000*60*60*24*2 ) {
if ( DiffDate < 1000*60*60*12*3 )
DateString += "a day ago";
else
DateString += "a day and a half ago";
}
else if ( DiffDate < 1000*60*60*24*7*2 ) { // 2 weeks of days
DateString += Math.floor(DiffDate/(1000*60*60*24)) + " days ago";
}
else if ( DiffDate < 1000*60*60*24*((7*4*3)+7.5) ) { // 12 weeks (briefly 13)
DateString += Math.floor(DiffDate/(1000*60*60*24*7)) + " weeks ago";
}
else if ( DiffDate < 1000*60*60*24*182*3 ) {
DateString += Math.floor(DiffDate/(1000*60*60*24*30.5)) + " months ago";
}
else if ( DiffDate < 1000*60*60*24*365*2 ) {
DateString += "a year and a half ago";
}
else {
DateString += Math.floor(DiffDate/(1000*60*60*24*365)) + " years ago";
}
DateString += '</span>';
DateString += '. ';
DateString += '<span class="date-local">';
{
// http://stackoverflow.com/a/20463521
// console.log("toString: " + PostDate.toString());
// console.log("toLocaleString: " + PostDate.toLocaleString());
// console.log("toLocaleTimeString: " + PostDate.toLocaleTimeString());
var Parts = PostDate.toString().split(" ");
// Pass only if the length is 9, and the GMT slot is in the correct spot.
if ( (Parts.length == 7) && (Parts[5].indexOf('GMT') != -1) ) {
var DaysOfWeek = {
'sun':"Sunday",
'mon':"Monday",
'tue':"Tuesday",
'wed':"Wednesday",
'thu':"Thursday",
'fri':"Friday",
'sat':"Saturday",
};
var MonthsOfYear = {
'jan':"January",
'feb':"February",
'mar':"March",
'apr':"April",
'may':"May",
'jun':"June",
'jul':"July",
'aug':"August",
'sep':"September",
'oct':"October",
'nov':"November",
'dec':"December",
};
// Day of the week //
if ( DaysOfWeek.hasOwnProperty(Parts[0].toLowerCase()) )
DateString += DaysOfWeek[Parts[0].toLowerCase()] + ", ";
else
DateString += Parts[0] + ", ";
// Month of the year //
if ( MonthsOfYear.hasOwnProperty(Parts[1].toLowerCase()) )
DateString += MonthsOfYear[Parts[1].toLowerCase()] + " ";
else
DateString += Parts[1] + " ";
DateString += Parts[2] + ", "; // Day //
DateString += Parts[3] + " "; // Year //
// 12 hour Timezone (if we can detect it) //
if ( PostDate.toLocaleTimeString().split(" ").length > 1 ) {
var TimeParts = Parts[4].split(':');
var Hour = parseInt(TimeParts[0]);
var AMPM = 'AM';
if ( Hour == 0 ) {
Hour = 12;
}
else if ( Hour == 12 ) {
AMPM = 'PM';
}
else if ( Hour > 12 ) {
Hour -= 12;
AMPM = 'PM';
}
DateString += Hour + ":";
DateString += TimeParts[1] + " ";
DateString += AMPM + " ";
}