From f2b3021b40e7c4b3cd3336ca368dab2706911a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= <sornjure@gmail.com> Date: Sun, 15 Dec 2019 18:51:34 +0100 Subject: [PATCH] Added custom TOC for mobile --- web/script_2.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/web/script_2.js b/web/script_2.js index 56316ea..8f0d6ee 100644 --- a/web/script_2.js +++ b/web/script_2.js @@ -1,3 +1,33 @@ +const TOC_MOBILE = + '<strong>ToC</strong> = {\n' + + ' <strong><span class="hljs-string">\'1. Collections\'</span></strong>: [<a href="#list">List</a>, <a href="#dictionary">Dictionary</a>, <a href="#set">Set</a>,\n' + + ' <a href="#tuple">Tuple</a>, <a href="#range">Range</a>, <a href="#enumerate">Enumerate</a>,\n' + + ' <a href="#iterator">Iterator</a>, <a href="#generator">Generator</a>],\n' + + ' <strong><span class="hljs-string">\'2. Types\'</span></strong>: [<a href="#type">Type</a>, <a href="#string">String</a>, <a href="#regex">Regular_Exp</a>,\n' + + ' <a href="#format">Format</a>, <a href="#numbers">Numbers</a>,\n' + + ' <a href="#combinatorics">Combinatorics</a>, <a href="#datetime">Datetime</a>],\n' + + ' <strong><span class="hljs-string">\'3. Syntax\'</span></strong>: [<a href="#arguments">Args</a>, <a href="#inline">Inline</a>, <a href="#closure">Closure</a>,\n' + + ' <a href="#decorator">Decorator</a>, <a href="#class">Class</a>,\n' + + ' <a href="#ducktypes">Duck_Types</a>, <a href="#enum">Enum</a>,\n' + + ' <a href="#exceptions">Exceptions</a>],\n' + + ' <strong><span class="hljs-string">\'4. System\'</span></strong>: [<a href="#print">Print</a>, <a href="#input">Input</a>,\n' + + ' <a href="#commandlinearguments">Command_Line_Arguments</a>,\n' + + ' <a href="#open">Open</a>, <a href="#path">Path</a>,\n' + + ' <a href="#oscommands">Command_Execution</a>],\n' + + ' <strong><span class="hljs-string">\'5. Data\'</span></strong>: [<a href="#json">JSON</a>, <a href="#pickle">Pickle</a>, <a href="#csv">CSV</a>, <a href="#sqlite">SQLite</a>,\n' + + ' <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>,\n' + + ' <a href="#memoryview">MemoryView</a>, <a href="#deque">Deque</a>],\n' + + ' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#threading">Threading</a>, <a href="#operator">Operator</a>,\n' + + ' <a href="#introspection">Introspection</a>,\n' + + ' <a href="#metaprograming">Metaprograming</a>, <a href="#eval">Eval</a>,\n' + + ' <a href="#coroutine">Coroutine</a>],\n' + + ' <strong><span class="hljs-string">\'7. Libraries\'</span></strong>: [<a href="#progressbar">Progress_Bar</a>, <a href="#plot">Plot</a>, <a href="#table">Table</a>,\n' + + ' <a href="#curses">Curses</a>, <a href="#logging">Logging</a>, <a href="#scraping">Scraping</a>,\n' + + ' <a href="#web">Web</a>, <a href="#profiling">Profile</a>, <a href="#numpy">NumPy</a>,\n' + + ' <a href="#image">Image</a>, <a href="#animation">Animation</a>, <a href="#audio">Audio</a>,\n' + + ' <a href="#synthesizer">Synthesizer</a>]\n' + + '}\n'; + const DIAGRAM_1_A = '+-------------+-------------+\n' + '| Classes | Metaclasses |\n' + @@ -232,6 +262,10 @@ if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine isMobile = true; } +if (isMobile) { + $(`code:contains(ToC)`).html(TOC_MOBILE); +} + // ===== Scroll to Top ==== $(window).scroll(function() { if (isMobile && $(this).scrollTop() >= 480) { // If mobile device and page is scrolled more than 520px.