At the moment it takes a few clicks to toggle the 'include_docs' flag inside the cloudant dashboard. If you do this a lot, it can be a little time consuming.
How can I speed this process up?
I created a javascript bookmarklet:
javascript:(function(){
if(document.location.toString().contains('include_docs=true')){
document.location=document.location.toString().replace('include_docs=true', '')
} else {
if (document.location.toString.contains('?') {
document.location+='&include_docs=true'
} else {
document.location+='?include_docs=true'
}
}
}())
When I want to toggle the 'include_docs' on or off, I can simply click on this bookmark in my bookmark toolbar.
Note: I have only tested this on firefox.
Related
I am trying to get the user to 'install' the shortcut icon to a webpage and use it as an icon to the PWA.
I am wondering if any of you had a chance to somehow discover if the user installed the shortcut on home screeen?
This is an interesting case, because when developing on Android or such one has access to such information, on the other hand I don't recall browser giving that information away.
The beforeinstallprompt will only fire if the user has NOT installed the PWA
First: Use that to check if installed
window.addEventListener('beforeinstallprompt', (e) => {
// If you get inside here, the PWA is not installed
});
Example code here
https://developers.google.com/web/fundamentals/app-install-banners
Second: If you are showing your own deferred prompt like the examples at the link above, you can listen to know if they close that without adding to home screen (A2HS)
// Wait for the user to respond to the prompt
this.deferredPrompt.userChoice
.then((choiceResult) => {
if (choiceResult.outcome === 'accepted') {
// User said yes to your A2HS
} else {
this.deferredPromptRejected = true;
}
});
Third: You can check if your PWA is running as a standalone
function isRunningStandalone() {
return (window.matchMedia('(display-mode: standalone)').matches);
}
Currently i am developing a listings portal here i am using angularjs as frontend and through this i am calling api to load data right now when a user hit all listings link whole data is loading and showing at this point the data is very less so problem but if data is large it will take some loading time, my requirement is when a user first click the link it has to show only top 50 listings and if user scrolls down the page then again api has to call for next 50 listings and so on how can i achieve this with angularjs.
Hope this helps.
$scope.limit=50;
$scope.loadMore1=true;
$scope.count=0;
$scope.loadMore=function()
{
$scope.limit=$scope.limit+100;
if($scope.limit>=$scope.count) {
$scope.loadMore1=false;
} else {
$scope.loadMore1=true;
}
$("html, body").animate({ scrollTop: $(document).height() }, 1000);
}
Inside your ajax call or api call
if(result.data.items.length<=50)
{
$scope.loadMore1=false;
} else {
$scope.count=result.data.items.length;
$scope.loadMore1=true;
}
And finally HTML list which loads certain number of results
<li ng-repeat="r in results | limitTo:limit"></li>
<button class="loadMore" ng-show="loadMore1" ng-click="loadMore()">Load more Items...</button>
I am using magnific popup JS (http://dimsemenov.com/plugins/magnific-popup/) to produce a popup for a youtube video on my Drupal site. The implementation works fine, but only if I am logged into Drupal. If I am not logged in, the popup link will just go the the youtube page (eg jQuery not initialising).
I suspect there may be something going on with Drupal loading a different version of jQuery when I am logged in. It seems that I may be able to add something to my template file to fix this. Haven't figured it out yet (https://www.drupal.org/node/2165555)
I do not have access to add jQuery update module.
Fixed. Added below snippet to template.php to force a later version of jQuery to load.
function theme_name_js_alter(&$javascript) {
$node_admin_paths = array(
'node/*/edit',
'node/add',
'node/add/*',
'node/*/extend_review_date',
);
$replace_jquery = TRUE;
if (path_is_admin(current_path())) {
$replace_jquery = FALSE;
} else {
foreach ($node_admin_paths as $node_admin_path) {
if (drupal_match_path(current_path(), $node_admin_path)) {
$replace_jquery = FALSE;
}
}
}
// Swap out jQuery to use an updated version of the library.
if ($replace_jquery) {
$javascript['misc/jquery.js']['data'] = '//code.jquery.com/jquery-1.7.0.min.js';
}
}
I would like to track VideoJS using Google Tag Manager. Since I am fairly new to GTM I have no idea how to proceed. I have only done some basic stuff like tracking mailto links and PDF downloads using tutorials.
I found a project on Github called videojs-ga which looks promising, now how would I correctly connect and set this up in GTM? Idealy we would end up tracking the play count and how long the video's get watched. There is no need to track multiple videos per page since there is only one video on a single page at any time.
Also if there is a better way to track VideoJS with GTM I am open to suggestions!
I suggest you make a fork from the code in that repository/ download the file from src and make the changes locally. In line 104 where it says:
sendbeacon = function(action, nonInteraction, value) {
if (window.ga) {
ga('send', 'event', {
'eventCategory': eventCategory,
'eventAction': action,
'eventLabel': eventLabel,
'eventValue': value,
'nonInteraction': nonInteraction
});
} else if (window._gaq) {
_gaq.push(['_trackEvent', eventCategory, action, eventLabel, value, nonInteraction]);
} else if (options.debug) {
console.log("Google Analytics not detected");
}
};
you replace the stuff within the sendbeacton function object in the following way:
sendbeacon = function(action, nonInteraction, value) {
dataLayer.push(
'eventCategory': eventCategory,
'eventAction': action,
'eventLabel': eventLabel,
'event' : 'videojs'
);
};
(make sure your dataLayer variable is declared somewhere before your GTM code). Create a script tag that links the modified script to our page.
Then create three variables of the "dataLayer" type which read their values from eventCategory, eventAction and eventLabel respectively. Set up a Google Analytics tag and configure it for event tracking, and pass in the variables to the respective fields. Create a trigger type custom event, event eq 'videojs' and use it to fire the GA event tracking tag.
I am using jqMobi, ( NOT jQuery Mobile ).
I am trying to get a swipelistener to work on the menu. Basically I just want to 'swipe' the menu open or closed with a horizontal swiping motion. Here is my js:
$.ui.ready(function () {
. . . . .
$(window).swipeListener({
vthreshold: 50,
hthreshold: 70,
callBack: function (dir) {
if (dir.right) {
$.ui.toggleSideMenu(true);
}
if (dir.left) {
$.ui.toggleSideMenu(false);
}
}
});
});
This works great except for when I 'swipe' on this red part here -->
If I swipe anywhere else, it works fine. I have also tried to use the document selector, that also didn't work. I tried to add another swipelistener to the #menu and #menu_scroller as well.
This is very difficult for me to debug as my device is IOS6 and the "Debug Console" has been removed, so I can't just add a ton of console logging. ( I don't have a Mac, so I can't hook up the Developer Menu )
My theory is that since there are ontouchstart and ontouchend listeners on the menu items that this is interfering with my swipelistener. Any suggestions?
The swipeListener is being deprecated. Instead, there are events dispatched by jqUi [swipe,swipeLeft,swipeRight,swipeUp,swipeDown] that you can bind. The listeners you have for ontouchstart/ontouchend could be killing the event from propegating up though (are they custom listeners?)
$.ui.ready(function(){
$(document).bind("swipeLeft",function(){
$.ui.toggleSideMenu(false);
});
$(document).bind("swipeRight",function(){
$.ui.toggleSideMenu(true);
});
}