java30天学习笔记

杂项最好不使用 clone()来进行复制,可以使用拷贝构造函数或拷贝工厂来复制对象. 抽象类提供了⼀种 IS-A 的关系接⼝更像是⼀种 LIKE-A 关系 Fail-Fast 机制Fail-Fast 机制是 Java 集合(Collection)中的...

基础笔记
} // chat iphone time let phoneTimes = document.querySelectorAll('.chat .status-bar .time'); if (phoneTimes.length > 0) { NowTime(); var date = new Date(); var sec = date.getSeconds(); var firstAdjustInterval = setInterval(firstAdjustTime, 1000 * (60 - sec)); } function firstAdjustTime() { NowTime(); clearInterval(firstAdjustInterval); setInterval(NowTime, 1000 * 60); } function NowTime() { for (let i = 0; i < phoneTimes.length; ++i) { var timeSpan = phoneTimes[i]; var date = new Date(); var hour = date.getHours(); var min = date.getMinutes(); timeSpan.innerHTML = check(hour) + ":" + check(min); } }; function check(val) { if (val < 10) { return ("0" + val); } return (val); } // chat quote const chat_quote_obverser = new IntersectionObserver((entries, observer) => { entries.filter((entry) => { return entry.isIntersecting }).sort((a, b) => a.intersectionRect.y !== b.intersectionRect.y ? a.intersectionRect.y - b.intersectionRect.y : a.intersectionRect.x - b.intersectionRect.x).forEach((entry, index) => { observer.unobserve(entry.target); setTimeout(() => { entry.target.classList.add('quote-blink'); setTimeout(() => { entry.target.classList.remove('quote-blink'); }, 1000); }, Math.max(100, 16) * (index + 1)); }); }); var chatQuotes = document.querySelectorAll(".chat .talk .quote"); chatQuotes.forEach((quote) => { quote.addEventListener('click', function () { var chatCellDom = document.getElementById("quote-" + quote.getAttribute("quotedCellTag")); if (chatCellDom) { var chatDiv = chatCellDom.parentElement; var mid = chatDiv.clientHeight / 2; var offsetTop = chatCellDom.offsetTop; if (offsetTop > mid - chatCellDom.clientHeight / 2) { chatDiv.scrollTo({ top: chatCellDom.offsetTop - mid + chatCellDom.clientHeight / 2, behavior: "smooth" }); } else { chatDiv.scrollTo({ top: 0, behavior: "smooth" }); } chat_quote_obverser.observe(chatCellDom); } }); }); });