Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7409791
eventSequencer.html
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
eventSequencer.html
View Options
<!DOCTYPE html>
<
html
>
<!--
/*!
* VisualEditor event sequencer page
*
* @copyright See AUTHORS.txt
*/
-->
<
head
>
<
meta
charset
=
"utf-8"
>
<
style
>
#
good
,
#
bad
{
min-height
:
2
em
;
border
:
1
px
solid
red
;
}
</
style
>
<
script
src
=
"../../lib/jquery/jquery.js"
></
script
>
<
script
src
=
"../../lib/oojs/oojs.js"
></
script
>
<
script
src
=
"../../lib/oojs-ui/oojs-ui-core.js"
></
script
>
<
script
src
=
"../../lib/unicodejs/unicodejs.js"
></
script
>
<
script
src
=
"../../src/ve.js"
></
script
>
<
script
src
=
"../../src/ve.utils.js"
></
script
>
<
script
src
=
"../../src/ve.EventSequencer.js"
></
script
>
<
script
src
=
"../../src/ce/ve.ce.js"
></
script
>
</
head
>
<
body
>
Good (ve.EventSequencer):
<
div
id
=
"good"
contenteditable
=
"true"
></
div
>
Bad (setTimeout):
<
div
id
=
"bad"
contenteditable
=
"true"
></
div
>
<
script
>
/* eslint-disable no-console */
(
function
()
{
const
onEvents
=
{},
afterEvents
=
{},
eventNames
=
[
'compositionstart'
,
'compositionend'
,
'keydown'
,
'keyup'
,
'keypress'
],
/* eslint-disable no-jquery/no-global-selector */
$
bad
=
$
(
'#bad'
),
$
good
=
$
(
'#good'
);
/* eslint-enable no-jquery/no-global-selector */
function
showEventCode
(
e
)
{
return
(
e
&&
e
.
keyCode
)
?
'(keyCode='
+
e
.
keyCode
+
')'
:
''
;
}
function
makeListener
(
message
)
{
return
function
(
e
)
{
console
.
log
(
message
+
showEventCode
(
e
)
+
' '
+
JSON
.
stringify
(
$
good
[
0
].
innerHTML
)
);
};
}
function
addSetTimeoutListeners
(
node
,
eventName
)
{
node
.
addEventListener
(
eventName
,
(
e
)
=>
{
console
.
log
(
eventName
+
showEventCode
(
e
)
+
': '
+
JSON
.
stringify
(
node
.
innerHTML
)
);
setTimeout
(
()
=>
{
console
.
log
(
'setTimeout from '
+
eventName
+
showEventCode
(
e
)
+
': '
+
JSON
.
stringify
(
node
.
innerHTML
)
);
}
);
}
);
}
eventNames
.
forEach
(
(
eventName
)
=>
{
onEvents
[
eventName
]
=
makeListener
(
'on '
+
eventName
);
afterEvents
[
eventName
]
=
makeListener
(
'after '
+
eventName
);
addSetTimeoutListeners
(
$
bad
[
0
],
eventName
);
}
);
new
ve
.
EventSequencer
(
eventNames
)
.
on
(
onEvents
)
.
after
(
afterEvents
)
.
attach
(
$
good
);
$
good
.
trigger
(
'focus'
);
}()
);
</
script
>
</
body
>
</
html
>
File Metadata
Details
Attached
Mime Type
text/html
Expires
Sat, Nov 21, 22:38 (1 d, 21 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a3/76/a5ff9d22fff4fcf76c967a46c537
Default Alt Text
eventSequencer.html (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment