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
Show 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 @@
...
@@ -58,24 +58,8 @@
})
})
.
declareMethod
(
"
remove_css
"
,
function
(
body
){
.
declareMethod
(
"
remove_css
"
,
function
(
body
){
var
regEx
,
var
regEx
=
new
RegExp
(
'
(style="(.*?)"|style="(.*?)")
'
,
'
gi
'
);
result
;
return
body
.
replace
(
regEx
,
""
);
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
){
.
declareMethod
(
"
is_already_parsed
"
,
function
(
storage
,
title
){
...
...
gadget_result.js
View file @
3d5b9c94
...
@@ -40,10 +40,8 @@
...
@@ -40,10 +40,8 @@
parser
=
new
DOMParser
();
parser
=
new
DOMParser
();
xmlDoc
=
parser
.
parseFromString
(
item
.
body
,
"
text/xml
"
);
xmlDoc
=
parser
.
parseFromString
(
item
.
body
,
"
text/xml
"
);
body_text
=
xmlDoc
.
getElementsByTagName
(
"
description
"
)[
0
].
childNodes
[
0
].
nodeValue
;
body_text
=
xmlDoc
.
getElementsByTagName
(
"
description
"
)[
0
].
childNodes
[
0
].
nodeValue
;
console
.
log
(
"
ok :
"
+
item
.
title
);
return
this
.
cut_description
(
body_text
,
key
)
return
this
.
cut_description
(
body_text
,
key
)
.
push
(
function
(
result
){
.
push
(
function
(
result
){
//console.log(item.title);
if
(
result
===
null
)
body
.
innerHTML
=
""
;
if
(
result
===
null
)
body
.
innerHTML
=
""
;
else
body
.
innerHTML
=
result
.
slice
(
1
);
else
body
.
innerHTML
=
result
.
slice
(
1
);
list_item
.
appendChild
(
body
);
list_item
.
appendChild
(
body
);
...
@@ -63,8 +61,9 @@
...
@@ -63,8 +61,9 @@
.
declareMethod
(
"
cut_description
"
,
function
(
body
,
key
){
.
declareMethod
(
"
cut_description
"
,
function
(
body
,
key
){
var
regEx
,
var
regEx
,
result
;
result
;
regEx
=
new
RegExp
(
'
[^.
]*
'
+
"
"
+
key
+
"
"
+
'
[^.]*
\
.
'
,
'
g
'
);
regEx
=
new
RegExp
(
'
[^.
?!]*
'
+
'
'
+
key
+
'
'
+
'
[^.?!]*[.?!]
'
,
'
gm
'
);
result
=
regEx
.
exec
(
body
);
result
=
regEx
.
exec
(
body
);
console
.
log
(
"
result:
"
);
console
.
log
(
result
);
if
(
result
===
null
)
return
null
;
if
(
result
===
null
)
return
null
;
else
return
result
[
0
];
else
return
result
[
0
];
});
});
...
...
search.js
View file @
3d5b9c94
...
@@ -60,7 +60,6 @@
...
@@ -60,7 +60,6 @@
promise_list
=
[],
promise_list
=
[],
i
;
i
;
for
(
i
=
0
;
i
<
gadget
.
state
.
to_load
.
length
;
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
]));
promise_list
.
push
(
gadget
.
state
.
parser_gadget
.
read_file
(
"
./test-files/
"
+
gadget
.
state
.
to_load
[
i
]));
}
}
RSVP
.
all
(
promise_list
);
RSVP
.
all
(
promise_list
);
...
@@ -71,7 +70,7 @@
...
@@ -71,7 +70,7 @@
options
;
options
;
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
()
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