diff --git a/css/obsidian.css b/css/obsidian.css index cfe1a3c..dbec5f9 100644 --- a/css/obsidian.css +++ b/css/obsidian.css @@ -1240,6 +1240,7 @@ footer .copyright a { background-color: #201c29; margin: calc(28.87px + 1rem) 1rem; transition: all 500ms ease-in-out; + padding: 0; } .category-list .category-list-item.active { z-index: 11; @@ -2438,8 +2439,12 @@ h1.title { .else .md-content ul li { list-style: none; margin: 5px 0; + position: relative; + padding: 0 0 0 1em; } .else .md-content ul li:before { + position: absolute; + left: 0; content: "•"; margin: 0 1rem 0 0; color: var(--secondary); @@ -2448,7 +2453,7 @@ h1.title { margin-left: 1em; } .else .md-content ol { - margin: 0 0 2rem 0; + margin: 0 0 2rem 1rem; padding-left: 20px; counter-reset: li; padding-inline-start: 0; @@ -2457,8 +2462,10 @@ h1.title { list-style: none; margin: 5px 0; counter-increment: li; + position: relative; } .else .md-content ol li:before { + position: absolute; content: counter(li); color: var(--secondary); display: inline-block; @@ -2752,8 +2759,12 @@ h1.title { .content ul li { list-style: none; margin: 5px 0; + position: relative; + padding: 0 0 0 1em; } .content ul li:before { + position: absolute; + left: 0; content: "•"; margin: 0 1rem 0 0; color: var(--dark); @@ -2770,11 +2781,13 @@ h1.title { list-style: none; margin: 5px 0; counter-increment: li; + position: relative; } .content ol li:before { content: counter(li); color: var(--dark); display: inline-block; + position: absolute; width: 1em; margin-left: -1.5em; margin-right: 0.5em; diff --git a/js/obsidian.js b/js/obsidian.js index 38833d5..d6d6207 100644 --- a/js/obsidian.js +++ b/js/obsidian.js @@ -15,13 +15,12 @@ */ function scrollSpy(menuSelector, options) { var menu = $(menuSelector); - if (!menu) - return; + if (!menu) return; options = options || {}; var offset = options.offset || 0; - var activeClassName = options.activeClassName || "active"; + var activeClassName = options.activeClassName || 'active'; - var scollTarget = $(".content :header").find("a.headerlink"), + var scollTarget = $('.content :header').find('a.headerlink'), lastId = null, active = $(); @@ -30,18 +29,25 @@ function scrollSpy(menuSelector, options) { var fromTop = $(this).scrollTop() + offset; // Get id of current scroll item - var id = scollTarget.prevObject.filter(function () { - return $(this).offset().top < fromTop; - }).last().attr("id") || ""; + var id = + scollTarget + .prevObject.filter(function () { + return $(this).offset().top < fromTop; + }) + .last() + .attr('id') || ''; if (lastId !== id) { active.removeClass(activeClassName); var newActive = []; - for (var target = menu.find("[href='#" + id + "']"); target.length && !target.is(menu); target = target.parent()) { - if (target.is("li")) - newActive.push(target[0]); + for ( + var target = menu.find("[href='#" + id + "']"); + target.length && !target.is(menu); + target = target.parent() + ) { + if (target.is('li')) newActive.push(target[0]); } - active = $(newActive).addClass(activeClassName).trigger("scrollspy"); + active = $(newActive).addClass(activeClassName).trigger('scrollspy'); lastId = id; } }); @@ -52,7 +58,7 @@ function scrollSpy(menuSelector, options) { */ function utiliseBgColor() { setTimeout(function () { - if ($("#single").length) { + if ($('#single').length) { $('html').css('background', '#fff'); } else { $('html').css('background', '#100e17'); @@ -61,14 +67,21 @@ function utiliseBgColor() { } /** - * Buidling the caption html in an aritle + * Building the caption html in an article */ function buildImgCaption() { var images = $('.content').find('img'); + var usedCaption = []; images.each(function () { var caption = $(this).attr('alt'); - $('.content').find("[alt='" + caption + "']").parent().append('

"' + caption + '"

'); + if (caption !== '' && usedCaption.indexOf(caption) < 0) { + $('.content') + .find("[alt='" + caption + "']") + .parent() + .append('

"' + caption + '"

'); + usedCaption.push(caption); + } }); } @@ -101,7 +114,7 @@ var Obsidian = { window.location.href = url; } xhrUrl = ''; - } + }, }); }, P: function () { @@ -111,10 +124,14 @@ var Obsidian = { if (!(window.history && history.pushState)) { return; } - history.replaceState({ - u: Home, - t: document.title - }, document.title, Home); + history.replaceState( + { + u: Home, + t: document.title, + }, + document.title, + Home + ); window.addEventListener('popstate', function (e) { var state = e.state; if (!state) return; @@ -147,14 +164,14 @@ var Obsidian = { HS: function (tag, flag) { var id = tag.data('id') || 0, url = tag.attr('href'), - title = tag.attr('title') + " - " + $("#config-title").text(); + title = tag.attr('title') + ' - ' + $('#config-title').text(); if (!$('#preview').length || !(window.history && history.pushState)) location.href = url; Obsidian.loading(); var state = { d: id, t: title, - u: url + u: url, }; Obsidian.L(url, function (data) { if (!$(data).filter('#single').length) { @@ -186,7 +203,7 @@ var Obsidian = { setTimeout(function () { Obsidian.player(); $('#top').show(); - comment = $("#gitalk-container"); + comment = $('#gitalk-container'); if (comment.data('ae') == true) { comment.click(); } @@ -195,21 +212,24 @@ var Obsidian = { }, preview: function () { // preview toggle - $("#preview").one('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function () { - var previewVisible = $('#preview').hasClass('show'); - if (!!previewVisible) { - $('#container').hide(); - } else { - $('#container').show(); + $('#preview').one( + 'transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', + function () { + var previewVisible = $('#preview').hasClass('show'); + if (!!previewVisible) { + $('#container').hide(); + } else { + $('#container').show(); + } + Obsidian.loaded(); } - Obsidian.loaded(); - }); + ); setTimeout(function () { $('#preview').addClass('show'); $('#container').data('scroll', window.scrollY); setTimeout(function () { $('#preview').css({ - 'position': 'static', + position: 'static', // 'overflow-y': 'auto' }); Obsidian.initArticleJs(); @@ -220,25 +240,25 @@ var Obsidian = { var p = $('#audio'); if (!p.length) { $('.icon-play').css({ - 'color': '#dedede', - 'cursor': 'not-allowed' + color: '#dedede', + cursor: 'not-allowed', }); return; } - var sourceSrc = $("#audio source").eq(0).attr('src'); + var sourceSrc = $('#audio source').eq(0).attr('src'); if (sourceSrc == '' && p[0].src == '') { audiolist = $('#audio-list li'); mp3 = audiolist.eq([Math.floor(Math.random() * audiolist.length)]); p[0].src = mp3.data('url'); } - if (p.eq(0).data("autoplay") == true) { + if (p.eq(0).data('autoplay') == true) { p[0].play(); } p.on({ - 'timeupdate': function () { - var progress = p[0].currentTime / p[0].duration * 100; + timeupdate: function () { + var progress = (p[0].currentTime / p[0].duration) * 100; $('.bar').css('width', progress + '%'); if (progress / 5 <= 1) { p[0].volume = progress / 5; @@ -246,24 +266,44 @@ var Obsidian = { p[0].volume = 1; } }, - 'ended': function () { + ended: function () { $('.icon-pause').removeClass('icon-pause').addClass('icon-play'); }, - 'playing': function () { + playing: function () { $('.icon-play').removeClass('icon-play').addClass('icon-pause'); - } + }, }); }, loading: function () { var w = window.innerWidth; - var css = ''; $('.loaderstyle').remove(); $('head').append(css); - $('#loader').removeClass().addClass('loader' + w).show(); + $('#loader') + .removeClass() + .addClass('loader' + w) + .show(); }, loaded: function () { $('#loader').removeClass().hide(); @@ -298,120 +338,120 @@ var Obsidian = { }, setCodeRowWithLang: function () { // Get the programming type of the current code block - var code = $("code"); + var code = $('code'); if (code && code.length) { code.each(function () { var item = $(this), - lang = ""; + lang = ''; if (item[0].className.indexOf(' ') > -1) { lang = item[0].className.split(' ')[0]; } else { lang = item[0].className; } var langMap = { - "html": "HTML", - "xml": "XML", - "svg": "SVG", - "mathml": "MathML", - "css": "CSS", - "clike": "C-like", - "js": "JavaScript", - "abap": "ABAP", - "apacheconf": "Apache Configuration", - "apl": "APL", - "arff": "ARFF", - "asciidoc": "AsciiDoc", - "adoc": "AsciiDoc", - "asm6502": "6502 Assembly", - "aspnet": "ASP.NET (C#)", - "autohotkey": "AutoHotkey", - "autoit": "AutoIt", - "shell": "BASH", - "bash": "BASH", - "basic": "BASIC", - "csharp": "C#", - "dotnet": "C#", - "cpp": "C++", - "cil": "CIL", - "csp": "Content-Security-Policy", - "css-extras": "CSS Extras", - "django": "Django/Jinja2", - "jinja2": "Django/Jinja2", - "dockerfile": "Docker", - "erb": "ERB", - "fsharp": "F#", - "gcode": "G-code", - "gedcom": "GEDCOM", - "glsl": "GLSL", - "gml": "GameMaker Language", - "gamemakerlanguage": "GameMaker Language", - "graphql": "GraphQL", - "hcl": "HCL", - "http": "HTTP", - "hpkp": "HTTP Public-Key-Pins", - "hsts": "HTTP Strict-Transport-Security", - "ichigojam": "IchigoJam", - "inform7": "Inform 7", - "javastacktrace": "Java stack trace", - "json": "JSON", - "jsonp": "JSONP", - "latex": "LaTeX", - "emacs": "Lisp", - "elisp": "Lisp", - "emacs-lisp": "Lisp", - "lolcode": "LOLCODE", - "markup-templating": "Markup templating", - "matlab": "MATLAB", - "mel": "MEL", - "n1ql": "N1QL", - "n4js": "N4JS", - "n4jsd": "N4JS", - "nand2tetris-hdl": "Nand To Tetris HDL", - "nasm": "NASM", - "nginx": "nginx", - "nsis": "NSIS", - "objectivec": "Objective-C", - "ocaml": "OCaml", - "opencl": "OpenCL", - "parigp": "PARI/GP", - "objectpascal": "Object Pascal", - "php": "PHP", - "php-extras": "PHP Extras", - "plsql": "PL/SQL", - "powershell": "PowerShell", - "properties": ".properties", - "protobuf": "Protocol Buffers", - "q": "Q (kdb+ database)", - "jsx": "React JSX", - "tsx": "React TSX", - "renpy": "Ren'py", - "rest": "reST (reStructuredText)", - "sas": "SAS", - "sass": "SASS (Sass)", - "scss": "SASS (Scss)", - "sql": "SQL", - "soy": "Soy (Closure Template)", - "tap": "TAP", - "toml": "TOML", - "tt2": "Template Toolkit 2", - "ts": "TypeScript", - "vbnet": "VB.Net", - "vhdl": "VHDL", - "vim": "vim", - "visual-basic": "Visual Basic", - "vb": "Visual Basic", - "wasm": "WebAssembly", - "wiki": "Wiki markup", - "xeoracube": "XeoraCube", - "xojo": "Xojo (REALbasic)", - "xquery": "XQuery", - "yaml": "YAML" + html: 'HTML', + xml: 'XML', + svg: 'SVG', + mathml: 'MathML', + css: 'CSS', + clike: 'C-like', + js: 'JavaScript', + abap: 'ABAP', + apacheconf: 'Apache Configuration', + apl: 'APL', + arff: 'ARFF', + asciidoc: 'AsciiDoc', + adoc: 'AsciiDoc', + asm6502: '6502 Assembly', + aspnet: 'ASP.NET (C#)', + autohotkey: 'AutoHotkey', + autoit: 'AutoIt', + shell: 'BASH', + bash: 'BASH', + basic: 'BASIC', + csharp: 'C#', + dotnet: 'C#', + cpp: 'C++', + cil: 'CIL', + csp: 'Content-Security-Policy', + 'css-extras': 'CSS Extras', + django: 'Django/Jinja2', + jinja2: 'Django/Jinja2', + dockerfile: 'Docker', + erb: 'ERB', + fsharp: 'F#', + gcode: 'G-code', + gedcom: 'GEDCOM', + glsl: 'GLSL', + gml: 'GameMaker Language', + gamemakerlanguage: 'GameMaker Language', + graphql: 'GraphQL', + hcl: 'HCL', + http: 'HTTP', + hpkp: 'HTTP Public-Key-Pins', + hsts: 'HTTP Strict-Transport-Security', + ichigojam: 'IchigoJam', + inform7: 'Inform 7', + javastacktrace: 'Java stack trace', + json: 'JSON', + jsonp: 'JSONP', + latex: 'LaTeX', + emacs: 'Lisp', + elisp: 'Lisp', + 'emacs-lisp': 'Lisp', + lolcode: 'LOLCODE', + 'markup-templating': 'Markup templating', + matlab: 'MATLAB', + mel: 'MEL', + n1ql: 'N1QL', + n4js: 'N4JS', + n4jsd: 'N4JS', + 'nand2tetris-hdl': 'Nand To Tetris HDL', + nasm: 'NASM', + nginx: 'nginx', + nsis: 'NSIS', + objectivec: 'Objective-C', + ocaml: 'OCaml', + opencl: 'OpenCL', + parigp: 'PARI/GP', + objectpascal: 'Object Pascal', + php: 'PHP', + 'php-extras': 'PHP Extras', + plsql: 'PL/SQL', + powershell: 'PowerShell', + properties: '.properties', + protobuf: 'Protocol Buffers', + q: 'Q (kdb+ database)', + jsx: 'React JSX', + tsx: 'React TSX', + renpy: "Ren'py", + rest: 'reST (reStructuredText)', + sas: 'SAS', + sass: 'SASS (Sass)', + scss: 'SASS (Scss)', + sql: 'SQL', + soy: 'Soy (Closure Template)', + tap: 'TAP', + toml: 'TOML', + tt2: 'Template Toolkit 2', + ts: 'TypeScript', + vbnet: 'VB.Net', + vhdl: 'VHDL', + vim: 'vim', + 'visual-basic': 'Visual Basic', + vb: 'Visual Basic', + wasm: 'WebAssembly', + wiki: 'Wiki markup', + xeoracube: 'XeoraCube', + xojo: 'Xojo (REALbasic)', + xquery: 'XQuery', + yaml: 'YAML', }; - var displayLangText = ""; + var displayLangText = ''; if (lang in langMap) displayLangText = langMap[lang]; else displayLangText = lang; - if (item.find(".language-mark").length <= 0 && displayLangText) { + if (item.find('.language-mark').length <= 0 && displayLangText) { // reset code block styles item.css('background', 'transparent'); item.css('padding', 0); @@ -426,32 +466,37 @@ var Obsidian = { lineNumbers: !item.is('.inline'), readOnly: true, lineWrapping: true, - theme: 'dracula' + theme: 'dracula', }); - item.find('.CodeMirror').prepend( - ' ' + displayLangText + ''); + item + .find('.CodeMirror') + .prepend( + ' ' + + displayLangText + + '' + ); } }); } }, tocSpy: function (offset) { - var tocContainer = $("#toc"); + var tocContainer = $('#toc'); var toc = tocContainer, tocHeight = toc.height(); scrollSpy(tocContainer, { - offset: 200 + offset: 200, }); - $(".toc-item").on("scrollspy", function () { + $('.toc-item').on('scrollspy', function () { var tocTop = toc.scrollTop(), - link = $(this).children(".toc-link"), + link = $(this).children('.toc-link'), thisTop = link.position().top; // make sure the highlighted element contains no child - if ($(this).height() != link.height()) - return; + if ($(this).height() != link.height()) return; // if the highlighted element is above current view of toc - if (thisTop <= 0) - toc.scrollTop(tocTop + thisTop); + if (thisTop <= 0) toc.scrollTop(tocTop + thisTop); // else if below current view of toc else if (tocHeight <= thisTop) toc.scrollTop(tocTop + thisTop + link.outerHeight() - tocHeight); @@ -474,7 +519,7 @@ var Obsidian = { var $config = { title: document.title, description: document.description, - wechatQrcodeTitle: "微信扫一扫:分享", // 微信二维码提示文字 + wechatQrcodeTitle: '微信扫一扫:分享', // 微信二维码提示文字 wechatQrcodeHelper: '

微信里点“发现”,扫一下

二维码便可将本文分享至朋友圈。

', }; @@ -483,335 +528,344 @@ var Obsidian = { v: function (t, e) { if (t) switch (t) { - case "javascript": - case "text/javascript": - case "js": - return t = "javascript"; - case "json": - return e ? t : t = { - name: "javascript", - json: !0 - }; - case "jsonld": - case "json-ld": - return e ? t : "application/ld+json"; - case "text/typescript": - case "typescript": - case "ts": - return e ? "typescript" : t = { - name: "javascript", - typescript: !0 - }; - case "clojure": + case 'javascript': + case 'text/javascript': + case 'js': + return (t = 'javascript'); + case 'json': + return e + ? t + : (t = { + name: 'javascript', + json: !0, + }); + case 'jsonld': + case 'json-ld': + return e ? t : 'application/ld+json'; + case 'text/typescript': + case 'typescript': + case 'ts': + return e + ? 'typescript' + : (t = { + name: 'javascript', + typescript: !0, + }); + case 'clojure': return t; - case "coffee": - case "coffeescript": - case "css": + case 'coffee': + case 'coffeescript': + case 'css': return t; - case "less": - return e ? "less" : "text/x-less"; - case "scss": - return e ? "scss" : t = "text/x-scss"; - case "gfm": - case "github flavored markdown": - return t = "gfm"; - case "markdown": - case "md": - case "mkd": + case 'less': + return e ? 'less' : 'text/x-less'; + case 'scss': + return e ? 'scss' : (t = 'text/x-scss'); + case 'gfm': + case 'github flavored markdown': + return (t = 'gfm'); + case 'markdown': + case 'md': + case 'mkd': return t; - case "xml": - case "xaml": - case "mjml": - case "xul": - case "enml": - return e ? t : "xml"; - case "haskell": + case 'xml': + case 'xaml': + case 'mjml': + case 'xul': + case 'enml': + return e ? t : 'xml'; + case 'haskell': return t; - case "htmlmixed": - case "html": - case "xhtml": - case "svg": - case "epub": - return e ? /^html/.exec(t) ? "html" : t : t = "htmlmixed"; - case "lua": + case 'htmlmixed': + case 'html': + case 'xhtml': + case 'svg': + case 'epub': + return e ? (/^html/.exec(t) ? 'html' : t) : (t = 'htmlmixed'); + case 'lua': return t; - case "lisp": - case "commonlisp": - case "common lisp": - return t = "commonlisp"; - case "pascal": + case 'lisp': + case 'commonlisp': + case 'common lisp': + return (t = 'commonlisp'); + case 'pascal': return t; - case "perl": - case "perl5": - case "perl4": - case "perl3": - case "perl2": - return "perl"; - case "perl6": + case 'perl': + case 'perl5': + case 'perl4': + case 'perl3': + case 'perl2': + return 'perl'; + case 'perl6': return t; - case "php+html": - return e ? "php" : "application/x-httpd-php"; - case "php": - case "php3": - case "php4": - case "php5": - case "php6": - return e ? t : "text/x-php"; - case "cython": - return e ? t : t = "text/x-cython"; - case "python": - return e ? t : t = "text/x-python"; - case "ruby": + case 'php+html': + return e ? 'php' : 'application/x-httpd-php'; + case 'php': + case 'php3': + case 'php4': + case 'php5': + case 'php6': + return e ? t : 'text/x-php'; + case 'cython': + return e ? t : (t = 'text/x-cython'); + case 'python': + return e ? t : (t = 'text/x-python'); + case 'ruby': return t; - case "shell": - case "sh": - case "zsh": - case "bash": - return t = "shell"; - case "sql": - case "sql lite": - case "sqlite": - return e ? t : t = "text/x-sql"; - case "mssql": - return e ? t : t = "text/x-mssql"; - case "mysql": - return e ? t : t = "text/x-mysql"; - case "mariadb": - return e ? t : t = "text/x-mariadb"; - case "cassandra": - case "cql": - return e ? t : t = "text/x-cassandra"; - case "plsql": - return e ? t : t = "text/x-plsql"; - case "stex": - case "tex": - case "latex": - return e ? t : "text/x-stex"; - case "tiddlywiki": - case "wiki": - return e ? t : t = "tiddlywiki"; - case "vb": - case "visual basic": - case "visualbasic": - case "basic": - return e ? t : t = "vb"; - case "vbscript": - case "velocity": + case 'shell': + case 'sh': + case 'zsh': + case 'bash': + return (t = 'shell'); + case 'sql': + case 'sql lite': + case 'sqlite': + return e ? t : (t = 'text/x-sql'); + case 'mssql': + return e ? t : (t = 'text/x-mssql'); + case 'mysql': + return e ? t : (t = 'text/x-mysql'); + case 'mariadb': + return e ? t : (t = 'text/x-mariadb'); + case 'cassandra': + case 'cql': + return e ? t : (t = 'text/x-cassandra'); + case 'plsql': + return e ? t : (t = 'text/x-plsql'); + case 'stex': + case 'tex': + case 'latex': + return e ? t : 'text/x-stex'; + case 'tiddlywiki': + case 'wiki': + return e ? t : (t = 'tiddlywiki'); + case 'vb': + case 'visual basic': + case 'visualbasic': + case 'basic': + return e ? t : (t = 'vb'); + case 'vbscript': + case 'velocity': return t; - case "verilog": - return e ? t : t = "text/x-verilog"; - case "xquery": + case 'verilog': + return e ? t : (t = 'text/x-verilog'); + case 'xquery': return t; - case "yaml": - case "yml": - return e ? t : "yaml"; - case "go": - case "groovy": - case "nginx": + case 'yaml': + case 'yml': + return e ? t : 'yaml'; + case 'go': + case 'groovy': + case 'nginx': return t; - case "octave": - case "matlab": - return e ? t : "text/x-octave"; - case "c": - case "clike": - case "csrc": - return e ? t : t = "text/x-csrc"; - case "c++": - case "c++src": - case "cpp": - case "cc": - case "hpp": - case "h++": - case "h": - return e ? t : t = "text/x-c++src"; - case "obj-c": - case "objc": - case "objective c": - case "objective-c": - case "objectivec": - return e ? t : t = "text/x-objectivec"; - case "text/x-scala": - case "scala": - return e ? t : t = "text/x-scala"; - case "csharp": - case "c#": - case "cs": - return e ? t : t = "text/x-csharp"; - case "java": - return e ? t : t = "text/x-java"; - case "squirrel": - return e ? t : t = "text/x-squirrel"; - case "ceylon": - return e ? t : t = "text/x-ceylon"; - case "kotlin": - return e ? t : t = "text/x-kotlin"; - case "swift": - return t = "swift"; - case "r": - case "rlang": - case "r-lang": - return e ? t : t = "text/x-rsrc"; - case "d": - case "diff": - case "erlang": - case "http": - case "jade": + case 'octave': + case 'matlab': + return e ? t : 'text/x-octave'; + case 'c': + case 'clike': + case 'csrc': + return e ? t : (t = 'text/x-csrc'); + case 'c++': + case 'c++src': + case 'cpp': + case 'cc': + case 'hpp': + case 'h++': + case 'h': + return e ? t : (t = 'text/x-c++src'); + case 'obj-c': + case 'objc': + case 'objective c': + case 'objective-c': + case 'objectivec': + return e ? t : (t = 'text/x-objectivec'); + case 'text/x-scala': + case 'scala': + return e ? t : (t = 'text/x-scala'); + case 'csharp': + case 'c#': + case 'cs': + return e ? t : (t = 'text/x-csharp'); + case 'java': + return e ? t : (t = 'text/x-java'); + case 'squirrel': + return e ? t : (t = 'text/x-squirrel'); + case 'ceylon': + return e ? t : (t = 'text/x-ceylon'); + case 'kotlin': + return e ? t : (t = 'text/x-kotlin'); + case 'swift': + return (t = 'swift'); + case 'r': + case 'rlang': + case 'r-lang': + return e ? t : (t = 'text/x-rsrc'); + case 'd': + case 'diff': + case 'erlang': + case 'http': + case 'jade': return t; - case "rst": - case "restructuredtext": - return t = "rst"; - case "rust": - case "jinja2": + case 'rst': + case 'restructuredtext': + return (t = 'rst'); + case 'rust': + case 'jinja2': return t; - case "aspx": - case "asp": - case "asp.net": - return e ? t : t = "application/x-aspx"; - case "jsp": - return e ? t : t = "application/x-jsp"; - case "erb": - return e ? t : t = "application/x-erb"; - case "ejs": - case "embeddedjs": - case "embedded javaScript": - return e ? t : t = "application/x-ejs"; - case "powershell": - case "bat": - case "cmd": - return e ? t : "application/x-powershell"; - case "dockerfile": - return e ? t : "text/x-dockerfile"; - case "jsx": - case "react": - return e ? t : "text/jsx"; - case "tsx": - return e ? t : "text/typescript-jsx"; - case "vue.js": - case "vue": - case "vue-template": - return e ? t : "script/x-vue"; - case "nsis": - return e ? t : "text/x-nsis"; - case "mathematica": - return e ? t : "text/x-mathematica"; - case "tiki": - case "tiki wiki": - case "tiki-wiki": - case "tikiwiki": - return "tiki"; - case "properties": - case "ini": - return e ? t : "text/x-properties"; - case "livescript": - return e ? t : "text/x-livescript"; - case "asm": - case "assembly": - case "nasm": - case "gas": - return e ? t : "assembly"; - case "toml": - return e ? t : "text/x-toml"; - case "sequence": - return "sequence"; - case "flow": - case "flowchart": - return "flow"; - case "mermaid": - return "mermaid"; - case "ocaml": - return e ? t : "text/x-ocaml"; - case "f#": - case "fsharp": - return e ? t : "text/x-fsharp"; - case "elm": - return e ? t : "text/x-elm"; - case "pgp": - case "pgp-keys": - case "pgp-key": - case "pgp-signature": - case "asciiarmor": - case "ascii-armor": - case "ascii armor": - return e ? t : "application/pgp"; - case "spreadsheet": - case "excel": - return e ? t : "text/x-spreadsheet"; - case "elixir": - return "elixir"; - case "cmake": - return e ? t : "text/x-cmake"; - case "cypher": - case "cypher-query": - return e ? t : "application/x-cypher-query"; - case "dart": - return "dart"; - case "django": - return e ? t : "text/x-django"; - case "dtd": - case "xml-dtd": - case "xml dtd": - case "xmldtd": - return e ? t : "application/xml-dtd"; - case "dylan": - return e ? t : "text/x-dylan"; - case "handlebars": - return e ? t : "text/x-handlebars-template"; - case "idl": - return e ? t : "text/x-idl"; - case "webidl": - case "web-idl": - case "web idl": - return e ? t : "text/x-webidl"; - case "yacas": - return e ? t : "text/x-yacas"; - case "mbox": - return e ? t : "application/mbox"; - case "vhdl": - return e ? t : "text/x-vhdl"; - case "julia": - return "julia"; - case "haxe": - return e ? t : "text/x-haxe"; - case "hxml": - return e ? t : "text/x-hxml"; - case "fortran": - return e ? t : "text/x-fortran"; - case "protobuf": - return e ? t : "text/x-protobuf"; - case "makefile": - return e ? t : "text/x-makefile"; - case "tcl": - return e ? t : "text/x-tcl"; - case "scheme": - return e ? t : "text/x-scheme"; - case "twig": - return e ? t : "text/x-twig"; - case "sas": - return e ? t : "text/x-sas"; - case "pseudocode": - return e ? t : "text/x-pseudocode"; - case "julia": - case "text/x-julia": - case "stylus": - case "cobol": - case "oz": - case "sparql": - case "crystal": + case 'aspx': + case 'asp': + case 'asp.net': + return e ? t : (t = 'application/x-aspx'); + case 'jsp': + return e ? t : (t = 'application/x-jsp'); + case 'erb': + return e ? t : (t = 'application/x-erb'); + case 'ejs': + case 'embeddedjs': + case 'embedded javaScript': + return e ? t : (t = 'application/x-ejs'); + case 'powershell': + case 'bat': + case 'cmd': + return e ? t : 'application/x-powershell'; + case 'dockerfile': + return e ? t : 'text/x-dockerfile'; + case 'jsx': + case 'react': + return e ? t : 'text/jsx'; + case 'tsx': + return e ? t : 'text/typescript-jsx'; + case 'vue.js': + case 'vue': + case 'vue-template': + return e ? t : 'script/x-vue'; + case 'nsis': + return e ? t : 'text/x-nsis'; + case 'mathematica': + return e ? t : 'text/x-mathematica'; + case 'tiki': + case 'tiki wiki': + case 'tiki-wiki': + case 'tikiwiki': + return 'tiki'; + case 'properties': + case 'ini': + return e ? t : 'text/x-properties'; + case 'livescript': + return e ? t : 'text/x-livescript'; + case 'asm': + case 'assembly': + case 'nasm': + case 'gas': + return e ? t : 'assembly'; + case 'toml': + return e ? t : 'text/x-toml'; + case 'sequence': + return 'sequence'; + case 'flow': + case 'flowchart': + return 'flow'; + case 'mermaid': + return 'mermaid'; + case 'ocaml': + return e ? t : 'text/x-ocaml'; + case 'f#': + case 'fsharp': + return e ? t : 'text/x-fsharp'; + case 'elm': + return e ? t : 'text/x-elm'; + case 'pgp': + case 'pgp-keys': + case 'pgp-key': + case 'pgp-signature': + case 'asciiarmor': + case 'ascii-armor': + case 'ascii armor': + return e ? t : 'application/pgp'; + case 'spreadsheet': + case 'excel': + return e ? t : 'text/x-spreadsheet'; + case 'elixir': + return 'elixir'; + case 'cmake': + return e ? t : 'text/x-cmake'; + case 'cypher': + case 'cypher-query': + return e ? t : 'application/x-cypher-query'; + case 'dart': + return 'dart'; + case 'django': + return e ? t : 'text/x-django'; + case 'dtd': + case 'xml-dtd': + case 'xml dtd': + case 'xmldtd': + return e ? t : 'application/xml-dtd'; + case 'dylan': + return e ? t : 'text/x-dylan'; + case 'handlebars': + return e ? t : 'text/x-handlebars-template'; + case 'idl': + return e ? t : 'text/x-idl'; + case 'webidl': + case 'web-idl': + case 'web idl': + return e ? t : 'text/x-webidl'; + case 'yacas': + return e ? t : 'text/x-yacas'; + case 'mbox': + return e ? t : 'application/mbox'; + case 'vhdl': + return e ? t : 'text/x-vhdl'; + case 'julia': + return 'julia'; + case 'haxe': + return e ? t : 'text/x-haxe'; + case 'hxml': + return e ? t : 'text/x-hxml'; + case 'fortran': + return e ? t : 'text/x-fortran'; + case 'protobuf': + return e ? t : 'text/x-protobuf'; + case 'makefile': + return e ? t : 'text/x-makefile'; + case 'tcl': + return e ? t : 'text/x-tcl'; + case 'scheme': + return e ? t : 'text/x-scheme'; + case 'twig': + return e ? t : 'text/x-twig'; + case 'sas': + return e ? t : 'text/x-sas'; + case 'pseudocode': + return e ? t : 'text/x-pseudocode'; + case 'julia': + case 'text/x-julia': + case 'stylus': + case 'cobol': + case 'oz': + case 'sparql': + case 'crystal': return t; - case "asn.1": - return e ? "ASN.1" : t = "text/x-ttcn-asn"; - case "gherkin": - case "smalltalk": - case "turtle": + case 'asn.1': + return e ? 'ASN.1' : (t = 'text/x-ttcn-asn'); + case 'gherkin': + case 'smalltalk': + case 'turtle': return t; default: - return ""; + return ''; } }, getCodeMirrorMode: function (t, e, n) { - var i = ((t = (t = t ? t.toLowerCase() : "").replace(/^\s*\.*lang(uage)*-/g, "").replace(/[{}]/g, "").trim()).split(/\s+/) || [t])[0], + var i = ((t = (t = t ? t.toLowerCase() : '') + .replace(/^\s*\.*lang(uage)*-/g, '') + .replace(/[{}]/g, '') + .trim()).split(/\s+/) || [t])[0], r = Obsidian.v(t, n); - return r || t == i || (r = Obsidian.v(i.replace(/(^[.])|(,$)/g, ""), n)), r || (n ? i : e ? null : t); + return ( + r || t == i || (r = Obsidian.v(i.replace(/(^[.])|(,$)/g, ''), n)), r || (n ? i : e ? null : t) + ); }, loadingOut: function () { setTimeout(function () { @@ -820,12 +874,12 @@ var Obsidian = { $('.loader').css('z-index', '-1'); }, 600); }, 500); - } + }, }; $(function () { initialMathJax(); - var inputArea = document.querySelector("#local-search-input"); + var inputArea = document.querySelector('#local-search-input'); if (inputArea) { inputArea.onclick = function () { getSearchFile(); @@ -925,7 +979,7 @@ $(function () { tw = $('#top').width(), dh = document.body.scrollHeight, wh = $(window).height(); - var width = tw / (dh - wh) * wt; + var width = (tw / (dh - wh)) * wt; $('.scrollbar').width(width); } @@ -933,12 +987,16 @@ $(function () { docHeight = $(document).height(), winHeight = $(window).height(), winWidth = $(window).width(), - scrollPercent = (scrollTop) / (docHeight - winHeight), + scrollPercent = scrollTop / (docHeight - winHeight), scrollPercentRounded = Math.round(scrollPercent * 100), backToTopState = $('#back-to-top').css('display'); - $('#back-to-top').find('.percentage').html(scrollPercentRounded + '%'); - $('#back-to-top').find('.flow').css('height', scrollPercentRounded + '%'); + $('#back-to-top') + .find('.percentage') + .html(scrollPercentRounded + '%'); + $('#back-to-top') + .find('.flow') + .css('height', scrollPercentRounded + '%'); if (winWidth >= 920) { if (scrollPercentRounded > 10) { @@ -973,26 +1031,29 @@ $(function () { clone; // .content > ... > img - if (e.target.nodeName == "IMG" && $(e.target).parents('div.content').length > 0) { + if (e.target.nodeName == 'IMG' && $(e.target).parents('div.content').length > 0) { tag = 'pimg'; } if (!tag && !rel) return; switch (true) { - case (tag.indexOf('share') != -1): - var shareComponent = $(".share-component-cc"); + case tag.indexOf('share') != -1: + var shareComponent = $('.share-component-cc'); if (shareComponent.css('opacity') != '1') { - $(".share-component-cc").css('opacity', 1); + $('.share-component-cc').css('opacity', 1); } else { - $(".share-component-cc").css('opacity', 0); + $('.share-component-cc').css('opacity', 0); } break; - case (tag.indexOf('icon-top02') != -1): - $("html,body").animate({ - scrollTop: 0 - }, 300); + case tag.indexOf('icon-top02') != -1: + $('html,body').animate( + { + scrollTop: 0, + }, + 300 + ); break; - // nav menu - case (tag.indexOf('switchmenu') != -1): + // nav menu + case tag.indexOf('switchmenu') != -1: window.scrollTo(0, 0); $('html, body').toggleClass('mu'); var switchMenu = $('.switchmenu'); @@ -1002,8 +1063,8 @@ $(function () { switchMenu.removeClass('icon-cross').addClass('icon-menu'); } return false; - // next page - case (tag.indexOf('more') != -1): + // next page + case tag.indexOf('more') != -1: tag = $('.more'); if (tag.data('status') == 'loading') { return false; @@ -1017,34 +1078,41 @@ $(function () { } tag.html(tag.attr('data-loading')).data('status', 'loading'); Obsidian.loading(); - Obsidian.L(tag.attr('href'), function (data) { - var link = $(data).find('.more').attr('href'); - if (link != undefined) { - tag.attr('href', link).html(tag.attr('data-load-more')).data('status', 'loaded'); - tag.data('page', parseInt(tag.data('page')) + 1); - } else { - $('#pager').remove(); + Obsidian.L( + tag.attr('href'), + function (data) { + var link = $(data).find('.more').attr('href'); + if (link != undefined) { + tag.attr('href', link).html(tag.attr('data-load-more')).data('status', 'loaded'); + tag.data('page', parseInt(tag.data('page')) + 1); + } else { + $('#pager').remove(); + } + var tempScrollTop = $(window).scrollTop(); + $('#primary').append($(data).find('.post')); + $(window).scrollTop(tempScrollTop + 100); + Obsidian.loaded(); + $('html,body').animate( + { + scrollTop: tempScrollTop + 400, + }, + 500 + ); + document.querySelectorAll('pre code').forEach(block => { + hljs.highlightBlock(block); + }); + Obsidian.setCodeRowWithLang(); + if ($('#vcomments').length) { + initValine(); + } + }, + function () { + tag.html(tag.attr('data-load-more')).data('status', 'loaded'); } - var tempScrollTop = $(window).scrollTop(); - $('#primary').append($(data).find('.post')); - $(window).scrollTop(tempScrollTop + 100); - Obsidian.loaded(); - $('html,body').animate({ - scrollTop: tempScrollTop + 400 - }, 500); - document.querySelectorAll('pre code').forEach((block) => { - hljs.highlightBlock(block); - }); - Obsidian.setCodeRowWithLang(); - if ($('#vcomments').length) { - initValine(); - } - }, function () { - tag.html(tag.attr('data-load-more')).data('status', 'loaded'); - }); + ); return false; - // home - case (tag.indexOf('icon-home') != -1): + // home + case tag.indexOf('icon-home') != -1: $('.toc').fadeOut(100); if ($('#preview').hasClass('show')) { history.back(); @@ -1052,42 +1120,44 @@ $(function () { location.href = $('.icon-home').data('url'); } return false; - // qrcode - case (tag.indexOf('icon-QRcode-o') != -1): + // qrcode + case tag.indexOf('icon-QRcode-o') != -1: if ($('.icon-scan').hasClass('tg')) { $('#qr').toggle(); } else { $('.icon-scan').addClass('tg'); - $('#qr').qrcode({ - width: 128, - height: 128, - text: location.href - }).toggle(); + $('#qr') + .qrcode({ + width: 128, + height: 128, + text: location.href, + }) + .toggle(); } return false; - // audio play - case (tag.indexOf('icon-play') != -1): + // audio play + case tag.indexOf('icon-play') != -1: $('#audio')[0].play(); $('.icon-play').removeClass('icon-play').addClass('icon-pause'); return false; - // audio pause - case (tag.indexOf('icon-pause') != -1): + // audio pause + case tag.indexOf('icon-pause') != -1: $('#audio')[0].pause(); $('.icon-pause').removeClass('icon-pause').addClass('icon-play'); return false; - // history state - case (tag.indexOf('posttitle') != -1): + // history state + case tag.indexOf('posttitle') != -1: $('body').removeClass('fixed'); Obsidian.HS($(e.target), 'push'); // initialArticleTyped(); return false; - // history state - case (tag.indexOf('menu-link') != -1): + // history state + case tag.indexOf('menu-link') != -1: $('body').removeClass('fixed'); Obsidian.HS($(e.target), 'push'); return false; - // prev, next post - case (rel == 'prev' || rel == 'next'): + // prev, next post + case rel == 'prev' || rel == 'next': var t; if (rel == 'prev') { t = $('#prev_next a')[0].text; @@ -1097,31 +1167,34 @@ $(function () { $(e.target).attr('title', t); Obsidian.HS($(e.target), 'replace'); return false; - // toc - case (tag.indexOf('toc-text') != -1 || + // toc + case tag.indexOf('toc-text') != -1 || tag.indexOf('toc-link') != -1 || - tag.indexOf('toc-number') != -1): + tag.indexOf('toc-number') != -1: hash = ''; if (e.target.nodeName == 'SPAN') { hash = $(e.target).parent().attr('href'); } else { hash = $(e.target).attr('href'); } - to = $(".content :header").find('[href="' + hash + '"]'); - $("html,body").animate({ - scrollTop: to.offset().top - 80 - }, 300); + to = $('.content :header').find('[href="' + hash + '"]'); + $('html,body').animate( + { + scrollTop: to.offset().top - 80, + }, + 300 + ); return false; - // quick view - case (tag.indexOf('pviewa') != -1): + // quick view + case tag.indexOf('pviewa') != -1: $('body').removeClass('mu'); setTimeout(function () { Obsidian.HS($(e.target), 'push'); $('.toc').fadeIn(1000); }, 300); return false; - // photoswipe - case (tag.indexOf('pimg') != -1): + // photoswipe + case tag.indexOf('pimg') != -1: var pswpElement = $('.pswp').get(0); if (pswpElement) { var items = []; @@ -1135,7 +1208,7 @@ $(function () { var item = { src: v.src, w: v.naturalWidth, - h: v.naturalHeight + h: v.naturalHeight, }; imgs.push(v); items.push(item); @@ -1155,18 +1228,17 @@ $(function () { return { x: rect.left, y: rect.top + pageYScroll, - w: rect.width + w: rect.width, }; - } + }, }; var lightBox = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); lightBox.init(); } return false; - // comment - case -1 != tag.indexOf("comment"): - Obsidian.loading(), - comment = $('#gitalk-container'); + // comment + case -1 != tag.indexOf('comment'): + Obsidian.loading(), (comment = $('#gitalk-container')); var gitalk = new Gitalk({ clientID: comment.data('ci'), clientSecret: comment.data('cs'), @@ -1175,13 +1247,13 @@ $(function () { admin: [comment.data('a')], id: md5(window.location.pathname), distractionFreeMode: comment.data('d'), - labels: ['Gitalk'] + labels: ['Gitalk'], }); - $(".comment").removeClass("link"); + $('.comment').removeClass('link'); gitalk.render('gitalk-container'); Obsidian.loaded(); return false; - case (tag.indexOf('category-list-child') != -1): + case tag.indexOf('category-list-child') != -1: tag = $(e.target); set = $('.set'); clone = $('.clone-element'); @@ -1191,7 +1263,7 @@ $(function () { if (categoryDisplay == 'none') { tag.parent('.category-list-item').addClass('active'); - tag.find(".category-list-item").each(function () { + tag.find('.category-list-item').each(function () { $(this).addClass('sub-active'); }); clone.append(set.html()).show(); @@ -1201,7 +1273,7 @@ $(function () { $('.category-mask').fadeIn(500); } return false; - case (tag.indexOf('category-mask') != -1): + case tag.indexOf('category-mask') != -1: set = $('.set'); clone = $('.clone-element'); set.append(clone.html()).css('height', 'auto'); @@ -1211,13 +1283,13 @@ $(function () { setTimeout(function () { that.removeClass('active'); }, 400); - $(".sub-active").each(function () { + $('.sub-active').each(function () { $(this).removeClass('sub-active'); }); }); $('.category-mask').fadeOut(500); return false; - case (tag.indexOf('search-bar') != -1 || tag.indexOf('search-box-close') != -1): + case tag.indexOf('search-bar') != -1 || tag.indexOf('search-box-close') != -1: var searchBox = $('.search-box'), searchBoxDisplay = $('.search-box').css('display'); @@ -1235,7 +1307,7 @@ $(function () { }); // 是否自动展开评论 - comment = $("#gitalk-container"); + comment = $('#gitalk-container'); if (comment.data('ae') == true) { comment.click(); } @@ -1257,5 +1329,10 @@ $(function () { utiliseBgColor(); initialTyped(); Obsidian.setCodeRowWithLang(); - console.log("%c Github %c", "background:#24272A; color:#73ddd7", "", "https://github.com/TriDiamond/hexo-theme-obsidian"); + console.log( + '%c Github %c', + 'background:#24272A; color:#73ddd7', + '', + 'https://github.com/TriDiamond/hexo-theme-obsidian' + ); }); diff --git a/search.xml b/search.xml index 9c1ecdc..eb657dc 100644 --- a/search.xml +++ b/search.xml @@ -274,10 +274,10 @@ - Open-Source - Windows + Open-Source + @@ -301,10 +301,10 @@ - Open-Source - Windows + Open-Source + Terminal @@ -330,10 +330,10 @@ - Windows - Cpp + Windows + Linux