User:Archimedes5000/vector.js

From Deceive Inc. Wiki
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.
/*Forces responsive content*/
function mobilefix(){
	var m = document.querySelector('meta[name="viewport"]');
	m.content = "width=device-width, initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0";
};
mobilefix();

/*Adds scrollable div wrappers to tables*/
function tablefix(){
	var table = document.querySelectorAll("table");
	for(var i = 0; i < table.length; i = i+1){
		var w = document.createElement("div");
		w.class = "table_wrapper";
		w.style = "overflow-x:scroll";
		table[i].parentNode.replaceChild(w, table[i]);
		w.appendChild(table[i]);
	};
};
if(window.innerWidth <= 700){
	tablefix();
};

/*Restores search on narrow screens by moving it above navigation*/
function searchfix(){
	var s = document.querySelector("#p-search");
	var p = document.querySelector("#right-navigation");
	var a = document.querySelector("#p-personal>div.vector-menu-content");
	if(window.innerWidth <= 700){
		a.prepend(s);
	}else if(window.innerWidth > 700){
		p.append(s);
	};
};
searchfix();
window.addEventListener("resize", searchfix);