From 129b0c84640afbc3da7fcb217869fd83710ef1f9 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Thu, 15 Dec 2011 14:22:09 +0200 Subject: Ensure WebBrowser is updated and available from BrowserDetails (#8098) --- WebContent/VAADIN/vaadinBootstrap.js | 78 +++++++++++++++++++++++++++++++++--- 1 file changed, 73 insertions(+), 5 deletions(-) (limited to 'WebContent/VAADIN/vaadinBootstrap.js') diff --git a/WebContent/VAADIN/vaadinBootstrap.js b/WebContent/VAADIN/vaadinBootstrap.js index 47656d9406..5728903545 100644 --- a/WebContent/VAADIN/vaadinBootstrap.js +++ b/WebContent/VAADIN/vaadinBootstrap.js @@ -86,11 +86,8 @@ // Root id url += ((/\?/).test(url) ? "&" : "?") + "browserDetails"; url += '&rootId=' + getConfig('rootId'); - // Uri fragment - url += '&f=' + encodeURIComponent(location.hash); - if (window.name) { - url += '&wn=' + encodeURIComponent(window.name); - } + url += '&' + vaadin.getBrowserDetailsParameters(appId); + // Timestamp to avoid caching url += '&' + (new Date()).getTime(); @@ -186,6 +183,77 @@ callback(appId); } widgetsets[widgetset].pendingApps = null; + }, + getBrowserDetailsParameters: function(parentElementId) { + // Screen height and width + var url = 'sh=' + window.screen.height; + url += '&sw=' + window.screen.width; + + // Window height and width + var cw = 0; + var ch = 0; + if(typeof(window.innerWidth) == 'number') { + // Modern browsers + cw = window.innerWidth; + ch = window.innerHeight; + } else { + // IE 8 + cw = document.documentElement.clientWidth; + ch = document.documentElement.clientHeight; + } + url += '&cw=' + cw + '&ch=' + ch; + + + var d = new Date(); + + url += '&curdate=' + d.getTime(); + + var tzo1 = d.getTimezoneOffset(); // current offset + var dstDiff = 0; + var rtzo = tzo1; + + for (var m=12;m>0;m--) { + d.setUTCMonth(m); + var tzo2 = d.getTimezoneOffset(); + if (tzo1 != tzo2) { + dstDiff = (tzo1 > tzo2 ? tzo1-tzo2 : tzo2-tzo1); // offset w/o DST + rtzo = (tzo1 > tzo2 ? tzo1 : tzo2); // offset w/o DST + break; + } + } + + // Time zone offset + url += '&tzo=' + tzo1; + + // DST difference + url += '&dstd=' + dstDiff; + + // Raw time zone offset + url += '&rtzo=' + rtzo; + + // DST in effect? + url += '&dston=' + (tzo1 != rtzo); + + var pe = document.getElementById(parentElementId); + if (pe) { + url += '&vw=' + pe.offsetWidth; + url += '&vh=' + pe.offsetHeight; + } + + // Uri fragment + if (location.hash) { + //Remove initial # + url += '&fr=' + encodeURIComponent(location.hash.replace(/^#/, "")); + } + // Window name + if (window.name) { + url += '&wn=' + encodeURIComponent(window.name); + } + + // Detect touch device support + try { document.createEvent("TouchEvent"); url += "&td=1";} catch(e){}; + + return url; } }; -- cgit v1.2.3