Редакция 401 |
Редакция 420 |
К новейшей редакции |
Авторство |
Сравнить с предыдущей |
Последнее изменение |
Открыть журнал
| Скачать
| 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 chooseDistro(){
var distValue = $('#dist').val();
var tmpSelect = $('#version');
if(distValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
chooseVersion();
$('#vdist').css('visibility','hidden');
$('#replist').css('display','none');
$('#getfile').css('display','none');
} else {
$.getJSON('./request.php',{d:distValue,step:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); chooseVersion(); });
$('#vdist').css('visibility','visible');
$('#replist').css('display','none');
$('#getfile').css('display','none');
}
};
// Выбор версии дистрибутива
function chooseVersion(){
var distValue = $('#dist').val();
var versionValue = $('#version').val();
if (distValue != 0 && versionValue != 0) {
$.get('./request.php',{d:distValue,v:versionValue,step:2},function(data){ $('#replist').css('display','block'); $('#replist').html(data); });
$.get('./request.php',{d:distValue,v:versionValue,step:3},function(data){ $('#getfile').css('display','block'); $('#getfile').html(data); });
$('#replist').css('visibility','visible');
} else {
$('#replist').css('display','none');
$('#getfile').css('display','none');
}
}
$('#dist').change(chooseDistro);
$('#version').change(chooseVersion);
});
</script>
";
$body = "<fieldset><legend>Дистрибутив</legend>\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>";
$body .= "<div id='vdist'>\n<fieldset>\n<legend>Версия дистрибутива</legend>\n";
$body .= "<select id='version' disabled='disabled'><option></option>\n";
$body .= "</select></div>\n";
//$body .= "<form action='./get.php' method='get'>\n";
$body .= "<div id='replist'></div>\n";
$tmpl->assign('scripts', $scripts);
$tmpl->assign('body', $body);
$tmpl->display('default.tpl');
?>