3
MediaTomb - http://www.mediatomb.cc/
5
tree-xml.js - this file is part of MediaTomb.
7
Copyright (C) 2007-2008 Jan Habermann <jan.habermann@gmail.com>
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.
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.
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.
22
$Id: tree-xml.js 1698 2008-02-23 20:48:30Z lww $
25
Ext.tree.TreeLoaderXML = function(config) {
27
this.requestMethod = "GET";
28
Ext.apply(this, config);
33
"loadexception" : true
36
Ext.extend(Ext.tree.TreeLoaderXML, Ext.tree.TreeLoader, {
37
getParams: function(node){
38
var buf = [], bp = this.baseParams;
40
if(typeof bp[key] != "function"){
41
buf.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&");
44
buf.push("parent_id=", encodeURIComponent(node.id));
47
processResponse : function(response, node, callback) {
49
var o = this.parseResponseXML(response.responseXML);
50
for(var i = 0, len = o.length; i < len; i++) {
51
var n = this.createNode(o[i]);
56
if(typeof callback == "function") {
60
this.handleFailure(response);
63
parseResponseXML : function(responseXML) {
66
var rootEl = MT.tools.xmlGetElement(responseXML, 'containers');
67
var els = rootEl.getElementsByTagName('container');
69
for(var i = 0, len = els.length; i < len; i++) {
71
id: MT.tools.xmlGetAttribute(els[i], 'id'),
72
text: MT.tools.xmlGetText(els[i]),
73
leaf: (MT.tools.xmlGetAttribute(els[i], 'childCount')) > 0 ? false : true
81
// Extens tree with auto-refresh
83
Ext.override(Ext.tree.AsyncTreeNode, {
84
startAutoRefresh : function(interval, refreshNow) {
88
if(this.autoRefreshProcId) {
89
clearInterval(this.autoRefreshProcId);
91
this.autoRefreshProcId = setInterval(this.reload.createDelegate(this), interval*1000);
93
stopAutoRefresh : function() {
94
if(this.autoRefreshProcId) {
95
clearInterval(this.autoRefreshProcId);