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 Form_handling_in_viewer_2  

Form_handling_in_viewer_2

The Limits

* 1024 bytes per...

Category: Viewer 2
By : Kelly Linden
Created: 2010-09-02 Edited: 2010-09-02
Worlds: Second Life

the Zip file

Download all files for Form_handling_in_viewer_2
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Form_handling_in_viewer_2_1.lsl
1 string html_base =
2 "<h1><form action='%url%' method='GET'>
3 Floating Text:<input type='text' name='text'><br>
4 <input type='submit' value='Set'>
5 </form></h1>";
6
7 string url;
8
9 integer r;
10 show(string html)
11 {
12 html = "data:text/html," + llEscapeURL(html) + "<span " + (string)((++r) % 10) + "/>";
13
14 llSetPrimMediaParams(0, // Side to display the media on.
15 [PRIM_MEDIA_AUTO_PLAY,TRUE, // Show this page immediately
16 PRIM_MEDIA_CURRENT_URL,html, // The url currently showing
17 PRIM_MEDIA_HOME_URL,html, // The url if they hit 'home'
18 PRIM_MEDIA_HEIGHT_PIXELS,512, // Height/width of media texture will be
19 PRIM_MEDIA_WIDTH_PIXELS,512]); // rounded up to nearest power of 2.
20 }
21
22 string replace_all(string src, string target, string replace)
23 {
24 return llDumpList2String(llParseString2List(src,[target],[]),replace);
25 }
26
27 string get_query(key id, string name)
28 {
29 string query = llGetHTTPHeader(id,"x-query-string");
30 query = replace_all(query,"+"," ");
31 query = llUnescapeURL(query);
32 list q = llParseString2List(query,["=","&",";"],[]);
33 integer i = llListFindList(q,[name]);
34 if(i != -1)
35 {
36 return llList2String(q,i+1);
37 }
38
39 return "";
40 }
41
42 default
43 {
45 {
47 }
48
49 http_request(key id, string method, string body)
50 {
51 if(method == URL_REQUEST_GRANTED)
52 {
53 url = body + "/";
54
55 show(replace_all(html_base,"%url%",url));
56 }
57 else if(method == "GET")
58 {
59 llSetText(get_query(id,"text"),<1,1,0>,1);
60 show(replace_all(html_base,"%url%",url));
61 llHTTPResponse(id,200,"Loading....");
62 }
63 }
64 }
65

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