Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

Commit

Permalink
fix script path
Browse files Browse the repository at this point in the history
  • Loading branch information
borismus committed Oct 31, 2016
1 parent de4fac9 commit 0ddbb33
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/api/player.js
Expand Up @@ -18,7 +18,8 @@ var IFrameMessageSender = require('./iframe-message-sender');
var Message = require('../message');
var Util = require('../util');

var EMBED_URL = '../../index.html?';
// Save the executing script. This will be used to calculate the embed URL.
var CURRENT_SCRIPT_SRC = document.currentScript.src;
var FAKE_FULLSCREEN_CLASS = 'vrview-fake-fullscreen';

/**
Expand Down Expand Up @@ -120,7 +121,7 @@ Player.prototype.createIframe_ = function(params) {
delete params.height;
}

var url = EMBED_URL + Util.createGetParams(params);
var url = this.getEmbedUrl_() + Util.createGetParams(params);
iframe.src = url;

return iframe;
Expand Down Expand Up @@ -188,5 +189,15 @@ Player.prototype.injectFullscreenStylesheet_ = function() {
document.body.appendChild(style);
};

Player.prototype.getEmbedUrl_ = function() {
// Assume that the script is in $ROOT/build/something.js, and that the iframe
// HTML is in $ROOT.
var path = CURRENT_SCRIPT_SRC;
var split = path.split('/');
var rootSplit = split.slice(0, split.length - 2);
var rootPath = rootSplit.join('/');
return rootPath + '/index.html';
};


module.exports = Player;

0 comments on commit 0ddbb33

Please sign in to comment.