jrwarwick / Oracle APEX Component Export Enhancements

// ==UserScript==
// @name         Oracle APEX Component Export Enhancements
// @namespace    https://jrwarwick.github.io/
// @version      0.1
// @description  Small handy injected features to improve efficiency for Oracle APEX developers and deployers. Includes: quickselect of list of page components by delimited list of pages
// @copyright    2023, Justin Warwick
// @author       jrwarwick
// @license      MIT
// @match        https://your-development-apex-hostname.abc.tld/ords/f?p=4000:688:*
// @icon         https://apex.oracle.com/assets/media/icons/favicon.ico
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // QuickSelect:Pages

  if ($("#P688_COMPONENT").val() == "PAGE") {
    $("div.a-Wizard-controls >div.wizardHeader").append('<label for="tgtPageIDlist"><em id="quickSelectPagesTag">QuickSelect:</em> PageID List (delimited) </label><textarea id="tgtPageIDlist" style="width:30em;"></textarea>');
  }

  function quickSelectPages() {
    var allPageIDs = $("#tgtPageIDlist").val().split(/[\s,;:]+/).sort(); // more strict RE, if you like: /\s*,\s*/
    var pageIDs = [...new Set(allPageIDs)]; // cool modern trick to uniq the array
    console.log("userscript: Trying to 'quick-select' (click) " + pageIDs.length + " checkboxes...");
    pageIDs.forEach((pageID) => $("input[value='" + pageID.trim() + "xPAGE']").click());
    //$("button:contains('Add to Export')").click();  //probably not a good idea actually.
  }

  $("#quickSelectPagesTag").on("click", quickSelectPages);
  $("#tgtPageIDlist").on("dblclick", quickSelectPages);

})();