├── README.md ├── src ├── universal-dapp.css └── universal-dapp.js ├── mappingBytes32.html ├── index.html └── libs ├── web3.min.js └── jquery-2.1.3.min.js /README.md: -------------------------------------------------------------------------------- 1 | # Universal ÐApp 2 | 3 | Demo: [http://d11e9.github.com/universal-dapp](http://d11e9.github.com/universal-dapp) 4 | 5 | A Universal Interface for contracts on the Ethereum blockchain. Best used in conjunction with a contract compiler like [browser-solidity](https://d11e9.github.io/browser-solidity) or in cases where you already have an ABI and/or bytecode for an existing contract 6 | 7 | ##How to use 8 | 9 | Include the source and its dependencies in your html. 10 | 11 | 12 | 13 | 14 | 15 | For the Universal-Universal Dapp which has input for ABI and Bytecode you can do the following: 16 | 17 | 23 | 24 | 25 | If you'd like to use a universal DApp for a specific set of contracts, either already in the blockchain or in the form of compiled bytecode and ABI, you can do the following: 26 | 27 | 28 | 38 | 39 | 40 | Or if you just need an interface for an existing contract you can provide its address directly. In the example below we omit the `bytecode` property wich prevents the uDApp from creating new contracts. 41 | 42 | 52 | 53 | 54 | **Connecting to a running Node** 55 | 56 | By default Universal DApp looks to see if there is already an existsing `web3.currentProvider` and will use that if available. If there is no current provider and `vm` is `false` then it will create a new `HttpProvider` (RPC) and connect to the `http://host:port` provided in options, defaulting to `http://localhost:8545`. 57 | 58 | 59 | 76 | 77 | or 78 | 79 | 92 | 93 | ###Example 94 | 95 | Check out the `gh-pages` branch [index.html](http://d11e9.github.com/universal-dapp) for a full working example. 96 | 97 | ##Acknowledgements 98 | 99 | In its initial form this project was a direct copy/paste of parts of [chriseth](https://github.com/chriseth)'s browser based [Solidty compiler](https://github.com/chriseth/browser-solidity). 100 | 101 | ##Caveats 102 | 103 | Currently works ~~exclusively~~ inside of a JavaScript Ethereum VM ([ethereumjs-vm](https://github.com/ethereum/ethereumjs-vm)) by [wanderer](https://github.com/wanderer). 104 | 105 | There is alpha support for [web3.js](https://github.com/ethereum/web3.js) connections to a local Ethereum Node, to deploy and interact with contracts live on the Ethereum Blockchain. 106 | -------------------------------------------------------------------------------- /src/universal-dapp.css: -------------------------------------------------------------------------------- 1 | 2 | .udapp { 3 | padding: 1em; 4 | border: 1px dotted #4D5686; 5 | position: relative; 6 | box-shadow: 0 0 5px rgba(0,0,0,0.3); 7 | box-sizing: border-box; 8 | overflow: auto; 9 | } 10 | 11 | .udapp a { 12 | color: #7A7AE2; 13 | } 14 | 15 | .udapp a:visited { 16 | color: #7A7AE2; 17 | } 18 | 19 | .udapp input, 20 | .udapp button, 21 | .udapp-setup textarea, 22 | .udapp-setup button { 23 | display: block; 24 | width: 100%; 25 | padding: 0.6em; 26 | box-sizing: border-box; 27 | border: 1px solid rgba( 0,0,0,0.3 ); 28 | border-radius: 0.5em; 29 | } 30 | 31 | .udapp-setup textarea { 32 | border-radius: 0; 33 | margin-bottom: 1em; 34 | height: 7em; 35 | } 36 | 37 | .udapp button { 38 | min-width: 8em; 39 | } 40 | 41 | .udapp-setup button { 42 | background-color: #556DF3; 43 | color: white; 44 | cursor: pointer; 45 | } 46 | 47 | .udapp .contract { 48 | margin-bottom: 1em; 49 | } 50 | 51 | .udapp .create { 52 | overflow: auto; 53 | margin-bottom: 1em; 54 | } 55 | 56 | .udapp .title { 57 | margin-bottom: 0.4em; 58 | display: inline-block; 59 | padding: 0.2em; 60 | background-color: rgba( 255,255,255,0.5 ); 61 | display: block; 62 | font-weight: bold; 63 | padding-right: 2em; 64 | word-wrap: break-word; 65 | position: relative; 66 | } 67 | 68 | .udapp .title .size { 69 | position: absolute; 70 | right: 2.2em; 71 | top: 0.2em; 72 | font-weight: normal; 73 | } 74 | 75 | .udapp .output { 76 | padding: 1em; 77 | clear: both; 78 | word-wrap: break-word; 79 | } 80 | 81 | .udapp .constructor > .output { 82 | padding-right: 1em; 83 | } 84 | 85 | .udapp .output .error { 86 | color: red; 87 | } 88 | 89 | .udapp .output .result { 90 | position: relative; 91 | margin-bottom: 0.5em; 92 | white-space: pre; 93 | } 94 | 95 | .udapp .result { position: relative; } 96 | .udapp .output .result .returned, 97 | .udapp .output .result .value, 98 | .udapp .output .result .waiting, 99 | .udapp .output .result .gasUsed { 100 | padding-right: 2em; 101 | word-wrap: break-word; 102 | } 103 | 104 | .udapp .output .result:last-child { margin: 0; } 105 | 106 | .udapp .output:empty { 107 | display: none; 108 | } 109 | 110 | .udapp-close:before { 111 | position: absolute; 112 | top: .4em; 113 | right: .4em; 114 | width: 1.5em; 115 | height: 1.5em; 116 | text-align: center; 117 | content: "x"; 118 | cursor: pointer; 119 | z-index: 9999; 120 | } 121 | 122 | .udapp .instance { 123 | padding: 0.4em; 124 | background-color: #ECD7D7; 125 | margin-bottom: 1em; 126 | position: relative; 127 | border: 1px solid #999; 128 | } 129 | 130 | .udapp .instance:last-child { 131 | margin-bottom: 0; 132 | } 133 | 134 | .udapp .instance .title { 135 | cursor: pointer; 136 | } 137 | 138 | .udapp .instance.hide .title { 139 | margin-bottom: 0; 140 | padding-right: 1.5em; 141 | word-wrap: break-word; 142 | } 143 | 144 | .udapp .instance .title:before { 145 | content: "\25BC"; 146 | opacity: 0.5; 147 | margin-right: 0.4em; 148 | font-size: 10px; 149 | } 150 | 151 | .udapp .instance.hide > *:not(.title) { 152 | display: none; 153 | } 154 | 155 | .udapp .instance.hide > .title:before { 156 | content: "\25B6"; 157 | } 158 | 159 | 160 | .udapp .contractProperty { 161 | overflow: auto; 162 | margin-bottom: 0.4em; 163 | } 164 | 165 | 166 | .udapp input, 167 | .udapp button { 168 | width: 33%; 169 | display: block; 170 | float: left; 171 | } 172 | 173 | .udapp .atAddress { 174 | background-color: #62B762; 175 | margin-right: 1em; 176 | border-radius: 0.5em; 177 | } 178 | 179 | .udapp input { border-left: 0 none;} 180 | .udapp button { 181 | background-color: #666; 182 | color: white; 183 | cursor: pointer; 184 | } 185 | 186 | .udapp .instance input, 187 | .udapp .instance button { 188 | width: 50%; 189 | float: left; 190 | } 191 | 192 | .udapp .contractProperty.hasArgs input, 193 | .udapp .contractProperty.hasArgs button { 194 | width: 50%; 195 | } 196 | 197 | .udapp .contractProperty .call { 198 | background-color: #D42828; 199 | } 200 | 201 | .udapp .contractProperty.constant .call { 202 | background-color: #556DF3; 203 | } 204 | 205 | .udapp .contractProperty input { 206 | display: none; 207 | } 208 | 209 | .udapp .contractProperty > .value { 210 | padding: 0 0.4em; 211 | box-sizing: border-box; 212 | width: 50%; 213 | float: left; 214 | word-wrap: break-word; 215 | } 216 | 217 | .udapp .contractProperty.hasArgs input { 218 | display: block; 219 | border-top-left-radius: 0; 220 | border-bottom-left-radius: 0; 221 | } 222 | 223 | .udapp .contractProperty.hasArgs button { 224 | border-top-right-radius: 0; 225 | border-bottom-right-radius: 0; 226 | border-right: 0; 227 | } 228 | 229 | 230 | .udapp .events:not(:empty):before { 231 | content: "Events"; 232 | font-weight: bold; 233 | display: block; 234 | margin-bottom: 0.4em; 235 | } 236 | 237 | .udapp .events .event { 238 | padding: 0.4em; 239 | position: relative; 240 | word-wrap: break-word; 241 | padding-right: 3em; 242 | background-color: white; 243 | margin-bottom: 0.5em; 244 | white-space: pre; 245 | } 246 | 247 | .udapp .events .event .name { margin-right: 0.5em; } 248 | 249 | 250 | 251 | .udapp .legend { 252 | font-size: 12px; 253 | float: left; 254 | color: #666; 255 | } 256 | 257 | .udapp .legend div { 258 | display: inline-block; 259 | margin-right: 0.5em; 260 | } 261 | .udapp .legend div:before { 262 | content: "."; 263 | color: transparent; 264 | display: inline-block; 265 | background-color: #ccc; 266 | height: 1em; 267 | margin-right: 0.5em; 268 | width: 1em; 269 | } 270 | 271 | .udapp .legend .attach:before { background-color: #62B762; } 272 | .udapp .legend .transact:before { background-color: #D42828; } 273 | .udapp .legend .call:before { background-color: #556DF3; } 274 | 275 | .udapp .poweredBy { 276 | float: right; 277 | color: #666; 278 | font-size: 12px; 279 | } 280 | -------------------------------------------------------------------------------- /mappingBytes32.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Universal ÐApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 | 23 | 24 | 25 |
26 |

Web3.js bug report

27 |

Documentation / Source: https://github.com/d11e9/universal-dapp

28 | 29 |

Github issue: mapping( bytes32 => bytes32) public x;

30 | 31 | 32 |

This is a demo page to reproduce a bug in web3.js

33 |

Steps in VM:

34 | 41 | 42 |

Steps when connected to a node (refresh)

43 |

You will need to mine the transactions (ideally on a test net)

44 | 45 | 52 | 53 |

For comparision you can get the public val method, which returns the last set bytes32. in the above case getting the value directly works while getting from the mapping returns '0x0000'

54 | 55 |

For reference the solidity code for this test case is:

56 | 66 | 67 | 68 | 69 |

By default Universal ÐApp runs in a VM

70 |

71 |
72 | 73 |
74 |
75 | 76 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /src/universal-dapp.js: -------------------------------------------------------------------------------- 1 | function UniversalDApp (contracts, options) { 2 | this.options = options || {}; 3 | this.$el = $('
'); 4 | this.contracts = contracts; 5 | 6 | if (!options.vm && web3.currentProvider) { 7 | 8 | } else if (options.vm) { 9 | this.BN = EthVm.deps.ethUtil.BN; 10 | this.stateTrie = new EthVm.deps.Trie(); 11 | this.vm = new EthVm(this.stateTrie); 12 | this.secretKey = '3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511' 13 | this.publicKey = '0406cc661590d48ee972944b35ad13ff03c7876eae3fd191e8a2f77311b0a3c6613407b5005e63d7d8d76b89d5f900cde691497688bb281e07a5052ff61edebdc0' 14 | this.address = ethUtil.pubToAddress(new Buffer(this.publicKey, 'hex'), true); 15 | this.account = new EthVm.deps.Account(); 16 | this.account.balance = new this.BN('f000000000000000001', 16); 17 | this.nonce = 0; 18 | this.stateTrie.put(this.address, this.account.serialize()); 19 | } else { 20 | var host = options.host || "localhost"; 21 | var port = options.port || "8545"; 22 | var rpc_url = 'http://' + host + ':' + port; 23 | web3.setProvider( new web3.providers.HttpProvider( rpc_url ) ); 24 | } 25 | 26 | } 27 | UniversalDApp.prototype.render = function () { 28 | if (this.contracts.length == 0) { 29 | this.$el.append( this.getABIInputForm() ); 30 | } else { 31 | 32 | for (var c in this.contracts) { 33 | var $contractEl = $('
'); 34 | 35 | if (this.contracts[c].address) { 36 | this.getInstanceInterface(this.contracts[c], this.contracts[c].address, $contractEl ); 37 | } else { 38 | var $title = $('').text( this.contracts[c].name ); 39 | if (this.contracts[c].bytecode) { 40 | $title.append($('
').text((this.contracts[c].bytecode.length / 2) + ' bytes')) 41 | } 42 | $contractEl.append( $title ).append( this.getCreateInterface( $contractEl, this.contracts[c]) ); 43 | } 44 | this.$el.append( $contractEl ); 45 | } 46 | } 47 | $legend = $('
') 48 | .append( $('
').text('Attach') ) 49 | .append( $('
').text('Transact') ) 50 | .append( $('
').text('Call') ) 51 | 52 | this.$el.append( $('
') 53 | .html("Universal ÐApp powered by The Blockchain") ) 54 | 55 | this.$el.append( $legend ) 56 | return this.$el; 57 | } 58 | 59 | UniversalDApp.prototype.getABIInputForm = function (cb){ 60 | var self = this; 61 | var $el = $('
'); 62 | var $jsonInput = $('",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*\s*$/g,ib={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("