Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Mynij
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
Mynij
Commits
677c64a2
Commit
677c64a2
authored
May 27, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test : remove styling in HTML while parsing
parent
a86a462d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
17 deletions
+26
-17
gadget_parser.js
gadget_parser.js
+26
-17
No files found.
gadget_parser.js
View file @
677c64a2
...
...
@@ -3,7 +3,7 @@
(
function
(
window
,
RSVP
,
rJS
,
jIO
)
{
"
use strict
"
;
rJS
(
window
)
.
declareAcquiredMethod
(
"
get_model
"
,
"
get_model
"
)
.
declareMethod
(
"
read_file
"
,
function
(
link
)
{
...
...
@@ -39,7 +39,7 @@
xmlhttp
.
send
();
});
})
.
declareMethod
(
"
parse
"
,
function
(
local_cur_text
,
storage
)
{
var
title_start
=
local_cur_text
.
indexOf
(
"
<title>
"
)
+
7
,
title_end
=
local_cur_text
.
indexOf
(
"
</title>
"
),
...
...
@@ -47,7 +47,7 @@
link_end
=
local_cur_text
.
indexOf
(
"
</link>
"
),
body_start
=
local_cur_text
.
indexOf
(
"
<description>
"
),
body_end
=
local_cur_text
.
indexOf
(
"
</description>
"
)
+
14
;
return
this
.
parse_body
(
local_cur_text
.
slice
(
body_start
,
body_end
))
return
this
.
remove_css
(
local_cur_text
.
slice
(
body_start
,
body_end
))
.
push
(
function
(
result
){
return
storage
.
put
({
"
title
"
:
local_cur_text
.
slice
(
title_start
,
title_end
),
...
...
@@ -56,19 +56,28 @@
});
});
})
.
declareMethod
(
"
parse_body
"
,
function
(
body
){
/*var before,
after;
while (body.indexOf("<span style") > -1){
before = body.slice(0, body.indexOf("<span style"));
after = body.slice(body.indexOf("">"), body.length -1);
body = before + after;
}
console.log(body);*/
return
body
;
.
declareMethod
(
"
remove_css
"
,
function
(
body
){
var
regEx
,
result
;
regEx
=
new
RegExp
(
'
<style.*/>
'
);
do
{
result
=
regEx
.
exec
(
body
);
body_before
=
body
.
slice
(
0
,
result
.
index
);
body_after
=
body
.
slice
(
result
.
index
+
result
[
0
].
length
+
1
);
body
=
body_before
+
body_after
;
}
while
(
result
!==
null
);
regEx
=
new
RegExp
(
'
(<span style=.*>|<span style.*">)
'
);
do
{
result
=
regEx
.
exec
(
body
);
body_before
=
body
.
slice
(
0
,
result
.
index
);
body_after
=
body
.
slice
(
result
.
index
+
result
[
0
].
length
+
1
);
body
=
body_before
+
'
<span>
'
+
body_after
;
}
while
(
result
!==
null
);
})
.
declareMethod
(
"
is_already_parsed
"
,
function
(
storage
,
title
){
return
storage
.
all_loaded_docs
()
.
push
(
function
(
result
){
...
...
@@ -79,5 +88,5 @@
return
false
;
})
});
}(
window
,
RSVP
,
rJS
,
jIO
));
\ No newline at end of file
}(
window
,
RSVP
,
rJS
,
jIO
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment