Implement local file upload with form.
This fixes the issue that after selecting a file it cannot be uploaded directly again without selecting another file in between.
This commit is contained in:
parent
ddfe2e5af3
commit
4c2624785f
4 changed files with 15 additions and 6 deletions
|
|
@ -21,5 +21,5 @@
|
|||
<item ref="/sites/www.osiweb.org/programs/basic/OsiBas/spacewar.bas">SPACEWAR</item>
|
||||
</control>
|
||||
<control type="button" class="input" binding="loadSerial">Load File</control>
|
||||
<control type="file" class="input" label="Load Local File:" binding="uploadSerial"/>
|
||||
<control type="file" class="input" binding="uploadSerial"/>
|
||||
</serial>
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@
|
|||
<item ref="/apps/c1p/BASIC/OSI/SAMPLE6.BAS">PRESIDENTS</item>
|
||||
</control>
|
||||
<control type="button" class="input" binding="loadSerial">Load File</control>
|
||||
<control type="file" class="input" label="Load Local File:" binding="uploadSerial"/>
|
||||
<control type="file" class="input" binding="uploadSerial"/>
|
||||
</serial>
|
||||
|
|
|
|||
|
|
@ -127,15 +127,19 @@ C1PSerialPort.prototype.setBinding = function(c, t, s, e)
|
|||
case "uploadSerial":
|
||||
this.bindings[s] = e;
|
||||
var serial = this;
|
||||
e.addEventListener('change', function () {
|
||||
var file = e.files[0];
|
||||
e.onsubmit = function (event) {
|
||||
var file = event.currentTarget[1].files[0];
|
||||
|
||||
var reader = new FileReader();
|
||||
reader.onload = function () {
|
||||
// serial.println("uploading " + file.name + "...");
|
||||
serial.loadFile(file.name, reader.result, 0);
|
||||
};
|
||||
reader.readAsText(file);
|
||||
});
|
||||
|
||||
// Prevent reloading of web page after form submission
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -286,7 +286,12 @@
|
|||
<div><xsl:value-of select="."/></div>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'file'">
|
||||
<input class="{$APPCLASS}-{@class}" type="file" data-value="{$type},{$binding}"/>
|
||||
<form class="{$APPCLASS}-{@class}" data-value="{$type},{$binding}">
|
||||
<fieldset>
|
||||
<input type="file"/>
|
||||
<input type="submit" value="Load Local File" />
|
||||
</fieldset>
|
||||
</form>
|
||||
</xsl:when>
|
||||
<xsl:when test="@type = 'separator'">
|
||||
<hr/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue