/**
 * This file is part of rpmphp.
 *
 * rpmphp is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * rpmphp is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with rpmphp.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
* Initialize Zoom page using ajax:
* - loads description from pkgdb
* - loads packages informations from pkgdb
* @param String name Name of the package
*/
function initZoomJS(name)
{
    $('#pkgdb-link').remove();
    $.ajax({
        url: 'pkgdb-ajax.php?name=' + name,
        success: function(data) {
            if ( data.error ) {
                alert(data.error);
            } else {
                $('#' + 'pkgdb_desc').empty().html(data.devel.package.description);
                $.each(
                    data,
                    function(k, v){
                        _data = data[k];
                        _owner_cell = $('#pkgdb_' + k + '_owner');
                        if ( _owner_cell ) {
                            _owner_cell.empty().text(_data.owner);
                            _maintainers_cell = $('#pkgdb_' + k + '_maintainers');
                            _maintainers_cell.empty().text( _data.people);
                        }
                    }
                );
            }
        }
    });
}

$(function(){
    $('#rpm').autocomplete(
        'autocompleter.php', {
        max:15
    });
});