Хранилища Subversion ant

Редакция

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

Редакция 554 Редакция 701
1
<?php
1
<?php
2
2
3
/**
3
/**
4
 *  
4
 *  
5
 *  Codename: ant-ng - generator of sources.list for apt-distributives
5
 *  Codename: ant-ng - generator of sources.list for apt-distributives
6
 *  http://alex-w.org.ru/p/antng/
6
 *  http://alex-w.org.ru/p/antng/
7
 *
7
 *
8
 *  Copyright (c) 2009 Alexander Wolf
8
 *  Copyright (c) 2009 Alexander Wolf
9
 *  Dual licensed under the MIT and GNU LGPL licenses.
9
 *  Dual licensed under the MIT and GNU LGPL licenses.
10
 *  http://alex-w.org.ru/p/antng/license
10
 *  http://alex-w.org.ru/p/antng/license
11
 *
11
 *
12
 */
12
 */
13
13
14
require_once dirname(__FILE__)."/init.php";
14
require_once dirname(__FILE__)."/init.php";
15
15
16
$scripts = "
16
$scripts = "
17
<script type='text/javascript'>
17
<script type='text/javascript'>
18
(function($){
18
(function($){
19
  // очищаем select
19
  // очищаем select
20
  $.fn.clearSelect = function() {
20
  $.fn.clearSelect = function() {
21
          return this.each(function(){
21
          return this.each(function(){
22
                  if(this.tagName=='SELECT') {
22
                  if(this.tagName=='SELECT') {
23
                      this.options.length = 0;
23
                      this.options.length = 0;
24
                      $(this).attr('disabled','disabled');
24
                      $(this).attr('disabled','disabled');
25
                  }
25
                  }
26
          });
26
          });
27
  }
27
  }
28
  // заполняем select
28
  // заполняем select
29
  $.fn.fillSelect = function(dataArray) {
29
  $.fn.fillSelect = function(dataArray) {
30
          return this.clearSelect().each(function(){
30
          return this.clearSelect().each(function(){
31
                  if(this.tagName=='SELECT') {
31
                  if(this.tagName=='SELECT') {
32
                          var currentSelect = this;
32
                          var currentSelect = this;
33
                          $.each(dataArray,function(index,data){
33
                          $.each(dataArray,function(index,data){
34
                                  var option = new Option(data.text,data.value);
34
                                  var option = new Option(data.text,data.value);
35
                                  if($.support.cssFloat) {
35
                                  if($.support.cssFloat) {
36
                                          currentSelect.add(option,null);
36
                                          currentSelect.add(option,null);
37
                                  } else {
37
                                  } else {
38
                                          currentSelect.add(option);
38
                                          currentSelect.add(option);
39
                                  }
39
                                  }
40
                          });
40
                          });
41
                  }
41
                  }
42
          });
42
          });
43
  }
43
  }
44
})(jQuery);
44
})(jQuery);
45
</script>
45
</script>
46
<script type='text/javascript'>
46
<script type='text/javascript'>
47
$(document).ready(function(){
47
$(document).ready(function(){
48
  // выбор дистрибутива
48
  // выбор дистрибутива
49
  function chooseDistro(){
49
  function chooseDistro(){
50
        var distValue = $('#dist').val();
50
        var distValue = $('#dist').val();
51
        var tmpSelect = $('#version');
51
        var tmpSelect = $('#version');
52
        if(distValue.length == 0) {
52
        if(distValue.length == 0) {
53
                tmpSelect.attr('disabled','disabled');
53
                tmpSelect.attr('disabled','disabled');
54
                tmpSelect.clearSelect();
54
                tmpSelect.clearSelect();
55
                chooseVersion();
55
                chooseVersion();
56
        $('#vdist').css('visibility','hidden');
56
        $('#vdist').css('visibility','hidden');
57
                $('#replist').css('display','none');           
57
                $('#replist').css('display','none');           
58
        } else {
58
        } else {
59
                $.getJSON('./request.php',{d:distValue,step:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); chooseVersion(); });
59
                $.getJSON('./request.php',{d:distValue,step:1},function(data) { tmpSelect.fillSelect(data).attr('disabled',''); chooseVersion(); });
60
        $('#vdist').css('visibility','visible');
60
        $('#vdist').css('visibility','visible');
61
                $('#replist').css('display','none');           
61
                $('#replist').css('display','none');           
62
        }
62
        }
63
  };
63
  };
64
  // Выбор версии дистрибутива
64
  // Выбор версии дистрибутива
65
  function chooseVersion(){
65
  function chooseVersion(){
66
        var distValue = $('#dist').val();
66
        var distValue = $('#dist').val();
67
        var versionValue = $('#version').val();
67
        var versionValue = $('#version').val();
68
        if (distValue != 0 && versionValue != 0) {
68
        if (distValue != 0 && versionValue != 0) {
69
                $.get('./request.php',{d:distValue,v:versionValue,step:2},function(data){ $('#replist').css('display','block'); $('#replist').html(data); });
69
                $.get('./request.php',{d:distValue,v:versionValue,step:2},function(data){ $('#replist').css('display','block'); $('#replist').html(data); });
70
        $('#replist').css('visibility','visible');
70
        $('#replist').css('visibility','visible');
71
        } else {
71
        } else {
72
                $('#replist').css('display','none');
72
                $('#replist').css('display','none');
73
        }
73
        }
74
  }
74
  }
75

75

76
  $('#dist').change(chooseDistro);
76
  $('#dist').change(chooseDistro);
77
  $('#version').change(chooseVersion);
77
  $('#version').change(chooseVersion);
78

78

79
});
79
});
80
</script>
80
</script>
81
";
81
";
82
82
83
$body  = "<fieldset><legend>Дистрибутив</legend>\n";
83
$body  = "<fieldset><legend>Дистрибутив</legend>\n";
84
$body .= "<select id='dist'>\n<option value=''>Выберите дистрибутив</option>\n";
84
$body .= "<select id='dist'>\n<option value=''>Выберите дистрибутив</option>\n";
85
85
86
$query = "SELECT * FROM ".PREFIX."distribution ORDER BY dist_id ASC";
86
$query = "SELECT * FROM ".PREFIX."distribution ORDER BY dist_id ASC";
87
$rq =& $db->query($query);
87
$rq =& $db->query($query);
88
while ($rq->fetchInto($element)) {
88
while ($rq->fetchInto($element)) {
89
    $body .= "<option value='".$secure->checkInt($element["dist_id"])."'>".$secure->checkStr($element["distname"],1)."</option>\n";
89
    $body .= "<option value='".$secure->checkInt($element["dist_id"])."'>".$secure->checkStr($element["distname"],1)."</option>\n";
90
}
90
}
91
$body .= "</select></fieldset>";
91
$body .= "</select></fieldset>";
92
$body .= "<div id='vdist'>\n<fieldset>\n<legend>Версия дистрибутива</legend>\n";
92
$body .= "<div id='vdist'>\n<fieldset>\n<legend>Версия дистрибутива</legend>\n";
93
$body .= "<select id='version' disabled='disabled'><option></option>\n";
93
$body .= "<select id='version' disabled='disabled'><option></option>\n";
94
$body .= "</select></fieldset></div>\n";
94
$body .= "</select></fieldset></div>\n";
95
$body .= "<div id='replist'></div>\n";
95
$body .= "<div id='replist'></div>\n";
96
96
97
$tmpl->assign('scripts', $scripts);
97
$tmpl->assign('scripts', $scripts);
98
$tmpl->assign('body', $body);
98
$tmpl->assign('body', $body);
99
99
100
$tmpl->display('default.tpl');
100
$tmpl->display('default.tpl');
101
101
102
?>
102
?>
103
 
103