User:Fractaler/taxonomy.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// Module: Taxonomy
// Description: Can be useful for selecting a sequence of categories
//("breadcrumb") in non-wiki or wiki format
//(Example1>Example2>..., [[:Category:Example1|Example1]]>[[:Category:Example2|Example2]]>...)
// Homepage: https://commons.wikimedia.org/wiki/User:Fractaler/taxonomy
// CSS: https://commons.wikimedia.org/wiki/User:Fractaler/taxonomy.css
// importStylesheet("User:Fractaler/taxonomy.css");
// Version 1.0 (date: 14.09.2018)
// Author: Fractaler (meta.wikimedia.org/wiki/User:Fractaler)
//==============================================================================

//(function() {
//===========================================================================
//Variables
//===========================================================================
var divDoc = document.createElement("DIV"); // main-DIV ("Taxonomy")
var divHead = document.createElement("DIV"); // head-DIV for main-DIV
var divBody = document.createElement("DIV"); // body-DIV
var Preferences = document.createElement("DIV"); // modal div for user references
var CMNSInputs = document.createElement("DIV"); // for "input" + "IS-input"
var CMNSLastCategory = document.createElement("DIV"); //"last category"
var CMNSBox4LastCategory = document.createElement("DIV"); //container for "last category"
var CMNSIs = document.createElement("DIV"); // sign between categories
var CMNSCategoryInput = document.createElement("INPUT"); //input for datalist
var CMNSAllCategories = document.createElement("DATALIST"); //datalist of input
var CMNSIsInput = document.createElement("INPUT"); // input for "is" (change "is" to other sign: ">", "<", "=>", etc.)
var CMNSCheckbox = document.createElement("INPUT"); // Commons' checkbox
var WDCheckbox = document.createElement("INPUT"); // Wikidata's checkbox
var WPCheckbox = document.createElement("INPUT"); // Wikipedia's checkbox
var CMNSDetails = document.createElement("DETAILS");// Parent of CMNSDetailsChild, used to show/hide "Commons"
var WDDetails = document.createElement("DETAILS");// Parent of WDDetailsChild, used to show/hide "Wikidata"
var WPDetails = document.createElement("DETAILS");// Parent of WPDetailsChild, used to show/hide "Wikipedia"
var CMNSDetailsChild = document.createElement("DETAILS"); // Child of CMNSDetails
var WDDetailsChild = document.createElement("DETAILS"); // Child of WDDetails
var WPDetailsChild = document.createElement("DETAILS"); // Child of WPDetails
var CMNSSummary = document.createElement("SUMMARY"); // used to show/hide Commons' "bread crumbs"
var WDSummary = document.createElement("SUMMARY"); // used to show/hide Wikidata's "bread crumbs"
var WPSummary = document.createElement("SUMMARY"); // used to show/hide Wikipedia's "bread crumbs"
var CMNSSummaryChild = document.createElement("SUMMARY"); // Commons' "bread crumbs" place
var WDSummaryChild = document.createElement("SUMMARY"); // Wikidata's "bread crumbs" place
var WPSummaryChild = document.createElement("SUMMARY"); // Wikipedia's "bread crumbs" place
var CMNSCopyingCategoryInput = document.createElement("BUTTON"); // copy CMNSCategoryInput to clipboard
var CMNSBreadCrumbs = document.createElement("UL"); // Commons' "bread crumbs" 
var CMNSSupercategoryList = document.createElement("UL"); //Commons' list of supercategories
var CMNSText4SummaryTitle = "Commons "; // string for CMNSSummaryTitle
var CMNSSummaryTitle = document.createElement("DIV");
CMNSSummaryTitle.innerHTML = CMNSText4SummaryTitle; // used to show "Commons" or "first category"
var CMNShost='https://commons.wikimedia.org'; // host, the first part of commons' URL
var wiki_Category="/wiki/Category:"; // second URL part, path after host
var CMNSQueryFirstPart=CMNShost + "/w/api.php?action=query&format=json&formatversion=2"; // the first part of the query (for supercategories and all categories)
var CMNSQueryAllCategoriesLimitNumber = 5; // number for second part of the commons query
var CMNSQueryAllCategoriesLimit = "&list=allcategories&aclimit=" + CMNSQueryAllCategoriesLimitNumber; // second part of query (limit list of all categories)
var CMNSQueryAllCategoriesFrom="&acprefix="; // component of query "all categories" (with which element to start a list of all categories)
var CMNSQueryAllCategories = CMNSQueryFirstPart +
CMNSQueryAllCategoriesLimit +
CMNSQueryAllCategoriesFrom; // query "all categories"
var CMNSQuerySupercategories=CMNSQueryFirstPart +
"&prop=categories&cllimit=499&clshow=!hidden&titles=Category:"; // query "supercategories"
var CMNSAfterRootCategorySign = " ? "; // sign of absence of supercategory

startTaxonomy(); // initialization

//Taxonomy: main function, initialization
function startTaxonomy() { 
    divDoc.id = "txnm_div";
    CMNSSummary.title = "Commons";
    CMNSSummary.id = "txnm_CMNSSummary";
    CMNSSummaryChild.id = "txnm_CMNSSummaryChild";
    divHead.id = "txnm_divheader";
    divHead.title = "double click for edit";
    divBody.id = "txnm_divbody";
    CMNSInputs.id = "txnm_CMNSInputs";
    CMNSIs.id = "txnm_ISdiv";
    CMNSIs.class="ISclass";
    CMNSLastCategory.id = "txnm_CMNSLastCategory";
    CMNSBox4LastCategory.id = "txnm_CMNSBox4LastCategory";
    CMNSBreadCrumbs.id = "txnm_CMNSBreadCrumbs";
    CMNSDetails.id = "txnm_CMNSDetails";
    CMNSDetailsChild.id = "txnm_CMNSDetailsChild";
    CMNSBreadCrumbs.style = "margin-left: 0px";
    CMNSBreadCrumbs.style.display = "none";
    divDoc.appendChild(divHead);
    divDoc.appendChild(Preferences);
    divDoc.appendChild(CMNSDetails);
    divDoc.appendChild(WDDetails);
    divDoc.appendChild(WPDetails);
    CMNSDetails.appendChild(CMNSSummary);
    WDDetails.appendChild(WDSummary);
    WPDetails.appendChild(WPSummary);
    CMNSDetails.appendChild(CMNSDetailsChild);
    WDDetails.appendChild(WDDetailsChild);
    WPDetails.appendChild(WPDetailsChild);
    CMNSDetailsChild.appendChild(CMNSSummaryChild);
    WDDetailsChild.appendChild(WDSummaryChild);
    WPDetailsChild.appendChild(WPSummaryChild);
    CMNSSummaryChild.appendChild(CMNSBox4LastCategory);
    CMNSSummaryChild.appendChild(CMNSBreadCrumbs);
    CMNSSummaryChild.style.display = "none";
    CMNSBox4LastCategory.appendChild(CMNSLastCategory);
    CMNSLastCategory.innerHTML += CMNSIs.innerHTML;
    CMNSDetails.appendChild(divBody);
    CMNSCategoryInput.setAttribute("list", "allcat");
    CMNSCategoryInput.setAttribute("oninput", "CMNSoninputDatalist(this.value)");
    CMNSCategoryInput.setAttribute("onchange", "CMNSonchangeInput(this.value)");
    CMNSAllCategories.id="allcat";
    CMNSDetails.insertBefore(CMNSInputs, CMNSDetailsChild);
    CMNSInputs.appendChild(CMNSCategoryInput);
    CMNSInputs.appendChild(CMNSIsInput);
    CMNSCategoryInput.appendChild(CMNSAllCategories);
    CMNSgetAllCategories(CMNSQueryAllCategories);
    CMNSCategoryInput.placeholder = "Enter category name";
    CMNSCategoryInput.title = "Display categories starting at:";
    CMNSIs.innerHTML = " is ";
    CMNSIs.style.display = "none";
    CMNSIsInput.style.display = "none";
    CMNSBox4LastCategory.style.display = "inline";
    CMNSLastCategory.style.display = "inline";
    CMNSInputs.style.display = "inline";
    CMNSIsInput.value = " is ";
    CMNSIsInput.placeholder = "is";
    CMNSIsInput.size = "1";
    CMNSIsInput.title = "A is B, B is C. A is C";

    // Preferences: beginning
    Preferences.id = "txnm_preferences";
    Preferences.class = "txnm_pref_overlay";
    Preferences.style.width = "20%"; // size of "Preferences"
    Preferences.style.display = "none"; // hide "Preferences" hide at startup
    
    // Positioning of "Preferences" relative to the browser window
    Preferences.style.position = "fixed"; // fixed (when scrolling does not move)
    Preferences.style.top = "0"; // top
    Preferences.style.left = "0"; // left
    
    Preferences.style.background = "silver"; // "Preferences" color
    //Preferences.innerHTML = '<a href="javascript:void(0)" class="closeprefrences" onclick="closePreferences()";>&times;</a>';
    Preferences.innerHTML = '<a href="javascript:void(0)" title="Close preferences" class="closeprefrences" onclick="closePreferences()";>&nbsp;X</a>';
    
    //add "Preferences" child
    var PreferencesChild = document.createElement("DIV");// elements in the modal DIV
    Preferences.appendChild(PreferencesChild);
    PreferencesChild.class = "txnm_pref_overlay_content";
    
    // Positioning of "Preferences"'s child 
    PreferencesChild.style.position = "relative"; // relative to its first positioned (not static) ancestor element
    PreferencesChild.style.top = "25%";
    PreferencesChild.style.width = "100%";
    PreferencesChild.innerHTML = "Hide:<BR>";

    // Preferences: Commons' checkbox
    PreferencesChild.appendChild(CMNSCheckbox);
    CMNSCheckbox.setAttribute("type", "checkbox");
    CMNSCheckbox.setAttribute("onclick", "onclickCMNSCheckbox()");
    CMNSCheckbox.setAttribute("checked", "checked");
    var CMNSCheckboxText = document.createTextNode("Commons");
    PreferencesChild.appendChild(CMNSCheckboxText);
    PreferencesChild.innerHTML += "<BR>";

    // Preferences: Wikidata's checkbox
    PreferencesChild.appendChild(WDCheckbox);
    WDCheckbox.checked = true;
    WDCheckbox.setAttribute("type", "checkbox");
    WDCheckbox.setAttribute("onclick", "onclickWDCheckbox()");
    WDCheckbox.setAttribute("checked", "checked");
    var WDCheckboxText = document.createTextNode("Wikidata");
    PreferencesChild.appendChild(WDCheckboxText);
    PreferencesChild.innerHTML += "<BR>";

    // Preferences: Wikipedia's checkbox
    PreferencesChild.appendChild(WPCheckbox);
    WPCheckbox.checked = true;
    WPCheckbox.setAttribute("type", "checkbox");
    WPCheckbox.setAttribute("onclick", "onclickWPCheckbox()");
    WPCheckbox.setAttribute("checked", "checked");
    var WPCheckboxText = document.createTextNode("Wikipedia");
    PreferencesChild.appendChild(WPCheckboxText);
    
    // "Hide taxonomy" row
    PreferencesChild.innerHTML += "<BR>";
    PreferencesChild.innerHTML += '<a href="javascript:void(0)" class="closetaxonomy" title="Close Taxonomy" onclick="closeTaxonomy()";>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Taxonomy</a>';
	// Preferences: end

    CMNSDetails.ontoggle = CMNSontoggleDetails; // tracing "Details" toggle events
    CMNSCopyingCategoryInput.style.display = "none"; //hide "copy button"
    CMNSDetailsChild.ontoggle = CMNSontoggleDetailsChild; // tracing "child of Details' toggle events
    
    document.body.appendChild(divDoc); // add "Taxonomy" to parent page
    divDoc.style.top = 1 + 'px'; // set "Taxonomy" at the top of the parent page
    divDoc.style.color = "green"; // Taxonomy-body color
    divHead.style.background = "LightSkyBlue"; // Taxonomy-head color

	// Summary
    CMNSSummary.appendChild(CMNSSummaryTitle);
    CMNSSummaryTitle.style.display = "inline";
    WDSummary.innerHTML = "Wikidata";
    WDSummaryChild.innerHTML = "under construction";
    WPSummary.innerHTML = "Wikipedia";
    WPSummaryChild.innerHTML = "under construction";
    CMNSSummary.appendChild(CMNSCopyingCategoryInput);
    CMNSCopyingCategoryInput.innerText="Copy";
    CMNSCopyingCategoryInput.style.display = "none";
    
    CMNSCopyingCategoryInput.onclick = CMNSCopyCategoryInput2clipboard;
    
    // Details
    CMNSDetails.style.display = "none";
    WDDetails.style.display = "none";
    WPDetails.style.display = "none";
    
    setHeadLink(); // set start-link
    
    dragTaxonomy(document.getElementById("txnm_div")); // make "Taxonomy" draggagle
}
//Taxonomy: end of initialization

//Drag functions: beginning
function dragTaxonomy(DIVTaxonomy) {
	var position1 = 0, position2 = 0, position3 = 0, position4 = 0;
	
	if (document.getElementById(DIVTaxonomy.id + "header")) {// if present, the header is where you move the DIV from
		document.getElementById(DIVTaxonomy.id + "header").onmousedown = dragMouseDown;
		} else {// otherwise, move the DIV from anywhere inside the DIV
			DIVTaxonomy.onmousedown = dragMouseDown;
		}

    function dragMouseDown(e) {
    	e = e || window.event;
    	
    	// get the mouse cursor position at startup
    	position3 = e.clientX;
    	position4 = e.clientY;
    	document.onmouseup = closeDragTaxonomy;
    	
    	// call a function whenever the cursor moves
    	document.onmousemove = onmousemoveDragTaxonomy;
    }
    
    function onmousemoveDragTaxonomy(e) {
    	e = e || window.event;
    	
    	// calculate the new cursor position
    	position1 = position3 - e.clientX;
    	position2 = position4 - e.clientY;
    	position3 = e.clientX;
    	position4 = e.clientY;
    	
    	// set the Taxonomy's new position
    	DIVTaxonomy.style.top = (DIVTaxonomy.offsetTop - position2) + "px";
    	DIVTaxonomy.style.left = (DIVTaxonomy.offsetLeft - position1) + "px";
    }

    // stop moving when mouse button is released    
    function closeDragTaxonomy() {
    document.onmouseup = null;
    document.onmousemove = null;
  }
}
//Drag functions: end

// touch: beginning
//under construction
//ontouchstart ~ onmousedown
//ontouchend ~ onmouseup
// touch: end

//Preference functions: beginning
function onclickCMNSCheckbox() {
	if (CMNSCheckbox.checked === true){
		CMNSDetails.style.display = "none";
		CMNSCheckbox.checked = false;
		} else {
			CMNSDetails.style.display = "block";
			CMNSCheckbox.checked = true;
		}
}

function onclickWDCheckbox() {
	if (WDCheckbox.checked === true){
		WDDetails.style.display = "none";
		WDCheckbox.checked = false;
		} else {
			WDDetails.style.display = "block";
			WDCheckbox.checked = true;
		}
}

function onclickWPCheckbox() {
	if (WPCheckbox.checked === true){
		WPDetails.style.display = "none";
		WPCheckbox.checked = false;
		} else {
			WPDetails.style.display = "block";
			WPCheckbox.checked = true;
		}
}

function closeTaxonomy() {
	setHeadLink();
	CMNSDetails.style.display = "none";
	WDDetails.style.display = "none";
	WPDetails.style.display = "none";
	Preferences.style.display = "none";
}

function setPreferencesLink() {
	//divHead.innerHTML = '<a href="javascript:void(0)" onclick="openPreferences();return false;"> &#9776;</a>';
	divHead.innerHTML = '<a href="javascript:void(0)" title="Preferences" onclick="openPreferences();return false;"> E</a>';
}

function setHeadLink(inrHTML) {
	divHead.innerHTML = '<a href="javascript:void(0)" title="Open Taxonomy" onclick="onclickHeadLink();return false;">Taxonomy</a>';
}

function openPreferences() {
	Preferences.style.display = "block";
}

function closePreferences() {
	Preferences.style.display = "none";
}
//Preference functions: end

//Taxonomy-head functions: beginning
function onclickHeadLink() {
CMNSDetails.style.display = "inline";
WDDetails.style.display = "block";
WPDetails.style.display = "block";
divDoc.style.position = "absolute"; //sticky, fixed, absolute, relative
setPreferencesLink();
}
//Taxonomy-head functions: end

//Commons functions: beginning
function CMNSCopyCategoryInput2clipboard() {
  CMNSCategoryInput.select();
  document.execCommand("copy");
}

// (when category is selected from "datalist")
function CMNSonchangeInput(selectedCategory) {
CMNSIsInput.style.display = "inline"; //show "IS input"
CMNSupdateSupercategoryList(selectedCategory); //update "supercategory list"
CMNSmakeBreadCrumbFirstNode(selectedCategory); // make the first element of "bread crumb"
CMNSupdateLastCategory(selectedCategory); //update "last category"
CMNSrestoreSummaryTitle(); // restore "super DETAILS" init-text
divHead.ondblclick = CMNSondblclickHead; //show/hide "inputs"
}

// show/hide "inputs"
function CMNSondblclickHead() {
	CMNSCopyingCategoryInput.style.display = "none"; // hide "copy button"
	
	if(CMNSInputs.style.display == "inline") { // if "DIV-inputs" is shown
	CMNSInputs.style.display = "none"; //hide all inputs
	CMNSDetailsChild.style.display = "inline"; // show "details Commons"'s child
	CMNSSummaryChild.style.display = "inline"; // show "bread crumbs" container
	
		if(CMNSIsInput.style.display == "inline") { // if "IS-input" is shown
		CMNSIsInput.style.display = "none";
		
		CMNSIs.innerText = CMNSIsInput.value; // update "is"-sign
		CMNSupdateLastCategory(CMNSCategoryInput.value); // update "last category"
		CMNSsetFirstCategory(); // set "first category"
	
		//update all "is" in "bread crumbs"
		for(var i = 1; i < CMNSBreadCrumbs.childNodes.length; i = i + 2)
		CMNSBreadCrumbs.childNodes[i].textContent = CMNSIs.innerText;
		
		}
	} else { // if "DIV-inputs" is hidden
		CMNSInputs.style.display = "inline"; //show inputs
		CMNSCategoryInput.readOnly = false; //make "category input" editable
		CMNSDetailsChild.style.display = "none";
		CMNSSummaryChild.style.display = "none"; // hide "bread crumbs" container
		
		if(CMNSDetailsChild.open === true) { //if no "last category" (if "bread crumbs")
		CMNSCopyingCategoryInput.style.display = "inline";
		CMNSIsInput.style.display = "none";
		CMNSCategoryInput.value = "";
		
		for(var j = 0; j < CMNSBreadCrumbs.children.length; j++)
		CMNSCategoryInput.value += CMNStext2wikiCategoryLink(CMNSBreadCrumbs.children[j].innerText) + CMNSIsInput.value;
		
		CMNSCategoryInput.readOnly = true;
		} else { //if "last category" (if no "bread crumbs")
			CMNSIsInput.style.display = "inline";
			CMNSIs.style.display = "none";
			CMNSCategoryInput.value = CMNSLastCategory.children[0].innerText;
		}
	}
}

function CMNSmakeBreadCrumbFirstNode(FirstNode) {
CMNSBreadCrumbs.innerHTML = ""; // empty "bread crumbs"

CMNSaddCrumb2breadcrumbs(FirstNode); // add the first category (crumb) to empty "bread crumbs"
}

function CMNSgetAllCategories(AllCategoriesAPI) {
	var xmlhttp = new XMLHttpRequest();
	
	xmlhttp.onreadystatechange = function() {
		if (this.readyState == 4 && this.status == 200) {
			var JSONObj = JSON.parse(this.responseText);
			CMNSAllCategories.innerHTML = ""; //empty all "option value" in datalist
			
            for (var i = 0; i < JSONObj.query.allcategories.length; ++i) {
            	CMNSAllCategories.innerHTML += "<option>" + JSONObj.query.allcategories[i].category + "</option>";
            }
		}
	};
	xmlhttp.open("GET", AllCategoriesAPI, true);
	xmlhttp.send();
}

// get a list of supercategories and put to CMNSSupercategoryList
function CMNSgetSupercategories(APIcategory) {
	var xmlhttp = new XMLHttpRequest();
	
	xmlhttp.onreadystatechange = function() {
		if (this.readyState == 4 && this.status == 200) {
			var JSONsupercategories = JSON.parse(this.responseText);
			divBody.appendChild(CMNSSupercategoryList);
			
			if(JSONsupercategories.query.pages[0].categories === undefined) {
				CMNSSupercategoryList.innerHTML = CMNSAfterRootCategorySign;
				} else {
					for (var i = 0; i< JSONsupercategories.query.pages[0].categories.length; ++i) {
						JSONsupercategories.query.pages[0].categories[i].title = JSONsupercategories.query.pages[0].categories[i].title.slice(JSONsupercategories.query.pages[0].categories[i].title.indexOf(":") + 1);
						CMNSSupercategoryList.innerHTML += '<li><a href="' + CMNShost +wiki_Category +
						JSONsupercategories.query.pages[0].categories[i].title +
						'" onclick="CMNSonclickSupercategoryList(this);return false;" class="category_list">' +
						JSONsupercategories.query.pages[0].categories[i].title+"</a></li>";
					}
				}
		}
	};
    xmlhttp.open("GET", APIcategory, true);
    xmlhttp.send();
}

function CMNSoninputDatalist(FromCategory) {
	CMNSgetAllCategories(CMNSQueryAllCategories + FromCategory);
}

function CMNSsetFirstCategory() {
	if(CMNSBreadCrumbs.childNodes.length > 2) { //if "bread crumbs" has more then 1 category
	// safe info about start: put "first category" of "bread crumbs" to parent's DETAILS
	
	// set the first category
	CMNSSummaryTitle.innerHTML = '<a href="javascript:void(0)">' +
	CMNSBreadCrumbs.childNodes[0].textContent + '</a>' +
	CMNSIs.innerText; // +"IS"-sign
	}
}

function CMNSonclickSupercategoryList(ClickedLink) {
	CMNSupdateSupercategoryList(ClickedLink.text); // update and show supercategories
	CMNSupdateLastCategory(ClickedLink.text); // set "last category"
    CMNSaddCrumb2breadcrumbs(ClickedLink.text); //add the category to "bread crumbs"-path

    if(CMNSInputs.style.display == "inline") { // if "inputs" is shown
    CMNSInputs.style.display = "none"; // hide "IS-input"
    CMNSDetailsChild.style.display = "inline";
    CMNSSummaryChild.style.display = "inline";
    CMNSCopyingCategoryInput.style.display = "none"; // hide "copy-button"
    }

    if(CMNSDetailsChild.open !== true) {
    	CMNSsetFirstCategory();
    }
}

function CMNSupdateSupercategoryList(LastPartOfLink) {
	CMNSSupercategoryList.innerHTML=""; //empty "supercategory list"
	CMNSgetSupercategories(CMNSQuerySupercategories + LastPartOfLink); //get "supercategory list" on request
}

function CMNSupdateLastCategory(CategoryText){
    CMNSLastCategory.innerHTML = CMNStext2LastCategoryLink(CategoryText);
    CMNSLastCategory.innerHTML += CMNSIs.innerHTML; //+ "is"
}

function CMNSrestoreSummaryTitle() {
	CMNSSummaryTitle.textContent = CMNSText4SummaryTitle;
}

function CMNSonBreadCrumbsClick(ClickedCategory) {
	CMNSupdateLastCategory(ClickedCategory.textContent); //update "last category"
	CMNSupdateSupercategoryList(ClickedCategory.textContent); //update "supercategory list"
	
	for(var i = CMNSBreadCrumbs.children.length - 1; i > 0; i--) {
		if(ClickedCategory.textContent === CMNSBreadCrumbs.children[i].textContent)
		{ break; }
		else {
			// remove last "Category + IS"
			CMNSBreadCrumbs.removeChild(CMNSBreadCrumbs.lastChild);
			CMNSBreadCrumbs.removeChild(CMNSBreadCrumbs.lastChild);
		}
	}
	CMNSIs.style.display = "inline"; //show "IS"-sign
}

function CMNSaddCrumb2breadcrumbs(Linktext){
    CMNSBreadCrumbs.innerHTML += CMNStext2BreadCrumbsLink(Linktext); //add the category to "bread crumbs"
    CMNSBreadCrumbs.innerHTML += CMNSIs.innerHTML; //add "IS"-sign

}

function CMNSontoggleDetails() {
	if(CMNSDetails.open === false) { //if "details Commons" is hidden
	CMNSCopyingCategoryInput.style.display = "none"; //hide "copy button"
	CMNSrestoreSummaryTitle();
	} else {
		if (CMNSInputs.style.display == "inline") { //if "inputs" is shown
		CMNSCopyingCategoryInput.style.display = "inline"; //show "copy button"
		} else // if "inputs" is hidden 
			if(CMNSDetailsChild.open === false) { // if "last category" (if no "bread crumbs")
			CMNSsetFirstCategory();
		}
	}
}

// show/hide "last category", "bread crumbs"; "first category" migration
function CMNSontoggleDetailsChild() {
	if (CMNSBox4LastCategory.style.display == "none") { // if no "last category" (if "bread crumbs")
	CMNSBox4LastCategory.style.display = "inline"; // show "last category"
	CMNSBreadCrumbs.style.display="none"; //hide "bread crumbs"
	CMNSsetFirstCategory(); // "first category" migration
	} else { // if "last category" (if no "bread crumbs")
	CMNSBox4LastCategory.style.display = "none"; //hide "last category"
	CMNSBreadCrumbs.style.display="inline"; //show "bread crumbs"
	CMNSrestoreSummaryTitle();
	}
}

function CMNStext2BreadCrumbsLink(strText) {
	return '<li style="display: inline"><a href="' + CMNShost + wiki_Category + strText +
    '" onclick="CMNSonBreadCrumbsClick(this);return false;">' + strText + '</a></li>';
}

function CMNStext2LastCategoryLink(strText) {
	return '<a href="' + CMNShost + wiki_Category + strText +
    '" onclick="return false;">' + strText + '</a>';
}

function CMNStext2wikiCategoryLink(strText) {
	return "[[:Category:" + strText + "|" + strText + "]]";
}
//Commons functions: end

//===========================================================================
//Wikidata functions: beginning
// (under construction)
// Wikidata functions: end
//===========================================================================

//===========================================================================
//Wikipeia functions: beginning
// (under construction)
// Wikipeia functions: end
//===========================================================================
//})();