/* NEW BSD LICENSE {{{ Copyright (c) 2009, anekos. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ################################################################################### # http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license # # に参考になる日本語訳がありますが、有効なのは上記英文となります。 # ################################################################################### }}} */ // PLUGIN_INFO {{{ let PLUGIN_INFO = Namakubi 生首 Wonderful Namakubi Talker! 素敵な生首トーカー 1.0.0 anekos new BSD License (Please read the source code comments of this plugin) 修正BSDライセンス (ソースコードのコメントを参照してください) http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk/namakubi.js 2.3pre 2.3 ; // }}} // INFO {{{ let INFO = anekos New BSD License

恐怖!喋る生首! ということで、棒読みちゃんというプログラムを Vimperator で操作するものです。

:namakubi :namakubi -speed=SPEED -tone=TONE -volume=VOLUME -voice=VOICE -host=HOST -port=PORT text

しゃ、しゃべったぞ!!

各オプション値の意味は以下の通り()内はデフォルト値

SPEED
速度(-1)
TONE
音程(-1)
VOLUME
音量(-1)
VOICE
声質(1)
HOST
棒読みちゃんサーバのホスト名("localhost")
PORT
棒読みちゃんサーバのポート番号(50001)

棒読みちゃん?

棒読みちゃんは日本語のテキストを合成音声で喋らせるプログラムです。 http://chi.usamimi.info/Program/Application/BouyomiChan/ で Windows 用バイナリが手に入ります。

; // }}} (function () { function intToBin (n, sz) { let r = ''; if (n < 0) n = 0x100000000 - Math.abs(n); for (let i = 0; i < sz; i++) r += String.fromCharCode((n >> (i * 8)) & 0xff); return r; } function strToBin (string) { return unescape(encodeURIComponent(string)); } let talkOption = { speed: {value: -1, short: 's', desc: 'Speech speed (50-300)'}, tone: {value: -1, short: 't', desc: 'Tone (50-200)'}, volume: {value: -1, short: 'vol', desc: 'Volume (0-100)'}, voice: {value: 1, short: 'v', desc: 'Voice Type (0-8 = Aques Talk, 9- = SAPI)'}, host: {value: 'localhost', short: 'h', desc: 'Hostname of BouyomiChan Server'}, port: {value: 50001, short: 'p', desc: 'Port number of server'} }; let socketService = let (stsvc = Components.classes["@mozilla.org/network/socket-transport-service;1"]) let (svc = stsvc.getService()) svc.QueryInterface(Components.interfaces["nsISocketTransportService"]); function talk (msg, option) { function value (name, size) let (v = (option && typeof option[name] !== 'undefined') ? option[name] : talkOption[name].value) (size ? intToBin(v, size) : v); let transport = socketService.createTransport(null, 0, value('host'), value('port'), null); let outputStream = transport.openOutputStream(0, 0, 0); let (binaryOutputStream = Components.classes["@mozilla.org/binaryoutputstream;1"]. createInstance(Components.interfaces["nsIBinaryOutputStream"])) binaryOutputStream.setOutputStream(outputStream); msg = strToBin(msg); let buf = intToBin(1, 2) + value('speed', 2) + value('tone', 2) + value('volume', 2) + value('voice', 2) + intToBin(0, 1) + intToBin(msg.length, 4) + msg; outputStream.write(buf, buf.length); } commands.addUserCommand( ['namakubi'], 'Description', function (args) { let option = {}; [option[n] = args['-' + n] for (n in talkOption) if (args['-' + n])]; talk(args.literalArg, option); }, { literal: 0, options: [ [ ['-' + n, '-' + talkOption[n].short], commands[(typeof talkOption[n] === 'number') ? 'OPTION_INT' : 'OPTION_ANY'] ] for (n in talkOption) ], completer: function (context, args) { context.title = ['message']; /* 素敵な補完募集中! */ context.completions = [ [ '-speed=1 \u3086\u3063\u304F\u308A\u3057\u3066\u3044\u3063\u3066\u306D\uFF01', 'Relaxation' ], [ '\u306D\u304E\u3092\u3076\u3061\u3053\u3093\u3067\u3084\u308D\u3046\u304B\uFF01', 'Miku Hatune' ] ]; } }, true ); liberator.plugins.namakubi = { talk: talk }; })(); // vim:sw=2 ts=2 et si fdm=marker: #n137'>137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539
/**
 * I LOVE :echo
 * I LOVE :js
 *
 * 説明
 * :echo コマンドが大好きな人用
 * とにかく、ワンラインでタブ補完しつつコードを実行するためのネタ的プラグイン
 *
 * 完成度は低い
 *
 *  設計思想
 *   *  最初に与えた引数を変換に変換を重ねてコネくり回すことが主眼
 *   *  各メソッドやgetterは常にvalue(またはxhr)メンバを持つObject
 *   *  メソッドやgetterはvalue値に相応しいメソッドまたはgetterである
 *
 *
 * Example:
 *        1                                        2      3      4   5        6           7                              8
 *  :echo $x("http://d.hatena.ne.jp/teramako/rss").open().send().xml.toObject.get("item").map(function(item) item.title).value
 *  ブログのRSSをゲットしてオブジェクト化して、各item要素内のtitle文字列を格納した配列をechoする
 *
 *  1. $xにURLを渡し
 *  2. XMLHttpRequest.open()し
 *  3. リクエストを送信し
 *  4. レスポンスをDOMオブジェクトを得て(XMLHttpRequest.responseXML)
 *  5. さらにObject化し(toObjectはXMLのタグ名をキーにツリー構造を模したObject)
 *  6. オブジェクト内の"item"メンバ(配列)を得て
 *  7. map関数で各item内のtitleを得て
 *  8. その値 :echo に渡す(RSSのタイトル一覧の出力となる)
 *
 *  :js $_.url.MD5Hash.copy()
 *  現在開いているURLのMD5ハッシュ値をクリップボードにコピー
 *
 *  :js $x("http://example.com").open().send().xml.stack()
 *   とりあえず、http://exapmle.comのDOMドキュメントをstack
 *  :echo $_.cache.last.inspect()
 *   最後にstackしたものを取り出し、DOM Inspectorが入っている場合はDOM Inspectorに出力
 *
 *  :echo $('//a').evaluate().grep(/^http/).join("\n").copy()
 *  リンクを抽出してクリップボードにコピー
 *
 *  :echo $('//a').evaluate().map(function(v)v.href.replace(/.*\//,'')).copy()
 *  :echo $('//a').evaluate().map($f.href().replace(/.*\//,'')).copy()
 *  リンクのファイル名部分のみをクリップボードにコピー
 *
 */

(function(){
var cache = [];
var cacheXHR = null;

function $(arg){ //{{{
    if (!arg) return new $c();
    if (typeof arg == "string"){
        let s = new $s(arg);
        if (/^https?:\/\/./.test(arg)){
            s.open = function(){ var x = modules.$x(arg); return x.open(); };
        }
        return s;
    } else if (typeof arg == "xml"){
        return new $e4x(arg);
    } else if (arg instanceof Array){
        return new $a(arg);
    } else if (arg instanceof Element || arg instanceof Document){
        return new $xml(arg);
    } else if (typeof arg == "object"){
        return new $o(arg);
    }
} //}}}
modules.$f = (function(){ //{{{
    const pests = [
        '__defineGetter__', '__defineSetter__', 'hasOwnProperty', 'isPrototypeOf',
        '__lookupGetter__', '__lookupSetter__', '__parent__', 'propertyIsEnumerable',
        '__proto__', 'toSource', 'toString', 'toLocaleString', 'unwatch', 'valueOf', 'watch'
    ];

    function id(value)
        value;

    function memfn(parent)
        function(name,args)
            FFF(function(self)
                    let (s = parent(self))
                        let (f = s[name])
                            (f instanceof Function ? s[name].apply(s, args) : f));

    function mem(parent)
        function(name)
            FFF(function(self)
                    parent(self)[name]);

    function FFF(parent){
        parent.__noSuchMethod__ = memfn(parent);
        parent.m = {__noSuchMethod__: mem(parent)};
        pests.forEach(function(it) (parent[it] = function() parent.__noSuchMethod__(it, arguments)));
        return parent;
    }

    return FFF(id);
})(); //}}}


modules.$ = $;
modules.$x = function $x(url, method, user, password){ //{{{
    if (!cacheXHR){
        cacheXHR = new $xhr(url, method, user, password);
    } else if (cacheXHR.success && cacheXHR.url == url){
        return cacheXHR;
    } else {
        cacheXHR = new $xhr(url      || cacheXHR.url,
                            method   || cacheXHR.method,
                            user     || cacheXHR.user,
                            password || cacheXHR.password);
    }
    return cacheXHR;
}; //}}}
modules.$_ = { //{{{
    cache: {
        get: function(num) $(cache[num]),
        get length() cache.length,
        get first() this.length > 0 ? this.get(0)             : null,
        get last()  this.length > 0 ? this.get(this.length-1) : null,
        get all() $(cache),
        shift: function() $(cache.shift()),
        pop: function() $(cache.pop()),
        get xhr() cacheXHR,
        clear: function(){
            cache = [];
            cacheXHR = null;
        }
    },
    env: {
        maxCacheLength: 20,
        autoCache: false,
        xhr: { user: null, password: null }
    },
    get clipboard() $(util.readFromClipboard()),
    get url() $(buffer.URL),
    get sel() $(content.window.getSelection().toString()),
    get lastInputValue(){
        if (buffer.lastInputField){
            return $(buffer.lastInputField.value);
        }
        return null;
    }
}; // }}}
const DOMINSPECTOR = Application.extensions.has("inspector@mozilla.org") && Application.extensions.get("inspector@mozilla.org").enabled;

// -----------------------------------------------------------------------------
// Core
// --------------------------------------------------------------------------{{{
function $c(arg){ this.value = arg || null; }
$c.prototype = {
    echo: function(flag){
        liberator.echo(this.value, flag);
        return this;
    },
    log: function(level){
        liberator.log(this.value, level || 0);
        return this;
    },
    copy: function(){
        util.copyToClipboard(this.value);
        return this;
    },
    stack: function(){
        cache.push(this.value);
        return this;
    },
    toString: function(){
        return this.value.toString();
    },
    __noSuchMethod__: function(name, args){
        return $(this.value[name].apply(this.value, args));
    }
};
// }}}

// -----------------------------------------------------------------------------
// String
// --------------------------------------------------------------------------{{{
function $s(arg){ this.value = arg || null; }
$s.prototype = new $c();
createPrototype($s, {
    get htmlEscape() $(this.value.replace("&","&amp;","g").replace("<","&lt;","g").replace(">","&gt;","g")),
    get utf16() $(["\\u"+("0000"+this.value.charCodeAt(i).toString(16).toUpperCase()).slice(-4) for (i in this.value)].join("")),
    get numCharRef() $(["&#" + this.value.charCodeAt(i) + ";" for (i in this.value)].join("")),
    get base64() $(window.btoa(this.value)),
    get encodeURICompoenent() $(encodeURIComponent(this.value)),
    get MD5Hash(){
        var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
        converter.charset = "UTF-8";
        var result = {};
        var data = converter.convertToByteArray(this.value, result);
        var ch = Cc["@mozilla.org/security/hash;1"].createInstance(Ci.nsICryptoHash);
        ch.init(ch.MD5);
        ch.update(data, data.length);
        var hash = ch.finish(false);
        function toHexString(charCode){
            return ("0" + charCode.toString(16)).slice(-2);
        }
        var s = [i < hash.length ? toHexString(hash.charCodeAt(i)) : "" for (i in hash)].join("");
        return $(s);
    },
    s: function(from, to) $(this.value.replace(from, to)),
    split: function(reg) $(this.value.split(reg)),
    get toJSON(){
        var json;
        try {
            json = Cc["@mozilla.org/dom/json;1"].getService(Ci.nsIJSON);
            return $(json.decode(this.value));
        } catch (e){
            return null;
        }
    },
    evaluate: function(doc, context){
        if (!doc) doc = content.document;
        if (!context) context = doc;
        var result = [];
        var nodes = doc.evaluate(this.value, context, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
        var node;
        while (node = nodes.iterateNext()){
            result.push(node);
        }
        return $(result);
    }
});
// }}}

// -----------------------------------------------------------------------------
// Array
// --------------------------------------------------------------------------{{{
function $a(arg){ this.value = arg; }
$a.prototype = new $c();
createPrototype($a, {
    get length() this.value.length,
    item:    function(index) 0 <= index && index < this.length ? $(this.value[index]) : null,
    join:    function(str) $(this.value.join(str)),
    grep:    function(reg) $(this.value.filter(function(v) reg.test(v.toString()))),
    forEach: function(func, thisp) $(this.value.forEach(func, thisp)),
    map:     function(func, thisp) $(this.value.map(func, thisp)),
    some:    function(func, thisp) $(this.value.some(func, thisp)),
    filter:  function(func, thisp) $(this.value.filter(func, thisp)),

    push:    function(arg){
        this.value.push(arg);
        return this;
    },
    unshift: function(arg){
        this.value.unshift(arg);
        return this;
    },
    get first() $(this.value[0]),
    get last() $(this.value[this.length - 1])
});
// }}}

// -----------------------------------------------------------------------------
// Object
// --------------------------------------------------------------------------{{{
function $o(arg){ this.value = arg; }
$o.prototype = new $c();
createPrototype($o, {
    get toArrayName()  $([i             for (i in this.value)]),
    get toArrayValue() $([this.value[i] for (i in this.value)]),
    get: function(prop){
        if (prop in this.value) return $(this.value[prop]);
    },
    getItemsByKeyName: function(itemName){
        var a = [];
        function walk(obj){
            for (let item in obj){
                if (itemName == item) a.push(obj[itemName]);
                if (typeof obj[item] == "object") walk(obj[item]);;
            }
        }
        walk(this.value);
        return $(a);
    },
    map: function(func, thisp){
        if (typeof func != "function") throw new TypeError();
        var obj = {};
        var thisp = arguments[1];
        for (let i in this.value){
            obj[i] = func.call(thisp, this.value[i], i, this);
        }
        return $(obj);
    },
    forEach: function(func, thisp){
        if (typeof func != "function") throw new TypeError();
        var thisp = arguments[1];
        for (let i in this.value){
            func.call(thisp, this.value[i], i, this);
        }
        return this;
    },
    filter: function(func, thisp){
        if (typeof func != "function") throw new TypeError();
        var obj = {};
        var thisp = arguments[1];
        for (let i in this.value){
            if (func.call(thisp, this.value[i], i, this)){
                obj[i] = this.value[i];
            }
        }
        return $(obj);
    },
    get toJSON(){
        var json = Cc["@mozilla.org/dom/json;1"].getService(Ci.nsIJSON);
        return $(json.encode(this.value));
    }
});
if (DOMINSPECTOR){ createPrototype($o, { inspect: function(){ inspectObject(this.value); return ""; } }); }
// }}}

// -----------------------------------------------------------------------------
// XML
// --------------------------------------------------------------------------{{{
function $xml(arg){ this.value = arg; }
$xml.prototype = new $c();
createPrototype($xml, {
    get toObject(){ // {{{2
        function parseElement(node){ //{{{3
            var res = {};
            var isTextOnly = true;
            if (node.attributes && node.attributes.length > 0){
                isTextOnly = false;
                let attrs = node.attributes;
                for (let i=0; i<attrs.length; i++){
                    res["@"+attrs[i].nodeName] = attrs[i].nodeValue;
                }
            }
            if (isTextOnly){
                for (let i=0; i<node.childNodes.length; i++){
                    let type = node.childNodes[i].nodeType;
                    if (type != 3 && type != 4){
                        isTextOnly = false;
                    }
                }
            }
            if (isTextOnly){
                res = "";
                for (let i=0; i<node.childNodes.length; i++){
                    res += node.childNodes[i].nodeValue;
                }
            } else {
                for (let i=0; i<node.childNodes.length; i++){
                    let child = node.childNodes[i];
                    let name = child.nodeName;
                    let value = parse(child);
                    if (!value) continue;
                    if (!res[name]){
                        res[name] = value;
                    } else {
                        if (!(res[name] instanceof Array)){
                            res[name] = [res[name]];
                        }
                        res[name].push(value);
                    }
                }
            }
            return res;
        } //3}}}
        function parse(node){ //{{{3
            switch(node.nodeType){
                case node.ELEMENT_NODE:
                    return parseElement(node);
                case node.TEXT_NODE:
                case node.CDATA_SECTION_NODE:
                    return /[^\x00-\x20]/.test(node.nodeValue) ? node.nodeValue : null;
            }
            return null;
        } //3}}}
        var elm;
        if (this.value instanceof Document){
            elm = this.value.documentElement;
        } else {
            elm = this.value;
        }
        var o = parse(elm);
        return $(o);
    }, // 2}}}
    evaluate: function(expression){ // {{{2
        function nsResolver(prefix){ // {{{3
            var ns = {
                xhtml:   "http://www.w3.org/1999/xhtml",
                rdf:     "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
                dc:      "http://purl.org/dc/elements/1.1/",
                content: "http://purl.org/rss/1.0/modules/content/",
                taxo:    "http://purl.org/rss/1.0/modules/taxonomy/",
                rss:     "http://purl.org/rss/1.0/",
                atom:    "http://purl.org/atom/ns#"
            };
            return ns[prefix] || null;
        } // 3}}}
        var xpe = new XPathEvaluator();
        var result, found = [], res;
        try {
            result = xpe.evaluate(expression, this.value, nsResolver, 0, null);
            while (res = result.iterateNext()) found.push(res);
            return $(found);
        } catch (e){ }
    }, // 2}}}
});
if (DOMINSPECTOR){
    createPrototype($xml, {
        inspect: function(){
            if (this.value instanceof Document)
                inspectDOMDocument(this.value);
            else
                inspectDOMNode(this.value);
        }
    });
}
// }}}

// -----------------------------------------------------------------------------
// XMLHttpRequest
// --------------------------------------------------------------------------{{{
function $xhr(url, method, user, password, xhr){
    this.url = url || null;
    this.method = method || "GET";
    this.user = user || null;
    this.password = password || null;
    this.xhr = xhr || new XMLHttpRequest();
    this.success = null;
}
$xhr.prototype = {
    open: function(url, user, password){
        if (this.xhr.readyState != 0) return this;
        if (url) this.url = url;
        if (user) this.user = user;
        if (password) this.password = password;
        this.xhr.open(this.method, this.url, false, this.user, this.password);
        return this;
    },
    setMIME: function(type, charset){
        this.xhr.overrideMimeType((type || "text/html") +
                                  (charset ? ("; charset=" + charset) : ""));
        return this;
    },
    send: function(){
        if (this.xhr.readyState < 3) this.xhr.send(null);
        if (this.xhr.status == 200){
            this.success = true;
            return new $xhrResult(this.xhr);
        } else {
            this.success = false;
            return this;
        }
    }
};
// }}}

// -----------------------------------------------------------------------------
// XMLHttpRequest Result
// --------------------------------------------------------------------------{{{
function $xhrResult(xhr){
    this.value = xhr;
}
$xhrResult.prototype = new $c();
createPrototype($xhrResult, {
    get allHeaders(){
        return $(this.value.getAllResponseHeaders());
    },
    getHeader: function(header){
        return $(this.value.getResponseHeader(header));
    },
    get text(){
        return $(this.value.responseText);
    },
    get xml(){
        if (this.value.responseXML){
            return $(this.value.responseXML);
        } else if (this.value.getResponseHeader("Content-Type").indexOf("text/html") == 0){
            let str = this.value.responseText.
                                 replace(/^[\s\S]*?<html(?:[ \t\r\n][^>]*)?>|<\/html[ \t\n\t]*>[\S\s]*$/ig, "").
                                 replace(/[\r\n]+/g, " ");
            let htmlFragment = document.implementation.createDocument(null, "html", null);
            //let range = window.content.document.createRange();
            let range = document.getElementById("liberator-multiline-output").contentDocument.createRange();
            range.setStartAfter(window.content.document.body);
            htmlFragment.documentElement.appendChild(htmlFragment.importNode(range.createContextualFragment(str), true));
            return $(htmlFragment);
        } else {
            return this.text;
        }
    }
});
// }}}

// -----------------------------------------------------------------------------
// E4X
// --------------------------------------------------------------------------{{{
function $e4x(arg){ this.value = arg; }
$e4x.prototype = new $c();
createPrototype($e4x, {
    get: function(str) $(window.eval("this.value." + str)),
    item: function(num) $(this.value[num]),
    get length() this.value.length(),
    toXMLString: function() $(this.value.toXMLString()),
    toArray: function(){
        var a = [];
        for (let i=0; i<this.length; i++){
            a.push(this.xml[i]);
        }
        return $(a);
    },
    toDocument: function(rootName){
        var parser = new DOMParser;
        rootName = rootName || "root";
        var str = this.length > 1 ? "<" + rootName +">" + this.value.toXMLString() + "</" + rootName + ">" : this.value.toXMLString();
        var doc = parser.parseFromString(str, "text/xml");
        if (doc.firstChild.tagName == "parsererror"){
            return;
        }
        return $(doc);
    },
    get toHTMLDOM() $(util.xmlToDom(this.value, document))
});
// }}}

function createPrototype(class, obj){
    var flag;
    for (let i in obj){
        flag = false;
        if (obj.__lookupGetter__(i)){
            class.prototype.__defineGetter__(i, obj.__lookupGetter__(i));
            flag = true;
        }
        if (obj.__lookupSetter__(i)){
            class..prototype.__defineSetter__(i, obj.__lookupSetter__(i));
            flag = true;
        }
        if (!flag) class.prototype[i] = obj[i];
    }
}
})();
// vim:sw=4 ts=4 et si fdm=marker: