From 6b39a81ef754eeeb92e79f4415e1968b13445dd7 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Mon, 25 Mar 2013 16:36:13 -0400 Subject: [PATCH] open: fix docs, tileHost * Updated documentation to match actual parameters (see #53) * tileHost was completely broken for dzi files. Now it's based on the DZI source URL (e.g. `foo.dzi` -> tileHost + `foo_files/` vs. `_files/`). --- src/openseadragon.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/openseadragon.js b/src/openseadragon.js index 6b4debd0..4302f621 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -1389,12 +1389,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ * and provides a callback hook for the resulting Document * @function * @name OpenSeadragon.createFromDZI - * @param {String} xmlUrl - * @param {String} xmlString + * @param {String} dziUrlOrString * @param {Function} callback + * @param {String} tileHostname * @deprecated */ - createFromDZI: function( dzi, callback, tileHost ) { + createFromDZI: function( dzi, callback, tileHost) { var async = typeof ( callback ) == "function", dziUrl = ( dzi.substring(0,1) != '<' && @@ -1408,13 +1408,9 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ tilesUrl, callbackName; - - if( tileHost ){ - - tilesUrl = tileHost + "/_files/"; - - } else if( dziUrl ) { - + if (tileHost) { + tilesUrl = tileHost + '/' + dziUrl.replace(/^.*\/(.*)\.dzi$/, '$1') + '_files/'; + } else if (dziUrl) { urlParts = dziUrl.split( '/' ); filename = urlParts[ urlParts.length - 1 ]; if( filename.match(/_dzi\.js$/) ){ @@ -1431,7 +1427,6 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ tilesUrl = urlParts.join( '/' ) + "_files/"; - } function finish( func, obj ) { @@ -1449,7 +1444,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ if ( async ) { if ( dziString ) { window.setTimeout( function() { - var source = finish( processDZIXml, $.parseXml( xmlString ) ); + var source = finish( processDZIXml, $.parseXml( dziString ) ); // call after finish sets error callback( source, error ); }, 1);