Click here to Skip to main content
15,885,366 members
Articles / Web Development / HTML

TDL: Protocol for .dan.g.'s ToDoList, Useful for SVN Users

Rate me:
Please Sign up or sign in to vote.
4.43/5 (3 votes)
25 Apr 2008CPOL3 min read 55.7K   509   44  
Register a fake protocol of TDL: to make tdl:///filename.tdl?tid available
// 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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
China China
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

Comments and Discussions