Редакция 51 | К новейшей редакции | Авторство | Сравнить с предыдущей | Последнее изменение | Открыть журнал | Скачать | RSS
<?php
/**
* Project: Ant: sources.list generator
* File: modern.php
*
* This application is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This application 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
include "lib/init.php";
$query =& $db->query("SELECT * FROM settings WHERE opt LIKE 'version'");
$query->fetchInto($antv, DB_FETCHMODE_ASSOC);
$antversion = $antv["optvalue"];
$scripts = "
(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 adjustDistro(){
var distroValue = $('#distro').val();
var tmpSelect = $('#distver');
if(distroValue.length == 0) {
tmpSelect.attr('disabled','disabled');
tmpSelect.clearSelect();
adjustReps();
$('#replist').css('display','none');
$('#getfile').css('display','none');
} else {
$.getJSON('m-process.php',{d:distroValue,status:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); adjustReps(); });
$('#replist').css('display','none');
$('#getfile').css('display','none');
}
};
// Выбор версии дистрибутива
function adjustReps(){
var distroValue = $('#distro').val();
var versionValue = $('#distver').val();
if (distroValue != 0 && versionValue != 0) {
$.get('m-process.php',{d:distroValue,v:versionValue,status:2},function(data){ $('#replist').css('display','block'); $('#replist').html(data); });
$.get('m-process.php',{d:distroValue,v:versionValue,status:3},function(data){ $('#getfile').css('display','block'); $('#getfile').html(data); });
}
}
$('#distro').change(adjustDistro);
$('#distver').change(adjustReps);
});
";
$query =& $db->query("SELECT * FROM distribution");
while ($query->fetchInto($data, DB_FETCHMODE_ASSOC)) {
$linux .= "<option value='".$data["dist_id"]."'>".stripslashes($data["distname"])."</option>\n";
}
$modern .= "<h2>Генератор sources.list</h2>";
$modern .= "<div class='border'>";
$modern .= "<label>Дистрибутив</label><br>";
$modern .= "<select id='distro'>\n<option value=''>Выбрать дистрибутив</option>\n";
$modern .= $linux."</select>";
$modern .= "</div><div class='border'>";
$modern .= "<label>Версия дистрибутива</label><br>";
$modern .= "<select id='distver' disabled='disabled'><option></option>";
$modern .= "</select></div>";
$modern .= "<pre id='replist'></pre>";
$modern .= "<p id='getfile'></p>";
$smarty->assign('modern',$modern);
$smarty->assign('scripts',$scripts);
$smarty->assign('antversion',$antversion);
$smarty->assign('interface'," • <a href='./classic.php'>Классический интерфейс</a>");
$smarty->display('modern.tpl');
?>