Scriptonite Updates

20250711

Everything mentioned in the original gemlog still applies and works as advertised. The goal is to remain backwards compatible as new features are added.

Original Gemlog

Anyway, there are a few new features worth documenting.

URL Parameters

You can now set the prompt messages in the Scriptonite url. You do this by adding a colon to the variable name followed by url-encoded prompt text.

/scriptonite/codepage;first:Enter%20your%20first%20name

As values are entered by the user, the corresponding prompt text is removed from the url. This makes for a smaller, less cluttered link. Parameters can also be supplied in any order.

Here's a Scriptonite page to help with url encoding:

UrlEncoder

Scriptonite Variables

There are two new variables that can be accessed from scripts. SCRIPT_URL and CERT_HASH. SCRIPT_URL contains the complete url used to load the current page. This can make it easier to generate links in some situations (see updated examples below). CERT_HASH is the client certificate hash or null if there is no cert.

Local Storage

Instead of jamming state into a url parameter, it's now possible to store data on the server when using a client certificate. If Scriptonite detects a client cert, it sets the CERT_HASH variable and adds two functions to the JavaScript context: saveData(String) and readData().

if(CERT_HASH == null){
    print("This code block requires a client certificate");
}else {
    // create a js object
    const user = { name: "Dude", age: 48, skills: ["bowling", "abiding"] };
    // you can add to it
    user.location = "California";
    // save the data
    saveData(JSON.stringify(user));
}

This example converts a js object into a string and saves it on the server. To access the data later, even in another code block or a different page using the same cert, do this:

var user = JSON.parse(readData());
print(user.name);

You don't have to use js objects. You can format the data however you like as long as it's a string. Scriptonite will throw an error if you try to save a number, for example. There's also a reasonable size limit on the size of the string.

Updated Examples

Emoji Clock has been updated to show prompt text and the use of SCRIPT_URL.

Clocks Code
Scriptonized
Auto-prompt for locale but let code ask for timezone

Storage demonstrates how to read and save data on the server.

Storage Code
Server Storage (Requires Client Certificate)

URLEncoder is a simple utility for generating url encoded strings.

URLEncoder Code
Scriptonized

Pick A Number has been updated to use a descriptive prompt.

Pick A Number Code
Game