From 6865a0651e61fb8261aa67939c6683cea51c6e44 Mon Sep 17 00:00:00 2001 From: sbwml Date: Wed, 21 Aug 2024 20:20:38 +0800 Subject: [PATCH] luci-app-mosdns: fix codemirror may not work correctly Signed-off-by: sbwml --- luci-app-mosdns/Makefile | 2 +- .../codemirror5/addon/fold/foldcode.min.js | 1 - .../codemirror5/addon/fold/foldgutter.min.css | 1 - .../codemirror5/addon/fold/foldgutter.min.js | 1 - .../codemirror5/addon/fold/indent-fold.min.js | 1 - .../resources/view/mosdns/basic.js | 24 +++++++------------ luci-app-mosdns/po/zh_Hans/mosdns.po | 3 --- 7 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 luci-app-mosdns/htdocs/luci-static/resources/codemirror5/addon/fold/foldcode.min.js delete mode 100644 luci-app-mosdns/htdocs/luci-static/resources/codemirror5/addon/fold/foldgutter.min.css delete mode 100644 luci-app-mosdns/htdocs/luci-static/resources/codemirror5/addon/fold/foldgutter.min.js delete mode 100644 luci-app-mosdns/htdocs/luci-static/resources/codemirror5/addon/fold/indent-fold.min.js diff --git a/luci-app-mosdns/Makefile b/luci-app-mosdns/Makefile index 5f66a2e..9ab0465 100644 --- a/luci-app-mosdns/Makefile +++ b/luci-app-mosdns/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-mosdns -PKG_VERSION:=1.6.3 +PKG_VERSION:=1.6.4 PKG_RELEASE:=1 LUCI_TITLE:=LuCI Support for mosdns diff --git a/luci-app-mosdns/htdocs/luci-static/resources/codemirror5/addon/fold/foldcode.min.js b/luci-app-mosdns/htdocs/luci-static/resources/codemirror5/addon/fold/foldcode.min.js deleted file mode 100644 index cefcfc5..0000000 --- a/luci-app-mosdns/htdocs/luci-static/resources/codemirror5/addon/fold/foldcode.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(n){"object"==typeof exports&&"object"==typeof module?n(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(c){"use strict";function t(t,i,n,f){n&&n.call?(l=n,n=null):l=a(t,n,"rangeFinder"),"number"==typeof i&&(i=c.Pos(i,0));var l,d=a(t,n,"minFoldSize");function o(n){var o=l(t,i);if(!o||o.to.line-o.from.linet.firstLine();)i=c.Pos(i.line-1,0),u=o(!1);u&&!u.cleared&&"unfold"!==f&&(e=function(n,o,e){n=a(n,o,"widget");"function"==typeof n&&(n=n(e.from,e.to));"string"==typeof n?(o=document.createTextNode(n),(n=document.createElement("span")).appendChild(o),n.className="CodeMirror-foldmarker"):n=n&&n.cloneNode(!0);return n}(t,n,u),c.on(e,"mousedown",function(n){r.clear(),c.e_preventDefault(n)}),(r=t.markText(u.from,u.to,{replacedWith:e,clearOnEnter:a(t,n,"clearOnEnter"),__isFold:!0})).on("clear",function(n,o){c.signal(t,"unfold",t,n,o)}),c.signal(t,"fold",t,u.from,u.to))}c.newFoldFunction=function(e,r){return function(n,o){t(n,o,{rangeFinder:e,widget:r})}},c.defineExtension("foldCode",function(n,o,e){t(this,n,o,e)}),c.defineExtension("isFolded",function(n){for(var o=this.findMarksAt(n),e=0;e=d){if(l&&e&&l.test(e.className))return;o=p(i.indicatorOpen)}}(o||e)&&r.setGutterMarker(t,i.gutter,o)})}function e(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}function f(t){var o=t.getViewport(),e=t.state.foldGutter;e&&(t.operation(function(){i(t,o.from,o.to)}),e.from=o.from,e.to=o.to)}function d(t,o,e){var n=t.state.foldGutter;!n||e==(e=n.options).gutter&&((n=s(t,o))?n.clear():t.foldCode(c(o,0),e))}function a(t,o){"mode"==o&&u(t)}function u(t){var o,e=t.state.foldGutter;e&&(o=e.options,e.from=e.to=0,clearTimeout(e.changeUpdate),e.changeUpdate=setTimeout(function(){f(t)},o.foldOnChangeTimeSpan||600))}function l(o){var t,e=o.state.foldGutter;e&&(t=e.options,clearTimeout(e.changeUpdate),e.changeUpdate=setTimeout(function(){var t=o.getViewport();e.from==e.to||20e.to&&(i(o,e.to,t.to),e.to=t.to)})},t.updateViewportTimeSpan||400))}function m(t,o){var e=t.state.foldGutter;!e||(o=o.line)>=e.from&&o { for (const href of styles) { @@ -400,13 +396,10 @@ return view.extend({ matchBrackets: true, mode: "text/yaml", styleActiveLine: true, - theme: "dracula", - fontSize: "14", - viewportMargin: Infinity + theme: "dracula" }); - console.log('CodeMirror editor initialized.'); } - }, 120); + }, 150); o = s.taboption('basic', form.TextValue, '_custom', _('Configuration Editor'), _('This is the content of the file \'/etc/mosdns/config_custom.yaml\' from which your MosDNS configuration will be generated. \ Only accepts configuration content in yaml format.')); @@ -419,15 +412,14 @@ return view.extend({ if (configeditor) { var editorContent = configeditor.getValue(); if (editorContent === formvalue) { - return; + return window.location.reload(); } return fs.write('/etc/mosdns/config_custom.yaml', editorContent.trim().replace(/\r\n/g, '\n') + '\n') .then(function (i) { - ui.addNotification(null, E('p', _('Configuration have been saved.')), 'info'); return fs.exec('/etc/init.d/mosdns', ['restart']); }) .then(function () { - window.location.reload(); + return window.location.reload(); }) .catch(function (e) { ui.addNotification(null, E('p', _('Unable to save contents: %s').format(e.message))); diff --git a/luci-app-mosdns/po/zh_Hans/mosdns.po b/luci-app-mosdns/po/zh_Hans/mosdns.po index 16760aa..604921f 100644 --- a/luci-app-mosdns/po/zh_Hans/mosdns.po +++ b/luci-app-mosdns/po/zh_Hans/mosdns.po @@ -371,9 +371,6 @@ msgstr "规则列表" msgid "Rule Settings" msgstr "自定义规则列表" -msgid "Rules have been saved." -msgstr "规则已保存" - msgid "Unable to save contents: %s" msgstr "无法保存内容:%s"