Agg. pagina Percent-Encoding

This commit is contained in:
octt 2025-02-11 23:15:29 +01:00
parent da82f8441f
commit e249817c94
7 changed files with 65 additions and 6 deletions

View File

@ -5,8 +5,12 @@ cd "${swd}/.."
mkdir -p ./static/res/lib
cd ./static/res/lib
wget --continue "https://spaccinc.gitlab.io/SpaccDotWeb/SpaccDotWeb.Alt.min.js"
wget --continue "https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"
wget --continue "https://uicdn.toast.com/editor/latest/toastui-editor.min.css"
downloadfile(){
wget -O "./$2" "https://$1/$2"
}
downloadfile spaccinc.gitlab.io/SpaccDotWeb SpaccDotWeb.Alt.min.js
downloadfile uicdn.toast.com/editor/latest toastui-editor-all.min.js
downloadfile uicdn.toast.com/editor/latest toastui-editor.min.css
cd "${owd}"

View File

@ -0,0 +1,14 @@
+++
Title = "Codifica URL"
+++
<div class="Percent-Encoding">
<label>Plain</label>
<textarea name="plain"></textarea>
<label>URL-encoded</label>
<textarea name="coded"></textarea>
<p>
<label>Passaggi: <input name="steps" type="number" value="1" min="1" /></label>
</p>
<link rel="stylesheet" href="/res/Percent-Encoding.css" />
<script src="/res/Percent-Encoding.js"></script>
</div>

View File

@ -0,0 +1,6 @@
.Percent-Encoding > div {
/* display: grid;
grid-template-columns: auto auto; */
}
.Percent-Encoding textarea { width: 100%; min-height: 10em; }

View File

@ -0,0 +1,19 @@
(function(stepsEl){
function convertText (sourceEl, destinationEl, handler) {
var text = sourceEl.value;
for (var i=0; i<stepsEl.value; i++) {
text = handler(text);
}
destinationEl.value = text;
}
function makeConvertHandler(sourceEl, destinationEl, handler) {
return (function(){
convertText(sourceEl, destinationEl, handler);
});
}
sitoctt.utils.setTextConvertEvents(document.querySelector('textarea[name="plain"]'), document.querySelector('textarea[name="coded"]'), encodeURIComponent, decodeURIComponent, makeConvertHandler);
})(document.querySelector('input[name="steps"]'));

View File

@ -41,7 +41,8 @@ input.onkeyup = function (event) {
};
function documentOnKeyDown (event) {
if (event.key == "/") {
if (event.key == '/' && event.ctrlKey) {
if (!searchVisible) {
event.preventDefault();
displaySearch();
@ -50,7 +51,7 @@ function documentOnKeyDown (event) {
}
}
if (event.key == "Escape") {
if (event.key == 'Escape') {
hideSearch();
}

View File

@ -0,0 +1,14 @@
(function(self){
self.setTextFieldEvents = (function (el, handler) {
['click', 'change', 'input', 'paste'].forEach(function(event){
el.addEventListener(event, handler);
});
});
self.setTextConvertEvents = (function (el0, el1, convertHandler, unconvertHandler, constructor) {
self.setTextFieldEvents(el0, constructor(el0, el1, convertHandler));
self.setTextFieldEvents(el1, constructor(el1, el0, unconvertHandler));
});
})(sitoctt.utils);

View File

@ -1,5 +1,5 @@
<script>
window.sitoctt = {};
window.sitoctt = { utils: {} };
window.Void = (function Void(){});
{{- with resources.Get "SiteProps.toml" -}}
{{- with . | transform.Unmarshal -}}
@ -8,6 +8,7 @@ window.Void = (function Void(){});
{{- end -}}
window.sitoctt.localStorage = (function localStorage(key, value){ return SpaccDotWeb.LocalStorage('org.eu.octt.sitoctt', key, value); });
</script>
<script src="/res/sitoctt-utils.js"></script>
<script src="/res/ajax-navigation.js"></script>
<script src="/res/local-file-tweaks.js"></script>
<script src="/{{ .Lang }}/searchindex.js"></script>