Diff
checker
文本
文本
图像
文档
Excel
文件夹
Legal
Enterprise
桌面版
定价
登录
下载 Diffchecker 桌面版
比较文本
查找两个文本文件之间的差异
工具
历史
实时编辑器
隐藏空白更改
折叠未更改行
关闭换行
视图
拆分
统一
比对精度
智能
单词
字符
文本样式
更改外观
语法高亮
选择语法
忽略
文本转换
转到第一个差异
编辑输入
Diffchecker Desktop
运行Diffchecker最安全的方式。获取Diffchecker桌面应用:您的差异永远不会离开您的电脑!
获取桌面版
invoice-code-update
创建于
2年前
差异永不过期
清除
导出
分享
解释
15 删除
行
总计
删除
字符
总计
删除
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
80 行
全部复制
20 添加
行
总计
添加
字符
总计
添加
要继续使用此功能,请升级到
Diff
checker
Pro
查看价格
82 行
全部复制
import { v4 as uuidv4 } from 'uuid'
import { v4 as uuidv4 } from 'uuid'
const washCarBtn = document.getElementById("wash-car-btn")
const washCarBtn = document.getElementById("wash-car-btn")
const mowLawnBtn = document.getElementById("mow-lawn-btn")
const mowLawnBtn = document.getElementById("mow-lawn-btn")
const pullWeedsBtn = document.getElementById("pull-weeds-btn")
const pullWeedsBtn = document.getElementById("pull-weeds-btn")
const taskP = document.getElementById("tasks")
const taskP = document.getElementById("tasks")
const totalH2 = document.getElementById("total-amount")
const totalH2 = document.getElementById("total-amount")
let total = []
let total = []
let tasks = [{
let tasks = [{
"task": "Wash Car",
"task": "Wash Car",
"total": 10
"total": 10
},
},
{"task": "Mow Lawn",
{"task": "Mow Lawn",
"total": 20
"total": 20
},
},
{"task": "Pull Weeds",
{"task": "Pull Weeds",
"total": 30
"total": 30
}]
}]
washCarBtn.addEventListener("click", function(){
washCarBtn.addEventListener("click", function(){
复制
已复制
复制
已复制
const id = uuidv4(); // Generate a unique id
taskP.innerHTML += `
taskP.innerHTML += `
<div class = "outer-task-total-div">
<div class = "outer-task-total-div">
<div class = "task-total-div">
<div class = "task-total-div">
<p>${tasks[0].task}</p>
<p>${tasks[0].task}</p>
<p>$${tasks[0].total}</p>
<p>$${tasks[0].total}</p>
</div>
</div>
复制
已复制
复制
已复制
<p class = "remove-btn" data-
share = ${tasks[0].task}
>Remove</p>
<p class = "remove-btn" data-
id="${id}"
>Remove</p>
</div>`
</div>`
复制
已复制
复制
已复制
total.push({id:
uuidv4()
, total: tasks[0].total})
total.push({id:
id
, total: tasks[0].total})
render()
render()
})
})
mowLawnBtn.addEventListener("click", function(){
mowLawnBtn.addEventListener("click", function(){
复制
已复制
复制
已复制
const id = uuidv4(); // Generate a unique id
taskP.innerHTML += `
taskP.innerHTML += `
<div class = "outer-task-total-div">
<div class = "outer-task-total-div">
<div class = "task-total-div">
<div class = "task-total-div">
<p>${tasks[1].task}</p>
<p>${tasks[1].task}</p>
<p>$${tasks[1].total}</p>
<p>$${tasks[1].total}</p>
</div>
</div>
复制
已复制
复制
已复制
<p class = "remove-btn" data-
share = ${tasks[1].task}
>Remove</p>
<p class = "remove-btn" data-
id="${id}"
>Remove</p>
</div>`
</div>`
复制
已复制
复制
已复制
total.push({id:
uuidv4()
, total: tasks[1].total})
total.push({id:
id
, total: tasks[1].total})
render()
render()
})
})
pullWeedsBtn.addEventListener("click", function(){
pullWeedsBtn.addEventListener("click", function(){
复制
已复制
复制
已复制
const id = uuidv4(); // Generate a unique id
taskP.innerHTML += `
taskP.innerHTML += `
<div class = "outer-task-total-div">
<div class = "outer-task-total-div">
<div class = "task-total-div">
<div class = "task-total-div">
<p>${tasks[2].task}</p>
<p>${tasks[2].task}</p>
<p>$${tasks[2].total}</p>
<p>$${tasks[2].total}</p>
</div>
</div>
复制
已复制
复制
已复制
<p class = "remove-btn" data-
share = ${tasks[2].task}
>Remove</p>
<p class = "remove-btn" data-
id="${id}"
>Remove</p>
</div>`
</div>`
复制
已复制
复制
已复制
total.push({id:
uuidv4()
, total: tasks[2].total})
total.push({id:
id
, total: tasks[2].total})
render()
render()
})
})
function render(){
function render(){
const totalAmount = total.reduce((accumulator, currentValue) => {
const totalAmount = total.reduce((accumulator, currentValue) => {
复制
已复制
复制
已复制
return accumulator + currentValue.total
}, 0);
return accumulator + currentValue.total
;
}, 0);
totalH2.innerHTML = `$${totalAmount}`
totalH2.innerHTML = `$${totalAmount}`
}
}
document.addEventListener("click", function(e){
document.addEventListener("click", function(e){
复制
已复制
复制
已复制
if (e.target.dataset.
share){
if (e.target.dataset.
id) {
e.target.parentElement.remove()
const id = e.target.dataset.id; // Get the id from the dataset
e.target.parentElement.remove()
;
removeItem(id); // Call the remove function to update the total array
render(); // Recalculate the total
}
}
})
})
复制
已复制
复制
已复制
function removeItem(id) {
//HELP! Need help getting this function working to remove the removed items from totals array
function removeItem(id) {
total = total.filter(item => item.id !== id); // Filter out the item with the matching id
const index = total.indexOf(id);
}
if (index !== -1) {
total.splice(index, 1);
}
return total;
已保存差异
原始文本
打开文件
import { v4 as uuidv4 } from 'uuid' const washCarBtn = document.getElementById("wash-car-btn") const mowLawnBtn = document.getElementById("mow-lawn-btn") const pullWeedsBtn = document.getElementById("pull-weeds-btn") const taskP = document.getElementById("tasks") const totalH2 = document.getElementById("total-amount") let total = [] let tasks = [{ "task": "Wash Car", "total": 10 }, {"task": "Mow Lawn", "total": 20 }, {"task": "Pull Weeds", "total": 30 }] washCarBtn.addEventListener("click", function(){ taskP.innerHTML += ` <div class = "outer-task-total-div"> <div class = "task-total-div"> <p>${tasks[0].task}</p> <p>$${tasks[0].total}</p> </div> <p class = "remove-btn" data-share = ${tasks[0].task}>Remove</p> </div>` total.push({id: uuidv4(), total: tasks[0].total}) render() }) mowLawnBtn.addEventListener("click", function(){ taskP.innerHTML += ` <div class = "outer-task-total-div"> <div class = "task-total-div"> <p>${tasks[1].task}</p> <p>$${tasks[1].total}</p> </div> <p class = "remove-btn" data-share = ${tasks[1].task}>Remove</p> </div>` total.push({id: uuidv4(), total: tasks[1].total}) render() }) pullWeedsBtn.addEventListener("click", function(){ taskP.innerHTML += ` <div class = "outer-task-total-div"> <div class = "task-total-div"> <p>${tasks[2].task}</p> <p>$${tasks[2].total}</p> </div> <p class = "remove-btn" data-share = ${tasks[2].task}>Remove</p> </div>` total.push({id: uuidv4(), total: tasks[2].total}) render() }) function render(){ const totalAmount = total.reduce((accumulator, currentValue) => { return accumulator + currentValue.total}, 0); totalH2.innerHTML = `$${totalAmount}` } document.addEventListener("click", function(e){ if (e.target.dataset.share){ e.target.parentElement.remove() } }) function removeItem(id) { //HELP! Need help getting this function working to remove the removed items from totals array const index = total.indexOf(id); if (index !== -1) { total.splice(index, 1); } return total;
更改后文本
打开文件
import { v4 as uuidv4 } from 'uuid' const washCarBtn = document.getElementById("wash-car-btn") const mowLawnBtn = document.getElementById("mow-lawn-btn") const pullWeedsBtn = document.getElementById("pull-weeds-btn") const taskP = document.getElementById("tasks") const totalH2 = document.getElementById("total-amount") let total = [] let tasks = [{ "task": "Wash Car", "total": 10 }, {"task": "Mow Lawn", "total": 20 }, {"task": "Pull Weeds", "total": 30 }] washCarBtn.addEventListener("click", function(){ const id = uuidv4(); // Generate a unique id taskP.innerHTML += ` <div class = "outer-task-total-div"> <div class = "task-total-div"> <p>${tasks[0].task}</p> <p>$${tasks[0].total}</p> </div> <p class = "remove-btn" data-id="${id}">Remove</p> </div>` total.push({id: id, total: tasks[0].total}) render() }) mowLawnBtn.addEventListener("click", function(){ const id = uuidv4(); // Generate a unique id taskP.innerHTML += ` <div class = "outer-task-total-div"> <div class = "task-total-div"> <p>${tasks[1].task}</p> <p>$${tasks[1].total}</p> </div> <p class = "remove-btn" data-id="${id}">Remove</p> </div>` total.push({id: id, total: tasks[1].total}) render() }) pullWeedsBtn.addEventListener("click", function(){ const id = uuidv4(); // Generate a unique id taskP.innerHTML += ` <div class = "outer-task-total-div"> <div class = "task-total-div"> <p>${tasks[2].task}</p> <p>$${tasks[2].total}</p> </div> <p class = "remove-btn" data-id="${id}">Remove</p> </div>` total.push({id: id, total: tasks[2].total}) render() }) function render(){ const totalAmount = total.reduce((accumulator, currentValue) => { return accumulator + currentValue.total; }, 0); totalH2.innerHTML = `$${totalAmount}` } document.addEventListener("click", function(e){ if (e.target.dataset.id) { const id = e.target.dataset.id; // Get the id from the dataset e.target.parentElement.remove(); removeItem(id); // Call the remove function to update the total array render(); // Recalculate the total } }) function removeItem(id) { total = total.filter(item => item.id !== id); // Filter out the item with the matching id }
查找差异