As I write and load notes from tours I developed as small xml-fileload plugin (xmlfileinput.js):
Code
var krpanoplugin = function()
{
var local = this;
var krpano = null;
var plugin = null;
var inputelement = null;
local.registerplugin = function(krpanointerface, pluginpath, pluginobject)
{
krpano = krpanointerface;
plugin = pluginobject;
inputelement = document.createElement("input");
inputelement.id = "filedialog";
inputelement.type = "file";
inputelement.accept = "text/xml";
inputelement.style.width = "100%";
inputelement.style.height = "100%";
inputelement.style.visibility = "hidden";
inputelement.filename = "";
inputelement.text = "";
labelelement = document.createElement("label");
labelelement.setAttribute("for","filedialog");
labelelement.innerHTML = "Select xml-notesfile";
labelelement.style.color = "black";
labelelement.style.backgroundColor = "white";
labelelement.style.padding = "16px";
labelelement.style.borderRadius = "5px";
labelelement.style.borderStyle = "outset";
plugin.registerattribute("filename", "", filename_set, filename_get);
plugin.registerattribute("text", "", text_set, text_get);
plugin.registerattribute("onchanged", null); // to be defined by user
function readText(evt) {
var reader;
var fileInput = evt.target;
if(fileInput.files[0].type.match('text/xml')) {
reader = new FileReader();
reader.onload = function (e) {
fileInput.filename = fileInput.value;
fileInput.text = e.target.result;
krpano.call(plugin.onchanged, plugin);
};
reader.readAsText(fileInput.files[0]);
}
}
inputelement.addEventListener("change", readText, false);
plugin.sprite.appendChild(labelelement);
plugin.sprite.appendChild(inputelement);
}
local.unloadplugin = function()
{
plugin = null;
krpano = null;
}
function filename_set(newtext)
{
inputelement.filename = newtext;
}
function filename_get()
{
return inputelement.filename;
}
function text_set(newtext)
{
inputelement.text = newtext;
}
function text_get()
{
return inputelement.text;
}
};
Alles anzeigen
Usage Example:
Code
<plugin name="xmlload" devices="html5"
url="%SWFPATH%/plugins/xmlfileinput.js"
align="center" x="0" y="0" width="400" height="32"
visible="false"
keep="true"
/>
<action name="load_notes">
set(curOnchanged, "getxmltext();");
copy(plugin[xmlload].onchanged, curOnchanged);
set(plugin[xmlload].visible, true);
tween(plugin[xmlload].alpha,0,7,easeInExpo,set(plugin[xmlload].visible,false);set(plugin[xmlload].alpha,1););
</action>
<action name="getxmltext">
copy(curNotestext, plugin[xmlload].text);
...
</action>
Alles anzeigen
Be careful as it is an asynchronous process therefore only when the onchanged routine was called as event (in the example "getxmltext") the resulting text input is ready.