{"id":73838,"student_id":1991,"content":"var comments = [];\nvar name = prompt(\"what is your name?\") || \"某XX\";\nvar users={\n 100: { id:100, name:\"某XXA\"},\n 101: { id:100, name:\"某XXB\"},\n 102: { id:100, name:\"某XXC\"},\n};\n\nvar myID = Math.floor(Math.random()*1000000);\nusers[myID] = {\n id: myID,\n name: name\n};\n\nDB.onMessage(\"update\", function(otherUser){\n if(users[otherUser.id] === undefined){\n comments.unshift(`${otherUser.name}'you are online now!!!`);\n } \n users[otherUser.id] = otherUser;\n});\n\n\n\n\n\nforever(function() {\n \n users[myID].time = Date.now();\n DB.broadcast('update',users[myID]);\n \n var idx=0;\n for (var id in users) {\n print(users[id].name, 0, 30+idx*20,\"black\",20);\n idx++;\n }\n \n if(Date.now()\u003eusers[id].time+1000){\n comments.unshift(users[id].name+'you leave now!!!');\n delete users[id];\n \n \n }\n \n for (var i = 0; i \u003c comments.length; i++) {\n print(comments[i], 100, 30+i*30, \"black\", 30);\n }\n});\n\nwhen(\"click\", function() {\n var text = prompt(\"what do you whant to say?\");\n if (text == \"\" || text == null) return;\n\n var time = new Date();\n time = time.toLocaleTimeString();\n\n var msg = `[${time}] ${name}:${text}`;\n comments.unshift(\"you\"+msg);\n DB.broadcast(`message`, msg);\n});\n\nDB.onMessage(\"massage\", function(data) {\n comments.unshift(\"@\"+data);\n});\n\nDB.onMessage(\"update\", function(otherUser){\n users[otherUser.id] \n});\n\n\n\n\n\n\n\n\n\n\n","created_at":"2019-06-22T10:12:26.741+08:00","updated_at":"2019-10-07T08:18:31.104+08:00","name":"聊天室 副本","language":"javascript","screenshot":{"url":"https://cdn3.koding.school/uploads/project/screenshot/73838/7ab6361a1fc1df07e2be542867b07ee6.jpg"},"parent_id":34007,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":77,"hashid":"4y3swj2z","is_content_changed":false,"review_status":"unsubmitted","submitted_at":null,"reviewed_at":null,"advise":null,"is_deleted":false}
[]
橘蘋學習平台
我的作品
檢視專案頁
匯出
複製
匯入
刪除
下載 Android APP (APK)
截圖
繁中
简中
English
日本語
1:1:1
1:1
全寬
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦
用手機掃描下方 QRCode 進行安裝
或您也可以
下載 APK
到這台電腦