Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4126301
showOnPageReload.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
showOnPageReload.js
View Options
const
storageKey
=
'mobileFrontend/toast'
;
/**
* Show the previously saved toast data and delete it from storage
*
* @memberof Toast
* @instance
* @private
*/
function
showPending
()
{
let
data
=
mw
.
storage
.
get
(
storageKey
);
if
(
data
)
{
data
=
JSON
.
parse
(
data
);
mw
.
notify
(
data
.
content
,
data
.
options
);
mw
.
storage
.
remove
(
storageKey
);
}
}
mw
.
requestIdleCallback
(
showPending
);
/**
* Save the toast data in storage so that we can show it on page reload.
* Also check whether there is a pending message that's not shown yet.
* If yes, output a warning message and discard this message.
* This is to ensure that the page needs to be reloaded before adding
* a new message for showing later.
*
* @memberof Toast
* @instance
* @param {string} content Content to be placed in element
* @param {Object|string} [options]
* If a string (deprecated) CSS class to add to the element
* If an object, more options for the notification see mw.notification.show.
* For backwards compatibility reasons if a string is given it will be
* treated as options.type
*/
function
showOnPageReload
(
content
,
options
)
{
if
(
mw
.
storage
.
get
(
storageKey
)
)
{
mw
.
log
.
warn
(
'A pending toast message already exits. '
+
'The page should have been reloaded by now.'
);
return
;
}
mw
.
storage
.
set
(
storageKey
,
JSON
.
stringify
(
{
content
,
options
}
)
);
}
module
.
exports
=
{
showOnPageReload
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 08:01 (2 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
82/0c/f1af71455b30ed4835b57cc7404f
Default Alt Text
showOnPageReload.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment