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 = {
20 installed_version: null,
22 is_installed: function()
24 if ($.jqCouch.connection('db').exists($.ajatus.preferences.client.application_database)) {
25 $.ajatus.installer.installed = true;
27 var version = $.jqCouch.connection('doc').get($.ajatus.preferences.client.application_database + '/version');
28 $.ajatus.installer.installed_version = version.value;
29 $.ajatus.installer.installed_version_rev = version._rev;
35 var dbc = $.jqCouch.connection('db');
38 var row_failed = '<span class="status_failed">' + $.ajatus.i10n.get('failed').toUpperCase() + '</span><br />';
39 var row_ok = '<span class="status_ok">' + $.ajatus.i10n.get('ok').toUpperCase() + '</span><br />';
41 $.ajatus.debug('Installing');
43 var dialog = new $.ajatus.elements.dialog($.ajatus.i10n.get('Installing'), '', {
49 row = $.ajatus.i10n.get('Installing application database') + '... ';
50 dialog.append_content(row);
51 // jqcouch_db.create($.ajatus.preferences.client.application_database);
54 if (dbc.create($.ajatus.preferences.client.application_database).ok) {
57 dialog.append_content(row);
59 row = $.ajatus.i10n.get('Preparing application database') + '... ';
60 dialog.append_content(row);
63 if ($.jqCouch.connection('doc').put($.ajatus.preferences.client.application_database + '/preferences', {value: $.ajatus.preferences.local_defaults}).id) {
66 if ($.jqCouch.connection('doc').put($.ajatus.preferences.client.application_database + '/version', {value: $.ajatus.version}).id) {
69 dialog.append_content(row);
71 row = $.ajatus.i10n.get('Installing application content database') + '... ';
72 dialog.append_content(row);
75 if (dbc.create($.ajatus.preferences.client.content_database).ok) {
78 dialog.append_content(row);
80 var close = jQuery('<br /><br /><span class="jqmClose">' + $.ajatus.i10n.get('Continue') + '</span>');
81 dialog.append_content(close);
82 jQuery('#' + dialog.id + ' .jqmClose').bind('click', function(e){
85 }).css({cursor: 'pointer'});
92 var dbc = $.jqCouch.connection('db');
95 var row_failed = '<span class="status_failed">' + $.ajatus.i10n.get('failed').toUpperCase() + '</span><br />';
96 var row_ok = '<span class="status_ok">' + $.ajatus.i10n.get('ok').toUpperCase() + '</span><br />';
98 $.ajatus.debug('uninstalling');
100 var dialog = new $.ajatus.elements.dialog($.ajatus.i10n.get('Uninstalling'), '', {
106 row = $.ajatus.i10n.get('Uninstalling application content database') + '... ';
107 dialog.append_content(row);
110 if (dbc.del($.ajatus.preferences.client.content_database).ok) {
113 dialog.append_content(row);
115 row = $.ajatus.i10n.get('Uninstalling application database') + '... ';
116 dialog.append_content(row);
119 if (dbc.del($.ajatus.preferences.client.application_database).ok) {
122 dialog.append_content(row);
124 var close = jQuery('<br /><br /><span class="jqmClose">' + $.ajatus.i10n.get('Continue') + '</span>');
125 dialog.append_content(close);
126 jQuery('#' + dialog.id + ' .jqmClose').bind('click', function(e){
128 window.location.reload();
129 }).css({cursor: 'pointer'});