Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save langdonx/7ec42932bf1a4d57490612073e862be1 to your computer and use it in GitHub Desktop.
Save langdonx/7ec42932bf1a4d57490612073e862be1 to your computer and use it in GitHub Desktop.
Giant Bomb's web site doesn't let you convert your unordered list to an ordered one. That's annoying. This makes it less so.
// create instead of edit
$('form#user-list-form').get(0).action = location.href.replace(/lists(.*)/, 'lists/create/');
// add positions
$('ul#user_list_items li').each(function(index, element) {
$(element)
.find('input:first')
.after('<input type="number" name="user_list[items][' + index + '][position]" value="' + (index + 1) + '">');
});
// make the new list ordered
$('form#user-list-form').prepend('<input type="radio" id="user_list_unordered_0" name="user_list[unordered]" value="0" checked>');
// change the new list's title
$('#user_list_title').val('Ordered: ' + $('#user_list_title').val());
// save
$('form#user-list-form').submit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment