Registered: March 14, 2007 | Reputation: | Posts: 1,819 |
| Posted: | | | | Hello all
I currently have an html window that I use to display reviews from my favourite film magazine. Currently the code utilises the UPC of each film as the file name. I would like to change this so that the title of the film is used (which will make the files easier to find later).
Here's the code as it stands; and if someone can change the bits required I would be very grateful:
<HTML> <HEAD> <SCRIPT TYPE="text/javascript"> <!-- <DP NAME="HEADER_VARS" Language="JavaScript" Comments="True" IncludeCast="False" IncludeCrew="False"> //-->
// -------- Configuration block - Start -------- // Extended Features Storage Location var pathToEfStorage = "C:\\Documents and Settings\\Neil\\Documents\\DVD Profiler\\tfr\\"; // <-- SET
// filename var fileNamePrefix = "tfr."; // <-- SET var excludeLocality = true; // <-- SET true/false var fileNameSuffix = ".html"; // <-- SET .htm/.html
// -------- Configuration block - END --------
function showEF() { var notes = DP_Notes.indexOf("\<tfr=1\>"); if (notes != -1) { var upc = DP_UPC; if (excludeLocality == true && upc.indexOf(".") != -1) upc = upc.substring(0, upc.lastIndexOf(".")); pageToLoad = pathToEfStorage + fileNamePrefix+ upc + fileNameSuffix;
window.location.href = pageToLoad; } else { document.write("No Review Available!"); } }
</SCRIPT> </HEAD> <BODY onload="showEF()"> </BODY> |
|
Registered: March 18, 2007 | Reputation: | Posts: 6,463 |
| Posted: | | | | Of course anything can be programmed, but I think you're asking for a bit of trouble IMHO. Examples:
- Special characters in the title that aren't allowed in filenames would have to be filtered out - Profile changes could change the title, then it won't match your file - (almost forgot) Same title for multiple profiles
But good luck anyway ... | | | Thanks for your support. Free Plugins available here. Advanced plugins available here. Hey, new product!!! BDPFrog. | | | Last edited: by mediadogg |
|
Registered: March 13, 2007 | Reputation: | Posts: 922 |
| Posted: | | | | Okay, try this code: Quote: <HTML> <HEAD> <SCRIPT TYPE="text/javascript"> <!-- <DP NAME="HEADER_VARS" Language="JavaScript" Comments="True" IncludeCast="False" IncludeCrew="False"> //-->
function RemoveReservedChars(title){ title = title.replace(/\./g, ""); title = title.replace(/\//g, ""); title = title.replace(/\*/, ""); title = title.replace(/\\/g, ""); title = title.replace(/\?/g, ""); title = title.replace(/%/g, ""); title = title.replace(/:/g, ""); title = title.replace(/\|/g, ""); title = title.replace(/\"/g, ""); title = title.replace(/>/g, ""); title = title.replace(/</g, ""); title = title.replace (/^\s+/, '').replace (/\s+$/, ''); return(title); }
// -------- Configuration block - Start -------- // Extended Features Storage Location var pathToEfStorage = "C:\\Documents and Settings\\Neil\\Documents\\DVD Profiler\\tfr\\"; // <-- SET
// filename var fileNamePrefix = "tfr."; // <-- SET var excludeLocality = true; // <-- SET true/false var fileNameSuffix = ".html"; // <-- SET .htm/.html
// -------- Configuration block - END --------
var title = "<DP NAME="TITLE">"; title = RemoveReservedChars(title);
function showEF(title) { var notes = DP_Notes.indexOf("\<tfr=1\>"); if (notes != -1) {
pageToLoad = pathToEfStorage + fileNamePrefix+ title + fileNameSuffix;
window.location.href = pageToLoad; } else { document.write("No Review Available!"); } }
</SCRIPT> </HEAD> <BODY onload="showEF(title)"> </BODY> </HTML>
This function should eliminate all reserved characters from the title. The following characters are forbidden: . \ / * " ? % : | < > and a leading or trailing space. And you could use the sorttitle to avoid the "Same title for multiple profiles" problem by changing Quote: var title = "<DP NAME="TITLE">"; to Quote: var title = "<DP NAME="SORTTITLE">"; | | | Deutsches DVD Profiler Forum: www.dvdprofiler-forum.de | | | Last edited: by SH84 |
|
Registered: March 18, 2007 | Reputation: | Posts: 6,463 |
| Posted: | | | | Don't you just love this place! Nice job SH84! | | | Thanks for your support. Free Plugins available here. Advanced plugins available here. Hey, new product!!! BDPFrog. | | | Last edited: by mediadogg |
|
Registered: March 14, 2007 | Reputation: | Posts: 1,819 |
| Posted: | | | | Thank you so much SH84.
I had some trouble getting it to work.
But, after comparing to the original code all I did was change the following:
function showEF(title) to function showEF()
and
<BODY onload="showEF(title)"> to <BODY onload="showEF()">
Then it worked perfectly.
I really appreciate you taking the time to do this!! |
|
Registered: March 13, 2007 | Posts: 646 |
| Posted: | | | | Here is a shorter version of SH84's code: Quote: <html> <head> <script type="text/javascript"> <!-- <DP NAME="HEADER_VARS" Language="JavaScript" Comments="True" IncludeCast="False" IncludeCrew="False"> function getStorageLocation() { // -------- Configuration block - Start -------- // Extended Features Storage Location var pathToEfStorage = "C:\\Documents and Settings\\Neil\\Documents\\DVD Profiler\\tfr\\"; // <-- SET var fileNamePrefix = "tfr."; // <-- SET var fileNameSuffix = ".html"; // <-- SET .htm/.html // -------- Configuration block - END -------- return pathToEfStorage + fileNamePrefix + getSortTitle() + fileNameSuffix; } function showReview() { ( DP_Notes.indexOf( "\<tfr=1\>" ) != -1 ) ? window.location.href = getStorageLocation(): document.write( "No review available for '" + getSortTitle() + "'!" ); } function getSortTitle() { return '<DP NAME="SORTTITLE">'.replace( /^\s+|\.|\/|\*|\\|\?|%|:¤¤¤|\||\"|<|>|\s{2}/g, "" ).replace( /\s+$/, "" ); } //--> </script> </head> <body onload="showReview();"> </body> </html> Remove the three ¤¤¤ characters in the regexp after you pasted it into DVD Profiler. |
|