Advertisement
BLOCKLY18

crazy.js

Aug 11th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.42 KB | None | 0 0
  1. le._apps["crazy"] = {
  2. categories: "Amusement",
  3. name: "Crazy arror",
  4. icon: "/c/sys/skins/w93/error.png",
  5. exec: function(url, opt) {
  6. $loader(["/c/libs/MIDIFile/dist/MIDIFile.js"], function() {
  7. var cont = le._dom.desktop;
  8. ////////////////////////////////////////////////
  9. var styleTopppp =
  10. " position: absolute;" +
  11. " top: 0;" +
  12. " bottom: 0;" +
  13. " left: 0;" +
  14. " right: 0;" +
  15. " width: auto;" +
  16. " height: auto;" +
  17. " z-index: 500;" +
  18. " background-repeat: no-repeat;" +
  19. " background-size: contain;" +
  20. " image-rendering: pixelated;" +
  21. " background-position: center;";
  22.  
  23. var bsodEl = document.createElement("div");
  24. bsodEl.id = "CE_BSOD";
  25. bsodEl.className = "hide";
  26. var loginEl = document.createElement("div");
  27. loginEl.id = "CE_LOGIN";
  28. loginEl.className = "hide";
  29.  
  30. var styles = document.createElement("style");
  31. styles.innerHTML =
  32. "#CE_BSOD{" +
  33. styleTopppp +
  34. " background-color: #0102AC;" +
  35. ' background-image: url("/c/programs/crazyError/BSoD.png");' +
  36. "}#CE_LOGIN{" +
  37. styleTopppp +
  38. " background-color: #000;" +
  39. " background-size: initial;" +
  40. ' background-image: url("/c/sys/img/progress_bar.gif");' +
  41. "}";
  42.  
  43. cont.appendChild(styles);
  44. cont.appendChild(bsodEl);
  45. cont.appendChild(loginEl);
  46.  
  47. // console.log(cont.offsetWidth)
  48.  
  49. var folders = [
  50. "/c/",
  51. "/c/sys/cursors/",
  52. "/c/files/images/icons/",
  53. "/c/sys/skins/w93/",
  54. "/c/sys/skins/w93/16/",
  55. "/c/sys/skins/w93/ext/",
  56. "/c/libs/",
  57. "/a/",
  58. "/c/sys/fonts/C64_TrueType_v1.2-STYLE/",
  59. "/c/files/music/modules/ACID/",
  60. "/c/programs/filter",
  61. "/c/sys/img/",
  62. ];
  63.  
  64. var sequences;
  65.  
  66. // var bsodEl = document.get
  67. var bsod = {
  68. show: function() {
  69. bsodEl.classList.remove("hide");
  70. },
  71. hide: function() {
  72. bsodEl.classList.add("hide");
  73. },
  74. };
  75. var login = {
  76. show: function() {
  77. loginEl.classList.remove("hide");
  78. },
  79. hide: function() {
  80. loginEl.classList.add("hide");
  81. },
  82. };
  83.  
  84. // ENGINE
  85. /////////
  86.  
  87. var w2 = cont.offsetWidth / 2;
  88. var h2 = cont.offsetHeight / 2;
  89.  
  90. function pointFromPointAngleRadius(myPoint, myAngle, myRadius) {
  91. var newPoint = [0.0, 0.0];
  92. newPoint[0] =
  93. myPoint[0] +
  94. Math.cos(myAngle * 3.14 / 180.0) * Math.floor(myRadius);
  95. newPoint[1] =
  96. myPoint[1] +
  97. Math.sin(myAngle * 3.14 / 180.0) * Math.floor(myRadius);
  98. return newPoint;
  99. }
  100.  
  101. var trigo = {
  102. cnt: 0,
  103. exec: function(total) {
  104. var xy = pointFromPointAngleRadius(
  105. [w2, h2],
  106. this.cnt * (360 / total) - 90,
  107. cont.offsetWidth / 5
  108. );
  109. this.cnt++;
  110. var cnt = this.cnt;
  111. return {
  112. left: xy[0] - 380 / 2,
  113. top: xy[1] - 110 / 2,
  114. };
  115. },
  116. };
  117.  
  118. var spin = {
  119. cnt: 0,
  120. exec: function(total) {
  121. var xy = pointFromPointAngleRadius(
  122. [w2, h2],
  123. this.cnt * (360 / total) - 90,
  124. cont.offsetWidth / 5
  125. );
  126. this.cnt++;
  127. var cnt = this.cnt;
  128. return {
  129. left: xy[0] - 380 / 2,
  130. top: xy[1] - 110 / 2,
  131. baseClass: "ui_alert fx_spin",
  132. };
  133. },
  134. };
  135.  
  136. var OK = {
  137. cnt: 0,
  138. exec: function() {
  139. var xy = pointFromPointAngleRadius(
  140. [w2, h2],
  141. this.cnt * (360 / 10) - 90,
  142. cont.offsetWidth / 5
  143. );
  144. this.cnt++;
  145. var cnt = this.cnt;
  146. return {
  147. left: xy[0] - 380 / 2,
  148. top: xy[1] - 110 / 2,
  149. style: {
  150. transform: "scale(" + cnt / 2 + ")",
  151. },
  152. };
  153. },
  154. };
  155.  
  156. function resetSeq() {
  157. trigo.cnt = 0;
  158. spin.cnt = 0;
  159. OK.cnt = 0;
  160. sequences = [
  161. { top: 200, left: 200, noOut: true },
  162. { top: 23, left: 23, noOut: true },
  163. { top: 23, left: cont.offsetWidth - 380 - 23, noOut: true },
  164. ];
  165. }
  166. resetSeq();
  167.  
  168. var sounds = {};
  169.  
  170. var notes = {
  171. 24: function(seq) {
  172. // $audio('/c/programs/crazyError/SOUNDS/24.mp3').play()
  173. sounds[24].play();
  174. $alert(
  175. $extend(
  176. {
  177. title: "Error",
  178. msg:
  179. "Cock and ball torture (CBT), penis torture or dick torture is a sexual activity involving application of pain or constriction to the penis or testicles. This may involve directly painful activities, such as genital piercing, wax play, genital spanking, squeezing, ball-busting, genital flogging, urethral play, tickle torture, erotic electrostimulation, kneeing or kicking. The recipient of such activities may receive direct physical pleasure via masochism, or emotional pleasure through erotic humiliation, or knowledge that the play is pleasing to a sadistic dominant. Many of these practices carry significant health risks.",
  180. img: "/c/sys/skins/w93/error.png",
  181. center: false,
  182. sound: null,
  183. animationIn: "slideInLeft",
  184. onready: function() {
  185. if (this.cfg.maxTop && this.cfg.maxLeft) resetSeq();
  186. },
  187. },
  188. seq
  189. )
  190. );
  191. },
  192. 25: function(seq) {
  193. // $audio('/c/programs/crazyError/SOUNDS/25.mp3').play()
  194. sounds[25].play();
  195. $alert(
  196. $extend(
  197. {
  198. title: "TADAAAA",
  199. msg: "†¥bˇYf˜˜gYiugb§76©§§¶§§›¶•¶•5RÁF•¶°Ô·˙´·¸µ≤",
  200. img: "/c/sys/skins/w93/trophy.gif",
  201. btnOk: "¥¥¥¥§¶∞§¶¥",
  202. sound: null,
  203. center: true,
  204. animationIn: "tada",
  205. },
  206. seq
  207. )
  208. );
  209. },
  210. 26: function(seq) {
  211. // $audio('/c/programs/crazyError/SOUNDS/26.mp3').play()
  212. sounds[26].play();
  213. $alert(
  214. $extend(
  215. {
  216. title: "ãåÅÅÅÅ‚¨ãƒ©ãƒ¼",
  217. msg: "ã‚÷¿¿÷÷÷¿ã‚¹ã‚¯ãŒæ­£å¸¸ã«å“«]“:”Ú‘'æ‘æ]OP∏lplp¬¬˚ø˚¬¬∆∆˙˙©ÓÔK¤±æ•—しました",
  218. img: "/c/sys/skins/w93/alert.png",
  219. btnOk: "ワオ",
  220. sound: null,
  221. center: false,
  222. },
  223. seq
  224. )
  225. );
  226. },
  227. 27: function(seq) {
  228. // $audio('/c/programs/crazyError/SOUNDS/27.mp3').play()
  229. sounds[27].play();
  230. $alert(
  231. $extend(
  232. {
  233. title: "エラー",
  234. msg: "タスクが正常に失敗しました",
  235. img: "/c/sys/skins/w93/info.png",
  236. btnOk: "ワオ",
  237. sound: null,
  238. center: false,
  239. style: {
  240. transform: "scale(2)",
  241. },
  242. onready: function() {
  243. var ttt = this;
  244. setTimeout(function() {
  245. ttt.destroy();
  246. }, 100);
  247. },
  248. },
  249. seq
  250. )
  251. );
  252. },
  253. 28: function(seq) {
  254. // truc aleatoire
  255. // $audio('/c/programs/crazyError/SOUNDS/28.mp3').play()
  256. sounds[28].play();
  257. $alert(
  258. $extend(
  259. {
  260. title: "エラー",
  261. msg: "タスクが正常に失敗しました",
  262. img: "/c/sys/skins/w93/error.png",
  263. btnOk: "ワオ",
  264. sound: null,
  265. center: false,
  266. },
  267. seq
  268. )
  269. );
  270. },
  271. 29: function(seq) {
  272. // $audio('/c/programs/crazyError/SOUNDS/29.mp3').play()
  273. sounds[29].play();
  274. $alert(
  275. $extend(
  276. {
  277. title: "MOUP",
  278. msg: "タスクが正常に失敗しました",
  279. img: "/c/files/images/icons/no.png",
  280. btnOk: "ワオ",
  281. sound: null,
  282. center: false,
  283. },
  284. seq
  285. )
  286. );
  287. },
  288. 30: function(seq) {
  289. // console.log('left')
  290. // $audio('/c/programs/crazyError/SOUNDS/30.mp3').play()
  291. sounds[30].play();
  292. $alert(
  293. $extend(
  294. {
  295. title: "KAHCT",
  296. msg: '何か問題でも "C:\\Program Files" 笑',
  297. img: "/c/sys/skins/w93/install.png",
  298. btnOk: "いいえ",
  299. btnCancel: "うん",
  300. sound: null,
  301. center: false,
  302. },
  303. seq
  304. )
  305. );
  306. },
  307. 31: function(seq) {
  308. // $audio('/c/programs/crazyError/SOUNDS/31.mp3').play()
  309. sounds[31].play();
  310. $alert(
  311. $extend(
  312. {
  313. title: "ウィンドウ",
  314. msg:
  315. "曖昧さ回避 ã“ã®é …ç›®ã§ã¯ã€ã‚³ãƒ³ãƒ”ãƒ¥ãƒ¼ã‚¿ã®ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã‚·ã‚¹ãƒ†ãƒ ã«ãŠã‘ã‚‹ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¤ã„ã¦èª¬æ˜Žã—ã¦ã„ã¾ã™ã€‚ä¸€èˆ¬çš„ãªã€Œçª“ã€ã«ã¤ã„ã¦ã¯ã€Œçª“ã€ã‚’ã”è¦§ãã ã•ã„ã€‚ãƒ•ãƒ­ãƒ¼åˆ¶å¾¡ã«ãŠã‘ã‚‹ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã«ã¤ã„ã¦ã¯ã€Œã‚¹ãƒ©ã‚¤ãƒ‡ã‚£ãƒ³ã‚°ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã€ã‚’ã”è¦§ãã ã•ã„ã€‚ã‚·ãƒ£ãƒ¼ãƒ—ã®æ¶²æ™¶ãƒ†ãƒ¬ãƒ“ã®ãƒ–ãƒ©ãƒ³ãƒ‰åç§°ã«ã¤ã„ã¦ã¯ã€Œã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ (シャープの製品)」をご覧ください。芸能事務所については「ウィンドー (芸能プロダクション)」をご覧ください。PEARLのアルバムについては「WINDOW」をご覧ください。",
  316. img: "/c/files/images/icons/lol.png",
  317. btnOk: "いいえ",
  318. btnCancel: "うん",
  319. sound: null,
  320. center: false,
  321. },
  322. seq
  323. )
  324. );
  325. },
  326. 32: function(seq) {
  327. // $audio('/c/programs/crazyError/SOUNDS/32.mp3').play()
  328. sounds[32].play();
  329. $alert(
  330. $extend(
  331. {
  332. title: "エラー",
  333. msg: '何か問題でも "C:\\Program Files" 笑',
  334. img: "/c/files/images/icons/yea.png",
  335. btnOk: "いいえ",
  336. btnCancel: "うん",
  337. // ,baseClass: 'fx_spin ui_alert'
  338. sound: null,
  339. center: false,
  340. },
  341. seq
  342. )
  343. );
  344. },
  345. 33: function(seq) {
  346. // notif
  347. // $audio('/c/programs/crazyError/SOUNDS/33.mp3').play()
  348. sounds[33].play();
  349. $notif(
  350. $extend(
  351. {
  352. text: "あまりにも多くのエラー笑",
  353. speed: 1,
  354. },
  355. seq
  356. )
  357. );
  358. },
  359. 34: function(seq) {
  360. // $audio('/c/programs/crazyError/SOUNDS/34.mp3').play()
  361. sounds[34].play();
  362. $alert(
  363. $extend(
  364. {
  365. title: "エラー",
  366. msg: '何か問題でも "C:\\Program Files" 笑',
  367. img: "/c/sys/skins/w93/floppy-format.png",
  368. btnOk: "いいえ",
  369. btnCancel: "うん",
  370. sound: null,
  371. center: false,
  372. },
  373. seq
  374. )
  375. );
  376. },
  377. 35: function(seq) {
  378. // $audio('/c/programs/crazyError/SOUNDS/35.mp3').play()
  379. sounds[35].play();
  380. $alert(
  381. $extend(
  382. {
  383. title: "あまりにも多くのエラー笑",
  384. msg: "Windowsエクスプローラが動作を停止しました",
  385. img: "/c/sys/skins/w93/alert.png",
  386. btnOk: "いいえ",
  387. btnCancel: "うん",
  388. center: false,
  389. sound: null,
  390. width: 200,
  391. },
  392. seq
  393. )
  394. );
  395. },
  396. 36: function(seq) {
  397. // shutdown
  398. // $audio('/c/programs/crazyError/SOUNDS/36.mp3').play()
  399. sounds[36].play();
  400. $alert(
  401. $extend(
  402. {
  403. title: "あまりにも多くのエラー笑",
  404. msg: "Windowsエクスプローラが動作を停止しました",
  405. img: "/c/sys/skins/w93/question.png",
  406. btnOk: "いいえ",
  407. btnCancel: "うん",
  408. center: false,
  409. sound: null,
  410. },
  411. seq
  412. )
  413. );
  414. },
  415. 37: function(seq) {
  416. // bonjour
  417. // $audio('/c/programs/crazyError/SOUNDS/37.mp3').play()
  418. sounds[37].play();
  419. $alert(
  420. $extend(
  421. {
  422. title: "エラー",
  423. msg:
  424. '曖昧さ回避 "C:\\WINDOWS" 私は何を入力しているのか分かりません',
  425. img: "/c/sys/skins/w93/error.png",
  426. center: false,
  427. sound: null,
  428. },
  429. seq
  430. )
  431. );
  432. },
  433. 38: function(seq) {
  434. // $audio('/c/programs/crazyError/SOUNDS/38.mp3').play()
  435. sounds[38].play();
  436. $prompt(
  437. {
  438. msg: "Enter your Credit card number",
  439. center: false,
  440. },
  441. ""
  442. );
  443. },
  444. 39: function(seq) {
  445. // $audio('/c/programs/crazyError/SOUNDS/39.mp3').play()
  446. sounds[39].play();
  447. $alert(
  448. $extend(
  449. {
  450. title: "エラー",
  451. msg:
  452. '曖昧さ回避 "C:\\WINDOWS" 私は何を入力しているのか分かりません',
  453. img: "/c/files/images/icons/derp.png",
  454. btnOk: "OK",
  455. center: false,
  456. sound: null,
  457. onready: function() {
  458. var ttt = this;
  459. setTimeout(function() {
  460. ttt.destroy();
  461. }, 500);
  462. },
  463. },
  464. seq
  465. )
  466. );
  467. },
  468. 40: function(seq) {
  469. // $audio('/c/programs/crazyError/SOUNDS/40.mp3').play()
  470. sounds[40].play();
  471. $explorer(folders[~~(Math.random() * folders.length)], {
  472. window: {
  473. width: 100 + Math.random() * 400,
  474. height: 100 + Math.random() * 300,
  475. },
  476. });
  477. },
  478. 41: function(seq) {
  479. // $audio('/c/programs/crazyError/SOUNDS/41.mp3').play()
  480. sounds[41].play();
  481. $alert(
  482. $extend(
  483. {
  484. title: "Error",
  485. msg:
  486. "Windows has detected that your monitor<br>is not plugined in.",
  487. img: "/c/sys/skins/w93/settings.png",
  488. btnOk: "wat",
  489. center: false,
  490. sound: null,
  491. },
  492. seq
  493. )
  494. );
  495. },
  496. };
  497.  
  498. // RUN
  499. //////
  500.  
  501. function loadSound(url) {
  502. return new Promise(function(resolve, reject) {
  503. var sound = new Howl({
  504. buffer: false,
  505. urls: [url],
  506. onload: function() {
  507. resolve(sound);
  508. },
  509. });
  510. });
  511. }
  512.  
  513. var all = [
  514. fetch("/c/programs/crazyError/CRAZY-ERROR-170BPM.mid", {
  515. credentials: "include",
  516. }),
  517. new Promise(function(resolve, reject) {
  518. var sound = new Howl({
  519. buffer: true,
  520. urls: ["/c/programs/crazyError/CRAZY-ERROR-170BPM.wav"],
  521. onload: function() {
  522. resolve(sound);
  523. },
  524. });
  525. }),
  526. ];
  527.  
  528. for (var i = 24; i < 42; i++) {
  529. all.push(loadSound("/c/programs/crazyError/SOUNDS/" + i + ".mp3"));
  530. }
  531.  
  532. Promise.all(all).then(function(assets) {
  533. var midi = assets.shift();
  534. var track = assets.shift();
  535. assets.forEach(function(sound, i) {
  536. sounds[24 + i] = sound;
  537. });
  538. // console.log(sounds)
  539. track.volume(0.5);
  540. midi.arrayBuffer().then(function(buffer) {
  541. var midiFile = new MIDIFile(buffer);
  542. midiFile.header.setTicksPerBeat(
  543. midiFile.header.getTicksPerBeat() / 120 * 170
  544. );
  545.  
  546. var events = midiFile.getMidiEvents();
  547. var curTime = 0; // performance.now();
  548. var eventBytes = [];
  549.  
  550. // return
  551. var seqNum = {};
  552. var seqStart = {};
  553. var seqCursor = {};
  554. var lastParam;
  555. var lastSeq;
  556.  
  557. function getTotal(param) {
  558. var total = seqNum[param][seqCursor[param]];
  559. // console.log(total)
  560. return total;
  561. }
  562.  
  563. // return
  564.  
  565. var gom = 0;
  566. for (var i = 0, j = events.length; i < j; i++) {
  567. var ev = events[i];
  568. if (ev.param2 > 70 && ev.param1 !== 0) {
  569. if (lastParam !== ev.param1) {
  570. seqCursor[ev.param1] = -1;
  571. seqStart[i] = ev.param1;
  572. if (!seqNum[ev.param1]) seqNum[ev.param1] = [0];
  573. else seqNum[ev.param1].push(0);
  574. }
  575. lastParam = ev.param1;
  576. seqNum[ev.param1][seqNum[ev.param1].length - 1]++;
  577. }
  578. //////////////////////
  579. !(function(ev, i) {
  580. if (i === 0)
  581. setTimeout(function() {
  582. track.play();
  583. }, curTime + ev.playTime);
  584. setTimeout(function() {
  585. if (seqStart[i]) seqCursor[seqStart[i]]++;
  586. // console.log(JSON.stringify(ev))
  587. // console.log(i)
  588. if (ev.param1 === 0 && ev.param2 >= 70) {
  589. // $exe('fx ' + le._fx)
  590. // $exe('fx ' + le._fx[~~(Math.random() * le._fx.length)])
  591. // gom++
  592. resetSeq();
  593. $window.instances.forEach(function(item) {
  594. if (item && item.destroy) item.close();
  595. });
  596. $window.instances.length = 0;
  597. }
  598.  
  599. if (ev.param1 === 24) {
  600. if (ev.param2 >= 70 && notes[ev.param1]) {
  601. sequences[0].top += 23;
  602. sequences[0].left += 23;
  603. notes[ev.param1](sequences[0]);
  604. // console.log(seqCursor[ev.param1])
  605. // notes[ev.param1](spin.exec(getTotal(ev.param1)))
  606. // notes[39](OK.exec())
  607. }
  608. } else if (ev.param1 === 39) {
  609. if (ev.param2 >= 70 && notes[ev.param1]) {
  610. notes[ev.param1](OK.exec());
  611. }
  612. } else if (ev.param1 === 35) {
  613. if (ev.param2 >= 70 && notes[ev.param1]) {
  614. var tt = getTotal(ev.param1);
  615. if (tt > 5) {
  616. notes[ev.param1](spin.exec(getTotal(ev.param1)));
  617. } else {
  618. // notes[ev.param1](trigo.exec(getTotal(ev.param1)))
  619. notes[ev.param1]();
  620. }
  621. // notes[ev.param1](spin.exec(getTotal(ev.param1)))
  622. }
  623. } else if (ev.param1 === 26) {
  624. if (ev.param2 < 70) bsod.hide();
  625. else bsod.show();
  626. } else if (ev.param1 === 41) {
  627. if (ev.param2 < 70) login.hide();
  628. else login.show();
  629. } else if (ev.param1 === 42) {
  630. if (ev.param2 < 70) login.hide();
  631. else login.show();
  632. } else if (ev.param1 === 29) {
  633. if (ev.param2 >= 70 && notes[ev.param1]) {
  634. sequences[1].top += 23;
  635. sequences[1].left += 23;
  636. notes[ev.param1](sequences[1]);
  637. }
  638. } else if (ev.param1 === 30) {
  639. if (ev.param2 >= 70 && notes[ev.param1]) {
  640. sequences[2].top += 23;
  641. sequences[2].left -= 23;
  642. notes[ev.param1](sequences[2]);
  643. }
  644. } else if (ev.param1 === 32) {
  645. if (ev.param2 >= 70 && notes[ev.param1]) {
  646. notes[ev.param1](trigo.exec(getTotal(ev.param1)));
  647. }
  648. } else {
  649. if (ev.param2 > 100 && notes[ev.param1]) notes[ev.param1]();
  650. }
  651. }, curTime + ev.playTime);
  652. })(events[i], i);
  653. //////////////////////
  654. }
  655. });
  656. });
  657. //////////////////////////
  658. });
  659. },
  660. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement