WINAMP.COM | Forums > Skinning and Design > Modern Skins > Walkthrough: Allowing users to select a file through a File Open dialog |
Last Thread
Next Thread
|
| Author |
|
|
rohan_pwln Major Dude
Registered: Aug 2002 |
Walkthrough: Allowing users to select a file through a File Open dialog
Walkthrough: Allowing users to select a file through a File Open dialog code: The browser object is quite clear. As for the two text object holders, 'dummyaddholder' is added to get the store the skin path somewhere which we can use later. The 'filename' text object is the object to which we will output the file path we recieve. Part 3: The HTML+JS+CSS page This is the most important part of it. This HTML page will present a file upload box which can will return uss the path of the file selected. Code for fselect.html code: In this file, look at the <input> object. It's attribute says onchange="java script:checkfile()". Hence whenever the content of the <input type="file"> changes, the JavaScript checkfile() function will be executed. As you can see we have defined a checkfile() function which first gets the path of the file using "document.getElementById('fselect').value" and then it appends the file name to a dummy HTML file called fseldum.html. So, if you actually selected a file called 'c:/personal/photograph.jpg', the page will be redirected(using document.location) to: 'fsledum.html?add=(__c:/personal/photograph.jpg'. As we have added the file name to the query string, the page will load without giving any error. The fseldum.html file may be empty or just create <html></html> tags for the sake of it. As for the CSS there, I set the margin to -149px so that the textline of the <input type="file"> object is hidden and only the "Browse" button is visible. Part 3: The MAKI file Now, we come to the interface between the browser and the winamp skin. Here's the code for fselect.m: code: It's quite simple. I make a browser object and locate it from the skin. Most important here is the fselect.onDocumentComplete() event. It is fired when the page finishes loading. It gives a parameter, which isthe URL at which the browser currently is. In our case it must be something like "file:///C:\program files\winamp\skins\myskin\fseldum.html?add={__c:/personal/photograph.jpg". What we do is parse that string. It is done by first getting the position of the string, then finding the starting position of the address(int starting) and by finding the length of the filepath in that whole string(int length). Then using strmid, we parse out the filename into a string called 'floc'. This string can be used as you like for various purposes. Here, I navigate the browser to the fselect.html page as and when the script is loaded. You can do that anytime you wish. I hope this helps you. Bye ![]() -rohan __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
I'll work out an wal-xui-interface for easy implementation in skins __________________ |
||
|
|
|
Michgelsen Major Dude
Registered: Oct 2003 |
Good addition for the maki cheats thread! __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
i started working right now __________________ |
||
|
|
|
rohan_pwln Major Dude
Registered: Aug 2002 |
thanks a lot everybody... __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
is there a way to 'click' on the input object via JS?, so i don't need to click the button and the popup appears on site loading? this might be usefull to create a wasabi button wich will load the html and with it the popup appears! __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
fileselect example skin
here is a little example skin with an full skinned xui object!
__________________ |
||
|
|
|
Michgelsen Major Dude
Registered: Oct 2003 |
Martin, don't post it yet, I found a little typo in interface.xml. In line 17, there's sysrehion="1", which should be sysregion="1" I think. __________________ |
||
|
|
|
rohan_pwln Major Dude
Registered: Aug 2002 |
thanks a lot martin for that. __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
no prob! __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
new Version
fixed all bugs mentioned
__________________ |
||
|
|
|
SLoB Major Dude
Registered: Jul 2003 |
cool stuff martin __________________ |
||
|
|
|
Michgelsen Major Dude
Registered: Oct 2003 |
What was that about? The html/javascript as .maki? __________________ |
||
|
|
|
SLoB Major Dude
Registered: Jul 2003 |
yep, used in this instance is more of a security issue than the cover art unless its allowed as common practice i can see this being squashed, afaik winamp wont allow skins to be submitted with the workarounds for cover art? so this is using the same workaround __________________ |
||
|
|
|
Michgelsen Major Dude
Registered: Oct 2003 |
Hmm I feared so. When I read the "used technologies" part I had my doubts. Anyway I think it's cleverly done, but understand also why they won't accept it. __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
__________________ |
||
|
|
|
rohan_pwln Major Dude
Registered: Aug 2002 |
ya.. even i too tried using accept="image/png, image/jpeg, image/jpg"... but it didn't work at all in IE6 nor in Opera8. It however worked in Opera9.tp2 __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
in the dreamweaver docs it says it will be supportet with netscape7and iexplorer7 __________________ |
||
|
|
|
leechbite Banned
Registered: Sep 2003 |
just implemented this on Kameleon. works great! thanks to both of you. |
||
|
|
|
rohan_pwln Major Dude
Registered: Aug 2002 |
thanks for using it.. leech. __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
__________________ |
||
|
|
|
rohan_pwln Major Dude
Registered: Aug 2002 |
that's a good idea, but you cannot select folders via the browser file-fetch controls. __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
i'll post an example skin soon... __________________ |
||
|
|
|
martin.deimos Martin Pöhlmann UI Developer Winamp Dev Team
Registered: Sep 2004 |
i've bundled this hacked html file with the new version of MSPP, so I don't need the renaming to maki hack anymore! __________________ |
||
|
|
|
Last Thread Next Thread
|
WINAMP.COM | Forums > Skinning and Design > Modern Skins > Walkthrough: Allowing users to select a file through a File Open dialog |
Forum Rules:
|