User:SimonWikt/common.js

Hello, you have come here looking for the meaning of the word User:SimonWikt/common.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:SimonWikt/common.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:SimonWikt/common.js in singular and plural. Everything you need to know about the word User:SimonWikt/common.js you have here. The definition of the word User:SimonWikt/common.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:SimonWikt/common.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
(function () {
  const sw = JSON.parse( localStorage.getItem("SimonWikt") );
  if( !sw || !sw.collapseDisabled ) {	
	const openLangs = ;
	const openDets =
		[ "Conjugation",
		  "Declension",
		  "Etymology 1", "Etymology 2", "Etymology 3", "Etymology 4",
		  "Adjective", "Adverb",
		  "Conjunction",
		  "Determiner",
		  "Interjection",
		  "Letter",
		  "Numeral", "Noun",
		  "Particle", "Participle", "Prefix", "Preposition", "Pronoun", "Proper noun",
		  "Suffix",
		  "Translations",
		  "Verb"
		];
	
	if( document.querySelector("section") ) {
		/* Mobile Wiktionary has 'section's */
		/* and collapsible languages */
		/* Headings are now in DIVs */
		document.querySelectorAll("#mw-content-text > div .mw-heading3").forEach(
			(h3)=>{ createDetailsLevel(h3) }
		);
		document.querySelectorAll("#mw-content-text > div .mw-heading2").forEach(
			(h2)=>{
				/* collapse unwanted languages */
				const headingName = h2.querySelector( "H2" ).innerText;
				if( ! openLanguage( headingName ) ) h2.click();
			}
		);
	} else
		/* Collapse 'H2's and above, except wanted languages and headings */
		document.querySelectorAll("#mw-content-text > div .mw-heading2").forEach(
			(h2)=>{ createDetailsLevel(h2) }
		);

	function openLanguage( lang ) {
		return openLangs.indexOf( lang ) >= 0;
	}
	function openDet( det ){
		return openLanguage( det ) || openDets.indexOf( det ) >= 0;
	}

	function createDetailsLevel( heading ) {
		function getHeadingInfo( heading ) {
			const headings = ;
			/* Mobile and Desktop headings are in a DIV */
			let id = ""; let name = "";
			let i = headings.indexOf( heading.nodeName );
			if( heading.nodeName == "DIV" && heading.classList.contains("mw-heading") ) {
				heading = heading.children;
				i = headings.indexOf( heading.nodeName );
				id = heading.id;
				name = heading.innerText;
			}
			else if ( i > 0 ) {
				let span = heading.querySelector( "span" );
				id = span.id;
				name = span.innerText;
			}
			return { level: i, id: id, name: name };
		}
		const headingInfo = getHeadingInfo( heading );
		const level = headingInfo.level;
		let sib = heading.nextSibling;
		const dets = document.createElement( "details" );
		heading.after( dets );
		const summary = document.createElement( "summary" );
		dets.appendChild( summary );
		summary.appendChild( heading );
		dets.open = openDet( headingInfo.name );
		dets.title = headingInfo.id + " details";
		while( sib ) {
			let nsib = sib.nextSibling;
			let sibLevel = getHeadingInfo( sib ).level;
			if( sibLevel > 0 ) {
				if( sibLevel > level ) {
					let subDets = createDetailsLevel( sib );
					nsib = subDets.nextSibling;
					dets.appendChild( subDets );
				}
				else break;
			}
			else dets.appendChild( sib );
			sib = nsib;
		}
		return dets;
	}
  }
})();

SimonWikt = {
	
	sw: function() { return JSON.parse( localStorage.getItem("SimonWikt") ) },
	
	collapsible: function() { return !this.sw() || !this.sw().collapseDisabled },

	disableCollapse: function () {
		localStorage.setItem( "SimonWikt",JSON.stringify( {collapseDisabled:true} ) );
	},
	
	enableCollapse: function() {
		localStorage.setItem( "SimonWikt",JSON.stringify( {collapseDisabled:false} ) );
	}
}

if( document.querySelector("#mw-content-text > div .mw-heading2") )
	document.querySelector("#mw-content-text").insertAdjacentHTML(
		"afterbegin",
		'<a id="p-visibility-collapse" href="#visibility-collapse" ' +
			'onclick="javascript:SimonWikt.' +
			( SimonWikt.collapsible() ? 'disableCollapse()' : 'enableCollapse()' ) +
			';location.reload();return false;">' +
			( SimonWikt.collapsible() ? 'Expand sections' : 'Collapse sections' ) +
		'</a>'
	);