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 Javascript_boot_strapping_method  

Javascript_boot_strapping_method

Javascript_boot_strapping_method

Category: Viewer 2
By : Vegas Silverweb
Created: 2010-09-02 Edited: 2010-09-02
Worlds: Second Life

the Zip file

Download all files for Javascript_boot_strapping_method
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Javascript_boot_strapping_method_1.lsl
1 string URL;
2
3 string get(string page)
4 {
5 if(page == "index")
6 {
7 return "<h1>Index</h1>This is the index page.<br><br><a href='page1.html'>Link to page 1</a>";
8 }
9 else if(page == "page1")
10 {
11 return "<h1>Page 1</h1>This is page 1!.<br><br><a href ='index.html'>Link to the index page.</a>";
12 }
13 else return "Unknown page.";
14 }
15
16 string serve(string page)
17 {
18 return "document.write(atob('"+llStringToBase64(get(page))+"'));";
19 }
20
21 integer R;
22 load(string page)
23 {
24 string content="data:text/html;base64,"
25 +llStringToBase64("<html><head><base href='"+URL+"/'></head><body>"+
26 "<script src='"+page+".js' type='text/javascript'>"+
27 "</script><span r='"+(string)(++R%10)+"</body></html>");
28
29 llSetPrimMediaParams(0,[
30 PRIM_MEDIA_CURRENT_URL,content,
31 PRIM_MEDIA_HOME_URL,content,
32 PRIM_MEDIA_AUTO_ZOOM,FALSE,
33 PRIM_MEDIA_FIRST_CLICK_INTERACT,TRUE,
34 PRIM_MEDIA_PERMS_INTERACT,PRIM_MEDIA_PERM_ANYONE,
35 PRIM_MEDIA_PERMS_CONTROL,PRIM_MEDIA_PERM_NONE,
36 PRIM_MEDIA_AUTO_PLAY,TRUE
37 ]);
38 }
39
40 default
41 {
43 {
45 }
46
47 http_request(key id, string method, string body)
48 {
49 if(method == URL_REQUEST_GRANTED)
50 {
51 URL = body;
52 load("index");
53 }
54 else if(method == URL_REQUEST_DENIED)
55 {
56 llOwnerSay("Unable to get url!");
57 }
58 else if(method == "GET")
59 {
60 string path_raw = llGetHTTPHeader(id,"x-path-info");
61 if(path_raw == "")
62 {
63 // No path, assume index.html
64 path_raw = "/index.html";
65 }
66
67 list path = llParseString2List(llGetSubString(path_raw,1,-1),["."],[]);
68 string page = llList2String(path,0);
69 string type = llList2String(path,1);
70
71 if(type == "js")
72 {
73 llHTTPResponse(id,200,serve(page));
74 }
75 else if(type == "html")
76 {
77 llHTTPResponse(id,100,"");
78 load(page);
79 }
80 }
81 }
82 }
83

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