Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7448343
ext.inputBox.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
ext.inputBox.js
View Options
(
function
()
{
mw
.
hook
(
'wikipage.content'
).
add
(
()
=>
{
const
inputBoxForms
=
document
.
querySelectorAll
(
'.inputbox-searchengine-not-set'
);
// Replace form action with the user's preference.
const
userPref
=
mw
.
user
.
options
.
get
(
'search-special-page'
);
const
searchPages
=
mw
.
config
.
get
(
'SpecialSearchPages'
);
if
(
searchPages
[
userPref
]
!==
undefined
)
{
const
searchUrl
=
mw
.
util
.
getUrl
(
searchPages
[
userPref
]
);
for
(
const
inputboxForm
of
inputBoxForms
)
{
inputboxForm
.
action
=
searchUrl
;
}
}
// Change the 'search' parameter on submit, if searchfilter is present.
// This avoids an HTTP redirect that happens as a no-JS fallback.
for
(
const
inputboxForm
of
inputBoxForms
)
{
const
searchFilter
=
inputboxForm
.
querySelector
(
'input[name="searchfilter"]'
);
if
(
searchFilter
)
{
inputboxForm
.
addEventListener
(
'submit'
,
()
=>
{
const
search
=
inputboxForm
.
querySelector
(
'input[name="search"]'
);
if
(
search
)
{
// This matches what's done in InputBoxHooks::onSpecialPageBeforeExecute().
search
.
value
=
search
.
value
.
trim
()
+
' '
+
searchFilter
.
value
.
trim
();
// Remove the searchfilter input, so it doesn't trigger the redirect.
searchFilter
.
remove
();
}
}
);
}
}
}
);
}()
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 22, 19:36 (1 d, 11 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e4/de/1ae95ede792ba709eeff4c3d5e29
Default Alt Text
ext.inputBox.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment