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
a404e13f
Commit
a404e13f
authored
May 28, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New model [test]
parent
131452c4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
44 deletions
+75
-44
gadget_model.js
gadget_model.js
+46
-11
gadget_parser.js
gadget_parser.js
+27
-31
search.js
search.js
+2
-2
No files found.
gadget_model.js
View file @
a404e13f
...
...
@@ -5,7 +5,19 @@
rJS
(
window
)
.
ready
(
function
(){
this
.
feeds
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
mynij-v1.2
"
});
this
.
search_storage
=
jIO
.
createJIO
({
type
:
"
union
"
,
storage_list
:
[]
});
this
.
sub_storages
=
[];
/*this.search_storage = jIO.createJIO({
type : "query",
sub_storage:{
type : "uuid",
...
...
@@ -14,14 +26,37 @@
database: "mynij-v1"
}
}
});
});*/
this
.
info
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
mynij-v1-info
"
});
return
this
.
feeds
.
put
(
"
feeds_doc
"
,
{});
})
.
declareMethod
(
"
add_attachment
"
,
function
(
title
,
rss
){
return
this
.
feeds
.
putAttachment
(
"
feeds_doc
"
,
title
,
new
Blob
([
rss
],
{
type
:
"
text/xml
"
}))
.
push
(
function
(){
this
.
sub_storages
.
push
({
type
:
"
my_parser
"
,
document_id
:
"
feeds_doc
"
,
attachment_id
:
title
,
parser
:
"
rss
"
,
sub_storage
:
{
type
:
"
indexeddb
"
,
database
:
"
mynij-v1.2
"
}
});
this
.
search_storage
=
jIO
.
createJIO
({
type
:
"
union
"
,
storage_list
:
this
.
sub_storages
});
});
})
.
declareMethod
(
"
put
"
,
function
()
{
.
declareMethod
(
"
put
"
,
function
()
{
// deprecated
return
this
.
search_storage
.
post
.
apply
(
this
.
search_storage
,
arguments
);
})
...
...
gadget_parser.js
View file @
a404e13f
...
...
@@ -21,35 +21,47 @@
})
.
declareMethod
(
"
read_file_new
"
,
function
(
link
){
var
gadget
=
this
;
return
gadget
.
get_rss
(
link
)
.
push
(
function
(
result
){
var
gadget
=
this
,
xmlhttp
=
new
XMLHttpRequest
();
xmlhttp
.
onreadystatechange
=
function
()
{
if
(
xmlhttp
.
status
==
200
&&
xmlhttp
.
readyState
==
4
){
var
rss
,
title
;
rss
=
resul
t
;
rss
=
xmlhttp
.
responseTex
t
;
title
=
rss
.
slice
(
rss
.
indexOf
(
"
<title>
"
)
+
7
,
rss
.
indexOf
(
"
</title>
"
));
return
gadget
.
is_already_parsed
(
title
)
.
push
(
function
(
is_parsed
){
if
(
!
is_parsed
){
return
gadget
.
remove_css
(
rss
)
.
push
(
function
(
rss_without_css
){
return
gadget
.
state
.
storage
.
put
(
rss_without_css
);
return
gadget
.
state
.
storage
.
add_attachment
(
title
,
rss_without_css
);
});
}
});
});
})
.
declareMethod
(
"
get_rss
"
,
function
(
link
){
var
xmlhttp
=
new
XMLHttpRequest
();
xmlhttp
.
onreadystatechange
=
function
()
{
if
(
xmlhttp
.
status
==
200
&&
xmlhttp
.
readyState
==
4
)
return
xmlhttp
.
responseText
;
}
}
xmlhttp
.
open
(
"
GET
"
,
link
,
true
);
xmlhttp
.
send
();
})
.
declareMethod
(
"
read_file
"
,
function
(
link
)
{
.
declareMethod
(
"
remove_css
"
,
function
(
body
){
var
regEx
=
new
RegExp
(
'
(style="(.*?)"|style="(.*?)")
'
,
'
gi
'
);
return
body
.
replace
(
regEx
,
""
);
})
.
declareMethod
(
"
is_already_parsed
"
,
function
(
title
){
return
this
.
state
.
storage
.
all_loaded_docs
()
.
push
(
function
(
result
){
var
i
;
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
){
if
(
result
.
data
.
rows
[
i
].
id
===
title
)
return
true
;
}
return
false
;
});
});
/*.declareMethod("read_file", function(link) {
var gadget,
xmlhttp,
cur_text,
...
...
@@ -94,22 +106,6 @@
"body": result
});
});
})
.
declareMethod
(
"
remove_css
"
,
function
(
body
){
var
regEx
=
new
RegExp
(
'
(style="(.*?)"|style="(.*?)")
'
,
'
gi
'
);
return
body
.
replace
(
regEx
,
""
);
})
.
declareMethod
(
"
is_already_parsed
"
,
function
(
title
){
return
this
.
state
.
storage
.
all_loaded_docs
()
.
push
(
function
(
result
){
var
i
;
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
){
if
(
result
.
data
.
rows
[
i
].
id
===
title
)
return
true
;
}
return
false
;
});
});
})*/
}(
window
,
RSVP
,
rJS
,
jIO
));
search.js
View file @
a404e13f
...
...
@@ -60,7 +60,7 @@
promise_list
=
[],
i
;
for
(
i
=
0
;
i
<
gadget
.
state
.
to_load
.
length
;
i
++
){
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
_new
(
"
./test-files/
"
+
gadget
.
state
.
to_load
[
i
]));
}
RSVP
.
all
(
promise_list
);
})
...
...
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