feature(util) rm log

This commit is contained in:
coderaiser 2015-01-12 10:11:20 -05:00
parent f803a76bfa
commit 6194b1e96d
16 changed files with 54 additions and 60 deletions

View file

@ -7,12 +7,16 @@ var Util, DOM, CloudFunc, join;
function CloudCmdProto(Util, DOM, CloudFunc) {
var Key,
log = function() {
DOM.Files.get('config', function(error, config) {
if (!error && config.debug)
console.log.apply(console, arguments);
});
Debug,
log = function(str) {
var date = Util.getShortDate(),
time = Util.getTime(),
prefix = date + ' ' + time;
if (Debug)
console.log('[' + prefix + '] ' + str);
},
Listeners,
Files = DOM.Files,
Images = DOM.Images,
@ -21,6 +25,7 @@ var Util, DOM, CloudFunc, join;
Storage = DOM.Storage,
type = Util.type;
this.log = log,
this.PREFIX = '',
this.MousePosition = {};
this.LIBDIR = '/lib/';
@ -28,6 +33,15 @@ var Util, DOM, CloudFunc, join;
this.MIN_ONE_PANEL_WIDTH = 1155;
this.HOST = location.origin ||
location.protocol + '//' + location.host;
log.enable = function() {
Debug = true;
};
log.disable = function() {
Debug = false;
};
/**
* Функция привязываеться ко всем ссылкам и
* загружает содержимое каталогов
@ -179,7 +193,7 @@ var Util, DOM, CloudFunc, join;
if (file && !current) {
msg = CloudFunc.formatMsg('set current file', file, 'error');
log(msg);
CloudCmd.log(msg);
} else {
DOM.setCurrentFile(current);
CloudCmd.execFromModule(module, 'show');
@ -347,7 +361,7 @@ var Util, DOM, CloudFunc, join;
if (!options)
options = {};
log('reading dir: "' + path + '";');
CloudCmd.log('reading dir: "' + path + '";');
Files.get('config', function(error, config) {
var dirStorage;

View file

@ -65,7 +65,7 @@ var CloudCmd, Util, DOM, io;
});
socket.on('log', function(msg) {
Util.log(msg);
CloudCmd.log(msg);
});
socket.on('disconnect', function() {

View file

@ -133,7 +133,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
if (!isQuiet)
Dialog.alert(text);
Util.log(text);
CloudCmd.log(text);
}, 100);
return image;
@ -1390,13 +1390,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
if (!panel)
Util.log('Error can not find Active Panel');
throw(Error('can not find Active Panel!'));
return panel;
};
this.getFiles = function(element) {
var files = DOM.getByDataName('js-files', element),
var files = DOM.getByDataName('js-files', element),
ret = files.children || [];
return ret;

View file

@ -420,7 +420,7 @@ var CloudCmd, Util, DOM;
*/
case Key.R:
if (ctrlMeta) {
Util.log('reloading page...\n');
CloudCmd.log('reloading page...\n');
CloudCmd.refresh();
Events.preventDefault(event);
@ -450,10 +450,10 @@ var CloudCmd, Util, DOM;
/* чистим хранилище */
case Key.D:
if (ctrlMeta) {
Util.log('clearing storage...');
CloudCmd.log('clearing storage...');
DOM.Storage.clear(function() {
Util.log('storage cleared');
CloudCmd.log('storage cleared');
});
Events.preventDefault(event);

View file

@ -213,7 +213,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
});
});
Util.log('Uploading to ' + name + '...');
CloudCmd.log('Uploading to ' + name + '...');
}
function getFromPicker() {
@ -241,7 +241,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO;
isDir = DOM.isCurrentIsDir(file),
dir = isDir ? '&&json' : '';
Util.log('downloading file ' + path +'...');
CloudCmd.log('downloading file ' + path +'...');
path = apiURL + FS + path + '?download' + dir;

View file

@ -192,7 +192,7 @@ var Util, DOM, CloudFunc, CloudCmd;
Images.hide();
if (!p.notLog)
Util.log(data);
CloudCmd.log(data);
Util.exec(p.callback, data);
}

View file

@ -18,7 +18,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dropbox, cb, Client;
}
cb = function (err, data){ Util.log(err || data);};
cb = function (err, data){ console.log(err || data);};
/**
* function loads dropbox.js
@ -42,7 +42,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dropbox, cb, Client;
var lHello = 'Hello ' + pData.name + ' :)!',
lMsg = pError ? pError : lHello;
Util.log(lMsg);
console.log(lMsg);
});
Util.exec(callback);
@ -72,7 +72,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dropbox, cb, Client;
}));
Client.authenticate(function(error, client) {
Util.log(error);
console.log(error);
Client = client;
Util.exec(callback);
});
@ -137,7 +137,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dropbox, cb, Client;
Client.writeFile(name, data, function(error, data){
DOM.Images.hide();
Util.log(error || data);
console.log(error || data);
Util.exec(callback);
});
}

View file

@ -18,7 +18,7 @@ var CloudCmd, Util, DOM, filepicker;
this.uploadFile = function(params) {
var content = params.data,
name = params.name,
log = Util.log.bind(Util);
log = console.log.bind(console);
filepicker.store(content, {
mimetype: '',
@ -33,7 +33,7 @@ var CloudCmd, Util, DOM, filepicker;
this.saveFile = function(callback) {
filepicker.pick(function(fpFile) {
Util.log(fpFile);
console.log(fpFile);
DOM.load.ajax({
url : fpFile.url,

View file

@ -89,7 +89,7 @@ var CloudCmd, Util, DOM, gapi;
if (!pCallBack)
pCallBack = function(file) {
Util.log(file);
console.log(file);
};
request.execute(pCallBack);

View file

@ -12,7 +12,7 @@ var CloudCmd, Util, join, DOM, CloudFunc, Github, cb;
GH,
User;
cb = function (err, data) { Util.log(err || data);};
cb = function (err, data) { console.log(err || data);};
function init(callback) {
Util.exec.series([
@ -78,7 +78,7 @@ var CloudCmd, Util, join, DOM, CloudFunc, Github, cb;
if (!error) {
name = data.name;
Util.log('Hello ' + name + ' :)!');
console.log('Hello ' + name + ' :)!');
} else
DOM.Storage.remove('token');
});
@ -133,9 +133,9 @@ var CloudCmd, Util, join, DOM, CloudFunc, Github, cb;
gist.create(options, function(error, data) {
if (error)
Util.log(error);
console.log(error);
else
Util.log(data, data.html_url);
console.log(data, data.html_url);
Util.exec(callback);
DOM.Images.hide();

View file

@ -39,10 +39,10 @@ var CloudCmd, Util, DOM, WL;
scope: ['wl.skydrive wl.signin']
}).then(
function(response) {
Util.log(response);
console.log(response);
},
function() {
Util.log('Failed to authenticate.');
console.log('Failed to authenticate.');
});
WL.Event.subscribe('auth.login', onLogin);
@ -60,7 +60,7 @@ var CloudCmd, Util, DOM, WL;
function (response) {
if (!response.error) {
strGreeting = 'Hi, ' + response.first_name + '!';
Util.log(strGreeting);
console.log(strGreeting);
}
});
}

View file

@ -42,8 +42,8 @@ var CloudCmd, Util, DOM, VK;
VK.Api.call('getVariable', {key: lNAME}, function(r) {
var lName = r.response;
if(lName)
Util.log ('Hello, ' + lName + ':)');
if (lName)
console.log ('Hello, ' + lName + ':)');
});
Util.exec(callback);
@ -74,11 +74,11 @@ var CloudCmd, Util, DOM, VK;
},
dataType: 'application/x-www-form-urlencoded',
success : function(data){
Util.log(data);
VK.Api.call('docs.save', {}, Util.log);
console.log(data);
VK.Api.call('docs.save', {}, console.log);
},
error : Util.log
error : console.log
});
});
};

View file

@ -238,7 +238,7 @@ var CloudCmd, Util, DOM, CloudFunc, $;
name = Info.name;
if (error) {
Util.log(error);
alert(error);
} else {
if (!TemplateAudio)
TemplateAudio = template;

View file

@ -99,7 +99,7 @@
files.read(filesList, 'utf8', function(error, files) {
if (error)
Util.log(error.message);
throw(error);
else
Object.keys(files).forEach(function(path) {
var name = paths[path];
@ -134,7 +134,7 @@
if (!isAuth && !isFS)
callback();
else if (isAuth) {
Util.log('* Routing' + '-> ' + name);
console.log('* Routing' + '-> ' + name);
p.name = DIR_HTML + name + '.html';
ponse.sendFile(p);

View file

@ -100,7 +100,7 @@
lRet = 'client #' + pConnNum + lType + pStr;
Util.log(lRet);
console.log(lRet);
}
return lRet;

View file

@ -220,26 +220,6 @@
};
}
/**
* function log pArg if it's not empty
* @param pArg
*/
this.log = function() {
var args = [].slice.call(arguments),
console = Scope.console,
lDate = '[' + Util.getDate() + '] ';
if (console && args.length && args[0]) {
args.unshift(lDate);
console.log.apply(console, args);
args.shift();
}
return args.join(' ');
};
/**
* function remove substring from string
* @param str