forked from sugarlabs/musicblocks
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbitcoin.rtp
executable file
·72 lines (54 loc) · 8.41 KB
/
bitcoin.rtp
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//* comment *//
Copyright (C) 2015 Walter Bender
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
//* globals *//
var bitcoinMashapeKey = 'PCwj8N1ftxmsh4WCJmQoJqiNhRCbp1DTsnTjsnkmyDCNwB94sm';
//* block:bitcoinrate *//
var bitcoinRate = new ProtoBlock('bitcoinrate');
bitcoinRate.palette = palettes.dict['mashape'];
blocks.protoBlockDict['bitcoinrate'] = bitcoinRate;
bitcoinRate.staticLabels.push(_('bitcoin'), _('from'), _('value'));
bitcoinRate.adjustWidthToLabel();
bitcoinRate.twoArgMathBlock();
bitcoinRate.dockTypes[1] = 'anyin';
bitcoinRate.dockTypes[2] = 'numberin';
bitcoinRate.defaults.push('USD', 100);
//* arg:bitcoinrate *//
var block = logo.blocks.blockList[blk];
var conns = block.connections;
var from = logo.parseArg(logo, turtle, conns[1]);
var amount = logo.parseArg(logo, turtle, conns[2]);
var apiURL = 'https://community-bitcointy.p.mashape.com/convert/' + amount + '/' + from;
if (block.cacheFor === apiURL && block.cache !== undefined) {
var response = block.cache;
} else {
try {
var request = new XMLHttpRequest();
request.open('GET', apiURL, false);
request.setRequestHeader('X-Mashape-Authorization', bitcoinMashapeKey);
request.send(null);
var response = request.responseText;
block.cacheFor = apiURL;
block.cache = response;
} catch (e) {
logo.errorMsg('Could not connect to Currency API', blk);
}
}
console.log(response);
obj = JSON.parse(response);
block.value = obj['value'] / 100;
//* palette-icon:mashape *//
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns="http://www.w3.org/2000/svg" width="55" height="55"> <g transform="matrix(0.31397464,0,0,0.31397464,2.0028903,2.1546045)"> <path d="m 35.018867,92.07547 a 4.8301888,7.2452831 0 1 1 -9.660377,0 4.8301888,7.2452831 0 1 1 9.660377,0 z" transform="translate(104.15094,-1.8113191)" style="fill:none;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> <path d="m 35.018867,92.07547 a 4.8301888,7.2452831 0 1 1 -9.660377,0 4.8301888,7.2452831 0 1 1 9.660377,0 z" transform="translate(-2.1132075,-1.509434)" style="fill:none;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> <path d="M 71.25,9.0625 58.5625,20.84375 57.96875,16.3125 46.78125,25.34375 46.1875,22.65625 c 0,0 -14.136933,16.664759 -17.21875,26.84375 -3.178922,10.49972 -2.700852,22.140109 -0.59375,32.90625 0.588789,3.008393 3.739358,5.405415 3.625,8.46875 -0.105779,2.833549 -3.456549,4.736814 -3.9375,7.53125 -0.741046,4.30566 1.150227,9.82856 2.71875,13.90625 2.575193,6.69474 6.05599,11.89439 11.1875,16.90625 5.052121,4.93432 12.490836,9.32245 19.21875,11.46875 1.583469,0.50515 -0.516475,-5.75339 0.96875,-5.96875 1.485226,-0.21536 12.440702,5.01282 13.90625,4.46875 2.931095,-1.08813 0.113725,-1.85415 3.4375,-1.90625 1.63985,-0.0257 3.614341,0.76451 5.1875,2.5625 1.132489,1.29434 9.045031,-5.70569 14.71875,-4.9375 2.84452,2.46637 -0.846938,0.25984 -0.09375,5.15625 7.31233,-2.09545 14.50668,-5.57499 20.25,-10.5625 4.95497,-4.3029 8.97167,-9.93112 11.46875,-16 1.93885,-4.71215 2.88988,-10.02131 2.40625,-15.09375 -0.33538,-3.517542 -4.09338,-6.466437 -3.625,-9.96875 0.27756,-2.075474 3.5667,-3.03186 3.625,-5.125 0.22629,-8.125101 1.63147,-15.652124 0.59375,-23.84375 -0.8443,-6.664799 -2.80533,-14.195558 -6.34375,-19.90625 -5.28767,-8.533838 -21.125,-20.84375 -21.125,-20.84375 L 105.96875,21.75 95.6875,14.1875 95.09375,19.3125 84.53125,10.5625 82.125,17.21875 80,11.15625 72.4375,17.21875 71.25,9.0625 z M 97.40625,70 c 3.31389,0.01928 6.76796,0.911145 9.46875,2.75 3.57769,2.435896 6.03034,6.502856 7.53125,10.5625 1.19105,3.221552 1.85707,6.980805 0.90625,10.28125 -1.01401,3.519794 -5.15779,5.398156 -6.625,8.75 3.02698,4.43561 5.77874,6.73855 6.03125,10.875 0.2448,4.01014 -1.7957,8.21382 -4.53125,11.15625 -5.4237,5.83388 -13.621286,9.0271 -21.4375,10.5625 -5.642126,1.10833 -11.602007,0.17788 -17.1875,-1.1875 -5.647589,-1.38056 -11.564422,-3.21018 -16,-6.96875 -3.109059,-2.63452 -5.251218,-6.42471 -6.65625,-10.25 -0.804739,-2.19095 -1.506483,-4.68193 -0.90625,-6.9375 0.812583,-3.05354 2.658271,-5.0073 5.75,-7.5625 -2.63524,-2.638337 -4.732976,-5.463822 -6.0625,-8.75 -1.147839,-2.837108 -2.243158,-6.093589 -1.5,-9.0625 1.202286,-4.803124 4.850663,-9.178192 9.0625,-11.78125 3.139318,-1.940205 7.198007,-2.409085 10.875,-2.09375 5.362787,0.459906 10.315451,3.067371 15.09375,5.71875 C 85.034654,73.280608 90.687788,70.410507 96,70.03125 96.465581,69.998011 96.932837,69.997245 97.40625,70 z" style="fill:#ffffff;fill-opacity:1;stroke:none" /> <path d="m 70.037737,90.71698 a 4.0754719,4.981132 0 1 1 -8.150944,0 4.0754719,4.981132 0 1 1 8.150944,0 z" transform="translate(-0.90566038,-0.30188679)" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-opacity:1" /> <path d="m 70.037737,90.71698 a 4.0754719,4.981132 0 1 1 -8.150944,0 4.0754719,4.981132 0 1 1 8.150944,0 z" transform="matrix(-1,0,0,1,162.26415,0.15094455)" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-opacity:1" /> <path d="m 75.471698,139.77358 c -3.97085,-2.86522 -8.130251,-4.61904 -12.981132,-5.13207 -0.978245,0.74817 -1.670291,2.73645 -1.573157,4.2661 0.125778,1.98072 1.858225,3.35677 2.780704,5.09239 -0.706534,1.58232 -1.31503,2.94914 -1.509434,4.5283 -0.16031,1.30221 0.06218,1.97943 1.056075,3.28943 5.248759,-1.11116 8.295181,-1.55313 11.925057,-4.19509 -1.058592,-2.41406 -0.807838,-5.06122 0.301887,-7.84906 z" style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> <path d="m 75.249199,140.0995 c 0.920412,-1.66065 2.97442,-3.40692 4.869883,-3.29673 1.92976,0.11219 3.649731,1.90082 4.528302,3.62264 0.961557,1.88446 0.886213,5.02107 -0.09505,6.89534 -0.880645,1.68208 -2.936595,2.88021 -4.830189,3.01887 -1.752715,0.12834 -3.312556,-0.7615 -4.274471,-2.23228 -1.432059,-2.18964 -1.466796,-5.71946 -0.198471,-8.00784 z" style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> <path d="m 84.69544,140.58419 c 1.442735,-2.39498 4.612529,-3.28513 7.245283,-4.22641 2.399004,-0.85771 6.000079,-2.40927 7.983805,-0.81061 -2.043057,6.58235 -2.082076,5.75783 -2.334647,8.77356 0.110945,2.50663 0.153543,4.71871 0.689406,7.39464 -3.646529,0.42109 -11.064298,0.3341 -13.449098,-3.48895 0.665678,-2.88446 0.52328,-5.01598 -0.134749,-7.64223 z" style="fill:#ffffff;fill-opacity:1;stroke:#ffffff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> <path d="m 55.245283,112.45283 c 0,0 11.890824,6.85167 17.408806,8.19471 7.045871,1.71492 10.33351,1.58918 17.408805,0 5.543635,-1.24515 17.408806,-8.19471 17.408806,-8.19471" style="fill:none;stroke:#ffffff;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> <path d="m 83.320758,101.13207 a 6.7924528,4.2264152 0 1 1 -13.584906,0 6.7924528,4.2264152 0 1 1 13.584906,0 z" transform="translate(-1.8113208,-0.90566038)" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-opacity:1" /> <path d="m 83.320758,101.13207 a 6.7924528,4.2264152 0 1 1 -13.584906,0 6.7924528,4.2264152 0 1 1 13.584906,0 z" transform="matrix(-1,0,0,1,162.86792,-1.2075441)" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-opacity:1" /> <path d="m 78.792455,100.98113 a 2.5660377,1.3584906 0 1 1 -5.132075,0 2.5660377,1.3584906 0 1 1 5.132075,0 z" transform="translate(-1.358493,-1.0566042)" style="fill:none;stroke:#ffffff;stroke-opacity:1" /> <path d="m 78.792455,100.98113 a 2.5660377,1.3584906 0 1 1 -5.132075,0 2.5660377,1.3584906 0 1 1 5.132075,0 z" transform="translate(9.8113183,-0.75471741)" style="fill:none;stroke:#ffffff;stroke-opacity:1" /> </g> </svg>
//* palette-fill:mashape *// #ff0066
//* palette-stroke:mashape *// #ef003e
//* palette-highlight:mashape *// #ffb1b3
//* palette-stroke-highlight:mashape *// #000000