6 作業

index.js 檔案中,第一行先放入以下:

var user_id = 1; // 自己的座號

初始載入時,顯示 loading icon:

$("ul.task_list").html('<li style="text-align: center;"><i class="fas fa-spinner fa-spin fa-3x"></i></li>');

GET: 取得待辦事項列表

GET https://notes.webmix.cc/ajax/teach/api/list.php

取得待辦事清的清單列表。

Path Parameters

Name
Type
Description

user_id*

string

自己的座號,例:1

[
  {
    "item_id": "abc",
    "name":"dddda",
    "star":0,
    "sort":1
  },
  {
    "item_id": "abc123",
    "name":"dddd",
    "star":0,
    "sort":1
  }
]

POST: 新增待辦事項

POST https://notes.webmix.cc/ajax/teach/api/add.php

輸入欲新增的待辦事項。

Request Body

Name
Type
Description

user_id*

string

自己的座號,例:1

name*

string

待辦事項的文字

新增資料與顯示資料結果:

DELETE: 移除單筆待辦事項

DELETE https://notes.webmix.cc/ajax/teach/api/delete_item.php

移除單筆待辦事項

Request Body

Name
Type
Description

user_id*

string

自己的座號,例:1。

item_id*

string

待辦事項的id。

DELETE: 清空所有待辦事項

DELETE https://notes.webmix.cc/ajax/teach/api/delete_all.php

清空所有待辦事項。

Request Body

Name
Type
Description

user_id*

string

自己的座號,例:1。

星號更新的注意事項

加上以下的 css:

串接 API 之前,執行:

串接 API 之後,執行:

PATCH: 更新待辦事項的星號

PATCH https://notes.webmix.cc/ajax/teach/api/patch_star.php

更新待辦事項的星號。

Request Body

Name
Type
Description

user_id*

string

自己的座號,例:1。

item_id*

string

待辦事項的id。

star*

string

星號數字。

撰寫排序的注意事項

  • 需將排序的 API 部份,寫在另一個函式。

  • 在 css 檔的 article.task_container 樣式,加上一行:position: relative;

串接 API 之前,執行:

串接 API 之後,執行:

PATCH: 更新待辦事項的排序

PATCH https://notes.webmix.cc/ajax/teach/api/patch_sort.php

Request Body

Name
Type
Description

user_id*

string

自己的座號,例:1。

item_id*

string

待辦事項id。

direction*

string

up 或 down。

PUT: 更新單筆待辦事項當中,所用者所打的字。

PUT https://notes.webmix.cc/ajax/teach/api/update_item.php

更新的資料:使用者所打的字。

Request Body

Name
Type
Description

user_id*

string

自己的座號,例:1。

item_id*

string

待辦事項id。

name*

string

待辦事項文字。

完成示意

Java 班先下載

完成版的 JS 版本(未串接 API): https://alldata.sgp1.digitaloceanspaces.com/sample/assignment_js_only.ziparrow-up-right

Last updated