Хранилища Subversion ant

Редакция

Редакция 395 | Авторство | Сравнить с предыдущей | Последнее изменение | Открыть журнал | Скачать | RSS

<?php

/**
 *  
 *  Codename: ant-ng - generator of sources.list for Debian and
 *  distributives, based on Debian
 *  http://alex-w.org.ru/p/antng/
 *
 *  Copyright (c) 2009 Alexander Wolf
 *  Dual licensed under the MIT and GNU LGPL licenses.
 *  http://alex-w.org.ru/p/antng/license
 *
 */


require_once dirname(__FILE__)."/init.php";

$scripts = "
<script type='text/javascript'>
(function($){
    // очищаем select
    $.fn.clearSelect = function() {
        return this.each(function(){
            if(this.tagName=='SELECT') {
                this.options.length = 0;
                $(this).attr('disabled','disabled');
            }
        });
    }
    // заполняем select
    $.fn.fillSelect = function(dataArray) {
        return this.clearSelect.each(function(){
            if(this.tagName=='SELECT') {
                var currentSelect = this;
                $.each(dataArray,function(index,data) {
                    var option = new Option(data.text,data.value);
                    if($.support.cssFloat) {
                        currentSelect.add(option,null);
                    } else {
                        currentSelect.add(option);
                    }
                });
            }
        });
    }
})(jQuery);
</script>
<script type='text/javascript'>
$(document).ready(function(){
    // выбор дистрибутива
    function chooseDist() {
        var distValue = $('#dist').val();
        var tmpSelect = $('#version');
        if(distValue.length == 0) {
            tmpSelect.attr('disabled','disabled');
            tmpSelect.clearSelect();
            chooseVersion();
        } else {
            $.getJSON('./request.php',{d:distValue,status:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); chooseVersion(); });
        }
    };
    // выбор версии дистрибутива
    function chooseVersion() {
        var distValue = $('#dist').val();
        var versValue = $('#version').val();
        if(distValue != 0 && versValue !=0 ) {
            $.get('./request.php',{d:distValue,v:versValue,status:2},function(data){ chooseReps(); });
        }
    };
});
</script>
"
;

$body  = "<fieldset><label>Дистрибутив</label>\n";
$body .= "<select id='dist'>\n<option value=''>Выберите дистрибутив</option>\n";

$query = "SELECT * FROM ".PREFIX."distribution ORDER BY dist_id ASC";
$rq =& $db->query($query);
while ($rq->fetchInto($element)) {
    $body .= "<option value='".$secure->checkInt($element["dist_id"])."'>".$secure->checkStr($element["distname"],1)."</option>\n";
}
$body .= "</select></fieldset>";

$tmpl->assign('scripts', $scripts);
$tmpl->assign('body', $body);

$tmpl->display('default.tpl');

?>