| 1 |
document.jsXPointerEvaluator = new XPointerEvaluator ();
|
| 2 |
document.jsXPointerEvaluator.setXPointerSchemeProcessor
|
| 3 |
('http://suika.fam.cx/~wakaba/archive/2005/3/style/',
|
| 4 |
'style',
|
| 5 |
new XPointerSchemeProcessor (function (aDocument, aContext, aData) {
|
| 6 |
var styles = aDocument.styleSheets;
|
| 7 |
var enabled = [];
|
| 8 |
for (var i = 0; styles.length > i; i++) {
|
| 9 |
var style = styles[i];
|
| 10 |
if (style.title != null) {
|
| 11 |
if (style.title == aData) {
|
| 12 |
style.disabled = false;
|
| 13 |
} else {
|
| 14 |
style.disabled = true;
|
| 15 |
enabled.push (style);
|
| 16 |
}
|
| 17 |
}
|
| 18 |
}
|
| 19 |
return XPointerResult.createEmptyXPointerResult ();
|
| 20 |
}));
|
| 21 |
document.jsXPointerEvaluator.setXPointerSchemeProcessor
|
| 22 |
('http://suika.fam.cx/~wakaba/archive/2005/3/window/',
|
| 23 |
'title',
|
| 24 |
new XPointerSchemeProcessor (function (aDocument, aContext, aData) {
|
| 25 |
aDocument.title = aData;
|
| 26 |
return XPointerResult.createEmptyXPointerResult ();
|
| 27 |
}));
|
| 28 |
document.jsXPointerEvaluator.setXPointerSchemeProcessor
|
| 29 |
('http://suika.fam.cx/~wakaba/archive/2005/3/xpointer/',
|
| 30 |
'document',
|
| 31 |
new XPointerSchemeProcessor (function (aDocument, aContext, aData) {
|
| 32 |
return XPointerResult.createNodeXPointerResult (aDocument);
|
| 33 |
}));
|
| 34 |
|
| 35 |
function reevaluateFragment () {
|
| 36 |
var uri = location.href;
|
| 37 |
var fstart = uri.indexOf ('#');
|
| 38 |
if (fstart == -1) return;
|
| 39 |
var fragment = decodeURI (uri.substr (fstart + 1));
|
| 40 |
try {
|
| 41 |
document.jsXPointerEvaluator.evaluate (document, fragment);
|
| 42 |
} catch (e) {
|
| 43 |
window.status = e;
|
| 44 |
}
|
| 45 |
};
|
| 46 |
|
| 47 |
window.onload = function () {
|
| 48 |
var anchors = document.links;
|
| 49 |
for (var i = 0; anchors.length > i; i++) {
|
| 50 |
anchors[i].onclick = function (ev) {
|
| 51 |
location.href = this.href;
|
| 52 |
reevaluateFragment ();
|
| 53 |
return false;
|
| 54 |
};
|
| 55 |
}
|
| 56 |
|
| 57 |
reevaluateFragment ();
|
| 58 |
}
|
| 59 |
|
| 60 |
|
| 61 |
/* Revision: $Date: 2005/03/08 11:01:26 $ */
|
| 62 |
|
| 63 |
/* ***** BEGIN LICENSE BLOCK *****
|
| 64 |
* Copyright 2005 Wakaba <[email protected]>. All rights reserved.
|
| 65 |
*
|
| 66 |
* This program is free software; you can redistribute it and/or
|
| 67 |
* modify it under the same terms as Perl itself.
|
| 68 |
*
|
| 69 |
* Alternatively, the contents of this file may be used
|
| 70 |
* under the following terms (the "MPL/GPL/LGPL"),
|
| 71 |
* in which case the provisions of the MPL/GPL/LGPL are applicable instead
|
| 72 |
* of those above. If you wish to allow use of your version of this file only
|
| 73 |
* under the terms of the MPL/GPL/LGPL, and not to allow others to
|
| 74 |
* use your version of this file under the terms of the Perl, indicate your
|
| 75 |
* decision by deleting the provisions above and replace them with the notice
|
| 76 |
* and other provisions required by the MPL/GPL/LGPL. If you do not delete
|
| 77 |
* the provisions above, a recipient may use your version of this file under
|
| 78 |
* the terms of any one of the Perl or the MPL/GPL/LGPL.
|
| 79 |
*
|
| 80 |
* "MPL/GPL/LGPL":
|
| 81 |
*
|
| 82 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
| 83 |
*
|
| 84 |
* The contents of this file are subject to the Mozilla Public License Version
|
| 85 |
* 1.1 (the "License"); you may not use this file except in compliance with
|
| 86 |
* the License. You may obtain a copy of the License at
|
| 87 |
* <http://www.mozilla.org/MPL/>
|
| 88 |
*
|
| 89 |
* Software distributed under the License is distributed on an "AS IS" basis,
|
| 90 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
| 91 |
* for the specific language governing rights and limitations under the
|
| 92 |
* License.
|
| 93 |
*
|
| 94 |
* The Original Code is xpointer-js code.
|
| 95 |
*
|
| 96 |
* The Initial Developer of the Original Code is Wakaba.
|
| 97 |
* Portions created by the Initial Developer are Copyright (C) 2005
|
| 98 |
* the Initial Developer. All Rights Reserved.
|
| 99 |
*
|
| 100 |
* Contributor(s):
|
| 101 |
* Wakaba <[email protected]>
|
| 102 |
*
|
| 103 |
* Alternatively, the contents of this file may be used under the terms of
|
| 104 |
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
| 105 |
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
| 106 |
* in which case the provisions of the GPL or the LGPL are applicable instead
|
| 107 |
* of those above. If you wish to allow use of your version of this file only
|
| 108 |
* under the terms of either the GPL or the LGPL, and not to allow others to
|
| 109 |
* use your version of this file under the terms of the MPL, indicate your
|
| 110 |
* decision by deleting the provisions above and replace them with the notice
|
| 111 |
* and other provisions required by the LGPL or the GPL. If you do not delete
|
| 112 |
* the provisions above, a recipient may use your version of this file under
|
| 113 |
* the terms of any one of the MPL, the GPL or the LGPL.
|
| 114 |
*
|
| 115 |
* ***** END LICENSE BLOCK ***** */
|