Last active
August 29, 2015 13:56
-
-
Save trevordixon/8846363 to your computer and use it in GitHub Desktop.
Hello World KRL
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 HelloWorldApp { | |
rule Excercise1 is active { | |
select when pageview ".*" | |
{ | |
notify("Hello World", "This is a sample rule.") with sticky = true; | |
notify("Another One", "Notification 2.") with sticky = true; | |
} | |
} | |
rule Exercise4 is active { | |
select when pageview ".*" | |
pre { | |
qs = page:url("query"); | |
name = qs.extract(re/name=([^&]*)/); | |
name = (name[0] neq "") => name[0] | "Monkey"; | |
} | |
notify("Query string", "Hello " + name) with sticky = true; | |
} | |
rule Excercise6 is active { | |
select when pageview ".*" | |
pre { | |
qs = page:url("query").split(re/&/); | |
reset = qs.any(function(q) { q eq "clear" }); | |
} | |
if reset then notify("Reset count", "Count reset") | |
fired { | |
clear ent:count | |
} | |
} | |
rule Excercise5 is active { | |
select when pageview ".*" | |
if ent:count <= 4 then | |
notify("Only 5 times", "Count: " + ent:count) with sticky = true; | |
always { | |
ent:count += 1 from 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment