Created
December 22, 2010 05:32
-
-
Save edorcutt/751134 to your computer and use it in GitHub Desktop.
Demo Persistent Application Variables
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 a169x196 { | |
meta { | |
name "KRL_Scope_Safari_Application_Variables" | |
description << | |
Demo Persistent Application Variables | |
>> | |
author "Ed Orcutt" | |
logging on | |
} | |
dispatch { | |
domain "kynetx.aculis.net" | |
} | |
global { | |
SafariHeader = << | |
<div id="SafariHeader"> | |
KRL Scope Safari: Application Variables | |
<hr class="safarititlehr" /> | |
</div> | |
>>; | |
SafariContent = << | |
<div id="SafariContent"> | |
no content :( | |
</div> | |
>>; | |
SafariCurrentValue = << | |
Current Value: | |
<span id="SafariCurrentValue">no value yet</span> | |
<hr class="safarihr"/> | |
>>; | |
SafariSubmit = << | |
<form id="SafariSubmitForm" onsubmit="return false"> | |
<input id="SafariFormValue" | |
type="text" | |
name="SafariInputValue" | |
value="Enter a new value" /> | |
<input type="submit" value="Mutate"> | |
</form> | |
>>; | |
SafariClear = << | |
<form id="SafariClearForm" onsubmit="return false"> | |
<input type="submit" value="Clear"> | |
</form> | |
>>; | |
css << | |
.safarititlehr { | |
height:2px; | |
border-width:0; | |
background-color:white; | |
} | |
.safarihr { | |
height: 1px; | |
border-width: 0; | |
background-color: gray; | |
} | |
#SafariSubmitForm { | |
float: left; | |
} | |
#SafariCurrentValue { | |
font-weight: bold; | |
} | |
>> | |
} | |
rule Safari_Initialize { | |
select when pageview ".*" | |
pre { | |
SafariValue = app:safari_app || "Just Born!"; | |
} | |
{ | |
notify(SafariHeader, SafariContent) with | |
background_color = "#222" and | |
opacity = 1.0 and | |
width = "320px" and | |
sticky = true; | |
replace_inner("#SafariContent", SafariCurrentValue); | |
replace_inner("#SafariCurrentValue", SafariValue); | |
append("#SafariContent", SafariSubmit); | |
watch("#SafariSubmitForm", "submit"); | |
append("#SafariContent", SafariClear); | |
watch("#SafariClearForm", "submit"); | |
} | |
fired { | |
set app:safari_app SafariValue; | |
} | |
} | |
rule Safari_Respond_Submit { | |
select when web submit "#SafariSubmitForm" | |
pre { | |
newValue = page:param("SafariInputValue"); | |
} | |
{ | |
replace_inner("#SafariCurrentValue", newValue); | |
emit << | |
$K("input#SafariFormValue").val("Thanks, again?"); | |
>> | |
} | |
fired { | |
set app:safari_app newValue; | |
} | |
} | |
rule Safari_Respond_Clear { | |
select when web submit "#SafariClearForm" | |
{ | |
replace_inner("#SafariCurrentValue", "all clear"); | |
emit << | |
$K("input#SafariFormValue").val("Cleared!"); | |
>> | |
} | |
fired { | |
clear app:safari_app; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment