Skip to content

Commit

Permalink
[JENKINS-73891] Extract inline JS in ConfigFilesUI/edit.jelly and `…
Browse files Browse the repository at this point in the history
…ConfigFilesUI/show.jelly` (#342)
  • Loading branch information
shlomomdahan authored Oct 22, 2024
1 parent 4554bc6 commit 88956aa
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ THE SOFTWARE.
<j:if test="${contentType!=null}">
<st:adjunct includes="
org.kohsuke.stapler.codemirror.mode.${contentType.cmMode}.${contentType.cmMode},
org.kohsuke.stapler.codemirror.theme.default"/>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("config.content"), {
lineNumbers: true,
matchBrackets: true,
mode: "${contentType.mime}"
});
</script>
org.kohsuke.stapler.codemirror.theme.default,
org.jenkinsci.plugins.configfiles.ConfigFilesUI.setup-codemirror"/>
<span class="content-type-config" data-content-type="${contentType.mime}" data-read-only="false" style="display:none"/>
</j:if>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
document.addEventListener("DOMContentLoaded", function () {
const textarea = document.getElementById("config.content");
const contentTypeElement = document.querySelector(".content-type-config");

const contentType = contentTypeElement.dataset.contentType;
const readOnly = contentTypeElement.dataset.readOnly === "true";

CodeMirror.fromTextArea(textarea, {
lineNumbers: true,
matchBrackets: true,
mode: contentType,
readOnly: readOnly,
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,8 @@ THE SOFTWARE.
<j:if test="${contentType!=null}">
<st:adjunct includes="
org.kohsuke.stapler.codemirror.mode.${contentType.cmMode}.${contentType.cmMode},
org.kohsuke.stapler.codemirror.theme.default"/>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("config.content"), {
lineNumbers: true,
matchBrackets: true,
mode: "${contentType.mime}",
readOnly: true
});
</script>
org.kohsuke.stapler.codemirror.theme.default,
org.jenkinsci.plugins.configfiles.ConfigFilesUI.setup-codemirror"/>
<span class="content-type-config" data-content-type="${contentType.mime}" data-read-only="true" style="display:none"/>
</j:if>
</j:jelly>

0 comments on commit 88956aa

Please sign in to comment.