Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Mynij-test
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
Mynij
Mynij-test
Commits
4f5d5b13
Commit
4f5d5b13
authored
Jun 03, 2019
by
Alexandra Rogova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new model start
parent
387a207a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
175 additions
and
0 deletions
+175
-0
new_gadget_model.js
new_gadget_model.js
+136
-0
server_model_gadget.html
server_model_gadget.html
+0
-0
server_model_gadget.js
server_model_gadget.js
+39
-0
No files found.
new_gadget_model.js
0 → 100644
View file @
4f5d5b13
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80*/
/*global window, RSVP, rJS, jIO*/
(
function
(
window
,
RSVP
,
rJS
,
jIO
)
{
"
use strict
"
;
rJS
(
window
)
.
ready
(
function
(){
var
gadget
=
this
;
this
.
my_indexes
=
[];
var
index_storage
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
my_indexes
"
});
return
index_storage
.
allDocs
()
.
push
(
function
(
result
){
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
){
//CHECK THIS
promise_list
.
push
(
index_storage
.
get
(
result
[
i
].
id
));
}
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
result
){
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
result
.
length
;
i
+=
1
){
promise_list
.
push
(
gadget
.
_load_index
(
result
[
i
]));
}
return
RSVP
.
all
(
promise_list
);
});
})
.
declareMethod
(
"
_load_index
"
,
function
(
to_load
){
/*!!! DOES NOT WORK CHECK WHAT index_storage.get(index_id) RETURNS !!!*/
/*var raw_index,
index,
index_storage,
gadget = this;*/
/*index_storage = jIO.createJIO({
type :"indexeddb",
database :"my_indexes"
});*/
/*return index_storage.get(index_id)
.push(function(result){*/
var
raw_index
,
index
,
key
,
doc
;
index
=
elasticlunr
(
function
()
{
this
.
use
(
elasticlunr
.
fr
);
this
.
addField
(
'
title
'
);
this
.
addField
(
'
body
'
);
this
.
addField
(
'
link
'
);
this
.
setRef
(
'
id
'
);
//id = index.x."/a/b" where index = index name, x = substorage id, "/a/b" = item id in x
});
raw_index
=
JSON
.
parse
(
to_load
);
for
(
key
in
raw_index
.
documentStore
.
docs
){
doc
=
{
"
id
"
:
raw_index
.
documentStore
.
docs
[
key
].
id
,
"
title
"
:
raw_index
.
documentStore
.
docs
[
key
].
title
,
"
body
"
:
raw_index
.
documentStore
.
docs
[
key
].
body
,
"
link
"
:
raw_index
.
documentStore
.
docs
[
key
].
link
};
index
.
addDoc
(
doc
);
}
this
.
my_indexes
.
push
({
name
:
""
,
// get name,
index
:
index
});
//});
})
.
declareMethod
(
"
add_rss
"
,
function
(
index_name
,
link
){
//WIP needs proxy
})
.
declareMethod
(
"
remove_rss
"
,
function
(
index_name
,
something
){
//WIP needs working brain
})
.
declareMethod
(
"
_get_index
"
,
function
(
index_name
){
var
i
;
for
(
i
=
0
;
i
<
this
.
my_indexes
;
i
+=
1
){
if
(
this
.
my_indexes
[
i
].
name
===
index_name
)
return
this
.
my_indexes
[
i
];
}
return
null
;
})
.
declareMethod
(
"
search
"
,
function
(
index_name
,
key
){
return
this
.
_get_index
(
index_name
)
.
push
(
function
(
result
){
if
(
result
===
null
)
return
[];
else
return
result
.
search
(
key
);
});
})
.
declareMethod
(
"
my_indexes
"
,
function
(){
index_storage
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
my_indexes
"
});
return
index_storage
.
allDocs
()
.
push
(
function
(
result
){
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
){
promise_list
.
push
(
index_storage
.
get
(
result
.
data
.
rows
[
i
].
id
));
}
return
promise_list
;
})
.
push
(
function
(
result
){
var
i
,
info
=
[];
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
){
//CHECK
info
.
push
(
result
.
data
.
rows
[
i
]);
}
return
info
;
});
})
.
declareMethod
(
"
download_index
"
,
function
(
index_id
){
var
gadget
=
this
;
return
this
.
getDeclaredGadget
(
"
server
"
)
.
push
(
function
(
server
){
return
server
.
get
(
index_id
);
})
.
push
(
function
(
result
){
return
gadget
.
_load_index
(
result
);
});
});
}(
window
,
RSVP
,
rJS
,
jIO
));
\ No newline at end of file
server_model_gadget.html
0 → 100644
View file @
4f5d5b13
server_model_gadget.js
0 → 100644
View file @
4f5d5b13
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80*/
/*global window, RSVP, rJS, jIO*/
(
function
(
window
,
RSVP
,
rJS
,
jIO
)
{
"
use strict
"
;
rJS
(
window
)
.
delcareMethod
(
"
get_all_available_indexes
"
,
function
(){
var
all_indexes
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
all_indexes
"
});
return
all_indexes
.
allDocs
()
.
push
(
function
(
result
){
var
i
,
promise_list
=
[];
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
){
promise_list
.
push
(
all_indexes
.
get
(
result
.
data
.
rows
[
i
].
id
));
}
return
promise_list
;
})
.
push
(
function
(
result
){
var
i
,
info
=
[];
for
(
i
=
0
;
i
<
result
.
data
.
rows
.
length
;
i
+=
1
){
//CHECK
info
.
push
(
result
.
data
.
rows
[
i
]);
}
return
info
;
});
})
.
declareMethod
(
"
get
"
,
function
(
index_id
){
var
all_indexes
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
all_indexes
"
});
return
all_indexes
.
get
(
index_id
);
});
}(
window
,
RSVP
,
rJS
,
jIO
));
\ No newline at end of file
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