// import '../references/extensions.dist.js';

class ContentService {

    GenerateCheckBox(num, label, checked) {
        let html = "";
        html += "<div class=\"form-check form-switch\">";
        html += "<input class=\"form-check-input\" type=\"checkbox\" role=\"switch\" id=\"checkbox" + num + "\" name=\"checkbox" + num + "\" " + (checked ? "checked" : "") + ">";
        html += "<label class=\"form-check-label\" for=\"checkbox" + num + "\">" + label + "</label>";
        html += "</div>";

        return html;
    }

    GenerateCols(...args) {
        let html = "";

        for (let i=0; i<args.length; i++) {
            html += "<div class=\"col\">" + args[i] + "</div>";
        }

        return html;
    }

    GenerateCSVLine(delimiter, ...args) {
        const a = this;

        if (args.length === 1) {
            if (Object.getDataType(args[0]) == "array") {
                args = args[0];
            }
        }

        let result = "";
        for (let i=0; i<args.length; i++) {
            if (i > 0) {
                result += delimiter
            }

            result += args[i];
        }

        return result;
    }

    GenerateRadioBox(groupNo, num, label, value, checked) {
        let html = "";
        html += "<div class=\"form-check\">";
        html += "<input class=\"form-check-input\" type=\"radio\" name=\"radioGroup" + groupNo + "\" id=\"radioBox" + num + "\" value=\"" + value + "\" " + (checked ? "checked" : "") + ">";
        html += "<label class=\"form-check-label\" for=\"radioBox" + num + "\">" + label + "</label>";
        html += "</div>";

        return html;
    }

    GenerateRow(...args) {
        const a = this;

        if (args.length === 1) {
            if (Object.getDataType(args[0]) == "array") {
                args = args[0];
            }
        }

        let result = "";
        for (let i=0; i<args.length; i++) {
            result = result + a.GenerateRowCell(args[i]);
        }

        return "<tr>" + result + "</tr>";
    }

    GenerateRowCell(value) {
        return "<td class=\"\"><input type=\"text\" class=\"display\" readonly=\"readonly\" value=\"" + value + "\" /></td>";
    }

    SetHtml(element, htmlContent) {
        if (element == null) {
            return;
        }

        element.innerHTML = htmlContent;
    }

}


export default ContentService;