commit aad4c06d23c2986e53a2d046f9ccd0bc806e40a7
parent 3c988e6b4625b456aa44191fa56a4ae68cf21749
Author: Marcel <MTRNord@users.noreply.github.com>
Date: Sat, 31 Dec 2016 21:46:10 +0100
Try other way of focusing
Diffstat:
| M | screencap.js | | | 86 | ++++++++++++++++++++----------------------------------------------------------- |
1 file changed, 21 insertions(+), 65 deletions(-)
diff --git a/screencap.js b/screencap.js
@@ -234,73 +234,29 @@ function portalinfoScreen(){
});
},
success: function () {
- page.evaluate(function() {
- (function($) {
- $.fn.allBut = function(context) {
- var target = this;
- var otherList = $();
- var processList = $(context || 'body').children();
- while (processList.size() > 0) {
- var cElem = processList.first();
- processList = processList.slice(1);
- if (cElem.filter(target).size() != target.size()) {
- if (cElem.has(target).size() > 0) {
- processList = processList.add(cElem.children());
- } else {
- otherList = otherList.add(cElem);
- }
- }
- }
- return otherList;
- }
- })(jQuery);
- $('#sidebar').allBut().hide();
- });
- width = page.evaluate(function() {
- return document.getElementById('sidebar').clientWidth;
- });
- height = page.evaluate(function() {
- return document.getElementById('sidebar').clientHeight;
- });
- page.evaluate(function() {
- document.getElementById('sidebar').focus();
- });
- page.viewportSize = { width: width, height: height };
- setTimeout(function() {s(filepath)}, "1000");
+ var clipRect = page.evaluate(function(){
+ return document.querySelector('#sidebar').getBoundingClientRect();
+ });
+
+ page.clipRect = {
+ top: clipRect.top,
+ left: clipRect.left,
+ width: clipRect.width,
+ height: clipRect.height
+ };
+ setTimeout(function() {s(filepath)}, "1000");
},
error: function () {
- page.evaluate(function() {
- (function($) {
- $.fn.allBut = function(context) {
- var target = this;
- var otherList = $();
- var processList = $(context || 'body').children();
- while (processList.size() > 0) {
- var cElem = processList.first();
- processList = processList.slice(1);
- if (cElem.filter(target).size() != target.size()) {
- if (cElem.has(target).size() > 0) {
- processList = processList.add(cElem.children());
- } else {
- otherList = otherList.add(cElem);
- }
- }
- }
- return otherList;
- }
- })(jQuery);
- $('#sidebar').allBut().hide();
- });
- width = page.evaluate(function() {
- return document.getElementById('sidebar').clientWidth;
- });
- height = page.evaluate(function() {
- return document.getElementById('sidebar').clientHeight;
- });
- page.evaluate(function() {
- document.getElementById('sidebar').focus();
- });
- page.viewportSize = { width: width, height: height };
+ var clipRect = page.evaluate(function(){
+ return document.querySelector('#sidebar').getBoundingClientRect();
+ });
+
+ page.clipRect = {
+ top: clipRect.top,
+ left: clipRect.left,
+ width: clipRect.width,
+ height: clipRect.height
+ };
setTimeout(function() {s(filepath)}, "1000");
}
});