{"id":36062,"student_id":1976,"content":"\nvar comments = [];\nvar name = prompt('What is your name ?') || 'Anonymous';\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 + 50);\n }\n\n print('===Online Users===');\n print('Click Screen to Start chatting !',230,10);\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 + 1000) {\n addMsg(users[_].name + ' leave the chat room.');\n delete users[_];\n }\n }\n});\n\nwhen('click', function () {\n var msg = name + ':' + prompt('What do your want to say ?')\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 + ' join the chat room.');\n }\n users[data.id] = data;\n});\n\nDB.onMessage('message', function (data) {\n comments.unshift('【' + (new Date).toLocaleTimeString('en-US') + '】' + data);\n});\n\nfunction addMsg (str) {\n comments.unshift('【' + (new Date).toLocaleTimeString('en-US') + '】' + str);\n}\n","created_at":"2018-07-23T00:47:04.330+08:00","updated_at":"2019-10-26T22:29:15.109+08:00","name":"Chat Room","language":"javascript","screenshot":{"url":"https://cdn4.koding.school/uploads/project/screenshot/36062/2af7b96d760d7c8ef38b85c5c90890fa.jpg"},"parent_id":34007,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":374,"hashid":"882sn8ge","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
到這台電腦