~vanvugt/ubuntu/oneiric/mediatomb/fix-770964-784431

« back to all changes in this revision

Viewing changes to webnew/js/items.js

  • Committer: Bazaar Package Importer
  • Author(s): Andres Mejia
  • Date: 2009-04-22 21:39:19 UTC
  • mto: (4.2.1 sid)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20090422213919-52m015y6gcpv1m1g
Tags: upstream-0.12.0~svn2018
ImportĀ upstreamĀ versionĀ 0.12.0~svn2018

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*MT_J*
 
2
    
 
3
    MediaTomb - http://www.mediatomb.cc/
 
4
    
 
5
    items.js - this file is part of MediaTomb.
 
6
    
 
7
    Copyright (C) 2007-2008 Jan Habermann <jan.habermann@gmail.com>
 
8
    
 
9
    MediaTomb is free software; you can redistribute it and/or modify
 
10
    it under the terms of the GNU General Public License version 2
 
11
    as published by the Free Software Foundation.
 
12
    
 
13
    MediaTomb is distributed in the hope that it will be useful,
 
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
    GNU General Public License for more details.
 
17
    
 
18
    You should have received a copy of the GNU General Public License
 
19
    version 2 along with MediaTomb; if not, write to the Free Software
 
20
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
21
    
 
22
    $Id: items.js 1698 2008-02-23 20:48:30Z lww $
 
23
*/
 
24
 
 
25
MT.items.addItems = function(itemIds) {
 
26
        if(itemIds && itemIds.length > 0) {
 
27
                for(var i = 0, len = itemIds.length; i < len; i++) {
 
28
                        MT.items.addItem(itemIds[i]);
 
29
                }
 
30
        }
 
31
}
 
32
 
 
33
MT.items.addItem = function(itemId) {
 
34
        Ext.Ajax.request({
 
35
                method: 'GET',
 
36
                url: MT.tools.generateURL('add'),
 
37
                success: MT.items.onAddItemSuccess,
 
38
                failure: MT.items.onAddItemFailure,
 
39
                params: { object_id: itemId }
 
40
        });
 
41
}
 
42
 
 
43
MT.items.onAddItemSuccess = function(response) {
 
44
    var xml = response.responseXML;
 
45
    if(!MT.tools.xmlErrorCheck(xml)) {
 
46
                return; 
 
47
        }
 
48
    
 
49
    Ext.MessageBox.alert('Item Added', 'The item has been successfully added.');
 
50
}
 
51
 
 
52
MT.items.onAddItemFailure = function(response) {
 
53
        Ext.MessageBox.alert('Error', 'Could not add item. :-(');
 
54
}
 
55
 
 
56
MT.items.removeItems = function(itemIds, all) {
 
57
        if(itemIds && itemIds.length > 0) {
 
58
                for(var i = 0, len = itemIds.length; i < len; i++) {
 
59
                        MT.items.removeItem(itemIds[i], all);
 
60
                }
 
61
        }
 
62
}
 
63
 
 
64
MT.items.removeItem = function(itemId, all) {
 
65
        if(itemId == '0') {
 
66
                Ext.MessageBox.alert("Root container cannot be removed!");
 
67
        return;
 
68
    }
 
69
    
 
70
    if(all) {
 
71
                all_send = '1';
 
72
        } else {
 
73
                all_send = '0';
 
74
        }
 
75
    
 
76
        Ext.Ajax.request({
 
77
                method: 'GET',
 
78
                url: MT.tools.generateURL('remove', {object_id: itemId, all: all_send}, true),
 
79
                success: MT.items.onRemoveItemSuccess,
 
80
                failure: MT.items.onRemoveItemFailure
 
81
        });
 
82
}
 
83
 
 
84
MT.items.onRemoveItemSuccess = function(response) {
 
85
        MT.layout.DataGrid.loadData();
 
86
        MT.layout.GridToolbar.disableButtons();
 
87
}
 
88
 
 
89
MT.items.onRemoveItemFailure = function(response) {
 
90
        Ext.MessageBox.alert('Error', 'Could not remove item. :-(');
 
91
}