{"id":50406,"student_id":10,"content":"{\"html\":\"\u003c!DOCTYPE html\u003e\\n\u003chtml\u003e\\n\u003chead\u003e\\n\\t\u003ctitle\u003eDocument\u003c/title\u003e\\n\\t\u003clink rel=\\\"stylesheet\\\" href=\\\"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css\\\"\u003e\\n\u003c/head\u003e\\n\u003cbody class=\\\"p-3\\\"\u003e\\n \u003cp class=\\\"js-chatbox\\\"\u003e\\n \u003c/p\u003e\\n \u003cinput class=\\\"form-control js-input\\\" placeholder=\\\"是/不是/不知道\\\" value=\\\"\\\"\u003e\\n\u003c/body\u003e\\n\u003c/html\u003e\",\"css\":\"p {\\n height: calc(100vh - 100px);\\n overflow: scroll;\\n color: #444;\\n}\",\"js\":\"var data = {\\n \\\"陳水扁\\\": {\\n is: [\\\"政治人物\\\", \\\"做過總統\\\", \\\"辯論之王\\\"],\\n not: [\\\"國民黨\\\", \\\"美國人\\\"]\\n },\\n \\\"柯文哲\\\": {\\n is: [\\\"做過醫生\\\", \\\"白色力量\\\", \\\"台北市長\\\", \\\"常常抓頭\\\", \\\"戴眼鏡\\\"],\\n not: [\\\"國民黨\\\", \\\"台中市長\\\", \\\"日本人\\\"]\\n },\\n \\\"蔡英文\\\": {\\n is: [\\\"做過總統\\\", \\\"民進黨\\\", \\\"戴眼鏡\\\"],\\n not: [\\\"國民黨\\\"]\\n },\\n \\\"馬英九\\\": {\\n is: [\\\"國民黨\\\", \\\"水母\\\", \\\"死亡之握\\\"],\\n not: [\\\"民進黨\\\"]\\n }\\n}\\n\\nvar tags = getTags(data).sort((a, b) =\u003e a.count - b.count );\\nvar q = currentTag = tags.pop();\\nsay('他是' + q.attr + '嗎?');\\n\\n\\nfunction ask (s) {\\n for (var name in data) {\\n if (s == '是' \u0026\u0026 data[name].not.indexOf(currentTag.attr) != -1) {\\n delete data[name];\\n }\\n if (s == '不是' \u0026\u0026 data[name].is.indexOf(currentTag.attr) != -1) {\\n delete data[name];\\n }\\n }\\n \\n var size = 0;\\n for (var name in data) {\\n size++;\\n }\\n \\n if (size == 1) {\\n for (var name in data) {\\n say('我知道了是' + name + '對吧!');\\n }\\n } else if (size \u003c= 0) {\\n say('我不知道,你能告訴我嗎?');\\n }else {\\n var q = currentTag = tags.pop();\\n say('他是' + q.attr + '嗎?');\\n }\\n}\\n\\n\\n\\n\\n\"}","created_at":"2018-11-27T15:43:48.139+08:00","updated_at":"2019-11-11T09:10:08.286+08:00","name":"阿拉丁","language":"web","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/50406/3295d25f98a4cbe1b88c5457f113bed6.jpg"},"parent_id":50404,"plugin":"var input = document.querySelector('.js-input');\nvar chatbox = document.querySelector('.js-chatbox');\n\ninput.addEventListener('keydown', function (e) {\n // enter\n if (e.keyCode === 13) {\n var q = input.value;\n // if (q.length == '') return;\n chatbox.innerHTML += '你 \u003e ' + q + '\u003cbr\u003e';\n setTimeout(function () {\n var res = ask(q);\n chatbox.scrollTop = chatbox.scrollHeight;\n }, 500);\n input.value = '';\n\n }\n});\n\nfunction say (something) {\n chatbox.innerHTML += '你 \u003e ' + something + '\u003cbr\u003e';\n}\n\nfunction getTags (data) {\n var counts = {};\n var tags = [];\n for (var name in data) {\n var person = data[name];\n person.is.forEach((attr) =\u003e {\n if (counts[attr]) counts[attr]++;\n else counts[attr] = 1;\n });\n person.not.forEach((attr) =\u003e {\n if (counts[attr]) counts[attr]++;\n else counts[attr] = 1;\n });\n }\n for (var attr in counts) {\n tags.push({attr: attr, count: counts[attr]});\n }\n return tags;\n}","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":327,"hashid":"4y3s92rr","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
到這台電腦