: Notes"> "> ">

NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bilge Adam Api Dersleri</title>
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
</head>

<body>
<div class="container">
<div class="row mt-5">
<div class="col-6">
<div class="card p-3">
<table class="table table-hover">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Statu</th>
<th>Options</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>

<div class="col-6">
<div class="card p-3">
<form>
<div class="mb-3">
<label for="todo" class="form-label">ToDo Name</label>
<input
type="text"
class="form-control"
id="todo"
aria-describedby="todoHelp"
/>
<div id="todoHelp" class="form-text">Please Give ToDo Item</div>
</div>
<button
id="btnSave"
type="button"
class="btn btn-outline-dark btn-sm"
>
<i class="fa fa-save"></i> Save
</button>
<button type="reset" class="btn btn-outline-danger btn-sm">
<i class="fa fa-trash"></i> Clear
</button>
</form>
</div>
</div>
</div>
</div>

<div
class="modal fade"
id="subItemModal"
tabindex="-1"
aria-labelledby="subItemModalLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title display-6" id="subItemModalLabel">
Modal title
</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<form id="frmSubItem">
<input type="hidden" id="masterId" />
<div class="mb-3 input-group-sm" id="group">
<div class="input-group input-group-sm mb-3">
<span class="input-group-text" id="inputGroup-sizing-sm"
><i class="fa fa-bookmark-o"></i
></span>
<input
name="subItem"
type="text"
class="form-control"
aria-label="Sizing example input"
aria-describedby="inputGroup-sizing-sm"
/>
</div>
</div>
<button
type="button"
id="btnAdd"
class="btn btn-sm btn-outline-info mt-2"
>
<i class="fa fa-plus"></i> Add
</button>
</form>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-outline-dark btn-sm"
data-bs-dismiss="modal"
>
Close
</button>
<button
id="btnSubItemSave"
type="button"
class="btn btn-outline-danger btn-sm"
>
Save
</button>
</div>
</div>
</div>
</div>

<div
class="modal fade"
id="listModal"
tabindex="-1"
aria-labelledby="listModalLabel"
aria-hidden="true"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title display-6" id="listModalLabel">
Yapılacaklar Listesi
</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<ul class="list-group list-group-flush" id="brucelee"></ul>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-outline-danger btn-sm"
data-bs-dismiss="modal"
>
Close
</button>
</div>
</div>
</div>
</div>

<script
src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js"
integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p"
crossorigin="anonymous"
></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF"
crossorigin="anonymous"
></script>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"
></script>

<script>
$(() => {
let _url = `http://localhost:5039/api/TodoItems`;
let _urlSubItem = `http://localhost:5039/api/TodoSubItems`;

const getTodos = () => {
let todoItems = [];

$.getJSON(_url, (data) => {
$.map(data, (item) => {
let result = item.isComplete;
let statu = ` <button class="btn btn-sm shadow-sm statu" data-id='${item.id}'> <i statu" data-id='${item.id}' class='text-success fa fa-check'> </i> </button> `;
todoItems.push(`<tr>
<td>${item.id}</td>
<td>${item.name}</td>
<td>
<i class='text-${
result === true ? "success" : "warning"
} ${
result === true ? "fa fa-check" : "fa fa-clock-o"
}'> </i>
</td>
<td>
${result === false ? statu : ""}
<button data-name='${item.name}' data-id='${
item.id
}' class="btn btn-sm shadow-sm subItem">
<i data-name='${item.name}' data-id='${
item.id
}' class='fa fa-plus text-primary '></i>
</button>
<button data-id='${
item.id
}' class="btn btn-sm shadow-sm details">
<i data-id='${
item.id
}' class='fa fa-list text-info '></i>
</button>
<button data-id='${
item.id
}' class="btn btn-sm shadow-sm delete">
<i data-id='${
item.id
}' class='fa fa-trash text-danger '></i>
</button>
</td>
</tr>`);
});
$("table tbody").html(todoItems);
});
};

// $("form>button[type='button'][id='btnSave']").click(() => {
$("#btnSave").click(() => {
$.ajax({
url: _url,
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
dataType: "json",
data: JSON.stringify({
id: 0,
name: $("#todo").val(),
isComplete: false,
}),
success: (e) => {
getTodos();
$("form")[0].reset();
},
error: (e) => console.log("error -> ", e),
});
});

$(document).on("click", ".statu", (e) => {
let id = $(e.target).data("id");

$.get(`${_url}/${id}`, (data) => {
$.ajax({
url: `${_url}/${id}`,
method: "PUT",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
dataType: "json",
data: JSON.stringify({
id: id,
name: data.name,
isComplete: true,
}),
success: (e) => {
getTodos();
$("form")[0].reset();
},
error: (e) => console.log("error -> ", e),
});
});
});

$(document).on("click", ".delete", (e) => {
let id = $(e.target).data("id");

$.get(`${_url}/${id}`, (data) => {
$.ajax({
url: `${_url}/${id}`,
method: "DELETE",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
dataType: "json",
success: (e) => {
getTodos();
$("form")[0].reset();
},
error: (e) => console.log("error -> ", e),
});
});
});

$(document).on("click", ".subItem", (e) => {
// ItemId
let id = $(e.target).data("id");
// ItemName
let name = $(e.target).data("name");

$("#subItemModal").modal("show");
$("#subItemModalLabel").text(name);
$("#masterId").val(id);
});

$("#btnAdd").click(() => {
let guid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
/[xy]/g,
function (c) {
var r = (Math.random() * 16) | 0,
v = c == "x" ? r : (r & 0x3) | 0x8;
return v.toString(16);
}
);

var template = `
<div class="input-group input-group-sm mb-3 frm-item">
<span class="input-group-text" id="inputGroup-sizing-sm"><i class=" fa fa-bookmark-o"></i></span>
<input name='subItem' type="text" class="form-control" aria-label="Sizing example input"
aria-describedby="inputGroup-sizing-sm">
</div>`;

$("#group").append(template);
});

$("#btnSubItemSave").click(() => {
let subItems = $("#frmSubItem").serializeArray();
let id = $("#masterId").val();

$.ajax({
url: `${_urlSubItem}/${id}`,
method: "POST",
data: JSON.stringify(subItems),
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
dataType: "json",
success: (e) => {
$(".frm-item").remove();
$("#frmSubItem")[0].reset();
$("#subItemModal").modal("hide");
},
error: (e) => console.log("error -> ", e),
});
});

$(document).on("click", ".details", (e) => {
let id = $(e.target).data("id");

$.get(`${_urlSubItem}/${id}`, (data) => {
let items = [];
$.map(data, (val) => {
items.push(`
<li class="list-group-item">
<div class='row'>
<div class='col-11'>
<div class="form-check">
<input ${
val.isComplete === true
? "checked disabled"
: ""
} data-id='${
val.id
}' class="form-check-input list-chk" type="checkbox" value="" id="list-${
val.id
}" >
<label class="form-check-label" for="list-${
val.id
}">
${val.name}
</label>
</div>
</div>
<div class='col-1'>
<button data-id='${
val.id
}' id='btn-delete-${
val.id
}' class='btn btn-sm shadow-sm list-item-delete'> <i data-id='${
val.id
}' class='fa fa-trash text-danger'></i></div>
</button>
</div>
</li>`);
});

$("#brucelee").html(items);
});
$("#listModal").modal("show");
});

$(document).on("click", ".list-item-delete", (e) => {
let id = $(e.target).data("id");
$.ajax({
url: `${_urlSubItem}/${id}`,
method: "DELETE",
success: (result) => {
let parent = $(e.target).parents("li");
parent.remove();
},
error: (result) => {},
});
});

$(document).on("change", ".list-chk", (e) => {
if ($(e.target).is(":checked")) {
let id = $(e.target).data("id");
$(e.target).prop("disabled", true);

$.ajax({
url: `${_urlSubItem}/${id}`,
method: "PUT",
success: (result) => {
let parent = $(e.target).parents("li");
},
error: (result) => {},
});

console.log($(e.target).parents("li").children("button"));
// $(`#btn-delete-${$(e.target).data('id')}`).prop('disabled', true)
$(`#btn-delete-${$(e.target).data("id")}`).remove();
}
});
getTodos();
});
</script>
</body>
</html>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.