From 1d22f425e902dd19fe39ea5f396db35f3fa45c28 Mon Sep 17 00:00:00 2001 From: Gregory Soutade Date: Thu, 17 Sep 2015 20:32:29 +0200 Subject: [PATCH] Add export function --- server/index.php | 13 +++++++++++++ server/resources/gpass.css | 13 +++++++++++++ server/resources/gpass.js | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/server/index.php b/server/index.php index b2f0902..321abab 100644 --- a/server/index.php +++ b/server/index.php @@ -171,6 +171,19 @@ if ($user != "") } ?> +
+Export
\n"; + + echo ''; + echo 'Download'; +} +?> +
diff --git a/server/resources/gpass.css b/server/resources/gpass.css index a9527e5..2f2e3b4 100755 --- a/server/resources/gpass.css +++ b/server/resources/gpass.css @@ -79,6 +79,19 @@ body { margin : 15px; } +#export_database { + border-style:solid; + border-width:5px; + border-color:pink; + padding : 15px; + margin : 15px; +} + +#export_link { + display:none; + visibility:hidden; +} + .error { text-align:center; color:red; diff --git a/server/resources/gpass.js b/server/resources/gpass.js index 4721dd8..b9c7979 100755 --- a/server/resources/gpass.js +++ b/server/resources/gpass.js @@ -819,3 +819,42 @@ function update_masterkey() change_master_key(false); } } + +function makeText(text) { + var data = new Blob([text], {type: 'application/xml'}); + + textFile = window.URL.createObjectURL(data); + + // returns a URL you can use as a href + return textFile; +}; + +var text_link = null; +function export_database() +{ + link = document.getElementById("export_link"); + + if (text_link != null) window.URL.revokeObjectURL(text_link); + + text = "\n"; + for(i=0; i\n"; + text += "\t\t\n"; + text += "\t\t", "]]\\>", "g") + "]]>\n"; + text += "\t\n" + } + text += "\n"; + + text_link = makeText(text); + link.href = text_link; + + link.style.display = "inline"; + link.style.visibility = "visible"; + + alert_msg = "Click on download link to get all current unciphered passwords\n\n"; + alert_msg += "\"]]>\" sequence has been replaced by \"]]\\>\""; + alert(alert_msg); +}