{"id":113950,"student_id":234,"content":"","created_at":"2019-12-14T11:32:42.712+08:00","updated_at":"2019-12-14T11:32:42.712+08:00","name":"聊天室 DEMO 副本","language":"javascript","screenshot":{"url":null},"parent_id":17268,"plugin":"var comments = [];\nvar name = prompt('名字?') || '匿名';\nvar id = Math.floor(Math.random()*1000000);\nvar users = {};\n\nusers[id] = {\n id: id,\n name: name,\n time: Date.now()\n}\n\nforever(function(){\n\n users[id].time = Date.now();\n DB.broadcast('update', users[id]);\n\n for (var i=0; i\u003ccomments.length; i++) {\n print(comments[i], 150, 20*i + 10);\n }\n\n print('===在線使用者===');\n var i=0;\n for (var _ in users) {\n i++;\n print(users[_].name, 10, 10 + 20*i);\n if (Date.now() \u003e users[_].time + 5000) {\n addMsg(users[_].name + '離開了聊天室');\n delete users[_];\n }\n }\n});\n\nwhen('click', function () {\n var msg = name + ':' + prompt('?')\n addMsg(msg);\n DB.broadcast('message', msg);\n})\n\nDB.onMessage('update', function (data) {\n if (users[data.id] == undefined) {\n addMsg(data.name + '加入了聊天室');\n }\n users[data.id] = data;\n});\n\nDB.onMessage('message', function (data) {\n addMsg(data);\n});\n\nfunction addMsg (str) {\n comments.unshift('【' + (new Date).toLocaleTimeString() + '】' + str);\n}","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":78,"hashid":"rdvsrzgd","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
到這台電腦