Редакция 396 | Редакция 398 | К новейшей редакции | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 396 | Редакция 397 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | 2 | ||
3 | /**
|
3 | /**
|
4 | *
|
4 | *
|
5 | * Codename: ant-ng - generator of sources.list for Debian and
|
5 | * Codename: ant-ng - generator of sources.list for Debian and
|
6 | * distributives, based on Debian
|
6 | * distributives, based on Debian
|
7 | * http://alex-w.org.ru/p/antng/
|
7 | * http://alex-w.org.ru/p/antng/
|
8 | *
|
8 | *
|
9 | * Copyright (c) 2009 Alexander Wolf
|
9 | * Copyright (c) 2009 Alexander Wolf
|
10 | * Dual licensed under the MIT and GNU LGPL licenses.
|
10 | * Dual licensed under the MIT and GNU LGPL licenses.
|
11 | * http://alex-w.org.ru/p/antng/license
|
11 | * http://alex-w.org.ru/p/antng/license
|
12 | *
|
12 | *
|
13 | */
|
13 | */
|
14 | 14 | ||
15 | require_once dirname(__FILE__)."/init.php"; |
15 | require_once dirname(__FILE__)."/init.php"; |
16 | 16 | ||
17 | $scripts = " |
17 | $scripts = " |
18 | <script type='text/javascript'>
|
18 | <script type='text/javascript'>
|
19 | (function($){
|
19 | (function($){
|
20 | // очищаем select
|
20 | // очищаем select
|
21 | $.fn.clearSelect = function() {
|
21 | $.fn.clearSelect = function() {
|
22 | return this.each(function(){
|
22 | return this.each(function(){
|
23 | if(this.tagName=='SELECT') {
|
23 | if(this.tagName=='SELECT') {
|
24 | this.options.length = 0;
|
24 | this.options.length = 0;
|
25 | $(this).attr('disabled','disabled');
|
25 | $(this).attr('disabled','disabled');
|
26 | }
|
26 | }
|
27 | });
|
27 | });
|
28 | }
|
28 | }
|
29 | // заполняем select
|
29 | // заполняем select
|
30 | $.fn.fillSelect = function(dataArray) {
|
30 | $.fn.fillSelect = function(dataArray) {
|
31 | return this.clearSelect.each(function(){
|
31 | return this.clearSelect.each(function(){
|
32 | if(this.tagName=='SELECT') {
|
32 | if(this.tagName=='SELECT') {
|
33 | var currentSelect = this;
|
33 | var currentSelect = this;
|
34 | $.each(dataArray,function(index,data) {
|
34 | $.each(dataArray,function(index,data) {
|
35 | var option = new Option(data.text,data.value);
|
35 | var option = new Option(data.text,data.value);
|
36 | if($.support.cssFloat) {
|
36 | if($.support.cssFloat) {
|
37 | currentSelect.add(option,null);
|
37 | currentSelect.add(option,null);
|
38 | } else {
|
38 | } else {
|
39 | currentSelect.add(option);
|
39 | currentSelect.add(option);
|
40 | }
|
40 | }
|
41 | });
|
41 | });
|
42 | }
|
42 | }
|
43 | });
|
43 | });
|
44 | }
|
44 | }
|
45 | })(jQuery);
|
45 | })(jQuery);
|
46 | </script>
|
46 | </script>
|
47 | <script type='text/javascript'>
|
47 | <script type='text/javascript'>
|
48 | $(document).ready(function(){
|
48 | $(document).ready(function(){
|
49 | // выбор дистрибутива
|
49 | // выбор дистрибутива
|
50 | function chooseDist() {
|
50 | function chooseDist() {
|
51 | var distValue = $('#dist').val();
|
51 | var distValue = $('#dist').val();
|
52 | var tmpSelect = $('#version');
|
52 | var tmpSelect = $('#version');
|
53 | if(distValue.length == 0) {
|
53 | if(distValue.length == 0) {
|
54 | tmpSelect.attr('disabled','disabled');
|
54 | tmpSelect.attr('disabled','disabled');
|
55 | tmpSelect.clearSelect();
|
55 | tmpSelect.clearSelect();
|
56 | chooseVersion();
|
56 | chooseVersion();
|
57 | } else {
|
57 | } else {
|
58 | $.getJSON('./request.php',{d:distValue,status:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); chooseVersion(); });
|
58 | $.getJSON('./request.php',{d:distValue,status:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); chooseVersion(); });
|
59 | }
|
59 | }
|
60 | };
|
60 | };
|
61 | // выбор версии дистрибутива
|
61 | // выбор версии дистрибутива
|
62 | function chooseVersion() {
|
62 | function chooseVersion() {
|
63 | var distValue = $('#dist').val();
|
63 | var distValue = $('#dist').val();
|
64 | var versValue = $('#version').val();
|
64 | var versValue = $('#version').val();
|
65 | if(distValue != 0 && versValue !=0 ) {
|
65 | if(distValue != 0 && versValue !=0 ) {
|
66 | $.get('./request.php',{d:distValue,v:versValue,status:2},function(data){ chooseReps(); });
|
66 | $.get('./request.php',{d:distValue,v:versValue,status:2},function(data){ chooseReps(); });
|
67 | }
|
67 | }
|
68 | };
|
68 | };
|
69 | });
|
69 | });
|
70 | </script>
|
70 | </script>
|
71 | "; |
71 | "; |
72 | 72 | ||
73 | $body = "<fieldset><label>Дистрибутив</label>\n"; |
73 | $body = "<fieldset><legend>Дистрибутив</legend>\n"; |
74 | $body .= "<select id='dist'>\n<option value=''>Выберите дистрибутив</option>\n"; |
74 | $body .= "<select id='dist'>\n<option value=''>Выберите дистрибутив</option>\n"; |
75 | 75 | ||
76 | $query = "SELECT * FROM ".PREFIX."distribution ORDER BY dist_id ASC"; |
76 | $query = "SELECT * FROM ".PREFIX."distribution ORDER BY dist_id ASC"; |
77 | $rq =& $db->query($query); |
77 | $rq =& $db->query($query); |
78 | while ($rq->fetchInto($element)) { |
78 | while ($rq->fetchInto($element)) { |
79 | $body .= "<option value='".$secure->checkInt($element["dist_id"])."'>".$secure->checkStr($element["distname"],1)."</option>\n"; |
79 | $body .= "<option value='".$secure->checkInt($element["dist_id"])."'>".$secure->checkStr($element["distname"],1)."</option>\n"; |
80 | }
|
80 | }
|
81 | $body .= "</select></fieldset>"; |
81 | $body .= "</select></fieldset>"; |
82 | 82 | ||
83 | $tmpl->assign('scripts', $scripts); |
83 | $tmpl->assign('scripts', $scripts); |
84 | $tmpl->assign('body', $body); |
84 | $tmpl->assign('body', $body); |
85 | 85 | ||
86 | $tmpl->display('default.tpl'); |
86 | $tmpl->display('default.tpl'); |
87 | 87 | ||
88 | ?>
|
88 | ?>
|
89 | 89 |