-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
56 lines (52 loc) · 2.36 KB
/
index.html
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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chain of Resposability Design Pattern with DOJO framework</title>
</head>
<body style="{background-color: #6eff59}">
<h1>Browser and OS Chained Detection</h1>
<div id="cordetectorout"></div>
<!--div> <h2>Are you using ... </h2><ul><li>FireFox?{% if browser.isFireFox %} YEP! {% else %} nope {% endif %}</li></ul></div-->
<script>
var dojoConfig = {
async: true,
// This code registers the correct location of the "js"
// package so we can load Dojo from the CDN whilst still
// being able to load local modules
packages: [{
name: "js",
location: location.pathname.replace(/\/[^/]+$/, '') + 'js'
}]
};
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"></script>
<script type="text/javascript">
require([
"dojo/dom",
"js/cordetector2",
"dojox/dtl",
"dojox/dtl/Context",
"dojo/domReady!"], function(dom, cor, dtl, context){
console.log("cor.browser.isFirefox: " + cor.browser.isFirefox);
console.log("cor.browser.isIE: " + cor.browser.isIE);
console.log("cor.browser.isChrome: " + cor.browser.isChrome);
console.log("cor.browser.isSafari: " + cor.browser.isSafari);
console.log("cor.os.isWin: " + cor.os.isWin);
console.log("cor.os.isMac: " + cor.os.isMac);
var templateString = '<div> <h2>Detecting your browser ... </h2><ul>' +
'<li>FireFox:{% if browser.isFireFox %} YEP! {% else %} nope {% endif %}</li>' +
'<li>Internet Explorer:{% if browser.isIE %} YEP! {% else %} nope {% endif %}</li>' +
'<li>Safari:{% if browser.isSafari %} YEP! {% else %} nope {% endif %}</li>' +
'<li>Chrome:{% if browser.isChrome %} YEP! {% else %} nope {% endif %}</li>' +
'</ul><h2>Detecting your OS ... </h2><ul>' +
'<li>Windows:{% if os.isWin %} YEP! {% else %} nope {% endif %}</li>' +
'<li>Mac OS X:{% if os.isMac %} YEP! {% else %} nope {% endif %}</li>' +
'</div>';
var template = new dtl.Template(templateString);
var context = new context(cor);
document.getElementById('cordetectorout').innerHTML = template.render(context);
});
</script>
</body>
</html>