Joomla-Sermon-Distributor-Fork/media/js/local_listing.js

65 lines
2.7 KiB
JavaScript

/*-------------------------------------------------------------------------------------------------------------| www.vdm.io |------/
____ ____ __ __ __
/\ _`\ /\ _`\ __ /\ \__ __/\ \ /\ \__
\ \,\L\_\ __ _ __ ___ ___ ___ ___ \ \ \/\ \/\_\ ____\ \ ,_\ _ __ /\_\ \ \____ __ __\ \ ,_\ ___ _ __
\/_\__ \ /'__`\/\`'__\/' __` __`\ / __`\ /' _ `\ \ \ \ \ \/\ \ /',__\\ \ \/ /\`'__\/\ \ \ '__`\/\ \/\ \\ \ \/ / __`\/\`'__\
/\ \L\ \/\ __/\ \ \/ /\ \/\ \/\ \/\ \L\ \/\ \/\ \ \ \ \_\ \ \ \/\__, `\\ \ \_\ \ \/ \ \ \ \ \L\ \ \ \_\ \\ \ \_/\ \L\ \ \ \/
\ `\____\ \____\\ \_\ \ \_\ \_\ \_\ \____/\ \_\ \_\ \ \____/\ \_\/\____/ \ \__\\ \_\ \ \_\ \_,__/\ \____/ \ \__\ \____/\ \_\
\/_____/\/____/ \/_/ \/_/\/_/\/_/\/___/ \/_/\/_/ \/___/ \/_/\/___/ \/__/ \/_/ \/_/\/___/ \/___/ \/__/\/___/ \/_/
/------------------------------------------------------------------------------------------------------------------------------------/
@version 2.0.x
@created 22nd October, 2015
@package Sermon Distributor
@subpackage local_listing.js
@author Llewellyn van der Merwe <https://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
A sermon distributor that links to Dropbox.
/----------------------------------------------------------------------------------------------------------------------------------*/
jQuery(document).ready(function()
{
var sharedurls = jQuery('#jform_sharedurl').val();
if (sharedurls) {
getBuildTable(sharedurls,'jform_sharedurl');
}
var folders = jQuery('#jform_folder').val();
if (folders) {
getBuildTable(folders,'jform_folder');
}
jQuery('.save-modal-data').text('Done');
});
function getBuildTable_server(string,idName){
var getUrl = "index.php?option=com_sermondistributor&task=ajax.getBuildTable&format=json";
if(token.length > 0 && string.length > 0 && idName.length > 0){
var request = 'token='+token+'&idName='+idName+'&oject='+string;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
function getBuildTable(string,idName){
getBuildTable_server(string,idName).done(function(result) {
if(result){
buildTable(result,idName);
} else {
jQuery('#table_'+idName).remove();
}
})
}
function buildTable(result,idName){
jQuery('#table_'+idName).remove();
jQuery('#'+idName).closest('.control-group').append(result);
}