MediaWiki:Common.js

From Semantic Lab
Revision as of 20:50, 3 May 2024 by MattTest (talk | contribs)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
if (document.querySelector("#P200")){
  var p200Container = document.querySelector("#P200");
	var p200Container = document.querySelector("#P200");
	var aLinks = p200Container.querySelectorAll("a");
	var urls = [];
	for (var el in aLinks){
		if (aLinks[el].getAttribute('href') && (aLinks[el].getAttribute('href').toLowerCase().endsWith('.png') || aLinks[el].getAttribute('href').toLowerCase().endsWith('.jpg') || aLinks[el].getAttribute('href').toLowerCase().endsWith('.jpeg') ) ){
			urls.push(aLinks[el].getAttribute('href'));
		}
	}

	var imageContainer = document.createElement('div');
	imageContainer.classList.add('wikibase-statementgroupview');
	imageContainer.innerHTML = "";

	for (var url in urls){
		var img = document.createElement('img');
		img.style.width = "95%";
		img.style.height = "auto";
		img.style.marginTop="0.2em";
		img.style.marginBottom="0.2em";
		img.setAttribute('src',urls[url]);
		var a = document.createElement('a');
		a.setAttribute('href',urls[url]);
		a.setAttribute('target','_blank');
		a.appendChild(img);
		imageContainer.appendChild(a);

	}
	//imageContainer.style.border = "1px solid #c8ccd1"
	imageContainer.style.borderBottom = "none";
	imageContainer.style.marginBottom = 0;
	imageContainer.style.textAlign = 'center';
	imageContainer.style.width = '100%';
	imageContainer.style.backgroundColor = '#eaecf0';
	document.querySelector(".wikibase-listview").insertBefore(imageContainer, p200Container);
}