1420162a |
1 | var selected_file = null; |
2 | var rm_cb = { |
3 | success: function(o) { |
4 | if(o.responseText){ |
5 | repository_client.files[o.responseText]--; |
6 | selected_file.parentNode.removeChild(selected_file); |
7 | } |
8 | } |
9 | } |
10 | function rm_file(id, name, context) { |
11 | if (confirm(filemanager.strdelete)) { |
12 | var trans = YAHOO.util.Connect.asyncRequest('POST', |
13 | moodle_cfg.wwwroot+'/repository/ws.php?action=delete&itemid='+id, |
14 | rm_cb, |
15 | 'title='+name+'&client_id='+filemanager.clientid |
16 | ); |
17 | selected_file = context.parentNode; |
18 | } |
19 | } |
20 | function fp_callback(obj) { |
21 | var list = document.getElementById('draftfiles-'+obj.client_id); |
22 | var html = '<li><a href="'+obj['url']+'"><img src="'+obj['icon']+'" class="icon" /> '+obj['file']+'</a> '; |
23 | html += '<a href="###" onclick=\'rm_file('+obj['id']+', "'+obj['file']+'", this)\'><img src="'+filemanager.deleteicon+'" class="iconsmall" /></a>'; |
24 | html += '</li>'; |
71588976 |
25 | if(obj.maxfileslimit){ |
26 | var btn = document.getElementById('btnadd-'+obj.client_id); |
27 | btn.onclick = function(){return false;}; |
28 | btn.innerHTML = mstr.repository.nomorefiles; |
29 | } |
1420162a |
30 | list.innerHTML += html; |
31 | } |
32 | function callpicker(el_id, client_id, itemid) { |
33 | var picker = document.createElement('DIV'); |
34 | picker.id = 'file-picker-'+client_id; |
35 | picker.className = 'file-picker'; |
36 | document.body.appendChild(picker); |
37 | var el=document.getElementById(el_id); |
38 | var params = {}; |
39 | params.env = 'filemanager'; |
40 | params.maxbytes = filemanager.maxbytes; |
41 | params.maxfiles = filemanager.maxfiles; |
42 | params.itemid = itemid; |
43 | params.target = el; |
44 | params.callback = fp_callback; |
45 | var fp = open_filepicker(client_id, params); |
46 | return false; |
71588976 |
47 | } |