1window.onbeforeunload = function() { }; 2var CurrentDWikiUser = opener.oDokuWiki_FCKEditorInstance.dwiki_user; // use this variable to pass into frame (frmupload.html) 3var CurrentDWikiClient = opener.oDokuWiki_FCKEditorInstance.dwiki_client; // use this variable to pass into frame (frmupload.html) 4var isLocalDwikiBrowser = opener.oDokuWiki_FCKEditorInstance.isLocalDwikiBrowser ? true : false; 5var CreateDwikiFolder = opener.oDokuWiki_FCKEditorInstance.dwiki_create_folder; // use this variable to pass into frame (frmupload.html) 6var DwikiFNencode = opener.oDokuWiki_FCKEditorInstance.dwiki_fnencode; 7var isDwikiUrlExtern = opener.oDokuWiki_FCKEditorInstance.isUrlExtern ? true: false; 8var DwikiImageUploadAllowedExtensions = opener.oDokuWiki_FCKEditorInstance.imageUploadAllowedExtensions; 9var isDwikiMediaFile = opener.oDokuWiki_FCKEditorInstance.isDwikiMediaFile; 10var isDwikiImage = opener.oDokuWiki_FCKEditorInstance.isDwikiImage; 11var fbsz_increment =opener.oDokuWiki_FCKEditorInstance.fbsz_increment; 12 13 14// Automatically detect the correct document.domain (#1919). 15(function() 16{ 17 var d = document.domain ; 18 19 while ( true ) 20 { 21 // Test if we can access a parent property. 22 try 23 { 24 var test = window.opener.document.domain ; 25 break ; 26 } 27 catch( e ) 28 {} 29 30 // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... 31 d = d.replace( /.*?(?:\.|$)/, '' ) ; 32 33 if ( d.length == 0 ) 34 break ; // It was not able to detect the domain. 35 36 try 37 { 38 document.domain = d ; 39 } 40 catch (e) 41 { 42 break ; 43 } 44 } 45})() ; 46 47 48window.onload = function() 49{ 50 window.top.IsLoadedCreateFolder = true ; 51 setupLanguage(); 52 53 if(CurrentDWikiUser == 'visitor' || isLocalDwikiBrowser || !CurrentDWikiUser) { 54 document.getElementById("btn__create_folder").disabled = true; 55 document.getElementById("create_folder").innerHTML = ""; 56 } 57 else document.getElementById("create_folder").style.display='block'; 58 59 if(CreateDwikiFolder == 'n') { 60 document.getElementById('create_folder').style.display = 'none'; 61} 62 63 if(navigator.userAgent.match(/macintosh/i)) { 64 document.getElementById('is_mac').innerHTML = 'Cmd'; 65 } 66 if(navigator.userAgent.indexOf('MSIE') != -1 || navigator.userAgent.indexOf('Trident') != -1) { 67 document.getElementById('adustfbbuttons').style.display='none'; 68 } 69 if(fbsz_increment > 0) { 70 var isIE = navigator.userAgent.indexOf('MSIE') >= 0 ? true : false; 71 var fbl = document.getElementById("frmResourcesList"); 72 var frmfolders = document.getElementById("frmFolders"); 73 fbl['height'] = 400 + (400*(fbsz_increment/100)); 74 frmfolders['height'] = 490 + (490*(fbsz_increment/100)); 75 if(!isIE) { 76 var fbaf = document.getElementById("frmActualFolder"); 77 var width = 750 + (750*(fbsz_increment/100)); 78 fbl['width'] = width; 79 fbaf['width'] = width; 80 frmfolders['width'] = 180 + (180*(fbsz_increment/100)); 81 var fbmatter = document.getElementById("bottom_matter"); 82 fbmatter.style.width = width; 83 } 84 var whichsz = document.getElementById("adjfbsz" + fbsz_increment); 85 whichsz.checked=true; 86 87 } 88} 89function GetUrlParam( paramName ) 90{ 91 var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ; 92 var oMatch = oRegex.exec( window.top.location.search ) ; 93 94 if ( oMatch && oMatch.length > 1 ) { 95 // alert(paramName + ' ' + decodeURIComponent( oMatch[1] ) ); 96 return decodeURIComponent( oMatch[1] ) ; 97 // return dwikiUTF8_decodeFN( oMatch[1],DwikiFNencode); 98 } 99 else 100 return '' ; 101} 102 103var oConnector = new Object() ; 104oConnector.CurrentFolder = '/' ; 105 106var sConnUrl = GetUrlParam( 'Connector' ) ; 107 108// Gecko has some problems when using relative URLs (not starting with slash). 109if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 ) 110 sConnUrl = window.location.href.replace( /browser.html.*$/, '' ) + sConnUrl ; 111 112oConnector.ConnectorUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' ) ; 113 114var sServerPath = GetUrlParam( 'ServerPath' ) ; 115 116if ( sServerPath.length > 0 ) 117 oConnector.ConnectorUrl += 'ServerPath=' + dwikiUTF8_encodeFN(sServerPath, 'url') + '&' ; 118 119oConnector.ResourceType = GetUrlParam( 'Type' ) ; 120oConnector.ShowAllTypes = ( oConnector.ResourceType.length == 0 ) ; 121 122if ( oConnector.ShowAllTypes ) 123 oConnector.ResourceType = 'File' ; 124 125oConnector.SendCommand = function( command, params, callBackFunction ) 126{ 127 /* requires safe_ascii */ 128 129 var sUrl = this.ConnectorUrl + 'Command=' + command ; 130 sUrl += '&Type=' + this.ResourceType ; 131 sUrl += '&CurrentFolder=' + dwikiUTF8_encodeFN(this.CurrentFolder, DwikiFNencode); 132 133// sUrl += '&CurrentFolder=' + encodeURIComponent( this.CurrentFolder ) ; 134 135 if ( params ) sUrl += '&' + params ; 136 137 // opener takes its values from onload of helper.php 138 // alert('opener='+opener.oDokuWiki_FCKEditorInstance.dwiki_usergroups); 139 140 // sUrl += '&DWFCK_Browser=local'; // this opens the local browser 141 142 if(isLocalDwikiBrowser) { 143 sUrl += '&DWFCK_Browser=local'; 144 } 145 if(CurrentDWikiClient) { 146 sUrl += '&DWFCK_Client=' + CurrentDWikiClient; 147 } 148 if(CurrentDWikiClient) { 149 sUrl += '&DWFCK_usergrps=' + opener.oDokuWiki_FCKEditorInstance.dwiki_usergroups; 150 } 151 152 // Add a random salt to avoid getting a cached version of the command execution 153 sUrl += '&uuid=' + new Date().getTime() ; 154 155 var oXML = new FCKXml() ; 156 157 if ( callBackFunction ) 158 oXML.LoadUrl( sUrl, callBackFunction ) ; // Asynchronous load. 159 else 160 return oXML.LoadUrl( sUrl ) ; 161 162 return null ; 163} 164oConnector.CheckError = function( responseXml ) 165{ 166 var iErrorNumber = 0 ; 167 var oErrorNode = responseXml.SelectSingleNode( 'Connector/Error' ) ; 168 169 if ( oErrorNode ) 170 { 171 iErrorNumber = parseInt( oErrorNode.attributes.getNamedItem('number').value, 10 ) ; 172 173 switch ( iErrorNumber ) 174 { 175 case 0 : 176 break ; 177 case 1 : // Custom error. Message placed in the "text" attribute. 178 //alert( oErrorNode.attributes.getNamedItem('text').value ) ; 179 alert(translateErrorAny(oErrorNode.attributes.getNamedItem('text').value )) ; 180 break ; 181 case 101 : 182 alert(translateItem('FileBrowserError_101', 'Folder already exists' )); 183 break ; 184 case 102 : 185 alert(translateItem('FileBrowserError_102', 'Invalid folder name' )); 186 break ; 187 case 103 : 188 alert(translateItem('FileBrowserError_103', 'You have no permissions to create the folder' )); 189 break ; 190 case 110 : 191 alert(translateItem('FileBrowserError_110', 'Unknown error creating folder' )); 192 break ; 193 case 204 : 194 alert(translateItem('FileBrowserError_204', 'Unable to delete the selected file' )); 195 break ; 196 case 205 : 197 alert(translateItem('FileBrowserError_205', 198 'Unable to rename the selected file; check your directory/write permisssions' )); 199 break ; 200 default : 201 var err_default = translateItem('FileBrowserError_default', 'Error on your request. Error number: ' ); 202 alert(err_default + iErrorNumber ) ; 203 break ; 204 } 205 } 206 return iErrorNumber ; 207} 208 209var oIcons = new Object() ; 210 211oIcons.AvailableIconsArray = [ 212 'ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js', 213 'mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip' ] ; 214 215oIcons.AvailableIcons = new Object() ; 216 217for ( var i = 0 ; i < oIcons.AvailableIconsArray.length ; i++ ) 218 oIcons.AvailableIcons[ oIcons.AvailableIconsArray[i] ] = true ; 219 220oIcons.GetIcon = function( fileName ) 221{ 222 var sExtension = fileName.substr( fileName.lastIndexOf('.') + 1 ).toLowerCase() ; 223 224 if ( this.AvailableIcons[ sExtension ] == true ) 225 return sExtension ; 226 else 227 return 'default.icon' ; 228} 229 230function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) 231{ 232 // alert( errorNumber +"\nurl="+ fileUrl+"\nfname="+ fileName+"\nmsg="+ customMsg ); 233 fileUrl = fileUrl.replace(/.*?(media|userfiles\/image|file)\//,""); 234 //alert(fileUrl); 235 236 if (errorNumber == "1" || parseInt(errorNumber) > 300) 237 window.frames['frmUpload'].OnUploadCompleted( errorNumber, customMsg ) ; 238 else { 239 window.frames['frmUpload'].OnUploadCompleted( errorNumber, fileName ) ; 240 fileUrl = encodeURIComponent(fileUrl); 241 opener.ckged_setmedia(fileUrl,"") ; 242 } 243} 244 245function fbsz_inc(val) { 246 var d = new Date(); 247 if(val == 'reset') { 248 document.cookie ="fbsz=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; 249 alert(translateItem('DlgFileBrowserResizeMsg', "The file browser window will be reset to its default size after your page is reloaded into the editor.")); 250 // alert("The file browser window will be reset to its default size after your page is reloaded into the editor.") 251 return; 252 } 253 d.setTime(d.getTime() + 365*24*60*60*1000); 254 var expires = "expires="+d.toUTCString(); 255 document.cookie = "fbsz=" + val + "; " + expires + "; path=/"; 256 alert("The file browser window will be re-sized by "+ val + "% after your page is reloaded into the editor.") 257} 258 259function fb_sort(type) { 260 window.frames['frmResourcesList'].sortFileList(type); 261} 262function fb_search(f) { 263 window.frames['frmResourcesList'].findFiles(f.fsearch.value); 264} 265function fb_sz_date_order(el) { 266 window.frames['frmResourcesList'].reverseListOrder(el.checked); 267} 268 269function onSubmitFn() { 270 alert("use the button to submit"); 271 return false; 272} 273