/[suikacvs]/markup/hlink/implementation/hlink-script.js
Suika

Contents of /markup/hlink/implementation/hlink-script.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download) (as text)
Sun Jul 6 23:49:32 2003 UTC (21 years, 5 months ago) by w
Branch: MAIN
CVS Tags: HEAD
File MIME type: application/javascript
2003-03-01 06:49 version

1 w 1.1 const XHTML1NS = 'http://www.w3.org/1999/xhtml';
2     const HLinkNS = 'http://www.w3.org/2002/06/hlink';
3     const XLinkNS = 'http://www.w3.org/1999/xlink';
4     const tempNS = 'urn:x-suika-fam-cx:markup:temporary';
5    
6     function linkizeHTML (doc) {
7     var eLinks = doc.getElementsByTagNameNS (XHTML1NS, 'link');
8     for (var i = 0; i < eLinks.length; i++) {
9     if (eLinks[i].getAttribute ('type').toLowerCase () == 'application/x-hlink+xml'
10     && eLinks[i].getAttribute ('rel') == 'stylesheet' //.match (/stylesheet/i)
11     ) {
12     linkizeByHTMLLinkElement (eLinks[i]);
13     }
14     }
15     }
16    
17     function linkizeByHTMLLinkElement (eLink) {
18     var oHLink = eLink.ownerDocument.createElementNS (XHTML1NS, 'object');
19     oHLink.setAttributeNS (tempNS, 'HLinkStatus', 100);
20     oHLink.setAttribute ('data', eLink.getAttribute ('href'));
21     //oHLink.setAttribute ('type', 'application/xml');
22     oHLink.style.display = 'block';
23     oHLink.style.width = 0;
24     oHLink.style.height = 0;
25     oHLink.addEventListener ('load', function () {
26     var hlink = oHLink.contentDocument.getElementsByTagNameNS (HLinkNS, 'hlink');
27     for (var k = 0; k < hlink.length; k++) {
28     linkizeElement (hlink[k]);
29     }
30     }, false);
31     eLink.ownerDocument.documentElement.appendChild (oHLink);
32     }
33    
34     function linkizeElement (e) {
35     var elementNS = e.getAttribute ('namespace');
36     var elementType = e.getAttribute ('element');
37     var linkAttr = [];
38     var linkAttrList = new Array ('locator', 'effect', 'actuate', 'mediaType');
39     for (var i = 0; i < linkAttrList.length; i++) {
40     linkAttr[linkAttrList[i]] = [];
41     linkAttr[linkAttrList[i]].value = e.getAttribute (linkAttrList[i]);
42     if (linkAttr[linkAttrList[i]].value
43     && linkAttr[linkAttrList[i]].value.substr (0,1) == '@') {
44     linkAttr[linkAttrList[i]].attrName = linkAttr[linkAttrList[i]].value.substr (1);
45     linkAttr[linkAttrList[i]].value = undefined;
46     }
47     }
48     var linkElements = document.getElementsByTagNameNS (elementNS, elementType);
49     for (var i = 0; i < linkElements.length; i++) {
50     var elFlag = 1*linkElements[i].getAttributeNS (tempNS, 'HLinkStatus');
51     if (elFlag < 20) {
52     var myLinkAttr = [];
53     for (var j = 0; j < linkAttrList.length; j++) {
54     myLinkAttr[linkAttrList[j]] = linkAttr[linkAttrList[j]].value;
55     if (linkAttr[linkAttrList[j]].attrName
56     && linkElements[i].hasAttribute
57     (linkAttr[linkAttrList[j]].attrName)) {
58     myLinkAttr[linkAttrList[j]] = linkElements[i].getAttribute
59     (linkAttr[linkAttrList[j]].attrName);
60     }
61     }
62     if (myLinkAttr.locator != undefined) {
63     if (myLinkAttr.effect == 'embed' && myLinkAttr.actuate == 'onLoad'
64     && myLinkAttr.locator != '' && myLinkAttr.locator.substr (0,1) != '#') {
65     var oEl = linkElements[i].ownerDocument.createElementNS (XHTML1NS, 'object');
66     linkElements[i].setAttributeNS (tempNS, 'HLinkStatus', elFlag+1);
67     oEl.setAttributeNS (tempNS, 'HLinkStatus', 100);
68     oEl.setAttribute ('data', myLinkAttr.locator);
69     oEl.setAttribute ('type', myLinkAttr.mediaType);
70     while (linkElements[i].childNodes.length) {
71     oEl.appendChild (linkElements[i].firstChild);
72     //linkElements[i].removeChild (linkElements[i].firstChild);
73     }
74     linkElements[i].appendChild(oEl);
75     } else {
76     linkElements[i].setAttributeNS (tempNS, 'HLinkStatus', elFlag+1);
77     linkElements[i].setAttributeNS (XLinkNS, 'type', 'simple');
78     if (myLinkAttr.effect == 'submit' || myLinkAttr.effect == 'map')
79     myLinkAttr.effect = 'other';
80     linkElements[i].setAttributeNS (XLinkNS, 'show', myLinkAttr.effect);
81     if (myLinkAttr.actuate == 'onRequestSecondary')
82     myLinkAttr.actuate = 'other';
83     linkElements[i].setAttributeNS (XLinkNS, 'actuate', myLinkAttr.actuate);
84     if (!myLinkAttr.locator) myLinkAttr.locator = '#';
85     linkElements[i].setAttributeNS (XLinkNS, 'href', myLinkAttr.locator);
86     }
87     }
88     }
89     }
90     }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24