|
// ToDoList Protocol (TDL) Script Edition, Version 1.0 Beta2
function TdlParser(url) {
this.url = unescape(url);
this.tid = null;
this.parse();
}
TdlParser.prototype.init = function() {
TdlParser.prototype.ParseError = new Error("parse error");
}
TdlParser.prototype.parse = function() {
if (this.url.match(/^tdl:\/\/\//i) == null) {
throw this.ParseError;
}
var url = this.url.substr(7);
var i = url.indexOf("?");
if (i < 0) {
this.tid = null;
return;
}
this.filename = unescape(url.substr(0, i));
this.tid = parseInt(url.substr(i + 1));
if (isNaN(this.tid)) {
this.tid = 0;
throw this.ParseError;
}
}
TdlParser.prototype.getFilename = function() {
return this.filename;
}
TdlParser.prototype.getTid = function() {
return this.tid;
}
TdlParser.prototype.toString = function() {
var str = "tdl:///" + escape(this.filename.replace(/\\\\/g, "/"));
if (this.tid != null) {
str += "?" + this.tid;
}
return str;
}
TdlParser.prototype.init();
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
James Fancy, is a software engineer from China. He enjoys and familiar with Java, C++ and some script languages.
If you can read Chinese word, here is one of James Fancy's BLOG:
http://hi.baidu.com/jamesfancy