mirror of
https://github.com/lennyhans/systemd-to-openrc.git
synced 2026-03-09 20:31:09 +00:00
See http://openrc.run/ This able to split the same working piece as a node and browser module
31 lines
957 B
JavaScript
31 lines
957 B
JavaScript
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();
|