RE: Help me with my new website!
December 25, 2018 at 11:32 am
(This post was last modified: December 25, 2018 at 12:32 pm by FlatAssembler.)
Quote:I have to check support for the FEATURE, rather than the browser.Well, in the compiler web-app, I abstained from browser-sniffing as much as possible. Sometimes detecting a lack of particular feature and mitigating it is easy to do, like here:
Code:
if ((typeof document != "undefined") && !document.getElementsByClassName)
document.getElementsByClassName=function(str)
{
var niz=document.getElementsByTagName("*");
var ret=[];
for (var i=0; i<niz.length; i++)
if (eval("/(\\s|^)"+str+"(\\s|$)/").test(niz[i].className))
ret.push(niz[i]);
return ret;
}
Code:
if (!Array.prototype.includes)
Array.prototype.includes = function (x)
{
for (var i = 0; i < this.length; i++)
if (this[i] == x)
return true;
return false;
}
Code:
var kod = document.getElementById("assembly").innerText;
if (!kod)
{
alerted = 1;
alert("Emitter error: Your browser doesn't appear to support the JavaScript 'innerText' directive. Can't send the assembly code to the server. Please use either Internet Explorer or some modern browser.");
document.getElementById("AJAXmessage").style.display = "none";
return;
}
if (/\n\n/.test(kod))
kod = kod.replace(/\n\n*/g, '\n');
if (!/\n$/.test(kod))
kod+='\n';
Code:
if (!document.createElementNS)
{
alert("Diagram error: Can't access the SVG elements from JavaScript. You appear to be using a browser that doesn't support that. If you are using Internet Explorer 11, make sure it isn't running in the compatibility mode.")
alerted = 1
return
}
The CSS Box-Model bug in Internet Explorer 6 also isn't trivial to detect. The code I ended up using, after lot of experimenting, is this:
Code:
if ((document.getElementById("zatvori").offsetWidth<18 || document.getElementById("zatvori").style.width=="21px") && document.getElementById("zatvori").style.display!="none") ie6=true;
Code:
if ((typeof navigator != "undefined") && /(M|m)obile/.test(navigator.userAgent))
document.getElementById("content").onclick = function () {
document.getElementsByTagName("nav")[0].style.display = "none";
};
The "z-index"-bug in Android Stock Browser 4.1 also appears not to be easily detectible via JavaScript. I've mitigated it similarly, but I suppose that if I managed to find a reliable way of detecting Android Stock Browser, my web-app would run smoother in other mobile browsers.
And, the only work-around around Internet Explorer 11 ignoring the CSS "overflow" property on the JavaScript-generated SVG elements on my homepage is browser-sniffing, right?
Code:
if (!(navigator.userAgent.indexOf("Trident")+1))
crtanje.appendChild(krug);
Quote:I suspect that the WAY you said things might have been part of your banning, not only your political position.If I remember correctly, I posted the following on a day of an anniversary of the Genocide of Vukovar: "Čemu plakati za Vukovarem? Po svemu što znamo, Bitka za Vukovar mogla bi biti samo mit!". That means: "What's the point of crying about Vukovar? For all we know, the Battle of Vukovar may be just a myth!".
By the way, which browser do you think will become the most hated among web-developers once Internet Explorer, Microsoft Edge and Android Stock Browser (all of which are either deprecated or about to become deprecated) disappear? I think it's going to be Firefox. I've had to mitigate Firefox-specific behavior two times in the compiler web-app:
Code:
if (document.getElementById("zatvori").style.left.substring(0,document.getElementById("zatvori").style.left.length-2)
-document.getElementById("content").style.width.substring(0,document.getElementById("content").style.width.length-2)>10)
document.getElementById("content").style.width=
document.getElementById("zatvori").style.left.substring(0,document.getElementById("zatvori").style.left.length-2)-3+"px";
Code:
if (!window.event) {
isFirefox=true;
window.event=new Object();
}
if (isFirefox)
{
window.event.clientX=e.clientX;
window.event.clientY=e.clientY;
}