We want to make settings panels without an Apply button so that changes take effect immediately, just as in most GNOME apps. We want to do this on the web.
object. Then we hook it up like this:
function takes a template file and its environment to produce the finished document.
We need some support libraries: one in Scheme to handle the templating, and another in
.
function makeReqObj() { return new XMLHttpRequest()
function httpSendGeneric(method, url, content, errorHandler) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead") } catch (e) {
softError("httpSendGeneric",
e.toString() + " Could not enable UniversalBrowserRead privilege.") }
try {
var http = makeReqObj() if (!http) {
if (errorHandler) errorHandler("httpSendGeneric", "could not create http object") else softError("httpSendGeneric", "could not create http object") }
http.open(method, url, false) http.send(content) httpCheckOK(http, errorHandler) return http } catch (e) {
if (errorHandler) errorHandler("httpSendGeneric", e.toString()) else softError("httpSendGeneric", e.toString()) return null }
}
function httpGetGeneric(url, errorHandler) {
return httpSendGeneric("GET", url, null, errorHandler)}
function httpPostGeneric(url, content, errorHandler) {
return httpSendGeneric("POST", url, content, errorHandler)}
function httpGetGenericK(url, k, errorHandler) {
var http = makeReqObj() http.open("GET", url, true) http.onreadystatechange = function () {
// 4 means loaded
if (http.readyState == 4) {
httpCheckOK(http, errorHandler) k(http) }
}
}
function softError(callerName, msg) {
alert(msg)}
function httpCheckOK(http, errorHandler) {
if (http.status == 200) {
//alert("looks ok") return } else if (errorHandler) {
errorHandler(http) }else {
softError("http", http.statusText) }
}
function httpGetK(url, k, errorHandler) {
httpGetGenericK(url,
function (http) {k(http.responseXML) errorHandler)}
function httpGetKText(url, k, errorHandler) {
httpGetGenericK(url,
function (http) {k(http.responseText) errorHandler)}
function DOMParseText(str, contentType, errorHandler) {
try {
return (new DOMParser()).parseFromString(str, contentType) } catch (e) {
if (errorHandler) errorHandler("DOMParseText", e) else softError("DOMParseText", e) return null }
}
function httpGetHTML(url,errorHandler) {
return DOMParseText(httpGetText(url, errorHandler),
"text/html", errorHandler)}
function httpGetXML(url,errorHandler) {
return DOMParseText(httpGetText(url, errorHandler),
"text/xml", errorHandler)}
function httpGetText(url, errorHandler) {
return httpGetGeneric(url, errorHandler).responseText}
function httpPost(url, content, errorHandler) {
return httpPostGeneric(url, content, errorHandler).responseXML}