|
| 1 | +const TOC = |
| 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>, <a href="#tuple">Tuple</a>, <a href="#range">Range</a>, <a href="#enumerate">Enumerate</a>, <a href="#iterator">Iterator</a>, <a href="#generator">Generator</a>],\n' + |
| 4 | + ' <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>, <a href="#format">Format</a>, <a href="#numbers">Numbers</a>, <a href="#combinatorics">Combinatorics</a>, <a href="#datetime">Datetime</a>],\n' + |
| 5 | + ' <strong><span class="hljs-string">\'3. Syntax\'</span></strong>: [<a href="#arguments">Args</a>, <a href="#inline">Inline</a>, <a href="#closure">Closure</a>, <a href="#decorator">Decorator</a>, <a href="#class">Class</a>, <a href="#ducktypes">Duck_Types</a>, <a href="#enum">Enum</a>, <a href="#exceptions">Exceptions</a>],\n' + |
| 6 | + ' <strong><span class="hljs-string">\'4. System\'</span></strong>: [<a href="#print">Print</a>, <a href="#input">Input</a>, <a href="#commandlinearguments">Command_Line_Arguments</a>, <a href="#open">Open</a>, <a href="#path">Path</a>, <a href="#oscommands">Command_Execution</a>],\n' + |
| 7 | + ' <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>, <a href="#bytes">Bytes</a>, <a href="#struct">Struct</a>, <a href="#array">Array</a>, <a href="#memoryview">MemoryView</a>, <a href="#deque">Deque</a>],\n' + |
| 8 | + ' <strong><span class="hljs-string">\'6. Advanced\'</span></strong>: [<a href="#threading">Threading</a>, <a href="#operator">Operator</a>, <a href="#introspection">Introspection</a>, <a href="#metaprograming">Metaprograming</a>, <a href="#eval">Eval</a>, <a href="#coroutine">Coroutine</a>],\n' + |
| 9 | + ' <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>, <a href="#curses">Curses</a>, <a href="#logging">Logging</a>, <a href="#scraping">Scraping</a>, <a href="#web">Web</a>, <a href="#profiling">Profile</a>,\n' + |
| 10 | + ' <a href="#numpy">NumPy</a>, <a href="#image">Image</a>, <a href="#animation">Animation</a>, <a href="#audio">Audio</a>, <a href="#synthesizer">Synthesizer</a>]\n' + |
| 11 | + '}\n'; |
| 12 | + |
1 | 13 | const TOC_MOBILE =
|
2 | 14 | '<strong>ToC</strong> = {\n' +
|
3 | 15 | ' <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' +
|
@@ -262,9 +274,20 @@ if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine
|
262 | 274 | isMobile = true;
|
263 | 275 | }
|
264 | 276 |
|
265 |
| -if (isMobile && window.screen.width < 667) { |
266 |
| - $(`code:contains(ToC)`).html(TOC_MOBILE); |
| 277 | +val TOC_SCREEN_WIDTH_CUTOFF = 400 |
| 278 | + |
| 279 | +if (isMobile && window.screen.width < TOC_SCREEN_WIDTH_CUTOFF) { |
| 280 | + $(`code:contains(ToC)`).html(TOC_MOBILE); |
| 281 | +} |
| 282 | + |
| 283 | +function updateToc() { |
| 284 | + if (isMobile && window.screen.width < TOC_SCREEN_WIDTH_CUTOFF) { |
| 285 | + $(`code:contains(ToC)`).html(TOC_MOBILE); |
| 286 | + } else { |
| 287 | + $(`code:contains(ToC)`).html(TOC); |
| 288 | + } |
267 | 289 | }
|
| 290 | +window.addEventListener("orientationchange", updateToc, false); |
268 | 291 |
|
269 | 292 | // ===== Scroll to Top ====
|
270 | 293 | $(window).scroll(function() {
|
|
0 commit comments