Thursday 8 September 2016

Html Table Export To excel Using Javascript


Note : this Code is working Only Google Chrome
Note : only 2 MB data Uri in Exported  ( 1500 Record and 35 Columns ) Tested.


$("#btnExport").click(function(e) {
       //getting values of current time for generating the file name
       var dt = new Date();
       var day = dt.getDate();
       var month = dt.getMonth() + 1;
       var year = dt.getFullYear();
       var hour = dt.getHours();
       var mins = dt.getMinutes();
       var postfix = day + "." + month + "." + year + "_" + hour + "." + mins;
       //creating a temporary HTML link element (they support setting file names)
       var a = document.createElement('a');
       //getting data from our div that contains the HTML table
       var data_type = 'data:application/vnd.ms-excel';
       var table_div = document.getElementById('tableDiv');
       var table_html = table_div.outerHTML.replace(/ /g, '%20');
       a.href = data_type + ', ' + table_html;
       //setting the file name
       a.download = 'exported_table_' + postfix + '.xls';
       //triggering the function
       a.click();
       //just in case, prevent default behaviour
       e.preventDefault();
});

Friday 3 June 2016

English to marathi date convert


English to marathi date convert javascript

var marathiNumber = ["०","१","२","३","४","५","६","७","८","९"];
    function getMarathiDate(englishDate) {
      var englishDateArray = englishDate.split("");
      var marathiDate = "";
      englishDateArray.forEach(function(el) {
         if (isNaN(el) === false) {
           marathiDate +=  marathiNumber[el];
         } else {
           marathiDate += "-"
         }
      });
      return marathiDate;
    }

marathi date picker

bootstrap date picker localization example

bootstrap date picker marathi  localization

;(function($){
$.fn.datepicker.dates['MA'] = {
days: ["रविवारी", "सोमवारी", "मंगळवारी", "बुधवारी", "गुरुवारी", "शुक्रवारी", "शनिवारी"],
daysShort: ["रवी", "सोम", "मंगळ", "बुध", "गुर", "शुक", "शन"],
daysMin: ["रवी", "सोम", "मंगळ", "बुध", "गुर", "शुक", "शन"],
months: ["जानेवारी", "फेब्रुवारी", "मार्च", "एप्रिल", "मे", "जून", "जुलै", "ऑगस्ट", "सप्टेंबर", "ऑक्टोबर", "नोव्हेंबर", "डिसेंबर"],
monthsShort:  ["जानेवारी", "फेब्रुवारी", "मार्च", "एप्रिल", "मे", "जून", "जुलै", "ऑगस्ट", "सप्टेंबर", "ऑक्टोबर", "नोव्हेंबर", "डिसेंबर"],
today: "आज",
monthsTitle: "महिन्यात",
clear: "साफ करा",
weekStart: 1,
format: "d/mm/yyyy"
};
}(jQuery));


Sunday 22 May 2016

send push notification in android using node js?


send push notification in android ?
send push notification in android using node-gcm ?


save below code pushnotification.js

run code with this command

node pushnotification.js

register your token using  /register api call

open http://localhost:3000

send push notification
http://localhost:3000/push  (open in browser)


Friday 15 April 2016

Remove a drop down item if it is selected ?

   
Remove a drop down item if it is selected  Select2.js?
Ability to hide currently selected value in dropdown ?
Ability to hide currently selected value in dropdown Select2.js ?

$('#ddlType').select2({  
     tags:false,  
     multiple:multiple  
  });  




Hide Selected Tag Css
.select2-results__option[aria-selected="true"] {
  display:none;
}
.select2-results__option[aria-selected="false"] {
  display:block;
}




Prevent select2 dropdown open when clearing selection ?

  var ddl = selectEl.select2({  
       allowClear: true,  
       placeholder: "Select a "+columnName  
    }).on("select2:close",function() {  
      console.log("close");  
    }).on('select2:unselecting', function() {  
       $(this).data('unselecting',true);  
    }).on('select2:opening', function(e) {  
      if ($(this).data('unselecting')) {  
        $(this).removeData('unselecting');  
        e.preventDefault();  
      }  
    }).on("change", function (e) {  
       console.log("change event Call");
    });