| 1 | <!DOCTYPE html PUBLIC> |
| 2 | <html> |
| 3 | <head> |
| 4 | |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 6 | |
| 7 | <style type="text/css"> |
| 8 | body { |
| 9 | background-color: #000000; |
| 10 | } |
| 11 | |
| 12 | /* WEBKIT */ |
| 13 | text { |
| 14 | -webkit-touch-callout: none; |
| 15 | -webkit-user-select: none; |
| 16 | -khtml-user-select: none; |
| 17 | -moz-user-select: none; |
| 18 | -ms-user-select: none; |
| 19 | user-select: none; |
| 20 | } |
| 21 | |
| 22 | .faust-group-label { |
| 23 | font-family: Arial, Verdana, Helvetica, sans; |
| 24 | font-size: 13px; |
| 25 | fill: rgba(199,190,162,0.6); |
| 26 | } |
| 27 | |
| 28 | .faust-tooltip-text { |
| 29 | font-family: Arial, Verdana, Helvetica, sans; |
| 30 | font-size: 13px; |
| 31 | } |
| 32 | |
| 33 | .faust-button-label { |
| 34 | font-family: Arial, Verdana, Helvetica, sans; |
| 35 | font-size: 13px; |
| 36 | fill: rgba(0,182,253,0.6); |
| 37 | } |
| 38 | |
| 39 | .faust-tgroup-label { |
| 40 | font-family: Arial, Verdana, Helvetica, sans; |
| 41 | font-size: 13px; |
| 42 | fill: rgba(0,182,253,0.6); |
| 43 | } |
| 44 | |
| 45 | .faust-label { |
| 46 | font-family: Arial, Verdana, Helvetica, sans; |
| 47 | font-size: 13px; |
| 48 | fill: rgba(0,182,253,0.6); |
| 49 | } |
| 50 | |
| 51 | .faust-value-text { |
| 52 | font-family: Arial, Verdana, Helvetica, sans; |
| 53 | font-size: 11px; |
| 54 | font-weight: bold; |
| 55 | fill: rgb(82,79,79); |
| 56 | } |
| 57 | |
| 58 | path { |
| 59 | -webkit-user-select: none; |
| 60 | } |
| 61 | |
| 62 | rect { |
| 63 | -webkit-user-select: none; |
| 64 | -moz-user-select: none; |
| 65 | user-select: none; |
| 66 | } |
| 67 | |
| 68 | } |
| 69 | |
| 70 | circle { |
| 71 | -webkit-user-select: none; |
| 72 | } |
| 73 | |
| 74 | text:hover { |
| 75 | cursor: default; |
| 76 | } |
| 77 | |
| 78 | path.faust-vbox { |
| 79 | fill : white; |
| 80 | stroke : black; |
| 81 | } |
| 82 | |
| 83 | path.faust-rbutton-groove { |
| 84 | fill : rgb(152,251,152); |
| 85 | stroke : black; |
| 86 | } |
| 87 | |
| 88 | path.faust-rbutton-handle { |
| 89 | fill : grey; |
| 90 | stroke : black; |
| 91 | } |
| 92 | |
| 93 | rect.faust-hslider-meter { |
| 94 | fill : url(#horizontalSliderMeterGradient); |
| 95 | } |
| 96 | |
| 97 | rect.faust-hslider-groove { |
| 98 | fill : rgba(28,126,192,0.65); |
| 99 | stroke : rgba(0,182,253,0.9); |
| 100 | } |
| 101 | |
| 102 | rect.faust-hslider-handle { |
| 103 | fill : url(#horizontalSliderHandleGradient); |
| 104 | stroke : black; |
| 105 | } |
| 106 | |
| 107 | rect.faust-vslider-meter { |
| 108 | fill : url(#verticalSliderMeterGradient); |
| 109 | } |
| 110 | |
| 111 | rect.faust-vslider-groove { |
| 112 | fill : rgba(28,126,192, 0.65); |
| 113 | stroke : rgba(0,182,253,0.9); |
| 114 | } |
| 115 | |
| 116 | rect.faust-vslider-handle { |
| 117 | fill : url(#verticalSliderHandleGradient); |
| 118 | stroke : black; |
| 119 | } |
| 120 | |
| 121 | rect.faust-hbargraph-curtain { |
| 122 | fill : rgb(20,20,20); |
| 123 | stroke : black; |
| 124 | } |
| 125 | |
| 126 | // hbargraph meters cannot be defined via CSS because their widths and |
| 127 | // heights are dynamic |
| 128 | |
| 129 | rect.faust-hbargraph-meter { |
| 130 | fill : url(#horizontalBarGraphMeterGradient); |
| 131 | stroke : black; |
| 132 | } |
| 133 | |
| 134 | rect.faust-vbargraph-curtain { |
| 135 | fill : rgb(20,20,20); |
| 136 | stroke : black; |
| 137 | } |
| 138 | |
| 139 | rect.faust-vbargraph-meter { |
| 140 | fill : url(#verticalBarGraphMeterGradient); |
| 141 | stroke : black; |
| 142 | } |
| 143 | |
| 144 | rect.faust-checkbox-box { |
| 145 | fill : white; |
| 146 | stroke : black; |
| 147 | } |
| 148 | |
| 149 | path.faust-checkbox-check { |
| 150 | fill : black; |
| 151 | stroke : black; |
| 152 | } |
| 153 | |
| 154 | rect.faust-nentry-box { |
| 155 | fill : url(#numericalEntryUpGradient); |
| 156 | stroke : black; |
| 157 | } |
| 158 | |
| 159 | path.faust-nentry-operation { |
| 160 | stroke : black; |
| 161 | } |
| 162 | |
| 163 | rect.faust-button-box { |
| 164 | fill : url(#buttonUpGradient); |
| 165 | stroke : black; |
| 166 | } |
| 167 | |
| 168 | rect.faust-tgroup-box { |
| 169 | fill : url(#tabGroupUpGradient); |
| 170 | stroke : black; |
| 171 | } |
| 172 | |
| 173 | circle.faust-rbutton-groove { |
| 174 | fill : url(#rotatingButtonHandleGradient); |
| 175 | } |
| 176 | |
| 177 | circle.faust-rbutton-dot { |
| 178 | fill : pink; |
| 179 | stroke : black; |
| 180 | } |
| 181 | |
| 182 | path.faust-rbutton-meter { |
| 183 | fill : rgb(50,50,50); |
| 184 | } |
| 185 | |
| 186 | path.faust-rbutton-mgroove { |
| 187 | fill : url(#rotatingButtonMeterGradient); |
| 188 | } |
| 189 | |
| 190 | // as all of the above rectangles could be implemented as paths, we duplicate the definitions for paths |
| 191 | |
| 192 | path.faust-hslider-groove { |
| 193 | fill : red; |
| 194 | stroke : black; |
| 195 | } |
| 196 | |
| 197 | path.faust-hslider-handle { |
| 198 | fill : url(#horizontalSliderHandleGradient); |
| 199 | stroke : black; |
| 200 | } |
| 201 | |
| 202 | path.faust-vslider-groove { |
| 203 | fill : red; |
| 204 | stroke : black; |
| 205 | } |
| 206 | |
| 207 | path.faust-vslider-handle { |
| 208 | fill : url(#verticalSliderHandleGradient); |
| 209 | stroke : black; |
| 210 | } |
| 211 | |
| 212 | path.faust-hbargraph-curtain { |
| 213 | fill : rgb(0,255,255); |
| 214 | stroke : black; |
| 215 | } |
| 216 | |
| 217 | path.faust-hbargraph-meter { |
| 218 | fill : grey; |
| 219 | stroke : black; |
| 220 | } |
| 221 | |
| 222 | path.faust-vbargraph-curtain { |
| 223 | fill : rgb(0,255,255); |
| 224 | stroke : black; |
| 225 | } |
| 226 | |
| 227 | path.faust-vbargraph-meter { |
| 228 | fill : grey; |
| 229 | stroke : black; |
| 230 | } |
| 231 | |
| 232 | path.faust-checkbox-box { |
| 233 | fill : white; |
| 234 | stroke : black; |
| 235 | } |
| 236 | |
| 237 | path.faust-nentry-box { |
| 238 | fill : url(#numericalEntryUpGradient); |
| 239 | stroke : black; |
| 240 | } |
| 241 | |
| 242 | path.faust-button-box { |
| 243 | fill : #B0B0B0; |
| 244 | stroke : black; |
| 245 | } |
| 246 | |
| 247 | #filedrag{ |
| 248 | font-weight: bold; |
| 249 | text-align: center; |
| 250 | padding: 1em 0; |
| 251 | margin: 1em 0; |
| 252 | color: #CECECE; |
| 253 | border: 8px dashed #CECECE; |
| 254 | border-radius: 7px; |
| 255 | cursor: default; |
| 256 | font-size : 20px; |
| 257 | } |
| 258 | |
| 259 | #filedrag.hover{ |
| 260 | color: #FF7F00; |
| 261 | border-color: #FF7F00; |
| 262 | border-style: solid; |
| 263 | } |
| 264 | </style> |
| 265 | |
| 266 | </head> |
| 267 | <body bgcolor= "#000000"> |
| 268 | <div id="filedrag"> |
| 269 | Remote DSP processing : drop your .dsp file here |
| 270 | </div> |
| 271 | |
| 272 | <form id="upload" action="CompilerResponse" method="POST" enctype="multipart/form-data"> |
| 273 | <input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="50000000" /> |
| 274 | </form> |
| 275 | |
| 276 | <script type="text/javascript"> |
| 277 | |
| 278 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
| 279 | /* SHA-1 implementation in JavaScript | (c) Chris Veness 2002-2013 | www.movable-type.co.uk */ |
| 280 | /* - see http://csrc.nist.gov/groups/ST/toolkit/secure_hashing.html */ |
| 281 | /* http://csrc.nist.gov/groups/ST/toolkit/examples.html */ |
| 282 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
| 283 | |
| 284 | var Sha1 = {}; // Sha1 namespace |
| 285 | |
| 286 | /** |
| 287 | * Generates SHA-1 hash of string |
| 288 | * |
| 289 | * @param {String} msg String to be hashed |
| 290 | * @param {Boolean} [utf8encode=true] Encode msg as UTF-8 before generating hash |
| 291 | * @returns {String} Hash of msg as hex character string |
| 292 | */ |
| 293 | Sha1.hash = function(msg, utf8encode) { |
| 294 | utf8encode = (typeof utf8encode == 'undefined') ? true : utf8encode; |
| 295 | |
| 296 | // convert string to UTF-8, as SHA only deals with byte-streams |
| 297 | if (utf8encode) msg = Utf8.encode(msg); |
| 298 | |
| 299 | // constants [§4.2.1] |
| 300 | var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6]; |
| 301 | |
| 302 | // PREPROCESSING |
| 303 | |
| 304 | msg += String.fromCharCode(0x80); // add trailing '1' bit (+ 0's padding) to string [§5.1.1] |
| 305 | |
| 306 | // convert string msg into 512-bit/16-integer blocks arrays of ints [§5.2.1] |
| 307 | var l = msg.length/4 + 2; // length (in 32-bit integers) of msg + ‘1’ + appended length |
| 308 | var N = Math.ceil(l/16); // number of 16-integer-blocks required to hold 'l' ints |
| 309 | var M = new Array(N); |
| 310 | |
| 311 | for (var i=0; i<N; i++) { |
| 312 | M[i] = new Array(16); |
| 313 | for (var j=0; j<16; j++) { // encode 4 chars per integer, big-endian encoding |
| 314 | M[i][j] = (msg.charCodeAt(i*64+j*4)<<24) | (msg.charCodeAt(i*64+j*4+1)<<16) | |
| 315 | (msg.charCodeAt(i*64+j*4+2)<<8) | (msg.charCodeAt(i*64+j*4+3)); |
| 316 | } // note running off the end of msg is ok 'cos bitwise ops on NaN return 0 |
| 317 | } |
| 318 | // add length (in bits) into final pair of 32-bit integers (big-endian) [§5.1.1] |
| 319 | // note: most significant word would be (len-1)*8 >>> 32, but since JS converts |
| 320 | // bitwise-op args to 32 bits, we need to simulate this by arithmetic operators |
| 321 | M[N-1][14] = ((msg.length-1)*8) / Math.pow(2, 32); M[N-1][14] = Math.floor(M[N-1][14]) |
| 322 | M[N-1][15] = ((msg.length-1)*8) & 0xffffffff; |
| 323 | |
| 324 | // set initial hash value [§5.3.1] |
| 325 | var H0 = 0x67452301; |
| 326 | var H1 = 0xefcdab89; |
| 327 | var H2 = 0x98badcfe; |
| 328 | var H3 = 0x10325476; |
| 329 | var H4 = 0xc3d2e1f0; |
| 330 | |
| 331 | // HASH COMPUTATION [§6.1.2] |
| 332 | |
| 333 | var W = new Array(80); var a, b, c, d, e; |
| 334 | for (var i=0; i<N; i++) { |
| 335 | |
| 336 | // 1 - prepare message schedule 'W' |
| 337 | for (var t=0; t<16; t++) W[t] = M[i][t]; |
| 338 | for (var t=16; t<80; t++) W[t] = Sha1.ROTL(W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16], 1); |
| 339 | |
| 340 | // 2 - initialise five working variables a, b, c, d, e with previous hash value |
| 341 | a = H0; b = H1; c = H2; d = H3; e = H4; |
| 342 | |
| 343 | // 3 - main loop |
| 344 | for (var t=0; t<80; t++) { |
| 345 | var s = Math.floor(t/20); // seq for blocks of 'f' functions and 'K' constants |
| 346 | var T = (Sha1.ROTL(a,5) + Sha1.f(s,b,c,d) + e + K[s] + W[t]) & 0xffffffff; |
| 347 | e = d; |
| 348 | d = c; |
| 349 | c = Sha1.ROTL(b, 30); |
| 350 | b = a; |
| 351 | a = T; |
| 352 | } |
| 353 | |
| 354 | // 4 - compute the new intermediate hash value |
| 355 | H0 = (H0+a) & 0xffffffff; // note 'addition modulo 2^32' |
| 356 | H1 = (H1+b) & 0xffffffff; |
| 357 | H2 = (H2+c) & 0xffffffff; |
| 358 | H3 = (H3+d) & 0xffffffff; |
| 359 | H4 = (H4+e) & 0xffffffff; |
| 360 | } |
| 361 | |
| 362 | return Sha1.toHexStr(H0) + Sha1.toHexStr(H1) + |
| 363 | Sha1.toHexStr(H2) + Sha1.toHexStr(H3) + Sha1.toHexStr(H4); |
| 364 | } |
| 365 | |
| 366 | // |
| 367 | // function 'f' [§4.1.1] |
| 368 | // |
| 369 | Sha1.f = function(s, x, y, z) { |
| 370 | switch (s) { |
| 371 | case 0: return (x & y) ^ (~x & z); // Ch() |
| 372 | case 1: return x ^ y ^ z; // Parity() |
| 373 | case 2: return (x & y) ^ (x & z) ^ (y & z); // Maj() |
| 374 | case 3: return x ^ y ^ z; // Parity() |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | // |
| 379 | // rotate left (circular left shift) value x by n positions [§3.2.5] |
| 380 | // |
| 381 | Sha1.ROTL = function(x, n) { |
| 382 | return (x<<n) | (x>>>(32-n)); |
| 383 | } |
| 384 | |
| 385 | // |
| 386 | // hexadecimal representation of a number |
| 387 | // (note toString(16) is implementation-dependant, and |
| 388 | // in IE returns signed numbers when used on full words) |
| 389 | // |
| 390 | Sha1.toHexStr = function(n) { |
| 391 | var s="", v; |
| 392 | for (var i=7; i>=0; i--) { v = (n>>>(i*4)) & 0xf; s += v.toString(16); } |
| 393 | return s; |
| 394 | } |
| 395 | |
| 396 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
| 397 | /* Utf8 class: encode / decode between multi-byte Unicode characters and UTF-8 multiple */ |
| 398 | /* single-byte character encoding (c) Chris Veness 2002-2013 */ |
| 399 | /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ |
| 400 | |
| 401 | var Utf8 = {}; // Utf8 namespace |
| 402 | |
| 403 | /** |
| 404 | * Encode multi-byte Unicode string into utf-8 multiple single-byte characters |
| 405 | * (BMP / basic multilingual plane only) |
| 406 | * |
| 407 | * Chars in range U+0080 - U+07FF are encoded in 2 chars, U+0800 - U+FFFF in 3 chars |
| 408 | * |
| 409 | * @param {String} strUni Unicode string to be encoded as UTF-8 |
| 410 | * @returns {String} encoded string |
| 411 | */ |
| 412 | Utf8.encode = function(strUni) { |
| 413 | // use regular expressions & String.replace callback function for better efficiency |
| 414 | // than procedural approaches |
| 415 | var strUtf = strUni.replace( |
| 416 | /[\u0080-\u07ff]/g, // U+0080 - U+07FF => 2 bytes 110yyyyy, 10zzzzzz |
| 417 | function(c) { |
| 418 | var cc = c.charCodeAt(0); |
| 419 | return String.fromCharCode(0xc0 | cc>>6, 0x80 | cc&0x3f); } |
| 420 | ); |
| 421 | strUtf = strUtf.replace( |
| 422 | /[\u0800-\uffff]/g, // U+0800 - U+FFFF => 3 bytes 1110xxxx, 10yyyyyy, 10zzzzzz |
| 423 | function(c) { |
| 424 | var cc = c.charCodeAt(0); |
| 425 | return String.fromCharCode(0xe0 | cc>>12, 0x80 | cc>>6&0x3F, 0x80 | cc&0x3f); } |
| 426 | ); |
| 427 | return strUtf; |
| 428 | } |
| 429 | |
| 430 | /** |
| 431 | * Decode utf-8 encoded string back into multi-byte Unicode characters |
| 432 | * |
| 433 | * @param {String} strUtf UTF-8 string to be decoded back to Unicode |
| 434 | * @returns {String} decoded string |
| 435 | */ |
| 436 | Utf8.decode = function(strUtf) { |
| 437 | // note: decode 3-byte chars first as decoded 2-byte strings could appear to be 3-byte char! |
| 438 | var strUni = strUtf.replace( |
| 439 | /[\u00e0-\u00ef][\u0080-\u00bf][\u0080-\u00bf]/g, // 3-byte chars |
| 440 | function(c) { // (note parentheses for precence) |
| 441 | var cc = ((c.charCodeAt(0)&0x0f)<<12) | ((c.charCodeAt(1)&0x3f)<<6) | ( c.charCodeAt(2)&0x3f); |
| 442 | return String.fromCharCode(cc); } |
| 443 | ); |
| 444 | strUni = strUni.replace( |
| 445 | /[\u00c0-\u00df][\u0080-\u00bf]/g, // 2-byte chars |
| 446 | function(c) { // (note parentheses for precence) |
| 447 | var cc = (c.charCodeAt(0)&0x1f)<<6 | c.charCodeAt(1)&0x3f; |
| 448 | return String.fromCharCode(cc); } |
| 449 | ); |
| 450 | return strUni; |
| 451 | } |
| 452 | |
| 453 | // Faust part |
| 454 | var dsp_code = null; |
| 455 | var exportfilename = null; |
| 456 | |
| 457 | function FileDragHover(e) |
| 458 | { |
| 459 | e.stopPropagation(); |
| 460 | e.preventDefault(); |
| 461 | e.target.className = (e.type == "dragover" ? "hover" : ""); |
| 462 | } |
| 463 | |
| 464 | function FileSelectHandler(e) |
| 465 | { |
| 466 | FileDragHover(e); |
| 467 | var files = e.target.files || e.dataTransfer.files; |
| 468 | f = files[0]; |
| 469 | UploadFile(f); |
| 470 | } |
| 471 | |
| 472 | function UploadFile(e) |
| 473 | { |
| 474 | FileDragHover(e); |
| 475 | var files = e.target.files || e.dataTransfer.files; |
| 476 | var file = files[0]; |
| 477 | |
| 478 | if (location.host.indexOf("sitepointstatic") >= 0) return; |
| 479 | |
| 480 | var request = new XMLHttpRequest(); |
| 481 | if (request.upload && file.size <= document.getElementById("MAX_FILE_SIZE").value) { |
| 482 | |
| 483 | var reader = new FileReader(); |
| 484 | var ext = file.name.split('.').pop(); |
| 485 | exportfilename = file.name.split('.').shift(); |
| 486 | |
| 487 | if (ext == "dsp") { |
| 488 | reader.readAsText(file); |
| 489 | } |
| 490 | |
| 491 | reader.onloadend = function(e) { |
| 492 | dsp_code = reader.result; |
| 493 | //console.log(dsp_code); |
| 494 | |
| 495 | var postRequest = new XMLHttpRequest(); |
| 496 | var url_target = window.location.href + "GetJson"; |
| 497 | var sha_key = Sha1.hash(dsp_code + ":" + window.location.host, true).toUpperCase(); |
| 498 | var params = "name=FaustDSP" + "&shaKey=" + sha_key + "&dsp_data=" + encodeURIComponent(dsp_code); |
| 499 | |
| 500 | postRequest.open("POST", url_target, true); |
| 501 | postRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
| 502 | //postRequest.setRequestHeader("Content-length", params.length); |
| 503 | //postRequest.setRequestHeader("Connection", "close"); |
| 504 | |
| 505 | postRequest.onreadystatechange = function() { |
| 506 | console.log("postRequest.onreadystatechange"); |
| 507 | if (postRequest.readyState == 4 && postRequest.status == 200) { |
| 508 | //callback(postRequest.responseText); |
| 509 | console.log(postRequest.responseText); |
| 510 | } else if (postRequest.readyState == 4 && postRequest.status == 400) { |
| 511 | //errCallback(postRequest.responseText); |
| 512 | console.log(postRequest.responseText); |
| 513 | } |
| 514 | } |
| 515 | //console.log(params); |
| 516 | postRequest.send(params); |
| 517 | } |
| 518 | |
| 519 | } else { |
| 520 | alert("DSP file is too big!"); |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | function Init() |
| 525 | { |
| 526 | var filedrag1 = document.getElementById("filedrag"); |
| 527 | filedrag1.addEventListener("dragover", FileDragHover, false); |
| 528 | filedrag1.addEventListener("dragleave", FileDragHover, false); |
| 529 | filedrag1.addEventListener("drop", UploadFile, false); |
| 530 | } |
| 531 | |
| 532 | if (window.File && window.FileList && window.FileReader) { |
| 533 | Init(); |
| 534 | } |
| 535 | |
| 536 | </script> |
| 537 | |
| 538 | </body> |
| 539 | </html> |