-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplatform-not-kaios-not-firefox.js
113 lines (99 loc) · 4.14 KB
/
platform-not-kaios-not-firefox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
var OSName="Unknown OS";
if (navigator.userAgent.indexOf("Altaica")!=-1) OSName="Altaica";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
// using these directly from index.js says OSName is undefined; have to fix it
var envlogtxt = "Environment detected: " // also had to place it again; fix like in the previous
// from https://ourcodeworld.com/articles/read/390/how-to-know-if-your-application-is-running-in-cordova-or-a-web-browser
if(window.hasOwnProperty("cordova")){
console.log(envlogtxt +"Cordova.");
var environmenttext = document.getElementById('environment');
var text = document.createTextNode(OSName);
environmenttext.appendChild(text);
}
// Or
if(typeof(cordova) == "object"){
console.log(envlogtxt +"Cordova.");
var environmenttext = document.getElementById('environment');
var text = document.createTextNode(OSName);
environmenttext.appendChild(text);
}
// Or
if(!!window.cordova){
console.log(envlogtxt +"Cordova.");
var environmenttext = document.getElementById('environment');
var text = document.createTextNode(OSName);
environmenttext.appendChild(text);
}
// from https://ourcodeworld.com/articles/read/390/how-to-know-if-your-application-is-running-in-cordova-or-a-web-browser
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf(' electron/') > -1) {
console.log(envlogtxt +"Electron⚛");
var environmenttext = document.getElementById('environment');
var text = document.createTextNode("Electron⚛");
environmenttext.appendChild(text);
}
if(OSName == 'Altaica'){
console.log(envlogtxt +OSName +".");
var environmenttext = document.getElementById('environment');
var text = document.createTextNode(OSName);
environmenttext.appendChild(text);
}
if("file:" == document.location.protocol)
{
console.log(envlogtxt +"File protocol; Local page.");
//document.querySelector("#environment").innerHTML = `File protocol; Local page.`;
}
if("localhost:" == document.location.protocol)
{
console.log(envlogtxt +"Localhost.");
//document.querySelector("#environment").innerHTML = `Localhost`;
}
if("ipfs:" == document.location.protocol){console.log(envlogtxt +"IPFS.");}
if(window.location.href.match(/ba(.*)\.ipfs\./)){console.log(envlogtxt +"IPFS.");}
if(window.location.href.indexOf("/ipfs/Qm") > -1){console.log(envlogtxt +"IPFS.");}
if(window.location.href.indexOf("/ipfs/ba") > -1){console.log(envlogtxt +"IPFS.");}
if((navigator.userAgent.indexOf("Opera") || navigator.userAgent.indexOf('OPR')) != -1 )
{
alert('Opera');
}
else if(navigator.userAgent.indexOf("Chrome") != -1 )
{
alert('Chrome');
/* document.querySelector("#environment").innerHTML = `Chrome`; */
}
else if(navigator.userAgent.indexOf("Safari") != -1)
{
alert('Safari');
}
else if(navigator.userAgent.indexOf("Firefox") != -1 )
{
//alert('Firefox');
}
else if((navigator.userAgent.indexOf("MSIE") != -1 ) || (!!document.documentMode == true )) //IF IE > 10
{
alert('IE');
}
else
{
alert('unknown');
}
//function setInnerHTML(element, content) {
// element.innerHTML = content;
// return element;
//}
if(typeof(cordova) !== "object"){
if (OSName !== 'Altaica'){
if (userAgent.indexOf(' electron/') <= -1){
document.querySelector("#splashloader").innerHTML = ``;
console.log(envlogtxt +"Not mobile and not desktop app.");
var environmenttext = document.getElementById('environment');
var text = document.createTextNode("Not mobile and not desktop app.");
environmenttext.appendChild(text);
requirejs(["platform-not-mobile-not-desktop.js"],function(util){});
requirejs(["platform-not-mobile-not-desktop-custom.js"],function(util){});
}
}
}