Skip to content

Commit f2b3021

Browse files
committed
Added custom TOC for mobile
1 parent 2ebbd37 commit f2b3021

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

web/script_2.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1+
const TOC_MOBILE =
2+
'<strong>ToC</strong> = {\n' +
3+
' <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' +
4+
' <a href="#tuple">Tuple</a>, <a href="#range">Range</a>, <a href="#enumerate">Enumerate</a>,\n' +
5+
' <a href="#iterator">Iterator</a>, <a href="#generator">Generator</a>],\n' +
6+
' <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' +
7+
' <a href="#format">Format</a>, <a href="#numbers">Numbers</a>,\n' +
8+
' <a href="#combinatorics">Combinatorics</a>, <a href="#datetime">Datetime</a>],\n' +
9+
' <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' +
10+
' <a href="#decorator">Decorator</a>, <a href="#class">Class</a>,\n' +
11+
' <a href="#ducktypes">Duck_Types</a>, <a href="#enum">Enum</a>,\n' +
12+
' <a href="#exceptions">Exceptions</a>],\n' +
13+
' <strong><span class="hljs-string">\'4. System\'</span></strong>: [<a href="#print">Print</a>, <a href="#input">Input</a>,\n' +
14+
' <a href="#commandlinearguments">Command_Line_Arguments</a>,\n' +
15+
' <a href="#open">Open</a>, <a href="#path">Path</a>,\n' +
16+
' <a href="#oscommands">Command_Execution</a>],\n' +
17+
' <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' +
18+
' <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>,\n' +
19+
' <a href="#memoryview">MemoryView</a>, <a href="#deque">Deque</a>],\n' +
20+
' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#threading">Threading</a>, <a href="#operator">Operator</a>,\n' +
21+
' <a href="#introspection">Introspection</a>,\n' +
22+
' <a href="#metaprograming">Metaprograming</a>, <a href="#eval">Eval</a>,\n' +
23+
' <a href="#coroutine">Coroutine</a>],\n' +
24+
' <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' +
25+
' <a href="#curses">Curses</a>, <a href="#logging">Logging</a>, <a href="#scraping">Scraping</a>,\n' +
26+
' <a href="#web">Web</a>, <a href="#profiling">Profile</a>, <a href="#numpy">NumPy</a>,\n' +
27+
' <a href="#image">Image</a>, <a href="#animation">Animation</a>, <a href="#audio">Audio</a>,\n' +
28+
' <a href="#synthesizer">Synthesizer</a>]\n' +
29+
'}\n';
30+
131
const DIAGRAM_1_A =
232
'+-------------+-------------+\n' +
333
'| Classes | Metaclasses |\n' +
@@ -232,6 +262,10 @@ if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine
232262
isMobile = true;
233263
}
234264

265+
if (isMobile) {
266+
$(`code:contains(ToC)`).html(TOC_MOBILE);
267+
}
268+
235269
// ===== Scroll to Top ====
236270
$(window).scroll(function() {
237271
if (isMobile && $(this).scrollTop() >= 480) { // If mobile device and page is scrolled more than 520px.

0 commit comments

Comments
 (0)