From f91bb601ff9ea6ca4656dccc8341deba99900535 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sun, 28 Jan 2024 02:24:42 +0100 Subject: [PATCH] js: Migrate code to not use deprecated 2.x features --- dpl-docs/views/layout.dt | 2 +- js/run.js | 17 +++-------------- js/run_examples.js | 2 +- js/show_contributors.js | 2 +- spec/spec.ddoc | 2 +- std.ddoc | 2 +- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/dpl-docs/views/layout.dt b/dpl-docs/views/layout.dt index 712ddf72d6..cd056854b8 100644 --- a/dpl-docs/views/layout.dt +++ b/dpl-docs/views/layout.dt @@ -244,5 +244,5 @@ html(lang='en-US') script(type='text/javascript', src='#{root_dir}js/listanchors.js') script(type="text/javascript", src="#{root_dir}js/ddox.js") script(type='text/javascript'). - jQuery(document).ready(listanchors); + jQuery(listanchors); setupDdox(); diff --git a/js/run.js b/js/run.js index 48c85f26d8..bccf363bcc 100644 --- a/js/run.js +++ b/js/run.js @@ -42,11 +42,6 @@ All examples are replaced with custom form by default. You need to do additional your example to have default standard input or default standard arguments. */ -var nl2br = function() -{ - return this.replace(/\n/g, "
"); -} - function safeVar(data, path) { var p = path.split("."); @@ -150,10 +145,7 @@ function parseOutput(res, o, oTitle) if (res.cstatus != 0) { oTitle.text("Compilation output ("+res.cstatus+": "+res.cerr+")"); - if ($.browser.msie) - o.html(nl2br(res.cout)); - else - o.text(res.cout); + o.text(res.cout); return; } @@ -172,10 +164,7 @@ function parseOutput(res, o, oTitle) oTitle.text("Application output ("+res.rstatus+": "+res.rerr+")"); } - if ($.browser.msie) - o.html(nl2br(res.cout)); - else - o.text(output); + o.text(output); } // wraps a unittest into a runnable script @@ -197,7 +186,7 @@ function wrapIntoMain(code, compile) { } } -$(document).ready(function() +$(function() { setUpExamples(); diff --git a/js/run_examples.js b/js/run_examples.js index 063fea193a..c5b7539b7a 100644 --- a/js/run_examples.js +++ b/js/run_examples.js @@ -37,7 +37,7 @@ function wrapIntoMain(code) { return codeOut; } -$(document).ready(function() +$(function() { if ($('body')[0].id == "Home") return; diff --git a/js/show_contributors.js b/js/show_contributors.js index a003da6434..0aee28078f 100644 --- a/js/show_contributors.js +++ b/js/show_contributors.js @@ -14,7 +14,7 @@ function isPackage() return $('.tip.smallprint a[href*="package.d"]').length > 0; } -$(document).ready(function() +$(function() { // only for library documentation if (!$('body').hasClass("std")) diff --git a/spec/spec.ddoc b/spec/spec.ddoc index f7bfdb017f..5cbbf6e472 100644 --- a/spec/spec.ddoc +++ b/spec/spec.ddoc @@ -139,5 +139,5 @@ RAWHTML=$0 _= LAYOUT_SUFFIX = $(SCRIPTLOAD ../js/listanchors.js) -$(SCRIPT jQuery(document).ready(addVersionSelector);) +$(SCRIPT jQuery(addVersionSelector);) _= diff --git a/std.ddoc b/std.ddoc index 9ce7c58412..df2fa9dfa3 100644 --- a/std.ddoc +++ b/std.ddoc @@ -7,7 +7,7 @@ BODY_PREFIX = $(DIVCID quickindex, quickindex, ) LAYOUT_SUFFIX = $(SCRIPTLOAD ../js/listanchors.js) $(SCRIPTLOAD ../js/show_contributors.js) -$(SCRIPT jQuery(document).ready(listanchors);) +$(SCRIPT jQuery(listanchors);) LAYOUT_TITLE=$(H1 $(D_TITLE $(TITLE))) _=