4 * Ajatus - Distributed CRM
5 * @requires jQuery v1.2.1
7 * Copyright (c) 2007 Jerry Jalava <jerry.jalava@gmail.com>
8 * Copyright (c) 2007 Nemein Oy <http://nemein.com>
9 * Website: http://ajatus.info
10 * Licensed under the GPL license
11 * http://www.gnu.org/licenses/gpl.html
16 $.ajatus = $.ajatus || {};
18 $.ajatus.installer = {
21 is_installed: function()
23 if ($.jqCouch.connection('db').exists($.ajatus.preferences.client.application_database)) {
24 $.ajatus.installer.installed = true;
30 var dbc = $.jqCouch.connection('db');
33 var row_failed = '<span class="status_failed">' + $.ajatus.i10n.get('failed').toUpperCase() + '</span><br />';
34 var row_ok = '<span class="status_ok">' + $.ajatus.i10n.get('ok').toUpperCase() + '</span><br />';
36 $.ajatus.debug('Installing');
38 var dialog = new $.ajatus.elements.dialog($.ajatus.i10n.get('Installing'), '', {
44 row = $.ajatus.i10n.get('Installing application database') + '... ';
45 dialog.append_content(row);
46 // jqcouch_db.create($.ajatus.preferences.client.application_database);
49 if (dbc.create($.ajatus.preferences.client.application_database).ok) {
52 dialog.append_content(row);
54 row = $.ajatus.i10n.get('Preparing application database') + '... ';
55 dialog.append_content(row);
58 if ($.jqCouch.connection('doc').put($.ajatus.preferences.client.application_database + '/preferences', {value: $.ajatus.preferences.local_defaults}).id) {
61 if ($.jqCouch.connection('doc').put($.ajatus.preferences.client.application_database + '/version', {value: $.ajatus.version}).id) {
64 dialog.append_content(row);
66 row = $.ajatus.i10n.get('Installing application content database') + '... ';
67 dialog.append_content(row);
70 if (dbc.create($.ajatus.preferences.client.content_database).ok) {
73 dialog.append_content(row);
75 var close = jQuery('<br /><br /><span class="jqmClose">' + $.ajatus.i10n.get('Continue') + '</span>');
76 dialog.append_content(close);
77 jQuery('#' + dialog.id + ' .jqmClose').bind('click', function(e){
80 }).css({cursor: 'pointer'});
87 var dbc = $.jqCouch.connection('db');
90 var row_failed = '<span class="status_failed">' + $.ajatus.i10n.get('failed').toUpperCase() + '</span><br />';
91 var row_ok = '<span class="status_ok">' + $.ajatus.i10n.get('ok').toUpperCase() + '</span><br />';
93 $.ajatus.debug('uninstalling');
95 var dialog = new $.ajatus.elements.dialog($.ajatus.i10n.get('Uninstalling'), '', {
101 row = $.ajatus.i10n.get('Uninstalling application content database') + '... ';
102 dialog.append_content(row);
105 if (dbc.del($.ajatus.preferences.client.content_database).ok) {
108 dialog.append_content(row);
110 row = $.ajatus.i10n.get('Uninstalling application database') + '... ';
111 dialog.append_content(row);
114 if (dbc.del($.ajatus.preferences.client.application_database).ok) {
117 dialog.append_content(row);
119 var close = jQuery('<br /><br /><span class="jqmClose">' + $.ajatus.i10n.get('Continue') + '</span>');
120 dialog.append_content(close);
121 jQuery('#' + dialog.id + ' .jqmClose').bind('click', function(e){
123 window.location.reload();
124 }).css({cursor: 'pointer'});