Imitation DW8 code folding HTML editors
Related Tags:
Beta (only ie5.5 support, and a page where one can only release)
Collect views
Features:
1. Dynamic analysis, intelligent folding ctrl Enter mandatory renewal
2.tab key export two spaces (if constituency lines, prior to joining the two spaces, at the same time shift button on the contrary), Ctrl T to replace \ t for the two spaces
3. Automatic indentation Enter
4.Ctrl W Preview
Restrictions:
1. Cancel the pop-up menu (shear paste can be copied using the keyboard)
2. Not support drag-and-drop text
3.Ctrl Z will cancel all operations
4. Block beginning and ending testing not strict and does not consider vbscript
5. Operating efficiency to be improved
<style>
body (
Text-align: center;
)
OTxt # # (oBox
Height: 440px;
Border: none;
Border: 1px solid # 666666;
)
(# OTxt
Width: 740px;
Color: # 333333;
Background-color: # f0f0f0;
Font-family: verdana;
Font-size: 11px;
Line-height: 13px;
Margin-left: 16px;
Overflow: auto;
Border-left: none;
Scrollbar-arrow-color: # 666666;
Scrollbar-base-color: # 666666;
Scrollbar-darkshadow-color: # f0f0f0;
Scrollbar-face-color: # f0f0f0;
)
(# OBox
Position: absolute;
Width: 15px;
Overflow-y: hidden;
Background-color: # e0e0e0;
Padding-top: 1px;
Margin-top: 1px;
Padding-bottom: 19px;
Border-right: none;
)
</ Style>
<script>
/ *
Beta (only ie5.5 support, and a page where one can only release)
Collect views
Features:
1. Dynamic analysis, intelligent folding ctrl Enter mandatory renewal
2.tab key export two spaces (if constituency lines, prior to joining the two spaces, at the same time shift button on the contrary), Ctrl T to replace \ t for the two spaces
3. Automatic indentation Enter
4.Ctrl W Preview
Restrictions:
1. Cancel the pop-up menu (shear paste can be copied using the keyboard)
2. Not support drag-and-drop text
3.Ctrl Z will cancel all operations
4. Block beginning and ending testing not strict and does not consider vbscript
5. Operating efficiency to be improved
* /
Window.onload = function () (
OBox.mLine = "http://free.txd.cn/mozart0/img/line.gif";
OBox.mPlus = "http://free.txd.cn/mozart0/img/plus.gif";
OBox.mMinus = "http://free.txd.cn/mozart0/img/minus.gif";
OBox.mEnd = "http://free.txd.cn/mozart0/img/end.gif";
OBox.isPlus = function (o) (
Return / plus \. / .test (O.src);
)
OBox.isMinus = function (o) (
Return / minus \. / .test (O.src);
)
OBox.isLine = function (o) (
Return / line \. / .test (O.src);
)
OBox.isEnd = function (o) (
Return / end \. / .test (O.src);
)
OBox.childrenVisible = function (index) (
This.children var t = [index];
While (t.style.display == "none")
T = t.nextSibling;
Var x = t.offsetTop / t.height;
While (x <index) (
T = t.nextSibling;
If (t.style.display! = "None")
X;
)
Return t;
)
OBox.hideBlock = function (index) (
Var n = 1, x = 1;
Var c = this.children;
C [index]. Src = this.mPlus;
While (index <c.length & n) (
Var t = c [index];
If (t.style.display! = "None") (
X;
T.style.display = "none";
)
If (this.isEnd (t))
N -;
Else if (! This.isLine (t))
N;
)
Return x;
)
OBox.showBlock = function (index, b) (
Var index0 = index, c = oBox.children;
C [index]. Src = b? This.mMinus: this.mPlus;
C [index]. Style.display = "block";
Index;
If (b)
While (index <c.length) (
Var t = c [index];
If (this.isLine (t)) (
T.style.display = "block";
Index;
)
Else if (this.isEnd (t)) (
T.style.display = "block";
Break;
)
Else
Index = this.showBlock (index, this.isMinus (t))
)
Else (
Var n = 1;
While (index <c.length) (
Var t = c [index];
T.style.display == "none";
If (this.isEnd (t)) (
If (- n == 0)
Break;
)
Else if (! This.isLine (t))
N;
Index;
)
)
Return index-index0 1;
)
OBox.refresh = function (o, str) (
O.src = this.judge (str);
O.storeText = str;
)
OBox.judge = function (s) (
Var l = / \ (/. Test (s), r = / \) /. Test (s);
If (l & &! R)
Return this.mMinus;
If (! L & r)
Return this.mEnd;
S = s.replace (/ <(\ w) .* <\ / \ 1> / g, "<$ 1 />");
L = / ^ \ s * <\ w [^ \ /] [> \ r] /. Test (s);
R = / \ /> /. Test (s);
If (l & &! R)
Return this.mMinus;
R = / <\ / \ w> /. Test (s);
If (r)
Return this.mEnd;
Return this.mLine;
)
OBox.onclick = function () (
Var o = event.srcElement;
If (o == this)
Return;
Var vIndex = (o.offsetTop-1) / oTxt.lineHeight;
Var index = vIndex;
This.children var t = [vIndex];
While (t! = O) (
T = t.nextSibling;
Index;
)
If (this.isMinus (o))
OTxt.hideLines (vIndex, this.hideBlock (index));
Else if (this.isPlus (o))
OTxt.showLines (vIndex, this.showBlock (index, true));
OBox.scrollTop = oTxt.scrollTop;
)
OTxt.lineHeight = 13;
OTxt.strSpecial ="......";
OTxt.regSpecial = / \. (6) \ r? $ /;
OTxt.strTab = "";
OTxt.bFixed = false;
OTxt.originalValue = oTxt.value;
OTxt.trueValue = function () (
For (var s = "", c = oBox.children, i = 0; i <c.length-1; i)
S = c [i]. StoreText "\ n";
Return sc [i]. StoreText;
)
OTxt.lineNumber = function (r) (
Var t = this.createTextRange ();
Return Math.round ((r.boundingTop-t.boundingTop) / this.lineHeight);
)
OTxt.rngAtHome = function (r) (
Var t = this.createTextRange ();
T.boundingLeft return r.boundingLeft == == & r.boundingTop t.boundingTop;
)
OTxt.rngAtEnd = function (r) (
Var t = this.createTextRange ();
T.collapse (false);
T.boundingLeft return r.boundingLeft == == & r.boundingTop t.boundingTop;
)
OTxt.hideLines = function (ifrom, n) (
Var a = this.value.match (/. / Mg);
For (var i = 1; i <n; i)
A [ifrom i ]="";
A [ifrom] = a [ifrom]. Replace (/ \ r /, this.strSpecial);
If (ifrom n <a.length)
A [ifrom] = "\ r";
This.value = a.join ("");
)
OTxt.showLines = function (ifrom, n) (
Var a = this.value.match (/. / Mg);
Var t = oBox.childrenVisible (ifrom). NextSibling;
For (var s = "" i = 0, t & i <n-1, i, t = t.nextSibling)
If (t.style.display! = "None") (
If (! OBox.isPlus (t))
S = t.storeText;
Else
S = t.storeText.replace (/ \ r? $ /, This.strSpecial "\ r");
)
A [ifrom] = a [ifrom]. Replace (this.regSpecial, "\ r" s);
This.value = a.join ("");
)
OTxt.ondrag =
OTxt.ondrop =
OTxt.oncontextmenu = function () (
Return false;
)
OTxt.onscroll = function () (
OBox.scrollTop = this.scrollTop;
)
OTxt.onkeydown = function () (
If (event.keyCode> = 33 & & event.keyCode <= 40)
Return true;
Var r = document.selection.createRange ();
Var t = oBox.childrenVisible (this.lineNumber (r));
If (! R.text) (
If (oBox.isPlus (t))
Return false;
)
Else (
Var n = Math.floor (r.boundingHeight / this.lineHeight);
For (var i = 0, t1 = t.nextSibling; i <n & &t1; i, t1 = t1.nextSibling)
If (t1.style.display == "none")
Return false;
)
This.bFixed = false;
Var k = event.keyCode;
If (k = 9) (/ / Tab
Var r1 = r.duplicate ();
If (r.boundingHeight> this.lineHeight) (
If (! Event.shiftKey) (
R.text = r.text.replace (/^(.)/ mg, this.strTab "$ 1");
For (var i = 0, t = t1; i <n; i, t1 = t1.nextSibling)
T1.storeText = this.strTab t1.storeText;
)
Else (
Var reg = new RegExp ( "^" this.strTab, "mg");
R.text = r.text.replace (reg ,"");
For (var i = 0, t = t1; i <n; i, t1 = t1.nextSibling)
T1.storeText = t1.storeText.replace (reg ,"");
)
R.setEndPoint ( "StartToStart" r1)
R.select ();
This.bFixed = true;
)
Else
Fix (r, this.strTab);
Return false
)
If (k == 13) (/ / Enter
If (event.ctrlKey)
Build ();
Else (
Var r1 = r.duplicate ();
Var x = this.createTextRange ();
This.scrollLeft = 0;
R1.moveToPoint (x.offsetLeft, r.offsetTop);
R1.setEndPoint ( "EndToStart", r);
Fix (r, "\ r \ n" r1.text.replace (/ \ S. */,""));
)
Return false;
)
If (k == 46) (/ / Del
If (! R.boundingWidth) (
If (this.rngAtEnd (r)) (
This.bfixed = true;
Return;
)
R.moveEnd ( "character", 1);
)
Fix (r ,"");
Return false;
)
If (k = 8) (/ / BackSpace
If (! R.boundingWidth) (
If (this.rngAtHome (r)) (
This.bfixed = true;
Return true;
)
R.moveStart ( "character", -1);
)
Fix (r ,"");
Return false;
)
If (k == 87) (/ / ctrl W
If (! Event.ctrlKey)
Return true;
Try (
This.win.navigate ( "about: blank");
)
Catch (e) (
This.win = window.open ( "about: blank");
)
This.win.document.write (this.trueValue ());
This.win.focus ();
This.win.document.close ();
Return false;
)
If (k == 84) (/ / Ctrl T
If (! Event.ctrlKey)
Return true;
This.value.replace this.value = (/ \ t / g, this.strTab);
For (var i = 0, c = oBox.children; i <c.length; i)
C [i]. StoreText = c [i]. StoreText.replace (/ \ t / g, this.strTab);
OTxt.bFixed = true;
Return false;
)
If (k == 86) (/ / Ctrl V
If (! Event.ctrlKey)
Return true;
Fix (r, clipboardData.getData ( "text"));
Return false;
)
If (k == 88) (/ / Ctrl X
If (! Event.ctrlKey | |! R.boundingWidth)
Return true;
Var s = r.text;
If (! S)
For (var i = 0, n = Math.floor (r.boundingHeight / this.lineHeight); i <n; i)
S = "\ r \ n";
Else (
Var r1 = r.duplicate ();
R1.moveEnd ( "character", 1);
If (r.text == == r1.text & r.boundingTop r1.boundingTop)
S = "\ r \ n";
)
ClipboardData.setData ( "text", s);
Fix (r ,"");
Return false;
)
If (k == 90) (/ / Ctrl Z
If (! Event.ctrlKey)
Return true;
This.value = this.originalValue;
Build ();
Return false;
)
Return true;
)
OTxt.onkeyup = function () (
If (this.bFixed)
Return;
Var k = event.keyCode;
If (k == 32 | | k> = 48 & k <= 111 | | k> = 186 & & k <= 192 | | k> = 219 & & k <= 222) (
Var n = this.lineNumber (document.selection.createRange ());
OBox.refresh (oBox.childrenVisible (n), this.value.split ( "\ n") [n]);
)
)
Function fix (rng, str) (
OTxt.bFixed = true;
Var t0 = oTxt.lineNumber (rng);
Var t1 = t0 Math.floor (rng.boundingHeight / oTxt.lineHeight);
Rng.text = str;
Rng.select ();
Var t2 = oTxt.lineNumber (rng) 1;
Var a = oTxt.value.split ( "\ n");
Var o = oBox.childrenVisible (t0);
If (t1 <= t2) (
For (i = t0; i <t1; i, o = o.nextSibling)
OBox.refresh (o, a [i]);
For (i = t2-1; i> = t1; i -)
OBox.refresh (o = oBox.insertBefore (new Image (), o), a [i]);
)
Else (
For (i = t0; i <t2; i, o = o.nextSibling)
OBox.refresh (o, a [i]);
For (; i <t1; i) (
Var next = o.nextSibling;
OBox.removeChild (o);
O = next;
)
)
While (a.length <oBox.children.length) (
Var next = o.nextSibling;
OBox.removeChild (o);
O = next;
)
OBox.scrollTop = oTxt.scrollTop;
)
Function build () (
OBox.innerHTML = "";
If (! OTxt.value)
Return;
Var a = oTxt.value.split ( "\ n");
For (var i = 0; i <a.length; i)
OBox.refresh (oBox.appendChild (new Image ()), a [i]);
OTxt.bFixed = true;
)
Build ();
)
</ Script>
<div Id=oBox> </ div>
<textarea Id=oTxt wrap=off> <script>
Function fix (rng, str) (
OTxt.bFixed = true;
Var t0 = oTxt.lineNumber (rng);
Var t1 = t0 Math.floor (rng.boundingHeight / oTxt.lineHeight);
Rng.text = str;
Rng.select ();
Var t2 = oTxt.lineNumber (rng) 1;
Var a = oTxt.value.split ( "\ n");
Var o = oBox.childrenVisible (t0);
If (t1 <= t2) (
For (i = t0; i <t1; i, o = o.nextSibling)
OBox.refresh (o, a [i]);
For (i = t2-1; i> = t1; i -)
OBox.refresh (o = oBox.insertBefore (new Image (), o), a [i]);
)
Else (
For (i = t0; i <t2; i, o = o.nextSibling)
OBox.refresh (o, a [i]);
For (; i <t1; i) (
Var next = o.nextSibling;
OBox.removeChild (o);
O = next;
)
)
While (a.length <oBox.children.length) (
Var next = o.nextSibling;
OBox.removeChild (o);
O = next;
)
OBox.scrollTop = oTxt.scrollTop;
)
Function build () (
OBox.innerHTML = "";
If (! OTxt.value)
Return;
Var a = oTxt.value.split ( "\ n");
For (var i = 0; i <a.length; i)
OBox.refresh (oBox.appendChild (new Image ()), a [i]);
OTxt.bFixed = true;
)
</ Script>
<center>
<h1> Hello world </ h1>
<hr Id="emptyTag"/>
<Div id = "multiLineTag"
style = "text-align: right; font-size: 11px; font-family: tahoma">
By mozart0@2005.12.26 <br/>
Qq76239711 <br/>
<a Href=" mailto:mozart0@etang.com"> mozart0@etang.com </ a>
</ Div>
</ Center> </ textarea>
Update records
--------------
Join tests, to prevent the trip with the editors of a hack38 reminded that the importation of Chinese characters, the number of rows computational error
- CSS simple picture-Daolian code
- Optimizing your CSS code
- CSS code structure of: the div and span!
- CSS code-switching function tab
- HTML and CSS pages prepared by the beautiful formal code
- CSS code-writing techniques commonly used
- Some commonly used CSS code
- CSS style definition of the rolling code
- Clever css debug code
- Summary: A CSS code reference map
- CSS code abbreviation skills zz
- How to Optimize your CSS code?
- The magic code - CSS filter trip
- CSS code attributes Encyclopaedia (HTML)
- CSS code abbreviation skills
- CSS control ul code base
- Js code and code folding effect css
- Common CSS code
- Css code explain
- Css common code




