Import xinha so we can switch from htmlarea and fix a bunch of in-browser issues that htmlarea has

This commit is contained in:
Chris Morgan
2005-09-30 02:25:07 +00:00
committed by WineHQ
parent 2311d4d572
commit 9242a68c4a
375 changed files with 26623 additions and 0 deletions

View File

@@ -0,0 +1,252 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Destroydrop &raquo; Javascripts &raquo; Tree &raquo; Api</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
<link rel="stylesheet" href="/dd.css" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" />
</head>
<body>
<div id="shadow">
<div id="content">
<div id="location">
<h1><a href="/">Destroydrop</a> &raquo; <a href="/javascripts/">Javascripts</a> &raquo; <a href="/javascripts/tree/">Tree</a> &raquo; <a href="/javascripts/tree/api/">Api</a></h1>
</div>
<div class="line"></div>
<div id="files">
<h3>Overview</h3>
<div class="line"></div>
<div class="item">
<ul class="arrow">
<li><a href="#functions">Functions</a>
<ul class="arrow">
<li><a href="#add">add</a></li>
<li><a href="#openall">openAll</a></li>
<li><a href="#closeall">closeAll</a></li>
<li><a href="#opento">openTo</a></li>
</ul>
</li>
<li><a href="#configuration">Configuration</a></li>
</ul>
</div>
<a name="functions"></a>
<h3>Functions</h3>
<div class="line"></div>
<div class="item">
<a name="add"></a>
<h4 class="func">add()</h4>
<p>Adds a node to the tree.<br />Can only be called before the tree is drawn.</p>
<p>id, pid and name are required.</p>
<h4>Parameters</h4>
<table class="files">
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>id</td>
<td>Number</td>
<td>Unique identity number.</td>
</tr>
<tr>
<td>pid</td>
<td>Number</td>
<td>Number refering to the parent node. The value for the root node has to be -1.</td>
</tr>
<tr>
<td>name</td>
<td>String</td>
<td>Text label for the node.</td>
</tr>
<tr>
<td>url</td>
<td>String</td>
<td>Url for the node.</td>
</tr>
<tr>
<td>title</td>
<td>String</td>
<td>Title for the node.</td>
</tr>
<tr>
<td>target</td>
<td>String</td>
<td>Target for the node.</td>
</tr>
<tr>
<td>icon</td>
<td>String</td>
<td>Image file to use as the icon. Uses default if not specified.</td>
</tr>
<tr>
<td>iconOpen</td>
<td>String</td>
<td>Image file to use as the open icon. Uses default if not specified.</td>
</tr>
<tr>
<td>open</td>
<td>Boolean</td>
<td>Is the node open.</td>
</tr>
</table>
<br />
<h4>Example</h4>
<p><code>mytree.add(1, 0, 'My node', 'node.html', 'node title', 'mainframe', 'img/musicfolder.gif');</code></p>
<br />
<a name="openall"></a>
<h4 class="func">openAll()</h4>
<p>Opens all the nodes.<br />Can be called before and after the tree is drawn.</p>
<h4>Example</h4>
<p><code>mytree.openAll();</code></p>
<br />
<a name="closeall"></a>
<h4 class="func">closeAll()</h4>
<p>Closes all the nodes.<br />Can be called before and after the tree is drawn.</p>
<h4>Example</h4>
<p><code>mytree.closeAll();</code></p>
<br />
<a name="opento"></a>
<h4 class="func">openTo()</h4>
<p>Opens the tree to a certain node and can also select the node.<br />
Can only be called after the tree is drawn.</p>
<h4>Parameters</h4>
<table class="files">
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>id</td>
<td>Number</td>
<td>Identity number for the node.</td>
</tr>
<tr>
<td>select</td>
<td>Boolean</td>
<td>Should the node be selected.</td>
</tr>
</table>
<h4>Example</h4>
<p><code>mytree.openTo(4, true);</code></p>
</div>
<a name="configuration"></a>
<h3>Configuration</h3>
<div class="line"></div>
<div class="item">
<table class="files">
<tr>
<th>Variable</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
<tr>
<td>target</td>
<td>String</td>
<td>true</td>
<td>Target for all the nodes.</td>
</tr>
<tr>
<td>folderLinks</td>
<td>Boolean</td>
<td>true</td>
<td>Should folders be links.</td>
</tr>
<tr>
<td>useSelection</td>
<td>Boolean</td>
<td>true</td>
<td>Nodes can be selected(highlighted).</td>
</tr>
<tr>
<td>useCookies</td>
<td>Boolean</td>
<td>true</td>
<td>The tree uses cookies to rember it's state.</td>
</tr>
<tr>
<td>useLines</td>
<td>Boolean</td>
<td>true</td>
<td>Tree is drawn with lines.</td>
</tr>
<tr>
<td>useIcons</td>
<td>Boolean</td>
<td>true</td>
<td>Tree is drawn with icons.</td>
</tr>
<tr>
<td>useStatusText</td>
<td>Boolean</td>
<td>false</td>
<td>Displays node names in the statusbar instead of the url.</td>
</tr>
<tr>
<td>closeSameLevel</td>
<td>Boolean</td>
<td>false</td>
<td>Only one node within a parent can be expanded at the same time. openAll() and closeAll() functions do not work when this is enabled.</td>
</tr>
<tr>
<td>inOrder</td>
<td>Boolean</td>
<td>false</td>
<td>If parent nodes are always added before children, setting this to true speeds up the tree.</td>
</tr>
</table>
<h4>Example</h4>
<p><code>mytree.config.target = "mytarget";</code></p>
</div>
</div>
<div class="line"></div>
<div id="copy">
<p class="right"><a href="http://validator.w3.org/check/referer">XHTML</a>, <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a></p>
<p><a href="mailto&#58;drop&#64;destroydrop&#46;com">&copy;2002-2003 Geir Landr&ouml;</a></p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,39 @@
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landr? |
|--------------------------------------------------*/
.dtree {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #666;
white-space: nowrap;
}
.dtree img {
border: 0px;
vertical-align: middle;
}
.dtree a {
color: #333;
text-decoration: none;
}
.dtree a.node, .dtree a.nodeSel {
white-space: nowrap;
padding: 1px 2px 1px 2px;
/*padding: 0px 1px 0px 1px;*/
}
.dtree a.node:hover, .dtree a.nodeSel:hover {
color: #333;
text-decoration: underline;
}
.dtree a.nodeSel {
background-color: #c0d2ec;
/*
-moz-border-radius : 4px;
border:1px dotted #333;
*/
}
.dtree .clip {
overflow: hidden;
}

View File

@@ -0,0 +1,723 @@
/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landr? |
| |
| This script can be used freely as long as all |
| copyright messages are intact. |
| |
| Updated: 17.04.2003 |
|--------------------------------------------------*/
// Node object
function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
this.name = name;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};
// Tree object
function dTree(objName, baseDir) {
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false
}
this.icon = {
root : baseDir + 'img/base.gif',
folder : baseDir + 'img/folder.gif',
folderOpen : baseDir + 'img/folderopen.gif',
node : baseDir + 'img/page.gif',
empty : baseDir + 'img/empty.gif',
line : baseDir + 'img/line.gif',
join : baseDir + 'img/join.gif',
joinBottom : baseDir + 'img/joinbottom.gif',
plus : baseDir + 'img/plus.gif',
plusBottom : baseDir + 'img/plusbottom.gif',
minus : baseDir + 'img/minus.gif',
minusBottom : baseDir + 'img/minusbottom.gif',
nlPlus : baseDir + 'img/nolines_plus.gif',
nlMinus : baseDir + 'img/nolines_minus.gif'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
};
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
};
// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
};
// Outputs the tree to the page
dTree.prototype.toString = function() {
this.setCS_All();
var str = '<div class="dtree">\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'Browser not supported.';
str += '</div>';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == pNode.id) {
var cn = this.aNodes[n];
cn._p = pNode;
cn._ai = n;
// this.setCS(cn);
if (!cn.target && this.config.target) cn.target = this.config.target;
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
if (!this.config.folderLinks && cn._hc) cn.url = null;
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
cn._is = true;
this.selectedNode = n;
this.selectedFound = true;
}
str += this.node(cn, n);
if (cn._ls) break;
}
}
return str;
};
// Creates the node icon, url and text
dTree.prototype.node = function(node, nodeId) {
var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
if (this.config.useIcons) {
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
if (this.root.id == node.pid) {
node.icon = this.icon.root;
node.iconOpen = this.icon.root;
}
str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
}
if (node.url) {
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
if (node.title) str += ' title="' + node.title + '"';
if (node.target) str += ' target="' + node.target + '"';
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
str += '>';
}
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
str += node.name;
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
str += '</div>';
if (node._hc) {
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
str += this.addNode(node);
str += '</div>';
}
this.aIndent.pop();
return str;
};
// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n<this.aIndent.length; n++)
str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
str += '" alt="" /></a>';
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
}
return str;
};
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id) node._hc = true;
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
}
if (lastId==node.id) node._ls = true;
};
dTree.prototype.setCS_All = function()
{
var ids = { }; // ID => { _hc: haschildren, _ls_is: lastsibling}
for(var n = 0; n < this.aNodes.length; n++)
{
var node = this.aNodes[n];
if(!ids[node.pid])
{
ids[node.pid] = { _hc: true, _ls_is: node.id };
}
else
{
ids[node.pid]._hc = true;
ids[node.pid]._ls_is = node.id;
}
if(!ids[node.id])
{
ids[node.id] = { _hc: false, _ls_is: null }
}
}
for(var n = 0; n < this.aNodes.length; n++)
{
var node = this.aNodes[n];
node._ls = ids[node.pid]._ls_is == node.id ? true : false;
node._hc = ids[node.id]._hc;
}
}
// Returns the selected node
dTree.prototype.getSelected = function() {
var sn = this.getCookie('cs' + this.obj);
return (sn) ? sn : null;
};
// Highlights the selected node
dTree.prototype.s = function(id) {
if (!this.config.useSelection) return;
var cn = this.aNodes[id];
if (cn._hc && !this.config.folderLinks) return;
if (this.selectedNode != id) {
if (this.selectedNode || this.selectedNode==0) {
eOld = document.getElementById("s" + this.obj + this.selectedNode);
eOld.className = "node";
}
eNew = document.getElementById("s" + this.obj + id);
eNew.className = "nodeSel";
this.selectedNode = id;
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
}
};
// Toggle Open or close
dTree.prototype.o = function(id) {
var cn = this.aNodes[id];
this.nodeStatus(!cn._io, id, cn._ls);
cn._io = !cn._io;
if (this.config.closeSameLevel) this.closeLevel(cn);
if (this.config.useCookies) this.updateCookie();
};
// Open or close all nodes
dTree.prototype.oAll = function(status) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
this.nodeStatus(status, n, this.aNodes[n]._ls)
this.aNodes[n]._io = status;
}
}
if (this.config.useCookies) this.updateCookie();
};
// Opens the tree to a specific node
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
if (!bFirst) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].id == nId) {
nId=n;
break;
}
}
}
var cn=this.aNodes[nId];
if (cn.pid==this.root.id || !cn._p) return;
cn._io = true;
cn._is = bSelect;
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
if (this.completed && bSelect) this.s(cn._ai);
else if (bSelect) this._sn=cn._ai;
this.openTo(cn._p._ai, false, true);
};
// Closes all nodes on the same level as certain node
dTree.prototype.closeLevel = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Closes all children of a node
dTree.prototype.closeAllChildren = function(node) {
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
this.aNodes[n]._io = false;
this.closeAllChildren(this.aNodes[n]);
}
}
}
// Change the status of a node(open or closed)
dTree.prototype.nodeStatus = function(status, id, bottom) {
eDiv = document.getElementById('d' + this.obj + id);
eJoin = document.getElementById('j' + this.obj + id);
if (this.config.useIcons) {
eIcon = document.getElementById('i' + this.obj + id);
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
}
eJoin.src = (this.config.useLines)?
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
((status)?this.icon.nlMinus:this.icon.nlPlus);
eDiv.style.display = (status) ? 'block': 'none';
};
// [Cookie] Clears a cookie
dTree.prototype.clearCookie = function() {
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};
// [Cookie] Sets value in a cookie
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};
// [Cookie] Gets a value from a cookie
dTree.prototype.getCookie = function(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};
// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function() {
var str = '';
for (var n=0; n<this.aNodes.length; n++) {
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
if (str) str += '.';
str += this.aNodes[n].id;
}
}
this.setCookie('co' + this.obj, str);
};
// [Cookie] Checks if a node id is in a cookie
dTree.prototype.isOpen = function(id) {
var aOpen = this.getCookie('co' + this.obj).split('.');
for (var n=0; n<aOpen.length; n++)
if (aOpen[n] == id) return true;
return false;
};
// If Push and pop is not implemented by the browser
if (!Array.prototype.push) {
Array.prototype.push = function array_push() {
for(var i=0;i<arguments.length;i++)
this[this.length]=arguments[i];
return this.length;
}
};
if (!Array.prototype.pop) {
Array.prototype.pop = function array_pop() {
lastElement = this[this.length-1];
this.length = Math.max(this.length-1,0);
return lastElement;
}
};

View File

@@ -0,0 +1,53 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Destroydrop &raquo; Javascripts &raquo; Tree</title>
<link rel="StyleSheet" href="dtree.css" type="text/css" />
<script type="text/javascript" src="dtree.js"></script>
</head>
<body>
<h1><a href="/">Destroydrop</a> &raquo; <a href="/javascripts/">Javascripts</a> &raquo; <a href="/javascripts/tree/">Tree</a></h1>
<h2>Example</h2>
<div class="dtree">
<p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>
<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');
document.write(d);
//-->
</script>
</div>
<p><a href="mailto&#58;drop&#64;destroydrop&#46;com">&copy;2002-2003 Geir Landr&ouml;</a></p>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1012 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -0,0 +1,107 @@
<h1 id="[h1]"><l10n>Insert/Modify Link</l10n></h1>
<div style="position:relative">
<div id="[dTree]">(the dTree goes in here)</div>
<div id="[options]" >
<fieldset>
<legend><label><input type="radio" name="[type]" value="url" checked onclick="
document.getElementById('[urltable]').style.display=this.checked?'':'none';
document.getElementById('[mailtable]').style.display=this.checked?'none':'';
document.getElementById('[anchortable]').style.display=this.checked?'none':'';
" /> <l10n>URL Link</l10n></label></legend>
<table id="[urltable]" width="100%">
<tr>
<th><label for="[href]"><l10n>URL:</l10n> </label></th>
<td><input type="text" name="[href]" style="width:100%" value="http://www.example.com/" /></td>
</tr>
<tr valign="top">
<th><l10n>Target:</l10n></th>
<td>
<div><label><input type="radio" name="[target]" value="" onclick="document.getElementById('[popuptable]').style.display='none';" checked /> <l10n>Ordinary Link</l10n></label></div>
<div><label><input type="radio" name="[target]" value="_top" onclick="document.getElementById('[popuptable]').style.display='none';" /> <l10n>Same Window (jump out of frames)</l10n></label></div>
<div><label><input type="radio" name="[target]" value="_blank" onclick="document.getElementById('[popuptable]').style.display='none';"/> <l10n>New Window</l10n> </label></div>
<div>
<label><input type="radio" name="[target]" value="popup" onclick="document.getElementById('[popuptable]').style.display='';" /> <l10n>Popup Window</l10n> </label>
<div style="padding-left:10px">
<table id="[popuptable]">
<tr>
<th align="left"><l10n>Size:</l10n></th>
<td colspan="3"><input type="text" name="[p_width]" size="4" />x<input type="text" name="[p_height]" size="4" /> <l10n>(px)</l10n></td>
</tr>
<tr>
<th align="left"><l10n>Name:</l10n></th>
<td colspan="3"><input type="text" name="[p_name]" atyle="width:100%" value="_(PopupWindow)" /></td>
</tr>
<tr>
<th align="left"><l10n>Menu Bar:</l10n></th>
<td><input type="checkbox" name="[p_options]" value="menubar=yes" /></td>
<th align="left"><l10n>Toolbar:</l10n></th>
<td><input type="checkbox" name="[p_options]" value="toolbar=yes" checked /></td>
</tr>
<tr>
<th align="left"><l10n>Location Bar:</l10n></th>
<td><input type="checkbox" name="[p_options]" value="location=yes" /></td>
<th align="left"><l10n>Status Bar:</l10n></th>
<td><input type="checkbox" name="[p_options]" value="status=yes" /></td>
</tr>
<tr>
<th align="left"><l10n>Scrollbars:</l10n></th>
<td><input type="checkbox" name="[p_options]" value="scrollbars=yes" checked /></td>
<th align="left"><l10n>Resizeable:</l10n></th>
<td><input type="checkbox" name="[p_options]" value="resizeable=yes" checked /></td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend><label><input type="radio" name="[type]" value="mailto" onclick="
document.getElementById('[mailtable]').style.display=this.checked?'':'none';
document.getElementById('[urltable]').style.display=this.checked?'none':'';
document.getElementById('[anchortable]').style.display=this.checked?'none':'';
"/> <l10n>Email Link</l10n></label></legend>
<table id="[mailtable]" width="100%">
<tr>
<th><label for="[to]"><l10n>Email Address:</l10n> </label></th>
<td><input type="text" name="[to]" style="width:100%" value="alice@example.com" /></td>
</tr>
<tr>
<th><label for="[subject]"><l10n>Subject:</l10n> </label></th>
<td><input type="text" name="[subject]" style="width:100%" value="" /></td>
</tr>
<tr>
<th><label for="[body]"><l10n>Message Template:</l10n> </label></th>
<td><textarea name="[body]" style="width:100%" rows="5"></textarea></td>
</tr>
</table>
</fieldset>
<fieldset id="[anchorfieldset]">
<legend><label><input type="radio" name="[type]" value="anchor" onclick="
document.getElementById('[urltable]').style.display=this.checked?'none':'';
document.getElementById('[mailtable]').style.display=this.checked?'none':'';
document.getElementById('[anchortable]').style.display=this.checked?'':'none';
"/> <l10n>Anchor-Link</l10n></label></legend>
<table id="[anchortable]" width="100%">
<tr>
<th><label for="[anchor]"><l10n>Anchor:</l10n> </label></th>
<td>
<select name="[anchor]" id="[anchor]">
</select>
</td>
</tr>
</table>
</fieldset>
<div style="text-align:right">
<input type="button" id="[ok]" value="_(OK)" />
<input type="button" id="[clear]" value="_(REMOVE LINK)" onclick="this.form['[href]'].value='';this.form['[to]'].value='';document.getElementById('[ok]').click();" />
<input type="button" id="[cancel]" value="_(CANCEL)" />
</div>
</div>
</div>

View File

@@ -0,0 +1,21 @@
// I18N constants
// LANG: "de", ENCODING: UTF-8
// translated: Udo Schmal
{
"You must select some text before making a new link.": "Sie müssen einen Text markieren um einen Link zu erstellen",
"Are you sure you wish to remove this link?": "Wollen Sie diesen Link wirklich entfernen?",
"REMOVE LINK": "LINK ENTFERNEN",
"CANCEL": "ABBRECHEN",
"URL Link": "URL Adresse",
"Ordinary Link": "Standard Link",
"Same Window (jump out of frames)": "Selbes Fenster (ganzer Bereich)",
"New Window": "Neues Fenster",
"Popup Window": "Pop-Up Fenster",
"Email Link": "Email Link",
"Email Address:": "Email Adresse",
"Subject:": "Betreff:",
"Message Template:": "Nachrichten Vorlage:",
"Size:": "Größe:",
"Name:": "Name:"
}

View File

@@ -0,0 +1,19 @@
// I18N constants
// LANG: "fr", ENCODING: UTF-8
{
"You must select some text before making a new link.": "Vous devez sélectionner un texte avant de créer un nouveau lien",
"Are you sure you wish to remove this link?": "Confirmez-vous la suppression de ce lien ?",
"REMOVE LINK": "Supprimer",
"CANCEL": "Annuler",
"URL Link": "Lien URL",
"Ordinary Link": "Lien standard",
"Same Window (jump out of frames)": "Même fenêtre (sort des frames)",
"New Window": "Nouvelle fenêtre",
"Popup Window": "Fenêtre popup",
"Email Link": "Lien email",
"Email Address:": "Adresse email",
"Subject:": "Sujet",
"Message Template:": "Message",
"Size:": "Taille",
"Name:": "Nom"
}

View File

@@ -0,0 +1,8 @@
// I18N constants
// LANG: "no", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
"You must select some text before making a new link.": "Du må markere tekst eller et bilde før du kan lage en lenke.",
"Are you sure you wish to remove this link?": "Er du sikker på at du vil fjerne lenken?"
}

View File

@@ -0,0 +1,20 @@
// I18N constants
// LANG: "pl", ENCODING: UTF-8
// translated: Krzysztof Kotowicz, http://www.eskot.krakow.pl/portfolio/, koto@webworkers.pl
{
"You must select some text before making a new link.": "Zaznacz tekst przed dodaniem odnośnika.",
"Are you sure you wish to remove this link?": "Na pewno chcesz usunąć odnośnik?",
"REMOVE LINK": "USUŃ ODNOŚNIK",
"CANCEL": "ANULUJ",
"URL Link": "Adres URL",
"Ordinary Link": "Zwykły odnośnik",
"Same Window (jump out of frames)": "To samo okno (wyskocz z ramek)",
"New Window": "Nowe okno",
"Popup Window": "Okienko pop-up",
"Email Link": "Link do e-maila",
"Email Address:": "Adres e-mail",
"Subject:": "Temat:",
"Message Template:": "Szablon wiadmości:",
"Size:": "Rozmiar:",
"Name:": "Nazwa:"
}

View File

@@ -0,0 +1,552 @@
/** htmlArea - James' Fork - Linker Plugin **/
Linker._pluginInfo =
{
name : "Linker",
version : "1.0",
developer: "James Sleeman",
developer_url: "http://www.gogo.co.nz/",
c_owner : "Gogo Internet Services",
license : "htmlArea",
sponsor : "Gogo Internet Services",
sponsor_url : "http://www.gogo.co.nz/"
};
HTMLArea.loadStyle('dTree/dtree.css', 'Linker');
HTMLArea.Config.prototype.Linker =
{
'backend' : _editor_url + 'plugins/Linker/scan.php',
'files' : null
}
function Linker(editor, args)
{
this.editor = editor;
this.lConfig = editor.config.Linker;
var linker = this;
if(editor.config.btnList.createlink)
{
editor.config.btnList.createlink[3]
= function(e, objname, obj) { linker._createLink(linker._getSelectedAnchor()); };
}
else
{
editor.config.registerButton(
'createlink', 'Insert/Modify Hyperlink', [_editor_url + "images/ed_buttons_main.gif",6,1], false,
function(e, objname, obj) { linker._createLink(linker._getSelectedAnchor()); }
);
}
// See if we can find 'createlink'
editor.config.addToolbarElement("createlink", "createlink", 0);
}
Linker.prototype._lc = function(string)
{
return HTMLArea._lc(string, 'Linker');
}
Linker.prototype._createLink = function(a)
{
if(!a && this.editor._selectionEmpty(this.editor._getSelection()))
{
alert(this._lc("You must select some text before making a new link."));
return false;
}
var inputs =
{
type: 'url',
href: 'http://www.example.com/',
target: '',
p_width: '',
p_height: '',
p_options: ['menubar=no','toolbar=yes','location=no','status=no','scrollbars=yes','resizeable=yes'],
to: 'alice@example.com',
subject: '',
body: ''
}
if(a && a.tagName.toLowerCase() == 'a')
{
var m = a.href.match(/^mailto:(.*@[^?&]*)(\?(.*))?$/);
var anchor = a.href.match(/^#(.*)$/);
if(m)
{
// Mailto
inputs.type = 'mailto';
inputs.to = m[1];
if(m[3])
{
var args = m[3].split('&');
for(var x = 0; x<args.length; x++)
{
var j = args[x].match(/(subject|body)=(.*)/);
if(j)
{
inputs[j[1]] = decodeURIComponent(j[2]);
}
}
}
}
else if (anchor)
{
//Anchor-Link
inputs.type = 'anchor';
inputs.anchor = m[1];
}
else
{
if(a.getAttribute('onclick'))
{
var m = a.getAttribute('onclick').match(/window\.open\(\s*this\.href\s*,\s*'([a-z0-9_]*)'\s*,\s*'([a-z0-9_=,]*)'\s*\)/i);
// Popup Window
inputs.href = a.href ? a.href : '';
inputs.target = 'popup';
inputs.p_name = m[1];
inputs.p_options = [ ];
var args = m[2].split(',');
for(var x = 0; x < args.length; x++)
{
var i = args[x].match(/(width|height)=([0-9]+)/);
if(i)
{
inputs['p_' + i[1]] = parseInt(i[2]);
}
else
{
inputs.p_options.push(args[x]);
}
}
}
else
{
// Normal
inputs.href = a.href;
inputs.target = a.target;
}
}
}
var linker = this;
// If we are not editing a link, then we need to insert links now using execCommand
// because for some reason IE is losing the selection between now and when doOK is
// complete. I guess because we are defocusing the iframe when we click stuff in the
// linker dialog.
this.a = a; // Why doesn't a get into the closure below, but if I set it as a property then it's fine?
var doOK = function()
{
//if(linker.a) alert(linker.a.tagName);
var a = linker.a;
var values = linker._dialog.hide();
var atr =
{
href: '',
target:'',
title:'',
onclick:''
}
if(values.type == 'url')
{
if(values.href)
{
atr.href = values.href;
atr.target = values.target;
if(values.target == 'popup')
{
if(values.p_width)
{
values.p_options.push('width=' + values.p_width);
}
if(values.p_height)
{
values.p_options.push('height=' + values.p_height);
}
atr.onclick = 'try{if(document.designMode && document.designMode == \'on\') return false;}catch(e){} window.open(this.href, \'' + (values.p_name.replace(/[^a-z0-9_]/i, '_')) + '\', \'' + values.p_options.join(',') + '\');return false;';
}
}
}
else if(values.type == 'anchor')
{
if(values.anchor)
{
atr.href = values.anchor.value;
}
}
else
{
if(values.to)
{
atr.href = 'mailto:' + values.to;
if(values.subject) atr.href += '?subject=' + encodeURIComponent(values.subject);
if(values.body) atr.href += (values.subject ? '&' : '?') + 'body=' + encodeURIComponent(values.body);
}
}
if(a && a.tagName.toLowerCase() == 'a')
{
if(!atr.href)
{
if(confirm(linker._dialog._lc('Are you sure you wish to remove this link?')))
{
var p = a.parentNode;
while(a.hasChildNodes())
{
p.insertBefore(a.removeChild(a.childNodes[0]), a);
}
p.removeChild(a);
}
}
else
{
// Update the link
for(var i in atr)
{
a.setAttribute(i, atr[i]);
}
// If we change a mailto link in IE for some hitherto unknown
// reason it sets the innerHTML of the link to be the
// href of the link. Stupid IE.
if(HTMLArea.is_ie)
{
if(/mailto:([^?<>]*)(\?[^<]*)?$/i.test(a.innerHTML))
{
a.innerHTML = RegExp.$1;
}
}
}
}
else
{
if(!atr.href) return true;
// Insert a link, we let the browser do this, we figure it knows best
var tmp = HTMLArea.uniq('http://www.example.com/Link');
linker.editor._doc.execCommand('createlink', false, tmp);
// Fix them up
var anchors = linker.editor._doc.getElementsByTagName('a');
for(var i = 0; i < anchors.length; i++)
{
var a = anchors[i];
if(a.href == tmp)
{
// Found one.
for(var i in atr)
{
a.setAttribute(i, atr[i]);
}
}
}
}
}
this._dialog.show(inputs, doOK);
}
Linker.prototype._getSelectedAnchor = function()
{
var sel = this.editor._getSelection();
var rng = this.editor._createRange(sel);
var a = this.editor._activeElement(sel);
if(a != null && a.tagName.toLowerCase() == 'a')
{
return a;
}
else
{
a = this.editor._getFirstAncestor(sel, 'a');
if(a != null)
{
return a;
}
}
return null;
}
Linker.prototype.onGenerate = function()
{
this._dialog = new Linker.Dialog(this);
}
// Inline Dialog for Linker
Linker.Dialog_dTrees = [ ];
Linker.Dialog = function (linker)
{
var lDialog = this;
this.Dialog_nxtid = 0;
this.linker = linker;
this.id = { }; // This will be filled below with a replace, nifty
this.ready = false;
this.files = false;
this.html = false;
this.dialog = false;
// load the dTree script
this._prepareDialog();
}
Linker.Dialog.prototype._prepareDialog = function()
{
var lDialog = this;
var linker = this.linker;
// We load some stuff up int he background, recalling this function
// when they have loaded. This is to keep the editor responsive while
// we prepare the dialog.
if(typeof dTree == 'undefined')
{
HTMLArea._loadback(_editor_url + 'plugins/Linker/dTree/dtree.js',
function() {lDialog._prepareDialog(); }
);
return;
}
if(this.files == false)
{
if(linker.lConfig.backend)
{
//get files from backend
HTMLArea._getback(linker.lConfig.backend,
function(txt) {
try {
eval('lDialog.files = '+txt);
} catch(Error) {
lDialog.files = [ {url:'',title:Error.toString()} ];
}
lDialog._prepareDialog(); });
}
else if(linker.lConfig.files != null)
{
//get files from plugin-config
lDialog.files = linker.lConfig.files;
lDialog._prepareDialog();
}
return;
}
var files = this.files;
if(this.html == false)
{
HTMLArea._getback(_editor_url + 'plugins/Linker/dialog.html', function(txt) { lDialog.html = txt; lDialog._prepareDialog(); });
return;
}
var html = this.html;
// Now we have everything we need, so we can build the dialog.
var dialog = this.dialog = new HTMLArea.Dialog(linker.editor, this.html, 'Linker');
var dTreeName = HTMLArea.uniq('dTree_');
this.dTree = new dTree(dTreeName, _editor_url + 'plugins/Linker/dTree/');
eval(dTreeName + ' = this.dTree');
this.dTree.add(this.Dialog_nxtid++, -1, document.location.host, null, document.location.host);
this.makeNodes(files, 0);
// Put it in
var ddTree = this.dialog.getElementById('dTree');
//ddTree.innerHTML = this.dTree.toString();
ddTree.innerHTML = '';
ddTree.style.position = 'absolute';
ddTree.style.left = 1 + 'px';
ddTree.style.top = 0 + 'px';
ddTree.style.overflow = 'auto';
this.ddTree = ddTree;
this.dTree._linker_premade = this.dTree.toString();
var options = this.dialog.getElementById('options');
options.style.position = 'absolute';
options.style.top = 0 + 'px';
options.style.right = 0 + 'px';
options.style.width = 320 + 'px';
options.style.overflow = 'auto';
// Hookup the resizer
this.dialog.onresize = function()
{
options.style.height = ddTree.style.height = (parseInt(dialog.height) - dialog.getElementById('h1').offsetHeight) + 'px';
ddTree.style.width = (parseInt(dialog.width) - 322 ) + 'px';
}
this.ready = true;
}
Linker.Dialog.prototype.makeNodes = function(files, parent)
{
for(var i = 0; i < files.length; i++)
{
if(typeof files[i] == 'string')
{
this.dTree.add(Linker.nxtid++, parent,
files[i].replace(/^.*\//, ''),
'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i]) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);',
files[i]);
}
else if(files[i].length)
{
var id = this.Dialog_nxtid++;
this.dTree.add(id, parent, files[i][0].replace(/^.*\//, ''), null, files[i][0]);
this.makeNodes(files[i][1], id);
}
else if(typeof files[i] == 'object')
{
if(files[i].children) {
var id = this.Dialog_nxtid++;
} else {
var id = Linker.nxtid++;
}
if(files[i].title) var title = files[i].title;
else if(files[i].url) var title = files[i].url.replace(/^.*\//, '');
else var title = "no title defined";
if(files[i].url) var link = 'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i].url) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);';
else var link = '';
this.dTree.add(id, parent, title, link, title);
if(files[i].children) {
this.makeNodes(files[i].children, id);
}
}
}
}
Linker.Dialog.prototype._lc = Linker.prototype._lc;
Linker.Dialog.prototype.show = function(inputs, ok, cancel)
{
if(!this.ready)
{
var lDialog = this;
window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100);
return;
}
if(this.ddTree.innerHTML == '')
{
this.ddTree.innerHTML = this.dTree._linker_premade;
}
if(inputs.type=='url')
{
this.dialog.getElementById('urltable').style.display = '';
this.dialog.getElementById('mailtable').style.display = 'none';
this.dialog.getElementById('anchortable').style.display = 'none';
}
else if(inputs.type=='anchor')
{
this.dialog.getElementById('urltable').style.display = 'none';
this.dialog.getElementById('mailtable').style.display = 'none';
this.dialog.getElementById('anchortable').style.display = '';
}
else
{
this.dialog.getElementById('urltable').style.display = 'none';
this.dialog.getElementById('mailtable').style.display = '';
this.dialog.getElementById('anchortable').style.display = 'none';
}
if(inputs.target=='popup')
{
this.dialog.getElementById('popuptable').style.display = '';
}
else
{
this.dialog.getElementById('popuptable').style.display = 'none';
}
var anchor = this.dialog.getElementById('anchor');
for(var i=0;i<anchor.childNodes.length;i++) {
anchor.removeChild(anchor.childNodes[i]);
}
var html = this.linker.editor.getHTML();
var anchors = new Array();
var m = html.match(/<a[^>]+name="([^"]+)"/gi);
if(m)
{
for(i=0;i<m.length;i++)
{
var n = m[i].match(/name="([^"]+)"/i);
if(!anchors.contains(n[1])) anchors.push(n[1]);
}
}
m = html.match(/id="([^"]+)"/gi);
if(m)
{
for(i=0;i<m.length;i++)
{
n = m[i].match(/id="([^"]+)"/i);
if(!anchors.contains(n[1])) anchors.push(n[1]);
}
}
for(i=0;i<anchors.length;i++)
{
var opt = document.createElement('option');
opt.value = '#'+anchors[i];
opt.innerHTML = anchors[i];
anchor.appendChild(opt);
}
//if no anchors found completely hide Anchor-Link
if(anchor.childNodes.length==0) {
this.dialog.getElementById('anchorfieldset').style.display = "none";
}
// Connect the OK and Cancel buttons
var dialog = this.dialog;
var lDialog = this;
if(ok)
{
this.dialog.getElementById('ok').onclick = ok;
}
else
{
this.dialog.getElementById('ok').onclick = function() {lDialog.hide();};
}
if(cancel)
{
this.dialog.getElementById('cancel').onclick = cancel;
}
else
{
this.dialog.getElementById('cancel').onclick = function() { lDialog.hide()};
}
// Show the dialog
this.linker.editor.disableToolbar(['fullscreen','linker']);
this.dialog.show(inputs);
// Init the sizes
this.dialog.onresize();
}
Linker.Dialog.prototype.hide = function()
{
this.linker.editor.enableToolbar();
return this.dialog.hide();
}

View File

@@ -0,0 +1,162 @@
<?php
// /home/username/foo/public_html/
$dir = dirname(__FILE__)."/../..";
$include = '/\.(php|shtml|html|htm|shtm|cgi|txt|doc|pdf|rtf|xls|csv)$/';
$exclude = '';
$dirinclude = '';
$direxclude = '/(^|\/)[._]|htmlarea/'; // Exclude the htmlarea tree by default
$hash = '';
foreach(explode(',', 'dir,include,exclude,dirinclude,direxclude') as $k)
{
if(isset($_REQUEST[$k]))
{
if(get_magic_quotes_gpc())
{
$_REQUEST[$k] = stripslashes($_REQUEST[$k]);
}
$hash .= $k . '=' . $_REQUEST[$k];
$$k = $_REQUEST[$k];
}
}
if($hash)
{
session_start();
if(!isset($_SESSION[sha1($hash)]))
{
?>
[ ];
<?php
exit;
}
}
function scan($dir, $durl = '')
{
global $include, $exclude, $dirinclude, $direxclude;
static $seen = array();
$files = array();
$dir = realpath($dir);
if(isset($seen[$dir]))
{
return $files;
}
$seen[$dir] = TRUE;
$dh = @opendir($dir);
while($dh && ($file = readdir($dh)))
{
if($file !== '.' && $file !== '..')
{
$path = realpath($dir . '/' . $file);
$url = $durl . '/' . $file;
if(($dirinclude && !preg_match($dirinclude, $url)) || ($direxclude && preg_match($direxclude, $url))) continue;
if(is_dir($path))
{
if($subdir = scan($path, $url))
{
$files[] = array('url'=>$url, 'children'=>$subdir);
}
}
elseif(is_file($path))
{
if(($include && !preg_match($include, $url)) || ($exclude && preg_match($exclude, $url))) continue;
$files[] = array('url'=>$url);
}
}
}
@closedir($dh);
return dirsort($files);
}
function dirsort($files)
{
usort($files, 'dircomp');
return $files;
}
function dircomp($a, $b)
{
if(is_array($a)) $a = $a[0];
if(is_array($b)) $b = $b[0];
return strcmp(strtolower($a), strtolower($b));
}
function to_js($var, $tabs = 0)
{
if(is_numeric($var))
{
return $var;
}
if(is_string($var))
{
return "'" . js_encode($var) . "'";
}
if(is_array($var))
{
$useObject = false;
foreach(array_keys($var) as $k) {
if(!is_numeric($k)) $useObject = true;
}
$js = array();
foreach($var as $k => $v)
{
$i = "";
if($useObject) {
if(preg_match('#[a-zA-Z]+[a-zA-Z0-9]*#', $k)) {
$i .= "$k: ";
} else {
$i .= "'$k': ";
}
}
$i .= to_js($v, $tabs + 1);
$js[] = $i;
}
if($useObject) {
$ret = "{\n" . tabify(implode(",\n", $js), $tabs) . "\n}";
} else {
$ret = "[\n" . tabify(implode(",\n", $js), $tabs) . "\n]";
}
return $ret;
}
return 'null';
}
function tabify($text, $tabs)
{
if($text)
{
return str_repeat(" ", $tabs) . preg_replace('/\n(.)/', "\n" . str_repeat(" ", $tabs) . "\$1", $text);
}
}
function js_encode($string)
{
static $strings = "\\,\",',%,&,<,>,{,},@,\n,\r";
if(!is_array($strings))
{
$tr = array();
foreach(explode(',', $strings) as $chr)
{
$tr[$chr] = sprintf('\x%02X', ord($chr));
}
$strings = $tr;
}
return strtr($string, $strings);
}
echo to_js(scan($dir));
?>