By Rolig Loon
- https://d1yjxggot69855.cloudfront.net/skins/monobook/bullet.gif); ">
- Reads URLs and labels from a user-created notecard
* Each card may hold up to 21 URLs. * User may place an unlimited number of notecards in contents. User may advance to the next card by selecting that choice from a dialog button.
- https://d1yjxggot69855.cloudfront.net/skins/monobook/bullet.gif); ">
- Generates a dialog box with button labels from the notecard
- User selects URL from a dialog button to open the in-world browser and navigate to the web site
NOTE: You cannot create or edit a notecard with a script in LSL, so you must so that operation manually.
You may either create a notecard and then drop it in your HUD's contents, or edit an existing card by selecting the HUD in Edit and then Opening a card that is already in contents.
Sample Notecard
# Sample notecard for the "Bookmark URLs" HUD # Any blank line or a line starting with "#" is ignored. You cannot write to a notecard with a script in SL, so the only # way to store bookmarks is to add them to this card manually. Yes, it's annoying, but it's not difficult, especially # if you cut and paste the URL. # Each line on this card starts with a tag for a bookmark, followed by a "|" symbol, and then by the URL itself. # Only about 12 characters of the tag will fit on a dialog button. Extra characters will not be displayed. # A tag longer than 24 characters will generate an error message. # Here are some sample bookmarks Second Life | http://secondlife.com SL Toolbox | http://wiki.secondlife.com/wiki/Basic_Resource_Toolbox G Scholar | http://scholar.google.com/ Babelfish | http://babelfish.yahoo.com/ SLLVR wiki | http://sites.google.com/site/sllvrwiki/index AVL Catalog | http://sixsunflowers.wiki.zoho.com/ NY Times | http://www.nytimes.com/ Wikipedia | http://wikipedia.org/ SLED resources | http://simteach.com/sled/db/ SimTeach | http://www.simteach.com/wiki/index.php?title=Second_Life_Education_Wiki Natalia | http://www.mermaiddiaries.com/2006/11/build.html Windlight | http://secondsoigne.wordpress.com/2008/04/10/optimising-windlight-for-avatars-20/? LSL Portal |http://wiki.secondlife.com/wiki/LSL_Portal LSL Wiki | http://lslwiki.net/lslwiki/wakka.php?wakka=HomePage # You may store up to 21 bookmarks on a single card. When you have collected more than 21 bookmarks, start a new notecard. # You may put as many notecards in the HUD's inventory as you wish. The HUD will load the next notecard in inventory # when you select the "New Card?" button from the dialog menu. # Suggestion: You may want to use this multi-card feature as a way to organize your bookmarks by using each notecard # as a separate "folder".
Script
// Bookmark URLs -- Rolig Loon -- January 2010 // // Controls a HUD in which the user can store and access notecards containing bookmarked URLs. // On touch, a dialog box offers the user up to 21 bookmarks and the option to advance to another card in Contents. // Selecting a bookmark opens it in the user's default browser. // Free to copy, use, modify, distribute, or sell, with attribution. Be nice, please. // (C)2010 (CC-BY) [ http://creativecommons.org/licenses/by/3.0 ] // Rolig Loon [ https://wiki.secondlife.com/wiki/User:Rolig_Loon ] // All usages must contain a plain text copy of the previous 2 lines. list MENU1 = []; list MENU2 = []; list Choice = []; list URLs = []; integer listener; integer MENU_CHANNEL = 1000; key user; string gName; key gQueryID; integer gLine; integer Lines; integer cardNo = 0; integer Reading = FALSE; Dialog(key id, list menu) { llListenRemove(listener); listener = llListen(MENU_CHANNEL, "", "", ""); llDialog(id, "Select one bookmark below: ", menu, MENU_CHANNEL); } ResetLists() { Choice = []; URLs = []; Lines = 0; gLine = 0; gName = llGetInventoryName(INVENTORY_NOTECARD,cardNo); llListenRemove(listener); } BuildMenu() { integer i = 0; MENU1 = []; MENU2 = []; if (Lines <= 11) { for (; i < Lines; ++i) { MENU1 += llList2String(Choice,i); } for (i=0;i21) { Lines = 21; } for (; i < Lines; ++i) { MENU2 += llList2String(Choice,i); } MENU1 += ">>"; for (i=0;i >") { Dialog(id, MENU2); } else if (message == "<<") { Dialog(id, MENU1); } else if (message == "New Card?") { ++ cardNo; if(llGetInventoryNumber(INVENTORY_NOTECARD) == cardNo) { llOwnerSay("You have sampled all notecards in inventory. Returning to card #1."); cardNo = 0; } ResetLists(); state reading ; } else { integer URLNum = llListFindList(Choice,[message]); if (URLNum != -1) { string theURL = llList2String(URLs,URLNum); llLoadURL(id,"This is the web page you bookmarked as \""+ message + "\".", theURL); } else { llOwnerSay("No bookmarked URL found with the label \"" + message +"\"."); } } } } changed (integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } } state reading { on_rez(integer num) { llResetScript(); } state_entry() { Reading = TRUE ; gQueryID = llGetNotecardLine(gName,gLine); } dataserver(key query_id, string data) { if (query_id == gQueryID) { if(data != EOF) { if ( llGetSubString(data, 0, 0) != "#" && llStringTrim(data, STRING_TRIM) != "" ) { Choice += llStringTrim(llGetSubString(data,0,llSubStringIndex(data,"|")-1),STRING_TRIM); URLs += llStringTrim(llGetSubString(data,llSubStringIndex( data,"|")+1,-1),STRING_TRIM); ++Lines; } ++gLine; gQueryID = llGetNotecardLine(gName, gLine); } else { state default ; } } } changed (integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } }