forked from slash2009/XWMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
images.js
209 lines (180 loc) · 5.59 KB
/
images.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
var coverTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{title}">',
'<div class="thumb"><img src="{thumb}"></div>',
'<span class="x-editable">{title}</span></div>',
'</tpl>'
);
var fanartTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="{title}">',
'<div class="fanart"><img src="{thumb}"></div>',
'<span class="x-editable">{title}</span></div>',
'</tpl>'
);
window.loadingMask = new Ext.LoadMask(Ext.getBody(), {msg:"Downloading file, please wait..."});
function ChangeImages(record) {
var CoverUrlList = record.data.MovieCoverUrl;
var FanartUrlList = record.data.MovieFanartUrl;
var storeCovers = new Ext.data.ArrayStore({
data: CoverUrlList,
autoLoad: true,
fields: ['thumb','url', 'title', 'currentCover']
});
var storeFanarts = new Ext.data.ArrayStore({
data: FanartUrlList,
autoLoad: true,
fields: ['thumb','url', 'title', 'currentFanart']
});
function changeXBMCCover() {
loadingMask.show();
var selNode = viewCovers.getSelectedRecords();
// selNode contains only one item
downloadXBMCFile(selNode[0].data.url, record.data.thumbnail );
//update main Movie form
Ext.getCmp('cover').refreshMe();
loadingMask.hide();
}
function changeXBMCFanart() {
loadingMask.show();
var selNode = viewFanarts.getSelectedRecords();
// selNode contains only one item
downloadXBMCFile(selNode[0].data.url, record.data.fanart);
//update main Movie form
Ext.getCmp('fanart').refreshMe();
loadingMask.hide();
}
var viewFanarts = new Ext.DataView({
tpl: fanartTpl,
autoHeight:true,
id: 'tabfanarts',
multiSelect: true,
overClass:'x-view-over',
itemSelector:'div.thumb-wrap',
emptyText: 'No images to display',
store: storeFanarts,
title: 'Fanarts',
listeners: {
'selectionchange': function () {
var selNode = viewFanarts.getSelectedRecords();
if (selNode[0].data.title != "Current") {
Ext.getCmp('choosebutton').enable();
}
else { Ext.getCmp('choosebutton').disable()}
}
}
})
var viewCovers = new Ext.DataView({
tpl: coverTpl,
autoHeight:true,
id: 'tabcovers',
singleSelect: true,
//width:435,
frame:true,
overClass:'x-view-over',
itemSelector:'div.thumb-wrap',
emptyText: 'No images to display',
store: storeCovers,
title: 'Covers',
listeners: {
'selectionchange': function () {
var selNode = viewCovers.getSelectedRecords();
if (selNode[0].data.title != "Current") {
Ext.getCmp('choosebutton').enable();
}
else { Ext.getCmp('choosebutton').disable()}
}
}
})
var imagePanel = new Ext.TabPanel({
id:'images-view',
bodyStyle: 'background-color:#777777',
layoutOnTabChange: true,
//width:435,
activeTab:0,
autoHeight:true,
title:'Simple DataView',
items: [viewCovers, viewFanarts]
})
var preview = new Ext.Container ({
id: 'preview',
border: 0,
autoEl: {tag: 'img', src: "../images/defaultMovieFanart.jpg"},
updateSrc :function(v){
this.el.dom.src = v
}
});
var fp = new Ext.FormPanel({
fileUpload: true,
width: 500,
height: 300,
frame: true,
title: 'Upload Form',
//autoHeight: true,
labelWidth: 100,
defaults: {width: 200},
items: [{
xtype: 'textfield',
id: 'myUrl',
fieldLabel: 'From URL'
},{
xtype: 'textfield',
id:'myLocal',
inputType: 'file',
fieldLabel: 'From Local'
}, preview],
buttons: [{
text: 'Close',
handler: function(){
uploadWin.hide();
}
},{
text: 'Preview',
handler: function(){
if (Ext.getCmp('myUrl').getValue() != ""){
var v = Ext.getCmp('myUrl').getValue();
}
else {
var v = Ext.getCmp('myLocal').getValue();
console.log(Ext.getCmp('myLocal').files[0].getAsBinary());
}
preview.updateSrc(v);
fp.getForm().submit({url: '../test'})
}
}]
});
var uploadWin = new Ext.Window({
layout:'fit',
width:500,
height:300,
closeAction:'hide',
plain: true,
items: [fp]
});
var winImages = new Ext.Window({
layout:'fit',
margins: '5 5 5 0',
width:600,
height:400,
title: 'Change cover and Fanart',
closeAction:'hide',
//plain: true,
items: imagePanel,
autoScroll: true,
buttons: [{
text: 'Choose',
disabled: true,
id: 'choosebutton',
handler: function(){
if (imagePanel.getActiveTab().id == 'tabcovers'){changeXBMCCover()};
if (imagePanel.getActiveTab().id == 'tabfanarts'){changeXBMCFanart()};
}
},{
text: 'Done',
handler: function(){
winImages.hide();
}
}]
});
winImages.show()
}