forked from extern/egroupware
0a28f3812e
- Inclusion of the following javascript directories: * Connector: javascript object to interface xmlhttprequest object. This object allows asynchronous posts and support for messages while this post is being done, such as "wait, contacting server", etc. * JsAPI: general javascript functions and methods * jsolait: performs conversion from a xmlrpc message to a javascript object * xmlRpcMsgCreator: performs conversion from a javascript object to a xmlrpc message * dynapi: cross-browser class to draw layers - Update in setup version: now is 1.0.1.008; Update your versions. There was made a change in phpgw_vfs2_files table in handling of modified files. - Upgrade of vfs2 classes and PclZip class - Changes in javascript object and common object to allow the javascript backend to applications to work (now just filescenter will use it...)
263 lines
10 KiB
HTML
Executable File
263 lines
10 KiB
HTML
Executable File
<html>
|
|
<head>
|
|
<title>Example of HTMLArea 3.0</title>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<!-- Configure the path to the editor. We make it relative now, so that the
|
|
example ZIP file will work anywhere, but please NOTE THAT it's better to
|
|
have it an absolute path, such as '/htmlarea/'. -->
|
|
<script type="text/javascript">
|
|
_editor_url = "../";
|
|
_editor_lang = "en";
|
|
</script>
|
|
|
|
<!-- load the main HTMLArea file, this will take care of loading the CSS and
|
|
other required core scripts. -->
|
|
<script type="text/javascript" src="../htmlarea.js"></script>
|
|
|
|
<!-- load the plugins -->
|
|
<script type="text/javascript">
|
|
// WARNING: using this interface to load plugin
|
|
// will _NOT_ work if plugins do not have the language
|
|
// loaded by HTMLArea.
|
|
|
|
// In other words, this function generates SCRIPT tags
|
|
// that load the plugin and the language file, based on the
|
|
// global variable HTMLArea.I18N.lang (defined in the lang file,
|
|
// in our case "lang/en.js" loaded above).
|
|
|
|
// If this lang file is not found the plugin will fail to
|
|
// load correctly and NOTHING WILL WORK.
|
|
|
|
HTMLArea.loadPlugin("TableOperations");
|
|
HTMLArea.loadPlugin("SpellChecker");
|
|
HTMLArea.loadPlugin("FullPage");
|
|
HTMLArea.loadPlugin("CSS");
|
|
HTMLArea.loadPlugin("ContextMenu");
|
|
//HTMLArea.loadPlugin("HtmlTidy");
|
|
HTMLArea.loadPlugin("ListType");
|
|
HTMLArea.loadPlugin("CharacterMap");
|
|
HTMLArea.loadPlugin("DynamicCSS");
|
|
</script>
|
|
|
|
<style type="text/css">
|
|
html, body {
|
|
font-family: Verdana,sans-serif;
|
|
background-color: #fea;
|
|
color: #000;
|
|
}
|
|
a:link, a:visited { color: #00f; }
|
|
a:hover { color: #048; }
|
|
a:active { color: #f00; }
|
|
|
|
textarea { background-color: #fff; border: 1px solid 00f; }
|
|
</style>
|
|
|
|
<script type="text/javascript">
|
|
var editor = null;
|
|
|
|
function initEditor() {
|
|
|
|
// create an editor for the "ta" textbox
|
|
editor = new HTMLArea("ta");
|
|
|
|
// register the FullPage plugin
|
|
editor.registerPlugin(FullPage);
|
|
|
|
// register the SpellChecker plugin
|
|
editor.registerPlugin(TableOperations);
|
|
|
|
// register the SpellChecker plugin
|
|
editor.registerPlugin(SpellChecker);
|
|
|
|
// register the HtmlTidy plugin
|
|
//editor.registerPlugin(HtmlTidy);
|
|
|
|
// register the ListType plugin
|
|
editor.registerPlugin(ListType);
|
|
|
|
editor.registerPlugin(CharacterMap);
|
|
editor.registerPlugin(DynamicCSS);
|
|
|
|
// register the CSS plugin
|
|
editor.registerPlugin(CSS, {
|
|
combos : [
|
|
{ label: "Syntax:",
|
|
// menu text // CSS class
|
|
options: { "None" : "",
|
|
"Code" : "code",
|
|
"String" : "string",
|
|
"Comment" : "comment",
|
|
"Variable name" : "variable-name",
|
|
"Type" : "type",
|
|
"Reference" : "reference",
|
|
"Preprocessor" : "preprocessor",
|
|
"Keyword" : "keyword",
|
|
"Function name" : "function-name",
|
|
"Html tag" : "html-tag",
|
|
"Html italic" : "html-helper-italic",
|
|
"Warning" : "warning",
|
|
"Html bold" : "html-helper-bold"
|
|
},
|
|
context: "pre"
|
|
},
|
|
{ label: "Info:",
|
|
options: { "None" : "",
|
|
"Quote" : "quote",
|
|
"Highlight" : "highlight",
|
|
"Deprecated" : "deprecated"
|
|
}
|
|
}
|
|
]
|
|
});
|
|
|
|
// add a contextual menu
|
|
editor.registerPlugin("ContextMenu");
|
|
|
|
// load the stylesheet used by our CSS plugin configuration
|
|
editor.config.pageStyle = "@import url(custom.css);";
|
|
|
|
editor.generate();
|
|
return false;
|
|
}
|
|
|
|
HTMLArea.onload = initEditor;
|
|
|
|
function insertHTML() {
|
|
var html = prompt("Enter some HTML code here");
|
|
if (html) {
|
|
editor.insertHTML(html);
|
|
}
|
|
}
|
|
function highlight() {
|
|
editor.surroundHTML('<span style="background-color: yellow">', '</span>');
|
|
}
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<!-- use <body onload="HTMLArea.replaceAll()" if you don't care about
|
|
customizing the editor. It's the easiest way! :) -->
|
|
<body onload="HTMLArea.init();">
|
|
|
|
<h1>HTMLArea 3.0</h1>
|
|
|
|
<p>A replacement for <code>TEXTAREA</code> elements. © <a
|
|
href="http://interactivetools.com">InteractiveTools.com</a>, 2003-2004.</p>
|
|
|
|
<form action="test.cgi" method="post" id="edit" name="edit">
|
|
|
|
<textarea id="ta" name="ta" style="width:100%" rows="24" cols="80">
|
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
|
|
<html>
|
|
|
|
<head>
|
|
<title>Passing parameters to JavaScript code</title>
|
|
<link rel="stylesheet" href="custom.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Passing parameters to JavaScript code</h1>
|
|
|
|
<p>Sometimes we need to pass parameters to some JavaScript function that we
|
|
wrote ourselves. But sometimes it's simply more convenient to include the
|
|
parameter not in the function call, but in the affected HTML elements.
|
|
Usually, all JavaScript calls affect some element, right? ;-)</p>
|
|
|
|
<p>Well, here's an original way to do it. Or at least, I think it's
|
|
original.</p>
|
|
|
|
<h2>But first...</h2>
|
|
|
|
<p>... an example. Why would I need such thing? I have a JS function that
|
|
is called on <code>BODY</code> <code>onload</code> handler. This function
|
|
tries to retrieve the element with the ID "conttoc" and, if present, it will
|
|
<a href="toc.epl" title="Automatic TOC generation">generate an index</a>.
|
|
The problem is, this function exists in some external JavaScript library
|
|
that it's loaded in page. I only needed to pass the parameter from
|
|
<em>one</em> page. Thus, it makes sense to pass the parameter from the HTML
|
|
code on <em>that</em> page, not to affect the others.</p>
|
|
|
|
<p>The first idea that came to me was to use some attribute, like "id" or
|
|
"class". But "id" was locked already, it <em>had</em> to be "conttoc". Use
|
|
"class"? It's not elegant.. what if I really wanted to give it a class, at
|
|
some point?</p>
|
|
|
|
<h2>The idea</h2>
|
|
|
|
<p>So I thought: what are the HTML elements that do not affect the page
|
|
rendering in any way? Well, comments. I mean, <em>comments</em>, HTML
|
|
comments. You know, like <code>&lt;!-- this is a comment --&gt;</code>.</p>
|
|
|
|
<p>Though comments do not normally affect the way browser renders the page,
|
|
they are still parsed and are part of the DOM, as well as any other node.
|
|
But this mean that we can access comments from JavaScript code, just like we
|
|
access any other element, right? Which means that they <em>can</em> affect
|
|
the way that page finally appears ;-)</p>
|
|
|
|
<h2>The code</h2>
|
|
|
|
<p>The main part was the idea. The code is simple ;-) Suppose we have the
|
|
following HTML code:</p>
|
|
|
|
<pre class="code"><span class="function-name">&lt;</span><span class="html-tag">div</span> <span class="variable-name">id=</span><span class="string">&quot;conttoc&quot;</span><span class="paren-face-match">&gt;</span><span class="function-name">&lt;</span><span class="html-tag">/div</span><span class="function-name">&gt;</span></pre>
|
|
|
|
<p>and our function checks for the presence an element having the ID
|
|
"conttoc", and generates a table of contents into it. Our code will also
|
|
check if the "conttoc" element's first child is a comment node, and if so
|
|
will parse additional parameters from there, for instance, a desired prefix
|
|
for the links that are to be generated into it. Why did I need it? Because
|
|
if the page uses a <code>&lt;base&gt;</code> element to specify the default
|
|
link prefix, then links like "#gen1" generated by the <a href="toc.epl">toc
|
|
generator</a> will not point to that same page as they should, but to the
|
|
page reffered from <code>&lt;base&gt;</code>.</p>
|
|
|
|
<p>So the HTML would now look like this:</p>
|
|
|
|
<pre class="code"><span class="function-name">&lt;</span><span class="html-tag">div</span> <span class="variable-name">id=</span><span class="string">&quot;conttoc&quot;</span><span class="function-name">&gt;</span><span class="comment">&lt;!-- base:link/prefix.html --&gt;</span><span class="paren-face-match">&lt;</span><span class="html-tag">/div</span><span class="paren-face-match">&gt;</span></pre>
|
|
|
|
<p>And our TOC generation function does something like this:</p>
|
|
|
|
<pre class="code"><span class="keyword">var</span> <span class="variable-name">element</span> = getElementById(&quot;<span class="string">conttoc</span>&quot;);
|
|
<span class="keyword">if</span> (element.firstChild &amp;&amp; element.firstChild.nodeType == 8) {
|
|
<span class="comment">// 8 means Node.COMMENT_NODE. We're using numeric values
|
|
</span> <span class="comment">// because IE6 does not support constant names.
|
|
</span> <span class="keyword">var</span> <span class="variable-name">parameters</span> = element.firstChild.data;
|
|
<span class="comment">// at this point &quot;parameters&quot; contains base:link/prefix.html
|
|
</span> <span class="comment">// ...
|
|
</span>}</pre>
|
|
|
|
<p>So we retrieved the value passed to the script from the HTML code. This
|
|
was the goal of this article.</p>
|
|
|
|
<hr />
|
|
<address><a href="http://students.infoiasi.ro/~mishoo/">Mihai Bazon</a></address>
|
|
<!-- hhmts start --> Last modified on Thu Apr 3 20:34:17 2003
|
|
<!-- hhmts end -->
|
|
<!-- doc-lang: English -->
|
|
</body>
|
|
</html>
|
|
</textarea>
|
|
|
|
<p />
|
|
|
|
<input type="submit" name="ok" value=" submit " />
|
|
<input type="button" name="ins" value=" insert html " onclick="return insertHTML();" />
|
|
<input type="button" name="hil" value=" highlight text " onclick="return highlight();" />
|
|
|
|
<a href="javascript:mySubmit()">submit</a>
|
|
|
|
<script type="text/javascript">
|
|
function mySubmit() {
|
|
// document.edit.save.value = "yes";
|
|
document.edit.onsubmit(); // workaround browser bugs.
|
|
document.edit.submit();
|
|
};
|
|
</script>
|
|
|
|
</form>
|
|
|
|
</body>
|
|
</html>
|