Javascript: Cancel/Stop Image Requests

I had the exact same issue, when users ‘paged’ quickly through (ajax) search results the browser was still trying to download profile images for every page not just the current one. This code worked for me, called on the paging event just before the new search was run: //cancel image downloads if(window.stop !== undefined) { … Read more

org.openqa.selenium.ElementNotInteractableException: Element is not reachable by keyboard: while sending text to FirstName field in Facebook

ElementNotInteractableException: Element is not reachable by keyboard Element is not reachable by keyboard in plain words means that the element can’t be reached using the keyboard, which means you won’t even physically interact with it. Reason There can be multiple reasons behind the error Element is not reachable by keyboard which can be either of … Read more

How to $inject dynamically dependence in a controller

Don’t call angular.injector() — this creates a new injector. Instead, inject the already-created $injector into your controller and use it: So instead of: var algoController = function($scope) { $scope.base64 = angular.injector([‘main’]).get(‘base64’); }; Do this: var algoController = function($scope, $injector) { $scope.base64 = $injector.get(‘base64’); }; But most of the time you should inject your service directly, … Read more

How to organize JS files in a Appcelerator Titanium project

Titanium itself is essentially MVC given that your app.js file is the main controller and each View you create is the view and you pass (or set) model data against the view. In Titanium, you can decompose your application using a couple of nice built-in mechanisms: Titanium.include – Titanium.include allows you to include one or … Read more

Javascript eval on global scope?

(function(){ eval.apply(this, arguments); }(a,b,c)) This will invoke eval using the global object, window in browsers, as the this argument passing any arguments you’ve passed into the anonymous function. eval.call(window, x, y, z) or eval.apply(window, arguments) is also valid if you’re certain window is the global object. This isn’t always true, however. For instance, the global … Read more

Angular session timeout and management [duplicate]

Try ng-idle. It’s simple component where you can set the timeout and warning time before the timeout is reached. Then you can query server for user logout or something similar. myApp.config(function(IdleProvider, KeepaliveProvider) { IdleProvider.idle(900); // 15 min IdleProvider.timeout(60); KeepaliveProvider.interval(600); // heartbeat every 10 min KeepaliveProvider.http(‘/api/heartbeat’); // URL that makes sure session is alive }); myApp.run(function($rootScope, … Read more