pscript['onload_File Browser'] = function(){ // header and toolbar var h = new PageHeader('fb_header','File Management','Upload and share your file across users'); //$dh(h.toolbar); $y(h.toolbar,{width:'0px', height:'0px'}) if(!pscript.fb_tree) pscript.create_browser_tree(); pscript.get_root_file_grps(); pscript.create_action_widget(); pscript.create_display_div(); pscript.create_n_file_grp_obj(); pscript.create_n_file_obj(); pscript.create_attach_obj(); pscript.get_all_roles(); $ds(pscript.gen_div); $dh(pscript.grp_div); $dh(pscript.file_div); $ds($i('unselect')); } // Get all roles pscript.get_all_roles = function(){ if(!pscript.fg_all_roles){ var callback = function(r,rt){ pscript.fg_all_roles = r.message ? r.message : ''; pscript.create_share_obj(); pscript.fg_share.make(r.message); } $c_obj('File Browser Control','get_all_roles','',callback); } } // Creating File Browser tree. pscript.create_browser_tree = function() { $i('fb_tree_div').innerHTML = ''; var tree = new Tree($i('fb_tree_div'), '100%'); pscript.fb_tree = tree; pscript.fb_tree.std_onclick = function(node) { /*pass*/ } // on click pscript.fb_tree.std_onexp = function(node) { /*PASS*/ } // on expand $ds(pscript.gen_div); $dh(pscript.grp_div); $dh(pscript.file_div); $dh(pscript.f_file_display); } // Creating a Share Privilege object. pscript.create_share_obj = function(){ var d = new Dialog(400,400,'Assign Privilege'); var me = d; d.inputs = {}; d.make_body([ ['HTML','Privilege','
'], ['Button','Update'] ]); d.make = function(all_roles){ optn_header = make_table('fg_share_div',1,2,'100%',['60%','40%'],{padding:'4px'}); for(var c=0;c<2;c++){ if(c==1) $td(optn_header,0,c).innerHTML = 'Privilege'; else $td(optn_header,0,c).innerHTML = 'Role'; } optn_tbl = make_table('fg_share_div',all_roles.length,2,'100%',['60%','40%'],{padding:'4px'}); for(var i=0;i'; var ul_form = div.childNodes[0]; this.upload_div.ul_form = ul_form; var f_list = []; // file data var inp_fdata = $a_input($a(ul_form,'span'),'file',{name:'filedata'}); var inp_btn = $a_input($a(ul_form,'span'),'hidden',{name:'cmd'}); inp_btn.value = 'upload_many'; var inp = $a_input($a(ul_form,'span'),'hidden',{name:'form_name'}); inp.value = 'File Browser'; var inp = $a_input($a(ul_form,'span'),'submit'); inp.value = 'Upload'; this.inp_file = $a_input($a(ul_form,'span'),'hidden',{name:'file_id'}); this.file_det = $a_input($a(ul_form,'span'),'hidden',{name:'file_det'}); inp_btn.onclick = function(){ pscript.set_file_det_value(pscript.attach_obj,pscript.n_file); } } //download link this.make_dl_area = function(){ var me = this; var download_tbl = make_table(this.download_div,1,2,'100%',['70%','30%']); var download_link = $a($td(download_tbl,0,0),'a','link_type'); this.download_div.download_link = download_link; var remove_link = $a($td(download_tbl,0,1),'span','link_type',{textAlign:'right',marginLeft:'20px'}); remove_link.innerHTML = 'Remove'; this.download_div.remove_link = remove_link; } this.show_as = function(obj,parent,edit,dict){ var me = this; // add to parent if(me.wrapper.parentNode) me.wrapper.parentNode.removeChild(me.wrapper); parent.appendChild(me.wrapper); $ds(me.wrapper); if(edit){ pscript.set_file_det_value(pscript.attach_obj,pscript.n_file); me.inp_file.value = dict.name ? dict.name : ''; if(dict.file_list){ $dh(me.upload_div); $ds(me.download_div); } else{ $ds(me.upload_div); $dh(me.download_div); } // download me.download_div.download_link.innerHTML = dict.file_list ? dict.file_list.split(',')[0] : ''; me.download_div.download_link.onclick = function(){ this.href = repl('cgi-bin/getfile.cgi?ac=%(acc)s&name=%(f_nm)s',{acc:session.account_name, f_nm:pscript.f_cur_node_file}); this.target = "_blank"; } // remove me.download_div.remove_link.onclick = function(){ $c_obj('File Browser Control','remove_file',docstring(dict),function(r,rt){ pscript.n_file.show(0,'frm_remove'); }); $ds(me.upload_div); $dh(me.download_div); } } else{ $ds(me.upload_div); $dh(me.download_div); me.inp_file.value = ''; pscript.set_file_det_value(pscript.attach_obj,pscript.n_file); } } } // Get all root file groups(where Parent Group is null). pscript.get_root_file_grps = function(){ if (pscript.fb_tree){ pscript.fb_tree.body.innerHTML = ''; } var callback1 = function(r,rt){ var cl = r.message ? r.message : ''; var n = pscript.fb_tree.allnodes[cl]; var has_children = true; for(var i=0; i'] ]); delete_dialog.y_btn = $a($i('delete_record'),'button','button'); delete_dialog.y_btn.innerHTML = 'Ok'; delete_dialog.y_btn.onclick = function(){ delete_dialog.widgets['Response'].innerHTML = 'Deleting...'; var args = {}; args.dt = delete_dialog.dt; args.dn = delete_dialog.dn; var callback1 = function(r,rt){ delete_dialog.onhide = delete_dialog.callback; delete_dialog.hide(); //refreshing node pscript.load_child_nodes(); } $c_obj(sdt,'delete',docstring(args),callback1); } delete_dialog.n_btn = $a($i('delete_record'),'button','button'); delete_dialog.n_btn.innerHTML = 'Cancel'; delete_dialog.n_btn.onclick = function(){ delete_dialog.widgets['Response'].innerHTML = ''; delete_dialog.onhide = ''; delete_dialog.hide(); } delete_dialog.widgets['Message'].innerHTML = 'Note: All data will be deleted permanantly. Do you want to continue?'; pscript.delete_dialog = delete_dialog; } //if(!delete_dialog.display) delete_dialog.show(); pscript.delete_dialog.show(); pscript.delete_dialog.widgets['Response'].innerHTML = ''; pscript.delete_dialog.sdt = sdt; pscript.delete_dialog.dt=dt; pscript.delete_dialog.dn=dn; pscript.delete_dialog.callback = callback; } pscript.remove_child_nodes = function(parent){ var len = parent.childNodes.length; if(len){ for(l=0; l