//===================================For DM URL Constant Path========================
//var dmurl = 'https://test.danamojo.org/dm'; //==========TEST==============
//var dmurl = 'https://staging.danamojo.org/dm'; //==========STAGING===========
var dmurl = 'https://danamojo.org/dm'; //==========LIVE==============
//var dmurl = 'http://localhost/dm'; //==========Localhost==============
//===================================For DM URL Constant Path========================
(function() {
// Localize jQuery variable
var jQuery;
/******** Load jQuery if not present *********/
var host = window.location.hostname;
var params = new URLSearchParams(window.location.search);
if(params.has('utm_campaign') && getCookie("dana_donation_source") == ''){
const d = new Date();
d.setTime(d.getTime() + (7*24*60*60*1000));//10days
let expires = "expires=" + d.toUTCString();
document.cookie = "dana_donation_source=" + params.get('utm_campaign') + ";" + expires + ";path=/";
}
if(getCookie("dana_donation_source") != ''){
dana_donation_source = getCookie("dana_donation_source");
}else{
dana_donation_source = '';
}
if(host == 'www.bhumi.ngo'){
if (window.jQuery === undefined) {
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src",
"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function () { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
scriptLoadHandler();
}
};
} else {
script_tag.onload = scriptLoadHandler;
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
jQuery = window.jQuery;
main();
}
}
else{
if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2.0') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src",
"https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function () { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
scriptLoadHandler();
}
};
} else {
script_tag.onload = scriptLoadHandler;
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
jQuery = window.jQuery;
main();
}
}
/******** Called once jQuery has loaded ******/
function scriptLoadHandler() {
// Restore $ and window.jQuery to their previous values and store the
// new jQuery in our local jQuery variable
jQuery = window.jQuery.noConflict(true);
// Call our main function
main();
}
/******** Our main function ********/
function main() {
var starttime = new Date();
jQuery(document).ready(function($) {
/******* Load CSS *******/
jQuery = jQuery.noConflict(true);
var divStr = '
';
document.getElementsByTagName('body')[0].innerHTML += divStr;
var divModal = '
×
';
document.getElementsByTagName('body')[0].innerHTML += divModal;
var d = new Date();
/******* Load CSS *******/
var css_link = $("", {
rel: "stylesheet",
type: "text/css",
href: dmurl+"/css/widget_style.css?t="+d.getTime()
});
css_link.appendTo('head');
var css_gift_link = $("", {
rel: "stylesheet",
type: "text/css",
href: dmurl+"/css/gift_a_donation_style.css?t="+d.getTime()
});
css_gift_link.appendTo('head');
var micro_css_link = $("", {
rel: "stylesheet",
type: "text/css",
href: dmurl+"/css/microsite_style.css?t="+d.getTime()
});
micro_css_link.appendTo('head');
var js_link = $("";
$("#ngoContentContainer" ).after(gTag);
}
function donationProductsOverlay(){
var widget_content = $('#ngoContentContainer').html();
if(widget_content.length>1000){
$('#productoverlay').modal({
keyboard: true,
backdrop:false
});
$("#loading_div").hide();
$("#_navigation_state").val("0");
$("#_payment_option").val("1");
$("#_chequeDraftBankName").val("");
$("#_chequeDraftNumber").val("");
$("#_chequeDraftDate").val("");
$("#_chkbxChequePickup").val("");
$("#_trackingNumber").val("");
$("#donor-data").removeClass("active");
$("#donor_data").removeClass("active");
$("#donor-data").addClass("disabled");
$("#payment-options").removeClass('active');
$("#payment_options").removeClass('active');
$("#payment-options").addClass('disabled');
$("#confirmation-tab").removeClass('active');
$("#confirmation").removeClass('active');
$("#confirmation-tab").addClass('disabled');
$("#product-list").removeClass("disabled");
//$("#product-list").addClass("active");
$("#product_list").addClass("active");
$("#payment_options").hide();
$("#donor_data").hide();
$("#confirmation").hide();
$("#product_list").show();
$("#customDonationInfoId").val("");
$("#product-list a").removeAttr("style");
$("#product-list a").addClass("dm-theme-bgcolor");
$("#product-list").addClass("dmactive");
var donationProductNGOId = $('.donationProductNGOId_0').val();
var baseUrl = $("#customBaseUrl").text();
var refererUrl = $("#donationinfo-iframeurl").val();
var data = {'refererUrl' : refererUrl,'ngoId' : donationProductNGOId}
$.ajax({
url: baseUrl+'/button-logs',
type: 'POST',
data:data,
error: function() {
},
async: false,
success: function(response) {
return true;
}
});
}else{
alert("Please note that the page has not loaded completely. This may happen if you are over a slow Internet connection. We request you to wait for awhile for the page to load. If you are yet facing a problem, please refresh the page by clicking Ctrl+F5 to load the page completely.");
}
var currency_code = $('#currency_dropdown').val();
if(currency_code == 'INR'){
$("[custom_curr_att]").hide();
$('.inr_fade_cls,.inr_fade_cls span').css("color", "#333333");
$('.inr_fade_grid_cls,.inr_fade_grid_cls span').css("color", "#4a9111");
$('.inr_fade_cls,.inr_fade_cls span').css('font-size', '17px');
$('.inr_fade_grid_cls,.inr_fade_grid_cls span').css('font-size', '17px');
$('.cls-mobile-hide').hide();
}else{
$("[custom_curr_att]").show();
$('.inr_fade_cls,.inr_fade_cls span').css("color", "#c4bcbc");
$('.inr_fade_grid_cls,.inr_fade_grid_cls span').css("color", "#b8dd99");
$('.inr_fade_cls,.inr_fade_cls span').css('font-size', '15px');
$('.inr_fade_grid_cls,.inr_fade_grid_cls span').css('font-size', '15px');
$('.cls-mobile-hide').show();
}
$('.total-price-font-cls span').css('font-size', '20px');
}
function setloadtime(starttime,ngoId,refererUrl,dmurl){
// let userAgentString = navigator.userAgent;
// let firefoxAgent = userAgentString.indexOf("Firefox") > -1;
// let chromeAgent = userAgentString.indexOf("Chrome") > -1;
// var iframe = (window.location != window.parent.location) ? 'TRUE' : 'FALSE';
// var update = false;
// if(!chromeAgent && iframe == 'TRUE'){// ====== To avoid chrome entry in due to iFrame case======
// update = true;
// }
// else if(chromeAgent && iframe == 'FALSE'){// ====== To avoid chrome entry in due to iFrame case======
// update = true;
// }
// else if(iframe == 'FALSE'){// ====== To avoid chrome entry in due to iFrame case======
// update = true;
// }
var endtime = new Date();
var clientLoadTime = (endtime-starttime)/1000;
var serverLoadTime = $('#serverLoadTime').text();
var start_date = $('#start_date').text();
var end_date = $('#end_date').text();
var res_refererUrl = encodeURIComponent(refererUrl);
var ngoId = ngoId.trim();
var url = dmurl+"/widget/setloadtime?ngoId="+ngoId+"&clientLoadTime="+clientLoadTime+"&serverLoadTime="+serverLoadTime+"&start_date="+start_date+"&end_date="+end_date+"&refererUrl="+res_refererUrl;
$.get(url, function(data, status){
//alert(data);
});
}
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie() {
var user = getCookie("username");
if (user != "") {
alert("Welcome again " + user);
} else {
user = prompt("Please enter your name:", "");
if (user != "" && user != null) {
setCookie("username", user, 365);
}
}
}
function showTabDiv(pageid) {
$("html, body").animate({ scrollTop: 0 }, "slow");
window.location.hash = pageid;
}