Commit 22007610 authored by Alexandra Rogova's avatar Alexandra Rogova

list of rss files to read in search.js

parent fd43ee53
(function (window, document, rJS, RSVP) { (function (window, document, rJS, RSVP) {
var gadget; var gadget;
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",
.allowPublicAcquisition("get_model", function(){ "duolingo.rss",
return this.getDeclaredGadget("model"); "espagnolfacile.rss",
}) "francaisfacile.rss",
"hgeo_college.rss",
.allowPublicAcquisition("get_counter", function(){ "histoirencours.rss",
counter += 1; "italienfacile.rss",
return counter; "lewebpedagogique-lapasserelle.rss",
}) "mathematiquesfacile.rss",
"physique_chimie_college.rss",
.ready(function(){ "technologieaucollege27.rss",
var model_gadget, "vivelessvt.rss"
result_gadget; ]
})
console.log("ready !");
counter = 0; .allowPublicAcquisition("get_model", function(){
var gadget = this; return this.getDeclaredGadget("model");
return gadget.getDeclaredGadget("model") })
.push(function(model){
model_gadget = model; .ready(function(){
}) var model_gadget,
.push(function(){ result_gadget;
return gadget.getDeclaredGadget("result");
}) console.log("ready !");
.push(function(result){ var gadget = this;
result_gadget = result; return gadget.getDeclaredGadget("model")
}) .push(function(model){
.push(function(){ model_gadget = model;
return gadget.getDeclaredGadget("parser"); })
}) .push(function(){
.push(function(result){ return gadget.getDeclaredGadget("result");
return gadget.changeState({ })
model_gadget : model_gadget, .push(function(result){
parser_gadget : result, result_gadget = result;
result_gadget : result_gadget })
}); .push(function(){
}); return gadget.getDeclaredGadget("parser");
}) })
.push(function(result){
.onStateChange(function (modification_dict){ return gadget.changeState({
var gadget = this; model_gadget : model_gadget,
return new RSVP.Queue() parser_gadget : result,
.push(function (){ result_gadget : result_gadget
gadget.state.parser_gadget.readFile("../rss-files/vivelessvt.rss"); });
}) });
.push (function (result) { })
gadget.state.parser_gadget.readFile("../rss-files/italienfacile.rss");
}) .onStateChange(function (modification_dict){
.push (function (result) {}, function (err) { var gadget = this,
console.warn(error); promise_list = [],
throw(error); 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]));
}
.declareMethod("search", function (key){ RSVP.all(promise_list);
var gadget = this, })
options;
.declareMethod("search", function (key){
options = { var gadget = this,
query:'(title:"% '+key+' %") OR (title:"'+key+' %")OR (body:"% '+key+' %")' options;
};
options = {
return gadget.state.result_gadget.clear() query:'(title:"% '+key+' %") OR (title: key + "%") OR (body:"% '+key+' %")'
.push(function(){ };
return gadget.state.model_gadget.search(options);
}) return gadget.state.result_gadget.clear()
.push (function(result){ .push(function(){
if (result.data.rows.length === 0){ return gadget.state.model_gadget.search(options);
return gadget.state.result_gadget.addItem({ })
title : "No results found", .push (function(result){
link : "" if (result.data.rows.length === 0){
}); return gadget.state.result_gadget.addItem({
} title : "No results found",
var i, link : ""
id, }, "");
promise_list = []; }
var i,
for (i = 0; i < result.data.rows.length; i+=1){ id,
id = result.data.rows[i].id; promise_list = [];
promise_list.push(gadget.state.model_gadget.get(id));
console.log(id); 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));
return RSVP.all(promise_list); }
})
.push(function(result_list){ return RSVP.all(promise_list);
var j, })
promise_list = []; .push(function(result_list){
for (j = 0; j < result_list.length; j+=1){ var j,
promise_list.push(gadget.state.result_gadget.addItem(result_list[j])); promise_list = [];
} for (j = 0; j < result_list.length; j+=1){
return RSVP.all(promise_list); promise_list.push(gadget.state.result_gadget.addItem(result_list[j], key));
}); }
}) return RSVP.all(promise_list);
});
.onEvent("submit", function(event){ })
this.search(event.target.elements[0].value);
}); .onEvent("submit", function(event){
this.search(event.target.elements[0].value);
});
}(window, document, rJS, RSVP)); }(window, document, rJS, RSVP));
\ No newline at end of file
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