profile download implemented; closes #16

php
Marc Wäckerlin 9 years ago
parent 1e89b5536c
commit 585fc5613c
  1. 6
      ax_init_standard_project.m4
  2. 16
      bootstrap.sh
  3. 2
      configure.ac
  4. 5
      html/index.html.in
  5. 3
      html/safechat.css
  6. 34
      html/safechat.js

@ -250,10 +250,10 @@ EOF
# use this in configure.ac to support HTML data for webservers
AC_DEFUN([AX_BUILD_HTML], [
AC_CONFIG_FILES([html/makefile])
AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-example-targets], [html/makefile.in])
test -f html/makefile.in && cat >> examples/html.in <<EOF
AX_ADD_MAKEFILE_TARGET_DEP([maintainer-clean-am], [maintainer-clean-html-targets], [html/makefile.in])
test -f html/makefile.in && cat >> html/makefile.in <<EOF
#### Begin: Appended by $0
maintainer-clean-example-targets:
maintainer-clean-html-targets:
-rm makefile.in
#### End: $0
EOF

@ -40,7 +40,7 @@ SYNOPSIS
OPTIONS
--configure, -c call ./configure after initialization
--build, -c build, also call ./configure && make
--build, -b build, also call ./configure && make
--overwrite, -o overwrite all basic files (bootstrap.sh, m4-macros)
--rebuild, -r force rebuild of generated files, even if modified
--rebuild-file, -f <file> rebild specific file (can be added multiple times)
@ -102,6 +102,8 @@ GENERATED FILES
* ax_check_qt.m4 - auxiliary macro definition file
* mac-create-app-bundle.sh - script to create apple mac os-x app-bundle
* AUTHORS - replace your name in AUTHORS before first run
* NEWS - empty file add your project's news
* README - add project description (first line is header, followed by an empty line)
* configure.ac - global configuration file template
* makefile.am - global makefile template
* src/makefile.am - if you enabled AX_USE_CXX
@ -146,6 +148,7 @@ FILES TO EDIT
The following files normally require editing:
* AUTHORS
* NEWS
* README
* configure.ac
* src/makefile.am
@ -175,6 +178,7 @@ FILES
* AUTHORS: First line is the main author and used in Debian and RPM
packaging, so there must be a GPG key that matches
to this line.
* NEWS: File to add project news.
* README: First line is a short description of your project, then an
empty line must follow. All remaining lines are a
long description of your project. this information
@ -385,6 +389,14 @@ fi
to AUTHORS <<EOF && notice "please edit AUTHORS"
$AUTHOR
EOF
to NEWS <<EOF && notice "please edit NEWS"
$(date) created ${DEFAULT_PROJECT_NAME}
EOF
to README <<EOF && notice "please edit README"
${DEFAULT_PROJECT_NAME}
add description for ${DEFAULT_PROJECT_NAME}
EOF
to configure.ac <<EOF && \
( notice "please edit configure.ac, then rerun $0"; exit 0 )
${HEADER}m4_define(x_package_name, ${DEFAULT_PROJECT_NAME}) # project's name
@ -788,7 +800,7 @@ rm -rf \$RPM_BUILD_ROOT
$(if testtag AX_USE_LIBTOOL; then
echo '/usr/%_lib/@PACKAGE_NAME@.so.*'
else
/usr/bin/
echo /usr/bin/
fi)
%doc
/usr/share/doc/packages/@PACKAGE_NAME@/AUTHORS

@ -8,7 +8,7 @@
m4_define(x_package_name, safechat) # project's name
m4_define(x_major, 0) # project's major version
m4_define(x_minor, 0) # project's minor version
m4_define(x_minor, 1) # project's minor version
m4_include(ax_init_standard_project.m4)
AC_INIT(x_package_name, x_version, x_package_name)
AM_INIT_AUTOMAKE([1.9 tar-pax])

@ -24,10 +24,7 @@
<ul id="menu" style="display: none">
<li onclick="backup()">Download Backup</li>
<li>
<label for="restore">Restore: Upload Backup</label>
<input autocomplete="off" type="file" accept="text/*" id="restore" />
</li>
<li class="toolbutton"><label for="restore">Restore Backup</label><input autocomplete="off" type="file" accept="text/*" id="restore" /></li>
</ul>
<script>
$("#restore").change(function(evt){restore(evt)});

@ -121,9 +121,10 @@ td:last-child {
list-style-type: none;
border: 1px solid black;
}
#menu li {
#menu li, #menu li * {
padding: 0 1em 0 1em;
cursor: pointer;
text-align: left;
}
#menu li + li {
border-top: 1px solid black;

@ -139,7 +139,7 @@ function togglemenu() {
/// Download Profile Backup
function backup() {
status("<p>Starting Download...</p>");
status("<p>Starting backup download ...</p>");
var download = document.createElement('a');
download.href = 'data:attachment/text,'+encodeURI(JSON.stringify(localStorage));
download.target = '_blank';
@ -155,11 +155,29 @@ function backup() {
});
download.dispatchEvent(clickEvent);
togglemenu();
setTimeout(start, 20000);
setTimeout(start, 2000);
}
/// Upload Profile Backup
function restore(evt) {
status("<p>Starting backup restore ...</p>");
if (!window.FileReader)
return error("your browser dows not support file upload", true);
for (var i=0, f; f=evt.target.files[i]; ++i) {
var file = f;
var reader = new FileReader();
reader.onload = function(evt) {
if (evt.target.error) return error("error reading file", true);
if (evt.target.readyState==0) return notice("waiting for data ...");
if (evt.target.readyState==1) return notice("loading data ...");
var parsed=JSON.parse(evt.target.result);
togglemenu();
localStorage.pubKey = parsed.pubKey;
localStorage.privKey = parsed.privKey;
setTimeout(start, 2000);
}
reader.readAsText(file);
}
}
/// Check if user name is available
@ -251,8 +269,8 @@ function createkeypair(user, pwd) {
passphrase: pwd
}).then(function(keyPair) {
success("keys generated");
localStorage.pubKey = keyPair.publicKeyArmored;
localStorage.privKey = keyPair.privateKeyArmored;
localStorage["pubKey"] = keyPair.publicKeyArmored;
localStorage["privKey"] = keyPair.privateKeyArmored;
login();
}).catch(function(e) {
error(e);
@ -262,15 +280,15 @@ function createkeypair(user, pwd) {
/// Get Own Public Key
/** @return public key object */
function publicKey() {
if (typeof localStorage.pubKey == 'undefined') return null;
return openpgp.key.readArmored(localStorage.pubKey);
if (typeof localStorage["pubKey"] == 'undefined') return null;
return openpgp.key.readArmored(localStorage["pubKey"]);
}
/// Get Own Private Key
/** @return private key object */
function privateKey() {
if (typeof localStorage.privKey == 'undefined') return null;
return openpgp.key.readArmored(localStorage.privKey);
if (typeof localStorage["privKey"] == 'undefined') return null;
return openpgp.key.readArmored(localStorage["privKey"]);
}
/// Get Own User Name

Loading…
Cancel
Save