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
3d5b9c94
Commit
3d5b9c94
authored
May 27, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better regex
parent
677c64a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
23 deletions
+5
-23
gadget_parser.js
gadget_parser.js
+2
-18
gadget_result.js
gadget_result.js
+2
-3
search.js
search.js
+1
-2
No files found.
gadget_parser.js
View file @
3d5b9c94
...
...
@@ -58,24 +58,8 @@
})
.
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
);
var
regEx
=
new
RegExp
(
'
(style="(.*?)"|style="(.*?)")
'
,
'
gi
'
);
return
body
.
replace
(
regEx
,
""
);
})
.
declareMethod
(
"
is_already_parsed
"
,
function
(
storage
,
title
){
...
...
gadget_result.js
View file @
3d5b9c94
...
...
@@ -40,10 +40,8 @@
parser
=
new
DOMParser
();
xmlDoc
=
parser
.
parseFromString
(
item
.
body
,
"
text/xml
"
);
body_text
=
xmlDoc
.
getElementsByTagName
(
"
description
"
)[
0
].
childNodes
[
0
].
nodeValue
;
console
.
log
(
"
ok :
"
+
item
.
title
);
return
this
.
cut_description
(
body_text
,
key
)
.
push
(
function
(
result
){
//console.log(item.title);
if
(
result
===
null
)
body
.
innerHTML
=
""
;
else
body
.
innerHTML
=
result
.
slice
(
1
);
list_item
.
appendChild
(
body
);
...
...
@@ -63,8 +61,9 @@
.
declareMethod
(
"
cut_description
"
,
function
(
body
,
key
){
var
regEx
,
result
;
regEx
=
new
RegExp
(
'
[^.
]*
'
+
"
"
+
key
+
"
"
+
'
[^.]*
\
.
'
,
'
g
'
);
regEx
=
new
RegExp
(
'
[^.
?!]*
'
+
'
'
+
key
+
'
'
+
'
[^.?!]*[.?!]
'
,
'
gm
'
);
result
=
regEx
.
exec
(
body
);
console
.
log
(
"
result:
"
);
console
.
log
(
result
);
if
(
result
===
null
)
return
null
;
else
return
result
[
0
];
});
...
...
search.js
View file @
3d5b9c94
...
...
@@ -60,7 +60,6 @@
promise_list
=
[],
i
;
for
(
i
=
0
;
i
<
gadget
.
state
.
to_load
.
length
;
i
++
){
//console.log(gadget.state.parser_gadget);
promise_list
.
push
(
gadget
.
state
.
parser_gadget
.
read_file
(
"
./test-files/
"
+
gadget
.
state
.
to_load
[
i
]));
}
RSVP
.
all
(
promise_list
);
...
...
@@ -71,7 +70,7 @@
options
;
options
=
{
query
:
'
(title:"%
'
+
key
+
'
%") OR (title:"
'
+
key
+
'
%") OR (body:"%
'
+
key
+
'
%")
'
query
:
'
(title:"%
'
+
key
+
'
%") OR (title:"
'
+
key
+
'
%") OR (body:"%
'
+
key
+
'
%")
'
};
return
gadget
.
state
.
result_gadget
.
clear
()
...
...
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