luci/applications/luci-app-radicale/luasrc/view/radicale/btn_startstop.htm
Mustafa Can Elmacı ae8bbb814f treewide: HTML Cleanup
* HTML Cleanup: Meta tags.
* Converted charset to shorthand.
* Removed meta tags with `Content-Script-Type` attribute. (Invalid in HTML5 spec.)

* HTML Cleanup: CSS tags.
* Removed `type` attribute with CSS files from link tags. (HTML5 spec recommends omitting it.)
* Removed `type` attribute from style tags. (Deprecated in HTML5 spec.)
https://html.spec.whatwg.org/#attr-link-type
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style

* HTML Cleanup: Convert from XHTML to HTML5
* Removed XML declaration.
* Removed XML namespace.
* Changed doctype to HTML5.

* HTML Cleanup: CDATA tags.
* CDATA sections should not be used within HTML they are considered as comments and not displayed.
https://developer.mozilla.org/en-US/docs/Web/API/CDATASection

* HTML Cleanup: Script tags.
* Removed `language` attribute from script tags. (No longer valid in HTML5)
* Removed `type` attribute with JavaScript MIME type from script tags. (HTML5 spec recommends omitting it.)
https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
https://mimesniff.spec.whatwg.org/#javascript-mime-type

Signed-off-by: Mustafa Can Elmacı <mustafacan@elmaci.net>
2024-11-22 22:39:46 +01:00

49 baris
1,5 KiB
HTML

<!-- ++ BEGIN ++ Radicale ++ btn_startstop.htm ++ -->
<script>
// show XHR.poll/XHR.get response on button
function _data2elements(x) {
var btn = document.getElementById("cbid.radicale.<%=section%>._startstop");
if ( ! btn ) { return; } // security check
if (x.responseText == "0") {
btn.value = "<%:Start%>";
btn.className = "cbi-button cbi-button-apply";
btn.disabled = false;
} else {
btn.value = "PID: " + x.responseText;
btn.className = "cbi-button cbi-button-reset";
btn.disabled = false;
}
}
// event handler for start/stop button
function onclick_startstop(id) {
// do start/stop
var btnXHR = new XHR();
btnXHR.post('<%=url([[admin/services/radicale/startstop]])%>', { token: '<%=token%>' },
function(x) { _data2elements(x); }
);
}
XHR.poll(-1, '<%=url([[admin/services/radicale/status]])%>', null,
function(x, data) { _data2elements(x); }
);
</script>
<%+cbi/valueheader%>
<% if self:cfgvalue(section) ~= false then
-- We need to garantie that function cfgvalue run first to set missing parameters
%>
<!-- style="font-size: 100%;" needed for openwrt theme to fix font size -->
<!-- type="button" onclick="..." enable standard onclick functionalty -->
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="font-size: 100%;" type="button" onclick="onclick_startstop(this.id)"
<%=
attr("name", section) .. attr("id", cbid) .. attr("value", self.inputtitle) .. ifattr(self.disabled, "disabled")
%> />
<% end %>
<%+cbi/valuefooter%>
<!-- ++ END ++ Radicale ++ btn_startstop.htm ++ -->