X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=examples%2Fbiojson-doc%2Fwidget.js;fp=examples%2Fbiojson-doc%2Fwidget.js;h=4c5c0a8d051af40a9bed20e7d8e1873dda9cf437;hb=1ba05544b34253204ef6410017a179c31fe5e23d;hp=0000000000000000000000000000000000000000;hpb=f8ce78dc02ce9d96129fcc4882749f43869928ff;p=jalview.git diff --git a/examples/biojson-doc/widget.js b/examples/biojson-doc/widget.js new file mode 100755 index 0000000..4c5c0a8 --- /dev/null +++ b/examples/biojson-doc/widget.js @@ -0,0 +1,48 @@ +/* + * Copyright 2013 Laurent Bovet + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +var scripts = document.getElementsByTagName('script'); +var script = scripts[ scripts.length - 1 ]; + +if (script.attributes["data-schema"]) { + var docson; + if (script.attributes["data-docson"]) { + docson = script.attributes["data-docson"].value; + } else { + docson = script.src.replace("widget.js", "index.html"); + } + document.write(""); + function receiveMessage(event) { + console.log("<", event) + if (event.data.id && event.data.id == "docson") { + var frame = document.getElementById(event.data.url); + if(event.data.action == "resized") { + frame.height = event.data.height + 18; + } + if(event.data.action == "ready") { + console.log(frame.parentNode) + frame.contentWindow.postMessage({ id: "docson", font: window.getComputedStyle(frame.parentNode).fontFamily}, "*"); + } + } + + } + window.addEventListener("message", receiveMessage, false); +} else { + alert("

Missing data-schema (url to schema)

") +}