{"id":15588,"student_id":1486,"content":"{\"html\":\"\u003c!DOCTYPE html\u003e\\n\u003chtml\u003e\\n\u003chead\u003e\\n\\t\u003ctitle\u003eInfinte Loop Detector\u003c/title\u003e\\n\u003c/head\u003e\\n\u003cbody\u003e\\n \u003cinput id=\\\"start\\\" type=\\\"button\\\" value=\\\"Start\\\" /\u003e\\n \u003cdiv id=\\\"status\\\"\u003ePreparing worker...\u003c/div\u003e\\n \u003cbr /\u003e\\n \u003cbr /\u003e\\n \u003cdiv id=\\\"monaco\\\"\u003e\u003c/div\u003e\\n \u003cscript src=\\\"https://code.jquery.com/jquery-3.2.1.min.js\\\"\u003e\u003c/script\u003e\\n \u003cscript src=\\\"https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/min/vs/loader.js\\\"\u003e\u003c/script\u003e\\n \u003cscript\u003e\\n require.config({ paths: { 'vs': 'https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/min/vs' }});\\n require(['vs/editor/editor.main'], function() {\\n var editor = monaco.editor.create(document.getElementById('monaco'), {\\n language: \\\"javascript\\\",\\n theme: \\\"vs\\\",\\n value: \\\"paste your code here...\\\"\\n });\\n });\\n \u003c/script\u003e\\n\u003c/body\u003e\\n\u003c/html\u003e\",\"css\":\"html, body {\\n width: 100%;\\n height: 100%;\\n margin: 0 0;\\n}\\n\\n#monaco {\\n width: 100%;\\n height: 80vh;\\n}\\n\",\"js\":\"var stat = $(\\\"#status\\\");\\n$(\\\"#start\\\").click(function(){\\n var code = $(\\\"textarea\\\").val();\\n ILD(code, function(isRegular, re){\\n if(isRegular){\\n stat.text(`It is alright!\u003cbr /\u003elog: ${re}`);\\n }else{\\n stat.text(`There's an error or an infinte loop~`);\\n }\\n }, 1000);\\n});\\n\\nfunction ILD(code, functionOnStop, timeout){\\n var id = Math.random() + 1; \\n var workerjs = `\\n onmessage = function(e){\\n e = e.data;\\n postMessage({id: e.id + 1});\\n \\n postMessage({\\n k: {\\n a: 1,\\n b: 2,\\n c: 3\\n },\\n re: eval.call(this, e.code),\\n id: e.id\\n })\\n };\\n `;\\n var blob = new Blob([workerjs], {type: 'text/javascript'});\\n var myWorker = new Worker(URL.createObjectURL(blob));\\n\\n function onDone(){\\n URL.revokeObjectURL(blob);\\n functionOnStop.apply(this, arguments);\\n }\\n\\n myWorker.onmessage = function(e){\\n e = e.data;\\n if(e){\\n if(e.id === id){\\n id = 0;\\n onDone(true, e.re);\\n }else if(e.id === id + 1){\\n setTimeout(function(){\\n if(id){\\n myWorker.terminate();\\n onDone(false);\\n }\\n }, timeout || 1000);\\n }\\n }\\n };\\n\\n myWorker.postMessage({\\n code: code,\\n id: id\\n });\\n}\"}","created_at":"2017-11-17T18:23:15.915+08:00","updated_at":"2020-03-21T13:13:15.602+08:00","name":"Infinte Loop Detector","language":"web","screenshot":{"url":"https://cdn5.koding.school/uploads/project/screenshot/15588/118345ec61179b728181112e74cb82e5.jpg"},"parent_id":null,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":312,"hashid":"npms3v5r","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
橘蘋學習平台
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
前往網站頁面
1:1:1
1:1
full
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦