window.dataLayer = window.dataLayer || []; function gtag() { dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', 'G-NPSEEVD756'); var path = window.location.pathname var cookie = getCookie("lastPath"); console.log(path) if (path.replace("/", "") === "") { if (cookie.replace("/", "") !== "") { console.log(cookie) document.getElementById("tip").innerHTML = "跳转到上次进度" } } else { setCookie("lastPath", path) } window.onload = function () { var title = document.title var ele = document.getElementById(title + ".md"); if (ele) { ele.classList.add("current-tab") } var eleList = document.getElementsByClassName("menu-item") for (var i = 0; i < eleList.length; i++) { //遍历数组 if (eleList[i].id.startsWith(title) && i > 0) { document.getElementById("prePage").innerHTML = "上一页" } if (eleList[i].id.startsWith(title) && i < eleList.length) { document.getElementById("nextPage").innerHTML = "下一页" } } } function setCookie(cname, cvalue) { var d = new Date(); d.setTime(d.getTime() + (180 * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toGMTString(); document.cookie = cname + "=" + cvalue + "; " + expires + ";path = /"; } function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i].trim(); if (c.indexOf(name) === 0) return c.substring(name.length, c.length); } return ""; } hljs.initHighlightingOnLoad() function add_inner() { let inner = document.querySelector('.sidebar-toggle-inner') inner.classList.add('show') } function remove_inner() { let inner = document.querySelector('.sidebar-toggle-inner') inner.classList.remove('show') } function sidebar_toggle() { let sidebar_toggle = document.querySelector('.sidebar-toggle') let sidebar = document.querySelector('.book-sidebar') let content = document.querySelector('.off-canvas-content') if (sidebar_toggle.classList.contains('extend')) { // show sidebar_toggle.classList.remove('extend') sidebar.classList.remove('hide') content.classList.remove('extend') } else { // hide sidebar_toggle.classList.add('extend') sidebar.classList.add('hide') content.classList.add('extend') } } function open_sidebar() { let sidebar = document.querySelector('.book-sidebar') let overlay = document.querySelector('.off-canvas-overlay') sidebar.classList.add('show') overlay.classList.add('show') } function hide_canvas() { let sidebar = document.querySelector('.book-sidebar') let overlay = document.querySelector('.off-canvas-overlay') sidebar.classList.remove('show') overlay.classList.remove('show') }