var what = false;
var n = false;
var download = false;
exports.finalize = function(CLI){
if('widget' === what && download){
// frdl.UI.progress().start() ;
$.ajax( {
url: download,
crossDomain: true,
cache:false,
headers: {'X-Requested-With': 'XMLHttpRequest'/*,
'X-Frdl-Nw': (!!frdl.nw) ? 'true' : 'false'
*/
},
type: 'POST',
dataType: 'TEXT',
data: {
}
} )
.done(function(response) {
//alert(response);
var fs = require('fs');
//frdl.UI.progress().start() ;
//1.3.6.1.4.1.37553.8.1.8.8.10.1.3
var path = '1.3.6.1.4.1.37553.8.1.8.8.10.1.3' + frdl.DIRECTORY_SEPARATOR + n +frdl.DIRECTORY_SEPARATOR;
frdl.fs5.polyfill.getFiler().cd(frdl.fs5.polyfill.getFiler().fs.root);
fs.mkdir(path, '0755', function(err,dirEntry) {
if(err){
console.warn(err);
// return;
}
//frdl.UI.progress().start() ;
frdl.fs5.polyfill.getFiler().cd(frdl.fs5.polyfill.getFiler().fs.root);
fs.writeFile(path + 'widget.zip.wgt', response, function(err, data){
if(err){
console.error(err);
// return;
}
frdl.alert.error('...sorry, not fully implemented but coming very soon...!');
// frdl.UI.progress().complete() ;
} );
});
// frdl.UI.progress().complete() ;
})
.fail(function(jqXHR, textStatus) {
frdl.alert.error('Error: ' + widget.download + jqXHR.status);
})
.always(function() {
// frdl.UI.progress().complete() ;
});
}
//'widget' === what
};
exports.prepare = function(CLI){
CLI.addOption('download', 'Specify download url', function(name, value) {
download = value;
});
var parse_second_arg = function(value){
what = value;
};
var parse_third_arg = function(value){
n = value;
};
CLI.positionalSwitches[1] = parse_second_arg;
CLI.positionalSwitches[2] = parse_third_arg;
};
|