diff --git a/2020/yhr/todolist1/css/main.css b/2020/yhr/todolist1/css/main.css new file mode 100644 index 0000000..0c938f7 --- /dev/null +++ b/2020/yhr/todolist1/css/main.css @@ -0,0 +1,32 @@ +body { + background-color:rgb(32,32,32); + margin: 0%; +} +table { + text-align: center; + border:1; + border-collapse: collapse; +} +tr{ + height:20px; +} +a { + display: inline-block; + margin: 3px 5px; +} +input{ + width:98%; + border-radius: 15px; + text-indent: 5px; +} +._head{ + width:100%; + height:35px; + background-color: darkcyan; +} +.maindiv{ + margin:0 auto; + width: 1000px; + color: white; + text-align: center; +} \ No newline at end of file diff --git a/2020/yhr/todolist1/index.html b/2020/yhr/todolist1/index.html new file mode 100644 index 0000000..5203d2b --- /dev/null +++ b/2020/yhr/todolist1/index.html @@ -0,0 +1,33 @@ + + + + | Todolist | + + + + + + + +
+

 Todolist

+
+
+
+ + + + + + + + + + + +

things to do

deadline

+
+ +
+ + \ No newline at end of file diff --git a/2020/yhr/todolist1/js/read.js b/2020/yhr/todolist1/js/read.js new file mode 100644 index 0000000..77ccbc8 --- /dev/null +++ b/2020/yhr/todolist1/js/read.js @@ -0,0 +1,20 @@ +window.onload=function(){ + btn_addrow = document.getElementById("btn_addrow"); + btn_addrow.onclick = function(){ + addRow(); + } + var _request=new XMLHttpRequest(); + _request.open("get","../json/data.json"); + _request.onload=function(){ + if(_request.status==200){ + var _json=JSON.parse(_request.responseText); + var obj=getElementById("main"); + for(var i=1;i<=Object.keys(_json.lines);i++) + { + var line=document.createElement("tr"); + line.innerHTML=""+i+""+line.things[i]+""+line.times[i]+"savedelete"; + line.append(str); + } + } + } +} \ No newline at end of file diff --git a/2020/yhr/todolist1/js/table.js b/2020/yhr/todolist1/js/table.js new file mode 100644 index 0000000..70e1415 --- /dev/null +++ b/2020/yhr/todolist1/js/table.js @@ -0,0 +1,67 @@ +$(function(){ + registerClick(); +}); +function registerClick(){ + $("#main tbody tr td a").off("click").on("click", function(){ + var text = $(this).text(); + switch(text){ + case "change": + updateRow($(this)); + break; + case "save": + saveRow($(this)); + break; + case "delete": + deleteRow($(this)); + break; + } + }); +} +function addRow(){ + var rowindex = $("#main tbody tr").length+1; + var str = document.createElement("tr"); + str.innerHTML=""+rowindex+"savedelete"; + $("#main tbody").append(str); + registerClick(); + saveAllRow(); +} +function updateRow(t){ + $(t).text("save"); + var tr = $(t).parent().parent(); + var tds = $(tr).children(); + for (var i = 0; i < tds.length; i++) { + if(i>0 && i"); + } + } +} +function saveRow(t){ + $(t).text("change"); + var tr = $(t).parent().parent(); + var tds = $(tr).children(); + for (var i = 0; i < tds.length; i++) { + if(i>0 && i : + https://blog.csdn.net/qq_37902949/article/details/81056551 + https://blog.csdn.net/summerhmy/article/details/82892271 + ·The meaning of '$' in javascript: + https://blog.csdn.net/qq_42618969/article/details/88569385 + ·What is jQuery and how to use it: + https://m.runoob.com/jquery/jquery-tutorial.html + ·How to read and write .json files: + https://jingyan.baidu.com/article/22a299b56abc04de18376a54.html + https://www.cnblogs.com/liutianzeng/p/10483449.html \ No newline at end of file