Skip to content

Latest commit

 

History

History
538 lines (468 loc) · 16 KB

index.html

File metadata and controls

538 lines (468 loc) · 16 KB
 
1
2
3
<!doctype html>
<html>
<head>
Jul 5, 2010
Jul 5, 2010
4
<title>Steam Tags</title>
Jul 2, 2010
Jul 2, 2010
5
<link href="style.css" rel="stylesheet" type="text/css" />
6
7
8
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript">
<!--
Jul 1, 2010
Jul 1, 2010
9
Jul 5, 2010
Jul 5, 2010
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
Jul 6, 2010
Jul 6, 2010
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
Jul 5, 2010
Jul 5, 2010
48
49
50
51
52
53
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupWidth = windowWidth / 2;
$(element).css('width', popupWidth);
Jul 6, 2010
Jul 6, 2010
54
var popupHeight = $(element).children().height();
Jul 5, 2010
Jul 5, 2010
55
56
57
58
59
60
61
62
$(element).css({
position: 'absolute',
top: (windowHeight - popupHeight) / 2,
left: (windowWidth - popupWidth) / 2,
width: popupWidth,
height: popupHeight,
});
Jul 6, 2010
Jul 6, 2010
63
} // ui_resize
Jul 5, 2010
Jul 5, 2010
64
Jul 1, 2010
Jul 1, 2010
65
66
function render()
{
Jul 2, 2010
Jul 2, 2010
67
68
69
70
if (profile == null)
return;
$('img.avatar').attr('src', profile.avatarurl_medium);
Jul 1, 2010
Jul 1, 2010
71
$('div.nickname').text(profile.nickname);
Jul 1, 2010
Jul 1, 2010
72
Jul 1, 2010
Jul 1, 2010
73
74
var gameidx;
for (gameidx in profile.gamelist)
Jul 1, 2010
Jul 1, 2010
75
{
Jul 1, 2010
Jul 1, 2010
76
var game = profile.gamelist[gameidx];
Jul 4, 2010
Jul 4, 2010
77
78
var html = "<tr class='gamerow' profilegameidx='" + gameidx + "'>" +
"<td class='gamecell'>" +
Jul 2, 2010
Jul 2, 2010
79
"<img width='123' height='45' src='" + game.logourl + "'/>" +
Jul 4, 2010
Jul 4, 2010
80
"<td class='gamecell'>" +
Jul 4, 2010
Jul 4, 2010
81
82
83
"<h4><a href='steam://run/" + game.appid + "'>" +
game.title + "</a></h4><div class='tagline'>Tags:" +
"<div class='taglist' profilegameidx=" + gameidx + ">";
Jul 2, 2010
Jul 2, 2010
84
85
86
87
88
89
90
91
92
if (game.tags.length == 0)
html += ' (none)';
else
{
var tagidx;
for (tagidx in game.tags)
html += " " + game.tags[tagidx];
} // else
Jul 4, 2010
Jul 4, 2010
93
html += "</div></div></td></tr>";
Jul 2, 2010
Jul 2, 2010
94
Jul 1, 2010
Jul 1, 2010
95
$('table.gametable > tbody:last').append(html);
Jul 1, 2010
Jul 1, 2010
96
} // for
Jul 4, 2010
Jul 4, 2010
97
98
99
100
101
$('tr.gamerow').each(function() {
profile.gamelist[$(this).attr('profilegameidx')].element = $(this);
});
Jul 4, 2010
Jul 4, 2010
102
$('div.taglist').one("click", function() { clicked_taglist($(this)); });
Jul 5, 2010
Jul 5, 2010
103
$('a#profileurl').attr('href', profile.profileurl);
Jul 5, 2010
Jul 5, 2010
104
105
106
$('div.main').show();
end_popover();
} // render
Jul 5, 2010
Jul 5, 2010
107
108
109
110
function process_steam_profile(xml)
{
var prof = $(xml).find('profile');
Jul 5, 2010
Jul 5, 2010
111
112
var steamid = prof.find('steamid').text();
if (steamid == '0')
Jul 3, 2010
Jul 3, 2010
113
{
Jul 5, 2010
Jul 5, 2010
114
popover('#loginpopover');
Jul 3, 2010
Jul 3, 2010
115
116
117
return null;
} // if
Jul 5, 2010
Jul 5, 2010
118
119
120
121
122
123
124
if (prof.find('valid').text() == '0')
{
popover('#loginfailurepopover');
return null;
} // if
if (prof.find('private').text() == '1')
Jul 5, 2010
Jul 5, 2010
125
126
127
128
{
var url = 'http://steamcommunity.com/profiles/' + steamid + '/edit/settings';
$('a#privpage').attr('href', url);
popover('#privateprofilepopover');
Jul 5, 2010
Jul 5, 2010
130
} // if
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
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(),
Jul 4, 2010
Jul 4, 2010
152
153
filter: '',
tagmap: new Object(),
154
155
156
157
158
159
160
161
162
163
}
prof.find('weblink').each(function(){
retval['weblinks'].push({
title: $(this).find('title').text(),
url: $(this).find('url').text(),
});
})
prof.find('game').each(function(){
Jul 1, 2010
Jul 1, 2010
164
var game = {
165
166
167
168
appid: $(this).find('appid').text(),
title: $(this).find('title').text(),
logourl: $(this).find('logourl').text(),
storeurl: $(this).find('storeurl').text(),
Jul 5, 2010
Jul 5, 2010
169
tagmatchcount: 0,
Jul 4, 2010
Jul 4, 2010
170
element: null,
Jul 1, 2010
Jul 1, 2010
171
172
173
174
tags: new Array,
};
$(this).find('tag').each(function(){
Jul 4, 2010
Jul 4, 2010
175
176
177
178
179
var t = $(this).text().toLowerCase();
game.tags.push(t);
if (retval.tagmap[t] == null)
retval.tagmap[t] = new Array();
retval.tagmap[t].push(game);
Jul 1, 2010
Jul 1, 2010
181
182
183
retval['gamelist'].push(game);
});
Jul 5, 2010
Jul 5, 2010
185
186
187
188
189
190
if (retval['gamelist'].length == 0)
{
popover('#noappspopover');
return null;
} // if
191
192
193
return retval;
} // process_steam_profile
Jul 4, 2010
Jul 4, 2010
194
var run_filter_timer = null;
Jul 4, 2010
Jul 4, 2010
195
196
197
function run_filter()
{
// stop any pending filter runs.
Jul 4, 2010
Jul 4, 2010
198
199
clearTimeout(run_filter_timer);
run_filter_timer = null;
Jul 4, 2010
Jul 4, 2010
201
202
203
204
205
206
207
208
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();
Jul 4, 2010
Jul 4, 2010
209
filter = filter.replace(/^\s*|\s*$/g, '');
Jul 4, 2010
Jul 4, 2010
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
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];
Jul 5, 2010
Jul 5, 2010
241
game.tagmatchcount++;
Jul 4, 2010
Jul 4, 2010
242
243
244
245
246
247
248
} // 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];
Jul 5, 2010
Jul 5, 2010
249
if (game.tagmatchcount != filtertags.length)
Jul 4, 2010
Jul 4, 2010
250
251
252
game.element.hide();
else
game.element.show();
Jul 5, 2010
Jul 5, 2010
253
game.tagmatchcount = 0; // reset this for next time.
Jul 4, 2010
Jul 4, 2010
254
255
} // for
} // run_filter
Jul 4, 2010
Jul 4, 2010
256
Jul 4, 2010
Jul 4, 2010
257
function focus_filter_textbox()
Jul 4, 2010
Jul 4, 2010
258
{
Jul 4, 2010
Jul 4, 2010
259
// blank out the filter textbox when focused if it has default text.
Jul 4, 2010
Jul 4, 2010
260
261
262
263
264
265
var widget = $('input.tagfilter');
if (widget && !widget.attr('filter_cleared'))
{
widget.attr('filter_cleared', true);
widget.val('');
} // if
Jul 4, 2010
Jul 4, 2010
266
267
} // focus_filter_textbox
Jul 4, 2010
Jul 4, 2010
268
function typing_in_filter()
Jul 4, 2010
Jul 4, 2010
269
270
271
{
// we only update the filter when it's been more than X ms, in case the
// list is massive.
Jul 4, 2010
Jul 4, 2010
272
273
if (run_filter_timer != null)
clearTimeout(run_filter_timer);
Jul 4, 2010
Jul 4, 2010
274
run_filter_timer = setTimeout('run_filter();', 50);
Jul 4, 2010
Jul 4, 2010
275
} // typing_in_filter
Jul 4, 2010
Jul 4, 2010
276
Jul 4, 2010
Jul 4, 2010
277
278
279
function save_tags(appid, tagstr)
{
// we only allow a-z, 0-9, and spaces. So URI encode the spaces.
Jul 4, 2010
Jul 4, 2010
280
var tagstrurl = tagstr.replace(/ /g, '%20');
Jul 4, 2010
Jul 4, 2010
281
282
283
284
285
286
287
288
289
290
291
292
293
294
$.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;
Jul 5, 2010
Jul 5, 2010
295
296
297
298
299
300
301
302
303
304
305
306
// !!! 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
Jul 4, 2010
Jul 4, 2010
307
308
309
310
311
312
313
if (game == null)
return;
var element = game.element.find('div.taglist');
if (element == null)
return;
Jul 5, 2010
Jul 5, 2010
314
// !!! FIXME: get this from the stylesheet
Jul 4, 2010
Jul 4, 2010
315
316
317
318
319
320
element.css('color', '#FFFFFF');
element.one("click", function() { clicked_taglist($(this)); });
},
});
} // save_tags
Jul 5, 2010
Jul 5, 2010
321
function process_tag_edit(element, tagstr)
Jul 4, 2010
Jul 4, 2010
322
{
Jul 5, 2010
Jul 5, 2010
323
tagstr = tagstr.toLowerCase();
Jul 4, 2010
Jul 4, 2010
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
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.
Jul 4, 2010
Jul 4, 2010
379
save_tags(game.appid, tagstr);
Jul 4, 2010
Jul 4, 2010
380
381
382
383
384
// Kill the text input widget, go back to regular text.
if (tagstr == '')
tagstr = '(none)';
parentdiv.html(' ' + tagstr);
Jul 5, 2010
Jul 5, 2010
385
// !!! FIXME: get this from the stylesheet
Jul 4, 2010
Jul 4, 2010
386
parentdiv.css('color', '#777777');
Jul 4, 2010
Jul 4, 2010
387
388
389
390
391
392
393
394
395
396
397
398
} // 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 = '';
Jul 5, 2010
Jul 5, 2010
399
var html = "<input size='100' class='tagedit' name='tagedit' type='text'" +
Jul 5, 2010
Jul 5, 2010
400
"value='" + tagstr + "' autocomplete='off'/>";
Jul 4, 2010
Jul 4, 2010
401
402
403
element.html(html);
editor = $("input.tagedit");
Jul 5, 2010
Jul 5, 2010
404
405
406
407
408
409
410
411
412
413
414
415
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);
});
Jul 4, 2010
Jul 4, 2010
416
417
editor.focus();
} // clicked_taglist
Jul 4, 2010
Jul 4, 2010
418
419
420
// kick off AJAX load of user profile when document is ready for action.
$(document).ready(function(){
Jul 6, 2010
Jul 6, 2010
421
422
423
424
425
$(window).resize( function() { ui_resize(); } );
// Mobile Safari (etc?) orientation support.
window.onorientationchange = function() { ui_resize(); }
Jul 5, 2010
Jul 5, 2010
426
popover('#loadingmessage');
Jul 4, 2010
Jul 4, 2010
427
428
429
430
$.ajax({
type: "GET",
url: "steamprofile.php",
dataType: "xml",
Jul 5, 2010
Jul 5, 2010
431
error: function() { popover('#loginfailurepopover'); },
Jul 4, 2010
Jul 4, 2010
432
433
434
435
436
437
success: function(xml) {
profile = process_steam_profile(xml);
render();
},
});
});
Jul 4, 2010
Jul 4, 2010
438
439
440
441
442
-->
</script>
</head>
<body>
Jul 2, 2010
Jul 2, 2010
443
<div class='main'>
Jul 5, 2010
Jul 5, 2010
444
445
446
<div class="global_header">
<img class='avatar' width='64' height='64' src='loading.gif'/>
<div class='nickname'></div>
Jul 5, 2010
Jul 5, 2010
447
448
449
450
451
452
453
454
455
456
<div class='controls'>
<div class='searchbox'>
<input class='tagfilter' name='filter' type='text'
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'>
Jul 5, 2010
Jul 5, 2010
457
<center>
Jul 5, 2010
Jul 5, 2010
458
459
460
461
462
463
464
465
466
[
<a target='_blank' href='http://store.steampowered.com/'>buy games</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='auth.php?logout=1'>logout</a>
]
Jul 5, 2010
Jul 5, 2010
467
468
469
<br/>
[ <a target='_blank' href='http://steampowered.com/'> Powered by Steam</a> ]
</center>
Jul 5, 2010
Jul 5, 2010
470
</div>
Jul 4, 2010
Jul 4, 2010
471
</div>
Jul 5, 2010
Jul 5, 2010
472
</div>
Jul 5, 2010
Jul 5, 2010
473
474
<table class='gametable'><tbody></tbody></table>
<div class="global_footer"></div>
Jul 4, 2010
Jul 4, 2010
475
</div>
Jul 5, 2010
Jul 5, 2010
476
Jul 5, 2010
Jul 5, 2010
477
<div id='loadingmessage'>
Jul 5, 2010
Jul 5, 2010
478
<center>Loading your Steam Community profile...</center>
Jul 5, 2010
Jul 5, 2010
479
480
</div>
Jul 5, 2010
Jul 5, 2010
481
<div class='popover' id='loginpopover'>
Jul 5, 2010
Jul 5, 2010
482
<center>
Jul 5, 2010
Jul 5, 2010
483
<p>This website lets you organize and filter your Steam purchases
Jul 5, 2010
Jul 5, 2010
484
485
through tags you choose. You can categorize and file your games
thousands of different ways.</p>
Jul 5, 2010
Jul 5, 2010
486
487
488
489
490
<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/>
Jul 5, 2010
Jul 5, 2010
491
492
493
<p><a href='auth.php'>
Click here to log in through steamcommunity.com</a></p>
</center>
Jul 1, 2010
Jul 1, 2010
494
</div>
Jul 5, 2010
Jul 5, 2010
495
Jul 5, 2010
Jul 5, 2010
496
<div class='popover' id='loginfailurepopover'>
Jul 5, 2010
Jul 5, 2010
497
<center>
Jul 5, 2010
Jul 5, 2010
498
499
500
<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>
Jul 5, 2010
Jul 5, 2010
501
502
<p>If this problem persists, feel free to
<a href='mailto:icculus@icculus.org'>ask Ryan about it</a>.</p>
Jul 5, 2010
Jul 5, 2010
503
<br/>
Jul 5, 2010
Jul 5, 2010
504
<p><a href='http://store.steampowered.com/'>
Jul 5, 2010
Jul 5, 2010
505
Click here to shop for games on Steam in the meantime.</a></p>
Jul 5, 2010
Jul 5, 2010
506
</center>
Jul 5, 2010
Jul 5, 2010
507
508
</div>
Jul 5, 2010
Jul 5, 2010
509
<div class='popover' id='privateprofilepopover'>
Jul 5, 2010
Jul 5, 2010
510
<center>
Jul 5, 2010
Jul 5, 2010
511
512
513
514
515
516
517
<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/>
Jul 5, 2010
Jul 5, 2010
518
<p><a id='privpage' href='xxx'>
Jul 5, 2010
Jul 5, 2010
519
Click here to go to your steamcommunity.com settings.</a></p>
Jul 5, 2010
Jul 5, 2010
520
</center>
Jul 5, 2010
Jul 5, 2010
521
522
</div>
Jul 5, 2010
Jul 5, 2010
523
<div class='popover' id='noappspopover'>
Jul 5, 2010
Jul 5, 2010
524
<center>
Jul 5, 2010
Jul 5, 2010
525
526
527
528
529
<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/>
Jul 5, 2010
Jul 5, 2010
530
<p><a href='http://store.steampowered.com'>
Jul 5, 2010
Jul 5, 2010
531
Click here to go shopping!</a></p>
Jul 5, 2010
Jul 5, 2010
532
</center>
Jul 5, 2010
Jul 5, 2010
533
534
</div>
Jul 5, 2010
Jul 5, 2010
535
<div id='backgroundpopover'></div>