%PDF- %PDF-
Direktori : /proc/985914/root/data/old/home/stash/atlassian-stash/static/util/ |
Current File : //proc/985914/root/data/old/home/stash/atlassian-stash/static/util/html-min.js |
define("util/html",["aui","util/function","exports"],function(E,F,P){var M=window.console&&console.error?function(){console.error.apply(console,arguments)}:E.log;var D={OPEN:"open",CLOSE:"close"};function G(){}G.prototype.next=function(){M("NodeStream.next is abstract and must be implemented")};G.prototype.getNextType=function(){M("NodeStream.getNextType is abstract and must be implemented")};G.prototype.getNextTextPosition=function(){M("NodeStream.getNextTextPosition is abstract and must be implemented")};var O=/<\s*(\w+)(?=\s|>)/,C=1;function B(Y,d){var f=0,T=0,Z=Y.length,V="<",c=">";var g,e;var X=d||function(h){M("Not yet implemented")};function b(){g=null;e=false}function W(){if(e||f==null){return }e=true;var h=Y.indexOf(V,f);if(h===f){return }if(h===-1){f=null;T=null}else{T+=X(Y.substring(f,h)).length;f=h}}function U(){W();if(f==null){return null}return Y[f+1]==="/"?D.CLOSE:D.OPEN}var S=new G();var a=[];S.getNextType=function(){return g||(g=U())};S.next=function(){W();if(f==null){return null}var h=this.getNextType();var l=Y.indexOf(c,f),i=l===-1?Z:l+1,j=Y.substring(f,i);var k={type:h,value:j,textPosition:T};if(h===D.OPEN){k.close={type:D.CLOSE,value:"</"+j.match(O)[C]+">"};a.push(T)}f=i;b();return k};S.getNextTextPosition=function(){W();return T};return S}function Q(S){return B(S,function(T){return T.replace(/&|<|>/gm,function(U){switch(U){case"&":return"&";case"<":return"<";case">":return">"}})})}function R(T,U,S){S=S||"string";return typeof T==="function"?T:F.constant(typeof T===S?T:U)}function J(i,W,T){T=T||{};var h=0,U=0,c=i.length,V=D.OPEN,b=R(T.lineStart,""),Z=R(T.lineEnd,"<br />"),Y=R(T.emptyLine,""),X=R(T.lineOffset,1,"number"),e,d;W=W||F.dot("text");function a(){V=D.CLOSE;var j=W(i[h],h).length;d={type:D.CLOSE,value:j?Z(i[h],h):(Y(i[h],h)+Z(i[h],h))};e={type:D.OPEN,value:b(i[h],h),close:d,textPosition:U};U=U+j+X(i[h],h);return e}function g(){h++;d.textPosition=U;V=D.OPEN;e=null;return d}var f={open:a,close:g};var S=new G();S.getNextType=function(){if(h>=c){return null}return V};S.next=function(){if(h>=c){return null}return f[V]()};S.getNextTextPosition=function(){if(h>=c){return null}return U};return S}function L(Z){var W,T=Infinity,U={getNextTextPosition:F.constant(null)};for(var V=0,S=Z.length;V<S;V++){var X=Z[V],Y=X.getNextTextPosition();if(Y!=null&&Y<T){U=X;T=Y;W=V;continue}if(Y===T){if(X.getNextType()===D.CLOSE){U=X;W=V}}}return{index:W,stream:U}}function I(){this._backing=[]}I.prototype.pushAtPriority=function(U,S){var T=this._backing[S]||(this._backing[S]=[]);T.push(U)};I.prototype.popAtPriority=function(S){var T=this._backing[S]||(this._backing[S]=[]);return T.pop()};I.prototype.popPrioritiesAbove=function(V){var U=[],X=this._backing,T=V+1;while(X.length>T){var W=this._backing.pop();if(W){for(var S=W.length-1;S>=0;S--){U.push(W[S])}}}return U};I.prototype.peek=function(){var S=this._backing.length;while(S--){if(this._backing[S]&&this._backing[S].length){return this._backing[S][this._backing[S].length-1]}}return undefined};function N(V){var U=Array.prototype.slice.call(arguments,1),d=0,S=new I(),W=[],Y;var c="";while(true){var g=L(U),h=g.index,T=g.stream,f=T.getNextTextPosition(),Z=f==null,l=Z||f>d;if(W.length&&(l||h>=Y)){for(var b=W.length-1;b>=0;b--){var X=W[b];c+=X.tag.value;S.pushAtPriority(X,X.streamIndex)}W=[];Y=null}if(l){c+=E.escapeHtml(V.substring(d,f||undefined))}if(Z){return c}var m=T.next();if(m!=null){if(m.type===D.CLOSE){S.popAtPriority(h)}else{S.pushAtPriority({streamIndex:h,tag:m},h)}var k=S.popPrioritiesAbove(h);if(k.length){Y=k[0].streamIndex;for(var a=0,e=k.length;a<e;a++){c+=k[a].tag.close.value}W.push.apply(W,k)}c+=m.value}d=f}}var H=document.createElement("div");function A(V,U,W){if(W==="html"||!V.hasChildNodes()){V.innerHTML=U;return }H.innerHTML=U;var S=document.createDocumentFragment(),T=H.childNodes.length;while(T--){S.appendChild(H.childNodes[0])}if(W==="append"){V.appendChild(S)}else{V.insertBefore(S,V.firstChild)}}function K(S){return S.replace(/:/g,"\\:").replace(/\./g,"\\.")}P.quickNDirtyAttach=A;P.NodeStream=G;P.NodeType=D;P.htmlNodeStream=B;P.highlightJsNodeStream=Q;P.lineNodeStream=J;P.mergeStreams=N;P.sanitizeId=K});