Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Usage:
- // Paste the following in the console once on each reload.
- // After that, type `x(first_index, second_index)` and press ENTER.
- // Example: To swap 13th station with 75th station, you'd type:
- // x(13,75)
- // Example: To put 50th station at 2nd position, you'd type:
- // y(50,2)
- // Remember to save afterwards. :)
- let cheat = function() {
- let get_station_li_by_index = (target_index) => {
- let all_counters = $('div.ui-state-default.sortable-number');
- for (let i=0; i<all_counters.length; i++) {
- let counter = $(all_counters[i]);
- if (counter.text() == target_index) {
- return counter.parent();
- }
- }
- }
- let update_station_counters = () => {
- let all_counters = $('div.ui-state-default.sortable-number');
- for (let i=0; i<all_counters.length; i++) {
- let counter = $(all_counters[i]);
- counter.text(i+1);
- }
- }
- let swap = (first, second) => {
- first = $(get_station_li_by_index(first));
- second = $(get_station_li_by_index(second));
- first.after(second.clone());
- second.after(first).remove();
- update_station_counters();
- }
- let put_at = (id, destination) => {
- id = $(get_station_li_by_index(id));
- destination = $(get_station_li_by_index(destination));
- destination.before(id.clone());
- id.remove();
- update_station_counters();
- }
- return {
- swap,
- get_station_li_by_index,
- put_at,
- update_station_counters,
- };
- }();
- x = cheat.swap;
- y = cheat.put_at;
- // LEGALESE...
- // Copyright 2018 Rohitt Vashishtha
- // Published under the MIT License.
Add Comment
Please, Sign In to add comment