From 6f7f951fb3ff2d4d411205c132410a084dbcf270 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Wed, 3 Mar 2021 16:33:50 +0530 Subject: [PATCH 01/12] Update toys.ts --- src/content/toys.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 08f3c4b5..9d392728 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -9,21 +9,17 @@ */ export function jack_in() { // chinese characters - taken from the unicode charset - const chinese = "田由甲申甴电甶男甸甹町画甼甽甾甿畀畁畂畃畄畅畆畇畈畉畊畋界畍畎畏畐畑".split( - "", - ) + const chinese = "田由甲申甴电甶男甸甹町画甼甽甾甿畀畁畂畃畄畅畆畇畈畉畊畋界畍畎畏畐畑".split("") const colour = "#0F0" // green text - rain(chinese, colour) + rain(makeBlock(), chinese, colour) } - export function no_mouse() { - rain([" "], "#FFF", 0) // No characters, unused colour code, no darkening + makeBlock() } -export const snow = () => rain(["❄"], "#FFF", 0.15) - -export function rain(characters: string[], colour, darkening = 0.05) { +function makeBlock() { const d = document.createElement("div") + d.className = "_tridactyl_no_mouse_" d.style.position = "fixed" d.style.display = "block" d.style.width = "100%" @@ -33,7 +29,17 @@ export function rain(characters: string[], colour, darkening = 0.05) { d.style.right = "0" d.style.bottom = "0" d.style.zIndex = "1000" - d.style.opacity = "0.5" + d.style.opacity = "1" + return d +} + +function removeBlock() { + document.getElementsByClassName("_tridactyl_no_mouse_").map(el=>{clearInterval(el.intid); el.remove()}) +} + +export const snow = () => rain(makeBlock(), ["❄"], "#FFF", 0.15) + +export function rain(d, characters: string[], colour, darkening = 0.05) { const c = document.createElement("canvas") d.appendChild(c) document.body.appendChild(d) @@ -79,6 +85,6 @@ export function rain(characters: string[], colour, darkening = 0.05) { drops[i]++ } } - - setInterval(draw, 33) + intid = setInterval(draw, 33) + d.intid = intid } From cf7d9a48b52e513a63201046b8f09fff40e50ec7 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Fri, 5 Mar 2021 00:19:49 +0530 Subject: [PATCH 02/12] Update toys.ts --- src/content/toys.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 9d392728..ff98741d 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -22,19 +22,25 @@ function makeBlock() { d.className = "_tridactyl_no_mouse_" d.style.position = "fixed" d.style.display = "block" - d.style.width = "100%" - d.style.height = "100%" + d.style.width = window.innerWidth + d.style.height = window.innerHeight d.style.top = "0" d.style.left = "0" d.style.right = "0" d.style.bottom = "0" d.style.zIndex = "1000" d.style.opacity = "1" + document.body.appendChild(d) return d } function removeBlock() { - document.getElementsByClassName("_tridactyl_no_mouse_").map(el=>{clearInterval(el.intid); el.remove()}) + document.getElementsByClassName("_tridactyl_no_mouse_").map(el=>{ + if(el.intid!=null){ + clearInterval(el.intid) + } + el.remove(); + }); } export const snow = () => rain(makeBlock(), ["❄"], "#FFF", 0.15) @@ -42,7 +48,6 @@ export const snow = () => rain(makeBlock(), ["❄"], "#FFF", 0.15) export function rain(d, characters: string[], colour, darkening = 0.05) { const c = document.createElement("canvas") d.appendChild(c) - document.body.appendChild(d) const ctx = c.getContext("2d") // making the canvas full screen From 57df8d24d2cb00bbab3f166647d5c90a5c17170a Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Fri, 5 Mar 2021 00:33:26 +0530 Subject: [PATCH 03/12] Update excmds.ts --- src/excmds.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/excmds.ts b/src/excmds.ts index 3089f5db..f429eb3e 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1565,6 +1565,8 @@ export async function credits() { * * Suggested usage: `autocmd DocLoad .* no_mouse_mode` * + * To revert, use [[mouse_mode]] + * * "There is no mouse". */ //#content @@ -1585,13 +1587,31 @@ export function neo_mouse_mode() { } /** - * Christmas variant of [[no_mouse_mode]] (if you live in $DEFAULT hemisphere). + * Christmas variant of [[no_mouse_mode]]. */ //#content export function snow_mouse_mode() { toys.snow() } +/** +* Music variant of [[no_mouse_mode]]. +*/ +//#content +export function pied_piper_mouse_mode() { + toys.music() +} + +/** + * Revert any variant of the no_mouse_mode + * + * Suggested usage: `bind mouse_mode` + */ +//#content +export function mouse_mode() { + toys.removeBlock() +} + /** @hidden */ // Find clickable next-page/previous-page links whose text matches the supplied pattern, // and return the last such link. From 6d4ddba226ae36c874ad17894eaec7684c5bf453 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Fri, 5 Mar 2021 00:42:18 +0530 Subject: [PATCH 04/12] Add music --- src/content/toys.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index ff98741d..9ac5c080 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -5,7 +5,7 @@ * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIN, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ export function jack_in() { // chinese characters - taken from the unicode charset @@ -13,6 +13,15 @@ export function jack_in() { const colour = "#0F0" // green text rain(makeBlock(), chinese, colour) } + + +export function music() { + // music characters - taken from the unicode charset + const music = "𝄞𝄟𝄰𝅘𝅥𝅮𝅘𝅥𝅯𝅘𝅥𝅰𝄽".split("") + const colour = "#ead115" + rain(makeBlock(), music, colour) +} + export function no_mouse() { makeBlock() } @@ -29,7 +38,7 @@ function makeBlock() { d.style.right = "0" d.style.bottom = "0" d.style.zIndex = "1000" - d.style.opacity = "1" + d.style.opacity = "0.5" document.body.appendChild(d) return d } From 84b4e9d64dff41cd23279711bc4ab0f5182b5bf5 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Fri, 5 Mar 2021 02:14:33 +0530 Subject: [PATCH 05/12] Update src/excmds.ts to fix documentation Co-authored-by: Oliver Blanthorn --- src/excmds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excmds.ts b/src/excmds.ts index f429eb3e..3f331374 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1603,7 +1603,7 @@ export function pied_piper_mouse_mode() { } /** - * Revert any variant of the no_mouse_mode + * Revert any variant of the [[no_mouse_mode]] * * Suggested usage: `bind mouse_mode` */ From 45054a59f62514b67f538287760523653a7bacb0 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Fri, 5 Mar 2021 02:15:31 +0530 Subject: [PATCH 06/12] Revert inadvertent license change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thank God for diffs, or I'd be in jail 😱 Co-authored-by: Oliver Blanthorn --- src/content/toys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 9ac5c080..1d9f8ed3 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -5,7 +5,7 @@ * * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIN, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ export function jack_in() { // chinese characters - taken from the unicode charset From aeb1fd20923eeab44859cf3d5af087d1f041a046 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Fri, 5 Mar 2021 16:07:42 +0100 Subject: [PATCH 07/12] Fix errors preventing build --- src/content/toys.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 1d9f8ed3..1599d46a 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -31,8 +31,8 @@ function makeBlock() { d.className = "_tridactyl_no_mouse_" d.style.position = "fixed" d.style.display = "block" - d.style.width = window.innerWidth - d.style.height = window.innerHeight + d.style.width = String(window.innerWidth) + d.style.height = String(window.innerHeight) d.style.top = "0" d.style.left = "0" d.style.right = "0" @@ -43,13 +43,13 @@ function makeBlock() { return d } -function removeBlock() { - document.getElementsByClassName("_tridactyl_no_mouse_").map(el=>{ - if(el.intid!=null){ - clearInterval(el.intid) +export function removeBlock() { + Array.from(document.getElementsByClassName("_tridactyl_no_mouse_")).map(el=>{ + if((el as any).intid!=null){ + clearInterval((el as any).intid) } - el.remove(); - }); + el.remove() + }) } export const snow = () => rain(makeBlock(), ["❄"], "#FFF", 0.15) @@ -99,6 +99,5 @@ export function rain(d, characters: string[], colour, darkening = 0.05) { drops[i]++ } } - intid = setInterval(draw, 33) - d.intid = intid + d.intid = setInterval(draw, 33) } From 738d7cafa2c83dfeba7c6bd4db48dbafa4cd1314 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Tue, 9 Mar 2021 14:19:30 +0000 Subject: [PATCH 08/12] Tighten element type Co-authored-by: Rummskartoffel <20257197+Rummskartoffel@users.noreply.github.com> --- src/content/toys.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 1599d46a..50f41e72 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -44,9 +44,9 @@ function makeBlock() { } export function removeBlock() { - Array.from(document.getElementsByClassName("_tridactyl_no_mouse_")).map(el=>{ - if((el as any).intid!=null){ - clearInterval((el as any).intid) + Array.from(document.getElementsByClassName("_tridactyl_no_mouse_")).map((el: Element & { intid?: number | null}) => { + if(typeof el.intid === "number") { + clearInterval(el.intid) } el.remove() }) From b7ba379b71b75f50722af6792604ba842e362505 Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Tue, 9 Mar 2021 15:24:09 +0100 Subject: [PATCH 09/12] Restore important source of humour --- src/excmds.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/excmds.ts b/src/excmds.ts index 3f331374..af54bca4 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1587,7 +1587,7 @@ export function neo_mouse_mode() { } /** - * Christmas variant of [[no_mouse_mode]]. + * Christmas variant of [[no_mouse_mode]] (if you live in $DEFAULT hemisphere). */ //#content export function snow_mouse_mode() { From 62c6d5229abd41b86643790eaea9389e2ba0e7bd Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Wed, 10 Mar 2021 13:16:42 +0530 Subject: [PATCH 10/12] Rename d -> overlaydiv --- src/content/toys.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 50f41e72..317fe13a 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -54,9 +54,9 @@ export function removeBlock() { export const snow = () => rain(makeBlock(), ["❄"], "#FFF", 0.15) -export function rain(d, characters: string[], colour, darkening = 0.05) { +export function rain(overlaydiv, characters: string[], colour, darkening = 0.05) { const c = document.createElement("canvas") - d.appendChild(c) + overlaydiv.appendChild(c) const ctx = c.getContext("2d") // making the canvas full screen @@ -99,5 +99,5 @@ export function rain(d, characters: string[], colour, darkening = 0.05) { drops[i]++ } } - d.intid = setInterval(draw, 33) + overlaydiv.intid = setInterval(draw, 33) } From 507be18665f0759a7bdaccb9cf96d810f5a4bb4a Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Wed, 10 Mar 2021 13:21:41 +0530 Subject: [PATCH 11/12] Fix documentation --- src/excmds.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/excmds.ts b/src/excmds.ts index af54bca4..66f4357e 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1563,9 +1563,9 @@ export async function credits() { /** * Cover the current page in an overlay to prevent clicking on links with the mouse to force yourself to use hint mode. Get rid of it by reloading the page. * - * Suggested usage: `autocmd DocLoad .* no_mouse_mode` + * To bring back mouse control, use [[mouse_mode]] or refresh the page. * - * To revert, use [[mouse_mode]] + * Suggested usage: `autocmd DocLoad .* no_mouse_mode` * * "There is no mouse". */ @@ -1605,7 +1605,7 @@ export function pied_piper_mouse_mode() { /** * Revert any variant of the [[no_mouse_mode]] * - * Suggested usage: `bind mouse_mode` + * Suggested usage: `bind mouse_mode` with the autocmd mentioned in [[no_mouse_mode]]. */ //#content export function mouse_mode() { From c1e0ebc4f03a57189090cca09825183bae4e2463 Mon Sep 17 00:00:00 2001 From: Dhruva Sambrani <44899822+DhruvaSambrani@users.noreply.github.com> Date: Wed, 10 Mar 2021 13:24:27 +0530 Subject: [PATCH 12/12] unexport rain, rename more d ->overlaydiv --- src/content/toys.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/content/toys.ts b/src/content/toys.ts index 317fe13a..b0c27fe2 100644 --- a/src/content/toys.ts +++ b/src/content/toys.ts @@ -27,20 +27,20 @@ export function no_mouse() { } function makeBlock() { - const d = document.createElement("div") - d.className = "_tridactyl_no_mouse_" - d.style.position = "fixed" - d.style.display = "block" - d.style.width = String(window.innerWidth) - d.style.height = String(window.innerHeight) - d.style.top = "0" - d.style.left = "0" - d.style.right = "0" - d.style.bottom = "0" - d.style.zIndex = "1000" - d.style.opacity = "0.5" - document.body.appendChild(d) - return d + const overlaydiv = document.createElement("div") + overlaydiv.className = "_tridactyl_no_mouse_" + overlaydiv.style.position = "fixed" + overlaydiv.style.display = "block" + overlaydiv.style.width = String(window.innerWidth) + overlaydiv.style.height = String(window.innerHeight) + overlaydiv.style.top = "0" + overlaydiv.style.left = "0" + overlaydiv.style.right = "0" + overlaydiv.style.bottom = "0" + overlaydiv.style.zIndex = "1000" + overlaydiv.style.opacity = "0.5" + document.body.appendChild(overlaydiv) + return overlaydiv } export function removeBlock() { @@ -54,7 +54,7 @@ export function removeBlock() { export const snow = () => rain(makeBlock(), ["❄"], "#FFF", 0.15) -export function rain(overlaydiv, characters: string[], colour, darkening = 0.05) { +function rain(overlaydiv, characters: string[], colour, darkening = 0.05) { const c = document.createElement("canvas") overlaydiv.appendChild(c) const ctx = c.getContext("2d")