mirror of
https://github.com/lennyhans/systemd-to-openrc.git
synced 2026-03-12 05:35:18 +00:00
Add working module based clone from original openrc-run generator
See http://openrc.run/ This able to split the same working piece as a node and browser module
This commit is contained in:
parent
1163906176
commit
331d7980be
3 changed files with 129 additions and 13 deletions
31
index.js
Normal file
31
index.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { convert } from './magic.js'
|
||||
|
||||
function convertForBrowser (convertFunction){
|
||||
return function(event){
|
||||
event.preventDefault();
|
||||
const raw = document.getElementById('unit').value;
|
||||
|
||||
const response = convertFunction(raw)
|
||||
const validated = response.validated;
|
||||
const result = response.result;
|
||||
if (validated !== null) {
|
||||
document.getElementById('error').innerHTML = validated;
|
||||
return;
|
||||
} else {
|
||||
document.getElementById('error').innerHTML = '';
|
||||
}
|
||||
document.getElementById('openrc').innerText = result;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function setup(){
|
||||
if(typeof window !== "undefined" && typeof window.document !== "undefined"){
|
||||
const convertFunction = convertForBrowser(convert)
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
document.getElementById('convert').addEventListener('click', convertFunction);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setup();
|
||||
Loading…
Add table
Add a link
Reference in a new issue