From 889a79a2b5281793ea91d19cad9a6020d473240a Mon Sep 17 00:00:00 2001 From: kgashok Date: Thu, 20 Jul 2017 01:13:04 +0530 Subject: [PATCH 01/33] Update gfm-add-toc.user.js added missing semicolon; removed unnecessary spaces to format TOC properly. --- gfm-add-toc.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 5a3e0a9..6b1e396 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -29,7 +29,7 @@ button.setAttribute('tabindex', '-1'); button.setAttribute('title', 'Refresh table of contents'); button.setAttribute('role', 'button'); - button.innerHTML = 'TOC' + button.innerHTML = 'TOC'; button.onclick = function() { self.insertTOC(textarea); }; @@ -66,7 +66,7 @@ var md = textarea.value; /* Strip out existing TOC, if any */ - var tocStart = '** Table of contents **\n\n'; + var tocStart = '**Table of Contents**\n\n'; if (md.startsWith(tocStart)) md = md.substring(tocStart.length).replace(/[^]*?\n\n/m, ''); From 3f12d8ac777345b7531143564eeb86d555f89e0d Mon Sep 17 00:00:00 2001 From: kgashok Date: Thu, 20 Jul 2017 03:03:24 +0530 Subject: [PATCH 02/33] Update gfm-add-toc.user.js - Replaced **href** with **button** element; still some more styling to be done --- gfm-add-toc.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 6b1e396..23c4cb4 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -6,6 +6,7 @@ // @grant none // ==/UserScript== + (function(){ if (window.location.host != 'github.com' || !window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/)) @@ -22,14 +23,13 @@ var self = this; - var button = document.createElement('a'); + var button = document.createElement("button"); + button.type = 'button'; button.id = 'function-toc'; - button.href = '#'; - button.className = 'minibutton function-button'; + button.class = 'btn btn-sm function-button'; button.setAttribute('tabindex', '-1'); button.setAttribute('title', 'Refresh table of contents'); - button.setAttribute('role', 'button'); - button.innerHTML = 'TOC'; + button.innerHTML = 'ToC'; button.onclick = function() { self.insertTOC(textarea); }; From 4408bcc9d736cc9530e936411a5b808ac273d2f2 Mon Sep 17 00:00:00 2001 From: kgashok Date: Thu, 20 Jul 2017 03:19:39 +0530 Subject: [PATCH 03/33] Update gfm-add-toc.user.js - commented out the setTimeOut. Why is there? - added the right button style - ToC now appears before h1 --- gfm-add-toc.user.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 23c4cb4..64dd6d3 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -26,7 +26,7 @@ var button = document.createElement("button"); button.type = 'button'; button.id = 'function-toc'; - button.class = 'btn btn-sm function-button'; + button.className = 'btn btn-sm BtnGroup-item function-button'; button.setAttribute('tabindex', '-1'); button.setAttribute('title', 'Refresh table of contents'); button.innerHTML = 'ToC'; @@ -34,9 +34,8 @@ self.insertTOC(textarea); }; h1Button.parentNode.insertBefore(button, h1Button); - /* GitHub disables this button ;-) */ - setTimeout(function() { button.className = 'minibutton function-button'; }, 100); + //setTimeout(function() { button.className = 'minibutton function-button'; }, 100); /* Helper to generate the Table of Contents entries */ var toPlainText = function(list) { From 47ae6c9e67d472b0ce891d34590e9bc94708935f Mon Sep 17 00:00:00 2001 From: kgashok Date: Thu, 20 Jul 2017 04:18:06 +0530 Subject: [PATCH 04/33] Update gfm-add-toc.user.js Resolved #1 for Firefox usage by reintroducing the setTimeOut code --- gfm-add-toc.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 64dd6d3..d342792 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -35,7 +35,7 @@ }; h1Button.parentNode.insertBefore(button, h1Button); /* GitHub disables this button ;-) */ - //setTimeout(function() { button.className = 'minibutton function-button'; }, 100); + setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); /* Helper to generate the Table of Contents entries */ var toPlainText = function(list) { From 14cf7022b31230cb203a020c91805ff517b2e3e5 Mon Sep 17 00:00:00 2001 From: kgashok Date: Thu, 20 Jul 2017 04:33:54 +0530 Subject: [PATCH 05/33] Update gfm-add-toc.user.js Firefox not working, commenting out the timeOut again. --- gfm-add-toc.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index d342792..7060394 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -26,7 +26,7 @@ var button = document.createElement("button"); button.type = 'button'; button.id = 'function-toc'; - button.className = 'btn btn-sm BtnGroup-item function-button'; + button.className = 'btn btn-sm function-button'; button.setAttribute('tabindex', '-1'); button.setAttribute('title', 'Refresh table of contents'); button.innerHTML = 'ToC'; @@ -35,7 +35,7 @@ }; h1Button.parentNode.insertBefore(button, h1Button); /* GitHub disables this button ;-) */ - setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); + //setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); /* Helper to generate the Table of Contents entries */ var toPlainText = function(list) { From 13617e8f64857ab7f72130cc25163baf25a74008 Mon Sep 17 00:00:00 2001 From: kgashok Date: Fri, 21 Jul 2017 17:27:47 +0530 Subject: [PATCH 06/33] Create README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4402e13 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# tomancaklab.github.io +The website of the Tomancak Lab + + +Reproduced verbatim from the authors' [answer](https://stackoverflow.com/a/29012394/307454) on Stackoverflow: + +> My colleague @schmiedc and I have created a GreaseMonkey script that installs a new TOC button left of the h1 button which uses the excellent markdown-js library to add/refresh a table of contents. +> The advantage over solutions like doctoc is that it integrates into GitHub's wiki editor and does not need users to work on their command-line (and require users to install tools like node.js). In Chrome, it works by drag 'n dropping into the Extensions page, in Firefox you will need to install the GreaseMonkey extension. +> It will work with plain markdown (i.e. it does not handle code blocks correctly, as that is a GitHub extension to markdown). Contributions welcome. From 2abb13bd492bd5df34ab3a616c85cce29b27d100 Mon Sep 17 00:00:00 2001 From: kgashok Date: Fri, 21 Jul 2017 18:16:12 +0530 Subject: [PATCH 07/33] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 4402e13..9af1b45 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,8 @@ Reproduced verbatim from the authors' [answer](https://stackoverflow.com/a/29012 > My colleague @schmiedc and I have created a GreaseMonkey script that installs a new TOC button left of the h1 button which uses the excellent markdown-js library to add/refresh a table of contents. > The advantage over solutions like doctoc is that it integrates into GitHub's wiki editor and does not need users to work on their command-line (and require users to install tools like node.js). In Chrome, it works by drag 'n dropping into the Extensions page, in Firefox you will need to install the GreaseMonkey extension. > It will work with plain markdown (i.e. it does not handle code blocks correctly, as that is a GitHub extension to markdown). Contributions welcome. + + +# Test Drive + +Test drive the script here https://github.com/kgashok/tomancaklab.github.io/wiki From e9bf64661d3330ca7bc9bdd0de2abc78fc7b261b Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 12:48:06 +0530 Subject: [PATCH 08/33] Create lab7-kgashok.py.md --- lab7-kgashok.py.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 lab7-kgashok.py.md diff --git a/lab7-kgashok.py.md b/lab7-kgashok.py.md new file mode 100644 index 0000000..72a0b5c --- /dev/null +++ b/lab7-kgashok.py.md @@ -0,0 +1,6 @@ +# Header 1 + +# Header 2 + +## Header 33 + From 9afa8abdf10fd0a1972326ba2046ebba65d1650c Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 12:50:59 +0530 Subject: [PATCH 09/33] Update lab7-kgashok.py.md --- lab7-kgashok.py.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lab7-kgashok.py.md b/lab7-kgashok.py.md index 72a0b5c..89dc5b9 100644 --- a/lab7-kgashok.py.md +++ b/lab7-kgashok.py.md @@ -1,6 +1,16 @@ +**Table of Contents** + +* [Header 1](#header-1) +* [Header 2](#header-2) + * [Header 33](#header-33) + + + # Header 1 # Header 2 ## Header 33 + + From bc9b56d67b2e777f0a10c7243f5393a0845c3b94 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 12:52:07 +0530 Subject: [PATCH 10/33] Update lab7-kgashok.py.md --- lab7-kgashok.py.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lab7-kgashok.py.md b/lab7-kgashok.py.md index 89dc5b9..6f2ecd7 100644 --- a/lab7-kgashok.py.md +++ b/lab7-kgashok.py.md @@ -3,6 +3,7 @@ * [Header 1](#header-1) * [Header 2](#header-2) * [Header 33](#header-33) + * [Header 44](#header-44) @@ -12,5 +13,7 @@ ## Header 33 +## Header 44 + From 11b5ae5d5c1b16769b0905d0d52035d167e123c9 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 12:52:45 +0530 Subject: [PATCH 11/33] Update lab7-kgashok.py.md --- lab7-kgashok.py.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lab7-kgashok.py.md b/lab7-kgashok.py.md index 6f2ecd7..2649c1f 100644 --- a/lab7-kgashok.py.md +++ b/lab7-kgashok.py.md @@ -4,6 +4,7 @@ * [Header 2](#header-2) * [Header 33](#header-33) * [Header 44](#header-44) + * [Header 55](#header-55) @@ -15,5 +16,4 @@ ## Header 44 - - +## Header 55 From a16861c8bcab7c0369bbd625cec9a90b3a87e532 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 14:55:05 +0530 Subject: [PATCH 12/33] Update lab7-kgashok.py.md --- lab7-kgashok.py.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lab7-kgashok.py.md b/lab7-kgashok.py.md index 2649c1f..35aa459 100644 --- a/lab7-kgashok.py.md +++ b/lab7-kgashok.py.md @@ -5,6 +5,7 @@ * [Header 33](#header-33) * [Header 44](#header-44) * [Header 55](#header-55) + * [Header 66](#header-66) @@ -17,3 +18,5 @@ ## Header 44 ## Header 55 + +## Header 66 From b1e7751c8c4af581d6c46250392f65a8e40beb94 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 15:06:38 +0530 Subject: [PATCH 13/33] Update gfm-add-toc.user.js --- gfm-add-toc.user.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 7060394..a264fc1 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -3,18 +3,41 @@ // @namespace tomancaklab // @include http://github.com/*/wiki/*/_edit* // @include https://github.com/*/wiki/*/_edit* +// @include https://github.com/*/edit* // @grant none // ==/UserScript== (function(){ if (window.location.host != 'github.com' || - !window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/)) - return; // not editing a GitHub wiki page + !(window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/) || + window.location.pathname.match(/.*\/edit\/.*#?$/))) { + console.log("not on github!"); + if (window.location.host != 'stackedit.co') { + console.log("not on stackedit either!"); + return; // not editing a GitHub wiki page or on stackedit + } + } var textarea = document.getElementById('gollum-editor-body'); + if (!textarea) { + var fileInput = document.getElementsByClassName('form-control js-blob-filename js-breadcrumb-nav')[0]; + var fileNameClassName = 'blob_contents_' + fileInput.value; + fileNameClassName = fileNameClassName.replace(/\./g,'-'); + console.log(fileNameClassName); + textarea = document.getElementById(fileNameClassName); + } var h1Button = document.getElementById('function-h1'); - if (!textarea || !h1Button) { + var editButton; + //if (!h1Button) { + // h1Button = document.getElementById('wmd-bold-button'); + // console.log ("h1Button from stackedit.io"); + //} + if (!h1Button) { + var y = document.getElementsByClassName("btn-link preview tabnav-tab js-blob-edit-preview")[0]; + editButton = y; + } + if (!textarea || !(h1Button || editButton)) { console.log("Could not find text area or

button"); console.log(textarea); console.log(h1Button); @@ -33,7 +56,11 @@ button.onclick = function() { self.insertTOC(textarea); }; - h1Button.parentNode.insertBefore(button, h1Button); + if(h1Button) + h1Button.parentNode.insertBefore(button, h1Button); + else + editButton.parentNode.insertAdjacentElement('afterbegin', button); + /* GitHub disables this button ;-) */ //setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); From a1206be66b808b61f270e50d42d77d4e8690b64e Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 15:24:10 +0530 Subject: [PATCH 14/33] Update gfm-add-toc.user.js Included "Edit File" button for error prompts. --- gfm-add-toc.user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index a264fc1..eab4899 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -38,9 +38,10 @@ editButton = y; } if (!textarea || !(h1Button || editButton)) { - console.log("Could not find text area or

button"); - console.log(textarea); - console.log(h1Button); + console.log("Could not find text area or

button or "Edit File" button"); + console.log("text area:", textarea); + console.log("h1:", h1Button); + console.log("Edit:", editButton); return; } From ae6817259dcfc0eb29b966fd8f99fde2bf3a9a49 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 15:56:36 +0530 Subject: [PATCH 15/33] Update gfm-add-toc.user.js - Using querySelector (more widely supported versus getElementsByClassName) - changed the ToC styling to match Edit button --- gfm-add-toc.user.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index eab4899..1b77d6f 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -34,14 +34,14 @@ // console.log ("h1Button from stackedit.io"); //} if (!h1Button) { - var y = document.getElementsByClassName("btn-link preview tabnav-tab js-blob-edit-preview")[0]; + //var y = document.getElementsByClassName("btn-link preview tabnav-tab js-blob-edit-preview")[0]; + var y = document.querySelector("button.btn-link.preview.tabnav-tab.js-blob-edit-preview"); editButton = y; } if (!textarea || !(h1Button || editButton)) { - console.log("Could not find text area or

button or "Edit File" button"); - console.log("text area:", textarea); - console.log("h1:", h1Button); - console.log("Edit:", editButton); + console.log("Could not find text area or

button"); + console.log(textarea); + console.log(h1Button); return; } @@ -59,8 +59,10 @@ }; if(h1Button) h1Button.parentNode.insertBefore(button, h1Button); - else + else { + button.className = "btn-link code selected tabnav-tab js-blob-edit-code"; editButton.parentNode.insertAdjacentElement('afterbegin', button); + } /* GitHub disables this button ;-) */ //setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); From 46e3896d566fab2c52691038b84a8de0c0e690c3 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 16:02:22 +0530 Subject: [PATCH 16/33] Update gfm-add-toc.user.js folded back the more detailed error prompts. --- gfm-add-toc.user.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 1b77d6f..13115a3 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -39,9 +39,10 @@ editButton = y; } if (!textarea || !(h1Button || editButton)) { - console.log("Could not find text area or

button"); - console.log(textarea); - console.log(h1Button); + console.log("Could not find text area or

button or "Edit File" button"); + console.log("text area:", textarea); + console.log("h1:", h1Button); + console.log("Edit:", editButton); return; } From e00d24a0e04e86b602eab482b8c15da09c5d39f3 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 16:08:12 +0530 Subject: [PATCH 17/33] Update gfm-add-toc.user.js Double quotation error fixed. --- gfm-add-toc.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 13115a3..1733ba7 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -39,10 +39,10 @@ editButton = y; } if (!textarea || !(h1Button || editButton)) { - console.log("Could not find text area or

button or "Edit File" button"); + console.log("Could not find text area or

button or \"Edit File\" button"); console.log("text area:", textarea); console.log("h1:", h1Button); - console.log("Edit:", editButton); + console.log("Edit:", editButton); return; } From f773aea6d8f6f4556249fbdeed75ec53d945b4d0 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 16:35:36 +0530 Subject: [PATCH 18/33] Update gfm-add-toc.user.js removed stackedit.io related code for now. --- gfm-add-toc.user.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 1733ba7..89dd07f 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -13,10 +13,7 @@ !(window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/) || window.location.pathname.match(/.*\/edit\/.*#?$/))) { console.log("not on github!"); - if (window.location.host != 'stackedit.co') { - console.log("not on stackedit either!"); - return; // not editing a GitHub wiki page or on stackedit - } + return; // not editing a GitHub wiki page or github repo file } var textarea = document.getElementById('gollum-editor-body'); @@ -29,10 +26,6 @@ } var h1Button = document.getElementById('function-h1'); var editButton; - //if (!h1Button) { - // h1Button = document.getElementById('wmd-bold-button'); - // console.log ("h1Button from stackedit.io"); - //} if (!h1Button) { //var y = document.getElementsByClassName("btn-link preview tabnav-tab js-blob-edit-preview")[0]; var y = document.querySelector("button.btn-link.preview.tabnav-tab.js-blob-edit-preview"); From dc8e3d2c377863e37a40d1811eff8635b0b01a66 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 17:01:33 +0530 Subject: [PATCH 19/33] Create Capitalized-file.py.md --- Capitalized-file.py.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Capitalized-file.py.md diff --git a/Capitalized-file.py.md b/Capitalized-file.py.md new file mode 100644 index 0000000..4263d80 --- /dev/null +++ b/Capitalized-file.py.md @@ -0,0 +1,7 @@ +# Header 1 + +For files with capitalized characters, ToC must be generated. + +# Header 22 + + From e460941ac410fd8264d200c217fc434300bfbac2 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 17:10:41 +0530 Subject: [PATCH 20/33] Update Capitalized-file.py.md --- Capitalized-file.py.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Capitalized-file.py.md b/Capitalized-file.py.md index 4263d80..6d071f4 100644 --- a/Capitalized-file.py.md +++ b/Capitalized-file.py.md @@ -1,3 +1,10 @@ +**Table of Contents** + +* [Header 1](#header-1) +* [Header 22](#header-22) + + + # Header 1 For files with capitalized characters, ToC must be generated. From 7c508d227847bf27c445402a93f1728808d2e0f3 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 17:14:39 +0530 Subject: [PATCH 21/33] Update gfm-add-toc.user.js Resolved https://github.com/kgashok/tomancaklab.github.io/issues/8 by using toLowerCase --- gfm-add-toc.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 89dd07f..5fa4331 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -20,7 +20,7 @@ if (!textarea) { var fileInput = document.getElementsByClassName('form-control js-blob-filename js-breadcrumb-nav')[0]; var fileNameClassName = 'blob_contents_' + fileInput.value; - fileNameClassName = fileNameClassName.replace(/\./g,'-'); + fileNameClassName = fileNameClassName.toLowerCase().replace(/\./g,'-'); console.log(fileNameClassName); textarea = document.getElementById(fileNameClassName); } From fa39d46a31014c93b92a6dc8fe1379fcfbdd637e Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 17:49:09 +0530 Subject: [PATCH 22/33] Update gfm-add-toc.user.js --- gfm-add-toc.user.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 5fa4331..644173f 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -28,8 +28,8 @@ var editButton; if (!h1Button) { //var y = document.getElementsByClassName("btn-link preview tabnav-tab js-blob-edit-preview")[0]; - var y = document.querySelector("button.btn-link.preview.tabnav-tab.js-blob-edit-preview"); - editButton = y; + //var y = document.querySelector("button.btn-link.preview.tabnav-tab.js-blob-edit-preview"); + editButton = document.querySelector(".js-blob-edit-preview"); } if (!textarea || !(h1Button || editButton)) { console.log("Could not find text area or

button or \"Edit File\" button"); From 206d1b82a771195422045c254c33477a98e056d0 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 21:40:11 +0530 Subject: [PATCH 23/33] Update gfm-add-toc.user.js Resolved https://github.com/kgashok/tomancaklab.github.io/issues/3 by using the appropriate regex --- gfm-add-toc.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 644173f..fea3b31 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -11,7 +11,7 @@ (function(){ if (window.location.host != 'github.com' || !(window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/) || - window.location.pathname.match(/.*\/edit\/.*#?$/))) { + window.location.pathname.match(/.*\/edit\/.*\.md$/))) { console.log("not on github!"); return; // not editing a GitHub wiki page or github repo file } From d4b73581f3861ed56a567e2146033b9f68f74dcf Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 22:08:38 +0530 Subject: [PATCH 24/33] Update lab7-kgashok.py.md --- lab7-kgashok.py.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lab7-kgashok.py.md b/lab7-kgashok.py.md index 35aa459..0d59d37 100644 --- a/lab7-kgashok.py.md +++ b/lab7-kgashok.py.md @@ -6,6 +6,7 @@ * [Header 44](#header-44) * [Header 55](#header-55) * [Header 66](#header-66) + * [Header 77](#header-77) @@ -20,3 +21,5 @@ ## Header 55 ## Header 66 + +## Header 77 From e7bc0dcf573d37312ae347025a5e346ac1d0d5b7 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 22:20:07 +0530 Subject: [PATCH 25/33] Update gfm-add-toc.user.js Refactored code to be self documented. --- gfm-add-toc.user.js | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index fea3b31..5cada68 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -9,29 +9,34 @@ (function(){ + var editingWiki = window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/); + var editingMDfile = window.location.pathname.match(/.*\/edit\/.*\.md$/); if (window.location.host != 'github.com' || - !(window.location.pathname.match(/.*\/wiki\/.*\/_edit#?$/) || - window.location.pathname.match(/.*\/edit\/.*\.md$/))) { + !(editingWiki || editingMDfile)){ console.log("not on github!"); return; // not editing a GitHub wiki page or github repo file } - var textarea = document.getElementById('gollum-editor-body'); - if (!textarea) { - var fileInput = document.getElementsByClassName('form-control js-blob-filename js-breadcrumb-nav')[0]; - var fileNameClassName = 'blob_contents_' + fileInput.value; - fileNameClassName = fileNameClassName.toLowerCase().replace(/\./g,'-'); - console.log(fileNameClassName); - textarea = document.getElementById(fileNameClassName); + var textarea, childElement, h1Button, editButton, buttonClass; + if (editingWiki) { + textarea = document.getElementById('gollum-editor-body'); + childElement = h1Button = document.getElementById('function-h1'); + buttonClass = 'btn btn-sm function-button'; } - var h1Button = document.getElementById('function-h1'); - var editButton; - if (!h1Button) { + else if (editingMDfile) { + //var fileInput = document.getElementsByClassName('form-control js-blob-filename js-breadcrumb-nav')[0]; + var fileInput = document.querySelector(".js-blob-filename.js-breadcrumb-nav"); + var fileNameClassName = 'blob_contents_' + fileInput.value; + fileNameClassName = fileNameClassName.toLowerCase().replace(/\./g,'-'); + console.log(fileNameClassName); + textarea = document.getElementById(fileNameClassName); //var y = document.getElementsByClassName("btn-link preview tabnav-tab js-blob-edit-preview")[0]; //var y = document.querySelector("button.btn-link.preview.tabnav-tab.js-blob-edit-preview"); - editButton = document.querySelector(".js-blob-edit-preview"); + childElement = editButton = document.querySelector(".js-blob-edit-preview"); + buttonClass = 'btn-link code selected tabnav-tab js-blob-edit-code'; } - if (!textarea || !(h1Button || editButton)) { + + if (!textarea || !childElement) { console.log("Could not find text area or

button or \"Edit File\" button"); console.log("text area:", textarea); console.log("h1:", h1Button); @@ -44,19 +49,15 @@ var button = document.createElement("button"); button.type = 'button'; button.id = 'function-toc'; - button.className = 'btn btn-sm function-button'; + button.className = buttonClass; button.setAttribute('tabindex', '-1'); button.setAttribute('title', 'Refresh table of contents'); button.innerHTML = 'ToC'; button.onclick = function() { self.insertTOC(textarea); }; - if(h1Button) - h1Button.parentNode.insertBefore(button, h1Button); - else { - button.className = "btn-link code selected tabnav-tab js-blob-edit-code"; - editButton.parentNode.insertAdjacentElement('afterbegin', button); - } + //if h1Button -> childElement.parentNode.insertBefore(button, h1Button); + childElement.parentNode.insertAdjacentElement('afterbegin', button); /* GitHub disables this button ;-) */ //setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); From a2399e52ac223328f231f81781bd0f310908d960 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 23:03:06 +0530 Subject: [PATCH 26/33] Update gfm-add-toc.user.js trying to fix firefox disabling. --- gfm-add-toc.user.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 5cada68..7411bc8 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -56,8 +56,10 @@ button.onclick = function() { self.insertTOC(textarea); }; - //if h1Button -> childElement.parentNode.insertBefore(button, h1Button); - childElement.parentNode.insertAdjacentElement('afterbegin', button); + if (h1Button) + childElement.parentNode.insertBefore(button, h1Button); + else + childElement.parentNode.insertAdjacentElement('afterbegin', button); /* GitHub disables this button ;-) */ //setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); From cd2a89ed8b5e4a7fa559a8144263a6028661f308 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 23:33:40 +0530 Subject: [PATCH 27/33] Update gfm-add-toc.user.js --- gfm-add-toc.user.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 7411bc8..09f8703 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -62,7 +62,8 @@ childElement.parentNode.insertAdjacentElement('afterbegin', button); /* GitHub disables this button ;-) */ - //setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); + if (h1Button) + setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); /* Helper to generate the Table of Contents entries */ var toPlainText = function(list) { From 416acb67536be4bb81f5c74d7f93c8abf9bfa07b Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 23:40:18 +0530 Subject: [PATCH 28/33] Update gfm-add-toc.user.js Refactored to remove an 'if' - have to make sure it doesn't break Firefox --- gfm-add-toc.user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 09f8703..287a096 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -56,10 +56,10 @@ button.onclick = function() { self.insertTOC(textarea); }; - if (h1Button) - childElement.parentNode.insertBefore(button, h1Button); - else - childElement.parentNode.insertAdjacentElement('afterbegin', button); + //if (h1Button) + // childElement.parentNode.insertBefore(button, h1Button); + //else + childElement.parentNode.insertAdjacentElement('afterbegin', button); /* GitHub disables this button ;-) */ if (h1Button) From 5f2d6164f168c91685cf9496ad34a80091a94d53 Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 23:45:20 +0530 Subject: [PATCH 29/33] Update gfm-add-toc.user.js One more refactor - need to check Firefox --- gfm-add-toc.user.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 287a096..f3f052d 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -21,7 +21,7 @@ if (editingWiki) { textarea = document.getElementById('gollum-editor-body'); childElement = h1Button = document.getElementById('function-h1'); - buttonClass = 'btn btn-sm function-button'; + buttonClass = 'btn btn-sm BtnGroup-item function-button'; } else if (editingMDfile) { //var fileInput = document.getElementsByClassName('form-control js-blob-filename js-breadcrumb-nav')[0]; @@ -56,14 +56,11 @@ button.onclick = function() { self.insertTOC(textarea); }; - //if (h1Button) - // childElement.parentNode.insertBefore(button, h1Button); - //else - childElement.parentNode.insertAdjacentElement('afterbegin', button); + childElement.parentNode.insertAdjacentElement('afterbegin', button); /* GitHub disables this button ;-) */ - if (h1Button) - setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); + //if (h1Button) + // setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); /* Helper to generate the Table of Contents entries */ var toPlainText = function(list) { From f7948af075692ee48ff0cfea77df28d7b11aa58c Mon Sep 17 00:00:00 2001 From: kgashok Date: Mon, 24 Jul 2017 23:49:17 +0530 Subject: [PATCH 30/33] Update gfm-add-toc.user.js Re-introduced the setTimeout to re-enable the ToC button on Firefox --- gfm-add-toc.user.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index f3f052d..b7f18d9 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -58,9 +58,9 @@ }; childElement.parentNode.insertAdjacentElement('afterbegin', button); - /* GitHub disables this button ;-) */ - //if (h1Button) - // setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); + /* GitHub disables this button on Firefox; need to re-enable it again ;-) */ + if (h1Button) + setTimeout(function() { button.className = 'btn btn-sm BtnGroup-item function-button'; }, 100); /* Helper to generate the Table of Contents entries */ var toPlainText = function(list) { From e53bab7daac6c2c3392b45c736d36fb64fc9b87f Mon Sep 17 00:00:00 2001 From: kgashok Date: Tue, 25 Jul 2017 00:09:09 +0530 Subject: [PATCH 31/33] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 9af1b45..a913f92 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +**Table of Contents** + +* [tomancaklab.github.io](#tomancaklabgithubio) +* [Test Drive](#test-drive) + + + # tomancaklab.github.io The website of the Tomancak Lab From 777b28e0bd201f8239754788b5f894271b68cbbe Mon Sep 17 00:00:00 2001 From: kgashok Date: Tue, 25 Jul 2017 00:34:37 +0530 Subject: [PATCH 32/33] Update gfm-add-toc.user.js Resolved #15 --- gfm-add-toc.user.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfm-add-toc.user.js b/gfm-add-toc.user.js index 644173f..4b65b90 100644 --- a/gfm-add-toc.user.js +++ b/gfm-add-toc.user.js @@ -105,7 +105,7 @@ var anchor = plainText.toLowerCase() .replace(/ /g, '-') .replace(/[^-A-Za-z0-9]/g, ''); - toc += '* [' + plainText + '](#' + anchor + ')\n'; + toc += '* [' + plainText + '](#' + anchor + ') \n'; } }); toc += '\n'; From 55069af3fe943b0518464a6d09729ef6a3248689 Mon Sep 17 00:00:00 2001 From: kgashok Date: Tue, 25 Jul 2017 22:17:10 +0530 Subject: [PATCH 33/33] Create file1 --- file1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 file1 diff --git a/file1 b/file1 new file mode 100644 index 0000000..fba6d5d --- /dev/null +++ b/file1 @@ -0,0 +1 @@ +Intentionally left blank