+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+ <head>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <title>Site browser</title>
+ <link rel="stylesheet" href="browser.css" type="text/css" media="screen" title="Browser style" charset="utf-8" />
+ <script type="text/javascript" language="javascript" charset="utf-8" src="epoz_script_detect.js"></script>
+ <script type="text/javascript" language="javascript" charset="utf-8" src="javascript_events_api.js"></script>
+ <script type="text/javascript" language="javascript" charset="utf-8" src="sarissa.js"></script>
+ <script type="text/javascript" language="javascript" charset="utf-8">
+ // <![CDATA[
+ /* keyboard keycodes */
+ var keyLeft = 37, keyUp = 38, keyRight = 39, keyDown = 40, keyEnter = 13;
+
+ /* globals variables */
+ var finder, finderContent, cellWidth, currentColumn;
+ var scrollbarPlaceholder_offset = 0;
+ var scrollXStep = 25, scrollTimeStep = 10;
+ var ressourceType = GetUrlParam('Type');
+ var sConnUrl = GetUrlParam( 'Connector' ) ;
+ var baseDepth = 0;
+ if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
+ sConnUrl = window.location.href.replace( /browser.html.*$/, '' ) + sConnUrl ;
+ var getWindowWidth = (window.innerWidth != undefined) ? function(){return window.innerWidth;} : function(){return document.body.parentElement.clientWidth;};
+ var getWindowHeight = (window.innerHeight != undefined) ? function(){return window.innerHeight;} : function(){return document.body.parentElement.clientHeight;};
+
+
+ function _initBrowser(){
+ finder = document.getElementById('finder');
+ finder.colCpt = 3; // column counter;
+ finderContent = document.getElementById('finderContent');
+ cellWidth = Math.floor(getWindowWidth() / 3);
+
+ addListener(window, 'resize', resizeBrowser);
+ addListener(finder, 'click', onClickHandler);
+ addListener(finder, 'dblclick', onDblClickHandler);
+ var path = GetUrlParam('path');
+ path = (path) ? path : '/';
+ var level = -1;
+ for (var i = 0 ; i<path.length ; i++){
+ if (path.charAt(i) == '/')
+ level += 1;
+ }
+ baseDepth = level;
+
+ populateBrowser('ls', path);
+
+ if (browser.isGecko)
+ document.body.style.overflowX = 'scroll';
+ resizeBrowser();
+ scrollbarPlaceholder_offset = (window.scrollMaxY) ? window.scrollMaxY : document.body.offsetHeight - document.body.clientHeight;
+ resizeBrowser();
+ finder.style.width = cellWidth * 3 + "px";
+ }
+ addListener(window, 'load', _initBrowser);
+ addListener(document, 'keydown', onKeydownHandler);
+
+ function onClickHandler(evt) {
+ var li = getTargetedObject(evt);
+ switch (li.tagName) {
+ case 'IMG':
+ if (li.width != 16) // this img is a preview thumbnail.
+ return;
+ li = li.parentNode;
+ case 'LI':
+ // click on the current selected row
+ if (currentColumn == li.parentNode && currentColumn.currentRow == li)
+ return;
+
+ currentColumn = li.parentNode;
+ // hightlight row
+ if (currentColumn.currentRow) {
+ currentColumn.currentRow.className = currentColumn.currentRow.className.replace('-selected', '');
+ }
+ var command = li.className == 'folderish' ? 'ls' : 'info';
+ li.className += '-selected';
+ currentColumn.currentRow = li;
+
+ populateBrowser(command, li.path);
+ }
+ }
+
+ function onDblClickHandler(evt) {
+ var li = getTargetedObject(evt);
+
+ if(li.tagName != 'LI') {
+ if (li.tagName == 'IMG' && li.parentNode.tagName == 'LI')
+ li = t.parentNode;
+ else
+ return;
+ }
+ switch(window.parent.name) {
+ case 'FCKeditorDialog_PlinnImage' :
+ if (li.className == 'contentish-selected') {
+ window.parent.updateOrInsertImage(li.link);
+ window.close();
+ }
+ break;
+ case 'FCKBrowseWindow' :
+ window.opener.SetUrl(li.link);
+ window.close();
+ break;
+ }
+ }
+
+ function onKeydownHandler(evt) {
+ evt = (evt) ? evt : window.event;
+ if(!currentColumn) currentColumn = finder.getElementsByTagName('ul')[0];
+ if(!currentColumn.currentRow) {
+ raiseMouseEvent(currentColumn.firstChild,'click');
+ return;
+ }
+
+ var ob, evtType='click';
+ switch (evt.keyCode) {
+ case keyUp :
+ ob = currentColumn.currentRow.previousSibling;
+ break;
+ case keyDown :
+ ob = currentColumn.currentRow.nextSibling;
+ break;
+ case keyLeft :
+ var currentLevel = parseInt(currentColumn.parentNode.id.slice(6));
+ if (currentLevel) {
+ ob = document.getElementById('level-' + (currentLevel - 1)).firstChild;
+ if (ob.nodeType == 3) // text node
+ ob = ob.nextSibling
+ ob = ob.currentRow;
+ }
+ break;
+ case keyRight :
+ if(currentColumn.currentRow.className != 'folderish-selected')
+ return;
+ ob = document.getElementById('level-' + (parseInt(currentColumn.parentNode.id.slice(6)) + 1)).firstChild.firstChild;
+ break;
+ case keyEnter :
+ ob = currentColumn.currentRow;
+ evtType = 'dblclick'
+ break;
+ };
+ if (ob)
+ raiseMouseEvent(ob, evtType);
+ }
+
+ function resizeBrowser() {
+ var columns = finder.getElementsByTagName('ul');
+ var col;
+ for (var i=0 ; i<columns.length ; i++) {
+ col = columns[i];
+ col.style.height = getWindowHeight() - scrollbarPlaceholder_offset + "px";;
+
+ }
+ //document.body.style.width = getWindowWidth();
+ }
+
+ /* from fck default browser */
+ function GetUrlParam( paramName )
+ {
+ var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
+ var oMatch = oRegex.exec( window.location.search ) ;
+
+ if ( oMatch && oMatch.length > 1 )
+ return unescape(oMatch[1]) ;
+ else
+ return '' ;
+ }
+
+
+
+ function populateBrowser(command, path) {
+ var prevColNum = finder.colCpt;
+ var level = -1;
+ for (var i = 0 ; i<path.length ; i++){
+ if (path.charAt(i) == '/')
+ level += 1;
+ }
+ level = level - baseDepth;
+
+ // prepare / cleanup columns
+ var cellLevel, startCleanup = 3;
+ switch (level) {
+ case 0 : // initialization case
+ startCleanup = 0;
+ cellLevel = document.getElementById('level-0');
+ cellLevel.style.width = cellWidth + "px";
+ // remove default content
+ cellLevel.removeChild(cellLevel.firstChild);
+
+ // cosmetic: display the second col with a scrollbar
+ var c1 = document.createElement('td');
+ c1.id = "level-1";
+ c1.style.width = cellWidth + "px";
+ c1.appendChild(document.createElement('ul'));
+ finderContent.appendChild(c1);
+
+ // cosmetic: display the third col without scrollbar
+ var c2 = document.createElement('td');
+ c2.id = "level-2";
+ c2.style.width = cellWidth + "px";
+ finderContent.appendChild(c2);
+ break;
+
+ case 1 :
+ cellLevel = document.getElementById("level-1");
+ cellLevel.removeChild(cellLevel.firstChild);
+ var c2 = document.getElementById("level-2");
+ var ul = c2.firstChild;
+ if (ul)
+ c2.removeChild(ul);
+ break;
+
+ case 2 :
+ cellLevel = document.getElementById("level-2");
+ var ul = cellLevel.firstChild;
+ if (ul) {
+ cellLevel.removeChild(ul);
+ }
+ break;
+
+ default :
+ cellLevel = document.getElementById("level-" + level);
+ if (!cellLevel) {
+ cellLevel = document.createElement('td');
+ cellLevel.id = "level-" + level;
+ cellLevel.style.width = cellWidth + "px";
+ finderContent.appendChild(cellLevel);
+ startCleanup = 0;
+ finder.colCpt += 1;
+ }
+ else {
+ cellLevel.removeChild(cellLevel.firstChild);
+ startCleanup = level + 1
+ }
+ }
+ if (startCleanup) {
+ var nextColumn = document.getElementById("level-" + startCleanup);
+ while (nextColumn) {
+ finderContent.removeChild(nextColumn);
+ finder.colCpt -= 1;
+ nextColumn = document.getElementById("level-" + ++startCleanup);
+ }
+ }
+
+ // request
+ var req = new XMLHttpRequest();
+ req.open("POST", sConnUrl, false); // synchrone
+ req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+ req.send("command=" + command + "&path="+escape(path) + "&Type=" + ressourceType);
+ var respDom = req.responseXML.documentElement;
+
+
+ var list = document.createElement('UL');
+ list.style.height= getWindowHeight() - scrollbarPlaceholder_offset + "px";
+ cellLevel.appendChild(list);
+
+ switch (respDom.tagName) {
+ case 'ls' :
+ // import listing
+ var rows = respDom.getElementsByTagName('row');
+ var row, listItem, icon;
+
+ for (var i = 0 ; i<rows.length ; i++){
+ row = rows[i];
+ listItem = document.createElement('li');
+ if (row.getAttribute('folderish') != "0")
+ listItem.className = 'folderish';
+ else
+ listItem.className = 'contentish';
+
+ icon = document.createElement('img');
+ with (icon) {
+ src = row.getAttribute('icon');
+ width = "16";
+ height = "16";
+ border = "0";
+ }
+
+ listItem.path = row.getAttribute('path');
+ listItem.link = row.getAttribute('link');
+ listItem.appendChild(icon);
+ listItem.appendChild(document.createTextNode(row.firstChild.nodeValue));
+ list.appendChild(listItem);
+ }
+ break;
+ case 'info' :
+ var li = document.createElement('li');
+ list.appendChild(li);
+ li.innerHTML = respDom.firstChild.nodeValue;
+
+ // add create link button
+ li = document.createElement('li');
+ li.style.textAlign = 'center';
+ var createLinkBtn = document.createElement('button');
+ var text = (ressourceType == 'Image') ? 'Insert' : 'Create link';
+ createLinkBtn.appendChild(document.createTextNode(text));
+
+ createLinkBtn.onclick = function(){
+ var url = respDom.lastChild.firstChild.nodeValue;
+ switch(window.parent.name) {
+ case 'FCKeditorDialog_PlinnImage' :
+ window.parent.updateOrInsertImage(url);
+ break;
+ case 'FCKBrowseWindow' :
+ default:
+ window.opener.SetUrl(url);
+ break;
+ }
+ window.close();
+ };
+
+ list.appendChild(li);
+ li.appendChild(createLinkBtn);
+ break;
+ }
+
+ if (prevColNum != finder.colCpt) {
+ var finderWidth = finder.colCpt * cellWidth;
+ finder.style.width = finderWidth + "px";
+ if (finder.colCpt - prevColNum > 0) {
+ var start = (window.scrollX) ? window.scrollX : document.body.scrollLeft;
+ var stop = finder.colCpt * cellWidth - getWindowWidth();
+ smoothScroll(start, stop);
+ }
+ }
+ }
+
+ function smoothScroll(start, stop) {
+ start += scrollXStep;
+ window.scroll(start, 0);
+ if (start < stop) {
+ setTimeout('smoothScroll(' + start + ', ' + stop + ')', scrollTimeStep);
+ }
+ }
+
+
+ // ]]>
+ </script>
+ </head>
+ <body>
+ <table id="finder" cellspacing="0">
+ <tr id="finderContent">
+ <td id="level-0"><ul>
+ <li class="folderish">Folder</li>
+ <li class="contentish">Content</li>
+ </ul>
+ </td>
+ </tr>
+ </table>
+ </body>
+</html>
\ No newline at end of file