systemd-to-openrc/index.js
Lenny Andreu 331d7980be 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
2025-05-17 20:38:35 -04:00

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();