Click here to Skip to main content
12,999,417 members (62,882 online)
Click here to Skip to main content

Stats

41.8K views
464 downloads
43 bookmarked
Posted 2 Feb 2007

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

, 25 Apr 2008
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)

Share

About the Author

jamesfancy
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

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170624.1 | Last Updated 25 Apr 2008
Article Copyright 2007 by jamesfancy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid