Skip to content

Commit

Permalink
First bit of work on pushing tags back to the server.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 4, 2010
1 parent de1df87 commit d2c82b6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
37 changes: 34 additions & 3 deletions index.html
Expand Up @@ -205,6 +205,38 @@
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.
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;

var game = profile.gamelist[appidxml.text()];
if (game == null)
return;

var element = game.element.find('div.taglist');
if (element == null)
return;

element.css('color', '#FFFFFF');
element.one("click", function() { clicked_taglist($(this)); });
},
});
} // save_tags

function process_tag_edit(element)
{
var tagstr = element.val().toLowerCase();
Expand Down Expand Up @@ -262,15 +294,14 @@

game.tags = tags;

// !!! FIXME: write me.
// Push the updated tags back to the server for storage.
// save_tags(gameidx, tagstr);
save_tags(game.appid, tagstr);

// Kill the text input widget, go back to regular text.
if (tagstr == '')
tagstr = '(none)';
parentdiv.html(' ' + tagstr);
$('div.taglist').one("click", function() { clicked_taglist($(this)); });
parentdiv.css('color', '#777777');
} // process_tag_edit

function clicked_taglist(element)
Expand Down
2 changes: 1 addition & 1 deletion style.css
Expand Up @@ -130,5 +130,5 @@ div.taglist {
background-color: #4a4746;
color: #cdc9c0;
outline: none;
margin-left: 5px;
margin-left: 5px;
}

0 comments on commit d2c82b6

Please sign in to comment.