From 41b3e0945c32508844e530ae4bf1e2b90aff18d5 Mon Sep 17 00:00:00 2001 From: Bruno Ferreira Date: Thu, 3 Jul 2014 14:09:04 +0100 Subject: [PATCH 1/3] Added two optional parameters to the open function It would be nice to have a custom (and optional) success and failure function in the open function so for example, if I want to show an alert when there's no app to open a "pdf" file for example I could write a proper failure to show an alert or something else. --- www/fileopener.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/www/fileopener.js b/www/fileopener.js index b3ddf2f..db477f7 100644 --- a/www/fileopener.js +++ b/www/fileopener.js @@ -1,13 +1,17 @@ // forked from https://github.com/markeeftb/FileOpener module.exports = { - open: function (url) { - var success = function () { - console.log("success!"); + open: function (url, opt_success, opt_failure) { + if (typeof opt_success == 'undefined') { + opt_success = function () { + console.log("success!"); + } } - var failure = function (error) { - console.log(error); + if (typeof opt_failure == 'undefined') { + opt_failure = function (error) { + console.log(error); + } } - cordova.exec(success, failure, "FileOpener", "openFile", [url]); + cordova.exec(opt_success, opt_failure, "FileOpener", "openFile", [url]); } } From dcbbb3e9efa01a4a0e81428ed06ebaf3ba4a6500 Mon Sep 17 00:00:00 2001 From: Bruno Ferreira Date: Thu, 3 Jul 2014 14:31:33 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af70f1d..b8b496f 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Simple plugin which allows you to open popular files (PDF, WORD, EXCEL, JPG, GIF Adding the Plugin to your project ----------- - $ cordova plugin add https://github.com/don/FileOpener.git + $ cordova plugin add https://github.com/jamirooo/FileOpener.git Using the plugin =========== From b151464d5458b1d9fc8bd55ce3564a782a1d56d4 Mon Sep 17 00:00:00 2001 From: Bruno Ferreira Date: Thu, 3 Jul 2014 14:42:19 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8b496f..af70f1d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Simple plugin which allows you to open popular files (PDF, WORD, EXCEL, JPG, GIF Adding the Plugin to your project ----------- - $ cordova plugin add https://github.com/jamirooo/FileOpener.git + $ cordova plugin add https://github.com/don/FileOpener.git Using the plugin ===========