2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
21 <title>Metadata Demo
</title>
24 border: solid
1px #
000;
31 border-bottom: solid
1px #
000;
43 <script src=
"../../js/core.js?c=1"></script>
47 if (window
.XMLHttpRequest
) {
48 return new XMLHttpRequest();
49 } else if (window
.ActiveXObject
) {
50 var x
= new ActiveXObject("Msxml2.XMLHTTP");
52 x
= new ActiveXObject("Microsoft.XMLHTTP");
58 function renderGadgets(obj
) {
59 var gadgetList
= obj
.gadgets
;
61 for (var i
= 0, gadget
; gadget
= gadgetList
[i
]; ++i
) {
62 var feats
= gadget
.features
|| [];
63 for (var j
= 0, feature
; feature
= feats
[j
]; ++j
) {
64 features
[feature
] = true;
68 for (var lib
in features
) {libs
.push(lib
);}
70 libs
= libs
.join(":");
71 for (var i
= 0, gadget
; gadget
= gadgetList
[i
]; ++i
) {
72 var newGadget
= document
.createElement("div");
73 if (gadget
.errors
&& gadget
.errors
.length
> 0) {
74 newGadget
.innerHTML
= ["Unable to process gadget: ", gadget
.url
, ". Errors: <pre>", gadget
.errors
.join("\n"), "</pre>"].join("");
76 newGadget
.innerHTML
= ['<h2>', gadget
.title
, '</h2>',
77 '<iframe src="', gadget
.iframeUrl
, '&libs=', libs
,'" id="remote_iframe_', gadget
.moduleId
, '" name="remote_iframe_', gadget
.moduleId
, '"></iframe>'
80 newGadget
.className
= "gadget";
81 document
.body
.appendChild(newGadget
);
85 function processResp(xhr
) {
86 if (xhr
.readyState
!== 4) {return;}
87 renderGadgets(gadgets
.json
.parse(xhr
.responseText
));
99 url
: "http://www.google.com/ig/modules/hello.xml",
103 url
: "http://www.labpixies.com/campaigns/todo/todo.xml",
107 url
: "http://www.example.org/fake/fake/fake.xml",
114 xhr
.open("POST", "../../metadata", true);
115 xhr
.onreadystatechange = function(xobj
) {
120 var req
= gadgets
.json
.stringify(request
);