Repository navigation
Add some whimsical fun with an easter egg #13152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
45886c7
a27c5b5
a686785
9597553
b2150a3
182a994
bbd8f3a
5230403
3517a62
f7bcded
57e9174
7ba8542
3121e0f
1f10f8f
8b28dcb
4d4d44d
ce721d4
0073796
56eb699
f3aab92
2257da9
2cb7511
0f06f20
e44de84
3e5334e
dc20329
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /** | ||
| * Listens to the command palette for the teletype. | ||
| * | ||
| * @output wp-admin/js/teletype-loader.js | ||
| */ | ||
|
|
||
| /** | ||
| * IIFE. | ||
| * | ||
| * @param {Object} wp The global WordPress JS object. | ||
| * @param {Object} settings The settings object. | ||
| */ | ||
| ( function ( wp, settings ) { | ||
| 'use strict'; | ||
|
|
||
| if ( ! wp || ! wp.data || ! settings ) { | ||
| return; | ||
| } | ||
|
|
||
| var KEY = 'ishdg;rsdkot', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To allow for translations this will need a translator comment linking to something like this https://jsbin.com/yiraraf/edit?html,js,console,output Given there is going to need to be a link to a spoiler anyway, I think it best to put the keyword and strings inline and allow for the fact that nerds will go searching for spoilers. For a nerd, it's a pretty low barrier for spoiling as is so I don't think it will lose a great deal. |
||
| FROM = '\',.pyfgcrl/=\\aoeuidhtns-;qjkxbmwvz"<>PYFGCRL?+|AOEUIDHTNS_:QJKXBMWVZ[]', | ||
| TO = 'qwertyuiop[]\\asdfghjkl;\'zxcvbnm,./QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?-='; | ||
|
|
||
| /** | ||
| * Maps a string through the character tables. | ||
| * | ||
| * @param {string} value Text to map. | ||
| * @return {string} Mapped text. | ||
| */ | ||
| function dvortr( value ) { | ||
| var map = {}, | ||
| i; | ||
|
|
||
| for ( i = 0; i < FROM.length; i++ ) { | ||
| map[ FROM.charAt( i ) ] = TO.charAt( i ); | ||
| } | ||
|
|
||
| return value.replace( /[\s\S]/g, function ( character ) { | ||
| return map[ character ] || character; | ||
| } ); | ||
| } | ||
|
|
||
| /** | ||
| * Loads the teletype if needed, then runs it. | ||
| */ | ||
| function play() { | ||
| var script; | ||
|
|
||
| if ( wp.teletype ) { | ||
| wp.teletype.run( settings.name, settings.i18n ); | ||
| return; | ||
| } | ||
|
|
||
| script = document.createElement( 'script' ); | ||
| script.src = settings.src; | ||
|
|
||
| script.onload = function () { | ||
| if ( wp.teletype ) { | ||
| wp.teletype.run( settings.name, settings.i18n ); | ||
| } | ||
| }; | ||
|
|
||
| document.head.appendChild( script ); | ||
| } | ||
|
|
||
| /** | ||
| * Handles Enter in an open command palette. | ||
| * | ||
| * @param {KeyboardEvent} event The keydown event. | ||
| */ | ||
| function onKeydown( event ) { | ||
| var store, | ||
| input = event.target, | ||
| value; | ||
|
|
||
| if ( 'Enter' !== event.key || ! input || ! input.value ) { | ||
| return; | ||
| } | ||
|
|
||
| store = wp.data.select( 'core/commands' ); | ||
|
|
||
| if ( ! store || ! store.isOpen() ) { | ||
| return; | ||
| } | ||
|
|
||
| // Leave Enter to the palette whenever one of its results is active. | ||
| if ( | ||
| 'combobox' !== input.getAttribute( 'role' ) || | ||
| input.getAttribute( 'aria-activedescendant' ) | ||
| ) { | ||
| return; | ||
| } | ||
|
|
||
| value = input.value.toLowerCase().replace( /[^a-z0-9]/g, '' ); | ||
|
|
||
| if ( ! value || dvortr( value ) !== KEY ) { | ||
| return; | ||
| } | ||
|
|
||
| event.preventDefault(); | ||
| event.stopPropagation(); | ||
|
|
||
| wp.data.dispatch( 'core/commands' ).close(); | ||
| play(); | ||
| } | ||
|
|
||
| document.addEventListener( 'keydown', onKeydown, true ); | ||
| }( window.wp, window.wpTeletype ) ); | ||
Uh oh!
There was an error while loading. Please reload this page.