User:Zuphilip/filter.js

From Wikidata
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.
/*
$(document).ready(function() {
if (mw.config.get("wbEntityType") === "item") {//only for item pages
	$('div.toc').after('<input class="myInput"/><div id="myResult" style="border-style:solid; border-width:thin"/>');
	$('.myInput').keyup(function () {
		if ($(this).val().length > 0) {
		  if ($(this).val().substr(0,1)=="P") {
			if ($('.wb-claimlistview.listview-item:has(.wb-snak-property a[href*="'+$(this).val()+'"])').length == 1) {
				$('#myResult').html( $('.wb-claimlistview.listview-item:has(.wb-snak-property a[href*="'+$(this).val()+'"])').html() );
				//$('.wb-snak-property a[href*="'+$(this).val()+'"]').parent().parent().next().html());
			} else {
				$('#myResult').html('');
			}
		  } else {
			if ($('.wb-sitelinks-link-'+$(this).val()+'wiki a').length == 1) {
				$('#myResult').html($('.wb-sitelinks-link-'+$(this).val()+'wiki').html());
			} else {
				$('#myResult').html('');
			}
		  }
		}
	});
}
});
*/