mirror of
https://codeberg.org/scip/digiproof.git
synced 2025-12-17 04:30:59 +01:00
Changed the build process it generates a devel and a prod version
of the source, added some screenshots and a sample printout, couple bugfixes.
This commit is contained in:
@@ -74,3 +74,4 @@ function decode64(input) {
|
||||
|
||||
return unescape(output);
|
||||
}
|
||||
|
||||
|
||||
21
js/confirm.js
Normal file
21
js/confirm.js
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
function confirminit() {
|
||||
window.onbeforeunload = function(e) {
|
||||
if(window.confirmExit) return confirmExit();
|
||||
};
|
||||
}
|
||||
|
||||
var hadConfirmExit = false;
|
||||
function checkUnsavedChanges() {
|
||||
if(App.store && App.store.isDirty && window.hadConfirmExit === false) {
|
||||
if(confirm("unsafed changes"))
|
||||
saveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
function confirmExit() {
|
||||
hadConfirmExit = true;
|
||||
if(App.store && App.store.isDirty) {
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
7
js/controllers_application.js
Normal file
7
js/controllers_application.js
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
App.ApplicationController = Ember.Controller.extend({
|
||||
isDevel: isDevel,
|
||||
VERSION: VERSION
|
||||
});
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ App.UploadFileView = Ember.TextField.extend({
|
||||
App.DataImportController = Ember.ObjectController.extend({
|
||||
isEditing: true,
|
||||
clear: '',
|
||||
failed: false,
|
||||
errors: {},
|
||||
|
||||
doneEditing: function() {
|
||||
@@ -197,6 +198,15 @@ App.DataImportController = Ember.ObjectController.extend({
|
||||
// suck it in
|
||||
ImportJSON(importobj, pass);
|
||||
this.set('clear', translate('_importdone'));
|
||||
var isuccessors = [];
|
||||
$.each(importobj.successors, function(index, obj) {
|
||||
if(obj.id != '0') {
|
||||
isuccessors.pushObject(obj);
|
||||
}
|
||||
});
|
||||
this.set('successors', isuccessors);
|
||||
this.set('assets', importobj.assets);
|
||||
this.set('self', importobj.self);
|
||||
}
|
||||
else {
|
||||
throw 'decrypted variable $json doesnt contain anything, weird';
|
||||
@@ -205,12 +215,14 @@ App.DataImportController = Ember.ObjectController.extend({
|
||||
catch (e) {
|
||||
// console.log("decryption exception: %o", e);
|
||||
this.set('clear', translate('_error_decrypt') + " (" + e + ")");
|
||||
this.set('failed', true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// no password given
|
||||
this.set('isEditing', true);
|
||||
this.set('errors', validated);
|
||||
this.set('failed', true);
|
||||
this.set('clear', translate('_error_decrypt'));
|
||||
}
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ App.IndexController = Ember.Controller.extend({
|
||||
has_self: App.Self.find(),
|
||||
has_asset: App.Asset.find(),
|
||||
has_successor: App.Successor.find(),
|
||||
isDevel: isDevel,
|
||||
VERSION: VERSION
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
var isDevel = true;
|
||||
|
||||
DS.LSSerializer = DS.JSONSerializer.extend({
|
||||
|
||||
addBelongsTo: function(data, record, key, association) {
|
||||
238
js/libs/localstorage_adapter_prod.js
Normal file
238
js/libs/localstorage_adapter_prod.js
Normal file
@@ -0,0 +1,238 @@
|
||||
var isDevel = false;
|
||||
|
||||
/*
|
||||
* in the production actual saving to browser
|
||||
* storage on disk is disabled here by overwriting
|
||||
* the setItem and getItem function with dummies,
|
||||
* which hold the data in memory only.
|
||||
*/
|
||||
localStorage.setItem = function(namespace, json) {
|
||||
this.set('_fakestore') = { namespace: json };
|
||||
return this;
|
||||
}
|
||||
|
||||
localStorage.getItem = function(namespace) {
|
||||
return this.get('_fakestore').namespace;
|
||||
}
|
||||
|
||||
DS.LSSerializer = DS.JSONSerializer.extend({
|
||||
|
||||
addBelongsTo: function(data, record, key, association) {
|
||||
data[key] = record.get(key + '.id');
|
||||
},
|
||||
|
||||
addHasMany: function(data, record, key, association) {
|
||||
data[key] = record.get(key).map(function(record) {
|
||||
return record.get('id');
|
||||
});
|
||||
},
|
||||
|
||||
// extract expects a root key, we don't want to save all these keys to
|
||||
// localStorage so we generate the root keys here
|
||||
extract: function(loader, json, type, record) {
|
||||
this._super(loader, this.rootJSON(json, type), type, record);
|
||||
},
|
||||
|
||||
extractMany: function(loader, json, type, records) {
|
||||
this._super(loader, this.rootJSON(json, type, 'pluralize'), type, records);
|
||||
},
|
||||
|
||||
rootJSON: function(json, type, pluralize) {
|
||||
var root = this.rootForType(type);
|
||||
if (pluralize == 'pluralize') { root = this.pluralize(root); }
|
||||
var rootedJSON = {};
|
||||
rootedJSON[root] = json;
|
||||
return rootedJSON;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
DS.LSAdapter = DS.Adapter.extend(Ember.Evented, {
|
||||
|
||||
init: function() {
|
||||
this._loadData();
|
||||
},
|
||||
|
||||
generateIdForRecord: function() {
|
||||
return Math.random().toString(32).slice(2).substr(0,5);
|
||||
},
|
||||
|
||||
serializer: DS.LSSerializer.create(),
|
||||
|
||||
find: function(store, type, id) {
|
||||
var namespace = this._namespaceForType(type);
|
||||
this._async(function(){
|
||||
var copy = Ember.copy(namespace.records[id]);
|
||||
this.didFindRecord(store, type, copy, id);
|
||||
});
|
||||
},
|
||||
|
||||
findMany: function(store, type, ids) {
|
||||
var namespace = this._namespaceForType(type);
|
||||
this._async(function(){
|
||||
var results = [];
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
results.push(Ember.copy(namespace.records[ids[i]]));
|
||||
}
|
||||
this.didFindMany(store, type, results);
|
||||
});
|
||||
},
|
||||
|
||||
// Supports queries that look like this:
|
||||
//
|
||||
// {
|
||||
// <property to query>: <value or regex (for strings) to match>,
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// Every property added to the query is an "AND" query, not "OR"
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// match records with "complete: true" and the name "foo" or "bar"
|
||||
//
|
||||
// { complete: true, name: /foo|bar/ }
|
||||
findQuery: function(store, type, query, recordArray) {
|
||||
var namespace = this._namespaceForType(type);
|
||||
this._async(function() {
|
||||
var results = this.query(namespace.records, query);
|
||||
this.didFindQuery(store, type, results, recordArray);
|
||||
});
|
||||
},
|
||||
|
||||
query: function(records, query) {
|
||||
var results = [];
|
||||
var id, record, property, test, push;
|
||||
for (id in records) {
|
||||
record = records[id];
|
||||
for (property in query) {
|
||||
test = query[property];
|
||||
push = false;
|
||||
if (Object.prototype.toString.call(test) == '[object RegExp]') {
|
||||
push = test.test(record[property]);
|
||||
} else {
|
||||
push = record[property] === test;
|
||||
}
|
||||
}
|
||||
if (push) {
|
||||
results.push(record);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
},
|
||||
|
||||
findAll: function(store, type) {
|
||||
var namespace = this._namespaceForType(type);
|
||||
this._async(function() {
|
||||
var results = [];
|
||||
for (var id in namespace.records) {
|
||||
results.push(Ember.copy(namespace.records[id]));
|
||||
}
|
||||
this.didFindAll(store, type, results);
|
||||
});
|
||||
},
|
||||
|
||||
createRecords: function(store, type, records) {
|
||||
var namespace = this._namespaceForType(type);
|
||||
records.forEach(function(record) {
|
||||
this._addRecordToNamespace(namespace, record);
|
||||
}, this);
|
||||
this._async(function() {
|
||||
this._didSaveRecords(store, type, records);
|
||||
});
|
||||
},
|
||||
|
||||
updateRecords: function(store, type, records) {
|
||||
var namespace = this._namespaceForType(type);
|
||||
this._async(function() {
|
||||
records.forEach(function(record) {
|
||||
var id = record.get('id');
|
||||
namespace.records[id] = record.serialize({includeId:true});
|
||||
}, this);
|
||||
this._didSaveRecords(store, type, records);
|
||||
});
|
||||
},
|
||||
|
||||
deleteRecords: function(store, type, records) {
|
||||
var namespace = this._namespaceForType(type);
|
||||
this._async(function() {
|
||||
records.forEach(function(record) {
|
||||
var id = record.get('id');
|
||||
delete namespace.records[id];
|
||||
});
|
||||
this._didSaveRecords(store, type, records);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
dirtyRecordsForHasManyChange: function(dirtySet, parent, relationship) {
|
||||
dirtySet.add(parent);
|
||||
},
|
||||
|
||||
dirtyRecordsForBelongsToChange: function(dirtySet, child, relationship) {
|
||||
dirtySet.add(child);
|
||||
},
|
||||
|
||||
// private
|
||||
|
||||
_getNamespace: function() {
|
||||
return this.namespace || 'DS.LSAdapter';
|
||||
},
|
||||
|
||||
_loadData: function() {
|
||||
try {
|
||||
var storage = localStorage.getItem(this._getNamespace());
|
||||
this._data = storage ? JSON.parse(storage) : {};
|
||||
}
|
||||
catch(e) {
|
||||
this._data = {};
|
||||
}
|
||||
},
|
||||
|
||||
_didSaveRecords: function(store, type, records) {
|
||||
var success = this._saveData();
|
||||
if (success) {
|
||||
store.didSaveRecords(records);
|
||||
} else {
|
||||
records.forEach(function(record) {
|
||||
store.recordWasError(record);
|
||||
});
|
||||
this.trigger('QUOTA_EXCEEDED_ERR', records);
|
||||
}
|
||||
},
|
||||
|
||||
_saveData: function() {
|
||||
try {
|
||||
localStorage.setItem(this._getNamespace(), JSON.stringify(this._data));
|
||||
return true;
|
||||
}
|
||||
catch(error) {
|
||||
if (error.name == 'QUOTA_EXCEEDED_ERR') {
|
||||
return false;
|
||||
} else {
|
||||
// IE, Ignore. throw new Error(error);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_namespaceForType: function(type) {
|
||||
var namespace = type.url || type.toString();
|
||||
return this._data[namespace] || (
|
||||
this._data[namespace] = {records: {}}
|
||||
);
|
||||
},
|
||||
|
||||
_addRecordToNamespace: function(namespace, record) {
|
||||
var data = record.serialize({includeId: true});
|
||||
namespace.records[data.id] = data;
|
||||
},
|
||||
|
||||
_async: function(callback) {
|
||||
var _this = this;
|
||||
setTimeout(function(){
|
||||
Ember.run(_this, callback);
|
||||
}, 1);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -1 +1 @@
|
||||
var VERSION = "2013-09-13-080748"
|
||||
var VERSION = "2013-09-13-155304"
|
||||
|
||||
11
js/locale.js
11
js/locale.js
@@ -113,7 +113,10 @@ window.locale = {
|
||||
+"into the notes field below.",
|
||||
"_aboutmenu": "About Digiproof",
|
||||
"_about": "This is DigiProof, a JavaScript App to create a digital testament by Thomas Linden. Copyright (c) 2013. "
|
||||
+"Licensed under the terms of the General Public License Version 2."
|
||||
+"Licensed under the terms of the General Public License Version 2.",
|
||||
"_devel": "Caution! This is the development version of DigiProof. It stores data to local disk using the browsers "
|
||||
+"localStorage feature. So, whatever you enter, persists over sessions, is unencrypted and can be viewed by anyone "
|
||||
+"with access to this device. Use for testing/developing purposes only and don't ever enter production account informations!"
|
||||
},
|
||||
|
||||
"de": {
|
||||
@@ -233,7 +236,11 @@ window.locale = {
|
||||
+"dazugehörige Ergänzungen hinzufügen.",
|
||||
"_aboutmenu": "Über Digiproof",
|
||||
"_about": "Dies ist DigiProof, eine Javascript App zum Erstellen eines digitalen Testaments von Thomas Linden. Copyright (c) 2013. "
|
||||
+"Veröffentlicht unter der General Public License Version 2."
|
||||
+"Veröffentlicht unter der General Public License Version 2.",
|
||||
"_devel": "Achtung! Dies ist die Entwicklerversion von DigiProof. Eingegebene Daten werden auf der lokalen Festplatte "
|
||||
+"unter Verwendung des localStorage Features Ihres Browsers gespeichert. Was immer Sie eingeben, bleibt über Browsersitzungen "
|
||||
+"hinweg erhalten, ist nicht verschlüsselt und kann von jedem mit Zugriff auf das System gelesen werden. Verwenden Sie "
|
||||
+"diese Version ausschliesslich für Test- oder Entwicklungszwecke und geben Sie niemals echte Accountinformationen ein!"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user