Related posts: How do I get value from ACE editor? , How do I make a textarea an ACE editor? and jenkins how to activate syntax highlighting in "Build" -> "execute shell"
Tried so far:
// ==UserScript==
// @name jenkin
// @namespace <VALID JENKIN URL/*>
// @include <VALID JENKIN URL/*>
// @require https://github.com/ajaxorg/ace-builds/blob/master/src-nonconflict/ace.js
// @version 1
// @grant none
// ==/UserScript==
alert("I am in");
var txts = document.getElementsByName("command"); // ALL text areas are named as
// "command" with no id attribute.
for(var x=0; x < txts.length; x++)
{
var editDiv = $('<div>', {
position: 'absolute',
width: txts[x].width(),
height: txts[x].height(),
'class' : txts[x].attr('class')
}).insertBefore(txts[x]);
txts[x].css('visibility','hidden');
var editor = ace.edit(editDiv[0]);
editor.setTheme("/ace/theme/monokai");
editor.getSession().setValue(txts[x].value);
editor.getSession().setMode("/ace/mode/sh");
txts[x].closest('form').submit(function () {
txts[x].valve=editor.getSession().getValue();
});
}
Question:
I am trying to display the code in all command text areas (In jenkins build step) with syntax highlight. Also if the code changed in these text areas by the users then the new code should take effect on submitting the form.
The above grease-monkey user script is not working. I am getting the alert box but code is NOT highlighted.
Is there any way to fix this? Also any alternative suggestion on displaying the shell script code in jenkins job with syntax highlight are welcomed.