PluginProbe
Wp-Insert / 1.2
Wp-Insert v1.2
trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.3.0 1.3.1 1.3.3 1.4 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 2.0 All 63 releases
wp-insert / fckeditor / editor / _source / classes / fckhtmliterator.js

fckhtmliterator.js in Wp-Insert 1.2, at fckeditor/editor/_source/classes/fckhtmliterator.js

285 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*
2
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4
5 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
6
7 *
8
9 * == BEGIN LICENSE ==
10
11 *
12
13 * Licensed under the terms of any of the following licenses at your
14
15 * choice:
16
17 *
18
19 * - GNU General Public License Version 2 or later (the "GPL")
20
21 * http://www.gnu.org/licenses/gpl.html
22
23 *
24
25 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
26
27 * http://www.gnu.org/licenses/lgpl.html
28
29 *
30
31 * - Mozilla Public License Version 1.1 or later (the "MPL")
32
33 * http://www.mozilla.org/MPL/MPL-1.1.html
34
35 *
36
37 * == END LICENSE ==
38
39 *
40
41 * This class can be used to interate through nodes inside a range.
42
43 *
44
45 * During interation, the provided range can become invalid, due to document
46
47 * mutations, so CreateBookmark() used to restore it after processing, if
48
49 * needed.
50
51 */
52
53
54
55 var FCKHtmlIterator = function( source )
56
57 {
58
59 this._sourceHtml = source ;
60
61 }
62
63 FCKHtmlIterator.prototype =
64
65 {
66
67 Next : function()
68
69 {
70
71 var sourceHtml = this._sourceHtml ;
72
73 if ( sourceHtml == null )
74
75 return null ;
76
77
78
79 var match = FCKRegexLib.HtmlTag.exec( sourceHtml ) ;
80
81 var isTag = false ;
82
83 var value = "" ;
84
85 if ( match )
86
87 {
88
89 if ( match.index > 0 )
90
91 {
92
93 value = sourceHtml.substr( 0, match.index ) ;
94
95 this._sourceHtml = sourceHtml.substr( match.index ) ;
96
97 }
98
99 else
100
101 {
102
103 isTag = true ;
104
105 value = match[0] ;
106
107 this._sourceHtml = sourceHtml.substr( match[0].length ) ;
108
109 }
110
111 }
112
113 else
114
115 {
116
117 value = sourceHtml ;
118
119 this._sourceHtml = null ;
120
121 }
122
123 return { 'isTag' : isTag, 'value' : value } ;
124
125 },
126
127
128
129 Each : function( func )
130
131 {
132
133 var chunk ;
134
135 while ( ( chunk = this.Next() ) )
136
137 func( chunk.isTag, chunk.value ) ;
138
139 }
140
141 } ;
142
143 /*
144
145 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
146
147 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
148
149 *
150
151 * == BEGIN LICENSE ==
152
153 *
154
155 * Licensed under the terms of any of the following licenses at your
156
157 * choice:
158
159 *
160
161 * - GNU General Public License Version 2 or later (the "GPL")
162
163 * http://www.gnu.org/licenses/gpl.html
164
165 *
166
167 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
168
169 * http://www.gnu.org/licenses/lgpl.html
170
171 *
172
173 * - Mozilla Public License Version 1.1 or later (the "MPL")
174
175 * http://www.mozilla.org/MPL/MPL-1.1.html
176
177 *
178
179 * == END LICENSE ==
180
181 *
182
183 * This class can be used to interate through nodes inside a range.
184
185 *
186
187 * During interation, the provided range can become invalid, due to document
188
189 * mutations, so CreateBookmark() used to restore it after processing, if
190
191 * needed.
192
193 */
194
195
196
197 var FCKHtmlIterator = function( source )
198
199 {
200
201 this._sourceHtml = source ;
202
203 }
204
205 FCKHtmlIterator.prototype =
206
207 {
208
209 Next : function()
210
211 {
212
213 var sourceHtml = this._sourceHtml ;
214
215 if ( sourceHtml == null )
216
217 return null ;
218
219
220
221 var match = FCKRegexLib.HtmlTag.exec( sourceHtml ) ;
222
223 var isTag = false ;
224
225 var value = "" ;
226
227 if ( match )
228
229 {
230
231 if ( match.index > 0 )
232
233 {
234
235 value = sourceHtml.substr( 0, match.index ) ;
236
237 this._sourceHtml = sourceHtml.substr( match.index ) ;
238
239 }
240
241 else
242
243 {
244
245 isTag = true ;
246
247 value = match[0] ;
248
249 this._sourceHtml = sourceHtml.substr( match[0].length ) ;
250
251 }
252
253 }
254
255 else
256
257 {
258
259 value = sourceHtml ;
260
261 this._sourceHtml = null ;
262
263 }
264
265 return { 'isTag' : isTag, 'value' : value } ;
266
267 },
268
269
270
271 Each : function( func )
272
273 {
274
275 var chunk ;
276
277 while ( ( chunk = this.Next() ) )
278
279 func( chunk.isTag, chunk.value ) ;
280
281 }
282
283 } ;
284
285