Hints for programming Conkeror
These are some hints which you can use for programming Conkeror (or Vonkeror). Many of these can be applicable for any program written in Javascript, but not completely. (I might add more stuff here later, or you can do it also!)
Useful utility functions
function htmlEncode(s) {
return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ");
}
String.prototype.backspace=function(){return this.substring(0,this.length-1)};
//Object.prototype.toPrimitiveSource=function(){return this.toSource();}; // doesn't work
Number.prototype.toPrimitiveSource=Number.prototype.toString();
Boolean.prototype.toPrimitiveSource=Boolean.prototype.toString();
String.prototype.toPrimitiveSource=function(){return let(x=[this.valueOf()].toSource())x.substring(1,x.length-1)};
function toPrimitiveSource(obj) {
if(obj===undefined) return "undefined";
if(obj===null) return "null";
if(obj.toPrimitiveSource) return obj.toPrimitiveSource();
if(obj.toSource) return obj.toSource();
}
//SequentialGenerator: takes a array of Generators. Return a Generator running each element until finished in a sequence
function SequentialGenerator(x) {
var i=0;
for(i=0;i<x.length;i++) {
try {
while(true) yield x[i].next();
} catch(e if e instanceof StopIteration) {}
}
}
Single character options
When reading a single character option in the minibuffer, you can make it accept all characters as valid by passing $options={indexOf:function(x)(0)}