0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Chandrayya G K
  • 8,719
  • 5
  • 40
  • 68
  • It maybe caused by editor not being positioned correctly see http://stackoverflow.com/questions/25821470/ace-editor-doesnt-work-with-bootstrap/25830964#25830964 – a user Sep 14 '14 at 07:46
  • No help. Will you please provide me correct grease monkey script. – Chandrayya G K Sep 15 '14 at 08:34
  • I don't have jenkins page or greasmonkey to test this, if you could reduce it to a standalone html + js file, i can take a look. Also why that answer didn't help you? Do you see any errors in the console, is the ace editor initialized? – a user Sep 15 '14 at 20:13

0 Answers0