Sunday 30 September 2018

Know battery status of your mobile using JS

Hello guys,

Attaching code that will show your mobile is being charged or not, battery level and discharging time, simply using HTML and JS
Notes: Code works only for android

<html>
<head>
  <title>Battery Status API Example</title>
  <script>
    window.onload = function () {
      function updateBatteryStatus(battery) {
        document.querySelector('#charging').textContent = battery.charging ? 'charging' : 'not charging';
        document.querySelector('#level').textContent = battery.level;
        document.querySelector('#dischargingTime').textContent = battery.dischargingTime / 60;
      }

      navigator.getBattery().then(function(battery) {
        // Update the battery status initially when the promise resolves ...
        updateBatteryStatus(battery);

        // .. and for any subsequent updates.
        battery.onchargingchange = function () {
          updateBatteryStatus(battery);
        };

        battery.onlevelchange = function () {
          updateBatteryStatus(battery);
        };

        battery.ondischargingtimechange = function () {
          updateBatteryStatus(battery);
        };
      });
    };
  </script>
</head>
<body>
  <div id="charging">(charging state unknown)</div>
  <div id="level">(battery level unknown)</div>
  <div id="dischargingTime">(discharging time unknown)</div>
</body>
</html>



Stay Updated
Thanks
Aptechy

Tuesday 4 September 2018

Scroll To Top Demo Leads


hello Guys,
We used to face many of issues regarding Sticky side bar, Scroll when side bar is sticky etc kind of requirements, So I have found very easy stuffs by using which you guys can easily integrate it, If you still have any issues while using it, Please let me know, will defiantly help you!
You dont have to applu any Css or extra js for it
jQuery to include:

  • http://bigspotteddog.github.io/ScrollToFixed/jquery-scrolltofixed-min.js
  • Things to remember : You must include jQuery library(<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>) before including " jquery-scrolltofixed-min.js "

uses:
go through http://bigspotteddog.github.io/ScrollToFixed/
main code  snippet:
var summaries = $('.summary');
    summaries.each(function(i) {
    var summary = $(summaries[i]);
    var next = summaries[i + 1];

    summary.scrollToFixed({
        marginTop: $('.header').outerHeight(true) + 10,
        limit: function() {
            var limit = 0;
            if (next) {
                limit = $(next).offset().top - $(this).outerHeight(true) - 10;
            } else {
                limit = $('.footer').offset().top - $(this).outerHeight(true) - 10;
            }
            return limit;
        },
        zIndex: 999
    });

});

header – would be your wrapper class according to which you can make sticky side bar (Header part should not be scrolled)
summery – would be wrapper class which you want to make sticky
footer – would be your wrapper class , once it’s been scrolled up, your summery class will not have sticky functionality

Thank You,

Aptechy

Infinite scroll on collection page in Shopify

 Hello, Collection page structure is as followed {% paginate collection.products by 48 %} <div class="collection-content"> ...