I was looking for a possibility to write text from a panorama to a file on the user's computer and found
Downloadify, which can do this via JavaScript. So I have this code to add to the panorama.html:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<head>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/downloadify.min.js"></script>
</head>
<body onload="load();">
<form>
<p>
<label for="filename">Filename</label><br />
<input type="text" name="filename" value="testfile.txt" id="filename" />
</p>
<p>
<label for="data">File Contents</label><br />
<textarea cols="60" rows="10" name="data" id="data">
Whatever you put in this text box will be downloaded and saved in the file. If you leave it blank, no file will be downloaded</textarea>
</p>
<p id="downloadify">
You must have Flash 10 installed to download this file.
</p>
</form>
<script type="text/javascript">
function load(){
Downloadify.create('downloadify',{
filename: function(){
return document.getElementById('filename').value;
},
data: function(){
return document.getElementById('data').value;
},
onComplete: function(){ alert('Your File Has Been Saved!'); },
onCancel: function(){ alert('You have cancelled the saving of this file.'); },
onError: function(){ alert('You must put something in the File Contents or there will be nothing to save!'); },
swf: 'media/downloadify.swf',
downloadImage: 'images/download.png',
width: 100,
height: 30,
transparent: true,
append: false
});
}
</script>
</body>
|
And this for the panorama.xml:
|
Source code
|
1
|
<plugin name="save" url="save.png" onclick="js( load(get(variable1), get(variable2)) );" />
|
As I don't need the <form> I deleted it, but now (I guess) I have to rewrite these lines in the <body>:
|
Source code
|
1
2
|
return document.getElementById('filename').value;
return document.getElementById('data').value;
|
...but I don't know how. Can you help me? I'm sure it's very simple, but I couldn't manage to get it work.