3 <script type="text/javascript"
4 src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
7 if (typeof(window.eth) === "undefined") {
8 document.write('Please run in AlethZero.<br/>');
11 <script type="text/javascript" src="BigInteger.js"></script>
12 <script type="text/javascript" src="ethString.js"></script>
25 <title>Custom Artwork</title>
28 <canvas id="artwork"></canvas>
29 <a id="create" href="javascript:void(0)" onclick="purchase();">purchase</a>
33 var stripe_height = 100;
35 var fetch = function() {
36 var source = eth.storageAt(contract, eth.secretToAddress(eth.key)).bin()
38 var artwork = document.getElementById('artwork')
39 artwork.height = stripe_height;
40 var ctx = artwork.getContext('2d');
41 for(var i = 0; i < 10; i++) {
42 // Get each 2 bytes, multiply by 16 to get 000..FFF
43 ctx.fillStyle = source.substring(i * 2, i * 2 + 1) * 16;
44 ctx.fillRect(x, 0, 1, stripe_height);
49 var purchase = function() {
50 var price = eth.storageAt(contract, 1001).bin();
51 if (confirm("This will take a payment of " + price +
52 " and costs gas to run.")) {
53 var result = eth.transact(eth.key, "0", contract, padStr("toggle"), "10000", eth.gasPrice);
55 foreach(var element in result) {
56 artwork += element.unbin();
58 document.getElementById("artwork").innerText = artwork;
59 $("#purchase").hide();
62 eth.watch(contract, eth.secretToAddress(eth.key), fetch);