Skip to content

Instantly share code, notes, and snippets.

@r-k-b
Last active June 23, 2016 01:57
Show Gist options
  • Save r-k-b/eabcb44dfd4f712ce26aa32512c32abe to your computer and use it in GitHub Desktop.
Save r-k-b/eabcb44dfd4f712ce26aa32512c32abe to your computer and use it in GitHub Desktop.
Show webapp field IDs in BC Admin Raw
// ==UserScript==
// @name Show webapp field IDs in BC Admin
// @namespace https://gist.github.com/r-k-b/
// @version 1.0.0
// @description ...
// @author Robert K. Bell
// @homepage https://gist.github.com/r-k-b/eabcb44dfd4f712ce26aa32512c32abe
// @downloadURL https://gist.github.com/r-k-b/eabcb44dfd4f712ce26aa32512c32abe/raw/show-bc-webapp-field-ids.user.js
// @match https://*.worldsecuresystems.com/Admin/CustomContent*
// @grant none
// @run-at document-end
// @require https://cdn.jsdelivr.net/jquery/3.0.0/jquery.js#sha256=jrPLZ+8vDxt2FnE1zvZXCkCcebI/C8Dt5xyaQBjxQIo=
// @require https://cdn.jsdelivr.net/ramda/0.21.0/ramda.min.js#sha256=cVOOKbovbMkVdlMEdSBTWta9TkmRts60+o0I92BxS48=
// ==/UserScript==
// todo: keep field edit panel IDs visible through usage (event / setInterval?)
// todo: show field IDs on the item detail view
/* jshint esnext: true */
(($, R) => {
'use strict';
const fieldEditorItems = $('#ctl00_cp_uc_listFormItems option').toArray();
const getSuffix = R.compose(
x => parseInt(x, 10),
R.head,
R.split(','),
R.prop('value')
);
const getLabel = R.prop('innerHTML');
const isCustom = R.compose(
R.lt(0),
getSuffix
);
const updatedLabel = elem => {
return `<code>「CAT_Custom_${ getSuffix(elem) }」</code>${ getLabel(elem) }`;
};
const customItems = R.filter(isCustom, fieldEditorItems);
const doUpdate = elem => {
elem.innerHTML = updatedLabel(elem);
return;
};
const run = R.map(doUpdate);
// imperative:
run(customItems);
})(jQuery, R);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment