$(document).ready(function(){ var opts= { id: "view", prefixUrl: "/html/", springStiffness: 40, zoomPerScroll: 1.2, showNavigator: true, }; //support malformed URLs (eg with Windows-1252 encoding) var baseUrl = window.location.href.split('/').slice(0,-2).join('/') + '/'; var filename = window.location.href.split('/').slice(-2,-1).join(''); //var path = '/'+baseUrl+'/'+filename; var path = baseUrl + filename; var filetype = filename.split('.').slice(-1)[0]; var appmag = parseInt(window.fileinfo.appmag); var levels = [0.5, 1, 2, 4, 10, 20, 40, 60]; var imageLevels = levels.filter(function(val) { return val <= appmag; }).length; var source; var static_files=['jpg','jpeg','tiff','tif','gif','png']; if(static_files.indexOf(filetype.toLowerCase())!= -1){ source = { type:'image', url: path+ '?0+0' } $('body').append($('')); } else{ source = { mpp: {x: parseFloat(window.fileinfo.mpp), y: parseFloat(window.fileinfo.mpp)}, appmag: parseInt(window.fileinfo.appmag), width: parseInt(window.fileinfo.width), height: parseInt(window.fileinfo.height), tileSize: parseInt(window.fileinfo.tileSize), maxLevel: imageLevels, scanPower: levels[imageLevels-1], imageURL: path, getTileUrl: getTileUrl, }; } //create the viewer window.slideinfo = source; //save global reference so annotations can be configured window.slideviewer = new OpenSeadragon.Viewer(opts); window.slideviewer.addHandler('open',add_annotations); window.slideviewer.open(source); //add_annotations(); function getTileUrl(level, x, y) { var p = Math.pow(2, this.maxLevel - level); var url = this.imageURL; x = x * this._tileWidth * p; y = y * this._tileHeight * p; url = url + "?0" + x + "+" + "0" + y + "+" + this._tileWidth + "+" + this._tileHeight + "+" + p; return url; }; })