jslint: fix type confusion and property access
fix various type confusion, for example: items: {} and items: [] style: string and style: {} also fix object['property'] access with object.property also fix /=/ with either '=' or /\=/ where appropriate (/=/ can be confused with /= according to jslint) Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
84de645d34
commit
ec0bd652db
@ -10,7 +10,7 @@ Ext.define('PVE.Parser', { statics: {
|
||||
return default_value;
|
||||
}
|
||||
value = value.toLowerCase();
|
||||
return value === 1 || value === '1' ||
|
||||
return value === '1' ||
|
||||
value === 'on' ||
|
||||
value === 'yes' ||
|
||||
value === 'true';
|
||||
@ -192,9 +192,11 @@ Ext.define('PVE.Parser', { statics: {
|
||||
errors = true;
|
||||
return false; // break
|
||||
}
|
||||
data['bridge'] = bridge_res[1];
|
||||
data['tag'] = bridge_res[4];
|
||||
data['firewall'] = bridge_res[5] ? 1 : 0;
|
||||
data.bridge = bridge_res[1];
|
||||
data.tag = bridge_res[4];
|
||||
/*jslint confusion: true*/
|
||||
data.firewall = bridge_res[5] ? 1 : 0;
|
||||
/*jslint confusion: false*/
|
||||
} else {
|
||||
data[match_res[1]] = match_res[2];
|
||||
}
|
||||
@ -221,10 +223,10 @@ Ext.define('PVE.Parser', { statics: {
|
||||
Ext.Array.each(['ifname', 'mac', 'bridge', 'host_ifname' , 'host_mac', 'mac_filter', 'tag', 'firewall'], function(key) {
|
||||
var value = data[key];
|
||||
if (key === 'bridge'){
|
||||
if(data['tag']){
|
||||
value = value + 'v' + data['tag'];
|
||||
if(data.tag){
|
||||
value = value + 'v' + data.tag;
|
||||
}
|
||||
if (data['firewall']){
|
||||
if (data.firewall){
|
||||
value = value + 'f';
|
||||
}
|
||||
}
|
||||
@ -270,9 +272,11 @@ Ext.define('PVE.Parser', { statics: {
|
||||
}
|
||||
});
|
||||
|
||||
/*jslint confusion: true*/
|
||||
if (data.rate > 0) {
|
||||
tmparray.push('rate=' + data.rate);
|
||||
}
|
||||
/*jslint confusion: false*/
|
||||
return tmparray.join(',');
|
||||
},
|
||||
|
||||
@ -396,7 +400,7 @@ Ext.define('PVE.Parser', { statics: {
|
||||
var res = {};
|
||||
|
||||
Ext.Array.each(value.split(','), function(p) {
|
||||
var kva = p.split(/=/, 2);
|
||||
var kva = p.split('=', 2);
|
||||
res[kva[0]] = kva[1];
|
||||
});
|
||||
|
||||
@ -419,7 +423,7 @@ Ext.define('PVE.Parser', { statics: {
|
||||
var res = {};
|
||||
|
||||
Ext.Array.each(value.split(','), function(p) {
|
||||
var kva = p.split(/=/, 2);
|
||||
var kva = p.split('=', 2);
|
||||
res[kva[0]] = kva[1];
|
||||
});
|
||||
|
||||
@ -439,8 +443,8 @@ Ext.define('PVE.Parser', { statics: {
|
||||
return; // continue
|
||||
}
|
||||
|
||||
if (!p.match(/=/)) {
|
||||
if (Ext.isDefined(res['cpu'])) {
|
||||
if (!p.match(/\=/)) {
|
||||
if (Ext.isDefined(res.cpu)) {
|
||||
errors = true;
|
||||
return false; // break
|
||||
}
|
||||
|
@ -147,6 +147,7 @@ Ext.define('PVE.Datepicker', {
|
||||
// since Ext.Msg is an object and not a prototype, we need to override it
|
||||
// after the framework has been initiated
|
||||
Ext.onReady(function() {
|
||||
/*jslint confusion: true */
|
||||
Ext.override(Ext.Msg, {
|
||||
alert: function(title, message, fn, scope) {
|
||||
if (Ext.isString(title)) {
|
||||
@ -163,8 +164,8 @@ Ext.onReady(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
/*jslint confusion: false */
|
||||
});
|
||||
|
||||
Ext.define('Ext.ux.IFrame', {
|
||||
extend: 'Ext.Component',
|
||||
|
||||
|
@ -109,6 +109,9 @@ Ext.define('PVE.ConsoleWorkspace', {
|
||||
title: gettext('Console'),
|
||||
|
||||
initComponent : function() {
|
||||
// novnc is a string in param
|
||||
// but a boolean in content
|
||||
/*jslint confusion: true*/
|
||||
var me = this;
|
||||
|
||||
var param = Ext.Object.fromQueryString(window.location.search);
|
||||
|
@ -32,9 +32,12 @@ Ext.define('PVE.button.Split', {
|
||||
|
||||
if (me.confirmMsg) {
|
||||
msg = me.confirmMsg;
|
||||
// confirMsg can be boolean or function
|
||||
/*jslint confusion: true*/
|
||||
if (Ext.isFunction(me.confirmMsg)) {
|
||||
msg = me.confirmMsg(rec);
|
||||
}
|
||||
/*jslint confusion: false*/
|
||||
Ext.MessageBox.defaultButton = me.dangerous ? 2 : 1;
|
||||
Ext.Msg.show({
|
||||
title: gettext('Confirm'),
|
||||
|
@ -15,7 +15,7 @@ Ext.define('PVE.node.CephDiskList', {
|
||||
sortable: false,
|
||||
renderer: function(v, metaData, rec) {
|
||||
if (rec && (rec.data.osdid >= 0)) {
|
||||
return "osd." + rec.data.osdid;
|
||||
return "osd." + rec.data.osdid.toString();
|
||||
}
|
||||
return v || PVE.Utils.noText;
|
||||
},
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Ext.create is a function, but
|
||||
// we defined create a bool in PVE.window.Edit
|
||||
/*jslint confusion: true*/
|
||||
Ext.define('PVE.CephCreatePool', {
|
||||
extend: 'PVE.window.Edit',
|
||||
alias: ['widget.pveCephCreatePool'],
|
||||
|
@ -274,8 +274,11 @@ Ext.define('PVE.dc.AuthEdit', {
|
||||
data.yubico_api_id = tfacfg.id;
|
||||
data.yubico_url = tfacfg.url;
|
||||
} else if (tfacfg.type === 'oath') {
|
||||
// step is a number before
|
||||
/*jslint confusion: true*/
|
||||
data.oath_step = tfacfg.step;
|
||||
data.oath_digits = tfacfg.digits;
|
||||
/*jslint confusion: false*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,15 @@ Ext.define('PVE.form.HotplugFeatureSelector', {
|
||||
var me = this;
|
||||
|
||||
if (me.multiSelect && Ext.isString(value)) {
|
||||
var newVal;
|
||||
if (value === '0') {
|
||||
value = [];
|
||||
newVal = [];
|
||||
} else if (value === '1') {
|
||||
value = ['disk', 'network', 'usb'];
|
||||
newVal = ['disk', 'network', 'usb'];
|
||||
} else {
|
||||
value = value.split(',');
|
||||
newVal = value.split(',');
|
||||
}
|
||||
me.callParent([newVal, doSelect]);
|
||||
}
|
||||
|
||||
me.callParent([value, doSelect]);
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Ext.create is a function
|
||||
// but we defined create as a bool in PVE.window.Edit
|
||||
/*jslint confusion: true*/
|
||||
Ext.define('PVE.pool.AddVM', {
|
||||
extend: 'PVE.window.Edit',
|
||||
width: 600,
|
||||
|
@ -137,10 +137,10 @@ Ext.define('PVE.lxc.Config', {
|
||||
layout: 'fit',
|
||||
plugins: {
|
||||
ptype: 'lazyitems',
|
||||
items: {
|
||||
items: [{
|
||||
xtype: 'pveLxcRessourceView',
|
||||
pveSelNode: me.pveSelNode
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -106,7 +106,7 @@ Ext.define('PVE.lxc.DNSEdit', {
|
||||
|
||||
Ext.apply(me, {
|
||||
subject: gettext('Resources'),
|
||||
items: ipanel
|
||||
items: [ ipanel ]
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
|
@ -71,7 +71,7 @@ Ext.define('PVE.lxc.NetworkInputPanel', {
|
||||
|
||||
var i, netlist = [];
|
||||
for (i = 0; i < 10; i++) {
|
||||
netlist.push({ "name": "net" + i });
|
||||
netlist.push({ "name": "net" + i.toString() });
|
||||
}
|
||||
|
||||
var netliststore = Ext.create('Ext.data.Store', {
|
||||
@ -94,6 +94,8 @@ Ext.define('PVE.lxc.NetworkInputPanel', {
|
||||
if (me.create && me.dataCache[value]) {
|
||||
return "Network ID already in use";
|
||||
}
|
||||
// validator can return bool/String
|
||||
/*jslint confusion: true*/
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@ -107,7 +109,7 @@ Ext.define('PVE.lxc.NetworkInputPanel', {
|
||||
allowBlank: false,
|
||||
value: cdata.name,
|
||||
validator: function(value) {
|
||||
var result = true;
|
||||
var result = '';
|
||||
Ext.Object.each(me.dataCache, function(key, netstr) {
|
||||
if (!key.match(/^net\d+/) || key === me.ifname) {
|
||||
return; // continue
|
||||
@ -118,7 +120,12 @@ Ext.define('PVE.lxc.NetworkInputPanel', {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
if (result !== '') {
|
||||
return result;
|
||||
}
|
||||
// validator can return bool/string
|
||||
/*jslint confusion:true*/
|
||||
return true;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -54,7 +54,7 @@ Ext.define('PVE.lxc.Summary', {
|
||||
ptype: 'lazyitems',
|
||||
items: [
|
||||
{
|
||||
style: 'padding-top:0px',
|
||||
style: {'padding-top': '0px' },
|
||||
layout: {
|
||||
type: 'hbox',
|
||||
align: 'stretchmax'
|
||||
|
@ -74,7 +74,7 @@ Ext.define('PVE.node.Subscription', {
|
||||
}
|
||||
},
|
||||
],
|
||||
items: [ view ]
|
||||
items: view
|
||||
});
|
||||
|
||||
PVE.Utils.API2Request({
|
||||
|
@ -50,14 +50,14 @@ Ext.define('PVE.panel.Config', {
|
||||
items.unshift({
|
||||
itemId: 'search',
|
||||
title: gettext('Search'),
|
||||
layout: 'fit',
|
||||
plugins: {
|
||||
layout: { type:'fit' },
|
||||
plugins: [{
|
||||
ptype: 'lazyitems',
|
||||
items: {
|
||||
items: [{
|
||||
xtype: 'pveResourceGrid',
|
||||
pveSelNode: me.pveSelNode
|
||||
}
|
||||
}
|
||||
}]
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ Ext.define('PVE.panel.LogView', {
|
||||
var maxDown = me.getMaxDown();
|
||||
var scrollToEnd = (maxDown <= 0) && me.scrollToEnd;
|
||||
|
||||
el.setStyle('padding-top', start*me.lineHeight + 'px');
|
||||
el.setStyle('padding-top', (start*me.lineHeight).toString() + 'px');
|
||||
el.update(text);
|
||||
me.dataCmp.setHeight(total*me.lineHeight);
|
||||
|
||||
|
@ -66,7 +66,7 @@ Ext.define('PVE.widget.RRDChart', {
|
||||
// limit to 2 decimal points
|
||||
value = Ext.util.Format.number(value, "0.##");
|
||||
|
||||
return value + " " + units[si];
|
||||
return value.toString() + " " + units[si];
|
||||
},
|
||||
|
||||
leftAxisRenderer: function(axis, label, layoutContext) {
|
||||
|
@ -48,7 +48,7 @@ Ext.define('PVE.qemu.BootOrderPanel', {
|
||||
var res = { boot: order };
|
||||
|
||||
if (me.bootdisk && order.indexOf('c') !== -1) {
|
||||
res['bootdisk'] = me.bootdisk;
|
||||
res.bootdisk = me.bootdisk;
|
||||
} else {
|
||||
res['delete'] = 'bootdisk';
|
||||
}
|
||||
@ -151,10 +151,10 @@ Ext.define('PVE.qemu.BootOrderPanel', {
|
||||
Ext.define('PVE.qemu.BootOrderEdit', {
|
||||
extend: 'PVE.window.Edit',
|
||||
|
||||
items: {
|
||||
items: [{
|
||||
xtype: 'pveQemuBootOrderPanel',
|
||||
itemId: 'inputpanel',
|
||||
},
|
||||
itemId: 'inputpanel'
|
||||
}],
|
||||
|
||||
subject: gettext('Boot Order'),
|
||||
|
||||
|
@ -11,11 +11,11 @@ Ext.define('PVE.qemu.CPUOptionsInputPanel', {
|
||||
delete_array.push('vcpus');
|
||||
delete values.vcpus;
|
||||
}
|
||||
if (values.cpulimit === '' || values.cpulimit == 0) {
|
||||
if (values.cpulimit === '' || values.cpulimit == '0') {
|
||||
delete_array.push('cpulimit');
|
||||
delete values.cpulimit;
|
||||
}
|
||||
if (values.cpuunits === '' || values.cpuunits == 1024) {
|
||||
if (values.cpuunits === '' || values.cpuunits == '1024') {
|
||||
delete_array.push('cpuunits');
|
||||
delete values.cpuunits;
|
||||
}
|
||||
@ -58,7 +58,7 @@ Ext.define('PVE.qemu.CPUOptionsInputPanel', {
|
||||
fieldLabel: gettext('CPU units'),
|
||||
minValue: 8,
|
||||
maxValue: 500000,
|
||||
value: 1024,
|
||||
value: '1024',
|
||||
allowBlank: true
|
||||
}
|
||||
];
|
||||
@ -81,7 +81,7 @@ Ext.define('PVE.qemu.CPUOptions', {
|
||||
|
||||
Ext.apply(me, {
|
||||
subject: gettext('CPU options'),
|
||||
items: ipanel,
|
||||
items: [ ipanel ]
|
||||
});
|
||||
|
||||
me.callParent();
|
||||
|
@ -152,7 +152,7 @@ Ext.define('PVE.qemu.MemoryEdit', {
|
||||
|
||||
Ext.apply(me, {
|
||||
subject: gettext('Memory'),
|
||||
items: ipanel,
|
||||
items: [ ipanel ],
|
||||
// uncomment the following to use the async configiguration API
|
||||
// backgroundDelay: 5,
|
||||
width: 400
|
||||
|
@ -6,8 +6,8 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
|
||||
var me = this;
|
||||
|
||||
// build the cpu options:
|
||||
me.cpu.cputype = values['cputype'];
|
||||
delete values['cputype'];
|
||||
me.cpu.cputype = values.cputype;
|
||||
delete values.cputype;
|
||||
var cpustring = PVE.Parser.printQemuCpu(me.cpu);
|
||||
|
||||
// remove cputype delete request:
|
||||
@ -21,14 +21,14 @@ Ext.define('PVE.qemu.ProcessorInputPanel', {
|
||||
}
|
||||
|
||||
if (cpustring) {
|
||||
values['cpu'] = cpustring;
|
||||
values.cpu = cpustring;
|
||||
} else {
|
||||
del.push('cpu');
|
||||
}
|
||||
|
||||
del = del.join(',');
|
||||
if (del) {
|
||||
values['delete'] = del;
|
||||
var delarr = del.join(',');
|
||||
if (delarr) {
|
||||
values['delete'] = delarr;
|
||||
}
|
||||
|
||||
return values;
|
||||
@ -120,7 +120,7 @@ Ext.define('PVE.qemu.ProcessorEdit', {
|
||||
me.load({
|
||||
success: function(response, options) {
|
||||
var data = response.result.data;
|
||||
var value = data['cpu'];
|
||||
var value = data.cpu;
|
||||
if (value) {
|
||||
var cpu = PVE.Parser.parseQemuCpu(value);
|
||||
ipanel.cpu = cpu;
|
||||
|
@ -172,6 +172,9 @@ Ext.define('PVE.storage.LVMInputPanel', {
|
||||
|
||||
me.column1.push(vgnameField);
|
||||
|
||||
// here value is an array,
|
||||
// while before it was a string
|
||||
/*jslint confusion: true*/
|
||||
me.column1.push({
|
||||
xtype: 'pveContentTypeSelector',
|
||||
cts: ['images', 'rootdir'],
|
||||
@ -181,6 +184,7 @@ Ext.define('PVE.storage.LVMInputPanel', {
|
||||
multiSelect: true,
|
||||
allowBlank: false
|
||||
});
|
||||
/*jslint confusion: false*/
|
||||
|
||||
me.column2 = [
|
||||
{
|
||||
|
@ -168,6 +168,9 @@ Ext.define('PVE.storage.LvmThinInputPanel', {
|
||||
|
||||
me.column1.push(thinpoolField);
|
||||
|
||||
// here value is an array,
|
||||
// while before it was a string
|
||||
/*jslint confusion: true*/
|
||||
me.column1.push({
|
||||
xtype: 'pveContentTypeSelector',
|
||||
cts: ['images', 'rootdir'],
|
||||
@ -177,6 +180,7 @@ Ext.define('PVE.storage.LvmThinInputPanel', {
|
||||
multiSelect: true,
|
||||
allowBlank: false
|
||||
});
|
||||
/*jslint confusion: false*/
|
||||
|
||||
me.column2 = [
|
||||
{
|
||||
|
@ -52,6 +52,9 @@ Ext.define('PVE.storage.RBDInputPanel', {
|
||||
}
|
||||
];
|
||||
|
||||
// here value is an array,
|
||||
// while before it was a string
|
||||
/*jslint confusion: true*/
|
||||
me.column2 = [
|
||||
{
|
||||
xtype: 'pvecheckbox',
|
||||
@ -76,6 +79,7 @@ Ext.define('PVE.storage.RBDInputPanel', {
|
||||
fieldLabel: gettext('KRBD')
|
||||
}
|
||||
];
|
||||
/*jslint confusion: false*/
|
||||
|
||||
if (me.create || me.storageId !== 'local') {
|
||||
me.column2.unshift({
|
||||
|
@ -28,7 +28,7 @@ Ext.define('PVE.storage.Summary', {
|
||||
|
||||
var statusview = Ext.create('PVE.storage.StatusView', {
|
||||
pveSelNode: me.pveSelNode,
|
||||
style: 'padding-top:0px'
|
||||
style: {'padding-top':'0px'}
|
||||
});
|
||||
|
||||
var rstore = statusview.rstore;
|
||||
|
@ -79,6 +79,9 @@ Ext.define('PVE.storage.ZFSPoolInputPanel', {
|
||||
}));
|
||||
}
|
||||
|
||||
// value is an array,
|
||||
// while before it was a string
|
||||
/*jslint confusion: true*/
|
||||
me.column1.push(
|
||||
{xtype: 'pveContentTypeSelector',
|
||||
cts: ['images', 'rootdir'],
|
||||
@ -86,8 +89,9 @@ Ext.define('PVE.storage.ZFSPoolInputPanel', {
|
||||
name: 'content',
|
||||
value: ['images', 'rootdir'],
|
||||
multiSelect: true,
|
||||
allowBlank: false});
|
||||
|
||||
allowBlank: false
|
||||
});
|
||||
/*jslint confusion: false*/
|
||||
me.column2 = [
|
||||
{
|
||||
xtype: 'pvecheckbox',
|
||||
|
@ -104,7 +104,7 @@ Ext.define('PVE.tree.ResourceTree', {
|
||||
|
||||
var defaults = PVE.tree.ResourceTree.typeDefaults[info.type];
|
||||
if (info.id === 'root') {
|
||||
defaults = PVE.tree.ResourceTree.typeDefaults['datacenter'];
|
||||
defaults = PVE.tree.ResourceTree.typeDefaults.datacenter;
|
||||
} else if (info.type === 'type') {
|
||||
defaults = PVE.tree.ResourceTree.typeDefaults[info.groupbyid];
|
||||
}
|
||||
@ -128,7 +128,7 @@ Ext.define('PVE.tree.ResourceTree', {
|
||||
|
||||
if (info.template) {
|
||||
iconClsAdd = '-template';
|
||||
info.iconCls = PVE.tree.ResourceTree.typeDefaults['template'].iconCls + '-' + info.type;
|
||||
info.iconCls = PVE.tree.ResourceTree.typeDefaults.template.iconCls + '-' + info.type;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ Ext.define('PVE.window.SafeDestroy', {
|
||||
buttonAlign: 'center',
|
||||
bodyPadding: 10,
|
||||
width: 450,
|
||||
layout: 'hbox',
|
||||
layout: { type:'hbox' },
|
||||
defaultFocus: 'confirmField',
|
||||
|
||||
config: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user