Commit 22007610 authored by Alexandra Rogova's avatar Alexandra Rogova

list of rss files to read in search.js

parent fd43ee53
...@@ -3,27 +3,35 @@ ...@@ -3,27 +3,35 @@
rJS(window) rJS(window)
.setState({ .setState({
counter: 0,
model_gadget : null, model_gadget : null,
parser_gadget : null, parser_gadget : null,
result_gadget : null result_gadget : null,
to_load: [
"allemandfacile.rss",
"anglaisfacile.rss",
"duolingo.rss",
"espagnolfacile.rss",
"francaisfacile.rss",
"hgeo_college.rss",
"histoirencours.rss",
"italienfacile.rss",
"lewebpedagogique-lapasserelle.rss",
"mathematiquesfacile.rss",
"physique_chimie_college.rss",
"technologieaucollege27.rss",
"vivelessvt.rss"
]
}) })
.allowPublicAcquisition("get_model", function(){ .allowPublicAcquisition("get_model", function(){
return this.getDeclaredGadget("model"); return this.getDeclaredGadget("model");
}) })
.allowPublicAcquisition("get_counter", function(){
counter += 1;
return counter;
})
.ready(function(){ .ready(function(){
var model_gadget, var model_gadget,
result_gadget; result_gadget;
console.log("ready !"); console.log("ready !");
counter = 0;
var gadget = this; var gadget = this;
return gadget.getDeclaredGadget("model") return gadget.getDeclaredGadget("model")
.push(function(model){ .push(function(model){
...@@ -48,18 +56,13 @@ ...@@ -48,18 +56,13 @@
}) })
.onStateChange(function (modification_dict){ .onStateChange(function (modification_dict){
var gadget = this; var gadget = this,
return new RSVP.Queue() promise_list = [],
.push(function (){ i;
gadget.state.parser_gadget.readFile("../rss-files/vivelessvt.rss"); for (i = 0; i < gadget.state.to_load.length; i++){
}) promise_list.push(gadget.state.parser_gadget.readFile("../rss-files/" + gadget.state.to_load[i]));
.push (function (result) { }
gadget.state.parser_gadget.readFile("../rss-files/italienfacile.rss"); RSVP.all(promise_list);
})
.push (function (result) {}, function (err) {
console.warn(error);
throw(error);
});
}) })
.declareMethod("search", function (key){ .declareMethod("search", function (key){
...@@ -67,7 +70,7 @@ ...@@ -67,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()
...@@ -79,7 +82,7 @@ ...@@ -79,7 +82,7 @@
return gadget.state.result_gadget.addItem({ return gadget.state.result_gadget.addItem({
title : "No results found", title : "No results found",
link : "" link : ""
}); }, "");
} }
var i, var i,
id, id,
...@@ -88,7 +91,6 @@ ...@@ -88,7 +91,6 @@
for (i = 0; i < result.data.rows.length; i+=1){ for (i = 0; i < result.data.rows.length; i+=1){
id = result.data.rows[i].id; id = result.data.rows[i].id;
promise_list.push(gadget.state.model_gadget.get(id)); promise_list.push(gadget.state.model_gadget.get(id));
console.log(id);
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
...@@ -97,7 +99,7 @@ ...@@ -97,7 +99,7 @@
var j, var j,
promise_list = []; promise_list = [];
for (j = 0; j < result_list.length; j+=1){ for (j = 0; j < result_list.length; j+=1){
promise_list.push(gadget.state.result_gadget.addItem(result_list[j])); promise_list.push(gadget.state.result_gadget.addItem(result_list[j], key));
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment