/
index.html
669 lines (582 loc) · 20.1 KB
/
index.html
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
<!doctype html>
<html>
<head>
<title>Steam Tags</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
<!--
var profile = null; // all the user state.
var current_popover = null;
function end_popover()
{
if (current_popover != null)
{
$(current_popover).fadeOut("slow");
$("#backgroundpopover").fadeOut("slow");
current_popover = null;
} // if
} // end_popover
function popover(element)
{
if (current_popover != null)
$(current_popover).fadeOut("slow");
current_popover = element;
ui_resize(); // make this sane.
$("#backgroundpopover").css('opacity', '0.7');
$("#backgroundpopover").fadeIn('slow');
$(element).fadeIn('slow');
// I guess this doesn't actually recalculate the element sizes until the
// scripts are idle, so do a short timeout so it rechecks this after
// the layout has a chance to catchup.
setTimeout('ui_resize();', 10);
} // popover
function ui_resize()
{
var element = current_popover;
if (element == null)
return;
$('#backgroundpopover').css('height', windowHeight);
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupWidth = windowWidth / 2;
$(element).css('width', popupWidth);
var popupHeight = $(element).children().height();
$(element).css({
position: 'absolute',
top: (windowHeight - popupHeight) / 2,
left: (windowWidth - popupWidth) / 2,
width: popupWidth,
height: popupHeight
});
} // ui_resize
var tutorial_stage = -1;
var tutorial_timer = null;
function end_tutorial_stage()
{
if (tutorial_timer != null)
{
clearTimeout(tutorial_timer);
tutorial_timer = null;
} // if
if (tutorial_stage >= 0)
$('div#tutorial' + tutorial_stage).fadeOut('slow');
} // end_tutorial_stage
function tutorial()
{
end_tutorial_stage();
tutorial_stage++;
var element = $('div#tutorial' + tutorial_stage);
if (element.length == 0)
return; // ran out of tutorial.
var tut = $('div#tutorial' + tutorial_stage);
var target = $(tut.attr('tutorialtarget'));
var left = target.offset().left + 5;
var window_width = document.documentElement.clientWidth;
if ((left + tut.width()) > window_width)
left = (window_width - tut.width()) - 30;
var top = target.offset().top + target.height() + 5;
var window_height = document.documentElement.clientHeight;
if ((top + tut.height()) > window_height)
top = (window_height - tut.height()) - 30;
tut.css({ position: 'absolute', top: top, left: left });
tut.fadeIn('slow');
tutorial_timer = setTimeout('tutorial();', tut.attr('tutorialtimeout'));
} // tutorial
function halt_tutorial()
{
end_tutorial_stage();
tutorial_stage = -1;
} // halt_tutorial
function restart_tutorial()
{
halt_tutorial();
tutorial();
} // restart_tutorial
function render()
{
if (profile == null)
return;
$('img.avatar').attr('src', profile.avatarurl_medium);
$('div.nickname').text(profile.nickname);
var gameidx;
for (gameidx in profile.gamelist)
{
var game = profile.gamelist[gameidx];
var html = "<tr class='gamerow' profilegameidx='" + gameidx + "'>" +
"<td class='gamecell'>" +
"<a href='steam://run/" + game.appid + "'>" +
"<img width='123' height='45' src='" + game.logourl + "'/>" +
"</a><td class='gamecell'>" +
"<h4>" + game.title + "</h4><div class='tagline'>Tags:" +
"<div class='taglist' profilegameidx=" + gameidx + ">";
if (game.tags.length == 0)
html += ' (none)';
else
{
var tagidx;
for (tagidx in game.tags)
html += " " + game.tags[tagidx];
} // else
html += "</div></div></td></tr>";
$('table.gametable > tbody:last').append(html);
} // for
$('tr.gamerow').each(function() {
profile.gamelist[$(this).attr('profilegameidx')].element = $(this);
});
$('div.taglist').one("click", function() { clicked_taglist($(this)); });
$('a#profileurl').attr('href', profile.profileurl);
$('div.main').show();
end_popover();
var has_tags = false;
for (var i in profile.tagmap)
{
has_tags = true;
break;
} // for
if (!has_tags)
restart_tutorial();
} // render
function process_steam_profile(xml)
{
var prof = $(xml).find('profile');
var steamid = prof.find('steamid').text();
if (steamid == '0')
{
popover('#loginpopover');
return null;
} // if
if (prof.find('valid').text() == '0')
{
popover('#loginfailurepopover');
return null;
} // if
if (prof.find('private').text() == '1')
{
var url = 'http://steamcommunity.com/profiles/' + steamid + '/edit/settings';
$('a#privpage').attr('href', url);
popover('#privateprofilepopover');
return null;
} // if
var retval = {
nickname: prof.find('nickname').text(),
steamid: prof.find('steamid').text(),
name: prof.find('name').text(),
profileurl: prof.find('profileurl').text(),
onlinestate: prof.find('onlinestate').text(),
statemsg: prof.find('statemsg').text(),
avatarurl_small: prof.find('avatarurl_small').text(),
avatarurl_medium: prof.find('avatarurl_medium').text(),
avatarurl_large: prof.find('avatarurl_large').text(),
vacbanned: (prof.find('vacbanned').text() != '0'),
membersince: prof.find('membersince').text(),
rating: prof.find('rating').text(),
hoursplayed_2weeks: prof.find('hoursplayed_2weeks').text(),
headline: prof.find('headline').text(),
location: prof.find('location').text(),
realname: prof.find('realname').text(),
summary: prof.find('summary').text(),
weblinks: new Array(),
gamelist: new Array(),
filter: '',
tagmap: new Object()
}
prof.find('weblink').each(function(){
retval['weblinks'].push({
title: $(this).find('title').text(),
url: $(this).find('url').text()
});
})
prof.find('game').each(function(){
var game = {
appid: $(this).find('appid').text(),
title: $(this).find('title').text(),
logourl: $(this).find('logourl').text(),
storeurl: $(this).find('storeurl').text(),
tagmatchcount: 0,
element: null,
tags: new Array
};
$(this).find('tag').each(function(){
var t = $(this).text().toLowerCase();
game.tags.push(t);
if (retval.tagmap[t] == null)
retval.tagmap[t] = new Array();
retval.tagmap[t].push(game);
});
retval['gamelist'].push(game);
});
if (retval['gamelist'].length == 0)
{
popover('#noappspopover');
return null;
} // if
return retval;
} // process_steam_profile
var run_filter_timer = null;
function run_filter()
{
// stop any pending filter runs.
clearTimeout(run_filter_timer);
run_filter_timer = null;
var filter = '';
var widget = $('input.tagfilter');
// ignore text in box if we haven't focused it yet.
if (widget && widget.attr('filter_cleared'))
filter = widget.val();
filter = filter.toLowerCase();
filter = filter.replace(/^\s*|\s*$/g, '');
if (profile.filter == filter)
return; // fast path: nothing's changed.
profile.filter = filter;
// fast path: can we just show everything?
if (filter == '') // just show everything.
{
$('tr.gamerow').show();
return;
} // if
var filtertags = filter.split(' ');
for (var t in filtertags)
{
// fast path: can we just hide everything?
if (profile.tagmap[filtertags[t]] == null)
{
$('tr.gamerow').hide(); // no rows match this tag.
return;
} // if
} // for
for (var t in filtertags)
{
var tag = filtertags[t];
for (var i in profile.tagmap[tag])
{
var game = profile.tagmap[tag][i];
game.tagmatchcount++;
} // for
} // for
// okay, now we have a list of games that should be filtered.
for (var i in profile.gamelist)
{
var game = profile.gamelist[i];
if (game.tagmatchcount != filtertags.length)
game.element.hide();
else
game.element.show();
game.tagmatchcount = 0; // reset this for next time.
} // for
} // run_filter
function focus_filter_textbox()
{
// blank out the filter textbox when focused if it has default text.
var widget = $('input.tagfilter');
if (widget && !widget.attr('filter_cleared'))
{
widget.attr('filter_cleared', true);
widget.val('');
} // if
} // focus_filter_textbox
function typing_in_filter()
{
// we only update the filter when it's been more than X ms, in case the
// list is massive.
if (run_filter_timer != null)
clearTimeout(run_filter_timer);
run_filter_timer = setTimeout('run_filter();', 50);
} // typing_in_filter
function save_tags(appid, tagstr)
{
// we only allow a-z, 0-9, and spaces. So URI encode the spaces.
var tagstrurl = tagstr.replace(/ /g, '%20');
$.ajax({
type: 'GET',
url: 'savetags.php?appid=' + appid + '&tags=' + tagstrurl,
dataType: "xml",
success: function(xml) {
// !!! FIXME: we leave the tags dead if this fails for any reason.
var resxml = $(xml).find('result');
if ((resxml == null) || (resxml.text() != '1'))
return;
var appidxml = $(xml).find('appid');
if (appidxml == null)
return;
// !!! FIXME: we can just upvalue here, right? Why iterate?
var appid = appidxml.text();
var game = null;
for (var i in profile.gamelist)
{
if (profile.gamelist[i].appid == appid)
{
game = profile.gamelist[i];
break;
} // if
} // for
if (game == null)
return;
var element = game.element.find('div.taglist');
if (element == null)
return;
// !!! FIXME: get this from the stylesheet
element.css('color', '#FFFFFF');
element.one("click", function() { clicked_taglist($(this)); });
}
});
} // save_tags
function process_tag_edit(element, tagstr)
{
tagstr = tagstr.toLowerCase();
tagstr = tagstr.replace(/^\s*|\s*$/g, '');
tagstr = tagstr.replace(/\s+/g, ' ');
tagstr = tagstr.replace(/[^a-z0-9 ]/g, '');
// remove duplicate tags...
var dupetags = tagstr.split(' ');
var tags = new Array();
for (var i in dupetags)
{
var dupe = false;
for (var j in tags)
{
if (dupetags[i] == tags[j])
{
dupe = true;
break;
} // if
} // for
if (!dupe)
tags.push(dupetags[i]);
} // for
tagstr = tags.join(' ');
// update profile.gamelist[gameidx].tags and profile.tagmap...
var parentdiv = element.parent();
var gameidx = parentdiv.attr('profilegameidx');
var game = profile.gamelist[gameidx];
for (var i in game.tags)
{
var t = game.tags[i];
var gamelist = profile.tagmap[t];
for (var j = 0; j < gamelist.length; j++)
{
if (gamelist[j] == game)
{
gamelist.splice(j, 1);
j--;
} // if
} // for
if (gamelist.length == 0)
profile.tagmap[t] = null;
} // for
for (var i in tags)
{
var t = tags[i];
if (profile.tagmap[t] == null)
profile.tagmap[t] = new Array();
profile.tagmap[t].push(game);
} // for
game.tags = tags;
// Push the updated tags back to the server for storage.
save_tags(game.appid, tagstr);
// Kill the text input widget, go back to regular text.
if (tagstr == '')
tagstr = '(none)';
parentdiv.html(' ' + tagstr);
// !!! FIXME: get this from the stylesheet
parentdiv.css('color', '#777777');
} // process_tag_edit
function clicked_taglist(element)
{
var editor = $("input.tagedit");
if (editor)
editor.blur(); // that should kill it.
var tagstr = element.text().replace(/^\s*|\s*$/g, '');
if (tagstr == '(none)')
tagstr = '';
var html = "<input type='text' autocapitalize='off' size='100'" +
" class='tagedit' name='tagedit'" +
" value='" + tagstr + "'/>";
element.html(html);
editor = $("input.tagedit");
editor.blur(function() { process_tag_edit($(this), $(this).val()); });
editor.change(function() { process_tag_edit($(this), $(this).val()); });
editor.keyup(function(e) {
if (e.keyCode != 27)
return;
// revert to original tags on escape.
var parentdiv = $(this).parent();
var gameidx = parentdiv.attr('profilegameidx');
var game = profile.gamelist[gameidx];
var tagstr = game.tags.join(' ');
process_tag_edit($(this), tagstr);
});
editor.focus();
} // clicked_taglist
// kick off AJAX load of user profile when document is ready for action.
$(document).ready(function(){
$(window).resize( function() { ui_resize(); } );
// Mobile Safari (etc?) orientation support.
window.onorientationchange = function() { ui_resize(); }
popover('#loadingmessage');
$.ajax({
type: "GET",
url: "steamprofile.php",
dataType: "xml",
error: function() { popover('#loginfailurepopover'); },
success: function(xml) {
profile = process_steam_profile(xml);
render();
}
});
});
-->
</script>
</head>
<body>
<div class='main'>
<div class="global_header">
<img class='avatar' width='64' height='64' src='loading.gif'/>
<div class='nickname'></div>
<div class='controls'>
<div class='searchbox'>
<input type='text' autocapitalize='off'
class='tagfilter' name='filter'
onFocus='focus_filter_textbox();'
onBlur='run_filter();'
onChange='run_filter();'
onKeyDown='typing_in_filter();'
value='Enter filter tags' size='22' autocomplete='off'/>
</div>
<div class='navbar'>
<center>
[
<a href='javascript:restart_tutorial();'>help</a>
-
<a target='_blank' href='http://hg.icculus.org/icculus/steamtags'>source code</a>
-
<a target='_blank' id='profileurl' href='xxx'>profile</a>
-
<a href='mailto:icculus@icculus.org?subject=Steam%20Tags%20Feedback'>feedback</a>
-
<a href='auth.php?logout=1'>logout</a>
]
<br/>
[ <a target='_blank' href='http://steampowered.com/'> Powered by Steam</a> ]
</center>
</div>
</div>
</div>
<table class='gametable'><tbody></tbody></table>
<div class="global_footer"></div>
</div>
<div id='loadingmessage'>
<center>Loading your Steam Community profile...</center>
</div>
<div class='popover' id='loginpopover'>
<center>
<p>This website lets you organize and filter your Steam purchases
through tags you choose. You can categorize and file your games
thousands of different ways.</p>
<br/>
<p>You need to log in to Steam Community to access this page.</p>
<p>Your password will only be supplied to the Steam website. This
website will never have access to your login information.</p>
<br/>
<p><a href='auth.php'>
Click here to log in through steamcommunity.com</a></p>
</center>
</div>
<div class='popover' id='loginfailurepopover'>
<center>
<p>We're having trouble accessing your Steam Community profile.</p>
<br/>
<p>This is probably a temporary network glitch. Please try again later.</p>
<p>If this problem persists, feel free to
<a href='mailto:icculus@icculus.org'>ask Ryan about it</a>.</p>
<br/>
<p><a href='http://store.steampowered.com/'>
Click here to shop for games on Steam in the meantime.</a></p>
</center>
</div>
<div class='popover' id='privateprofilepopover'>
<center>
<p>Your Steam Community profile appears to be set to private.</p>
<br/>
<p>You need to change your Steam Community settings to access this page.</p>
<p>The "profile status" must be set to "public."</p>
<p>Please note that this will let everyone see your information!</p>
<p>Unfortunately, it's the only way this site can see it, too.</p>
<br/>
<p><a id='privpage' href='xxx'>
Click here to go to your steamcommunity.com settings.</a></p>
</center>
</div>
<div class='popover' id='noappspopover'>
<center>
<p>You don't seem to own any games!</p>
<br/>
<p>This website isn't very useful if you don't have something to
organize.</p>
<br/>
<p><a href='http://store.steampowered.com'>
Click here to go shopping!</a></p>
</center>
</div>
<div class='tutorial' id='tutorial0'
tutorialtarget='div.taglist:first' tutorialtimeout='15000'>
<center>
<p>Click a game's tags, and then you can edit them.</p>
<br/>
<p>Just type in some simple words, separated with spaces. Describe
the game.</p>
<br/>
<p>If this game were <a target='_blank' href='http://store.steampowered.com/app/26800'>Braid</a>, you might type in:</p>
<p><code>platformer indie puzzle steamplay</code></p>
<p>Or <a target='_blank' href='http://store.steampowered.com/app/1250'>Killing Floor</a> might be:</p>
<p><code>fps multiplayer zombies</code></p>
<br/>
<p>Use any words you like to describe the game. You'll be able to
find this game later through these words.</p>
<br/>
<p>When you're done, just click elsewhere to save.</p>
</center>
</div>
<div class='tutorial' id='tutorial1'
tutorialtarget='div.searchbox' tutorialtimeout='10000'>
<center>
<p>Next, type in some tags here.</p>
<br/>
<p>The list of games will filter down to exactly match the tags you
typed, as you type them.</p>
<p>Now you can find your games based on arbitrary criteria you choose!</p>
</center>
</div>
<div class='tutorial' id='tutorial2'
tutorialtarget='td.gamecell > a > img:first' tutorialtimeout='8000'>
<center>
<p>Click a game's icon to launch it.</p>
<br/>
<p>This will tell the Steam client to install and run the game.</p>
<p>You'll need to have Steam installed for this to work.</p>
</center>
</div>
<div class='tutorial' id='tutorial3'
tutorialtarget='img.avatar' tutorialtimeout='3000'>
<center>
This is you. A beautiful and unique snowflake.
</center>
</div>
<div class='tutorial' id='tutorial4'
tutorialtarget='div.navbar' tutorialtimeout='10000'>
<center>
<p>Here are some various useful links.</p>
<br/>
<p>Definitely consider clicking the 'feedback' one and telling Ryan
what you think. Javascript hacker? Grab the source code. Bored?
Buy something ('Powered by Steam'). Done? Logout.</p>
<br/>
<p>Clicking 'help' reruns this tutorial.</p>
</center>
<br/>
<p align='right'>Have fun!</p>
<p align='right'>--ryan.</p>
</div>
<div id='backgroundpopover'></div>
</body>
</html>