@iiif/manifold
Advanced tools
Comparing version
@@ -8,2 +8,3 @@ import { IManifoldOptions } from "./IManifoldOptions"; | ||
private _loaded; | ||
private _detectIE; | ||
} |
@@ -18,30 +18,32 @@ "use strict"; | ||
} | ||
//const msie = that._detectIE(); | ||
//if (msie === false) { | ||
manifesto_js_1.Utils.loadManifest(that._options.manifestUri).then(function (json) { | ||
that._loaded(that, json, resolve, reject); | ||
}); | ||
// } else { | ||
// // if not a recent version of IE | ||
// if (msie > 0) { | ||
// if (msie === 9) { | ||
// // CORS not available, use jsonp | ||
// const settings: JQueryAjaxSettings = <JQueryAjaxSettings>{ | ||
// url: that._options.manifestUri, | ||
// type: 'GET', | ||
// dataType: 'jsonp', | ||
// jsonp: 'callback', | ||
// jsonpCallback: 'manifestCallback' | ||
// }; | ||
// $.ajax(settings); | ||
// window.manifestCallback = (json: any) => { | ||
// that._loaded(that, JSON.stringify(json), resolve, reject); | ||
// }; | ||
// } else { | ||
// $.getJSON(that._options.manifestUri, (json) => { | ||
// that._loaded(that, JSON.stringify(json), resolve, reject); | ||
// }); | ||
// } | ||
// } | ||
// } | ||
var msie = that._detectIE(); | ||
if (msie === false) { | ||
manifesto_js_1.Utils.loadManifest(that._options.manifestUri).then(function (json) { | ||
that._loaded(that, json, resolve, reject); | ||
}); | ||
} | ||
else { | ||
// if not a recent version of IE | ||
if (msie > 0) { | ||
if (msie === 9) { | ||
// CORS not available, use jsonp | ||
var settings = { | ||
url: that._options.manifestUri, | ||
type: 'GET', | ||
dataType: 'jsonp', | ||
jsonp: 'callback', | ||
jsonpCallback: 'manifestCallback' | ||
}; | ||
$.ajax(settings); | ||
window.manifestCallback = function (json) { | ||
that._loaded(that, JSON.stringify(json), resolve, reject); | ||
}; | ||
} | ||
else { | ||
$.getJSON(that._options.manifestUri, function (json) { | ||
that._loaded(that, JSON.stringify(json), resolve, reject); | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
@@ -102,2 +104,32 @@ }; | ||
}; | ||
Bootstrapper.prototype._detectIE = function () { | ||
var ua = window.navigator.userAgent; | ||
// Test values; Uncomment to check result … | ||
// IE 10 | ||
// ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'; | ||
// IE 11 | ||
// ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; | ||
// Edge 12 (Spartan) | ||
// ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0'; | ||
// Edge 13 | ||
// ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586'; | ||
var msie = ua.indexOf('MSIE '); | ||
if (msie > 0) { | ||
// IE 10 or older => return version number | ||
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); | ||
} | ||
var trident = ua.indexOf('Trident/'); | ||
if (trident > 0) { | ||
// IE 11 => return version number | ||
var rv = ua.indexOf('rv:'); | ||
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); | ||
} | ||
var edge = ua.indexOf('Edge/'); | ||
if (edge > 0) { | ||
// Edge (IE 12+) => return version number | ||
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); | ||
} | ||
// other browser | ||
return false; | ||
}; | ||
return Bootstrapper; | ||
@@ -104,0 +136,0 @@ }()); |
@@ -184,7 +184,7 @@ "use strict"; | ||
that.isProbed = true; | ||
var xhr_1 = new XMLHttpRequest(); | ||
xhr_1.open('GET', that.probeService.id, true); | ||
xhr_1.withCredentials = true; | ||
xhr_1.onload = function () { | ||
var data = JSON.parse(xhr_1.responseText); | ||
$.ajax({ | ||
url: that.probeService.id, | ||
type: 'GET', | ||
dataType: 'json' | ||
}).done(function (data) { | ||
var contentLocation = unescape(data.contentLocation); | ||
@@ -198,13 +198,13 @@ if (contentLocation !== that.dataUri) { | ||
resolve(that); | ||
}; | ||
xhr_1.onerror = function () { | ||
that.status = xhr_1.status; | ||
}).fail(function (error) { | ||
that.status = error.status; | ||
that.error = error; | ||
resolve(that); | ||
}; | ||
xhr_1.send(); | ||
// $.ajax(<JQueryAjaxSettings>{ | ||
// url: that.probeService.id, | ||
// type: 'GET', | ||
// dataType: 'json' | ||
// }).done((data: any) => { | ||
}); | ||
// xhr implementation | ||
// const xhr: XMLHttpRequest = new XMLHttpRequest(); | ||
// xhr.open('GET', that.probeService.id, true); | ||
// xhr.withCredentials = true; | ||
// xhr.onload = () => { | ||
// const data = JSON.parse(xhr.responseText); | ||
// let contentLocation: string = unescape(data.contentLocation); | ||
@@ -217,7 +217,8 @@ // if (contentLocation !== that.dataUri) { | ||
// resolve(that); | ||
// }).fail((error) => { | ||
// that.status = error.status; | ||
// that.error = error; | ||
// } | ||
// xhr.onerror = () => { | ||
// that.status = xhr.status; | ||
// resolve(that); | ||
// }); | ||
// }; | ||
// xhr.send(); | ||
} | ||
@@ -242,10 +243,12 @@ else { | ||
} | ||
var xhr_2 = new XMLHttpRequest(); | ||
xhr_2.open(type, that.dataUri, true); | ||
xhr_2.withCredentials = true; | ||
if (accessToken) { | ||
xhr_2.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
} | ||
xhr_2.onload = function () { | ||
var data = JSON.parse(xhr_2.responseText); | ||
$.ajax({ | ||
url: that.dataUri, | ||
type: type, | ||
dataType: 'json', | ||
beforeSend: function (xhr) { | ||
if (accessToken) { | ||
xhr.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
} | ||
} | ||
}).done(function (data) { | ||
// if it's a resource without an info.json | ||
@@ -278,21 +281,19 @@ // todo: if resource doesn't have a @profile | ||
} | ||
}; | ||
xhr_2.onerror = function () { | ||
that.status = xhr_2.status; | ||
if (xhr_2.responseText) { | ||
that._parseAuthServices(JSON.parse(xhr_2.responseText)); | ||
}).fail(function (error) { | ||
that.status = error.status; | ||
that.error = error; | ||
if (error.responseJSON) { | ||
that._parseAuthServices(error.responseJSON); | ||
} | ||
resolve(that); | ||
}; | ||
xhr_2.send(); | ||
// $.ajax(<JQueryAjaxSettings>{ | ||
// url: that.dataUri, | ||
// type: type, | ||
// dataType: 'json', | ||
// beforeSend: (xhr) => { | ||
// if (accessToken) { | ||
// xhr.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
// } | ||
// } | ||
// }).done((data: any) => { | ||
}); | ||
// xhr implementation | ||
// const xhr: XMLHttpRequest = new XMLHttpRequest(); | ||
// xhr.open(type, that.dataUri, true); | ||
// xhr.withCredentials = true; | ||
// if (accessToken) { | ||
// xhr.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
// } | ||
// xhr.onload = () => { | ||
// const data = JSON.parse(xhr.responseText); | ||
// // if it's a resource without an info.json | ||
@@ -312,3 +313,3 @@ // // todo: if resource doesn't have a @profile | ||
// let dataUri: string | null = that.dataUri; | ||
// if (dataUri && dataUri.endsWith('/info.json')){ | ||
// if (dataUri && dataUri.endsWith('/info.json')) { | ||
// dataUri = dataUri.substr(0, dataUri.lastIndexOf('/')); | ||
@@ -324,10 +325,11 @@ // } | ||
// } | ||
// }).fail((error) => { | ||
// that.status = error.status; | ||
// that.error = error; | ||
// if (error.responseJSON){ | ||
// that._parseAuthServices(error.responseJSON); | ||
// } | ||
// xhr.onerror = () => { | ||
// that.status = xhr.status; | ||
// if (xhr.responseText) { | ||
// that._parseAuthServices(JSON.parse(xhr.responseText)); | ||
// } | ||
// resolve(that); | ||
// }); | ||
// }; | ||
// xhr.send(); | ||
} | ||
@@ -334,0 +336,0 @@ }); |
@@ -62,3 +62,3 @@ import { MultiSelectState } from "./MultiSelectState"; | ||
getShareServiceUrl(): string | null; | ||
getSortedTreeNodesByDate(sortedTree: TreeNode, tree: TreeNode): void; | ||
private _getSortedTreeNodesByDate; | ||
getStartCanvasIndex(): number; | ||
@@ -65,0 +65,0 @@ getThumbs(width: number, height: number): Thumb[]; |
@@ -397,3 +397,3 @@ "use strict"; | ||
}; | ||
Helper.prototype.getSortedTreeNodesByDate = function (sortedTree, tree) { | ||
Helper.prototype._getSortedTreeNodesByDate = function (sortedTree, tree) { | ||
// const all: TreeNode[] = <TreeNode[]>tree.nodes.en().traverseUnique(node => node.nodes) | ||
@@ -468,3 +468,3 @@ // .where((n) => n.data.type === TreeNodeType.COLLECTION || | ||
if (this.treeHasNavDates(tree)) { | ||
this.getSortedTreeNodesByDate(sortedTree, tree); | ||
this._getSortedTreeNodesByDate(sortedTree, tree); | ||
break; | ||
@@ -480,3 +480,3 @@ } | ||
// todo: write test | ||
var flattenedTree = this.getFlattenedTree(); | ||
var flattenedTree = this.getFlattenedTree(tree); | ||
return (flattenedTree) ? flattenedTree.some(function (n) { return !isNaN(n.navDate); }) : false; | ||
@@ -483,0 +483,0 @@ }; |
@@ -8,2 +8,3 @@ import { IManifoldOptions } from "./IManifoldOptions"; | ||
private _loaded; | ||
private _detectIE; | ||
} |
@@ -16,30 +16,32 @@ import { Helper } from "./Helper"; | ||
} | ||
//const msie = that._detectIE(); | ||
//if (msie === false) { | ||
Utils.loadManifest(that._options.manifestUri).then(function (json) { | ||
that._loaded(that, json, resolve, reject); | ||
}); | ||
// } else { | ||
// // if not a recent version of IE | ||
// if (msie > 0) { | ||
// if (msie === 9) { | ||
// // CORS not available, use jsonp | ||
// const settings: JQueryAjaxSettings = <JQueryAjaxSettings>{ | ||
// url: that._options.manifestUri, | ||
// type: 'GET', | ||
// dataType: 'jsonp', | ||
// jsonp: 'callback', | ||
// jsonpCallback: 'manifestCallback' | ||
// }; | ||
// $.ajax(settings); | ||
// window.manifestCallback = (json: any) => { | ||
// that._loaded(that, JSON.stringify(json), resolve, reject); | ||
// }; | ||
// } else { | ||
// $.getJSON(that._options.manifestUri, (json) => { | ||
// that._loaded(that, JSON.stringify(json), resolve, reject); | ||
// }); | ||
// } | ||
// } | ||
// } | ||
var msie = that._detectIE(); | ||
if (msie === false) { | ||
Utils.loadManifest(that._options.manifestUri).then(function (json) { | ||
that._loaded(that, json, resolve, reject); | ||
}); | ||
} | ||
else { | ||
// if not a recent version of IE | ||
if (msie > 0) { | ||
if (msie === 9) { | ||
// CORS not available, use jsonp | ||
var settings = { | ||
url: that._options.manifestUri, | ||
type: 'GET', | ||
dataType: 'jsonp', | ||
jsonp: 'callback', | ||
jsonpCallback: 'manifestCallback' | ||
}; | ||
$.ajax(settings); | ||
window.manifestCallback = function (json) { | ||
that._loaded(that, JSON.stringify(json), resolve, reject); | ||
}; | ||
} | ||
else { | ||
$.getJSON(that._options.manifestUri, function (json) { | ||
that._loaded(that, JSON.stringify(json), resolve, reject); | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
@@ -100,2 +102,32 @@ }; | ||
}; | ||
Bootstrapper.prototype._detectIE = function () { | ||
var ua = window.navigator.userAgent; | ||
// Test values; Uncomment to check result … | ||
// IE 10 | ||
// ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'; | ||
// IE 11 | ||
// ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; | ||
// Edge 12 (Spartan) | ||
// ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0'; | ||
// Edge 13 | ||
// ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586'; | ||
var msie = ua.indexOf('MSIE '); | ||
if (msie > 0) { | ||
// IE 10 or older => return version number | ||
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); | ||
} | ||
var trident = ua.indexOf('Trident/'); | ||
if (trident > 0) { | ||
// IE 11 => return version number | ||
var rv = ua.indexOf('rv:'); | ||
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); | ||
} | ||
var edge = ua.indexOf('Edge/'); | ||
if (edge > 0) { | ||
// Edge (IE 12+) => return version number | ||
return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); | ||
} | ||
// other browser | ||
return false; | ||
}; | ||
return Bootstrapper; | ||
@@ -102,0 +134,0 @@ }()); |
@@ -182,7 +182,7 @@ import { ServiceProfile, Utils } from "manifesto.js"; | ||
that.isProbed = true; | ||
var xhr_1 = new XMLHttpRequest(); | ||
xhr_1.open('GET', that.probeService.id, true); | ||
xhr_1.withCredentials = true; | ||
xhr_1.onload = function () { | ||
var data = JSON.parse(xhr_1.responseText); | ||
$.ajax({ | ||
url: that.probeService.id, | ||
type: 'GET', | ||
dataType: 'json' | ||
}).done(function (data) { | ||
var contentLocation = unescape(data.contentLocation); | ||
@@ -196,13 +196,13 @@ if (contentLocation !== that.dataUri) { | ||
resolve(that); | ||
}; | ||
xhr_1.onerror = function () { | ||
that.status = xhr_1.status; | ||
}).fail(function (error) { | ||
that.status = error.status; | ||
that.error = error; | ||
resolve(that); | ||
}; | ||
xhr_1.send(); | ||
// $.ajax(<JQueryAjaxSettings>{ | ||
// url: that.probeService.id, | ||
// type: 'GET', | ||
// dataType: 'json' | ||
// }).done((data: any) => { | ||
}); | ||
// xhr implementation | ||
// const xhr: XMLHttpRequest = new XMLHttpRequest(); | ||
// xhr.open('GET', that.probeService.id, true); | ||
// xhr.withCredentials = true; | ||
// xhr.onload = () => { | ||
// const data = JSON.parse(xhr.responseText); | ||
// let contentLocation: string = unescape(data.contentLocation); | ||
@@ -215,7 +215,8 @@ // if (contentLocation !== that.dataUri) { | ||
// resolve(that); | ||
// }).fail((error) => { | ||
// that.status = error.status; | ||
// that.error = error; | ||
// } | ||
// xhr.onerror = () => { | ||
// that.status = xhr.status; | ||
// resolve(that); | ||
// }); | ||
// }; | ||
// xhr.send(); | ||
} | ||
@@ -240,10 +241,12 @@ else { | ||
} | ||
var xhr_2 = new XMLHttpRequest(); | ||
xhr_2.open(type, that.dataUri, true); | ||
xhr_2.withCredentials = true; | ||
if (accessToken) { | ||
xhr_2.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
} | ||
xhr_2.onload = function () { | ||
var data = JSON.parse(xhr_2.responseText); | ||
$.ajax({ | ||
url: that.dataUri, | ||
type: type, | ||
dataType: 'json', | ||
beforeSend: function (xhr) { | ||
if (accessToken) { | ||
xhr.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
} | ||
} | ||
}).done(function (data) { | ||
// if it's a resource without an info.json | ||
@@ -276,21 +279,19 @@ // todo: if resource doesn't have a @profile | ||
} | ||
}; | ||
xhr_2.onerror = function () { | ||
that.status = xhr_2.status; | ||
if (xhr_2.responseText) { | ||
that._parseAuthServices(JSON.parse(xhr_2.responseText)); | ||
}).fail(function (error) { | ||
that.status = error.status; | ||
that.error = error; | ||
if (error.responseJSON) { | ||
that._parseAuthServices(error.responseJSON); | ||
} | ||
resolve(that); | ||
}; | ||
xhr_2.send(); | ||
// $.ajax(<JQueryAjaxSettings>{ | ||
// url: that.dataUri, | ||
// type: type, | ||
// dataType: 'json', | ||
// beforeSend: (xhr) => { | ||
// if (accessToken) { | ||
// xhr.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
// } | ||
// } | ||
// }).done((data: any) => { | ||
}); | ||
// xhr implementation | ||
// const xhr: XMLHttpRequest = new XMLHttpRequest(); | ||
// xhr.open(type, that.dataUri, true); | ||
// xhr.withCredentials = true; | ||
// if (accessToken) { | ||
// xhr.setRequestHeader("Authorization", "Bearer " + accessToken.accessToken); | ||
// } | ||
// xhr.onload = () => { | ||
// const data = JSON.parse(xhr.responseText); | ||
// // if it's a resource without an info.json | ||
@@ -310,3 +311,3 @@ // // todo: if resource doesn't have a @profile | ||
// let dataUri: string | null = that.dataUri; | ||
// if (dataUri && dataUri.endsWith('/info.json')){ | ||
// if (dataUri && dataUri.endsWith('/info.json')) { | ||
// dataUri = dataUri.substr(0, dataUri.lastIndexOf('/')); | ||
@@ -322,10 +323,11 @@ // } | ||
// } | ||
// }).fail((error) => { | ||
// that.status = error.status; | ||
// that.error = error; | ||
// if (error.responseJSON){ | ||
// that._parseAuthServices(error.responseJSON); | ||
// } | ||
// xhr.onerror = () => { | ||
// that.status = xhr.status; | ||
// if (xhr.responseText) { | ||
// that._parseAuthServices(JSON.parse(xhr.responseText)); | ||
// } | ||
// resolve(that); | ||
// }); | ||
// }; | ||
// xhr.send(); | ||
} | ||
@@ -332,0 +334,0 @@ }); |
@@ -62,3 +62,3 @@ import { MultiSelectState } from "./MultiSelectState"; | ||
getShareServiceUrl(): string | null; | ||
getSortedTreeNodesByDate(sortedTree: TreeNode, tree: TreeNode): void; | ||
private _getSortedTreeNodesByDate; | ||
getStartCanvasIndex(): number; | ||
@@ -65,0 +65,0 @@ getThumbs(width: number, height: number): Thumb[]; |
@@ -395,3 +395,3 @@ import { MultiSelectState } from "./MultiSelectState"; | ||
}; | ||
Helper.prototype.getSortedTreeNodesByDate = function (sortedTree, tree) { | ||
Helper.prototype._getSortedTreeNodesByDate = function (sortedTree, tree) { | ||
// const all: TreeNode[] = <TreeNode[]>tree.nodes.en().traverseUnique(node => node.nodes) | ||
@@ -466,3 +466,3 @@ // .where((n) => n.data.type === TreeNodeType.COLLECTION || | ||
if (this.treeHasNavDates(tree)) { | ||
this.getSortedTreeNodesByDate(sortedTree, tree); | ||
this._getSortedTreeNodesByDate(sortedTree, tree); | ||
break; | ||
@@ -478,3 +478,3 @@ } | ||
// todo: write test | ||
var flattenedTree = this.getFlattenedTree(); | ||
var flattenedTree = this.getFlattenedTree(tree); | ||
return (flattenedTree) ? flattenedTree.some(function (n) { return !isNaN(n.navDate); }) : false; | ||
@@ -481,0 +481,0 @@ }; |
{ | ||
"name": "@iiif/manifold", | ||
"version": "2.0.0-pre.1", | ||
"version": "2.0.0-pre.2", | ||
"description": "", | ||
@@ -31,2 +31,3 @@ "main": "./dist-esmodule/index.js", | ||
"dependencies": { | ||
"@types/jquery": "^3.3.29", | ||
"@edsilv/http-status-codes": "0.0.12", | ||
@@ -33,0 +34,0 @@ "@iiif/vocabulary": "^1.0.5", |
@@ -5,6 +5,14 @@ # manifold | ||
npm install @iiif/manifold --save | ||
Stateful utils on top of manifesto. Returns a `helper` object that can be used to navigate a IIIF manifest. | ||
npm install @iiif/manifold --save | ||
e.g. | ||
- `getMetadata`: returns all metadata for current image, range, canvas, sequence, manifest) | ||
- `getCurrentRange`, `getPreviousRange`, `getNextRange`: Used to navigate a flattened range tree (useful for IIIF AV scenarios) | ||
- `getTree`: Returns a default tree (sortable by `navDate`) of collections, manifests, ranges, or a tree based on a given top range. | ||
Has an ajax implementation of manifesto's IExternalResource (used in the IIIF auth flow). | ||
Getting Started | ||
@@ -11,0 +19,0 @@ -- |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3113643
0.29%5858
1.28%38
26.67%3
-40%4
33.33%+ Added
+ Added
+ Added