Batch Georeferencing - Randomly Select Batch

Add shuffle button to Symbiota "Batch Georeferencing Tools" page

  1. // ==UserScript==
  2. // @name Batch Georeferencing - Randomly Select Batch
  3. // @description Add shuffle button to Symbiota "Batch Georeferencing Tools" page
  4. // @namespace symbiota.user.batchgeoref.rsb
  5. // @include */batchgeoreftool.php
  6. // @author Jack Willis
  7. // @version 1.0
  8. // @grant none
  9. // @license MIT; https://opensource.org/licenses/MIT
  10. // ==/UserScript==
  11.  
  12. $(function() {
  13. function sample(array) { return array[(Math.random() * array.length) | 0]; }
  14. var shuffleButton = $("<a>")
  15. .html("&#x1F500;") // shuffle emoji
  16. .css("margin-left", "10px").css("font-size", "18px")
  17. .hover(function() {
  18. $(this).css("cursor", "pointer").css("text-decoration", "none");
  19. }).click(function(event) {
  20. event.preventDefault();
  21. $("#locallist option:selected").prop("selected", false); // deselect all batches
  22. $(sample($("#locallist option"))).prop("selected", true); // select random batch
  23. });
  24. // inject shuffle button in the panel above the <select>
  25. $("form[name=georefform] > div:first-child").append(shuffleButton);
  26. });