Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This script is needed for (anonymously) logging search terms by our Squids!
- // The search URL will contain the search term,
- // please modify retroactively at [[wikt:de:MediaWiki:If-search.js]];
- // rather IMPORT this script; example: [[wikt:de:MediaWiki:If-search.js/import]].
- // --
- // Updated on de.wiktionary by Krinkle 2011-02-08
- function getID( ID ) {
- return document.getElementById(ID);
- }
- function firstInputInID( ID ) {
- return getID( ID ).getElementsByTagName( 'input' )[0];
- }
- function fixSearchForm( id, input ) {
- var fNode = getID( id );
- if ( fNode ) {
- fNode.setAttribute( 'onsubmit', "SubSearch('" + id + "', '" + input + "', '/')" );
- fNode.parentNode.innerHTML = getID( id ).parentNode.innerHTML; // f***ing IE
- }
- }
- function SubSearch( id, input, delimeter ) {
- var inputNode = getID(input);
- var formNode = getID(id);
- if ( inputNode.value === '' ) {
- delimeter = '';
- }
- formNode.action = wgArticlePath.replace( '$1', oSEAp + delimeter + inputNode.value );
- // Try to remove <input name="title"> from the <form>
- if ( firstInputInID(id).name === 'title' ) {
- if ( firstInputInID(id).parentNode == formNode ) {
- formNode.removeChild( firstInputInID(id) );
- } else {
- formNode.firstChild.removeChild( firstInputInID(id) );
- }
- }
- }
- function LogSearch() {
- fixSearchForm( 'searchform', 'searchInput' );
- fixSearchForm( 'search', 'searchText' );
- fixSearchForm( 'powersearch', 'powerSearchText' );
- fixSearchForm( 'bodySearch', 'bodySearchIput' );
- var searchform = getID( 'searchform' );
- if ( searchform && searchform.action.indexOf(wgScript) !== -1) {
- window.oSEAp = firstInputInID( 'searchform' ).value;
- } else {
- window.oSEAp = searchform.action.replace( /^.*\/([^\/]+)$/, '$1' );
- }
- }
- // Execute it when the page is ready
- jQuery( document ).ready( LogSearch );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement