Skip to content

Commit e22a09b

Browse files
committed
Work on parsing with number sign
1 parent 7630bd9 commit e22a09b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

src/static/js/media.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function renderPlaylistFilesHTML (files, xinfo, el, artifactType, extraFiles) {
155155
tdBuy +
156156
"</tr>");
157157
var trackEl = extraFiles.children().last();
158-
trackEl.data({track: file, name: name, url: IPFSUrl([xinfo['DHT Hash'], file.fname]), sugPlay: file.sugPlay/priceScale, minPlay: file.minPlay/priceScale, sugBuy: file.sugBuy/priceScale, minBuy: file.minBuy/priceScale});
158+
trackEl.data({track: file, name: name, url: IPFSUrl([xinfo['DHT Hash'],file.fname]), sugPlay: file.sugPlay/priceScale, minPlay: file.minPlay/priceScale, sugBuy: file.sugBuy/priceScale, minBuy: file.minBuy/priceScale});
159159
} else {
160160
var fileRuntime = file.runtime;
161161
if (!file.runtime) {
@@ -169,7 +169,7 @@ function renderPlaylistFilesHTML (files, xinfo, el, artifactType, extraFiles) {
169169
tdBuy +
170170
"</tr>");
171171
var trackEl = el.children().last();
172-
trackEl.data({track: file, name: name, url: IPFSUrl([xinfo['DHT Hash'], file.fname]), sugPlay: file.sugPlay/priceScale, minPlay: file.minPlay/priceScale, sugBuy: file.sugBuy/priceScale, minBuy: file.minBuy/priceScale});
172+
trackEl.data({track: file, name: name, url: IPFSUrl([xinfo['DHT Hash'],file.fname]), sugPlay: file.sugPlay/priceScale, minPlay: file.minPlay/priceScale, sugBuy: file.sugBuy/priceScale, minBuy: file.minBuy/priceScale});
173173
}
174174
});
175175
if (extraFiles.children().length < 1) {
@@ -404,7 +404,13 @@ function watchForPin (addr, filename) {
404404
}
405405

406406
function IPFSUrl (components) {
407-
return encodeURI (IPFSHost + '/ipfs/' + components.join ('/'));
407+
var tmpComponents = [];
408+
for (var i in components)
409+
tmpComponents[i] = encodeURIComponent(components[i]);
410+
411+
console.log(tmpComponents);
412+
413+
return IPFSHost + '/ipfs/' + tmpComponents.join ('/');
408414
}
409415

410416
function showPaymentOption(e) {
@@ -739,6 +745,9 @@ function embedFile(mediaType, fileHash, mediaFilename, posterFrame) {
739745
if (mediaFilename == 'none') {
740746
mediaFilename = '';
741747
}
748+
749+
mediaFilename = encodeURIComponent(mediaFilename);
750+
742751
if (mediaType == 'book') {
743752
embedCode = '<object data="' + IPFSHost +'/ipfs/'+ fileHash + '/' + mediaFilename + '" type="application/pdf" width="100%" height="800px" class="book-embed"><p>No PDF plugin installed. You can <a href="' + IPFSHost +'/ipfs/'+ fileHash +'">click here to download the PDF file.</a></p></object>'
744753
} else if ( (mediaType == 'thing') && (fileExt != 'htm') ) {
@@ -763,11 +772,13 @@ function BTCtoUSD (amount) {
763772

764773
function loadTrack (name, url, fname) {
765774
filetype = filetype.toLowerCase();
766-
fname = encodeURI(fname).replace('+', '%20');
775+
fname = encodeURIComponent(fname).replace('+', '%20');
767776
var posterurl = url;
768777
if (posterFrame == 'alexandria-default-posterframe.png') {
769778
posterurl = IPFSHost+'/ipfs/QmQhoySfbL9j4jbDRSsZaeu3DACVBYW1o9vgs8aZAc5bLP/';
770779
}
780+
781+
posterFrame = encodeURIComponent(posterFrame);
771782
if (fname == 'none') {
772783
$('#audio-player').hide();
773784
if( $('#native-player') ) {
@@ -875,14 +886,13 @@ function onPaymentDone (action, file) {
875886

876887
console.info(file);
877888

878-
var trackPath = file.url.slice(0, '-'+ encodeURI(file.track.fname).length);
879-
880889
var fileType = file.track.type;
881890
if (!fileType) {
882891
fileType = history.state.mediaType;
883892
}
884893
var fileName = file.track.fname;
885-
var trackPath = file.url.slice(0, '-'+ encodeURI(fileName).length);
894+
var trackPath = file.url.slice(0, file.url.replace(encodeURIComponent(fileName), '').length);
895+
886896
if ( (fileType === 'video') || (fileType === 'movie') || (fileType === 'music') ) {
887897
var res = loadTrack(file.track.dname, trackPath, fileName);
888898

0 commit comments

Comments
 (0)