My KRL search annotation ruleset contains 4-5 rules that each do annotation based on the domain in the search results. I am getting good results, in that the annotations are pretty much when and where they should. However, as I look at the source code in the browser, each rule is inserting a div into the html whether any annotation should occur for that domain or not. There is nothing on visible the page to suggest it, but I don't want to add any unnecessary code and keep this light.
Is there a way to instruct those rules that do not annotate for a result to not place any code into the page? (btw - right now I'm using all local data - I will be doing a remote call later on after this is tested and realize that will solve this issue).
Two of my rules:
rule search_annotate_party is active {
select using "google.com|bing.com/search|search.yahoo.com/search" setting()
every {
emit <<
function annotate_party(toAnnotate, wrapper, data) {
if (data.domain == "www.mydomain.com" ) {
wrapper.append("<div style='border: 1px dashed orange'><a href='http://www.mydomain.com/search.do?query=some+product' target='_blank'><img src=https://dl.dropbox.com/u/3287029/product_image.png width='100%'></a></div>");
wrapper.show();
}
}
>>;
annotate:annotate("party") with
annotator = <| annotate_party |>;
}
}
rule search_annotate_jiffy is active {
select using "google.com|bing.com/search|search.yahoo.com/search" setting()
every {
emit <<
function annotate_jiffy(toAnnotate, wrapper, data) {
if (data.domain == "www.hisdomain.com" ) {
wrapper.append("<div style='border: 0px solid red'><img src=http://dl.dropbox.com/u/3287029/company_logo.jpg>");
wrapper.show();
}
}
>>;
annotate:annotate("jiffy") with
annotator = <| annotate_jiffy |>;
}
}