Created
January 24, 2017 02:39
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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