Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[NEXUS-5360] Cleanup JS

  • Loading branch information...
commit 9d6a3a5feddac27443aa9a12753733f20fd7eb15 1 parent 7dd152c
Benjamin Hanzelmann nabcos authored cstamas committed
2  nexus/nexus-webapp/src/main/webapp/js/nexus/ext/formpanel.js
@@ -341,5 +341,7 @@ Ext.extend(Nexus.ext.FormPanel, Ext.FormPanel, {
341 341
342 342 Sonatype.ext.FormPanel = Nexus.ext.FormPanel;
343 343
  344 +return Nexus.ext.FormPanel;
  345 +
344 346 });
345 347
12 nexus/nexus-webapp/src/main/webapp/js/repoServer/ConfigViewPanel.js
@@ -10,15 +10,15 @@
10 10 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
11 11 * Eclipse Foundation. All other trademarks are the property of their respective owners.
12 12 */
  13 +
  14 +/*global define*/
  15 +
13 16 /*
14 17 * View Nexus serer XML configuration file
15 18 */
16   -
17   -define('repoServer/ConfigViewPanel',['sonatype/all'], function(){
18   -Sonatype.repoServer.ConfigViewPanel = function(config) {
19   - var config = config || {};
20   - var defaultConfig = {};
21   - Ext.apply(this, config, defaultConfig);
  19 +define('repoServer/ConfigViewPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
  20 +Sonatype.repoServer.ConfigViewPanel = function(cfg) {
  21 + Ext.apply(this, cfg || {});
22 22
23 23 this.listeners = {
24 24 // note: this isn't pre-render dependent, we just need an early event to
51 nexus/nexus-webapp/src/main/webapp/js/repoServer/GroupsEditPanel.js
@@ -10,14 +10,15 @@
10 10 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
11 11 * Eclipse Foundation. All other trademarks are the property of their respective owners.
12 12 */
  13 +/*global define*/
13 14 /*
14 15 * Repository Groups Edit/Create panel layout and controller
15 16 */
16   -
17   -define('repoServer/GroupsEditPanel',['sonatype/all', 'nexus/ext/formpanel'], function(){
  17 +define('repoServer/GroupsEditPanel', ['extjs', 'sonatype/all', 'nexus/ext/formpanel'], function(Ext, Sonatype, FormPanel){
18 18 Sonatype.repoServer.RepositoryGroupEditor = function(config) {
19   - var config = config || {};
20   - var defaultConfig = {
  19 + var
  20 + ht = Sonatype.repoServer.resources.help.groups,
  21 + defaultConfig = {
21 22 dataModifiers : {
22 23 load : {
23 24 repositories : this.loadRepositories.createDelegate(this),
@@ -34,9 +35,7 @@ Sonatype.repoServer.RepositoryGroupEditor = function(config) {
34 35 referenceData : Sonatype.repoServer.referenceData.group,
35 36 uri : Sonatype.config.repos.urls.groups
36 37 };
37   - Ext.apply(this, config, defaultConfig);
38   -
39   - var ht = Sonatype.repoServer.resources.help.groups;
  38 + Ext.apply(this, config || {}, defaultConfig);
40 39
41 40 this.tfStore = new Ext.data.SimpleStore({
42 41 fields : ['value'],
@@ -181,7 +180,7 @@ Sonatype.repoServer.RepositoryGroupEditor = function(config) {
181 180 });
182 181 };
183 182
184   -Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
  183 +Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, FormPanel, {
185 184
186 185 isValid : function() {
187 186 if (!this.form.isValid())
@@ -197,18 +196,17 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
197 196 },
198 197
199 198 loadRepositories : function(arr, srcObject, fpanel) {
200   - var repoBox = fpanel.find('name', 'repositories')[0];
  199 + var i, repoBox = fpanel.find('name', 'repositories')[0];
201 200 this.repoStore.filterBy(function(rec, id) {
202   - var contentClass = this.contentClassStore.getById( rec.data.format );
  201 + var compatibleClasses, contentClass = this.contentClassStore.getById( rec.data.format );
203 202
204 203 // if we have the content class
205 204 // and the content class is compatible with the repo type
206   - if ( contentClass
207   - && rec.data.id != srcObject.id ) {
208   - var compatibleClasses = contentClass.get( 'compatibleTypes' );
  205 + if ( contentClass && rec.data.id !== srcObject.id ) {
  206 + compatibleClasses = contentClass.get( 'compatibleTypes' );
209 207
210   - for ( var i = 0 ; i < compatibleClasses.length ; i++ ) {
211   - if ( compatibleClasses[i] == srcObject.format ) {
  208 + for ( i = 0 ; i < compatibleClasses.length ; i+=1 ) {
  209 + if ( compatibleClasses[i] === srcObject.format ) {
212 210 return true;
213 211 }
214 212 }
@@ -225,11 +223,12 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
225 223 },
226 224
227 225 saveRepositories : function(value, fpanel) {
228   - var repoBox = fpanel.find('name', 'repositories')[0];
229   - var repoIds = repoBox.getValue();
  226 + var
  227 + i, response = [],
  228 + repoBox = fpanel.find('name', 'repositories')[0],
  229 + repoIds = repoBox.getValue();
230 230
231   - var response = [];
232   - for (var i = 0; i < repoIds.length; i++)
  231 + for (i = 0; i < repoIds.length; i+=1)
233 232 {
234 233 response.push({
235 234 id : repoIds[i]
@@ -263,11 +262,11 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
263 262
264 263 // @override
265 264 addSorted : function(store, rec) {
266   - var insertIndex;
267   - for (var i = 0; i < store.getCount(); i++)
  265 + var i, insertIndex, tempRec;
  266 + for (i = 0; i < store.getCount(); i+=1)
268 267 {
269   - var tempRec = store.getAt(i);
270   - if (tempRec.get('repoType') != 'group')
  268 + tempRec = store.getAt(i);
  269 + if (tempRec.get('repoType') !== 'group')
271 270 {
272 271 insertIndex = i;
273 272 break;
@@ -288,12 +287,12 @@ Ext.extend(Sonatype.repoServer.RepositoryGroupEditor, Sonatype.ext.FormPanel, {
288 287 });
289 288
290 289 Sonatype.Events.addListener('repositoryViewInit', function(cardPanel, rec) {
291   - var sp = Sonatype.lib.Permissions;
  290 + var sp = Sonatype.lib.Permissions, editor;
292 291
293   - if (rec.data.repoType == 'group' && rec.data.userManaged && sp.checkPermission('nexus:repogroups', sp.READ) && (sp.checkPermission('nexus:repogroups', sp.CREATE) || sp.checkPermission('nexus:repogroups', sp.EDIT)))
  292 + if (rec.data.repoType === 'group' && rec.data.userManaged && sp.checkPermission('nexus:repogroups', sp.READ) && (sp.checkPermission('nexus:repogroups', sp.CREATE) || sp.checkPermission('nexus:repogroups', sp.EDIT)))
294 293 {
295 294
296   - var editor = new Sonatype.repoServer.RepositoryGroupEditor({
  295 + editor = new Sonatype.repoServer.RepositoryGroupEditor({
297 296 tabTitle : 'Configuration',
298 297 name : 'configuration',
299 298 payload : rec
4 nexus/nexus-webapp/src/main/webapp/js/repoServer/LogEditPanel.js
@@ -10,9 +10,9 @@
10 10 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
11 11 * Eclipse Foundation. All other trademarks are the property of their respective owners.
12 12 */
  13 +/*global define*/
13 14
14   -define('repoServer/LogEditPanel',['sonatype/all'], function(){
15   -/*global Ext, Sonatype*/
  15 +define('repoServer/LogEditPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
16 16 Sonatype.repoServer.LogEditPanel = function(cfg) {
17 17 var
18 18 config = cfg || {},
156 nexus/nexus-webapp/src/main/webapp/js/repoServer/LogsViewPanel.js
@@ -10,13 +10,11 @@
10 10 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
11 11 * Eclipse Foundation. All other trademarks are the property of their respective owners.
12 12 */
  13 +/*global define*/
13 14
14   -define('repoServer/LogsViewPanel',['sonatype/all'], function(){
15   -/*global Ext,Sonatype,Nexus*/
  15 +define('repoServer/LogsViewPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
16 16 Sonatype.repoServer.LogsViewPanel = function(cfg) {
17   - var config = cfg || {}, defaultConfig = {};
18   -
19   - Ext.apply(this, config, defaultConfig);
  17 + Ext.apply(this, cfg || {});
20 18
21 19 this.currentLogUrl = null;
22 20 this.currentContentType = null;
@@ -219,30 +217,37 @@ Sonatype.repoServer.LogsViewPanel = function(cfg) {
219 217
220 218 Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
221 219 renderLogList : function(options, success, response) {
222   - if (success)
  220 + if (!success)
  221 + {
  222 + Sonatype.MessageBox.alert('Failed to get file list from server.');
  223 + }
  224 + else
223 225 {
224   - var resp = Ext.decode(response.responseText);
225   - var myMenu = Ext.menu.MenuMgr.get('log-menu');
  226 + var
  227 + i, name, size, text, uri, existingItem,
  228 + resp = Ext.decode(response.responseText),
  229 + myMenu = Ext.menu.MenuMgr.get('log-menu'),
  230 + list = resp.data,
  231 + sameUri = function(o) {
  232 + return o.logUri === uri;
  233 + };
226 234
227   - var list = resp.data;
228 235 this.sortFileListByName(list);
229 236
230   - for (var i = 0; i < list.length; i++)
  237 + for (i = 0; i < list.length; i+=1)
231 238 {
232   - var name = list[i].name;
233   - var size = list[i].size;
234   - var text = name + ' (' + this.printKb(size) + ')';
235   - var uri = list[i].resourceURI;
  239 + name = list[i].name;
  240 + size = list[i].size;
  241 + text = name + ' (' + this.printKb(size) + ')';
  242 + uri = list[i].resourceURI;
236 243
237   - var existingItem = myMenu.items.find(function(o) {
238   - return o.logUri == uri;
239   - });
  244 + existingItem = myMenu.items.find(sameUri);
240 245
241 246 if (existingItem)
242 247 {
243 248 existingItem.setText(text);
244 249 existingItem.value = size;
245   - if (this.currentLogUrl == uri)
  250 + if (this.currentLogUrl === uri)
246 251 {
247 252 this.totalSize = size;
248 253 this.getTopToolbar().items.get(2).setText(text);
@@ -279,59 +284,60 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
279 284 this.logToShowWhenLoaded = null;
280 285 }
281 286 }
282   - else
283   - {
284   - Sonatype.MessageBox.alert('Failed to get file list from server.');
285   - }
286 287 },
287 288
288 289 renderConfigList : function(options, success, response) {
289   - if (success)
  290 + if (!success)
  291 + {
  292 + Sonatype.MessageBox.alert('Failed to get config file list from server.');
  293 + }
  294 + else
290 295 {
291   - var resp = Ext.decode(response.responseText);
292   - var myMenu = Ext.menu.MenuMgr.get('log-menu');
  296 + var
  297 + i, name, uri, existingItem,
  298 + resp = Ext.decode(response.responseText),
  299 + myMenu = Ext.menu.MenuMgr.get('log-menu'),
  300 + list = resp.data,
  301 + sameUri = function(o) {
  302 + return o.logUri === uri;
  303 + };
  304 +
293 305
294   - if (resp.data.length > 0)
  306 + this.sortFileListByName(list);
  307 +
  308 + if (list.length > 0)
295 309 {
296 310 myMenu.add('-');
297 311 }
298 312
299   - var list = resp.data;
300   - this.sortFileListByName(list);
301   -
302   - for (var i = 0; i < list.length; i++)
  313 + for (i = 0; i < list.length; i+=1)
303 314 {
304   - var name = list[i].name;
305   - var uri = list[i].resourceURI;
  315 + name = list[i].name;
  316 + uri = list[i].resourceURI;
306 317
307   - var existingItem = myMenu.items.find(function(o) {
308   - return o.logUri === uri;
309   - });
  318 + existingItem = myMenu.items.find(sameUri);
310 319
311 320 if (!existingItem)
312 321 {
313 322 myMenu.addMenuItem({
314   - id : name,
315   - logUri : uri,
316   - text : name,
317   - value : 0,
318   - checked : false,
319   - group : 'rp-group',
320   - checkHandler : this.showItem.createDelegate(this, [name, 'application/xml'], 0),
321   - scope : this
322   - });
  323 + id : name,
  324 + logUri : uri,
  325 + text : name,
  326 + value : 0,
  327 + checked : false,
  328 + group : 'rp-group',
  329 + checkHandler : this.showItem.createDelegate(this, [name, 'application/xml'], 0),
  330 + scope : this
  331 + });
323 332 }
324 333 }
325 334 }
326   - else
327   - {
328   - Sonatype.MessageBox.alert('Failed to get config file list from server.');
329   - }
330 335 },
331 336
332 337 showItem : function(shortLogName, contentType, mItem, pressed) {
333   - if (!pressed)
  338 + if (!pressed) {
334 339 return;
  340 + }
335 341 this.logTextArea.setRawValue('');
336 342 this.currentSize = 0;
337 343 this.currentOffset = 0;
@@ -356,11 +362,11 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
356 362 // check to make sure the menubar is rendered
357 363 if (this.logListLoaded)
358 364 {
359   - var logsAndConfMenu = Ext.menu.MenuMgr.get('log-menu');
360   - for (var ii = 0; ii < logsAndConfMenu.items.length; ii++)
  365 + var ii, logsAndConfMenu = Ext.menu.MenuMgr.get('log-menu'), tmpMenuItem;
  366 + for (ii = 0; ii < logsAndConfMenu.items.length; ii+=1)
361 367 {
362   - var tmpMenuItem = logsAndConfMenu.items.itemAt(ii);
363   - if (tmpMenuItem != null && tmpMenuItem.id == logName)
  368 + tmpMenuItem = logsAndConfMenu.items.itemAt(ii);
  369 + if (tmpMenuItem && tmpMenuItem.id === logName)
364 370 {
365 371 this.showItem(tmpMenuItem.logUri, 'text/plain', tmpMenuItem, true);
366 372 break;
@@ -399,9 +405,9 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
399 405 {
400 406 toFetch = Number(this.fetchMoreButton.value) * 1024;
401 407 }
402   - if (toFetch == 0)
  408 + if (toFetch === 0)
403 409 {
404   - if (this.tailed && this.currentOffset == 0 && this.totalSize > 102400)
  410 + if (this.tailed && this.currentOffset === 0 && this.totalSize > 102400)
405 411 { // 100Kb
406 412 this.currentOffset = this.totalSize - 102400;
407 413 }
@@ -416,7 +422,7 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
416 422 count : toFetch
417 423 },
418 424 headers : {
419   - 'accept' : this.currentContentType ? this.currentContentType : 'text/plain'
  425 + 'accept' : this.currentContentType || 'text/plain'
420 426 },
421 427 url : this.currentLogUrl
422 428 });
@@ -426,15 +432,15 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
426 432 renderLog : function(options, success, response) {
427 433 if (success)
428 434 {
429   - var text = response.responseText;
430   - var newValue = this.currentSize == 0 ? text : this.logTextArea.getRawValue() + text;
431   -
432   - var logDom = this.logTextArea.getEl().dom;
433   - var scrollTop = logDom.scrollTop;
434   - var scrollHeight = logDom.scrollHeight;
435   - var clientHeight = logDom.clientHeight;
  435 + var
  436 + text = response.responseText,
  437 + newValue = this.currentSize === 0 ? text : this.logTextArea.getRawValue() + text,
  438 + logDom = this.logTextArea.getEl().dom,
  439 + scrollTop = logDom.scrollTop,
  440 + scrollHeight = logDom.scrollHeight,
  441 + clientHeight = logDom.clientHeight;
436 442 this.logTextArea.setRawValue(newValue);
437   - if (this.tailEnabled && (scrollTop == 0 || scrollTop + clientHeight >= scrollHeight - 20))
  443 + if (this.tailEnabled && (scrollTop === 0 || scrollTop + clientHeight >= scrollHeight - 20))
438 444 {
439 445 scrollTop = logDom.scrollHeight - clientHeight;
440 446 }
@@ -447,12 +453,12 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
447 453 }
448 454 else
449 455 {
450   - Sonatype.utils.connectionError(response, 'The file failed to load from the server.')
  456 + Sonatype.utils.connectionError(response, 'The file failed to load from the server.');
451 457 }
452 458 },
453 459
454 460 fetchMore : function(button, event) {
455   - if (button.value != this.fetchMoreButton.value)
  461 + if (button.value !== this.fetchMoreButton.value)
456 462 {
457 463 this.fetchMoreButton.value = button.value;
458 464 this.fetchMoreButton.setText(button.text);
@@ -470,7 +476,7 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
470 476 this.fetchMoreBar.items.removeAt(0);
471 477 this.fetchMoreBar.insertButton(0, new Ext.Toolbar.TextItem('Displaying ' + (this.tailed ? 'last ' : '') + this.printKb(this.currentSize) + ' of ' + this.printKb(this.totalSize)));
472 478
473   - this.tailUpdateButton.setDisabled(this.currentLogUrl == Sonatype.config.repos.urls.configCurrent);
  479 + this.tailUpdateButton.setDisabled(this.currentLogUrl === Sonatype.config.repos.urls.configCurrent);
474 480 this.fetchMoreButton.setDisabled(this.currentOffset >= this.totalSize);
475 481 },
476 482
@@ -509,13 +515,13 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
509 515 },
510 516
511 517 loadTailButtonHandler : function(button, event) {
512   - if (button.value != this.tailUpdateButton.value)
  518 + if (button.value !== this.tailUpdateButton.value)
513 519 {
514 520 this.tailUpdateButton.value = button.value;
515 521 this.tailUpdateButton.setText(button.text);
516 522 this.fixUpdateTask();
517 523 }
518   - else if (button.value == 0)
  524 + else if (button.value === 0)
519 525 {
520 526 this.loadTail();
521 527 }
@@ -560,19 +566,21 @@ Ext.extend(Sonatype.repoServer.LogsViewPanel, Ext.form.FormPanel, {
560 566
561 567 sortFileListByName : function(list) {
562 568 list.sort(function(a, b) {
563   - var valueA = a.name.toLowerCase();
564   - var valueB = b.name.toLowerCase();
  569 + var
  570 + valueA = a.name.toLowerCase(),
  571 + valueB = b.name.toLowerCase();
  572 +
565 573 if (valueA < valueB)
566 574 {
567 575 return -1;
568 576 }
569   - else if (valueA == valueB)
  577 + else if (valueA > valueB)
570 578 {
571   - return 0;
  579 + return 1;
572 580 }
573 581 else
574 582 {
575   - return 1;
  583 + return 0;
576 584 }
577 585 });
578 586 }
98 nexus/nexus-webapp/src/main/webapp/js/repoServer/Maven2InformationPanel.js
@@ -10,13 +10,12 @@
10 10 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
11 11 * Eclipse Foundation. All other trademarks are the property of their respective owners.
12 12 */
13   -define('repoServer/Maven2InformationPanel',['sonatype/all'], function(){
  13 +/*global define*/
  14 +define('repoServer/Maven2InformationPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
14 15 Sonatype.repoServer.Maven2InformationPanel = function(config) {
15   - var config = config || {};
16   - var defaultConfig = {
  16 + Ext.apply(this, config || {}, {
17 17 halfSize : false
18   - };
19   - Ext.apply(this, config, defaultConfig);
  18 + });
20 19
21 20 this.sp = Sonatype.lib.Permissions;
22 21
@@ -81,7 +80,44 @@ Ext.extend(Sonatype.repoServer.Maven2InformationPanel, Ext.form.FormPanel, {
81 80
82 81 showArtifact : function(data, artifactContainer) {
83 82 this.data = data;
84   - if (data == null)
  83 + if (data) {
  84 + Ext.Ajax.request({
  85 + url : this.data.resourceURI + '?describe=maven2&isLocal=true',
  86 + callback : function(options, isSuccess, response) {
  87 + if (isSuccess)
  88 + {
  89 + var infoResp = Ext.decode(response.responseText);
  90 +
  91 + // hide classifier if empty
  92 + if (this.data.classifier)
  93 + {
  94 + this.find('name', 'classifier')[0].show();
  95 + }
  96 + else
  97 + {
  98 + this.find('name', 'classifier')[0].hide();
  99 + }
  100 + this.form.setValues(infoResp.data);
  101 + artifactContainer.showTab(this);
  102 + }
  103 + else
  104 + {
  105 + if (response.status === 404)
  106 + {
  107 + artifactContainer.hideTab(this);
  108 + }
  109 + else
  110 + {
  111 + Sonatype.utils.connectionError(response, 'Unable to retrieve Maven information.');
  112 + }
  113 + }
  114 + },
  115 + scope : this,
  116 + method : 'GET',
  117 + suppressStatus : '404'
  118 + });
  119 + }
  120 + else
85 121 {
86 122 this.find('name', 'groupId')[0].setRawValue(null);
87 123 this.find('name', 'artifactId')[0].setRawValue(null);
@@ -90,44 +126,6 @@ Ext.extend(Sonatype.repoServer.Maven2InformationPanel, Ext.form.FormPanel, {
90 126 this.find('name', 'extension')[0].setRawValue(null);
91 127 this.find('name', 'dependencyXmlChunk')[0].setRawValue(null);
92 128 }
93   - else
94   - {
95   - Ext.Ajax.request({
96   - url : this.data.resourceURI + '?describe=maven2&isLocal=true',
97   - callback : function(options, isSuccess, response) {
98   - if (isSuccess)
99   - {
100   - var infoResp = Ext.decode(response.responseText);
101   -
102   - // hide classifier if empty
103   - if (this.data.classifier)
104   - {
105   - this.find('name', 'classifier')[0].show();
106   - }
107   - else
108   - {
109   - this.find('name', 'classifier')[0].hide();
110   - }
111   - this.form.setValues(infoResp.data);
112   - artifactContainer.showTab(this);
113   - }
114   - else
115   - {
116   - if (response.status = 404)
117   - {
118   - artifactContainer.hideTab(this);
119   - }
120   - else
121   - {
122   - Sonatype.utils.connectionError(response, 'Unable to retrieve Maven information.');
123   - }
124   - }
125   - },
126   - scope : this,
127   - method : 'GET',
128   - suppressStatus : '404'
129   - });
130   - }
131 129 }
132 130 });
133 131
@@ -142,13 +140,13 @@ Sonatype.Events.addListener('fileContainerInit', function(items) {
142 140 Sonatype.Events.addListener('fileContainerUpdate', function(artifactContainer, data) {
143 141 var panel = artifactContainer.find('name', 'maven2InformationPanel')[0];
144 142
145   - if (data == null || !data.leaf)
  143 + if ( data && data.leaf)
146 144 {
147   - panel.showArtifact(null, artifactContainer);
  145 + panel.showArtifact(data, artifactContainer);
148 146 }
149 147 else
150 148 {
151   - panel.showArtifact(data, artifactContainer);
  149 + panel.showArtifact(null, artifactContainer);
152 150 }
153 151 });
154 152
@@ -163,13 +161,13 @@ Sonatype.Events.addListener('artifactContainerInit', function(items) {
163 161 Sonatype.Events.addListener('artifactContainerUpdate', function(artifactContainer, payload) {
164 162 var panel = artifactContainer.find('name', 'maven2InformationPanel')[0];
165 163
166   - if (payload == null || !payload.leaf)
  164 + if (payload && payload.leaf)
167 165 {
168   - panel.showArtifact(null, artifactContainer);
  166 + panel.showArtifact(payload, artifactContainer);
169 167 }
170 168 else
171 169 {
172   - panel.showArtifact(payload, artifactContainer);
  170 + panel.showArtifact(null, artifactContainer);
173 171 }
174 172
175 173 });
127 nexus/nexus-webapp/src/main/webapp/js/repoServer/MirrorConfigPanel.js
@@ -10,12 +10,11 @@
10 10 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
11 11 * Eclipse Foundation. All other trademarks are the property of their respective owners.
12 12 */
13   -define('repoServer/MirrorConfigPanel',['sonatype/all'], function(){
  13 +/*global define*/
  14 +define('repoServer/MirrorConfigPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
14 15 var MIRROR_URL_REGEXP = /^(?:http|https):\/\//i;
15 16
16 17 Sonatype.repoServer.AbstractMirrorPanel = function(config) {
17   - var config = config || {};
18   -
19 18 this.mirrorStatusTask = {
20 19 run : function() {
21 20 Ext.Ajax.request({
@@ -82,44 +81,42 @@ Sonatype.repoServer.AbstractMirrorPanel = function(config) {
82 81 }
83 82 };
84 83
85   - Ext.apply(this, config, defaultConfig);
  84 + Ext.apply(this, config || {}, defaultConfig);
86 85
87 86 Sonatype.repoServer.AbstractMirrorPanel.superclass.constructor.call(this, {});
88 87 };
89 88
90 89 Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
91 90 addNewMirrorUrl : function() {
92   - var treePanel = this.find('name', 'mirror-url-list')[0];
93   - var urlField = this.find('name', 'mirrorUrl')[0];
94   - if (urlField.isValid())
  91 + var
  92 + i,
  93 + treePanel = this.find('name', 'mirror-url-list')[0],
  94 + nodes = treePanel.root.childNodes,
  95 + urlField = this.find('name', 'mirrorUrl')[0],
  96 + url = urlField.getRawValue();
  97 +
  98 + if (urlField.isValid() && url)
95 99 {
96   - var url = urlField.getRawValue();
97   -
98   - if (url)
  100 + for (i = 0; i < nodes.length; i+=1)
99 101 {
100   - var nodes = treePanel.root.childNodes;
101   - for (var i = 0; i < nodes.length; i++)
  102 + if (url === nodes[i].attributes.payload.url)
102 103 {
103   - if (url == nodes[i].attributes.payload.url)
104   - {
105   - urlField.markInvalid('This URL already exists');
106   - return;
107   - }
  104 + urlField.markInvalid('This URL already exists');
  105 + return;
108 106 }
  107 + }
109 108
110   - urlField.clearInvalid();
  109 + urlField.clearInvalid();
111 110
112   - this.addUrlNode(treePanel, url, url, Sonatype.config.extPath + '/resources/images/default/tree/leaf.gif');
113   - urlField.setRawValue('');
114   - urlField.setValue('');
115   - }
  111 + this.addUrlNode(treePanel, url, url, Sonatype.config.extPath + '/resources/images/default/tree/leaf.gif');
  112 + urlField.setRawValue('');
  113 + urlField.setValue('');
116 114 }
117 115 },
118 116
119 117 addUrlNode : function(treePanel, url, id, icon) {
120   - var validId;
121   - var manualUrl;
122   - if (url == id)
  118 + var validId, manualUrl;
  119 + if (url === id)
123 120 {
124 121 validId = Ext.id();
125 122 manualUrl = true;
@@ -146,9 +143,10 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
146 143 },
147 144
148 145 removeMirrorUrl : function() {
149   - var treePanel = this.find('name', 'mirror-url-list')[0];
  146 + var
  147 + treePanel = this.find('name', 'mirror-url-list')[0],
  148 + selectedNode = treePanel.getSelectionModel().getSelectedNode();
150 149
151   - var selectedNode = treePanel.getSelectionModel().getSelectedNode();
152 150 if (selectedNode)
153 151 {
154 152 treePanel.root.removeChild(selectedNode);
@@ -156,8 +154,9 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
156 154 },
157 155
158 156 removeAllMirrorUrls : function() {
159   - var treePanel = this.find('name', 'mirror-url-list')[0];
160   - var treeRoot = treePanel.root;
  157 + var
  158 + treePanel = this.find('name', 'mirror-url-list')[0],
  159 + treeRoot = treePanel.root;
161 160
162 161 while (treeRoot.lastChild)
163 162 {
@@ -166,20 +165,20 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
166 165 },
167 166
168 167 loadMirrors : function(arr, srcObj, fpanel) {
169   - var treePanel = this.find('name', 'mirror-url-list')[0];
170   -
171   - var mirrorArray = new Array();
  168 + var
  169 + i, j, childNodes, found,
  170 + treePanel = this.find('name', 'mirror-url-list')[0],
  171 + mirrorArray = [];
172 172
173   - for (var i = 0; i < arr.length; i++)
  173 + for (i = 0; i < arr.length; i+=1)
174 174 {
175   - var treePanel = this.find('name', 'mirror-url-list')[0];
176   - var childNodes = treePanel.getRootNode().childNodes;
177   - var found = false;
  175 + childNodes = treePanel.getRootNode().childNodes;
  176 + found = false;
178 177 if (childNodes && childNodes.length)
179 178 {
180   - for (var j = 0; j < childNodes.length; j++)
  179 + for (j = 0; j < childNodes.length; j+=1)
181 180 {
182   - if (arr[i].id == childNodes[j].id)
  181 + if (arr[i].id === childNodes[j].id)
183 182 {
184 183 mirrorArray[i] = {
185 184 id : arr[i].id,
@@ -203,7 +202,7 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
203 202
204 203 this.removeAllMirrorUrls();
205 204
206   - for (var i = 0; i < arr.length; i++)
  205 + for (i = 0; i < arr.length; i+=1)
207 206 {
208 207 this.addUrlNode(treePanel, mirrorArray[i].url, mirrorArray[i].id, mirrorArray[i].icon);
209 208 }
@@ -212,12 +211,13 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
212 211 },
213 212
214 213 saveMirrors : function(val, fpanel) {
215   - var treePanel = this.find('name', 'mirror-url-list')[0];
  214 + var
  215 + i,
  216 + treePanel = this.find('name', 'mirror-url-list')[0],
  217 + outputArr = [],
  218 + nodes = treePanel.root.childNodes;
216 219
217   - var outputArr = [];
218   - var nodes = treePanel.root.childNodes;
219   -
220   - for (var i = 0; i < nodes.length; i++)
  220 + for (i = 0; i < nodes.length; i+=1)
221 221 {
222 222 outputArr[i] = nodes[i].attributes.payload;
223 223 }
@@ -236,24 +236,27 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
236 236 statusCallback : function(options, success, response) {
237 237 if (success)
238 238 {
239   - var statusResp = Ext.decode(response.responseText);
  239 + var
  240 + i, j, data, item,
  241 + statusResp = Ext.decode(response.responseText),
  242 + treePanel = this.find('name', 'mirror-url-list')[0],
  243 + childNodes = treePanel.getRootNode().childNodes;
  244 +
240 245 if (statusResp.data)
241 246 {
242   - var data = statusResp.data;
  247 + data = statusResp.data;
243 248 if (data && data.length)
244 249 {
245   - for (var i = 0; i < data.length; i++)
  250 + for (i = 0; i < data.length; i+=1)
246 251 {
247   - var item = data[i];
248   - var treePanel = this.find('name', 'mirror-url-list')[0];
249   - var childNodes = treePanel.getRootNode().childNodes;
  252 + item = data[i];
250 253 if (childNodes && childNodes.length)
251 254 {
252   - for (var j = 0; j < childNodes.length; j++)
  255 + for (j = 0; j < childNodes.length; j+=1)
253 256 {
254   - if (item.id == childNodes[j].id)
  257 + if (item.id === childNodes[j].id)
255 258 {
256   - childNodes[j].getUI().getIconEl().src = item.status == 'Blacklisted' ? (Sonatype.config.extPath + '/resources/images/default/tree/drop-no.gif') : (Sonatype.config.extPath + '/resources/images/default/tree/drop-yes.gif');
  259 + childNodes[j].getUI().getIconEl().src = item.status === 'Blacklisted' ? (Sonatype.config.extPath + '/resources/images/default/tree/drop-no.gif') : (Sonatype.config.extPath + '/resources/images/default/tree/drop-yes.gif');
257 260 break;
258 261 }
259 262 }
@@ -280,21 +283,21 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
280 283 this.predefinedMirrorDataStore.load();
281 284 }
282 285
283   - if (panel.payload.data.repoType == 'proxy')
  286 + if (panel.payload.data.repoType === 'proxy')
284 287 {
285 288 Ext.TaskMgr.start(this.mirrorStatusTask);
286 289 }
287 290 },
288 291
289 292 deactivateHandler : function(panel) {
290   - if (panel.payload.data.repoType == 'proxy')
  293 + if (panel.payload.data.repoType === 'proxy')
291 294 {
292 295 Ext.TaskMgr.stop(this.mirrorStatusTask);
293 296 }
294 297 },
295 298
296 299 destroyHandler : function(component) {
297   - if (component.payload.data.repoType == 'proxy')
  300 + if (component.payload.data.repoType === 'proxy')
298 301 {
299 302 Ext.TaskMgr.stop(this.mirrorStatusTask);
300 303 }
@@ -302,8 +305,7 @@ Ext.extend(Sonatype.repoServer.AbstractMirrorPanel, Sonatype.ext.FormPanel, {
302 305 });
303 306
304 307 Sonatype.repoServer.ProxyMirrorEditor = function(config) {
305   - var config = config || {};
306   - Ext.apply(this, config, {});
  308 + Ext.apply(this, config || {}, {});
307 309 var ht = Sonatype.repoServer.resources.help.repoMirrors;
308 310
309 311 this.mirrorRecordConstructor = Ext.data.Record.create([{
@@ -432,8 +434,7 @@ Sonatype.repoServer.ProxyMirrorEditor = function(config) {
432 434 Ext.extend(Sonatype.repoServer.ProxyMirrorEditor, Sonatype.repoServer.AbstractMirrorPanel, {});
433 435
434 436 Sonatype.repoServer.HostedMirrorEditor = function(config) {
435   - var config = config || {};
436   - Ext.apply(this, config, {});
  437 + Ext.apply(this, config || {});
437 438 var ht = Sonatype.repoServer.resources.help.repoMirrors;
438 439
439 440 Sonatype.repoServer.HostedMirrorEditor.superclass.constructor.call(this, {
@@ -532,9 +533,9 @@ Ext.extend(Sonatype.repoServer.HostedMirrorEditor, Sonatype.repoServer.AbstractM
532 533
533 534 Sonatype.Events.addListener('repositoryViewInit', function(cardPanel, rec) {
534 535 var sp = Sonatype.lib.Permissions;
535   - if (rec.data.resourceURI && sp.checkPermission('nexus:repositorymirrors', sp.READ) && rec.data.userManaged == true && (rec.data.repoType == 'proxy' || rec.data.repoType == 'hosted'))
  536 + if (rec.data.resourceURI && sp.checkPermission('nexus:repositorymirrors', sp.READ) && rec.data.userManaged)
536 537 {
537   - if (rec.data.repoType == 'proxy')
  538 + if (rec.data.repoType === 'proxy')
538 539 {
539 540 cardPanel.add(new Sonatype.repoServer.ProxyMirrorEditor({
540 541 payload : rec,
@@ -542,7 +543,7 @@ Sonatype.Events.addListener('repositoryViewInit', function(cardPanel, rec) {
542 543 name : 'mirrors'
543 544 }));
544 545 }
545   - else if (rec.data.repoType == 'hosted')
  546 + else if (rec.data.repoType === 'hosted')
546 547 {
547 548 cardPanel.add(new Sonatype.repoServer.HostedMirrorEditor({
548 549 payload : rec,
73 nexus/nexus-webapp/src/main/webapp/js/repoServer/PrivilegeEditPanel.js
@@ -10,17 +10,16 @@
10 10 * of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
11 11 * Eclipse Foundation. All other trademarks are the property of their respective owners.
12 12 */
  13 +/*global define*/
  14 +
13 15 /*
14 16 * Privilege Edit/Create panel layout and controller
15 17 */
16   -
17   -define('repoServer/PrivilegeEditPanel',['sonatype/all'], function(){
  18 +define('repoServer/PrivilegeEditPanel',['extjs', 'sonatype/all'], function(Ext, Sonatype){
18 19 Sonatype.repoServer.PrivilegeEditPanel = function(config) {
19   - var config = config || {};
20   - var defaultConfig = {
  20 + Ext.apply(this, config || {}, {
21 21 title : 'Privileges'
22   - };
23   - Ext.apply(this, config, defaultConfig);
  22 + });
24 23
25 24 this.sp = Sonatype.lib.Permissions;
26 25
@@ -174,18 +173,18 @@ Sonatype.repoServer.PrivilegeEditPanel = function(config) {
174 173
175 174 Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
176 175 convertRepository : function(value, parent) {
177   - var targetPriv = false;
178   - for (var i = 0; i < parent.properties.length; i++)
  176 + var i, targetPriv = false;
  177 + for (i = 0; i < parent.properties.length; i+=1)
179 178 {
180   - if (parent.properties[i].key == 'repositoryId' && !Ext.isEmpty(parent.properties[i].value))
  179 + if (parent.properties[i].key === 'repositoryId' && !Ext.isEmpty(parent.properties[i].value))
181 180 {
182 181 return this.convertDataValue(parent.properties[i].value, this.repoStore, 'id', 'name');
183 182 }
184   - else if (parent.properties[i].key == 'repositoryGroupId' && !Ext.isEmpty(parent.properties[i].value))
  183 + else if (parent.properties[i].key === 'repositoryGroupId' && !Ext.isEmpty(parent.properties[i].value))
185 184 {
186 185 return this.convertDataValue(parent.properties[i].value, this.groupStore, 'id', 'name');
187 186 }
188   - else if (parent.properties[i].key == 'repositoryTargetId')
  187 + else if (parent.properties[i].key === 'repositoryTargetId')
189 188 {
190 189 targetPriv = true;
191 190 }
@@ -202,9 +201,10 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
202 201 },
203 202
204 203 convertTarget : function(value, parent) {
205   - for (var i = 0; i < parent.properties.length; i++)
  204 + var i;
  205 + for (i = 0; i < parent.properties.length; i+=1)
206 206 {
207   - if (parent.properties[i].key == 'repositoryTargetId' && !Ext.isEmpty(parent.properties[i].value))
  207 + if (parent.properties[i].key === 'repositoryTargetId' && !Ext.isEmpty(parent.properties[i].value))
208 208 {
209 209 return this.convertDataValue(parent.properties[i].value, this.targetStore, 'id', 'name');
210 210 }
@@ -217,9 +217,10 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
217 217 },
218 218
219 219 convertMethod : function(value, parent) {
220   - for (var i = 0; i < parent.properties.length; i++)
  220 + var i;
  221 + for (i = 0; i < parent.properties.length; i+=1)
221 222 {
222   - if (parent.properties[i].key == 'method' && !Ext.isEmpty(parent.properties[i].value))
  223 + if (parent.properties[i].key === 'method' && !Ext.isEmpty(parent.properties[i].value))
223 224 {
224 225 return parent.properties[i].value;
225 226 }
@@ -232,11 +233,12 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
232 233 },
233 234
234 235 convertRepositoryProperty : function(value, parent) {
  236 + var i;
235 237 if (Ext.isEmpty(value))
236 238 {
237   - for (var i = 0; i < parent.length; i++)
  239 + for (i = 0; i < parent.length; i+=1)
238 240 {
239   - if (parent[i].key == 'repositoryGroupId' && !Ext.isEmpty(parent[i].value))
  241 + if (parent[i].key === 'repositoryGroupId' && !Ext.isEmpty(parent[i].value))
240 242 {
241 243 return '';
242 244 }
@@ -308,11 +310,12 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
308 310 },
309 311
310 312 submitHandler : function(form, action, receivedData) {
  313 + var i, r;
311 314 if (Ext.isArray(receivedData))
312 315 {
313   - for (var i = 0; i < receivedData.length; i++)
  316 + for (i = 0; i < receivedData.length; i+=1)
314 317 {
315   - var r = receivedData[i];
  318 + r = receivedData[i];
316 319 r.sTarget = this.convertTarget(r.repositoryTargetId, r);
317 320 r.sType = this.convertType(r.type, r);
318 321 r.sRepository = this.convertRepository(r.repositoryId, r);
@@ -324,13 +327,14 @@ Ext.extend(Sonatype.repoServer.PrivilegeEditPanel, Sonatype.panels.GridViewer, {
324 327 });
325 328
326 329 Sonatype.repoServer.PrivilegeEditor = function(config) {
327   - var config = config || {};
328   - var defaultConfig = {
  330 + var i, items, targetStore2, typeRec,
  331 + ht = Sonatype.repoServer.resources.help.privileges,
  332 + defaultConfig = {
329 333 uri : Sonatype.config.repos.urls.privileges + '_target',
330 334 dataModifiers : {
331 335 load : {
332 336 properties : function(value, parent, fpanel) {
333   - for (var i = 0; i < value.length; i++)
  337 + for (i = 0; i < value.length; i+=1)
334 338 {
335 339 var field = fpanel.form.findField(value[i].key);
336 340 field.setValue(fpanel.propertyTypeStore.getAt(fpanel.propertyTypeStore.find('type', field.fieldConverterType)).data.converter(value[i].value, value));
@@ -346,11 +350,11 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
346 350 },
347 351 repositoryId : function(val, fpanel) {
348 352 var v = fpanel.form.findField('repositoryOrGroup').getValue();
349   - return v.indexOf('repo_') == 0 ? v.substring('repo_'.length) : '';
  353 + return v.indexOf('repo_') === 0 ? v.substring('repo_'.length) : '';
350 354 },
351 355 repositoryGroupId : function(val, fpanel) {
352 356 var v = fpanel.form.findField('repositoryOrGroup').getValue();
353   - return v.indexOf('group_') == 0 ? v.substring('group_'.length) : '';
  357 + return v.indexOf('group_') === 0 ? v.substring('group_'.length) : '';
354 358 },
355 359 type : function(val, fpanel) {
356 360 return 'target';
@@ -363,9 +367,8 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
363 367 },
364 368 referenceData : Sonatype.repoServer.referenceData.privileges.target
365 369 };
366   - Ext.apply(this, config, defaultConfig);
  370 + Ext.apply(this, config || {}, defaultConfig);
367 371
368   - var ht = Sonatype.repoServer.resources.help.privileges;
369 372 this.COMBO_WIDTH = 300;
370 373 this.sp = Sonatype.lib.Permissions;
371 374
@@ -390,7 +393,7 @@ Sonatype.repoServer.PrivilegeEditor = function(config) {
390 393 this.readOnly = true;
391 394 }
392 395
393   - var items = [{
  396 + items = [{
394 397 xtype : 'hidden',
395 398 name : 'id'
396 399 }, {