[pve-devel] [PATCH 2/3] Add indentation of one tab after each function block begin

Dietmar Maurer dietmar at proxmox.com
Wed Apr 22 15:43:37 CEST 2015


Applying: Add indentation of one tab after each function block begin
/home/dietmar/pve4-devel/pve-manager/.git/rebase-apply/patch:23: 
trailing whitespace, space before tab in indent.
         if (!options.headers) {
/home/dietmar/pve4-devel/pve-manager/.git/rebase-apply/patch:24: space 
before tab in indent.
                 options.headers = {};
/home/dietmar/pve4-devel/pve-manager/.git/rebase-apply/patch:25: space 
before tab in indent.
         }
/home/dietmar/pve4-devel/pve-manager/.git/rebase-apply/patch:26: space 
before tab in indent.
         options.headers.CSRFPreventionToken = PVE.CSRFPreventionToken;
/home/dietmar/pve4-devel/pve-manager/.git/rebase-apply/patch:38: space 
before tab in indent.
                 msg = result.message;
warning: squelched 73 whitespace errors
warning: 78 lines add whitespace errors.


On 04/22/2015 10:58 AM, Emmanuel Kasper wrote:
> Signed-off-by: Emmanuel Kasper <e.kasper at proxmox.com>
> ---
>   www/manager5/Utils.js | 179 ++++++++++++++++++++++++++------------------------
>   1 file changed, 93 insertions(+), 86 deletions(-)
>
> diff --git a/www/manager5/Utils.js b/www/manager5/Utils.js
> index 9e345fe..687378a 100644
> --- a/www/manager5/Utils.js
> +++ b/www/manager5/Utils.js
> @@ -13,12 +13,16 @@ Ext.Ajax.defaultHeaders = {
>       'Accept': 'application/json'
>   };
>   
> +/*
> + * Add Cross Site Request Forgery Token
> + * see https://pve.proxmox.com/wiki/Proxmox_VE_API#Authentification
> + */
>   Ext.Ajax.on('beforerequest', function(conn, options) {
>       if (PVE.CSRFPreventionToken) {
> -	if (!options.headers) {
> -	    options.headers = {};
> -	}
> -	options.headers.CSRFPreventionToken = PVE.CSRFPreventionToken;
> +    	if (!options.headers) {
> +    		options.headers = {};
> +    	}
> +    	options.headers.CSRFPreventionToken = PVE.CSRFPreventionToken;
>       }
>   });
>   
> @@ -346,16 +350,16 @@ Ext.define('PVE.Utils', { statics: {
>   	if (!result.success) {
>   	    msg = gettext("Unknown error");
>   	    if (result.message) {
> -		msg = result.message;
> -		if (result.status) {
> -		    msg += ' (' + result.status + ')';
> -		}
> +	    	msg = result.message;
> +	    	if (result.status) {
> +	    		msg += ' (' + result.status + ')';
> +	    	}
>   	    }
>   	    if (verbose && Ext.isObject(result.errors)) {
> -		msg += "<br>";
> -		Ext.Object.each(result.errors, function(prop, desc) {
> -		    msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " +
> -			Ext.htmlEncode(desc);
> +	    	msg += "<br>";
> +	    	Ext.Object.each(result.errors, function(prop, desc) {
> +	    		msg += "<br><b>" + Ext.htmlEncode(prop) + "</b>: " +
> +	    		Ext.htmlEncode(desc);
>   		});
>   	    }	
>   	}
> @@ -384,7 +388,9 @@ Ext.define('PVE.Utils', { statics: {
>   	return msg;
>       },
>   
> -    // Ext.Ajax.request
> +    /*
> +     * Extends Ext.Ajax.request
> +     */
>       API2Request: function(reqOpts) {
>   
>   	var newopts = Ext.apply({
> @@ -400,43 +406,44 @@ Ext.define('PVE.Utils', { statics: {
>   	    Ext.apply(newopts, {
>   		success: function(response, options) {
>   		    if (options.waitMsgTarget) {
> -			if (PVE.Utils.toolkit === 'touch') {
> -			    options.waitMsgTarget.setMasked(false);
> -			} else {
> -			    options.waitMsgTarget.setLoading(false);
> -			}
> +		    	if (PVE.Utils.toolkit === 'touch') {
> +		    		options.waitMsgTarget.setMasked(false);
> +		    	} else {
> +		    		options.waitMsgTarget.setLoading(false);
> +		    	}
>   		    }
>   		    var result = Ext.decode(response.responseText);
>   		    response.result = result;
>   		    if (!result.success) {
> -			response.htmlStatus = PVE.Utils.extractRequestError(result, true);
> -			Ext.callback(callbackFn, options.scope, [options, false, response]);
> -			Ext.callback(failureFn, options.scope, [response, options]);
> -			return;
> +		    	response.htmlStatus = PVE.Utils.extractRequestError(result, true);
> +		    	Ext.callback(callbackFn, options.scope, [options, false, response]);
> +		    	Ext.callback(failureFn, options.scope, [response, options]);
> +		    	return;
>   		    }
>   		    Ext.callback(callbackFn, options.scope, [options, true, response]);
>   		    Ext.callback(successFn, options.scope, [response, options]);
>   		},
>   		failure: function(response, options) {
>   		    if (options.waitMsgTarget) {
> -			if (PVE.Utils.toolkit === 'touch') {
> -			    options.waitMsgTarget.setMasked(false);
> -			} else {
> -			    options.waitMsgTarget.setLoading(false);
> -			}
> +		    	if (PVE.Utils.toolkit === 'touch') {
> +		    		options.waitMsgTarget.setMasked(false);
> +		    	} else {
> +		    		options.waitMsgTarget.setLoading(false);
> +		    	}
>   		    }
>   		    response.result = {};
>   		    try {
> -			response.result = Ext.decode(response.responseText);
> +		    	response.result = Ext.decode(response.responseText);
>   		    } catch(e) {}
> -		    var msg = gettext('Connection error') + ' - server offline?';
> -		    if (response.aborted) {
> -			msg = gettext('Connection error') + ' - aborted.';
> -		    } else if (response.timedout) {
> -			msg = gettext('Connection error') + ' - Timeout.';
> -		    } else if (response.status && response.statusText) {
> -			msg = gettext('Connection error') + ' ' + response.status + ': ' + response.statusText;
> -		    }
> +		    	var msg = gettext('Connection error') + ' - server offline?';
> +		    	if (response.aborted) {
> +		    		msg = gettext('Connection error') + ' - aborted.';
> +		    	} else if (response.timedout) {
> +		    		msg = gettext('Connection error') + ' - Timeout.';
> +		    	} else if (response.status && response.statusText) {
> +		    		msg = gettext('Connection error') + ' ' + response.status +
> +		    		': ' + response.statusText;
> +		    	}
>   		    response.htmlStatus = msg;
>   		    Ext.callback(callbackFn, options.scope, [options, false, response]);
>   		    Ext.callback(failureFn, options.scope, [response, options]);
> @@ -449,33 +456,34 @@ Ext.define('PVE.Utils', { statics: {
>   	var target = newopts.waitMsgTarget;
>   	if (target) {
>   	    if (PVE.Utils.toolkit === 'touch') {
> -		target.setMasked({ xtype: 'loadmask', message: newopts.waitMsg} );
> +	    	target.setMasked({ xtype: 'loadmask', message: newopts.waitMsg} );
>   	    } else {
>   		// Note: ExtJS bug - this does not work when component is not rendered
> -		target.setLoading(newopts.waitMsg);
> +	    	target.setLoading(newopts.waitMsg);
>   	    }
>   	}
>   	Ext.Ajax.request(newopts);
>       },
>   
>       assemble_field_data: function(values, data) {
> -        if (Ext.isObject(data)) {
> -	    Ext.Object.each(data, function(name, val) {
> -		if (values.hasOwnProperty(name)) {
> -                    var bucket = values[name];
> -                    if (!Ext.isArray(bucket)) {
> -                        bucket = values[name] = [bucket];
> -                    }
> -                    if (Ext.isArray(val)) {
> -                        values[name] = bucket.concat(val);
> -                    } else {
> -                        bucket.push(val);
> -                    }
> -                } else {
> +    if (Ext.isObject(data)) {
> +    	Ext.Object.each(data, function(name, val) {
> +    		if (values.hasOwnProperty(name)) {
> +        		var bucket = values[name];
> +        		if (!Ext.isArray(bucket)) {
> +        			bucket = values[name] = [bucket];
> +        		}
> +        		if (Ext.isArray(val)) {
> +        			values[name] = bucket.concat(val);
> +        		} else {
> +        			bucket.push(val);
> +        		}
> +        	}
> +		else {
>   		    values[name] = val;
> -                }
> -            });
> -	}
> +        	}
> +        });
> +    }
>       },
>   
>       checked_command: function(orig_cmd) {
> @@ -484,7 +492,7 @@ Ext.define('PVE.Utils', { statics: {
>   	    method: 'GET',
>   	    //waitMsgTarget: me,
>   	    failure: function(response, opts) {
> -		Ext.Msg.alert(gettext('Error'), response.htmlStatus);
> +	    	Ext.Msg.alert(gettext('Error'), response.htmlStatus);
>   	    },
>   	    success: function(response, opts) {
>   		var data = response.result.data;
> @@ -944,18 +952,18 @@ Ext.define('PVE.Utils', { statics: {
>   	    var url;
>   	    var params = { proxy: window.location.hostname };
>   	    if (vmtype === 'kvm') {
> -		url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
> -		PVE.Utils.openSpiceViewer(url, params);
> +	    	url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
> +	    	PVE.Utils.openSpiceViewer(url, params);
>   	    } else if (vmtype === 'lxc') {
> -		url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
> -		PVE.Utils.openSpiceViewer(url, params);
> +	    	url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
> +	    	PVE.Utils.openSpiceViewer(url, params);
>   	    } else if (vmtype === 'shell') {
> -		url = '/nodes/' + nodename + '/spiceshell';
> -		PVE.Utils.openSpiceViewer(url, params);
> +	    	url = '/nodes/' + nodename + '/spiceshell';
> +	    	PVE.Utils.openSpiceViewer(url, params);
>   	    } else if (vmtype === 'upgrade') {
> -		url = '/nodes/' + nodename + '/spiceshell';
> -		params.upgrade = 1;
> -		PVE.Utils.openSpiceViewer(url, params);
> +	    	url = '/nodes/' + nodename + '/spiceshell';
> +	    	params.upgrade = 1;
> +	    	PVE.Utils.openSpiceViewer(url, params);
>   	    }
>   	} else {
>   	    throw "unknown viewer type";
> @@ -998,34 +1006,33 @@ Ext.define('PVE.Utils', { statics: {
>   	    // It can have strange side effects (additional user prompt on firefox)
>   	    var andriod = navigator.userAgent.match(/Android/i) ? true : false;
>   	    if (andriod) {
> -		link.download = name;
> +	    	link.download = name;
>   	    }
>   
>   	    if (link.fireEvent) {
> -		link.fireEvent('onclick');
> +	    	link.fireEvent('onclick');
>   	    } else {
> -                var evt = document.createEvent("MouseEvents");
> -                evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
> +	    	var evt = document.createEvent("MouseEvents");
> +	    	evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
>   		link.dispatchEvent(evt);
>   	    }
>   	};
>   
>   	PVE.Utils.API2Request({
> -	    url: url,
> -	    params: params,
> -	    method: 'POST',
> -	    failure: function(response, opts){
> -		Ext.Msg.alert('Error', response.htmlStatus);
> +		url: url,
> +		params: params,
> +		method: 'POST',
> +		failure: function(response, opts){
> +			Ext.Msg.alert('Error', response.htmlStatus);
>   	    },
>   	    success: function(response, opts){
> -		var raw = "[virt-viewer]\n";
> -		Ext.Object.each(response.result.data, function(k, v) {
> +	    	var raw = "[virt-viewer]\n";
> +	    	Ext.Object.each(response.result.data, function(k, v) {
>   		    raw += k + "=" + v + "\n";
> -		});
> -		var url = 'data:application/x-virt-viewer;charset=UTF-8,' +
> +	    	});
> +	    	var url = 'data:application/x-virt-viewer;charset=UTF-8,' +
>   		    encodeURIComponent(raw);
> -		
> -		downloadWithName(url, "pve-spice.vv");
> +	    	downloadWithName(url, "pve-spice.vv");
>   	    }
>   	});
>       },
> @@ -1041,9 +1048,9 @@ Ext.define('PVE.Utils', { statics: {
>   	    el.unmask();
>   	} else {
>   	    if (msg === true) {
> -		el.mask(gettext("Loading..."));
> +	    	el.mask(gettext("Loading..."));
>   	    } else {
> -		el.mask(msg);
> +	    	el.mask(msg);
>   	    }
>   	}
>       },
> @@ -1051,8 +1058,8 @@ Ext.define('PVE.Utils', { statics: {
>       monStoreErrors: function(me, store) {
>   	me.mon(store, 'beforeload', function(s, operation, eOpts) {
>   	    if (!me.loadCount) {
> -		me.loadCount = 0; // make sure it is numeric
> -		PVE.Utils.setErrorMask(me, true);
> +	    	me.loadCount = 0; // make sure it is numeric
> +	    	PVE.Utils.setErrorMask(me, true);
>   	    }
>   	});
>   
> @@ -1061,7 +1068,7 @@ Ext.define('PVE.Utils', { statics: {
>   	    me.loadCount++;
>   
>   	    if (success) {
> -		PVE.Utils.setErrorMask(me, false);
> +	    	PVE.Utils.setErrorMask(me, false);
>   		return;
>   	    }
>   
> @@ -1069,9 +1076,9 @@ Ext.define('PVE.Utils', { statics: {
>   	    var operation = request.operation;
>   	    var error = operation.getError();
>   	    if (error.statusText) {
> -		msg = error.statusText + ' (' + error.status + ')';
> +	    	msg = error.statusText + ' (' + error.status + ')';
>   	    } else {
> -		msg = gettext('Connection error');
> +	    	msg = gettext('Connection error');
>   	    }
>   	    PVE.Utils.setErrorMask(me, msg);
>   	});




More information about the pve-devel mailing list