Created
October 10, 2010 15:26
-
-
Save edorcutt/619320 to your computer and use it in GitHub Desktop.
Kynetx Event Annotation from Kynetx Annotate V 2.0 http://docs.kynetx.com/docs/NEW_Search_Annotation_V2.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruleset a169x133 { | |
meta { | |
name "Kynetx_Annotate_Event" | |
description << | |
Kynetx Event Annotation | |
from Kynetx Annotate V 2.0 | |
http://k-docs.s3.amazonaws.com/Annotate%20V%202.pdf | |
>> | |
author "Ed Orcutt" | |
logging on | |
} | |
dispatch { | |
domain "google.com" | |
domain "bing.com" | |
domain "yahoo.com" | |
} | |
global {} | |
rule search_annotate_rule is active { | |
select using "google.com|bing.com/search|search.yahoo.com/search" setting() | |
every { | |
emit << | |
// This callback function will be passed | |
// | |
// toAnnotate - Item on screen that is being annotated | |
// wrapper - A wrapper div element that can be altered | |
// with the actual annotation. | |
// data - Data returned from remote service call. | |
// needs to be annotated on page. | |
function annotate_rentalcars(toAnnotate, wrapper, data) { | |
// In this case the data parameter is the data provided by | |
// the remote service. For our example it might have a | |
// discount amount we want to display. | |
wrapper.append("<div style='border: 3px solid red'>" + data.discount + "</div>"); | |
// All wrappers are hidden by default so request that | |
// it be shown now. | |
wrapper.show(); | |
} | |
>>; | |
// Request annotation of the current page. We name this specific | |
// annotation rentals and provide the annotate_rentalcars function | |
// as the javascript function that will add the annotation to the | |
// page. Also we tell annotation we want a remote event for | |
// annotation | |
annotate:annotate("rentals") with | |
annotator = <| annotate_rentalcars |> and | |
remote = "event"; | |
} | |
} | |
// This rule looks for the webevent annotate_search and executes only | |
// when the name is rentals | |
rule annotate_rentals is active { | |
select when web annotate_search name "rentals" setting () | |
foreach annotate_data setting (mykey,myvalue) | |
pre { | |
// This parameter is used by the annotation system to | |
// know which annotator should work on the resulting data | |
annotate_instance = page:env("annotate_instance"); | |
// This is the data collected by the annotation framework. | |
// This is in the same format as the remote annotation. | |
annotate_data = page:env("annotatedata").as("json"); | |
} | |
annotate:add_annotation_data(mykey,{"discount":"Discount of 10%" }, annotate_instance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment