krl

Assigning actions to a variable

≯℡__Kan透↙ 提交于 2020-01-16 05:35:08
问题 In answering Aaron's recent question, I'd like to do something like the following: rule first_rule { select when pageview "exampley.com/\?name=(.*)" setting (username) pre { isjoe = username eq "joe"; myaction = defaction() { thisaction = isjoe => notify("Hello, World", "Hi there, Joe!") | noop(); thisaction(); }; } { notify("Will it work?", "Methinks you are #{username}"); myaction(); } } However, the defaction never seems to work. It doesn't like that I'm trying to assign an action to a

ternary in postlude?

拈花ヽ惹草 提交于 2019-12-24 10:35:31
问题 Can I do ternary in the postlude(s) the same way that I do them int he prelude? In other words have it fire off different calls depending on the say something was evaluated in the prelude? 回答1: Yes. You can include a guard condition on a postlude expression. This works for both explicit event raising and persistant variable modification. The expression following if can be any valid expression, including functions. Example: fired { raise explicit event "foo" if cheese == 5; } 来源: https:/

Kynetx app not working when installed via KBX extension on Chrome

柔情痞子 提交于 2019-12-20 02:34:07
问题 My app is loading an external javascript file with jQuery.getScript() . When I use the bookmarklet or an extension to start the app everything works fine. When the app is installed through KBX though inside Chrome with the KBX extension the included functions inside the javascript file are not accessible in the callback anymore and I get : Uncaught ReferenceError: myfunc is not defined . Is there any trick to get access to the included functions? Bookmarklet : javascript:(function(){var d

KRL RSS parser: Handle encoding issues?

扶醉桌前 提交于 2019-12-12 16:56:25
问题 I'm importing an RSS feed from Tumblr into a Kynetx app. It appears that the RSS feed has some encoding issues, as apostrophes appear like this: The feed (which you can find here) claims to be encoded in UTF-8. Is there a way to specify the encoding or else replace those characters with regular apostrophes? 回答1: While not optimal, you could try to catch these encodings and replace them with the UTF-8 standard: newstring = oldstring.replace(re/’/\'/); This appears to be a case of a service

Using jsonPath looking for a string

谁说我不能喝 提交于 2019-12-10 16:08:25
问题 I'm trying to use jsonPath and the pick function to determine if a rule needs to run or not based on the current domain. A simplified version of what I'm doing is here: global { dataset shopscotchMerchants <- "https://s3.amazonaws.com/app-files/dev/merchantJson.json" cachable for 2 seconds } rule checkdataset is active { select when pageview ".*" setting () pre { merchantData = shopscotchMerchants.pick("$.merchants[?(@.merchant=='Telefora')]"); } emit <| console.log(merchantData); |> } The

Kynetx app not working when installed via KBX extension on Chrome

给你一囗甜甜゛ 提交于 2019-12-01 23:05:50
My app is loading an external javascript file with jQuery.getScript() . When I use the bookmarklet or an extension to start the app everything works fine. When the app is installed through KBX though inside Chrome with the KBX extension the included functions inside the javascript file are not accessible in the callback anymore and I get : Uncaught ReferenceError: myfunc is not defined . Is there any trick to get access to the included functions? Bookmarklet : javascript:(function(){var d=document;var s=d.createElement('script');s.text="KOBJ_config={'rids':['a1135x30']};";d.body.appendChild(s)