{"id":66546,"student_id":10,"content":"{\"html\":\"\u003c!DOCTYPE html\u003e\\n\u003chtml\u003e\\n\u003chead\u003e\\n\\t\u003ctitle\u003eDocument\u003c/title\u003e\\n\\t\u003cscript src=\\\"https://code.jquery.com/jquery-3.2.1.slim.min.js\\\"\u003e\u003c/script\u003e\\n\\t\u003cscript src=\\\"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.bundle.min.js\\\"\u003e\u003c/script\u003e\\n\u003c/head\u003e\\n\u003cbody\u003e\\n 新增選項\\n \u003cinput id=\\\"text\\\"/\u003e\\n \u003cbutton id=\\\"add\\\"\u003e新增\u003c/button\u003e\\n \u003ch2 id=\\\"\\\"\u003e誰要當班長?\u003c/h2\u003e\\n \u003col\u003e\\n \u003c/ol\u003e\\n \u003ccanvas id=\\\"canvas\\\"\u003e\\n \u003c/canvas\u003e\\n\u003c/body\u003e\\n\u003c/html\u003e\",\"css\":\"\",\"js\":\"var vote = DB.table('vote');\\n\\nupdate();\\n\\n$('#add').click(function () {\\n var name = $('#text').val(); \\n vote.insert({ name: name });\\n update();\\n});\\n\\n$('ol').on('click', 'button', function () {\\n var name = $(this).data('name');\\n vote.insert({ name: name });\\n update();\\n});\\n\\nfunction update () {\\n $('ol').html('');\\n vote.find({}, function (data) {\\n var options = {}\\n \\n for (var i=0; i\u003cdata.length; i++) {\\n var name = data[i].name;\\n if (options[name] != undefined) {\\n options[name] += 1;\\n } else {\\n options[name] = 1;\\n }\\n }\\n \\n for (name in options) {\\n addOption(name, options[name]);\\n }\\n \\n updateChart(options);\\n });\\n}\\n\\nfunction addOption (name, number) {\\n var html = `\\n \u003cli\u003e\\n ${name}(${number}票)\\n \u003cbutton data-name=\\\"${name}\\\"\u003e投你!\u003c/button\u003e\\n \u003c/li\u003e\\n `\\n $('ol').append(html);\\n}\\n\\nfunction updateChart (data) {\\n var names = [];\\n var count = [];\\n for (var key in data) {\\n names.push(key);\\n count.push(data[key]);\\n }\\n var ctx = $('#canvas')[0].getContext('2d');\\n new Chart(ctx, {\\n type: 'bar',\\n data: {\\n labels: names,\\n datasets: [{\\n data: [0, 10, 5, 2, 20, 30, 45]\\n }]\\n },\\n });\\n}\\n\"}","created_at":"2019-05-09T16:57:47.624+08:00","updated_at":"2019-11-11T22:15:28.725+08:00","name":"投票 v1","language":"web","screenshot":{"url":"https://cdn1.koding.school/uploads/project/screenshot/66546/d65893dbdf89098578053cd0f72296b9.jpg"},"parent_id":66538,"plugin":"","description":null,"note":null,"status":"public","like_student_ids":[],"is_featured":false,"views":308,"hashid":"gk4smnee","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
到這台電腦