Guest User

Untitled

a guest
Nov 16th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. // Usage:
  2. // Paste the following in the console once on each reload.
  3. // After that, type `x(first_index, second_index)` and press ENTER.
  4. // Example: To swap 13th station with 75th station, you'd type:
  5. // x(13,75)
  6. // Example: To put 50th station at 2nd position, you'd type:
  7. // y(50,2)
  8. // Remember to save afterwards. :)
  9.  
  10. let cheat = function() {
  11. let get_station_li_by_index = (target_index) => {
  12. let all_counters = $('div.ui-state-default.sortable-number');
  13. for (let i=0; i<all_counters.length; i++) {
  14. let counter = $(all_counters[i]);
  15. if (counter.text() == target_index) {
  16. return counter.parent();
  17. }
  18. }
  19. }
  20.  
  21. let update_station_counters = () => {
  22. let all_counters = $('div.ui-state-default.sortable-number');
  23. for (let i=0; i<all_counters.length; i++) {
  24. let counter = $(all_counters[i]);
  25. counter.text(i+1);
  26. }
  27. }
  28.  
  29. let swap = (first, second) => {
  30. first = $(get_station_li_by_index(first));
  31. second = $(get_station_li_by_index(second));
  32. first.after(second.clone());
  33. second.after(first).remove();
  34. update_station_counters();
  35. }
  36.  
  37. let put_at = (id, destination) => {
  38. id = $(get_station_li_by_index(id));
  39. destination = $(get_station_li_by_index(destination));
  40. destination.before(id.clone());
  41. id.remove();
  42. update_station_counters();
  43. }
  44.  
  45. return {
  46. swap,
  47. get_station_li_by_index,
  48. put_at,
  49. update_station_counters,
  50. };
  51. }();
  52.  
  53. x = cheat.swap;
  54. y = cheat.put_at;
  55.  
  56.  
  57. // LEGALESE...
  58. // Copyright 2018 Rohitt Vashishtha
  59. // Published under the MIT License.
Add Comment
Please, Sign In to add comment