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 @@
rJS(window)
.setState({
counter: 0,
model_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(){
return this.getDeclaredGadget("model");
})
.allowPublicAcquisition("get_counter", function(){
counter += 1;
return counter;
})
.ready(function(){
var model_gadget,
result_gadget;
console.log("ready !");
counter = 0;
var gadget = this;
return gadget.getDeclaredGadget("model")
.push(function(model){
......@@ -48,18 +56,13 @@
})
.onStateChange(function (modification_dict){
var gadget = this;
return new RSVP.Queue()
.push(function (){
gadget.state.parser_gadget.readFile("../rss-files/vivelessvt.rss");
})
.push (function (result) {
gadget.state.parser_gadget.readFile("../rss-files/italienfacile.rss");
})
.push (function (result) {}, function (err) {
console.warn(error);
throw(error);
});
var gadget = this,
promise_list = [],
i;
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]));
}
RSVP.all(promise_list);
})
.declareMethod("search", function (key){
......@@ -67,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()
......@@ -79,7 +82,7 @@
return gadget.state.result_gadget.addItem({
title : "No results found",
link : ""
});
}, "");
}
var i,
id,
......@@ -88,7 +91,6 @@
for (i = 0; i < result.data.rows.length; i+=1){
id = result.data.rows[i].id;
promise_list.push(gadget.state.model_gadget.get(id));
console.log(id);
}
return RSVP.all(promise_list);
......@@ -97,7 +99,7 @@
var j,
promise_list = [];
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);
});
......
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