| Forum Home | ||||
| Press F1 | ||||
| Thread ID: 94710 | 2008-11-09 02:55:00 | Sidebar gadget help | hueybot3000 (3646) | Press F1 |
| Post ID | Timestamp | Content | User | ||
| 718988 | 2008-11-09 02:55:00 | hey i use the sidebar gadget " SideLaunch " . its pretty simple but does what i want it to. only thing is that it resets itself to default settings on restart, it reads from the quicklaunch folder but you can change it to read from whatever folder of shortcuts you like, just doesnt stick to it can anyone suggest a change in the java below thatd lock the folder to C:\Quicklaunch <-- that being the folder i use for shortcuts, also make it so it doesnt round corners by default ------------------------------------------------------------------------ File 1 (settings.js) document.onreadystatechange = function() { if(document.readyState == " complete " ) { setDefaults(); $('reset').onclick = function() { $('path').value = shell.SpecialFolders( " Appdata " ) + " \\Microsoft\\Internet Explorer\\Quick Launch " ; } $('browse').onclick = function() { oFolder = shellApp.BrowseForFolder(0, " Set path containing your shortcuts " , 0); if (oFolder != null) { var objFolderItem = oFolder.self; $('path').value = objFolderItem.path; } } $('openFolder').onclick = function() { try { // Gadget code System.Shell.execute( " explorer.exe " , $('path').value); } catch(err) { alert( " Error while following Link: " +err.name + " - " + err.message)} } try { // Gadget code System.Gadget.onSettingsClosing = SettingsClosing; } catch(err) { alert(err) } } } function setDefaults() { // Round corners if(getSetting('roundCorners', doRoundCorners) == " True " ) { $('roundCorners').checked = true; } else { $('roundCorners').checked = false; } // QuickLaunch path $('path').value = getSetting('quickLaunch', quickLaunch); } function SettingsClosing(event) { if (event.closeAction == event.Action.commit) { System.Gadget.Settings.write( " roundCorners " , $('roundCorners').checked); System.Gadget.Settings.write( " quickLaunch " , $('path').value); } event.cancel = false; } ----------------------------------------------------------------------- File 2 (common.js) var shell = new ActiveXObject( " WScript.Shell " ); var shellApp = new ActiveXObject( " Shell.Application " ); var fso = new ActiveXObject( " Scripting.FileSystemObject " ); // Default configuration var quickLaunch = shell.SpecialFolders( " Appdata " ) + " \\Microsoft\\Internet Explorer\\Quick Launch " ; var doRoundCorners = " True " ; function getSetting(item, defaultval) { var setting = System.Gadget.Settings.readString(item); if(setting != " " ) { return setting; } else { return defaultval; } } function $(item) { return document.getElementById(item); } function absLeft(el) { return (el.offsetParent)? el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft; } function absTop(el) { return (el.offsetParent)? el.offsetTop+absTop(el.offsetParent) : el.offsetTop; } ---------------------------------------------------------------------- File 3 (sidelaunch.js) var li_height = 22; document.onreadystatechange = function() { if(document.readyState == " complete " ) { try { // Gadget code System.Gadget.settingsUI = " settings.html " ; System.Gadget.onSettingsClosed = SettingsClosed; } catch(err) {} init(); } } function init() { $('root').innerHTML = FileList(quickLaunch); $('root').innerHTML += FolderList(quickLaunch); roundCorners(); setGadgetHeight(); } function toggleSubmenu(handle, menu) { uls = $('root').getElementsByTagName('ul'); for(i=0;i<uls.length;i++) { if(menu != uls[i]) { uls[i].style.display = 'none'; } } if(menu.style.display == 'none') { menu.style.display = 'block'; } else { menu.style.display = 'none'; } if((absTop(menu) + menu.offsetHeight) > parseInt(document.getElementsByTagName('body')[0].style.height)) { menu.style.top = parseInt(document.getElementsByTagName('body')[0].style.height) - menu.offsetHeight + " px " ; } else { menu.style.top = absTop(handle) + " px " ; } } function setGadgetHeight() { items = $('root').childNodes.length; // root links + dirs /* uls = $('root').getElementsByTagName('ul'); for(i=0;i<uls.length;i++) { if(uls[i].style.display == " block " ) { items = items + uls[i].childNodes.length; } } */ document.getElementsByTagName('body')[0].style.setAttribute( " height " , li_height*items + " px " ); $('panel').style.setAttribute( " height " , li_height*items + " px " ); } function FolderList(foldersspec) { var f, fc, s; f = fso.GetFolder(foldersspec); fc = new Enumerator(f.SubFolders); s = " " ; for (; !fc.atEnd(); fc.moveNext()) { s += '<li class= " cat " onmouseover= " toggleSubmenu(this,this.firstChild.nextSibling) " onmouseout= " toggleSubmenu(this,this.firstChild.nextSibling) " ><a href= " " >'+ fso.GetBaseName(fc.item()) +'</a><ul style= " display:none " >'; s += FileList(fc.item()); s += '</ul></li>'; } return s; } function FileList(folderspec) { var f, i, fc, s; f = fso.GetFolder(folderspec); fc = new Enumerator(f.files); s = " " ; for(; !fc.atEnd(); fc.moveNext()) { // Only use links if(fso.GetExtensionName(fc.item()).toLowerCase() == 'lnk') { s += " <li> " s += '<a href= " # " onclick= " FollowLink(\''+ encodeURI(fc.item()) +'\') " >'; s += '<img class= " appicon " src= " gimage:///'+ getIconPath(fc.item()) +'?width=16&height=16 " />'; s += fso.GetBaseName(fc.item()) +'</a>'; s += " </li> " ; } } return s; } function getIconPath(fpath) { oLink = shell.CreateShortcut(fpath); tmpPath = oLink.TargetPath; theIconLocation = oLink.iconLocation; if((theIconLocation.length >= 2) && (theIconLocation.substr(theIconLocation.length - 2) == " ,0 " )) { tmpPath = theIconLocation.substr(0, (theIconLocation.length - 2)); if(tmpPath == " " ) { tmpPath = oLink.targetPath; } } return tmpPath; } function FollowLink(fpath) { fpath = decodeURI(fpath); if(fso.FileExists(fpath)) { try{ // Gadget code System.Shell.execute(fpath); event.returnValue = false; return false; } catch(err) { alert( " Error while following Link: " +err.name + " - " + err.message)} } } /* Design */ function roundCorners() { $('border').innerHTML = " " ; if(doRoundCorners == " True " ) { $('border').innerHTML += " <img src=\ " images/borderTopRight.png\ " style=\ " position:absolute;top:0;right:0;\ " /> " ; $('border').innerHTML += " <img src=\ " images/borderBottomRight.png\ " style=\ " position:absolute;bottom:0;right:0;\ " /> " ; } } function SettingsClosed(event) { // User hits OK on the settings page. if (event.closeAction == event.Action.commit) { doRoundCorners = getSetting('roundCorners', doRoundCorners); quickLaunch = getSetting('quickLaunch', quickLaunch); init(); } // User hits Cancel on the settings page. else if (event.closeAction == event.Action.cancel) { } } ---------------------------------------------------------------------- thanks to anyone who can help |
hueybot3000 (3646) | ||
| 1 | |||||