-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
762 lines (667 loc) · 32.1 KB
/
view.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
<?php
session_start();
require_once("cookie.php");
require_once("functions.php");
if(isset($_GET['id'])){
$scoreNum = $_GET['id'];
}else{
$scoreNum = -1;
}
dbconnect();
$query = "SELECT * FROM CT_Score WHERE id = ".mysql_real_escape_string($scoreNum).";";
$result = mysql_query($query, $connect);
$numOfResult = mysql_num_rows($result);
if(!isset($_GET['id']) || $numOfResult == 0){
$_SESSION['error'] = "The score you tried to access does not exist!";
header("Location: browse.php");
}else{
// get data from the database
$fetchResult = mysql_query($query, $connect);
}
dbclose();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<script src="./assets/libraries/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="./ct.js"></script>
<script src="assets/libraries/select/select2.js"></script>
<link href='http://fonts.googleapis.com/css?family=Kotta+One|Raleway:400|Average' rel='stylesheet' type='text/css'/>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="./assets/style.css">
<link rel="stylesheet" href="./assets/libraries/select/select2.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
</head>
<body>
<div id="bg"></div>
<div class="page">
<div class="top_nav">
<div class="logo_top" onclick="location.href='index.php';">
<img src="assets/images/logo.png"/>
</div>
<div class="topmenus">
<ul>
<li id="aboutPage">About</li>
<div id="signUp">
<div id="signUp_header"><br>Sign Up</div>
<div id="signUp_body">
<form id="FormSignUp" method="post" action="signup.php" data-ajax="false">
<div id="notifier">Notifier</div>
<input type="text" name="new_firstName" id="new_firstName" data-mini="true" placeholder="Your first name"><input type="text" data-mini="true" id="new_lastName" name="new_lastName" placeholder="Your last name">
<input type="text" data-mini="true" id="new_Email" name="new_Email" placeholder="Enter your email address">
<input type="password" data-mini="true" id="new_Pw" name="new_Pw" placeholder="Set your password">
<input type="password" data-mini="true" id="new_Pw_verify" name="new_Pw_verify" placeholder="Enter your password again">
<input type="hidden" name="loginType" value=2>
<input type="submit" id="FSU_submit" value="Sign up" ><input type="button" value="Cancel" onclick='$("#signUp").fadeOut(300);'>
</form>
</div>
</div>
<?php
if(!isset($_SESSION['primaryId']) || $_SESSION['primaryId'] == ''){
echo('
<li id="loginW">Sign in via Google</li>
<div id="loginWindow">
<div id="formComponents">
<form id="Form_keepSigned" action="index.php" method="get" data-ajax="false">
<input type="checkbox" name="keepSignedIn" value=1 id="keepSignedIn" data-role="none">
<input type="hidden" name="loginType" value=1> <!-- value 1 for openID Login, value 2 for traditional Login -->
<label for="keepSignedIn">Keep me signed in</label>
</form>
</div>
</div>
<li id="loginWN">Sign in</li>
<div id="loginWindowN">
<div id="formComponentsN">
<form id="Form_keepSignedN" action="index.php" method="post" data-ajax="false">
<input type="text" name="userEmail" placeholder="Email"><input type="password" placeholder="Password" name="userPw">
<input type="checkbox" name="keepSignedInN" value=1 id="keepSignedInN" data-role="none">
<label for="keepSignedInN">Keep me signed in</label>
<input type="hidden" name="loginType" value=2> <!-- value 1 for openID Login, value 2 for traditional Login -->
<div data-role="fieldcontain">
<input type="submit" id="normal_signin" value="Sign in"><input type="button" id="normal_signup" value="Sign up"><input type="button" id="normal_help" value="Help!">
</div>
</form>
</div>
</div>
');
}else{
echo("<li id='logOut'>Log out</li>");
echo("<li id='userPanel'>".$_SESSION['firstName']."</li>");
echo("<li id='upload' onclick=location.href='upload.php'>Upload a score</li>");
}
?>
</ul>
</div>
<div id="notification_main"></div>
</div>
<div class="main_layout">
<div class="main_left">
<div class="catList">
<span class="catListHeader">Browse scores by</span>
<ul>
<li id="br_all">All (<span id="numAll"></span>)</li>
<li id="br_genre" onclick="$('.subGenre').toggle();">Genre (<span id="numGenre"></span>)</li>
<?php
dbconnect();
$query_Cat = "SELECT * FROM CT_Genre;";
$result_Cat = mysql_query($query_Cat, $connect);
while($data = mysql_fetch_array($result_Cat)){
$query_scoresOfSubcat = "SELECT COUNT(*) FROM CT_Genre WHERE genre = '".$data["genre"]."';";
$result_scoresOfSubcat = mysql_query($query_scoresOfSubcat, $connect);
$numOfScoresOfSubcat = mysql_fetch_array($result_scoresOfSubcat);
echo('<li class="subGenre" data-link="browse.php?srchType=genre&keyword='.$data["genre"].'">'.htmlentities($data["genre"]).' ('.$numOfScoresOfSubcat[0].')</li>');
}
dbclose();
?>
<li id="br_composer" onclick="$('.subComposer').toggle();">Composer (<span id="numComp"></span>)</li>
<?php
dbconnect();
$query_Cat = "SELECT composer FROM CT_Score WHERE composer IS NOT NULL;";
$result_Cat = mysql_query($query_Cat, $connect);
while($data = mysql_fetch_array($result_Cat)){
$query_scoresOfSubcat = "SELECT COUNT(*) FROM CT_Score WHERE composer = '".$data["composer"]."';";
$result_scoresOfSubcat = mysql_query($query_scoresOfSubcat, $connect);
$numOfScoresOfSubcat = mysql_fetch_array($result_scoresOfSubcat);
echo('<li class="subComposer" data-link="browse.php?srchType=composer&keyword='.$data["composer"].'">'.htmlentities($data["composer"]).' ('.$numOfScoresOfSubcat[0].')</li>');
}
dbclose();
?>
<li id="br_composeyear" onclick="$('.subComposeYear').toggle();">Compose year (<span id="numCompYear"></span>)</li>
<?php
dbconnect();
$query_Cat = "SELECT composeYear FROM CT_Score WHERE composeYear IS NOT NULL;";
$result_Cat = mysql_query($query_Cat, $connect);
while($data = mysql_fetch_array($result_Cat)){
$query_scoresOfSubcat = "SELECT COUNT(*) FROM CT_Score WHERE composeYear = '".$data["composeYear"]."';";
$result_scoresOfSubcat = mysql_query($query_scoresOfSubcat, $connect);
$numOfScoresOfSubcat = mysql_fetch_array($result_scoresOfSubcat);
echo('<li class="subComposeYear" data-link="browse.php?srchType=composeYear&keyword='.$data["composeYear"].'">'.htmlentities($data["composeYear"]).' ('.$numOfScoresOfSubcat[0].')</li>');
}
dbclose();
?>
<li id="br_publishyear" onclick="$('.subPublishYear').toggle();">Publish year (<span id="numPubYear"></span>)</li>
<?php
dbconnect();
$query_Cat = "SELECT publishYear FROM CT_Score WHERE publishYear IS NOT NULL;";
$result_Cat = mysql_query($query_Cat, $connect);
while($data = mysql_fetch_array($result_Cat)){
$query_scoresOfSubcat = "SELECT COUNT(*) FROM CT_Score WHERE publishYear = '".$data["publishYear"]."';";
$result_scoresOfSubcat = mysql_query($query_scoresOfSubcat, $connect);
$numOfScoresOfSubcat = mysql_fetch_array($result_scoresOfSubcat);
echo('<li class="subPublishYear" data-link="browse.php?srchType=publishYear&keyword='.$data["publishYear"].'">'.htmlentities($data["publishYear"]).' ('.$numOfScoresOfSubcat[0].')</li>');
}
dbclose();
?>
<li id="br_instrumentation" onclick="$('.subInstrumentation').toggle();">Instrumentation (<span id="numInst"></span>)</li>
<?php
dbconnect();
$query_Cat = "SELECT DISTINCT instrumentation FROM CT_Instrumentation;";
$result_Cat = mysql_query($query_Cat, $connect);
while($data = mysql_fetch_array($result_Cat)){
$query_scoresOfSubcat = "SELECT COUNT(*) FROM CT_Instrumentation WHERE instrumentation = '".$data["instrumentation"]."';";
$result_scoresOfSubcat = mysql_query($query_scoresOfSubcat, $connect);
$numOfScoresOfSubcat = mysql_fetch_array($result_scoresOfSubcat);
echo('<li class="subInstrumentation" data-link="browse.php?srchType=instrumentation&keyword='.$data["instrumentation"].'">'.htmlentities($data["instrumentation"]).' ('.$numOfScoresOfSubcat[0].')</li>');
}
dbclose();
?>
</ul>
</div>
</div>
<div class="main_right">
<div class="srchbox">
<div id="category" data-role="fieldcontain">
<select data-inline="true" id="srchType" class="cat">
<option value="title">Title</option>
<option value="genre">Genre</option>
<option value="composer">Composer</option>
<option value="composeYear">Compose year</option>
<option value="publishYear">Publish year</option>
<option value="instrumentation">Instrumentation</option>
<option value="tag">Tag</option>
</select>
</div>
<div id="textinput" data-role="fieldcontain">
<input data-inline="true" type="text" id="keyword" name="keyword" placeholder="Type in keywords here" class="keyword">
<a data-role="button" id="submit">Search</a>
</div>
</div>
<div class="itemList">
<?php
$data = mysql_fetch_array($fetchResult);
// uploaded by
dbconnect();
$up_Query = "SELECT firstName FROM CT_User WHERE id = ".$data['uploadedBy'].";";
$up_Result = mysql_query($up_Query, $connect);
// only for genre data
$genre_Query = getSQLFromID("genre", $data['id']);
$genre_Result = mysql_query($genre_Query, $connect);
// only for style data
$style_Query = getSQLFromID("style", $data['id']);
$style_Result = mysql_query($style_Query, $connect);
// only for instrumentation data
$instr_Query = getSQLFromID("instrumentation", $data['id']);
$instr_Result = mysql_query($instr_Query, $connect);
// only for tag data
$tag_Query = getSQLFromID("tag", $data['id']);
$tag_Result = mysql_query($tag_Query, $connect);
// only for comments data
$comments_Query = getSQLFromID("comment", $data['id']);
$comments_Result = mysql_query($comments_Query, $connect);
// only for flagHistory data
$flag_Query = getSQLFromID("flagHistory", $data['id']);
$flag_Result = mysql_query($flag_Query, $connect);
dbclose();
echo('
<div class="detailTitle">'.htmlentities($data["title"]).'<div class="flagItContainer">
<div class="flagItHeader">Report this score</div>
<div class="flagIt"><span class="warning">You are about to report the following score.<br></span><span style="color: #455F7B; font-weight: bold; font-size: 16px; margin-top: 7px; display: inline-block; margin-bottom: 7px;">'.htmlentities($data["title"]).'</span><span class="warning"><br>Please make sure that you have proper sources as you describe the reason(s) for this claim in the text field below. This report will be reviewed by the operators as soon as it is submitted. Also, by reporting this score as problematic, you agree that other users can participate in the rebuttal process to prevent, if any, misjudgements.</span><hr style="width: 99%;" color="#BBBBBB" size="1" no-shade></hr><form id="flagForm" data-ajax="false"><textarea data-role="none" rows=9 cols=77 id="flagDesc" name="flagDesc"></textarea><br>'); if(isset($_SESSION['primaryId'])){ echo('<input type="hidden" id="flagTo" name="flagTo" value='.htmlentities($data['id']).'><input type="hidden" id="flagBy" name="flagBy" value='.$_SESSION['primaryId'].'>');} echo('<input type="submit" value="Report" id="submitFlag"><input type="button" value="Cancel" id="cancelButton" onclick=$(".flagItContainer").fadeOut(300)></form></div>
</div></div>
<div class="actions">
<span id="backToList"><img src="assets/images/back.png"><br>Back to list</span></div><div class="actionsContent"><span id="addToList" data-link='.$data['id'].'><img src="assets/images/add.png"><br>Add to mylist</span><span id="download" data-link='.$data['downloadLink'].'><img src="assets/images/download.png"><br>Download this score</span><span id="like"><img src="assets/images/like.png"><br>Like this score</span><span id="flag"><img src="assets/images/flag.png"><br>Report this score</span>
</div><br><br><br><br>
<div class="scoreDetail">
<span class="subTitle">General Information</span><br><div id="scoreimg"><img src="'.htmlentities($data["downloadLink"]).'" width=190 height=190></div>
<div class="txt">
<span class="key">Composer</span><span class="value">'.htmlentities($data["composer"]).'</span><br>
<span class="key">Compose Year</span><span class="value">'.htmlentities($data["composeYear"]).'</span><br>
<span class="key">Genre</span><span class="value">');
while($dataGenre = @mysql_fetch_array($genre_Result)){
echo("<span class='genres' data-link='browse.php?srchType=genre&keyword=".htmlentities($dataGenre["genre"])."'>".htmlentities($dataGenre["genre"])." </span>");
}
echo('</span><br>
<span class="key">Opus Number</span><span class="value">'.htmlentities($data["opusNum"]).'</span><br>
<span class="key">Key</span><span class="value">'.htmlentities($data["key"]).'</span><br>
<span class="key">Language</span><span class="value">'.htmlentities($data["language"]).'</span><br>
<span class="key">Piece Style</span><span class="value">');
while($dataStyle = @mysql_fetch_array($style_Result)){
echo("<span class='genres not'>".htmlentities($dataStyle["style"])." </span>");
}
echo('</span><br>
<span class="key">Instrumentation</span><span class="value">');
while($dataInstr = @mysql_fetch_array($instr_Result)){
echo("<span class='genres' data-link='browse.php?srchType=instrumentation&keyword=".htmlentities($dataInstr["instrumentation"])."'>".htmlentities($dataInstr["instrumentation"])." </span>");
}
echo('</span><br>
</div>
</div>
<div class="scoreDetail">
<span class="subTitle">Music Score Information</span><br>
<div class="txt">
<span class="key">Publish Year</span><span class="value">'.htmlentities($data["publishYear"]).'</span><br>
<span class="key">Uploaded by</span><span class="value">');
$dataUp = mysql_fetch_array($up_Result);
echo("<span class='friend'>".htmlentities($dataUp[0]).'</span>
<div class="friendProfileContainer">
<div class="friendProfile">
<img src="'.getSpecific("CT_User","avatarPic","id=".$data["uploadedBy"]).'">
<div class="name">'.htmlentities(getSpecific("CT_User","firstName", "id=".$data["uploadedBy"])).' '.htmlentities(getSpecific("CT_User","lastName", "id=".$data["uploadedBy"])).'</div>
<div class="buttonArea">
<ul>');
// checks whether the user has the uploader as friend
if(isset($_SESSION['primaryId'])){
if($data['uploadedBy'] == $_SESSION['primaryId']){
echo("<li id='isFriend' class='myself'>Myself</li>
");
}else{
dbconnect();
$isFriendQuery = "SELECT id FROM CT_Friends WHERE refUser = ".mysql_real_escape_string($_SESSION['primaryId'])." AND targetUser = ".mysql_real_escape_string($data["uploadedBy"]).";";
$resultIsFriendQuery = mysql_query($isFriendQuery, $connect);
if(mysql_num_rows($resultIsFriendQuery) != 0){
echo("<li id='isFriend' class='already'>Friend already</li>
");
}else{
echo("<li id='isFriend'>Add friends</li>");
}
echo("<script>$('li[id=isFriend]').not('li[class=myself]').click(function(){
$.ajax({
url: 'retrieve.php',
data: {'mode': 5, 'refUser': ".$_SESSION['primaryId'].", 'targetUser': ".$data['uploadedBy']."},
success: function(data){
if(data == 0){
$('li[id=isFriend]').not('li[class=myself]').addClass('already').text('Friend already');
$('li[id=isFriend]').not('li[class=myself]').mouseleave(function(){
$(this).text('Friend already');
});
$('li[id=isFriend]').not('li[class=myself]').mouseenter(function(){
$(this).text('Unfriend');
});
}else if(data == 1){
$('li[id=isFriend]').not('li[class=myself]').removeAttr('class');
$('li[id=isFriend]').not('li[class=myself]').text('Add friends');
$('li[id=isFriend]').not('li[class=myself]').mouseenter(function(){
$(this).text('Add friends');
});
$('li[id=isFriend]').not('li[class=myself]').mouseleave(function(){
$(this).text('Add friends');
});
}else{
alert('quack?');
}
}
});
});
</script>");
dbclose();
}
}else{
echo("<li>Log in first</li>");
}
echo('
<li id="close" onclick=$(".friendProfileContainer").fadeOut(300)>Close</li>
</ul>
</div>
</div>
</div><br>
<span class="key">Description</span><span class="value">'.htmlentities($data["description"]).'</span><br>
</div>
</div>
<div class="scoreDetail">
<span class="subTitle">Tags</span><br>
<div class="txt">');
while($dataTag = @mysql_fetch_array($tag_Result)){
echo("<span class='tags' data-link='browse.php?srchType=tag&keyword=".htmlentities($dataTag[0])."'>".htmlentities($dataTag[0])." </span>");
}
echo('
</div>
</div>
<div class="scoreDetail">
<span class="subTitle">Comments</span><br>
<div class="txt">
<form id="msgForm" data-ajax="false">'); if(isset($_SESSION['firstName'])){ echo('<input type="text" data-inline="true" name="msgContent" id="msgContent"><input type="hidden" value='.$_SESSION['primaryId'].' id="msgBy" name="msgBy">');} echo('<input type="hidden" value='.$data["id"].' id="msgTo" name="msgTo"></form><div class="commentArea">');
while($dataComments = @mysql_fetch_array($comments_Result)){
$tempData = idToValue("firstName", "CT_User", $dataComments['commentBy']);
echo("<div class='msgItem' id=".htmlentities($dataComments['id'])."><span class='name'>".htmlentities($tempData[0])."</span><span class='time'>(".date("M d, Y H:i:s",htmlentities($dataComments['timestamp'])).")</span><span class='msg'>".htmlentities($dataComments['comment'])."</span></div>");
}
echo('
</div></div>
</div>
<div class="scoreDetail">
<span class="subTitle">Flag History</span><br>
<div class="txt">
<div class="commentArea">');
if(mysql_num_rows($flag_Result) == 0){
echo("<span style='color: #aeaeae;' class='msg'>No flag history</span>");
}
while($dataFlag = @mysql_fetch_array($flag_Result)){
$tempData = idToValue("firstName", "CT_User", $dataFlag['flagBy']);
echo("<div class='msgItem' id=".htmlentities($dataFlag['id'])."><span class='name'>".htmlentities($tempData[0])."</span><span class='time'>(".date("M d, Y H:i:s",htmlentities($dataFlag['timestamp'])).")</span><span class='msg'>".htmlentities($dataFlag['description'])."</span>"); if($dataFlag['isResolved'] == 0){ echo('<span class="revoke">resolve</span>');}else{ echo('<span class="time">resolved</span>');} echo("</div>");
}
echo('
</div>
</div>
</div>
');
// if isFlagged = 1, make the download button unable to click
if($data['isFlagged'] == 1){
echo("<script>
$('#download').html('<img src=assets/images/download.png><br>Reported');
$('#download').addClass('inDispute');
$('.actions span[id=flag]').remove();
$('#scoreimg').html('<br><br><br><br><div style=\'color:#FFFFFF;text-align:center;\'>Reported</div>');
</script>");
}
$likeList = explode(",", $data["likeList"]);
if(isset($_SESSION['userEmail']) && in_array($_SESSION['userEmail'], $likeList)){
echo("<script>
$('#like').html('<img src=assets/images/like2.png><br>Liked this score');
$('#like').addClass('liked');
</script>");
}
if(isset($_SESSION['primaryId'])){
$mylistId = getSpecific("CT_Mylist", "id", "creator = ".$_SESSION['primaryId']);
}else{
$mylistId = -1;
}
dbconnect();
$queryIsMylistItem = "SELECT id FROM CT_MylistEntity WHERE refScrapbook = ".$mylistId." AND refScore = ".$data['id'].";";
$resultMylistItem = mysql_query($queryIsMylistItem, $connect);
if(mysql_num_rows($resultMylistItem) > 0){
echo("<script>
$('#addToList').html('<img src=assets/images/add.png><br>Added to mylist');
$('#addToList').addClass('added');
</script>");
}
echo("
<script>document.title='".htmlentities($data['title'])."';</script>
");
dbclose();
?>
</div>
</div> </div>
<div class="footer">
</div>
</div>
<script>
// should be exported to a separate JS file
var availableTags, signUpWidth;
var comments = [];
$('#msgForm').submit(function(e){
$.ajax({
url: 'retrieve.php',
data: {'mode': 2, 'msgTo': $('#msgForm #msgTo').val(), 'msgBy': $('#msgForm #msgBy').val(), 'msgContent': $('#msgForm #msgContent').val()},
success: function(data){
location.href='view.php?id='+$('#msgForm #msgTo').val();
}
});
e.preventDefault();
});
$('#flagForm').submit(function(e){
$.ajax({
url: 'retrieve.php',
data: {'mode': 3, 'flagBy': $('#flagForm #flagBy').val(), 'flagTo': $('#flagForm #flagTo').val(), 'flagDesc': $('#flagForm #flagDesc').val()},
success: function(data){
location.href='view.php?id='+$('#flagForm #flagTo').val();
}
});
e.preventDefault();
});
$('#FSU_submit').click(function(e){
var firstName = $('#new_firstName').val();
var lastName = $('#new_lastName').val();
var Email = $('#new_Email').val();
var Pw = $('#new_Pw').val();
var Pw_verify = $('#new_Pw_verify').val();
if(firstName == ''){ $('#notifier').html('First name field is empty!').show(); $('#new_firstName').focus(); e.preventDefault(); }
if(lastName == ''){ $('#notifier').html('Last name field is empty!').show(); $('#new_lastName').focus(); e.preventDefault(); }
if(Email == ''){ $('#notifier').html('Email field is empty!').show(); $('#new_Email').focus(); e.preventDefault(); }
if(Pw == ''){ $('#notifier').html('Password field is empty!').show(); $('#new_Pw').focus(); e.preventDefault(); }
if(firstName && lastName && Email && Pw){
if(Pw !== Pw_verify){
$('#notifier').html('Password fields do not match!').show(); $('#new_Pw_verify').focus(); e.preventDefault();
}else{
$('#FormSignUp').submit();
e.preventDefault();
}
}
});
$(window).resize(function(){
signUpWidth = $('#signUp').css('width').toString().substr(0,$('#signUp').css('width').toString().length-2);
signUpHeight = $('#signUp').css('height').toString().substr(0,$('#signUp').css('height').toString().length-2);
signUpWidth = parseInt(signUpWidth);
signUpHeight = parseInt(signUpHeight);
$('#signUp').css({'right': ((window.innerWidth - signUpWidth-50)/2)+'px', 'top': ((window.innerHeight - signUpHeight)/2)+'px'});
/* added in browser.php */
$('.main_right').css('width', (innerWidth - 317)+'px');
$('.srchbox #textinput').css({'width': (innerWidth - 530)+'px'});
$('.srchbox #textinput .ui-input-text').css({'width': (innerWidth - 665)+'px'});
$('.main_right .textInfo').css({'width': (innerWidth - 500)+'px'});
$('.flagItContainer').css({'left': (innerWidth - 1000)/2+'px'});
});
$(document).ready(function(){
// retrieve the number of all data implemented
$.ajax({
url: "retrieve.php",
data: {"mode": 0 },
success: function(data){
jdata = eval("("+data+")");
$("#numAll").text(jdata[0]["scoreNum"]); // all
$("#numGenre").text(jdata[0]["genreNum"]); // genre
$("#numComp").text(jdata[0]["composerNum"]); // composer
$("#numCompYear").text(jdata[0]["composeYearNum"]); // compose year
$("#numPubYear").text(jdata[0]["publishYearNum"]); // publishe year
$("#numInst").text(jdata[0]["instrumentationNum"]); // instrumentation
}
});
/*
$('#keyword').click(function(){
if($(this).val() == 'Type in keywords here'){
$(this).css({'color': '#000000'}).val('');
}
});
*/
/* logo title */
$('#logotitle').click(function(){
location.href="index.php";
});
/* popup context menu handlers */
$('#loginW').on('mouseenter', function(){
$('#loginWindow').show();
$('#loginWindowN').hide();
});
$('#loginW').on('mouseleave', function(){
$('#loginWindow').mouseenter(function(){
$('#loginWindow').show();
});
$('.top_nav').mouseleave(function(){
$('#loginWindow').hide();
});
});
$('#loginWN').on('mouseenter', function(){
$('#loginWindowN').show();
$('#loginWindow').hide();
});
$('#loginWN').on('mouseleave', function(){
$('#loginWindowN').mouseenter(function(){
$('#loginWindowN').show();
});
$('.top_nav').mouseleave(function(){
$('#loginWindowN').hide();
});
});
/* adjusts the location of the signup window based on the current size of the window */
signUpWidth = $('#signUp').css('width').toString().substr(0,$('#signUp').css('width').toString().length-2);
signUpHeight = $('#signUp').css('height').toString().substr(0,$('#signUp').css('height').toString().length-2);
signUpWidth = parseInt(signUpWidth);
signUpHeight = parseInt(signUpHeight);
$('#signUp').css({'right': ((window.innerWidth - signUpWidth-50)/2)+'px', 'top': ((window.innerHeight - signUpHeight)/2)+'px'});
/* added in browser.php */
$('.main_right').css('width', (innerWidth - 317)+'px');
$('.srchbox #textinput').css({'width': (innerWidth - 530)+'px'});
$('.srchbox #textinput .ui-input-text').css({'width': (innerWidth - 665)+'px'});
$('.main_right .textInfo').css({'width': (innerWidth - 500)+'px'});
$('.flagItContainer').css({'left': (innerWidth - 1000)/2+'px'});
/* sign in/up and help event handlers */
$('#loginW').mouseup(function(){
$('#Form_keepSigned').submit();
});
$('#Form_keepSignedN').submit(function(e){
$(this).submit();
e.preventDefault();
});
$('#normal_signup').click(function(){
$('#signUp').fadeIn(300);
$('#loginWindowN').hide();
});
$('#submit').click(function(){
var srchType = $('#srchType').val();
var keyword = $('#keyword').val();
location.href="browse.php?srchType="+srchType+"&keyword="+keyword;
});
$('#keyword').keyup(function(){
$.ajax({
async: false,
url: 'retrieve.php',
data: {'mode': 1, 'srchType': $('#srchType').val(), 'keyword': $('#keyword').val()},
success: function(data){
availableTags = [];
var jdata = eval("("+data+")");
for(var i in jdata){
availableTags.push(jdata[i][0]);
}
}
});
});
// back button
$('#backToList').click(function(){
history.back(1);
});
// download button
$('#download').not('.inDispute').click(function(){
$.ajax({
url: 'retrieve.php',
data: {'mode': 7, 'refScore': $('#addToList').attr('data-link')},
success: function(data){
}
});
window.open($(this).attr('data-link'));
});
// like button
$('#like').click(function(){
var isLoggedIn = <?php if(isset($_SESSION['primaryId'])){ echo 1; }else { echo 0; } ?>;
if(isLoggedIn == 1){
$.ajax({
url: 'retrieve.php',
data: {'mode': 4, 'likeTo': $('#flagForm #flagTo').val()},
success: function(data){
location.href='view.php?id='+$('#flagForm #flagTo').val();
}
});
}else{
alert('You have to log in to like a score!');
}
});
// mylist button
$('#addToList').click(function(){
var isLoggedIn = <?php if(isset($_SESSION['primaryId'])){ echo 1; }else { echo 0; } ?>;
if(isLoggedIn == 1){
$.ajax({
url: 'retrieve.php',
data: {'mode': 6, 'creator': <?php if(isset($_SESSION['primaryId'])){ echo($_SESSION['primaryId']); } else { echo -1; } ?>, 'refScore': $(this).attr('data-link')},
success: function(data){
if(data == 1){
$('#addToList').html("<img src='assets/images/add.png'><br>Added to mylist");
$('#addToList').addClass('added');
}else if(data == 2){
$('#addToList').html("<img src='assets/images/add.png'><br>Add to mylist");
$('#addToList').removeClass('added');
}else if(data == -1){
alert('You have to log in to add scores to mylist!');
}
}
});
}else{
alert('You have to log in to add scores to mylist!');
}
});
// resolve part
$('#flag').click(function(){
var isLoggedIn = <?php if(isset($_SESSION['primaryId'])){ echo 1; }else { echo 0; } ?>;
if(isLoggedIn == 1){
$('.flagItContainer').fadeIn(300);
}else{
alert('You have to log in to report a score!');
}
});
$('.revoke').click(function(){
$('.flagItContainer .flagItHeader').text('Resolve the reported status');
$('.flagItContainer .flagIt').css('height', '230px');
$('.flagItContainer .flagIt').html('<span class="warning">You can rebut the current hold status by sending us the reason(s) this score is not problematic. Once submitted, this resolve request will be reviewed by the operators. </span><hr style="width: 99%;" color="#BBBBBB" size="1" no-shade></hr><textarea data-role="none" rows=9 cols=77 id="flagDesc" name="flagDesc"></textarea><br><input type="button" value="Report" onclick=alert("REQUEST_SENT");location.href="view.php?id=<?php echo(htmlentities($data['id'])); ?>"><input type="button" value="Cancel" id="cancelButton" onclick=$(".flagItContainer").fadeOut(300)>');
$('.flagItContainer').fadeIn(300);
});
$('.tags').click(function(){
location.href=$(this).attr('data-link');
});
$('.genres').not('.not').click(function(){
location.href=$(this).attr('data-link');
});
$('#aboutPage').click(function(){
location.href='about.php';
});
$('#userPanel').click(function(){
location.href='mypage.php';
});
$('#logOut').click(function(){
location.href='logout.php';
});
/* category links */
$('#br_all').click(function(){
location.href='browse.php';
});
$('.subGenre').click(function(){
location.href=$(this).attr('data-link');
});
$('.subComposer').click(function(){
location.href=$(this).attr('data-link');
});
$('.subComposeYear').click(function(){
location.href=$(this).attr('data-link');
});
$('.subPublishYear').click(function(){
location.href=$(this).attr('data-link');
});
$('.subInstrumentation').click(function(){
location.href=$(this).attr('data-link');
});
$('.friend').click(function(){
$('.friendProfileContainer').fadeIn(300);
});
$(document).ajaxSuccess(function(){
$('#keyword').autocomplete({
source: availableTags
});
$('#isFriend[class=already]').not('#isFriend[class=myself]').mouseenter(function(){
$(this).text("Unfriend");
});
$('#isFriend[class=already]').not('#isFriend[class=myself]').mouseleave(function(){
$(this).text("Friend already");
});
});
});
</script>
</body>
</html>