SAVED-PAGE/3.1 Content-Location: http://www.reversed-java.com/fernflower/?wicket:interface=:1:1::: Content-Type: multipart/mixed; boundary="S60BrowserSavedPage" Content-Length: 189840 Last-Modified: Mon, 31 Jan 2011 11:05:23 GMT --S60BrowserSavedPage Content-Location: http://www.reversed-java.com/fernflower/?wicket:interface=:1:1::: Content-Type: text/html;charset=ucs-2 <HTML lang="de"><HEAD> <META name="verify-v1" content="lNbS0ZtAsqsOpR6aHhbSeC4pGLkYdxE7QlLvdWdH9kk="> <TITLE>Fernflower - 5:><?8;OB>@ Java</TITLE> <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <META name="description" content="The world's first analytical decompiler and deobfuscator for Java."> <META name="description" lang="de" content="Der erste analytische Decompiler und Deobfuscator für Java."> <META name="description" lang="ru" content="5@2K9 0=0;8B8G5A:89 45:><?8;OB>@ 8 45>1DCA:0B>@ O7K:0 Java."> <META name="author" content="Stiver"> <META name="keywords" content="java, free, online, decompiler, decompile, decompilation, deobfuscator, deobfuscate, deobfuscation, bytecode, reverse engineering, class, jar, zip, files, restore, java 5, java 6, generics, batch, fast, simple"> <META name="keywords" lang="de" content="Java, frei, kostenlos, online, Decompiler, dekompilieren, Deobfuscator, deobfuskieren, deobfuszieren, Bytecode, Reverse Engineering, class, jar, zip, Dateien, Files, wiederherstellen, Java 5, Java 6, Generics, Batch, schnell"> <META name="keywords" lang="ru" content="/20, A2>1>4=K9, 15A?;0B=K9, >=;09=, 45:><?8;OB>@, 45:><?8;8@>20BL, 45:><?8;OF8O, 45>1DCA:0B>@, 45>1DCAF8@>20BL, 45>1DCA:0F8O, 109B:>4, @525@A8=3, class, jar, zip, D09;K, 2>AAB0=>28BL, /20 5, /20 6, 35=5@8:8, 1KAB@K9, ?@>AB>9"> <META http-equiv="expires" content="0"> <LINK rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"> <LINK rel="icon" href="img/favicon.ico" type="image/x-icon"> <LINK rel="stylesheet" type="text/css" href="common.css"> <STYLE type="text/css">@import url(style.css) all;</STYLE> <!--[if IE]> <style type="text/css">@import url(style_ie.css);</style> <![endif]--> <SCRIPT type="text/javascript" src="resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js"></SCRIPT><SCRIPT type="text/javascript" src="resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js"></SCRIPT><SCRIPT type="text/javascript"><!--/*--><![CDATA[/*><!--*/ Wicket.Event.add(window, "load", function(event) { setTimeout("var wcall=wicketAjaxGet('?wicket:interface=:1:1:IActivePageBehaviorListener:0:&amp;wicket:ignoreIfNotActive=true',null,null);", 1000);;}); /*-->]]>*/</SCRIPT> <SCRIPT type="text/javascript" src="resources/org.apache.wicket.markup.html.form.upload.MultiFileUploadField/MultiFileUploadField.js"></SCRIPT><SCRIPT type="text/javascript"><!--/*--><![CDATA[/*><!--*/ Wicket.Event.add(window, "domready", function(event) { new MultiSelector('fileInput', document.getElementById('id13'), 7,'#40;8BL').addElement(document.getElementById('id14'));;}); /*-->]]>*/</SCRIPT> <SCRIPT type="text/javascript" src="resources/org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar/progressbar.js"></SCRIPT><LINK rel="stylesheet" type="text/css" href="resources/org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar/UploadProgressBar.css"><LINK></HEAD><BODY style="background-color:#EDEBE2;" marginwidth="2" marginheight="2"> <DIV class="sidebereich" style="float:left;margin-right:-400px;"> </DIV> <DIV class="sidebereich" style="float:right;margin-left:-401px;overflow:hidden;"> <DIV style="margin-left:450px;margin-top:50px;"> <A href=""></A> </DIV> </DIV> <DIV class="cbereich" style="float:left;"> <DIV class="xblock"> <B class="xtop"><B class="xb1"></B><B class="xb2"></B><B class="xb3"></B><B class="xb4"></B></B> <DIV class="xboxcontent" style="overflow:hidden;"> <TABLE style="margin:0px;" cellpadding="0px" cellspacing="0px"><TBODY><TR><TD style="height:100%;width:200px"> <TABLE cellspacing="0" cellpadding="0" style="height:100%;width:100%;"> <TBODY><TR><TD colspan="2" style="padding-right:0px;padding-left:10px;"><A href="/fernflower/" class="menu"><IMG src="img/bullet.gif" style="border:none;vertical-align:middle;"> <SPAN>5:><?8;OB>@</SPAN></A></TD></TR><TR><TD colspan="2" style="padding-right:0px;padding-left:25px;"><A href="/fernflower/forum" class="menu"><IMG src="img/bullet.gif" style="border:none;vertical-align:middle;"> <SPAN>$>@C<</SPAN></A></TD></TR><TR><TD colspan="2" style="padding-right:0px;padding-left:40px;"><A href="/fernflower/faq" class="menu"><IMG src="img/bullet.gif" style="border:none;vertical-align:middle;"> <SPAN>FAQ</SPAN></A></TD></TR><TR><TD style="padding-left:5px;width:45px;"><B>v0.6</B></TD><TD style="padding-right:0px;padding-left:5px;"><A href="/fernflower/contact" class="menu"><IMG src="img/bullet.gif" style="border:none;vertical-align:middle;"> <SPAN>>=B0:B</SPAN></A></TD></TR></TBODY></TABLE> </TD><TD valign="middle" align="center" style="background: #000000;"> <IMG src="img/header.jpg"> </TD><TD style="height:100%;width:200px;"> <TABLE style="height:100%"> <TBODY><TR><TD style="padding-left:35px;"><A href="?wicket:interface=:1:de_img:1:ILinkListener::"><IMG src="img/deflag.jpg" style="border:none;vertical-align:middle;"></A> <A href="?wicket:interface=:1:de:1:ILinkListener::">Deutsch</A></TD></TR><TR><TD style="padding-left:35px;"><A href="?wicket:interface=:1:en_img:1:ILinkListener::"><IMG src="img/enflag.jpg" style="border:none;vertical-align:middle;"></A> <A href="?wicket:interface=:1:en:1:ILinkListener::">English</A></TD></TR><TR><TD style="padding-left:35px;"><A href="?wicket:interface=:1:ru_img:1:ILinkListener::"><IMG src="img/ruflag.jpg" style="border:none;vertical-align:middle;"></A> <A href="?wicket:interface=:1:ru:1:ILinkListener::"> CAA:89</A></TD></TR></TBODY></TABLE> </TD></TR></TBODY></TABLE> </DIV> <B class="xbottom"><B class="xb4"></B><B class="xb3"></B><B class="xb2"></B><B class="xb1"></B></B> </DIV> <P style="height: 20px; margin: 0px; padding: 0px;"></P> <DIV class="xblock"> <B class="xtop"><B class="xb1"></B><B class="xb2"></B><B class="xb3"></B><B class="xb4"></B></B> <DIV class="xboxcontent"> <P style="text-align: left; margin: 0px; padding: 0px 5% 0px 5%;"> Fernflower - ?5@2K9 0=0;8B8G5A:89 45:><?8;OB>@ 109B:>40 Java. 0: B>;L:> C <5=O >1@07C5BAO =5<=>3> A2>1>4=>3> 2@5<5=8, O ?>AB0@0NAL 40BL 1>;55 @0725@=CB>5 8 ?>4@>1=>5 >?8A0=85.  ?>:0 ?@>AB> ?>;L7C9B5AL 8< ?> =07=0G5=8N.  =5 701K209B5 ?@8AK;0BL 103@5?>@BK :) </P> </DIV> <B class="xbottom"><B class="xb4"></B><B class="xb3"></B><B class="xb2"></B><B class="xb1"></B></B> </DIV> <P style="height: 20px; margin: 0px; padding: 0px;"></P> <DIV class="xblock" style="overflow:hidden;"> <B class="xtop"><B class="xb1"></B><B class="xb2"></B><B class="xb3"></B><B class="xb4"></B></B> <DIV class="xboxcontent"> <SPAN sty=""> <TABLE cellpadding="0" cellspacing="0" width="93%" style="margin:0px 0px 0px 5%"> <TBODY><TR><TD rowspan="2" style="width:5em;"><B>23.07.2009</B></TD><TD rowspan="2" style="padding-left:30px;padding-bottom:8px;"> <UL style="margin-top:5px;margin-bottom:5px;margin-left:1em;padding:0px;"> <LI><B>=0G8B5;L=K9 ?@>3@5AA:</B> B5?5@L ?@028;L=> 45:><?8;8@CNBAO 4065 <5B>4K A =5A2>48<K< 3@0D>< ?>B>:0 C?@02;5=8O. >4>1=K5 <5B>4K 22>4OBAO :0: ?@028;> >1DCA:0B>@0<8 (:0: =0?@8<5@ Zelix KlassMaster) 8 45;0NB =52>7<>6=>9 =082=CN ?>H03>2CN 45:><?8;OF8N. Fernflower - ?5@2K9 45:><?8;OB>@ 2 8AB>@88 A B0:>9 A?>A>1=>ABLN.</LI> <LI> 071>@ =525@=KE 8;8 >1DCAF8@>20==KE 0B@81CB>2 InnerClass</LI> <LI>A?@02;5=> =5A:>;L:> =5B@8280;L=KE >H81>:, 2 B>< G8A;5 :0A0NI8EAO ;>:0;L=KE ?5@5<5==KE 2> 2=CB@5==8E :;0AA0E 8 ?@8A20820=89 2 A>AB025 &amp;&amp; 8 || 2K@065=89.</LI> <LI>0:A8<0;L=>5 2@5<O >1@01>B:8 ?>2KH5=> 4> 10 <8=CB.</LI> </UL> <B>A:>@5 4>ABC?5=:</B> Fernflower 2 2845 ?;038=0 4;O Eclipse (@01>G55 =0720=85: Fernclipse) </TD><TD align="right" valign="top"><A href="rss/ru/rss.xml" style="text-decoration:none;"><IMG src="img/rss.gif" style="border:none;"></A></TD></TR><TR><TD align="right" valign="bottom"><A href="/fernflower/allnews"><NOBR><SPAN>A5 =>2>AB8</SPAN></NOBR></A></TD></TR></TBODY></TABLE> </SPAN> </DIV> <B class="xbottom"><B class="xb4"></B><B class="xb3"></B><B class="xb2"></B><B class="xb1"></B></B> </DIV> <P style="height: 20px; margin: 0px; padding: 0px;"></P> <DIV class="xblock"> <B class="xtop"><B class="xb1"></B><B class="xb2"></B><B class="xb3"></B><B class="xb4"></B></B> <DIV class="xboxcontent"> <FORM style="padding:0px;margin:0px;" id="id15" method="post" action="?wicket:interface=:1:ajax-simpleUpload:2:IFormSubmitListener::" enctype="multipart/form-data" onsubmit="var def=new Wicket.WUPB.Def('id15', 'id16', 'id17', 'resources/org.apache.wicket.Application/org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar'); Wicket.WUPB.start(def);"><DIV style="display:none"><INPUT type="hidden" name="id15_hf_0" id="id15_hf_0"></DIV> <CENTER> <TABLE style="width:90%;"> <TBODY><TR><TD colspan="2" style="text-align:left;vertical-align:top;"> <SPAN>"8?K D09;>2: *.class, *.jar, *.zip</SPAN> <DIV class="mfuex"> <INPUT type="file" class="wicket-mfu-field" id="id14"> <DIV class="wicket-mfu-container" id="id13"> <DIV class="wicket-mfu-caption"><0:A. 7 D09;>2, 5 MB, 10 <8=CB</DIV> </DIV> </DIV> </TD></TR><TR><TD style="text-align:left;vertical-align:top;padding-top:30px;"> <INPUT type="checkbox" checked="checked" name="inner">decompile inner classes<BR> <INPUT type="checkbox" checked="checked" name="enums">decompile enumerations<BR> <INPUT type="checkbox" name="generic">decompile generic signatures<BR> <INPUT type="checkbox" checked="checked" name="assertions">decompile assertions<BR> <INPUT type="checkbox" checked="checked" name="bridge">hide bridge methods<BR> <INPUT type="checkbox" name="synthetic">hide synthetic methods<BR> <INPUT type="checkbox" checked="checked" name="emptysuper">hide empty super invocation<BR> <INPUT type="checkbox" checked="checked" name="emptydefault">hide empty default constructor<BR> </TD><TD style="text-align:left;vertical-align:top;padding-top:30px;"> <INPUT type="checkbox" checked="checked" name="class14">collapse 1.4 class references<BR> <INPUT type="checkbox" checked="checked" name="noexceptionsreturn">assume return not throwing exceptions<BR> <INPUT type="checkbox" checked="checked" name="getclass">remove getClass() invocation in a qualified new statement<BR> <INPUT type="checkbox" checked="checked" name="boolone">interpret int 1 as boolean true (compiler bug)<BR> <INPUT type="checkbox" checked="checked" name="synthnotset">allow for not set synthetic attribute (compiler bug)<BR> <INPUT type="checkbox" checked="checked" name="undeftypeobject">consider nameless types as Object (compiler bug) </TD></TR></TBODY></TABLE> </CENTER> <P style="text-align:center"> <INPUT type="submit" value="Decompile" name="btsubmit" id="id18"> </P> <DIV class="wupb-container"> <DIV class="wupb-progressBar" style="display:none;" id="id17"><DIV class="wupb-border"><DIV class="wupb-background"><DIV class="wupb-foreground"></DIV></DIV></DIV></DIV> <DIV class="wupb-uploadStatus" style="display:none;" id="id16"></DIV> </DIV> <DIV style="text-align:left;padding-right:7%;padding-left:7%;margin:0px;padding-top:0px;padding-bottom:0px;"> #@>25=L ;>30: <SPAN><INPUT name="logging" type="radio" checked="checked" value="0" id="id1a-0"><LABEL for="id1a-0">;0AAK</LABEL><INPUT name="logging" type="radio" value="1" id="id1a-1"><LABEL for="id1a-1">5B>4K</LABEL></SPAN> </DIV> </FORM> <HR noshade="noshade" style="width:90%;text-align:center;margin-top:0px;"> <CENTER> <DIV id="id1b"> <TABLE style="border-collapse:collapse;border:3px solid black;text-align:center"> <TBODY><TR style="font-weight:bold;font-size:larger"><TH style="padding-left:30px;padding-right:30px;padding-top:5px;padding-bottom:5px;border-right:1px solid gray;border-bottom:3px solid black">Download</TH><TH style="padding-left:30px;padding-right:30px;padding-top:5px;padding-bottom:5px;border-bottom:3px solid black">Highlighted Code (HTML)</TH></TR><TR><TD style="padding-left:30px;padding-right:30px;padding-top:5px;padding-bottom:5px;border:1px solid gray"> <A href="res/20110131110131387_oakcjdvp/r0.0.0.5.7.java" id="id2c"><SPAN id="id2d">r0.0.0.5.7.java</SPAN></A><SPAN id="id2e"></SPAN> </TD><TD style="padding-left:30px;padding-right:30px;padding-top:5px;padding-bottom:5px;border:1px solid gray"> <A href="res/20110131110131387_oakcjdvp/r0.0.0.5.7.java.html" id="id2f" target="_blank"><SPAN id="id30">r0.0.0.5.7.java.html</SPAN></A><SPAN id="id31"></SPAN> </TD></TR></TBODY></TABLE> </DIV> </CENTER> <HR noshade="noshade" style="width:90%;text-align:center;"> <CENTER> <DIV class="tabpanel4" id="id22"> <DIV class="tab-row"> <UL> <LI class="tab0 selected"> <A href="?wicket:interface=:1:tabs:tabs-container:tabs:0:link:2:ILinkListener::" id="id32" onclick="var wcall=wicketAjaxGet('?wicket:interface=:1:tabs:tabs-container:tabs:0:link:2:IBehaviorListener:0:',null,null, function() {return Wicket.$('id32') != null;}.bind(this));return !wcall;"><SPAN>>=A>;L</SPAN></A> </LI><LI class="tab1 last"> <A href="?wicket:interface=:1:tabs:tabs-container:tabs:1:link:2:ILinkListener::" id="id33" onclick="var wcall=wicketAjaxGet('?wicket:interface=:1:tabs:tabs-container:tabs:1:link:2:IBehaviorListener:0:',null,null, function() {return Wicket.$('id33') != null;}.bind(this));return !wcall;"><SPAN>r0.0.0.5.7.java</SPAN></A> </LI> </UL> </DIV> <DIV class="tab-panel"> <TEXTAREA class="console" readonly="readonly" wrap="off" name="tabs:panel:console" id="id24">11:01:49 done. 11:01:46 ... written. 11:01:46 Writing class r ... 11:01:46 ... proceeded. 11:01:31 Processing class r ... 11:01:31 WARNING: Nested class i missing! 11:01:31 WARNING: Nested class b missing! 11:01:31 WARNING: Nested class v missing! 11:01:31 Initializing decompiler engine.. </TEXTAREA> </DIV> </DIV> </CENTER> <P style="height: 20px; margin: 0px; padding: 0px;"></P> </DIV> <B class="xbottom"><B class="xb4"></B><B class="xb3"></B><B class="xb2"></B><B class="xb1"></B></B> </DIV> <CENTER> <DIV style="padding-top:20px;"> <ADDRESS>© 2008-2009 Stiver - All rights reserved and reversed</ADDRESS> </DIV> </CENTER> </DIV> </BODY></HTML> --S60BrowserSavedPage Content-Location: http://www.reversed-java.com/fernflower/common.css Content-Type: text/css;charset=ucs-2 * { <!--margin:0px; padding:0px;-->} body,html {margin:0;padding:0;height:100%;} div.wupb-container { text-align:center; } div.tabpanel4 { width: 90%; } div.tabpanel4 div.tab-panel { height:500px; border: 1px solid #000000; } div.tab-panel { margin-bottom:0px; } div.tabpanel4 div.tab-row ul { height: 20px; margin: 0; padding-left: 10px; } div.tabpanel4 div.tab-row li { margin: 0; padding: 0; display: inline; list-style-type: none; } div.tabpanel4 div.tab-row a:link, div.tabpanel4 div.tab-row a:visited { float: left; background: #f3f3f3; font-size: 12px; line-height: 14px; font-weight: bold; padding: 2px 10px 2px 10px; margin-right: 4px; border: 1px solid #ccc; text-decoration: none; color: #666; } div.tabpanel4 div.tab-row li.selected a:link, div.tabpanel4 div.tab-row li.selected a:visited { border-bottom: 1px solid #fff; background: #fff; color: #000; } div.tabpanel4 div.tab-row a:hover { cursor:default; background: #f3f3f3; } div.tabpanel4 div.tab-row li.selected a:hover { cursor:default; background: #ffffff; } div.cbereich { min-height:90%; height:auto !important; height:90%; width:800px; } div.sidebereich { min-height:90%; height:auto !important; height:90%; width:50%; } a.menu { text-decoration:none; font-size:larger; } a.menu:link, a.menu:visited, a.menu:focus, a.menu:hover, a.menu:active { color:blue; } .xblock {background-color:#EDEBE2; padding:0px; } .xboxcontent {display:block; background-color:#FFFFFF; border:0 solid #000000; border-width:0 1px; margin:0px; padding:0px;} .xtop, .xbottom {display:block; background:transparent; font-size:1px; margin:0px; padding:0px;} .xb1, .xb2, .xb3, .xb4 {display:block; overflow:hidden; padding: 0px;} .xb1, .xb2, .xb3 {height:1px;} .xb2, .xb3, .xb4 {background-color:#FFFFFF; border-left:1px solid #000000; border-right:1px solid #000000;} .xb1 {margin:0 5px; background:#000000;} .xb2 {margin:0 3px; border-width:0 2px;} .xb3 {margin:0 2px;} .xb4 {height:2px; margin:0 1px;} --S60BrowserSavedPage Content-Location: http://www.reversed-java.com/fernflower/resources/org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar/UploadProgressBar.css Content-Type: text/css;charset=ucs-2 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Progress bar */ .wupb-progressBar { margin: 0.5em auto 0 auto; } .wupb-border { border: 1px solid #888; background-color: #eee; width: 20em; margin: 0 auto; } .wupb-background { background-color: #ccc; height: 1.5em; width: 0%; } .wupb-foreground { /* Nothing here - included merely so you know you can change this. */ } --S60BrowserSavedPage Content-Location: resources/org.apache.wicket.markup.html.WicketEventReference/wicket-event.js Content-Type: application/x-javascript;charset=ucs-2 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Wicket Ajax Support * * @author Igor Vaynberg * @author Matej Knopp */ if (Function.prototype.bind == null) { Function.prototype.bind = function(object) { var __method = this; return function() { return __method.apply(object, arguments); } } } // Wicket Namespace if (typeof(Wicket) == "undefined") Wicket = { }; /** * Browser types */ Wicket.Browser = { isKHTML: function() { return /Konqueror|KHTML/.test(navigator.userAgent) && !/Apple/.test(navigator.userAgent); }, isSafari: function() { return /KHTML/.test(navigator.userAgent) && /Apple/.test(navigator.userAgent); }, isOpera: function() { return !Wicket.Browser.isSafari() && typeof(window.opera) != "undefined"; }, isIE: function() { return !Wicket.Browser.isSafari() && typeof(document.all) != "undefined" && typeof(window.opera) == "undefined"; }, isIEQuirks: function() { // is the browser internet explorer in quirks mode (we could use document.compatMode too) return Wicket.Browser.isIE() && document.documentElement.clientHeight == 0; }, isIELessThan7: function() { var index = navigator.userAgent.indexOf("MSIE"); var version = parseFloat(navigator.userAgent.substring(index + 5)); return Wicket.Browser.isIE() && version < 7; }, isIE7: function() { var index = navigator.userAgent.indexOf("MSIE"); var version = parseFloat(navigator.userAgent.substring(index + 5)); return Wicket.Browser.isIE() && version >= 7; }, isGecko: function() { return /Gecko/.test(navigator.userAgent) && !Wicket.Browser.isSafari(); } }; /** * Events related code * Based on code from Mootools (http://mootools.net) */ Wicket.Event = { idCounter: 0, getId: function(element) { var current = element.getAttribute("id"); if (typeof(current) == "string" && current.length > 0) { return current; } else { current = "wicket-generated-id-" + Wicket.Event.idCounter++; element.setAttribute("id", current); return current; } }, handler: function() { var id = this[0]; var original = this[1]; var element = Wicket.$(id); original.bind(element)(); }, // adds an event of specified type to the element // also supports the domready event on window // domready is event fired when the DOM is complete, but before loading external resources (images, ...) add: function(element, type, fn) { // is the event domready? if (element == window && type == "domready") { Wicket.Event.addDomReadyEvent(fn); } else { if (element.addEventListener){ element.addEventListener((type == 'mousewheel' && Wicket.Browser.isGecko()) ? 'DOMMouseScroll' : type, fn, false); } else { if (element == window || element == document) { fn = fn.bind(element); } else { fn = Wicket.Event.handler.bind([Wicket.Event.getId(element), fn]); } // Because of the fn.bind (returning a new function object) // you can't detach the event first to be sure that there are no doubles :( //element.detachEvent('on'+type, fn); element.attachEvent('on'+type, fn); } } return element; }, // handlers that will be fired on dom ready event domReadyHandlers : new Array(), // fires the dom ready event and cleanup the handlers fireDomReadyHandlers : function() { var h = Wicket.Event.domReadyHandlers; while (h.length > 0) { var c = h.shift(); c(); } Wicket.Event.domReadyHandlers = null; }, // adds the dom ready event addDomReadyEvent : function(fn) { // is the window already loaded? if (window.loaded) { fn(); } else if (!window.events || !window.events.domready) { // register the handler Wicket.Event.domReadyHandlers.push(fn); // callback var domReady = function() { if (window.loaded) return; window.loaded = true; // invoke the handlers Wicket.Event.fireDomReadyHandlers(); }.bind(this); if (document.readyState && (Wicket.Browser.isKHTML() || Wicket.Browser.isSafari())) { //safari and konqueror don't support the event - simulate it through a timeout var domCheck = function() { if (document.readyState == "loaded" || document.readyState == "complete") { domReady(); } else { // dom not yet ready, set timer to check later window.setTimeout(domCheck, 10); } } window.setTimeout(domCheck, 10); } else if (document.readyState && Wicket.Browser.isIE()) { if (document.getElementById('ie_ready') == null) { // for internet explorer we need to load a "dummy" scrip from ::/ to get the // readystatechangeevernt - that means the main page being loaded and now the browser // is loading dependencies var src = (window.location.protocol == 'https:') ? '\/\/:' : 'javascript:void(0)'; document.write('<script id="ie_ready" defer src="' + src + '"><\/script>'); document.getElementById('ie_ready').onreadystatechange = function() { if (this.readyState == 'complete') domReady(); }; } } else { // other browsers Wicket.Event.add(document, "DOMContentLoaded", domReady); } } else { window.addEventListener("domready", fn, false); } } } --S60BrowserSavedPage Content-Location: resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js Content-Type: application/x-javascript;charset=ucs-2 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* * Wicket Ajax Support * * @author Igor Vaynberg * @author Matej Knopp */ if (Function.prototype.bind == null) { Function.prototype.bind = function(object) { var __method = this; return function() { return __method.apply(object, arguments); } } } // Wicket Namespace if (typeof(Wicket) == "undefined") Wicket = { }; Wicket.$ = function(arg) { if (arg == null || typeof(arg) == "undefined") { return null; } if (arguments.length > 1) { var e=[]; for (var i=0; i<arguments.length; i++) { e.push(Wicket.$(arguments[i])); } return e; } else if (typeof arg == 'string') { return document.getElementById(arg); } else { return arg; } } // returns if the element belongs to current document // if the argument is not element, function returns true Wicket.$$ = function(element) { if (typeof(element) == "string") { element = Wicket.$(element); } if (element == null || typeof(element) == "undefined" || element.tagName == null || typeof(element.tagName) == "undefined") { return true; } var id = element.getAttribute('id'); if (typeof(id) == "undefined" || id == null || id == "") return element.ownerDocument == document; else return document.getElementById(id) == element; } Wicket.isPortlet = function() { return Wicket.portlet == true; } Wicket.emptyFunction = function() { }; Wicket.Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } /** * Add a check for old Safari. It should not be our responsibility to check the * browser's version, but it's a minor version that makes a difference here, * so we try to be at least user friendly. */ if (typeof DOMParser == "undefined" && Wicket.Browser.isSafari()) { DOMParser = function () {} DOMParser.prototype.parseFromString = function (str, contentType) { alert('You are using an old version of Safari.\nTo be able to use this page you need at least version 2.0.1.'); } } /** * Logging functionality. */ Wicket.Log = { enabled: function() { return wicketAjaxDebugEnabled(); }, info: function(msg) { if (Wicket.Log.enabled()) WicketAjaxDebug.logInfo(msg); }, error: function(msg) { if (Wicket.Log.enabled()) WicketAjaxDebug.logError(msg); }, log: function(msg) { if(Wicket.Log.enabled()) WicketAjaxDebug.log(msg); } }, /** * Functions executer takes array of functions and executes them. Each function gets * the notify object, which needs to be called for the next function to be executed. * This way the functions can be executed synchronously. Each function has to call * the notify object at some point, otherwise the functions after it wont be executed. * After the FunctionExecuter is initiatialized, the start methods triggers the * first function. */ Wicket.FunctionsExecuter = Wicket.Class.create(); Wicket.FunctionsExecuter.prototype = { initialize: function(functions) { this.functions = functions; this.current = 0; this.depth = 0; // we need to limit call stack depth }, processNext: function() { if (this.current < this.functions.length) { var f = this.functions[this.current]; var run = function() { f(this.notify.bind(this)); }.bind(this); this.current++; if (this.depth > 50 || Wicket.Browser.isKHTML() || Wicket.Browser.isSafari()) { // to prevent khtml bug that crashes entire browser // or to prevent stack overflow (safari has small call stack) this.depth = 0; window.setTimeout(run, 1); } else { this.depth ++; run(); } } }, start: function() { this.processNext(); }, notify: function() { this.processNext(); } } Wicket.replaceOuterHtmlIE = function(element, text) { // replaces all <iframe references with <__WICKET_JS_REMOVE_X9F4A__iframe text var marker = "__WICKET_JS_REMOVE_X9F4A__"; function markIframe(text) { var t = text; var r = /<\s*iframe/i; while ((m = t.match(r)) != null) { t = Wicket.replaceAll(t, m[0], "<" + marker + m[0].substring(1)); } return t; } function removeIframeMark(text) { return Wicket.replaceAll(text, marker, ""); } if (element.tagName == "SCRIPT") { // we need to get the javascript content, so we create an invalid DOM structure, // (that is necessary for IE to let us see the innerHTML of the script tag var tempDiv = document.createElement("div"); tempDiv.innerHTML = "<table>" + text + "</table>"; var script = tempDiv.childNodes[0].childNodes[0].innerHTML; element.outerHtml = text; try { eval(script); } catch (e) { Wicket.Log.error(e); } return; } var parent = element.parentNode; var tn = element.tagName; var tempDiv = document.createElement("div"); var tempParent; // array for javascripts that were in the text var scripts = new Array(); if (window.parent == window || window.parent == null) { document.body.appendChild(tempDiv); } if (tn != 'TBODY' && tn != 'TR' && tn != "TD" && tn != "THEAD" && tn != "TFOOT" && tn != "TH") { // in case the element is not any of these // this is not exactly nice, but we need to get invalid markup inside innerHTML, // because otherwise IE just swallows the <script> tags (sometimes) tempDiv.innerHTML = '<table style="display:none">' + markIframe(text) + '</table>'; // now copy the script tags to array (needed later for script execution) var s = tempDiv.getElementsByTagName("script"); for (var i = 0; i < s.length; ++i) { scripts.push(s[i]); } // now use regular div so that we won't mess the DOM tempDiv.innerHTML = '<div style="display:none">' + text + '</div>'; // set the outer <div> as parent tempParent = tempDiv.childNodes[0]; tempParent.parentNode.removeChild(tempParent); } else { // same trick as with before, this time we need a div to to create invalid markup // (otherwise we wouldn't be able to get the script tags) tempDiv.innerHTML = '<div style="display:none">' + markIframe(text) + '</div>'; // now copy the script tags to array (needed later for script execution) var s = tempDiv.getElementsByTagName("script"); for (var i = 0; i < s.length; ++i) { scripts.push(s[i]); } // hack to get around the fact that IE doesn't allow to replace table elements tempDiv.innerHTML = '<table style="display: none">' + text + '</table>'; // get the parent element of new elements tempParent = tempDiv.getElementsByTagName(tn).item(0).parentNode; } // place all newly created elements before the old element while(tempParent.childNodes.length > 0) { var tempElement = tempParent.childNodes[0]; tempParent.removeChild(tempElement); parent.insertBefore(tempElement, element); tempElement = null; } // remove the original element if(element.style.backgroundImage) element.style.backgroundImage = ""; parent.removeChild(element); element.outerHTML = ""; element = ""; if (window.parent == window || window.parent == null) { if(tempDiv.style.backgroundImage) tempDiv.style.backgroundImage = ""; document.body.removeChild(tempDiv); } tempDiv.outerHTML = ""; parent = null; tempDiv = null; tempParent = null; for (i = 0; i < scripts.length; ++i) { Wicket.Head.addJavascripts(scripts[i], removeIframeMark); } } Wicket.replaceOuterHtmlSafari = function(element, text) { // if we are replacing a single <script> element if (element.tagName == "SCRIPT") { // create temporal div and add script as inner HTML var tempDiv = document.createElement("div"); tempDiv.innerHTML = text; // try to get script content var script = tempDiv.childNodes[0].innerHTML; if (typeof(script) != "string") { script = tempDiv.childNodes[0].text; } element.outerHTML = text; try { eval(script); } catch (e) { Wicket.Log.error(e); } return; } var parent = element.parentNode; var next = element.nextSibling; var index = 0; while (parent.childNodes[index] != element) { ++index; } element.outerHTML = text; element = parent.childNodes[index]; // go through newly added elements and try to find javascripts that // need to be executed while (element != next) { try { Wicket.Head.addJavascripts(element); } catch (ignore) { } element = element.nextSibling; } } /** * A cross-browser method that replaces the markup of an element. The behavior * is similar to calling element.outerHtml=text in internet explorer. However * this method also takes care of executing javascripts within the markup on * browsers that don't do that automatically. * Also this method takes care of replacing table elements (tbody, tr, td, thead) * on browser where it's not supported when using outerHTML (IE). */ Wicket.replaceOuterHtml = function(element, text) { if (Wicket.Browser.isIE()) { Wicket.replaceOuterHtmlIE(element, text); } else if (Wicket.Browser.isSafari() || Wicket.Browser.isOpera()) { Wicket.replaceOuterHtmlSafari(element, text); } else /* GECKO */ { // create range and fragment var range = element.ownerDocument.createRange(); range.selectNode(element); var fragment = range.createContextualFragment(text); element.parentNode.replaceChild(fragment, element); } } /** * Decoding functionality * * Wicket sends rendered components and javascript as CDATA section of XML document. When the * component body itself contains a CDATA section, Wicket needs to escape it properly. */ Wicket.decode = function(encoding, text) { if (encoding == "wicket1") { return Wicket.decode1(text); } } Wicket.decode1 = function(text) { return Wicket.replaceAll(text, "]^", "]"); } Wicket.replaceAll = function(str, from, to) { var idx = str.indexOf(from); while (idx > -1) { str = str.replace(from, to); idx = str.indexOf(from); } return str; } /** * Form serialization * * To post a form using Ajax Wicket first needs to serialize it, which means composing a string * from form elments names and values. The string will then be set as body of POST request. */ Wicket.Form = { } Wicket.Form.encode = function(text) { if (encodeURIComponent) { return encodeURIComponent(text); } else { return escape(text); } } Wicket.Form.serializeSelect = function(select){ // if it is a non-multiple select, iterating on each element is not required (WICKET-389) if (select.multiple == false){ return Wicket.Form.encode(select.name) + "=" + Wicket.Form.encode(select.value) + "&"; } //else var result = ""; for (var i = 0; i < select.options.length; ++i) { var option = select.options[i]; if (option.selected) { result += Wicket.Form.encode(select.name) + "=" + Wicket.Form.encode(option.value) + "&"; } } return result; } // this function intentionally ignores image and submit inputs Wicket.Form.serializeInput = function(input) { var type = input.type.toLowerCase(); if ((type == "checkbox" || type == "radio") && input.checked) { return Wicket.Form.encode(input.name) + "=" + Wicket.Form.encode(input.value) + "&"; } else if (type == "text" || type == "password" || type == "hidden" || type == "textarea" || type == "search") { return Wicket.Form.encode(input.name) + "=" + Wicket.Form.encode(input.value) + "&"; } else { return ""; } } //list of item to exclude from serialization Wicket.Form.excludeFromAjaxSerialization = {}; // Returns url/post-body fragment representing element (e) Wicket.Form.serializeElement = function(e) { if (Wicket.Form.excludeFromAjaxSerialization && e.id && Wicket.Form.excludeFromAjaxSerialization[e.id] == "true") { return ""; } var tag = e.tagName.toLowerCase(); if (tag == "select") { return Wicket.Form.serializeSelect(e); } else if (tag == "input" || tag == "textarea") { return Wicket.Form.serializeInput(e); } else { return ""; } } Wicket.Form.doSerialize = function(form) { var result = ""; for (var i = 0; i < form.elements.length; ++i) { var e = form.elements[i]; if (e.name && e.name != "" && !e.disabled) { result += Wicket.Form.serializeElement(e); } } return result; } Wicket.Form.serialize = function(element, dontTryToFindRootForm) { if (element.tagName.toLowerCase() == "form") { return Wicket.Form.doSerialize(element); } else { // try to find a form in DOM parents var elementBck = element; if (dontTryToFindRootForm != true) { do { element = element.parentNode; } while(element.tagName.toLowerCase() != "form" && element.tagName.toLowerCase() != "body") } if (element.tagName.toLowerCase() == "form"){ // We found a form : serialize it return Wicket.Form.doSerialize(element); } else { // there is not form in dom hierarchy // simulate it var form = document.createElement("form"); var parent = elementBck.parentNode; parent.replaceChild(form, elementBck); form.appendChild(elementBck); var result = Wicket.Form.doSerialize(form); parent.replaceChild(elementBck, form); return result } } } /** * DOM nodes serialization functionality * * The purpose of these methods is to return a string representation * of the DOM tree. */ Wicket.DOM = { } // Method for serializing DOM nodes to string // original taken from Tacos (http://tacoscomponents.jot.com) Wicket.DOM.serializeNodeChildren = function(node) { if (node == null) { return "" } var result = ""; for (var i = 0; i < node.childNodes.length; i++) { var thisNode = node.childNodes[i]; switch (thisNode.nodeType) { case 1: // ELEMENT_NODE case 5: // ENTITY_REFERENCE_NODE result += Wicket.DOM.serializeNode(thisNode); break; case 8: // COMMENT result += "<!--" + thisNode.nodeValue + "-->"; break; case 4: // CDATA_SECTION_NODE result += "<![CDATA[" + thisNode.nodeValue + "]]>"; break; case 3: // TEXT_NODE case 2: // ATTRIBUTE_NODE result += thisNode.nodeValue; break; default: break; } } return result; } Wicket.DOM.serializeNode = function(node){ if (node == null) { return "" } var result = ""; result += '<' + node.nodeName; if (node.attributes && node.attributes.length > 0) { for (var i = 0; i < node.attributes.length; i++) { result += " " + node.attributes[i].name + "=\"" + node.attributes[i].value + "\""; } } result += '>'; result += Wicket.DOM.serializeNodeChildren(node); result += '</' + node.nodeName + '>'; return result; } // Utility function that determines whether given element is part of the current document Wicket.DOM.containsElement = function(element) { var id = element.getAttribute("id"); if (id != null) return Wicket.$(id) != null; else return false; } /** * Channel management * * Wicket Ajax requests are organized in channels. A channel maintain the order of * requests and determines, what should happen when a request is fired while another * one is being processed. The default behavior (stack) puts the all subsequent requests * in a queue, while the drop behavior limits queue size to one, so only the most * recent of subsequent requests is executed. * The name of channel determines the policy. E.g. channel with name foochannel|s is * a stack channel, while barchannel|d is a drop channel. * * The Channel class is supposed to be used through the ChannelManager. */ Wicket.Channel = Wicket.Class.create(); Wicket.Channel.prototype = { initialize: function(name) { var res = name.match(/^([^|]+)\|(d|s)$/) if (res == null) this.type ='s'; // default to stack else this.type = res[2]; this.callbacks = new Array(); this.busy = false; }, schedule: function(callback) { if (this.busy == false) { this.busy = true; return callback(); } else { Wicket.Log.info("Channel busy - postponing..."); if (this.type == 's') // stack this.callbacks.push(callback); else /* drop */ this.callbacks[0] = callback; return null; } }, done: function() { var c = null; if (this.callbacks.length > 0) { c = this.callbacks.shift(); } if (c != null && typeof(c) != "undefined") { Wicket.Log.info("Calling posponed function..."); // we can't call the callback from this call-stack // therefore we set it on timer event window.setTimeout(c, 1); } else { this.busy = false; } } }; /** * Channel manager maintains a map of channels. */ Wicket.ChannelManager = Wicket.Class.create(); Wicket.ChannelManager.prototype = { initialize: function() { this.channels = new Array(); }, // Schedules the callback to channel with given name. schedule: function(channel, callback) { var c = this.channels[channel]; if (c == null) { c = new Wicket.Channel(channel); this.channels[channel] = c; } return c.schedule(callback); }, // Tells the ChannelManager that the current callback in channel with given name // has finished processing and another scheduled callback can be executed (if any). done: function(channel) { var c = this.channels[channel]; if (c != null) c.done(); } }; // Default channel manager instance Wicket.channelManager = new Wicket.ChannelManager(); /** * The Ajax class handles low level details of creating and pooling XmlHttpRequest objects, * as well as registering and execution of pre-call, post-call and failure handlers. */ Wicket.Ajax = { // Creates a new instance of a XmlHttpRequest createTransport: function() { var transport = null; if (window.ActiveXObject) { transport = new ActiveXObject("Microsoft.XMLHTTP"); Wicket.Log.info("Using ActiveX transport"); } else if (window.XMLHttpRequest) { transport = new XMLHttpRequest(); Wicket.Log.info("Using XMLHttpRequest transport"); } if (transport == null) { Wicket.Log.error("Could not locate ajax transport. Your browser does not support the required XMLHttpRequest object or wicket could not gain access to it."); } return transport; }, transports: [], // Returns a transport from pool if any of them is not being used, or creates new instance getTransport: function() { var t = Wicket.Ajax.transports; for (var i = 0; i < t.length; ++i) { if (t[i].readyState == 0) { return t[i]; } } t.push(Wicket.Ajax.createTransport()); return t[t.length-1]; }, preCallHandlers: [], postCallHandlers: [], failureHandlers: [], registerPreCallHandler: function(handler) { var h = Wicket.Ajax.preCallHandlers; h.push(handler); }, registerPostCallHandler: function(handler) { var h = Wicket.Ajax.postCallHandlers; h.push(handler); }, registerFailureHandler: function(handler) { var h = Wicket.Ajax.failureHandlers; h.push(handler); }, invokePreCallHandlers: function() { var h = Wicket.Ajax.preCallHandlers; if (h.length > 0) { Wicket.Log.info("Invoking pre-call handler(s)..."); } for (var i = 0; i < h.length; ++i) { h[i](); } }, invokePostCallHandlers: function() { var h = Wicket.Ajax.postCallHandlers; if (h.length > 0) { Wicket.Log.info("Invoking post-call handler(s)..."); } for (var i = 0; i < h.length; ++i) { h[i](); } }, invokeFailureHandlers: function() { var h = Wicket.Ajax.failureHandlers; if (h.length > 0) { Wicket.Log.info("Invoking failure handler(s)..."); } for (var i = 0; i < h.length; ++i) { h[i](); } } } /** * The Ajax.Request class encapsulates a XmlHttpRequest. */ Wicket.Ajax.Request = Wicket.Class.create(); Wicket.Ajax.Request.prototype = { // Creates a new request object. initialize: function(url, loadedCallback, parseResponse, randomURL, failureHandler, channel) { this.url = url; this.loadedCallback = loadedCallback; // whether we should give the loadedCallback parsed response (DOM tree) or the raw string this.parseResponse = parseResponse != null ? parseResponse : true; this.randomURL = randomURL != null ? randomURL : true; this.failureHandler = failureHandler != null ? failureHandler : function() { }; this.async = true; this.channel = channel; this.precondition = function() { return true; } // allow a condition to block request // when suppressDone is set, the loadedCallback is responsible for calling // Ajax.Request.done() to process possibly pendings requests in the channel. this.suppressDone = false; this.instance = Math.random(); this.debugContent = true; }, done: function() { Wicket.channelManager.done(this.channel); }, createUrl: function() { if (this.randomURL == false) return this.url; else return this.url + (this.url.indexOf("?")>-1 ? "&" : "?") + "random=" + Math.random(); }, log: function(method, url) { var log = Wicket.Log.info; log(""); log("Initiating Ajax "+method+" request on " + url); }, failure: function() { this.failureHandler(); Wicket.Ajax.invokePostCallHandlers(); Wicket.Ajax.invokeFailureHandlers(); }, // Executes a get request get: function() { if (Wicket.isPortlet()) { // first check if a query string is provided var qs = this.url.indexOf('?'); if (qs==-1) { qs = this.url.indexOf('&'); } if (qs>-1) { var query = this.url.substring(qs+1); // ensure the query is not empty if (query && query.length > 0) { // cut off query part from original url this.url = this.url.substring(0,qs); // ensure query ends with & if (query.charAt(query.length-1)!='&') { query += "&"; } // post the query string instead to support portlets // for which you cannot modify/append to the url return this.post(query); } } } if (this.channel != null) { var res = Wicket.channelManager.schedule(this.channel, this.doGet.bind(this)); return res != null ? res : true; } else { return this.doGet(); } }, // The actual get request implementation doGet: function() { if (this.precondition()) { this.transport = Wicket.Ajax.getTransport(); var url = this.createUrl(); this.log("GET", url); Wicket.Ajax.invokePreCallHandlers(); var t = this.transport; if (t != null) { t.open("GET", url, this.async); t.onreadystatechange = this.stateChangeCallback.bind(this); // set a special flag to allow server distinguish between ajax and non-ajax requests t.setRequestHeader("Wicket-Ajax", "true"); if (typeof(Wicket.Focus.lastFocusId) != "undefined" && Wicket.Focus.lastFocusId != "" && Wicket.Focus.lastFocusId != null) t.setRequestHeader("Wicket-FocusedElementId", Wicket.Focus.lastFocusId); t.setRequestHeader("Accept", "text/xml"); t.send(null); return true; } else { this.failure(); return false; } } else { Wicket.Log.info("Ajax GET stopped because of precondition check, url:" + this.url); this.done(); return true; } }, // Posts the given string post: function(body) { if (this.channel != null) { var res = Wicket.channelManager.schedule(this.channel, function() { this.doPost(body); }.bind(this)); return res != null ? res: true; } else { return this.doPost(body); } }, // The actual post implementation doPost: function(body) { if (this.precondition()) { this.transport = Wicket.Ajax.getTransport(); var url = this.createUrl(); this.log("POST", url); Wicket.Ajax.invokePreCallHandlers(); var t = this.transport; if (t != null) { // we allow body to be a method - to lazily evaluate itself if (typeof(body) == "function") { body = body(); } t.open("POST", url, this.async); t.onreadystatechange = this.stateChangeCallback.bind(this); t.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); // set a special flag to allow server distinguish between ajax and non-ajax requests t.setRequestHeader("Wicket-Ajax", "true"); if (typeof(Wicket.Focus.lastFocusId) != "undefined" && Wicket.Focus.lastFocusId != "" && Wicket.Focus.lastFocusId != null) t.setRequestHeader("Wicket-FocusedElementId", Wicket.Focus.lastFocusId); t.setRequestHeader("Accept", "text/xml"); t.send(body); return true; } else { this.failure(); return false; } } else { Wicket.Log.info("Ajax POST stopped because of precondition check, url:" + this.url); this.done(); return true; } }, // Method that processes the request states stateChangeCallback: function() { var t = this.transport; var status; if (t != null && t.readyState == 4) { try { status = t.status; } catch (e) { Wicket.Log.error("Exception evaluating AJAX status: " + e); status = "unavailable"; } if (status == 200 || status == "") { // as stupid as it seems, IE7 sets status to "" on ok // response came without error var responseAsText = t.responseText; // first try to get the redirect header var redirectUrl; try { redirectUrl = t.getResponseHeader('Ajax-Location'); } catch (ignore) { // might happen in older mozilla } // the redirect header was set, go to new url if (typeof(redirectUrl) != "undefined" && redirectUrl != null && redirectUrl != "") { t.onreadystatechange = Wicket.emptyFunction; // In case the page isn't really redirected. For example say the redirect is to an octet-stream. // A file download popup will appear but the page in the browser won't change. this.done(); // support/check for non-relative redirectUrl like as provided and needed in a portlet context if (redirectUrl.charAt(0)==('/')||redirectUrl.match("^http://")=="http://"||redirectUrl.match("^https://")=="https://") { window.location = redirectUrl; } else { var urlDepth = 0; while (redirectUrl.substring(0, 3) == "../") { urlDepth++; redirectUrl = redirectUrl.substring(3); } // Make this a string. var calculatedRedirect = window.location.pathname; while (urlDepth > -1) { urlDepth--; i = calculatedRedirect.lastIndexOf("/"); if (i > -1) { calculatedRedirect = calculatedRedirect.substring(0, i); } } calculatedRedirect += "/" + redirectUrl; if (Wicket.Browser.isGecko()) { // firefox 3 has problem with window.location setting relative url calculatedRedirect = window.location.protocol + "//" + window.location.host + calculatedRedirect; } window.location = calculatedRedirect; } } else { // no redirect, just regular response var log = Wicket.Log.info; log("Received ajax response (" + responseAsText.length + " characters)"); if (this.debugContent != false) { log("\n" + responseAsText); } // parse the response if the callback needs a DOM tree if (this.parseResponse == true) { var xmldoc; if (typeof(window.XMLHttpRequest) != "undefined" && typeof(DOMParser) != "undefined") { var parser = new DOMParser(); xmldoc = parser.parseFromString(responseAsText, "text/xml"); } else if (window.ActiveXObject) { xmldoc = t.responseXML; } // invoke the loaded callback with an xml document this.loadedCallback(xmldoc); } else { // invoke the loaded callback with raw string this.loadedCallback(responseAsText); } if (this.suppressDone == false) this.done(); } } else { // when an error happened var log = Wicket.Log.error; log("Received Ajax response with code: " + status); if (status == 500) { log("500 error had text: " + t.responseText); } this.done(); this.failure(); } t.onreadystatechange = Wicket.emptyFunction; t.abort(); this.transport = null; } } }; /** * Ajax call fires a Wicket Ajax request and processes the response. * The response can contain * - javascript that should be invoked * - body of components being replaced * - header contributions of components */ Wicket.Ajax.Call = Wicket.Class.create(); Wicket.Ajax.Call.prototype = { // Initializes the Call initialize: function(url, successHandler, failureHandler, channel) { this.successHandler = successHandler != null ? successHandler : function() { }; this.failureHandler = failureHandler != null ? failureHandler : function() { }; var c = channel != null ? channel : "0|s"; // set the default channel if not specified // initialize the internal Ajax request this.request = new Wicket.Ajax.Request(url, this.loadedCallback.bind(this), true, true, failureHandler, c); this.request.suppressDone = true; }, // On ajax request failure failure: function(message) { if (message != null) Wicket.Log.error("Error while parsing response: " + message); this.request.done(); this.failureHandler(); Wicket.Ajax.invokePostCallHandlers(); Wicket.Ajax.invokeFailureHandlers(); }, // Fires a get request call: function() { return this.request.get(); }, // Fires a post request post: function(body) { return this.request.post(body); }, // Submits a form using ajax. // This method serializes a form and sends it as POST body. submitForm: function(form, submitButton) { var body = function() { var s = Wicket.Form.serialize(form); if (submitButton != null) { s += Wicket.Form.encode(submitButton) + "=1"; } return s; } return this.request.post(body); }, // Submits a form using ajax submitFormById: function(formId, submitButton) { var form = Wicket.$(formId); if (form == null || typeof (form) == "undefined") Wicket.Log.error("Trying to submit form with id '"+formId+"' that is not in document."); return this.submitForm(form, submitButton); }, // Processes the response loadedCallback: function(envelope) { // To process the response, we go through the xml document and add a function for every action (step). // After this is done, a FunctionExecuter object asynchronously executes these functions. // The asynchronous execution is necessary, because some steps might involve loading external javascript, // which must be asynchronous, so that it doesn't block the browser, but we also have to maintain // the order in which scripts are loaded and we have to delay the next steps until the script is // loaded. try { var root = envelope.getElementsByTagName("ajax-response")[0]; // the root element must be <ajax-response if (root == null || root.tagName != "ajax-response") { this.failure("Could not find root <ajax-response> element"); return; } // iinitialize the array for steps (closures that execute each action) var steps = new Array(); // start it a bit later so that the browser does handle the next event // before the component is or can be replaced. We could do (if (!posponed)) // because if there is already something in the queue then we could execute that immedietly steps.push(function(notify) { window.setTimeout(notify,2); }.bind(this)); if (Wicket.Browser.isKHTML()) { // there's a nasty bug in KHTML that makes the browser crash // when the methods are delayed. Therefore we have to fire it // ASAP. The javascripts that would cause dependency problems are // loaded synchronously in konqueror. steps.push = function(method) { method(function() { }); } } // go through the ajax response and for every action (component, js evaluation, header contribution) // ad the proper closure to steps for (var i = 0; i < root.childNodes.length; ++i) { var node = root.childNodes[i]; if (node.tagName == "component") { this.processComponent(steps, node); } else if (node.tagName == "evaluate") { this.processEvaluation(steps, node); } else if (node.tagName == "header-contribution") { this.processHeaderContribution(steps, node); } } // add the last step, which should trigger the success call the done method on request this.success(steps); if (Wicket.Browser.isKHTML() == false) { Wicket.Log.info("Response parsed. Now invoking steps..."); var executer = new Wicket.FunctionsExecuter(steps); executer.start(); } } catch (e) { this.failure(e.message); } }, // Adds a closure to steps that should be invoked after all other steps have been successfully executed success: function(steps) { steps.push(function(notify) { Wicket.Log.info("Response processed successfully."); Wicket.Ajax.invokePostCallHandlers(); // retach the events to the new components (a bit blunt method...) // This should be changed for IE See comments in wicket-event.js add (attachEvent/detachEvent) // IE this will cause double events for everything.. (mostly because of the Function.prototype.bind(element)) Wicket.Focus.attachFocusEvent(); this.request.done(); this.successHandler(); // set the focus to the last component setTimeout("Wicket.Focus.requestFocus();", 0); // continue to next step (which should make the processing stop, as success should be the final step) notify(); }.bind(this)); }, // Adds a closure that replaces a component processComponent: function(steps, node) { steps.push(function(notify) { // get the component id var compId = node.getAttribute("id"); var text=""; // get the new component body if (node.hasChildNodes()) { text = node.firstChild.nodeValue; } // if the text was escaped, unascape it // (escaping is done when the component body contains a CDATA section) var encoding = node.getAttribute("encoding"); if (encoding != null && encoding!="") { text = Wicket.decode(encoding, text); } // get existing component var element = Wicket.$(compId); if (element == null || typeof(element) == "undefined") { Wicket.Log.error("Component with id [["+compId+"]] a was not found while trying to perform markup update. Make sure you called component.setOutputMarkupId(true) on the component whose markup you are trying to update."); } else { // replace the component Wicket.replaceOuterHtml(element, text); } // continue to next step notify(); }); }, // Adds a closure that evaluates javascript code processEvaluation: function(steps, node) { steps.push(function(notify) { // get the javascript body var text = node.firstChild.nodeValue; // unescape it if necessary var encoding = node.getAttribute("encoding"); if (encoding != null) { text = Wicket.decode(encoding, text); } // test if the javascript is in form of identifier|code // if it is, we allow for letting the javascript decide when the rest of processing will continue // by invoking identifier(); var res = text.match(new RegExp("^([a-z|A-Z_][a-z|A-Z|0-9_]*)\\|((.|\\n)*)$")); if (res != null) { text = "var f = function(" + res[1] + ") {" + res[2] +"};"; try { // do the evaluation eval(text); f(notify); } catch (exception) { Wicket.Log.error("Exception evaluating javascript: " + exception); } } else { // just evaluate the javascript try { // do the evaluation eval(text); } catch (exception) { Wicket.Log.error("Exception evaluating javascript: " + exception); } // continue to next step notify(); } }); }, // Adds a closure that processes a header contribution processHeaderContribution: function(steps, node) { var c = new Wicket.Head.Contributor(); c.processContribution(steps, node); } }; /** * Header contribution allows component to include custom javascript and stylesheet. * * Header contributor takes the code component would render to page head and * interprets it just as browser would when loading a page. * That means loading external javascripts and stylesheets, executing inline * javascript and aplying inline styles. * * Header contributor also filters duplicate entries, so that it doesn't load/process * resources that have been loaded. * For inline styles and javascript, element id is used to filter out duplicate entries. * For stylesheet and javascript references, url is used for filtering. */ Wicket.Head = { }; Wicket.Head.Contributor = Wicket.Class.create(); Wicket.Head.Contributor.prototype = { initialize: function() { }, // Parses the header contribution element (returns a DOM tree with the contribution) parse: function(headerNode) { // the header contribution is stored as CDATA section in the header-contribution element. // even though we need to parse it (and we have aleady parsed the response), header // contribution needs to be treated separately. The reason for this is that // Konqueror crashes when it there is a <script element in the parsed string. So we // need to replace that first // get the header contribution text and unescape it if necessary var text = headerNode.firstChild.nodeValue; var encoding = headerNode.getAttribute("encoding"); if (encoding != null && encoding != "") { text = Wicket.decode(encoding, text); } if (Wicket.Browser.isKHTML()) { // konqueror crashes if there is a <script element in the xml, but <SCRIPT is fine. text = text.replace(/<script/g,"<SCRIPT"); text = text.replace(/<\/script>/g,"</SCRIPT>"); } // build a DOM tree of the contribution var xmldoc; if (window.ActiveXObject) { xmldoc = new ActiveXObject("Microsoft.XMLDOM"); xmldoc.loadXML(text); } else { var parser = new DOMParser(); xmldoc = parser.parseFromString(text, "text/xml"); } return xmldoc; }, // Processes the parsed header contribution processContribution: function(steps, headerNode) { var xmldoc = this.parse(headerNode); var rootNode = xmldoc.documentElement; // go through the individual elements and process them according to their type for (var i = 0; i < rootNode.childNodes.length; i++) { var node = rootNode.childNodes[i]; if (node.tagName != null) { var name = node.tagName.toLowerCase(); // it is possible that a reference is surrounded by a <wicket:link // in that case, we need to find the inner element if (name == "wicket:link") { for (var j = 0; j < node.childNodes.length; ++j) { var childNode = node.childNodes[j]; // try to find a regular node inside wicket:link if (childNode.nodeType == 1) { node = childNode; name = node.tagName.toLowerCase(); break; } } } // process the element if (name == "link") { this.processLink(steps, node); } else if (name == "script") { this.processScript(steps, node); } else if (name == "style") { this.processStyle(steps, node); } } } }, // Process an external stylesheet element processLink: function(steps, node) { steps.push(function(notify) { // if the element is already in head, skip it if (Wicket.Head.containsElement(node, "href")) { notify(); return; } // create link element var css = Wicket.Head.createElement("link"); // copy required attributes css.id = node.getAttribute("id"); css.rel = node.getAttribute("rel"); css.href = node.getAttribute("href"); css.type = node.getAttribute("type"); // add element to head Wicket.Head.addElement(css); // continue to next step notify(); }); }, // Process an inline style element processStyle: function(steps, node) { steps.push(function(notify) { // if element with same id is already in document, skip it if (Wicket.DOM.containsElement(node)) { notify(); return; } // serialize the style to string var content = Wicket.DOM.serializeNodeChildren(node); // create style element var style = Wicket.Head.createElement("style"); // copy id attribute style.id = node.getAttribute("id"); // create stylesheet if (Wicket.Browser.isIE()) { try { document.createStyleSheet().cssText = content; } catch(ignore) { var run = function() { try { document.createStyleSheet().cssText = content; } catch(e) { Wicket.Log.error(e); } } window.setTimeout(run, 1); } } else { var textNode = document.createTextNode(content); style.appendChild(textNode); } Wicket.Head.addElement(style); // continue to next step notify(); }); }, // Process a script element (both inline and external) processScript: function(steps, node) { steps.push(function(notify) { // if element in same id is already in document, // or element with same src attribute is in document, skip it if (Wicket.DOM.containsElement(node) || Wicket.Head.containsElement(node, "src")) { notify(); return; } // determine whether it is external javascript (has src attribute set) var src = node.getAttribute("src"); if (src != null && src != "") { // load the external javascript using Wicket.Ajax.Request // callback when script is loaded var onLoad = function(content) { Wicket.Head.addJavascript(content, null, src); Wicket.Ajax.invokePostCallHandlers(); // continue to next step notify(); } // we need to schedule the request as timeout // calling xml http request from another request call stack doesn't work window.setTimeout(function() { var req = new Wicket.Ajax.Request(src, onLoad, false, false); req.debugContent = false; if (Wicket.Browser.isKHTML()) // konqueror can't process the ajax response asynchronously, therefore the // javascript loading must be also synchronous req.async = false; // get the javascript req.get(); },1); } else { // serialize the element content to string var text = Wicket.DOM.serializeNodeChildren(node); // get rid of prefix and suffix, they are not eval-d correctly text = text.replace(/^<!--\/\*--><!\[CDATA\[\/\*><!--\*\//, ""); text = text.replace(/\/\*-->]]>\*\/$/, ""); var id = node.getAttribute("id"); if (typeof(id) == "string" && id.length > 0) { // add javascript to document head Wicket.Head.addJavascript(text, id); } else { try { eval(text); } catch (e) { Wicket.Log.error(e); } } // continue to next step notify(); } }); } }; /** * Head manipulation */ // Creates an element in document Wicket.Head.createElement = function(name) { return document.createElement(name); } // Adds the element to page head Wicket.Head.addElement = function(element) { var head = document.getElementsByTagName("head"); if (head[0]) { head[0].appendChild(element); } } // Returns true, if the page head contains element that has attribute with // name mandatoryAttribute same as the given element and their names match. // // e.g. Wicket.Head.containsElement(myElement, "src") return true, if there // is an element in head that is of same type as myElement, and whose src // attribute is same as myElement.src. Wicket.Head.containsElement = function(element, mandatoryAttribute) { var attr = element.getAttribute(mandatoryAttribute); if (attr == null || attr == "" || typeof(attr) == "undefined") return false; var head = document.getElementsByTagName("head")[0]; if (element.tagName == "script") head = document; var nodes = head.getElementsByTagName(element.tagName); for (var i = 0; i < nodes.length; ++i) { var node = nodes[i]; // check node names and mandatory attribute values // we also have to check for attribute name that is suffixed by "_". // this is necessary for filtering script references if (node.tagName.toLowerCase() == element.tagName.toLowerCase() && (node.getAttribute(mandatoryAttribute) == attr || node.getAttribute(mandatoryAttribute+"_") == attr)) { return true; } } return false; } // Adds a javascript element to page header. // The fakeSrc attribute is used to filter out duplicate javascript references. // External javascripts are loaded using xmlhttprequest. Then a javascript element is created and the // javascript body is used as text for the element. For javascript references, wicket uses the src // attribute to filter out duplicates. However, since we set the body of the element, we can't assign // also a src value. Therefore we put the url to the src_ (notice the underscore) attribute. // Wicket.Head.containsElement is aware of that and takes also the underscored attributes into account. Wicket.Head.addJavascript = function(content, id, fakeSrc) { var script = Wicket.Head.createElement("script"); script.id = id; script.setAttribute("src_", fakeSrc); // set the javascript as element content if (null == script.canHaveChildren || script.canHaveChildren) { var textNode = document.createTextNode(content); script.appendChild(textNode); } else { script.text = content; } Wicket.Head.addElement(script); } // Goes through all script elements contained by the element and add them to head Wicket.Head.addJavascripts = function(element, contentFilter) { function add(element) { var src = element.getAttribute("src"); // if it is a reference, just add it to head if (src != null && src.length > 0) { var e = document.createElement("script"); e.setAttribute("type","text/javascript"); e.setAttribute("src", src); Wicket.Head.addElement(e); } else { var content = Wicket.DOM.serializeNodeChildren(element); if (content == null || content == "") content = element.text; if (typeof(contentFilter) == "function") { content = contentFilter(content); } Wicket.Head.addJavascript(content); } } if (typeof(element) != "undefined" && typeof(element.tagName) != "undefined" && element.tagName.toLowerCase() == "script") { add(element); } else { // we need to check if there are any children, because Safari // aborts when the element is a text node if (element.childNodes.length > 0) { var scripts = element.getElementsByTagName("script"); for (var i = 0; i < scripts.length; ++i) { add(scripts[i]); } } } } /** * Throttler's purpose is to make sure that ajax requests wont be fired too often. */ Wicket.ThrottlerEntry = Wicket.Class.create(); Wicket.ThrottlerEntry.prototype = { initialize: function(func) { this.func = func; this.timestamp = new Date().getTime(); this.timeoutVar = undefined; }, getTimestamp: function() { return this.timestamp; }, getFunc: function() { return this.func; }, setFunc: function(func) { this.func = func; }, getTimeoutVar: function() { return this.timeoutVar; }, setTimeoutVar: function(timeoutVar) { this.timeoutVar = timeoutVar; } }; Wicket.Throttler = Wicket.Class.create(); Wicket.Throttler.prototype = { /* "postponeTimerOnUpdate" is an optional parameter. If it is set to true, then the timer is reset each time the throttle function gets called. Use this behaviour if you want something to happen at X milliseconds after the *last* call to throttle. If the parameter is not set, or set to false, then the timer is not reset. */ initialize: function(postponeTimerOnUpdate) { this.entries = new Array(); if (postponeTimerOnUpdate != undefined) this.postponeTimerOnUpdate = postponeTimerOnUpdate; else this.postponeTimerOnUpdate = false; }, throttle: function(id, millis, func) { var entry = this.entries[id]; var me = this; if (entry == undefined) { entry = new Wicket.ThrottlerEntry(func); entry.setTimeoutVar(window.setTimeout(function() { me.execute(id); }, millis)); this.entries[id] = entry; } else { entry.setFunc(func); if (this.postponeTimerOnUpdate == true) { window.clearTimeout(entry.getTimeoutVar()); entry.setTimeoutVar(window.setTimeout(function() { me.execute(id); }, millis)); } } }, execute: function(id) { var entry = this.entries[id]; if (entry != undefined) { var func = entry.getFunc(); this.entries[id] = undefined; var tmp = func(); } } }; Wicket.throttler = new Wicket.Throttler(); /** * Prevent event from bubbling up in the element hierarchy. */ Wicket.stopEvent = function(e) { e=Wicket.fixEvent(e); e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); } /** * If no event is given as argument (IE), window.event is returned. */ Wicket.fixEvent = function(e) { if (typeof e == 'undefined') e = window.event; return e; } /** * Flexible dragging support. */ Wicket.Drag = { /** * Initializes the dragging on the specified element. * Element's onmousedown will be replaced by generated handler. * * @param {Element} element - element clicking on which the drag should begin * @param {Function} onDragBegin - handler called at the begin on dragging - passed element as first parameter * @param {Function} onDragEnd - handler called at the end of dragging - passed element as first parameter * @param {Function} onDrag - handler called during dragging - passed element and mouse deltas */ init: function(element, onDragBegin, onDragEnd, onDrag) { if (typeof(onDragBegin) == "undefined") onDragBegin = Wicket.emptyFunction; if (typeof(onDragEnd) == "undefined") onDragEnd = Wicket.emptyFunction; if (typeof(onDrag) == "undefined") onDrag = Wicket.emptyFunction; element.wicketOnDragBegin = onDragBegin; element.wicketOnDrag = onDrag; element.wicketOnDragEnd = onDragEnd; // set the mousedown handler Wicket.Event.add(element, "mousedown", Wicket.Drag.mouseDownHandler); }, mouseDownHandler: function(e) { e = Wicket.fixEvent(e); var element = this; // HACK - for safari stopPropagation doesn't work well because // it also prevents scrollbars and form components getting the // event. Therefore for safari the 'ignore' flag is set on event. if (typeof(e.ignore) == "undefined") { Wicket.stopEvent(e); if (e.preventDefault) { e.preventDefault(); } element.wicketOnDragBegin(element); element.lastMouseX = e.clientX; element.lastMouseY = e.clientY; element.old_onmousemove = document.onmousemove; element.old_onmouseup = document.onmouseup; element.old_onselectstart = document.onselectstart; element.old_onmouseout = document.onmouseout; document.onselectstart = function() { return false; } document.onmousemove = Wicket.Drag.mouseMove; document.onmouseup = Wicket.Drag.mouseUp; document.onmouseout = Wicket.Drag.mouseOut; Wicket.Drag.current = element; return false; } }, /** * Deinitializes the dragging support on given element. */ clean: function(element) { element.onmousedown = null; }, /** * Called when mouse is moved. This method fires the onDrag event * with element instance, deltaX and deltaY (the distance * between this call and the previous one). * The onDrag handler can optionally return an array of two integers * - the delta correction. This is used, for example, if there is * element being resized and the size limit has been reached (but the * mouse can still move). * * @param {Event} e */ mouseMove: function(e) { e = Wicket.fixEvent(e); var o = Wicket.Drag.current; // this happens sometimes in Safari if (e.clientX < 0 || e.clientY < 0) { return; } if (o != null) { var deltaX = e.clientX - o.lastMouseX; var deltaY = e.clientY - o.lastMouseY; var res = o.wicketOnDrag(o, deltaX, deltaY, e); if (res == null) res = [0, 0]; o.lastMouseX = e.clientX + res[0]; o.lastMouseY = e.clientY + res[1]; } return false; }, /** * Called when the mouse button is released. * Cleans all temporary variables and callback methods. * * @param {Event} e */ mouseUp: function(e) { e = Wicket.fixEvent(e); var o = Wicket.Drag.current; if (o != null && typeof(o) != "undefined") { o.wicketOnDragEnd(o); o.lastMouseX = null; o.lastMouseY = null; document.onmousemove = o.old_onmousemove; document.onmouseup = o.old_onmouseup; document.onselectstart = o.old_onselectstart; document.onmouseout = o.old_onmouseout; o.old_mousemove = null; o.old_mouseup = null; o.old_onselectstart = null; o.old_onmouseout = null; Wicket.Drag.current = null; } }, /** * Called when mouse leaves an element. We need this for firefox, as otherwise * the dragging would continue after mouse leaves the document. * Unfortunately this break dragging in firefox immediately after the mouse leaves * page. */ mouseOut: function(e) { if (false && Wicket.Browser.isGecko()) { // other browsers handle this more gracefully e = Wicket.fixEvent(e); if (e.target.tagName == "HTML") { Wicket.Drag.mouseUp(e); } } } }; Wicket.ChangeHandler=function(elementId){ var KEY_BACKSPACE=8; var KEY_TAB=9; var KEY_ENTER=13; var KEY_ESC=27; var KEY_LEFT=37; var KEY_UP=38; var KEY_RIGHT=39; var KEY_DOWN=40; var KEY_SHIFT=16; var KEY_CTRL=17; var KEY_ALT=18; var obj = Wicket.$(elementId); obj.setAttribute("autocomplete", "off"); if (Wicket.Browser.isIE() || Wicket.Browser.isKHTML() || Wicket.Browser.isSafari()) { var objonchange = obj.onchange; obj.onkeyup = function(event) { switch (wicketKeyCode(Wicket.fixEvent(event))) { case KEY_ENTER: case KEY_UP: case KEY_DOWN: case KEY_ESC: case KEY_TAB: case KEY_RIGHT: case KEY_LEFT: case KEY_SHIFT: case KEY_ALT: case KEY_CTRL: return Wicket.stopEvent(event); break; default: if (typeof objonchange == "function")objonchange(); } return null; } obj.onpaste = function(event) { if (typeof objonchange == "function"){ setTimeout(function() { objonchange(); }, 10); } return null; } obj.oncut = function(event) { if (typeof objonchange == "function"){ setTimeout(function() { objonchange(); }, 10); } return null; } } else { obj.addEventListener('input', obj.onchange, true); } obj.onchange = function(event) { Wicket.stopEvent(event); } } /* * Compatibility layer to maintain the original wicket-ajax API. */ var wicketThrottler = Wicket.throttler; function wicketAjaxGet(url, successHandler, failureHandler, precondition, channel) { var call = new Wicket.Ajax.Call(url, successHandler, failureHandler, channel); if (typeof(precondition) != "undefined" && precondition != null) { call.request.precondition = precondition; } return call.call(); } function wicketAjaxPost(url, body, successHandler, failureHandler, precondition, channel) { var call = new Wicket.Ajax.Call(url, successHandler, failureHandler, channel); if (typeof(precondition) != "undefined" && precondition != null) { call.request.precondition = precondition; } return call.post(body); } function wicketSubmitForm(form, url, submitButton, successHandler, failureHandler, precondition, channel) { var call = new Wicket.Ajax.Call(url, successHandler, failureHandler, channel); if (typeof(precondition) != "undefined" && precondition != null) { call.request.precondition = precondition; } return call.submitForm(form, submitButton); } function wicketSubmitFormById(formId, url, submitButton, successHandler, failureHandler, precondition, channel) { var call = new Wicket.Ajax.Call(url, successHandler, failureHandler, channel); if (typeof(precondition) != "undefined" && precondition != null) { call.request.precondition = precondition; } return call.submitFormById(formId, submitButton); } wicketSerialize = Wicket.Form.serializeElement; wicketSerializeForm = Wicket.Form.serialize; wicketEncode = Wicket.Form.encode; wicketDecode = Wicket.decode; wicketAjaxGetTransport = Wicket.Ajax.getTransport; // Global handlers stubs Wicket.Ajax.registerPreCallHandler(function() { if (typeof(window.wicketGlobalPreCallHandler) != "undefined") { var global=wicketGlobalPreCallHandler; if (global!=null) { global(); } } }); Wicket.Ajax.registerPostCallHandler(function() { if (typeof(window.wicketGlobalPostCallHandler) != "undefined") { var global=wicketGlobalPostCallHandler; if (global!=null) { global(); } } }); Wicket.Ajax.registerFailureHandler(function() { if (typeof(window.wicketGlobalFailureHandler) != "undefined") { var global=wicketGlobalFailureHandler; if (global!=null) { global(); } } }); // FOCUS FUNCTIONS Wicket.Focus = { lastFocusId : "", setFocus: function(event) { event = Wicket.fixEvent(event); // IE doesn't have the property "target". // Use "srcElement" instead. var target = event.target ? event.target : event.srcElement; if (target) { Wicket.Focus.lastFocusId=target.id; Wicket.Log.info("focus set on " + Wicket.Focus.lastFocusId); } }, blur: function(event) { event = Wicket.fixEvent(event); // IE doesn't have the property "target". // Use "srcElement" instead. var target = event.target ? event.target : event.srcElement; if (target && Wicket.Focus.lastFocusId==target.id) { Wicket.Focus.lastFocusId=null; Wicket.Log.info("focus removed from " + target.id); } }, setFocusOnId: function(id) { Wicket.Focus.lastFocusId=id; Wicket.Log.info("focus set on " + Wicket.Focus.lastFocusId + " from serverside"); }, getFocusedElement: function() { if (typeof(Wicket.Focus.lastFocusId) != "undefined" && Wicket.Focus.lastFocusId != "" && Wicket.Focus.lastFocusId != null) { Wicket.Log.info("returned focused element: " + Wicket.$(Wicket.Focus.lastFocusId)); return Wicket.$(Wicket.Focus.lastFocusId); } return; }, requestFocus: function() { if (typeof(Wicket.Focus.lastFocusId) != "undefined" && Wicket.Focus.lastFocusId != "" && Wicket.Focus.lastFocusId != null) { var toFocus = Wicket.$(Wicket.Focus.lastFocusId); if (toFocus != null && typeof(toFocus) != "undefined") { Wicket.Log.info("Calling focus on " + Wicket.Focus.lastFocusId); try { toFocus.focus(); } catch (ignore) { } } else { Wicket.Focus.lastFocusId = ""; Wicket.Log.info("Couldn't set focus on " + Wicket.Focus.lastFocusId + " not on the page anymore"); } } else { Wicket.Log.info("last focus id was not set"); } }, setFocusOnElements: function (elements) { for (var i=0; i< elements.length; i++) { if (elements[i].wicketFocusSet != true) { Wicket.Event.add(elements[i],'focus',Wicket.Focus.setFocus); Wicket.Event.add(elements[i],'blur',Wicket.Focus.blur); elements[i].wicketFocusSet = true; } } }, attachFocusEvent: function() { Wicket.Focus.setFocusOnElements(document.getElementsByTagName("input")); Wicket.Focus.setFocusOnElements(document.getElementsByTagName("select")); Wicket.Focus.setFocusOnElements(document.getElementsByTagName("textarea")); Wicket.Focus.setFocusOnElements(document.getElementsByTagName("button")); Wicket.Focus.setFocusOnElements(document.getElementsByTagName("a")); } } Wicket.Event.addDomReadyEvent(Wicket.Focus.attachFocusEvent); // DEBUG FUNCTIONS function wicketAjaxDebugEnabled() { if (typeof(wicketAjaxDebugEnable)=="undefined") { return false; } else { return wicketAjaxDebugEnable==true; } } // MISC FUNCTIONS function wicketKeyCode(event) { if (typeof(event.keyCode)=="undefined") { return event.which; } else { return event.keyCode; } } function wicketGet(id) { return Wicket.$(id); } function wicketShow(id) { var e=wicketGet(id); if (e!=null) { e.style.display = ""; } } function wicketHide(id) { var e=wicketGet(id); if (e!=null) { e.style.display = "none"; } } --S60BrowserSavedPage Content-Location: resources/org.apache.wicket.markup.html.form.upload.MultiFileUploadField/MultiFileUploadField.js Content-Type: application/x-javascript;charset=ucs-2 /** * Convert a single file-input element into a 'multiple' input list * * Usage: * * 1. Create a file input element (no name) * eg. <input type="file" id="first_file_element"> * * 2. Create a DIV for the output to be written to * eg. <div id="files_list"></div> * * 3. Instantiate a MultiSelector object, passing in the DIV and an (optional) maximum number of files * eg. var multi_selector = new MultiSelector( document.getElementById( 'files_list' ), 3 ); * * 4. Add the first element * eg. multi_selector.addElement( document.getElementById( 'first_file_element' ) ); * * 5. That's it. * * You might (will) want to play around with the addListRow() method to make the output prettier. * * You might also want to change the line * element.name = 'file_' + this.count; * ...to a naming convention that makes more sense to you. * * Licence: * Use this however/wherever you like, just don't blame me if it breaks anything. * * Credit: * If you're nice, you'll leave this bit: * * Class by Stickman -- http://www.the-stickman.com * with thanks to: * [for Safari fixes] * Luis Torrefranca -- http://www.law.pitt.edu * and * Shawn Parker & John Pennypacker -- http://www.fuzzycoconut.com * [for duplicate name bug] * 'neal' */ function MultiSelector( eprefix, list_target,max, del_label ){ // Where to write the list this.list_target = list_target; // How many elements? this.count = 0; // How many elements? this.id = 0; // Is there a maximum? if( max ){ this.max = max; } else { this.max = -1; }; this.delete_label=del_label this.element_name_prefix=eprefix; /** * Add a new file input element */ this.addElement = function( element ){ // Make sure it's a file input element if( element.tagName == 'INPUT' && element.type == 'file' ){ // Element name -- what number am I? element.name = this.element_name_prefix + "_mf_"+this.id++; // Add reference to this object element.multi_selector = this; // What to do when a file is selected element.onchange = function(){ // New file input var new_element = document.createElement( 'input' ); new_element.type = 'file'; // Add new element this.parentNode.insertBefore( new_element, this ); // Apply 'update' to element this.multi_selector.addElement( new_element ); // Update list this.multi_selector.addListRow( this ); // Hide this: we can't use display:none because Safari doesn't like it this.style.position = 'absolute'; this.style.left = '-1000px'; }; // If we've reached maximum number, disable input element if( this.max != -1 && this.count >= this.max ){ element.disabled = true; }; // File element counter this.count++; // Most recent element this.current_element = element; } else { // This can only be applied to file input elements! alert( 'Error: not a file input element' ); }; }; /** * Add a new row to the list of files */ this.addListRow = function( element ){ // Row div var new_row = document.createElement( 'div' ); // Delete button var new_row_button = document.createElement( 'input' ); new_row_button.type = 'button'; new_row_button.value = this.delete_label; // References new_row.element = element; // Delete function new_row_button.onclick= function(){ // Remove element from form this.parentNode.element.parentNode.removeChild( this.parentNode.element ); // Remove this row from the list this.parentNode.parentNode.removeChild( this.parentNode ); // Decrement counter this.parentNode.element.multi_selector.count--; // Re-enable input element (if it's disabled) this.parentNode.element.multi_selector.current_element.disabled = false; // Appease Safari // without it Safari wants to reload the browser window // which nixes your already queued uploads return false; }; // Set row value new_row.innerHTML = element.value; // Add button new_row.appendChild( new_row_button ); // Add it to the list this.list_target.appendChild( new_row ); }; }; --S60BrowserSavedPage Content-Location: resources/org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar/progressbar.js Content-Type: application/x-javascript;charset=ucs-2 /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ if (typeof(Wicket) == "undefined") Wicket = { }; Wicket.WUPB= { Def : function(formid, statusid, barid, url) { this.formid=formid; this.statusid=statusid; this.barid=barid; this.url=url; }, get : function(id) { return document.getElementById(id); }, start : function(def) { //Wicket.WUPB.get(def.formid).submit(); Wicket.WUPB.get(def.statusid).innerHTML='Upload starting...'; Wicket.WUPB.get(def.barid).firstChild.firstChild.style.width='0%'; Wicket.WUPB.get(def.statusid).style.display='block'; Wicket.WUPB.get(def.barid).style.display='block'; window.setTimeout(function() { Wicket.WUPB.ajax(def); }, 1000); }, ajax : function(def) { transport = false; if(window.XMLHttpRequest) { transport = new XMLHttpRequest(); if(transport.overrideMimeType) { transport.overrideMimeType('text/xml'); } } else if(window.ActiveXObject) { try { transport = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { transport = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if(!transport) { alert('Error: could not create XMLHTTP object.'); return false; } transport.onreadystatechange = function() { Wicket.WUPB.update(transport, def); }; transport.open('GET', def.url+'?anticache='+Math.random(), true); transport.send(null); }, update: function(transport, def) { if (transport.readyState == 4) { if (transport.status == 200) { var update = transport.responseText.split('|'); var completed_upload_size = update[2]; var total_upload_size = update[3]; var progressPercent = update[1]; var transferRate = update[4]; var timeRemaining = update[5]; if ((completed_upload_size != "") && (completed_upload_size != 0)) { Wicket.WUPB.get(def.barid).firstChild.firstChild.style.width=progressPercent+'%'; Wicket.WUPB.get(def.statusid).innerHTML=progressPercent + '% finished, ' + completed_upload_size + ' of ' + total_upload_size + ' at ' + transferRate + "; " + timeRemaining; } if (progressPercent == 100) { Wicket.WUPB.get(def.barid).firstChild.firstChild.style.width='100%'; Wicket.WUPB.get(def.statusid).style.display='none'; Wicket.WUPB.get(def.barid).style.display='none'; return null; } window.setTimeout(function() { Wicket.WUPB.ajax(def); }, 1000); } else { alert('Error: got a not-OK status code...'); } } } } --S60BrowserSavedPage--