Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable viewing locally defined panoramas like the examples #573

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pannellum.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pannellum</title>
<link type="text/css" rel="Stylesheet" href="src/css/pannellum.css"/>
<link type="text/css" rel="Stylesheet" href="src/standalone/standalone.css"/>
</head>
<body>
<div id="container">
<noscript>
<div class="pnlm-info-box">
<p>Javascript is required to view this panorama.<br>(It could be worse; you could need a plugin.)</p>
</div>
</noscript>
</div>
<script type="text/javascript" src="src/js/libpannellum.js"></script>
<script type="text/javascript" src="src/js/RequestAnimationFrame.js"></script>
<script type="text/javascript" src="src/js/pannellum.js"></script>
<script type="text/javascript" src="src/standalone/standalone.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/js/pannellum.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function init() {

var xhr = new XMLHttpRequest();
xhr.onloadend = function() {
if (xhr.status != 200) {
if (xhr.status != 200 && xhr.status != 0) {
// Display error if image can't be loaded
var a = document.createElement('a');
a.href = encodeURI(p);
Expand Down
20 changes: 11 additions & 9 deletions src/standalone/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function parseURLParameters() {
// Get JSON configuration file
request = new XMLHttpRequest();
request.onload = function() {
if (request.status != 200) {
if (request.status != 200 && request.status != 0) {
// Display error if JSON can't be loaded
var a = document.createElement('a');
a.href = configFromURL.config;
Expand Down Expand Up @@ -84,6 +84,14 @@ function parseURLParameters() {
configFromURL.escapeHTML = true;
viewer = pannellum.viewer('container', configFromURL);
};
request.onerror = function(e) {
// Display error if opened from local file
if (window.location.protocol == 'file:')
anError('Due to browser security restrictions, loading Pannellum files from the local filesystem has been denied; ' +
'use the Chrome/Opera command-line option "--allow-file-access-from-files" or some sort of local web server.');
else
anError("Error loading "+configFromURL.config);
}
request.open('GET', configFromURL.config);
request.send();
return;
Expand All @@ -98,11 +106,5 @@ function parseURLParameters() {
viewer = pannellum.viewer('container', configFromURL);
}

// Display error if opened from local file
if (window.location.protocol == 'file:') {
anError('Due to browser security restrictions, Pannellum can\'t be run ' +
'from the local filesystem; some sort of web server must be used.');
} else {
// Initialize viewer
parseURLParameters();
}
// Initialize viewer
parseURLParameters();