Debug uses now pretty printing for better readability for objects
[ajatus.git] / js / ajatus.installer.js
blobe376b7ef4be171db1ba9a3e69e203df3b91c366a
1 /*
2 * This file is part of
4 * Ajatus - Distributed CRM
5 * @requires jQuery v1.2.1
6 *
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
15 (function($){
16 $.ajatus = $.ajatus || {};
18 $.ajatus.installer = {
19 installed: false,
21 is_installed: function()
23 if ($.jqCouch.connection('db').exists($.ajatus.preferences.client.application_database)) {
24 $.ajatus.installer.installed = true;
28 install: function()
30 var dbc = $.jqCouch.connection('db');
32 var row = '';
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'), '', {
39 closable: false
40 });
42 dialog.open();
44 row = $.ajatus.i10n.get('Installing application database') + '... ';
45 dialog.append_content(row);
46 // jqcouch_db.create($.ajatus.preferences.client.application_database);
48 row = row_failed;
49 if (dbc.create($.ajatus.preferences.client.application_database).ok) {
50 row = row_ok;
52 dialog.append_content(row);
54 row = $.ajatus.i10n.get('Preparing application database') + '... ';
55 dialog.append_content(row);
57 row = row_failed;
58 if ($.jqCouch.connection('doc').put($.ajatus.preferences.client.application_database + '/preferences', {value: $.ajatus.preferences.local_defaults})._id) {
59 row = row_ok;
61 dialog.append_content(row);
63 row = $.ajatus.i10n.get('Installing application tags database') + '... ';
64 dialog.append_content(row);
66 row = row_failed;
67 if (dbc.create($.ajatus.preferences.client.tags_database).ok) {
68 row = row_ok;
70 dialog.append_content(row);
72 row = $.ajatus.i10n.get('Installing application content database') + '... ';
73 dialog.append_content(row);
75 row = row_failed;
76 if (dbc.create($.ajatus.preferences.client.content_database).ok) {
77 row = row_ok;
79 dialog.append_content(row);
81 var close = jQuery('<br /><br /><span class="jqmClose">' + $.ajatus.i10n.get('Continue') + '</span>');
82 dialog.append_content(close);
83 jQuery('#' + dialog.id + ' .jqmClose').bind('click', function(e){
84 dialog.close();
85 $.ajatus.preload();
86 }).css({cursor: 'pointer'});
88 return true;
91 uninstall: function()
93 var dbc = $.jqCouch.connection('db');
95 var row = '';
96 var row_failed = '<span class="status_failed">' + $.ajatus.i10n.get('failed').toUpperCase() + '</span><br />';
97 var row_ok = '<span class="status_ok">' + $.ajatus.i10n.get('ok').toUpperCase() + '</span><br />';
99 $.ajatus.debug('uninstalling');
101 var dialog = new $.ajatus.elements.dialog($.ajatus.i10n.get('Uninstalling'), '', {
102 closable: false
105 dialog.open();
107 row = $.ajatus.i10n.get('Uninstalling application content database') + '... ';
108 dialog.append_content(row);
110 row = row_failed;
111 if (dbc.del($.ajatus.preferences.client.content_database).ok) {
112 row = row_ok;
114 dialog.append_content(row);
116 row = $.ajatus.i10n.get('Uninstalling application tags database') + '... ';
117 dialog.append_content(row);
119 row = row_failed;
120 if (dbc.del($.ajatus.preferences.client.tags_database).ok) {
121 row = row_ok;
123 dialog.append_content(row);
125 row = $.ajatus.i10n.get('Uninstalling application database') + '... ';
126 dialog.append_content(row);
128 row = row_failed;
129 if (dbc.del($.ajatus.preferences.client.application_database).ok) {
130 row = row_ok;
132 dialog.append_content(row);
134 var close = jQuery('<br /><br /><span class="jqmClose">' + $.ajatus.i10n.get('Continue') + '</span>');
135 dialog.append_content(close);
136 jQuery('#' + dialog.id + ' .jqmClose').bind('click', function(e){
137 dialog.close();
138 window.location.reload();
139 }).css({cursor: 'pointer'});
141 return true;
145 })(jQuery);