{"id":112035,"student_id":234,"content":"var comments = [];\nvar users = {\n //159202: { id: 159202, name: \"皮卡丘\"},\n //464878: {id: 464878, name: \"傑尼龜\"},\n //991421: {id: 991421, name: \"小火龍\"},\n};\nvar yourname = prompt(\"what your name?\");\nvar id =Math.floor(Math.random()*10000);\nusers[id] = {\n id: id,\n name: yourname,\n time: Date.now(),\n};\n/*\ndelete users[id];*/\n\nforever(function() {\n /* Do this every tick */\n DB.broadcast('update',users[id]);\n console.log(users);\n for (var i = 0; i \u003c comments.length; i++) {\n print(comments[i], 10+60, 15*i+30);\n }\n var j = 0;\n for (var id in users) {\n //console.log(users[id]);\n print(users[id].name, 10, 15*j+30);\n j++;\n if(Date.now() \u003e users[id].time + 15000){\n delete users[id];\n }\n }\n});\n\nwhen('click', function() {\n var msg = prompt(\"留言:\");\n var time = new Date();\n msg = '['+time.toLocaleTimeString()+'] ' + yourname + ' : ' + msg;\n comments.unshift(msg);\n DB.broadcast(\"message\", msg);\n});\n\nDB.onMessage(\"message\", function(data) {\n console.log(data);\n comments.unshift(data);\n});\n\nDB.onMessage(\"update\", function(data) {\n users[data.id]=data;\n});\n\n\n","created_at":"2019-12-07T10:11:48.578+08:00","updated_at":"2019-12-14T12:01:46.078+08:00","name":"聊天室 副本","language":"javascript","screenshot":{"url":"https://cdn8.koding.school/uploads/project/screenshot/112035/e5cf46edef4add918ea05db882a109fa.jpg"},"parent_id":34007,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":76,"hashid":"882s94qy","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
到這台電腦