##// END OF EJS Templates
strip: cleaning code, plus fixing changes after switch from <i/> to <div/>
Bartłomiej Wołyńczyk -
r1605:a40f72fa default
parent child Browse files
Show More
@@ -1,165 +1,168 b''
1 1 <div class="panel panel-default">
2 2 <div class="panel-heading">
3 3 <h3 class="panel-title">${_('Strip commits from repository')}</h3>
4 4 </div>
5 5 <div class="panel-body">
6 6 %if c.repo_info.repo_type != 'svn':
7 7 <h4>${_('Please provide up to %d commits commits to strip') % c.strip_limit}</h4>
8 8 <p>
9 9 ${_('In the first step commits will be verified for existance in the repository')}. </br>
10 10 ${_('In the second step, correct commits will be available for stripping')}.
11 11 </p>
12 12 ${h.secure_form(h.route_path('strip_check', repo_name=c.repo_info.repo_name), method='post')}
13 13 <div id="change_body" class="field">
14 14 <div id="box-1" class="inputx locked_input">
15 15 <input class="text" id="changeset_id-1" name="changeset_id-1" size="59"
16 16 placeholder="${_('Enter full 40 character commit sha')}" type="text" value="">
17 17 <div id="plus_icon-1" class="btn btn-default plus_input_button" onclick="addNew(1);return false">
18 18 <i class="icon-plus">${_('Add another commit')}</i>
19 19 </div>
20 20 </div>
21 21 </div>
22 22
23 23 <div id="results" style="display:none; padding: 10px 0px;"></div>
24 24
25 25 <div class="buttons">
26 26 <button class="btn btn-small btn-primary" onclick="checkCommits();return false">
27 27 ${_('Check commits')}
28 28 </button>
29 29 </div>
30 30
31 31 ${h.end_form()}
32 32 %else:
33 33 <h4>${_('Sorry this functionality is not available for SVN repository')}</h4>
34 34 %endif
35 35 </div>
36 36 </div>
37 37
38 38
39 39 <script>
40 40 var plus_leaf = 1;
41 41
42 42 addNew = function(number){
43 43 if (number >= ${c.strip_limit}){
44 44 return;
45 45 }
46 var minus = '<i id="i_minus_icon-'+(number+1)+'" class="icon-minus">${_('Remove')}</i>';
46 var minus = '<i class="icon-minus">${_('Remove')}</i>';
47 47 $('#plus_icon-'+number).detach();
48 48 number++;
49 49
50 50 var input = '<div id="box-'+number+'" class="inputx locked_input">'+
51 '<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value="">'+
51 '<input class="text" id="changeset_id-'+number+'" name="changeset_id-'+number+'" size="59" type="text" value=""' +
52 'placeholder="${_('Enter full 40 character commit sha')}">'+
52 53 '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number+');return false">'+
53 '<i id="i_plus_icon-'+(number)+'" class="icon-plus">${_('Add another commit')}</i>'+
54 '<i class="icon-plus">${_('Add another commit')}</i>'+
54 55 '</div>'+
55 56 '<div id="minus_icon-'+number+'" class="btn btn-default minus_input_button" onclick="delOld('+(number)+');return false">'+
56 57 minus +
57 58 '</div>' +
58 59 '</div>';
59 60 $('#change_body').append(input);
60 61 plus_leaf++;
61 62 };
62 63
63 64 reIndex = function(number){
64 65 for(var i=number;i<=plus_leaf;i++){
65 66 var check = $('#box-'+i);
66 67 if (check.length == 0){
67 68 var change = $('#box-'+(i+1));
68
69 69 change.attr('id','box-'+i);
70 70 var plus = $('#plus_icon-'+(i+1));
71 var i_plus = $('#i_plus_icon-'+(i+1));
71
72 72 if (plus.length != 0){
73 73 plus.attr('id','plus_icon-'+i);
74 i_plus.attr('id','i_plus_icon-'+i);
75 i_plus.attr('onclick','addNew('+i+');return false');
74 plus.attr('onclick','addNew('+i+');return false');
76 75 plus_leaf--;
77 76 }
78 77 var minus = $('#minus_icon-'+(i+1));
79 var i_minus = $('#i_minus_icon-'+(i+1));
78
80 79 minus.attr('id','minus_icon-'+i);
81 i_minus.attr('id','i_minus_icon-'+i);
82 i_minus.attr('onclick','delOld('+i+');return false');
80
81 minus.attr('onclick','delOld('+i+');re' +
82 'turn false');
83 var input = $('input#changeset_id-'+(i+1));
84 input.attr('name','changeset_id-'+i);
85 input.attr('id','changeset_id-'+i);
83 86 }
84 87 }
85 88 };
86 89
87 90 delOld = function(number){
88 91 $('#box-'+number).remove();
89 92 number = number - 1;
90 93 var box = $('#box-'+number);
91 94 var plus = '<div id="plus_icon-'+number+'" class="btn btn-default plus_input_button" onclick="addNew('+number +');return false">'+
92 95 '<i id="i_plus_icon-'+number+'" class="icon-plus">${_('Add another commit')}</i></div>';
93 96 var minus = $('#minus_icon-'+number);
94 97 if(number +1 == plus_leaf){
95 98 minus.detach();
96 99 box.append(plus);
97 100 box.append(minus);
98 101 plus_leaf --;
99 102 }
100 103 reIndex(number+1);
101 104
102 105 };
103 106
104 107 var result_data;
105 108
106 109 checkCommits = function() {
107 110 var postData = $('form').serialize();
108 111 $('#results').show();
109 112 $('#results').html('<h4>${_('Checking commits')}...</h4>');
110 113 var url = "${h.route_path('strip_check', repo_name=c.repo_info.repo_name)}";
111 114 var btn = $('button');
112 115 btn.attr('disabled', 'disabled');
113 116 btn.addClass('disabled');
114 117
115 118 var success = function (data) {
116 119 result_data = {};
117 120 var i = 0;
118 121 result ='';
119 122 $.each(data, function(index, value){
120 123 i= index;
121 124 var box = $('#box-'+index);
122 125 if (value.rev){
123 126 result_data[index] = JSON.stringify(value);
124 127 msg = '${_("author")}: ' + value.author + ' ${_("comment")}: ' + value.comment;
125 128 result += '<h4><code>' +value.rev+ '</code>${_(' commit verified positive')}</br> '+ msg + '</h4>';
126 129 }
127 130 else{
128 131 result += '<h4><code>' +value.commit+ '</code>${_(' commit verified negative')}' + '</h4>';
129 132 }
130 133 box.remove();
131 134 });
132 135 var box = $('#box-'+(parseInt(i)+1));
133 136 box.remove();
134 137 $('#results').html(result);
135 138 };
136 139
137 140 btn.html('Strip');
138 141 btn.removeAttr('disabled');
139 142 btn.removeClass('disabled');
140 143 btn.attr('onclick','strip();return false;');
141 144 ajaxPOST(url, postData, success, null);
142 145 };
143 146
144 147 strip = function(){
145 148 var url = "${h.route_path('strip_execute', repo_name=c.repo_info.repo_name)}";
146 149 var success = function(data){
147 150 result = '';
148 151 $.each(data, function(index, value){
149 152 if(data[index]){
150 153 result += '<h4>' +index+ '${_(' commit striped successful')}' + '</h4>';
151 154 }
152 155 else{
153 156 result += '<h4>' +index+ '${_(' commit striped failed')}' + '</h4>';
154 157 }
155 158 });
156 159 $('#results').html(result);
157 160
158 161 };
159 162 ajaxPOST(url, result_data, success, null);
160 163 var btn = $('button');
161 164 btn.attr('disabled', 'disabled');
162 165 btn.addClass('disabled');
163 166
164 167 };
165 168 </script>
General Comments 0
You need to be logged in to leave comments. Login now