|
24 | 24 | </style>
|
25 | 25 | <script>
|
26 | 26 | $(document).ready(function() {
|
27 |
| - var orange = false; |
28 |
| - setInterval(function() { |
29 |
| - orange = !orange; |
30 |
| - $('h1').css('border-color', orange ? 'transparent' : '#fa4500'); |
31 |
| - }, 500); |
| 27 | + var orange = false; |
32 | 28 |
|
33 |
| - $('#textarea').bind('updateInfo keyup mousedown mousemove mouseup', function() { |
34 |
| - var range = $(this).textrange(); |
| 29 | + setInterval(function() { |
| 30 | + orange = !orange; |
| 31 | + $('h1').css('border-color', orange ? 'transparent' : '#fa4500'); |
| 32 | + }, 500); |
35 | 33 |
|
36 |
| - $('#info .property').each(function() { |
37 |
| - if(typeof range[$(this).attr('id')] !== 'undefined') { |
38 |
| - if($(this).attr('id') === 'text') { |
39 |
| - range[$(this).attr('id')] = range[$(this).attr('id')].replace(/\n/g, "\\n").replace(/\r/g, "\\r"); |
40 |
| - } |
| 34 | + $('#textarea').bind('updateInfo keyup mousedown mousemove mouseup', function() { |
| 35 | + var range = $(this).textrange(); |
41 | 36 |
|
42 |
| - $(this).children('.value').html(range[$(this).attr('id')]); |
43 |
| - } |
44 |
| - }); |
45 |
| - }); |
| 37 | + $('#info .property').each(function() { |
| 38 | + if (typeof range[$(this).attr('id')] !== 'undefined') { |
| 39 | + if ($(this).attr('id') === 'text') { |
| 40 | + range[$(this).attr('id')] = range[$(this).attr('id')].replace(/\n/g, "\\n").replace(/\r/g, "\\r"); |
| 41 | + } |
46 | 42 |
|
47 |
| - $('#console-log').click(function() { |
48 |
| - var obj = {}; |
| 43 | + $(this).children('.value').html(range[$(this).attr('id')]); |
| 44 | + } |
| 45 | + }); |
| 46 | + }); |
49 | 47 |
|
50 |
| - $('#info .property').each(function() { |
51 |
| - var value = $(this).children('.value').html(); |
52 |
| - obj[$(this).attr('id')] = isNaN(value) || value == '' ? value : parseInt(value); |
53 |
| - }); |
| 48 | + $('#console-log').click(function() { |
| 49 | + var obj = {}; |
54 | 50 |
|
55 |
| - console.log(obj); |
| 51 | + $('#info .property').each(function() { |
| 52 | + var value = $(this).children('.value').html(); |
| 53 | + obj[$(this).attr('id')] = isNaN(value) || value == '' ? value : parseInt(value); |
| 54 | + }); |
56 | 55 |
|
57 |
| - return false; |
58 |
| - }); |
| 56 | + console.log(obj); |
59 | 57 |
|
60 |
| - $('#selection-set').click(function() { |
61 |
| - $('#textarea').textrange('set', $('#char-start').val(), $('#char-end').val()).trigger('updateInfo').focus(); |
62 |
| - }); |
| 58 | + return false; |
| 59 | + }); |
63 | 60 |
|
64 |
| - $('#selection-replace').click(function() { |
65 |
| - $('#textarea').textrange('replace', $('#replace-text').val()).trigger('updateInfo').focus(); |
66 |
| - }); |
| 61 | + $('#selection-set').click(function() { |
| 62 | + $('#textarea').textrange('set', $('#char-start').val(), $('#char-end').val()).trigger('updateInfo').focus(); |
| 63 | + }); |
| 64 | + |
| 65 | + $('#selection-replace').click(function() { |
| 66 | + $('#textarea').textrange('replace', $('#replace-text').val()).trigger('updateInfo').focus(); |
| 67 | + }); |
67 | 68 | });
|
68 | 69 | </script>
|
69 | 70 | </head>
|
@@ -91,7 +92,7 @@ <h1><a href="https://github.com/dwieeb/jquery-textrange/">jquery-textrange</a></
|
91 | 92 | <input type="button" id="console-log" name="console-log" value="console.log() this bad boy">
|
92 | 93 | </div>
|
93 | 94 | <div>
|
94 |
| -Select a substring starting at <input type="text" id="char-start" name="char-start" value="30"> and ending at <input type="text" id="char-end" name="char-end" value="55"> <input type="button" id="selection-set" name="selection-set" value="Go!!"> |
| 95 | +Select a substring starting at <input type="text" id="char-start" name="char-start" value="30"> with a length of <input type="text" id="char-end" name="char-end" value="15"> <input type="button" id="selection-set" name="selection-set" value="Go!!"> |
95 | 96 | </div>
|
96 | 97 | <div>
|
97 | 98 | Replace the selected text with: <input type="text" id="replace-text" name="replace-text" value="some text"> <input type="button" id="selection-replace" name="selection-replace" value="Go!!">
|
|
0 commit comments