Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Viewer 2 DHTML__Javascript__bootstrapping  

DHTML__Javascript__bootstrapping

Tali Rosca made this code to render the output of HTTP-In directly. Kelly Linden wrapped her magic into the build_url and build_response functions in the example below. This example renders a page that is around 3.5k bytes - well past the 1k limit of urls.
Pros:

* Navigation is much smoother and feels more natural
* Only limited by script memory

Cons:

* Links are extremely large: 296 bytes for a link to just the base http-in url.

Category: Viewer 2
By : Tali Rosca
Created: 2010-09-02 Edited: 2010-09-02
Worlds: Second Life

the Zip file

Download all files for DHTML__Javascript__bootstrapping
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. DHTML__Javascript__bootstrapping_1.lsl
1 string url; // Our base http-in url
2 integer r; // Used for uniqueness in PrimMedia urls
3 integer page; // The page number.
4
5 show(string html)
6 {
7 html += "<span " + (string)((++r) % 10) + "/>";
8
9 llSetPrimMediaParams(0, // Side to display the media on.
10 [PRIM_MEDIA_AUTO_PLAY,TRUE, // Show this page immediately
11 PRIM_MEDIA_CURRENT_URL,html, // The url if they hit 'home'
12 PRIM_MEDIA_HOME_URL,html, // The url currently showing
13 PRIM_MEDIA_HEIGHT_PIXELS,512, // Height/width of media texture will be
14 PRIM_MEDIA_WIDTH_PIXELS,512]); // rounded up to nearest power of 2.
15 }
16
17 // This creates a data: url that will render the output of the http-in url
18 // given.
19 string build_url(string url)
20 {
21 return "data:text/html,"
22 + llEscapeURL("<html><head><script src='" + url
23 + "' type='text/javascript'></script></head><body onload='init()'></body></html>");
24 }
25
26 // This wraps the html you want to display so that it will be shown from links
27 // made with build_url
28 string build_response(string body)
29 {
30 return "function init() {document.getElementsByTagName('body')[0].innerHTML='" + body + "';}";
31 }
32
33 default
34 {
36 {
38 }
39
40 http_request(key id, string method, string body)
41 {
42 if(method == URL_REQUEST_GRANTED)
43 {
44 url = body + "/";
45
46 show(build_url(url + "page" + (string)(page)));
47 }
48 else if(method == "GET")
49 {
50 string path = llGetHTTPHeader(id,"x-path-info");
51 string content = "<h1>path: " + path + "</h1>";
52 page = (integer)llGetSubString(path,5,5);
53 if(page > 0) content += "<a href=\"" + build_url(url + "page" + (string)(page - 1)) + "\">Previous</a> ";
54 if(page < 9) content += "<a href=\"" + build_url(url + "page" + (string)(page + 1)) + "\">Next</a><br>";
55 integer k;
56 for(;k<10;++k)
57 {
58 if(k == page)
59 content += "<br>Page " + (string)k;
60 else
61 content += "<br><a href=\"" + build_url(url + "page" + (string)(k)) + "\">Page " + (string)k + "</a>";
62 }
63 content += "<br><br>This page is " + (string)(llStringLength(build_response(content)) + 37) + " bytes long.";
64 llHTTPResponse(id,200,build_response(content));
65 }
66 }
67 }
68

Back to the Best Free Tools in Second Life and OpenSim.