Commit 677c64a2 authored by Alexandra Rogova's avatar Alexandra Rogova

test : remove styling in HTML while parsing

parent a86a462d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
(function(window, RSVP, rJS, jIO) { (function(window, RSVP, rJS, jIO) {
"use strict"; "use strict";
rJS(window) rJS(window)
.declareAcquiredMethod("get_model", "get_model") .declareAcquiredMethod("get_model", "get_model")
.declareMethod("read_file", function(link) { .declareMethod("read_file", function(link) {
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
xmlhttp.send(); xmlhttp.send();
}); });
}) })
.declareMethod("parse", function(local_cur_text, storage) { .declareMethod("parse", function(local_cur_text, storage) {
var title_start = local_cur_text.indexOf("<title>") + 7, var title_start = local_cur_text.indexOf("<title>") + 7,
title_end = local_cur_text.indexOf("</title>"), title_end = local_cur_text.indexOf("</title>"),
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
link_end = local_cur_text.indexOf("</link>"), link_end = local_cur_text.indexOf("</link>"),
body_start = local_cur_text.indexOf("<description>"), body_start = local_cur_text.indexOf("<description>"),
body_end = local_cur_text.indexOf("</description>") + 14; body_end = local_cur_text.indexOf("</description>") + 14;
return this.parse_body(local_cur_text.slice(body_start, body_end)) return this.remove_css(local_cur_text.slice(body_start, body_end))
.push (function(result){ .push (function(result){
return storage.put({ return storage.put({
"title": local_cur_text.slice(title_start, title_end), "title": local_cur_text.slice(title_start, title_end),
...@@ -56,19 +56,28 @@ ...@@ -56,19 +56,28 @@
}); });
}); });
}) })
.declareMethod("parse_body", function(body){ .declareMethod("remove_css", function(body){
/*var before, var regEx,
after; result;
while (body.indexOf("&lt;span style") > -1){ regEx = new RegExp('<style.*/>');
before = body.slice(0, body.indexOf("&lt;span style"));
after = body.slice(body.indexOf("&quot;&gt"), body.length -1); do {
body = before + after; result = regEx.exec(body);
} body_before = body.slice(0, result.index);
console.log(body);*/ body_after = body.slice(result.index+result[0].length+1);
return body; body = body_before+body_after;
} while (result !== null);
regEx = new RegExp('(<span style=.*>|&lt;span style.*&quot;&gt)');
do {
result = regEx.exec(body);
body_before = body.slice(0, result.index);
body_after = body.slice(result.index+result[0].length+1);
body = body_before+'<span>'+body_after;
} while (result !== null);
}) })
.declareMethod("is_already_parsed", function(storage, title){ .declareMethod("is_already_parsed", function(storage, title){
return storage.all_loaded_docs() return storage.all_loaded_docs()
.push(function (result){ .push(function (result){
...@@ -79,5 +88,5 @@ ...@@ -79,5 +88,5 @@
return false; return false;
}) })
}); });
}(window, RSVP, rJS, jIO)); }(window, RSVP, rJS, jIO));
\ 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