Created
November 20, 2010 02:46
-
-
Save MikeGrace/707561 to your computer and use it in GitHub Desktop.
Process client side array in KRL raised to Kynetx app
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 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