Skip to content

Instantly share code, notes, and snippets.

@MikeGrace
Created November 20, 2010 02:46
Show Gist options
  • Save MikeGrace/707561 to your computer and use it in GitHub Desktop.
Save MikeGrace/707561 to your computer and use it in GitHub Desktop.
Process client side array in KRL raised to Kynetx app
ruleset a60x426 {
meta {
name "client-side-array-to-server"
description <<
client-side-array-to-server
>>
author "Mike Grace"
logging on
}
rule get_tags_on_page {
select when pageview "process-client-side-array-in-krl-raised-to-kynetx-app"
{
emit <|
// get text of each tag into array
var tags = [];
$K(".tagged a").each(function(index, element) {
tags[index] = $K(element).text();
});
// convert array into string and add
// comma to end to facilitate processing csv
tags = tags + ",";
// raise event to server side KRL
app = KOBJ.get_application("a60x426");
app.raise_event("process_tags_from_page", {"pageTags":tags});
|>;
}
}
rule process_tags_from_page {
select when web process_tags_from_page or explicit process_tags_from_page
pre {
tags = event:param("pageTags");
tag = tags.replace(re/(.*?),.*/,"$1");
remainingTags = tags.replace(re/.*?,(.*)/,"$1");
}
if ((tag neq "")) then {
notify("Tag: #{tag}"," ") with sticky = true;
}
fired {
raise explicit event process_tags_from_page
with pageTags = remainingTags;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment