Welcome to the Invelos forums. Please read the forum rules before posting.

Read access to our public forums is open to everyone. To post messages, a free registration is required.

If you have an Invelos account, sign in to post.

    Invelos Forums->DVD Profiler: Layouts and Reports Page: 1  Previous   Next
Help with amending HTML window
Author Message
DVD Profiler Desktop and Mobile RegistrantStar ContributorPantheon
Registered: March 14, 2007
Reputation: High Rating
United Kingdom Posts: 1,819
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
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>
DVD Profiler Desktop and Mobile Registrantmediadogg
Aim high. Ride the wind.
Registered: March 18, 2007
Reputation: Highest Rating
United States Posts: 6,461
Posted:
PM this userVisit this user's homepageDirect link to this postReply with quote
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
DVD Profiler Desktop and Mobile RegistrantStar ContributorSH84
Registered: March 13, 2007
Reputation: High Rating
Germany Posts: 922
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
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
DVD Profiler Desktop and Mobile Registrantmediadogg
Aim high. Ride the wind.
Registered: March 18, 2007
Reputation: Highest Rating
United States Posts: 6,461
Posted:
PM this userVisit this user's homepageDirect link to this postReply with quote
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
DVD Profiler Desktop and Mobile RegistrantStar ContributorPantheon
Registered: March 14, 2007
Reputation: High Rating
United Kingdom Posts: 1,819
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
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!!
DVD Profiler Unlimited Registrantxyrano
41215.reg 70320.urk
Registered: March 13, 2007
Sweden Posts: 646
Posted:
PM this userView this user's DVD collectionDirect link to this postReply with quote
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.
    Invelos Forums->DVD Profiler: Layouts and Reports Page: 1  Previous   Next