if ( typeof jQuery != 'undefined'){
jQuery(function($){
var AjaxPostUrl = 'inc/ajax-action-call.php?type=',
AjaxGetUrl = 'inc/ajax-get.php?type=',
PostUrl = 'inc/ajax-post.php?type=',
ProgramTable = $('#ProgramTable');
function loadPrograms() {
if (ProgramTable.length) {
$.ajax({
dataType: 'json',
url: AjaxGetUrl + 'programs',
fail: function(response) { console.log(response)},
error: function(response) { console.log(response)},
success: function( response ){
ProgramTable.children('tbody').html(response.msg);
}
});
}
}
setTimeout(loadPrograms(), 1000);
function getSocialCount () {
// https://free.sharedcount.com/url?url=http%3A%2F%2Fwww.navayan.com%2Fphoto-gallery.php%3Fname%3Dbabasaheb-ambedkar&apikey=479dfb502221d2b4c4a0433c600e16ba5dc0df4e
//console.log(document.URL);
$.ajax({
dataType: 'json',
url: 'https://free.sharedcount.com/url?url=' + document.URL,
fail: function(response) { console.log(response)},
error: function(response) { console.log(response)},
success: function( responseText ){
$('#social-count').html(responseText);
}
});
}
//getSocialCount();
/*$('form.ajaxFormPost').each(function(){
var i = $(this), id=i.attr('id'), params='';
$('input[type="submit"]', i).bind('click', function(){ // mouseover
var submit_btn = $(this);
switch( i.attr('id') ){
//case 'formProgram': params = 'inc/ajax-post.php?type=programs'; break; // POST A QUICK NOTE
//case 'feedback_form': params = 'inc/ajax-post.php?type=paliinmpsc'; break; // POST PALI IN MPSC EXAM
//case 'formPaliInConsti': params = 'inc/ajax-post.php?type=PaliInConsti'; break; // POST PALI IN MPSC EXAM
//case 'formSendUpdates': params = 'inc/ajax-post.php?type=SendUpdates'; break; // SEND SITE UPDATES TO USERS
case 'formSiteOptions': params = 'inc/ajax-post.php?type=SiteOptions'; break; // SITE OPTIONS
default: params = ''; break;
}
if ( params != '' ) submit_btn.AjaxSubmitForm({ ActionUrl: params});
return false;
});
});*/
$('.media-parts:visible').hide();
$('.partof-' + $('#media_main_type').val() ).show();
$('#media_main_type').change(function(){
$('.media-parts:visible').hide();
$('.partof-' + $(this).val() ).show();
});
// add org, bv etc
$('#SupportPali').AjaxSubmitForm({ ActionUrl: PostUrl + 'PaliInConsti' });
$('#SiteOptionsSubmit').AjaxSubmitForm({
ActionUrl: PostUrl + 'SiteOptions',
ClearForm: false
});
$('#ProgramSubmit').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddProgram' });
$('#AddOrg').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddOrg' });
$('#AddBuddhavihar').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddBuddhavihar' });
$('#AddMedia').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddMedia' });
$('#AddVideo').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddVideo' });
$('#AddBook').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddBook' });
$('#AddPaliCenter').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddPaliCenter' });
$('#AddScholarship').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddScholarship' });
$('#AddUrl').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddUrl' });
$('#AddAdvertize').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddAdvertize' });
$('#AddQuote').AjaxSubmitForm({ ActionUrl: PostUrl + 'AddQuote' });
$('#AddPost').AjaxSubmitForm({
ActionUrl: PostUrl + 'AddPost',
AfterSuccess: function(){
/*$.getJSON(AjaxGetUrl + 'GetPost', function(data) {
console.log(data);
});*/
}
});
$('#QuerySubmit').AjaxSubmitForm({
ActionUrl: PostUrl + 'ExecuteQuery',
ClearForm: false,
ConfirmBox: true,
ConfirmTxt: 'Sure to execute this query?',
AfterSuccess: function(){
$('#IDField, #RowID, #QueryCode').val('');
}
});
$('#SubmitCounselingForm').AjaxSubmitForm({
ActionUrl: PostUrl + 'CounselingForm',
AfterSuccess: function(){
$("#CounselingForm > p").hide();
setTimeout(function () {
window.location.href = "https://navayan.com/14.php";
}, 10000);
}
});
$('#SelectQuerySubmit').click(function (e) {
e.preventDefault();
var self = $(this);
var form = $('#FormSelectQuery');
var result = $('#SelectQueryResult', form);
var resultCount = $('#ResultCount', form);
$.ajax({
//type: 'post',
url: AjaxGetUrl + 'GetSelectQuery',
data: form.serialize(),
beforeSend: function () {
resultCount.text('querying...');
},
dataType: 'json',
success: function(response) {
var out = '';
if (response.err) {
out = response.msg;
}
else {
out = '
';
response.msg.header.forEach(function (r) {
out += '| '+ r +' | ';
});
out += '
';
var records = response.msg.body.length;
var countText = '';
if (records === 0) {
countText = 'No record found.';
} else if (records === 1) {
countText = '1 record found.';
} else if (records > 1) {
countText = records + ' records found.';
}
resultCount.text(countText);
response.msg.body.forEach(function (r) {
out += '';
for (var a in r) {
if (isNaN(a)) {
out += '| '+ r[a] +' | ';
}
}
out += '
';
});
out += '
';
}
result.html(out);
$('table tbody tr', result).click(function () {
$(this).toggleClass('active');
});
},
fail: function(response) {result.html(response)},
error: function(response) {result.html(response)}
});
});
$(document).on('click', '.compose-email-to', function (e) {
e.preventDefault();
var self = $(this);
//$('.toggle-tabs a.ComposeTabLink').trigger('click');
$('#ComposeTab #compose_email').val(self.attr('data-composeEmail'));
$('#ComposeTab #compose_subject').val('Navayan.com - Hostel Admission');
$('#ComposeTab #compose_body').val(
"JaiBhim " + self.attr('data-composeName') + ",\n\n" +
"For hostel admission, please check this document https://navayan.com/hostel-help.php.\n\n" +
"You will have to contact to district Social Welfare office and hostel rector office.\n\n" +
"--\n" +
self.attr('data-composeMessage')
);
});
$('#ComposeEmail').AjaxSubmitForm({
ActionUrl: PostUrl + 'ComposeEmail',
ClearForm: false,
ConfirmBox: true,
ConfirmTxt: "Sure to send this email?"
});
/*$.getJSON(AjaxGetUrl + 'GetPosts', function(response) {
console.log(response.msg);
});*/
$('.upload-ajax-image').click(function(e){
e.preventDefault();
var me = $(this),
grand = me.parents('.AjaxImageUpload'),
form = $('form', grand),
spin = $('.fa', grand),
view = $('.preview-uploaded-image', grand);
//spin.show();
form.ajaxForm().submit();
//spin.delay(2000).hide();
return;
$.ajax({
type: 'post',
url: form.attr('action'), //'inc/ajax-post.php?type=ImageUpload&tab=' + tab,
data: form.serialize(), //{img: me.val()},
dataType: 'html',
cache: false,
contentType: 'image/jpeg', /*'multipart/form-data',*/ //'application/x-www-form-urlencoded',
//crossDomain: true,
success: function(response){
if (response.err) {
//img_status.html(' Unable to upload');
}else{
//img_status.html('');
}
console.log(response);
},
fail: function(response) {console.log(response)},
error: function(response) {console.log(response)}
});
});
/*$('.ajax-image-upload').change(function(e){
e.preventDefault();
var me = $(this),
tab = me.attr('data-tab'),
temp = me.next('.ajax-image-temp-upload'),
img_status = me.next('.ajax-image-upload-status');
$.ajax({
type: 'post',
url: 'inc/ajax-post.php?type=ImageUpload&tab=' + tab,
data: {img: me.val()},
dataType: 'json',
success: function(response){
if (response.err) {
img_status.html(' Unable to upload');
}else{
img_status.html('');
}
},
fail: function(response) {console.log(response)},
error: function(response) {console.log(response)}
});
});*/
// loksabha 2014 click/hover counter
$(document).on('click', '#loksabha_2014 a', function(e){
e.preventDefault();
var a = $(this);
$.ajax({
type: 'post',
url: 'inc/ajax-post.php?type=ls2014&code='+ a.attr('data-code') +'&id=' + a.attr('data-click'),
dataType: 'json',
success: function(){ window.location.href = a.attr('href'); },
fail: function() {},
error: function() {}
});
});
// Load more enterprises asynchronously
$(document).on('click', '#load-more-enterprises', function(e){
e.preventDefault();
var me = $(this),
loader = $('.fa', me),
more = $('span', me),
target = $('.enterprise-list'),
initialCount = parseInt(target.attr('data-rows'));
$.ajax({
type: 'get',
url: 'inc/ajax-get.php?type=enterprises&code='+ a.attr('data-code') +'&id=' + a.attr('data-click'),
dataType: 'json',
success: function(){ window.location.href = a.attr('href'); },
fail: function() {},
error: function() {}
});
});
$(document).on('click','a.AjaxLoadMoreRecords', function(e){
e.preventDefault();
var i = $(this),
recordscount = parseInt(i.attr('data-count')),
pluscount = parseInt(i.attr('data-plus')),
tar = i.parents('.AjaxedContent'),
active_menu = $('a.on', SidebarMenu),
param = active_menu.attr('data-param'),
param2 = active_menu.attr('data-param2'),
param2_url = param2 ? '¶m=' + param2 : '',
table = $('.LoadContent table', tar),
tbody = $('tbody', table),
temp = $('.LoadMoreRecords', tar); // work on this .LoadMoreRecords
if(!i.is('.NoMoreRecords')){
i.text('loading...');
if(param){
$.ajax({
type: 'post',
dataType: 'json',
url: AjaxGetUrl + param + param2_url + '&start=' + recordscount,
fail: function( response ) { console.log( response.msg ); },
error: function( response ) { console.log( response.msg ); },
success: function( response ){
if (response.err){
i.text(response.msg).addClass('NoMoreRecords');
}else{
temp.html(response.msg);
//$('tr.LoadedRecordsSeparator:last', tbody).removeClass('LoadedRecordsSeparator');
$('tr:first', temp).addClass('LoadedRecordsSeparator');
$('tr', temp).appendTo(tbody);
$('tr.LoadedRecordsSeparator:last', tbody).PageScroll({diff: 50});
i.attr('data-count', recordscount + pluscount).text('More records');
}
}
});
}else{
var this_href = active_menu.attr('href').slice(1);
// get member contacts
if (this_href == 'MemberContacts') {
$.ajax({
type: 'post',
dataType: 'json',
url: AjaxGetUrl + this_href + '&start=' + recordscount,
fail: function( response ) { console.log( response.msg ); },
error: function( response ) { console.log( response.msg ); },
success: function( response ){
if (response.err){
i.text(response.msg).addClass('NoMoreRecords');
}else{
$(response.msg).appendTo( $('#' + this_href + ' ol'));
i.attr('data-count', recordscount + pluscount).text('More records');
}
}
});
} // member contacts
}
}
});
// ADVT COUNTER
$('a.NYClientAd').click(function(){
var i = $(this);
$.ajax({
type: 'post',
url: 'inc/ajax-post.php?type=NYClientAdClick&id=' + i.attr('id'),
dataType: 'json',
success: function(){ window.location.href = i.attr('href'); },
fail: function() {},
error: function() {}
});
return false;
});
$('a.NYClientAd').contextmenu(function(){
var i = $(this);
$.ajax({
type: 'post',
url: 'inc/ajax-post.php?type=NYClientAdClick&id=' + i.attr('id'),
dataType: 'json',
success: function(){},
fail: function() {},
error: function() {}
});
return false;
});
// Bihar Election link counter
$('a.BiharElection').click(function(e){
e.preventDefault();
var i = $(this);
$.ajax({
type: 'post',
url: 'inc/ajax-post.php?type=BiharElectionClick',
dataType: 'json',
success: function(response){
if (response.err) {
} else {
setTimeout(function () {
window.location.href = i.attr('rel');
//window.open(i.attr('rel'), '_blank');
}, 10000);
}
},
fail: function() {},
error: function() {}
});
//return false;
});
$('a.BiharElection').contextmenu(function(e){
e.preventDefault();
var i = $(this);
$.ajax({
type: 'post',
url: 'inc/ajax-post.php?type=BiharElectionClick',
dataType: 'json',
success: function(response){
if (response.err) {
} else {
setTimeout(function () {
window.location.href = i.attr('rel');
//window.open(i.attr('rel'), '_blank');
}, 10000);
}
},
fail: function() {},
error: function() {}
});
//return false;
});
// reload clicks
$('#ReloadBiharElectionClicks').click(function(e){
e.preventDefault();
var i = $(this);
var b = $('b', i);
b.text('loading...');
$.ajax({
type: 'get',
url: 'inc/ajax-get.php?type=BiharElectionClick',
dataType: 'json',
success: function(response){
if (response.err) {
} else {
b.text(response.msg);
}
},
fail: function() {},
error: function() {}
});
//return false;
});
/*setInterval(function(){
$('.AppealSentCount b').load( $('body').attr('pali-consti-count') );
}, 10000);*/
}); // END JQUERY FUNCTION CALL
} // END JQUERY EXIST CHECK