1 | <!-- |
---|
2 | * FCKeditor - The text editor for internet |
---|
3 | * Copyright (C) 2003-2005 Frederico Caldeira Knabben |
---|
4 | * |
---|
5 | * Licensed under the terms of the GNU Lesser General Public License: |
---|
6 | * http://www.opensource.org/licenses/lgpl-license.php |
---|
7 | * |
---|
8 | * For further information visit: |
---|
9 | * http://www.fckeditor.net/ |
---|
10 | * |
---|
11 | * "Support Open Source software. What about a donation today?" |
---|
12 | * |
---|
13 | * File Name: frmresourceslist.html |
---|
14 | * This page shows all resources available in a folder in the File Browser. |
---|
15 | * |
---|
16 | * File Authors: |
---|
17 | * Frederico Caldeira Knabben (fredck@fckeditor.net) |
---|
18 | --> |
---|
19 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
---|
20 | <html> |
---|
21 | <head> |
---|
22 | <link href="browser.css" type="text/css" rel="stylesheet"> |
---|
23 | <script type="text/javascript" src="js/common.js"></script> |
---|
24 | <script language="javascript"> |
---|
25 | |
---|
26 | var oListManager = new Object() ; |
---|
27 | |
---|
28 | oListManager.Init = function() |
---|
29 | { |
---|
30 | this.Table = document.getElementById('tableFiles') ; |
---|
31 | } |
---|
32 | |
---|
33 | oListManager.Clear = function() |
---|
34 | { |
---|
35 | // Remove all other rows available. |
---|
36 | while ( this.Table.rows.length > 0 ) |
---|
37 | this.Table.deleteRow(0) ; |
---|
38 | } |
---|
39 | |
---|
40 | oListManager.AddFolder = function( folderName, folderPath ) |
---|
41 | { |
---|
42 | // Create the new row. |
---|
43 | var oRow = this.Table.insertRow(-1) ; |
---|
44 | |
---|
45 | // Build the link to view the folder. |
---|
46 | var sLink = '<a href="#" onclick="OpenFolder(\'' + folderPath + '\');return false;">' ; |
---|
47 | |
---|
48 | // Add the folder icon cell. |
---|
49 | var oCell = oRow.insertCell(-1) ; |
---|
50 | oCell.width = 16 ; |
---|
51 | oCell.innerHTML = sLink + '<img alt="" src="images/Folder.gif" width="16" height="16" border="0"></a>' ; |
---|
52 | |
---|
53 | // Add the folder name cell. |
---|
54 | oCell = oRow.insertCell(-1) ; |
---|
55 | oCell.noWrap = true ; |
---|
56 | oCell.colSpan = 2 ; |
---|
57 | oCell.innerHTML = ' ' + sLink + folderName + '</a>' ; |
---|
58 | } |
---|
59 | |
---|
60 | oListManager.AddFile = function( fileName, fileUrl, fileSize ) |
---|
61 | { |
---|
62 | // Create the new row. |
---|
63 | var oRow = this.Table.insertRow(-1) ; |
---|
64 | |
---|
65 | //This is the improvement to add exact URL of the file (parahat) |
---|
66 | var sHostname = window.location.hostname; |
---|
67 | if(window.location.port.length > 0) |
---|
68 | sHostname += ":" + window.location.port; |
---|
69 | |
---|
70 | // Build the link to view the folder. |
---|
71 | |
---|
72 | var sLink = '<a href="#" onclick="OpenFile(\'http://' + sHostname + fileUrl + '\');return false;">' ; |
---|
73 | |
---|
74 | // Get the file icon. |
---|
75 | var sIcon = oIcons.GetIcon( fileName ) ; |
---|
76 | |
---|
77 | // Add the file icon cell. |
---|
78 | var oCell = oRow.insertCell(-1) ; |
---|
79 | oCell.width = 16 ; |
---|
80 | oCell.innerHTML = sLink + '<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"></a>' ; |
---|
81 | |
---|
82 | // Add the file name cell. |
---|
83 | oCell = oRow.insertCell(-1) ; |
---|
84 | oCell.innerHTML = ' ' + sLink + fileName + '</a>' ; |
---|
85 | |
---|
86 | // Add the file size cell. |
---|
87 | oCell = oRow.insertCell(-1) ; |
---|
88 | oCell.noWrap = true ; |
---|
89 | oCell.align = 'right' ; |
---|
90 | oCell.innerHTML = ' ' + fileSize + ' KB' ; |
---|
91 | } |
---|
92 | |
---|
93 | function OpenFolder( folderPath ) |
---|
94 | { |
---|
95 | // Load the resources list for this folder. |
---|
96 | window.parent.frames['frmFolders'].LoadFolders( folderPath ) ; |
---|
97 | } |
---|
98 | |
---|
99 | function OpenFile( fileUrl ) |
---|
100 | { |
---|
101 | window.top.opener.SetUrl( fileUrl ) ; |
---|
102 | window.top.close() ; |
---|
103 | window.top.opener.focus() ; |
---|
104 | } |
---|
105 | |
---|
106 | function LoadResources( resourceType, folderPath ) |
---|
107 | { |
---|
108 | oListManager.Clear() ; |
---|
109 | oConnector.ResourceType = resourceType ; |
---|
110 | oConnector.CurrentFolder = folderPath |
---|
111 | oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack ) ; |
---|
112 | } |
---|
113 | |
---|
114 | function Refresh() |
---|
115 | { |
---|
116 | LoadResources( oConnector.ResourceType, oConnector.CurrentFolder ) ; |
---|
117 | } |
---|
118 | |
---|
119 | function GetFoldersAndFilesCallBack( fckXml ) |
---|
120 | { |
---|
121 | if ( oConnector.CheckError( fckXml ) != 0 ) |
---|
122 | return ; |
---|
123 | |
---|
124 | // Get the current folder path. |
---|
125 | var oNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ; |
---|
126 | var sCurrentFolderPath = oNode.attributes.getNamedItem('path').value ; |
---|
127 | var sCurrentFolderUrl = oNode.attributes.getNamedItem('url').value ; |
---|
128 | |
---|
129 | // Add the Folders. |
---|
130 | var oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ; |
---|
131 | for ( var i = 0 ; i < oNodes.length ; i++ ) |
---|
132 | { |
---|
133 | var sFolderName = oNodes[i].attributes.getNamedItem('name').value ; |
---|
134 | oListManager.AddFolder( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ; |
---|
135 | } |
---|
136 | |
---|
137 | // Add the Files. |
---|
138 | var oNodes = fckXml.SelectNodes( 'Connector/Files/File' ) ; |
---|
139 | for ( var i = 0 ; i < oNodes.length ; i++ ) |
---|
140 | { |
---|
141 | var sFileName = oNodes[i].attributes.getNamedItem('name').value ; |
---|
142 | var sFileSize = oNodes[i].attributes.getNamedItem('size').value ; |
---|
143 | oListManager.AddFile( sFileName, sCurrentFolderUrl + sFileName, sFileSize ) ; |
---|
144 | } |
---|
145 | } |
---|
146 | |
---|
147 | window.onload = function() |
---|
148 | { |
---|
149 | oListManager.Init() ; |
---|
150 | window.top.IsLoadedResourcesList = true ; |
---|
151 | } |
---|
152 | </script> |
---|
153 | </head> |
---|
154 | <body class="FileArea" bottomMargin="10" leftMargin="10" topMargin="10" rightMargin="10"> |
---|
155 | <table id="tableFiles" cellSpacing="1" cellPadding="0" width="100%" border="0"> |
---|
156 | </table> |
---|
157 | </body> |
---|
158 | </html> |
---|