Add file upload button to C1Pjs
This commit is contained in:
parent
905a30017e
commit
14944bb108
4 changed files with 18 additions and 0 deletions
|
|
@ -21,4 +21,5 @@
|
||||||
<item ref="/sites/www.osiweb.org/programs/basic/OsiBas/spacewar.bas">SPACEWAR</item>
|
<item ref="/sites/www.osiweb.org/programs/basic/OsiBas/spacewar.bas">SPACEWAR</item>
|
||||||
</control>
|
</control>
|
||||||
<control type="button" class="input" binding="loadSerial">Load File</control>
|
<control type="button" class="input" binding="loadSerial">Load File</control>
|
||||||
|
<control type="file" class="input" label="Upload File:" binding="uploadSerial"/>
|
||||||
</serial>
|
</serial>
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,5 @@
|
||||||
<item ref="/apps/c1p/BASIC/OSI/SAMPLE6.BAS">PRESIDENTS</item>
|
<item ref="/apps/c1p/BASIC/OSI/SAMPLE6.BAS">PRESIDENTS</item>
|
||||||
</control>
|
</control>
|
||||||
<control type="button" class="input" binding="loadSerial">Load File</control>
|
<control type="button" class="input" binding="loadSerial">Load File</control>
|
||||||
|
<control type="file" class="input" label="Upload File:" binding="uploadSerial"/>
|
||||||
</serial>
|
</serial>
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,19 @@ C1PSerialPort.prototype.setBinding = function(c, t, s, e)
|
||||||
};
|
};
|
||||||
}(this);
|
}(this);
|
||||||
return true;
|
return true;
|
||||||
|
case "uploadSerial":
|
||||||
|
this.bindings[s] = e;
|
||||||
|
var serial = this;
|
||||||
|
e.addEventListener('change', function () {
|
||||||
|
var file = e.files[0];
|
||||||
|
var reader = new FileReader();
|
||||||
|
reader.onload = function () {
|
||||||
|
// serial.println("uploading " + file.name + "...");
|
||||||
|
serial.loadFile(file.name, reader.result, 0);
|
||||||
|
};
|
||||||
|
reader.readAsText(file);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -285,6 +285,9 @@
|
||||||
<xsl:when test="@type = 'heading'">
|
<xsl:when test="@type = 'heading'">
|
||||||
<div><xsl:value-of select="."/></div>
|
<div><xsl:value-of select="."/></div>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
|
<xsl:when test="@type = 'file'">
|
||||||
|
<input class="{$APPCLASS}-{@class}" type="file" data-value="{$type},{$binding}"/>
|
||||||
|
</xsl:when>
|
||||||
<xsl:when test="@type = 'separator'">
|
<xsl:when test="@type = 'separator'">
|
||||||
<hr/>
|
<hr/>
|
||||||
</xsl:when>
|
</xsl:when>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue