# Donovan's Insects
**Source**: https://digital.library.sydney.edu.au/nodes/view/8231
**Parent**: https://digital.library.sydney.edu.au/
[Skip to content](#main_content)
- [Home](https://digital.library.sydney.edu.au/)
- [Browse All](https://digital.library.sydney.edu.au/nodes/browse)
- [Search](https://digital.library.sydney.edu.au/nodes/definesearch)
- [My History](https://digital.library.sydney.edu.au/pages/history)
- [Login](https://digital.library.sydney.edu.au/users/login)
- More
- [How to contribute](https://digital.library.sydney.edu.au/pages/howtocontribute)
- [Login](https://digital.library.sydney.edu.au/users/login)
- [Register](https://digital.library.sydney.edu.au/users/register)
8231
var texttype = "METADATA";
var textedit = "0";
var textview = "1";
var overrideShowHitsPopup = "no";
var initText = "1";
$(function() {
$("#cloneitembutton").button().on("click", function() {
var dialogCloneForm = '<div id="dialog-clone-form" title="Parent-child Relationship"><p><strong style="color:red;">Warning.</strong> Cloning this item will not retain its parent-child relationship.</p>' + '<form action="/nodes/cloneNode/8231" id="cloneitemform" method="post" accept-charset="utf-8"><div style="display:none;"><input type="hidden" name="\_method" value="POST" /><input type="hidden" name="data[\_Token][key]" value="e3df3a2d8b8333438b902756cf5eab86f6534e00" id="Token763093217" /></div><div style="display:none;"><input type="hidden" name="data[\_Token][fields]" value="b291a8f44525a110c391023a1834b1cc32fcb39c%3A" id="TokenFields672281755" /></div></form>' + '</div>';
dialog = $(dialogCloneForm).dialog({
autoOpen: false,
height: 120,
width: 360,
modal: true,
buttons: {
// Restructured buttons slightly to retain custom colours over the jquery upgrade
Cancel: {
text: "Cancel",
class: "ui-state-default",
hover: function() {
$(this).toggleClass("hoverClass");
},
click: function() {
dialog.dialog("close");
}
},
// Restructured buttons slightly to retain custom colours over the jquery upgrade
"Confirm Clone": {
text: "Confirm Clone",
class: "ui-state-default",
hover: function() {
$(this).toggleClass("hoverClass");
},
click: function() {
document.getElementById("cloneitemform").submit();
}
}
},
close: function() {
dialog.dialog('destroy').remove();
}
});
dialog.dialog("open");
});
});
Open/Close Toolbox
Format: Collection
Linked To
**Collections**
- [The natural world](https://digital.library.sydney.edu.au/nodes/view/15136)
**Text**
- [Collection (3)](https://digital.library.sydney.edu.au/nodes/browse?filter=eyJudGlkcyI6WyIyMyJdLCJmYWNldCI6eyI0NjAiOlsiRG9ub3ZhbidzIEluc2VjdHMiXX19&bid=8231 "Where Donovan's Insects is the Collection")
Copyright
[Click to read the full Digital Collections copyright statement.](https://digital.library.sydney.edu.au/pages/copyright)
The University of Sydney Library believes this item or collection is in the public domain in Australia but did not make a determination regarding its copyright status in other countries. If you wish to credit the University of Sydney Library as the source, please use the following statement "From the University of Sydney Library” and provide a link to the item on our Digital Collections site.
Tools
[Download](https://digital.library.sydney.edu.au/nodes/download/8231)[Add to My Collection](https://digital.library.sydney.edu.au/users/bookmarks/add:8231)[Contact us about this](https://digital.library.sydney.edu.au/messages/create/8231)Citation for this item
[Drop down list of top links](#)
.xf-web-container {
margin-bottom: 0;
font-size: 16px;
line-height: 24px;
}
/\*! CSS Used from: https://www.sydney.edu.au/etc.clientlibs/library/clientlibs/library-frontend-svelte-css.css?a=nocache \*/
div,
span,
a,
ul,
li,
header,
section {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
header,
section {
display: block;
}
ul {
list-style: none;
}
a {
background-color: transparent;
font-family: "Apercu", Helvetica, sans-serif;
}
button {
font-family: inherit;
font-size: 100%;
line-height: 1.15;
margin: 0;
}
button {
overflow: visible;
}
button {
text-transform: none;
}
button,
[type="button"] {
-webkit-appearance: button;
}
ul,
li {
margin: 0;
padding: 0;
}
.xf-web-container {
box-sizing: border-box;
}
.sr-only {
position: absolute;
border: 0;
padding: 0;
margin: -1px;
overflow: hidden;
width: 1px;
height: 1px;
clip: rect(0, 0, 0, 0);
}
.m-link[data-type="anchorLink"] {
color: #ce3d20;
}
.m-link[data-type="anchorLink"]:hover,
.m-link[data-type="anchorLink"]:focus {
color: #ce3d20;
}
.m-grid {
box-sizing: border-box;
display: flex;
flex: 0 1 auto;
flex-flow: row wrap;
padding: 0;
margin: 0;
margin-right: calc(var(--m-grid-column-gap) / -2);
margin-left: calc(var(--m-grid-column-gap) / -2);
}
.m-grid\_\_cell {
box-sizing: border-box;
margin: 0;
padding: 0 calc(var(--m-grid-column-gap) / 2);
--m-grid-cell-max-width: 100%;
max-width: var(--m-grid-cell-max-width);
}
@media screen and (min-width: 576px) {
.\31\/3--mobile-up {
--m-grid-cell-max-width: 33.33333%;
flex-basis: var(--m-grid-cell-max-width);
max-width: var(--m-grid-cell-max-width);
}
}
@media screen and (min-width: 768px) {
.\32\/3--tablet-up {
--m-grid-cell-max-width: 66.66667%;
flex-basis: var(--m-grid-cell-max-width);
max-width: var(--m-grid-cell-max-width);
}
}
.m-link {
--link-font-size: "inherit";
color: #ce3d20;
text-decoration: none;
font-size: var(--link-font-size);
font-weight: 400;
}
.m-link:focus,
.m-link:hover {
color: #ce3d20;
cursor: pointer;
text-decoration: none;
}
.m-link--block {
display: block;
}
.m-link\_\_content {
text-decoration: underline;
}
.m-link--block {
display: flex;
flex-flow: row wrap;
align-items: center;
}
.m-link\_\_icon-right {
position: relative;
transition: right 0.2s;
margin-left: 6px;
right: 0;
}
.m-link:focus:not(.m-link--no-movement) .m-link\_\_icon-right,
.m-link:hover:not(.m-link--no-movement) .m-link\_\_icon-right {
right: -5px;
}
.m-link--default {
display: flex;
align-items: center;
}
.m-link--default span {
text-decoration: none;
}
.m-link--default--block {
display: block;
}
.m-button {
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
padding: 16px 32px;
font-weight: 700;
line-height: 1;
text-align: center;
transition: all 400ms;
cursor: pointer;
}
.m-button--button {
border: none;
}
.m-button\_\_content {
text-decoration: none;
line-height: 1;
}
.m-button\_\_icon-right {
margin-left: 8px;
}
.m-button[data-style="inline"] {
background: none;
border: 0;
color: #fff;
}
.m-button[data-style="inline"]:focus,
.m-button[data-style="inline"]:hover {
background: none;
text-decoration: underline;
}
.m-content-container {
box-sizing: border-box;
margin-left: auto;
margin-right: auto;
width: 100%;
max-width: 100%;
padding-left: 16px;
padding-right: 16px;
}
@media (min-width: 768px) {
.m-content-container {
padding-left: 16px;
padding-right: 16px;
}
}
@media (min-width: 992px) {
.m-content-container {
padding-left: 16px;
padding-right: 16px;
}
}
@media (min-width: 1200px) {
.m-content-container {
padding-left: 16px;
padding-right: 16px;
max-width: 1200px;
}
}
.site-header {
position: relative;
z-index: 1;
}
.site-header {
position: relative;
min-height: 80px;
z-index: 99999;
}
.m-lib-header {
position: relative;
top: 0;
width: 100%;
background: #141414;
padding: 8px 16px;
}
.m-lib-header\_\_container {
align-items: center;
}
.m-lib-header\_\_logo-content {
display: flex;
flex: 0 0 100%;
align-items: center;
color: #fff;
}
@media (max-width: 575px) {
.m-lib-header\_\_logo-content {
padding: 8px 0 0 0;
justify-content: space-between;
}
}
.m-lib-header\_\_logo-title {
font-family: "Apercu", Helvetica, sans-serif;
font-size: 32px;
line-height: 40px;
font-weight: 400;
text-decoration: none !important;
color: #fff;
}
.m-lib-header\_\_logo-titlelink {
text-decoration: none !important;
color: #fff;
}
.m-lib-header\_\_logo-titlelink:hover {
text-decoration: none !important;
color: #fff;
}
@media (min-width: 576px) {
.m-lib-header\_\_logo-titlelink {
display: inline-block;
margin-left: 20px;
}
}
.m-lib-header\_\_navs--tablet {
display: none;
}
@media (min-width: 576px) {
.m-lib-header\_\_navs--tablet {
display: flex;
flex: 1;
justify-content: flex-end;
}
}
@media (min-width: 992px) {
.m-lib-header\_\_navs--tablet {
justify-content: space-between;
}
}
.m-lib-header\_\_navs-item {
margin-left: 32px;
}
.m-lib-header\_\_navs-item:first-child {
margin-left: 0;
}
.m-lib-header\_\_navs-item .m-link {
color: #fff;
font-weight: 400;
}
.m-lib-header\_\_navs-item .m-link\_\_content {
text-decoration: none;
}
.m-lib-header\_\_navs-item .m-link:hover {
color: #141414;
}
@media (min-width: 768px) {
.m-lib-header\_\_navs-item .m-link:hover {
color: #fff;
}
}
.m-lib-header\_\_navs-link {
border-bottom: 2px solid #141414;
color: #fff;
font-family: "Apercu", Helvetica, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;
text-decoration: none;
}
.m-lib-header\_\_navs-link:hover {
border-color: #fff;
}
.m-lib-header\_\_navs--primary-navs {
display: none;
}
@media (min-width: 992px) {
.m-lib-header\_\_navs--primary-navs {
display: flex;
justify-content: space-between;
}
}
@media (min-width: 768px) {
.m-lib-header\_\_navs--global-navs {
display: flex;
justify-content: space-between;
}
}
.m-lib-header\_\_mobile {
background: #fff;
display: none;
padding: 20px;
}
@media (max-width: 991px) {
.m-lib-header\_\_mobile {
display: block;
}
}
.m-lib-header\_\_mobile-pane {
position: absolute;
transform-origin: left top;
transform: scaleY(0);
margin-top: 0px;
z-index: 99910;
width: 100%;
}
@media (min-width: 768px) {
.m-lib-header\_\_mobile-pane {
top: 132px;
width: 30vw;
}
}
.m-lib-header\_\_mobile .m-lib-header\_\_navs {
border-top: 1px solid #d2d2d2;
padding-top: 20px;
margin-top: 20px;
}
.m-lib-header\_\_mobile .m-lib-header\_\_navs:first-child {
border-top: 0 none;
padding-top: 0;
margin-top: 0;
}
.m-lib-header\_\_mobile .m-lib-header\_\_navs-item {
padding-top: 20px;
margin: 0;
}
.m-lib-header\_\_mobile .m-lib-header\_\_navs-item:first-child {
padding-top: 0;
}
.m-lib-header\_\_mobile .m-lib-header\_\_navs-item .m-link {
color: #ce3d20;
}
.m-lib-header\_\_mobile .m-lib-header\_\_navs-link {
border-bottom: 2px solid #fff;
color: #141414;
font-size: 16px;
font-weight: 600;
line-height: 24px;
text-decoration: none;
transition: all 0.3s;
}
.m-lib-header\_\_mobile .m-lib-header\_\_navs-link:hover {
border-color: #ce3d20;
}
@media (min-width: 768px) {
.m-lib-header\_\_mobile .m-lib-header\_\_navs-global-links {
display: none;
}
}
.m-lib-cultural-wellbeing-link {
background: #40645c;
text-align: center;
}
.m-lib-cultural-wellbeing-link .m-button {
display: inline;
}
.m-lib-cultural-wellbeing-link .m-button\_\_icon-right {
--fill-colour: $colour-brand-white !important;
fill: #fff !important;
position: relative;
left: 0;
top: 2px;
transition: left 0.2s;
}
.m-lib-cultural-wellbeing-link .m-button:hover .m-button\_\_icon-right {
transition: left 0.2s;
left: 6px;
}
.m-lib-cultural-wellbeing-link .m-button\_\_content {
font-weight: 400;
}
#skiptocontent a {
padding: 5px;
position: fixed;
top: -40px;
left: 0px;
color: white;
border-right: 1px solid white;
border-bottom: 1px solid white;
border-bottom-right-radius: 8px;
background: #ce3d20;
transition: top 0.5s ease-out;
z-index: 100;
}
#skiptocontent a:focus {
left: 0px;
top: 0px;
outline-color: transparent;
transition: top 0.05s ease-in;
}
/\* Recollect custom mobile integration code \*/
@media (max-width: 790px) {
.m-logo {
margin-left: 20px;
}
.m-lib-header {
width: auto;
}
}
# Donovan's Insects
Details
Collection Description
This collection brings together Edward Donovan’s trilogy of illustrated works on exotic insects, published in London between 1798 and 1805. It's Known as the *Epitome series* and represent some of the earliest systematic studies of insects from Asia and the Pacific. The first volume, *Insects of China* (1798), introduced species based on specimens linked to George Macartney’s embassy. The second, *Insects of India ...* (1800), was the first European entomology publication devoted to India. The third, *Insects of New Holland ...* (1805), focused on Australasia and the Pacific and is considered the first work dedicated exclusively to Australian insects.
Privately printed by T. Bensley and sold by subscription through leading London booksellers, these works combined scientific classification under Linnaean taxonomy with remarkable artistry. Donovan, with possible assistance, engraved and hand-coloured each plate, applying rich pigments and decorative techniques such as burnished highlights, albumen overglazes, and metallic paints, which lent the illustrations a distinctive and highly refined appearance.
His research drew on specimens from major collections, including those associated with Sir Joseph Banks and voyages of James Cook, as well as his own museum—the London Museum and Institute of Natural History—which operated from 1807 until its closure in 1817.
Explore each digitised volume in full:
- [An Epitome of the Natural History of the Insects of China](https://digital.library.sydney.edu.au/nodes/view/8233) (1798)
- [An Epitome of the Natural History of the Insects of India and the Islands in the Indian Seas](https://digital.library.sydney.edu.au/nodes/view/8274) (1800)
- [An Epitome of the Natural History of the Insects of New Holland, New Zealand, New Guinea, Otaheite, and other islands in the Indian, Southern, and Pacific Oceans](https://digital.library.sydney.edu.au/nodes/view/8232) (1805)
Collection SummaryDonovan's illustrations were the first European recordings of the entomology of India and Australia.
\
\
\
\
Text
[\
An epitome of the natural history of the insects of China](https://digital.library.sydney.edu.au/nodes/view/8233)
[\
An epitome of the natural history of the insects of India, and the islands in the Indian Seas](https://digital.library.sydney.edu.au/nodes/view/8274)
[\
An epitome of the natural history of the insects of New Holland, New Zealand, New Guinea, Otaheite, and other islands in the Indian, Southern, and Pacific Oceans](https://digital.library.sydney.edu.au/nodes/view/8232)
Collections[The natural world](https://digital.library.sydney.edu.au/nodes/view/15136)
*Donovan's Insects*. University of Sydney Library, accessed 10/03/2026, https://digital.library.sydney.edu.au/nodes/view/8231
#threedeeCont,
#narImgCont {
background: #ffffff url("/img/ajax-loader.gif") no-repeat center center;
}
#autoplayer {
height: auto;
width: auto;
background: #ffffff url("/img/ajax-loader.gif") no-repeat center center !important;
}
.narImgCont\_close {
margin: 20px;
position: fixed;
}
span.marker {
background-color: #ffff00;
}
@media only screen and (max-width: 790px) {
#viewport.pdf {
display: block;
height: auto !important;
}
.pdf iframe {
display: block;
height: 100vh !important;
}
}
span.xsmall {
font-size: 12px;
}
.xhide {
display: none;
}
#gridtools {
display: none;
margin: 8px;
white-space: nowrap;
}
#eddy,
#eddyGrid {
display: inline-block;
}
.button {
border-radius: 5px;
}
a.disableClick {
color: #888888;
background-color: #cccccc;
border-color: #cccccc;
cursor: default;
pointer-events: none;
}
.form\_validation\_message {
color: red;
opacity: 0;
}
.error\_form {
border: 1px solid red;
outline: none;
}
.submit input:disabled {
background: #b9b9b9;
border: #b9b9b9;
}
/\* BB COSA-1412\*/
#jumpto ul {
z-index: 99;
}
/\* BB R1X-3135\*/
div#buttonsFullMonty {
float: left;
display: none;
}
div#buttonsFullMonty input {
vertical-align: -webkit-baseline-middle;
}
div#ocrbar.fullmonty {
position: absolute !important;
width: calc(100% - 110px);
z-index: 98 !important;
}
div#viewport.fullmonty {
position: relative;
z-index: 98 !important;
}
#ocrbar {
display: block;
}
div#ocrbar.tinymonty {
display: none !important;
}
.vscancolor {
color: orange !important;
font-size: 28px;
}
@media only screen and (max-width: 790px) {
html body #ocrbar {
display: none !important;
}
}
/\* BB R1X-3135 - toggle asset/text full screen\*/
$("#toggleFullText").change(function() {
transcriptionBlock.toggleFullText($(this));
});
$("#toggleFullAsset").change(function() {
transcriptionBlock.toggleFullAsset($(this));
});
var gridTable = '';
$('img.kaboom').css({
cursor: 'pointer'
}).on('click', function() {
var img = $(this);
//var url = location.origin;
var url = '';
var close = $('<span class="narImgCont\_close close-icon" ></span>');
var bigImg = $('<img />').css({
'max-width': '100%',
'max-height': '100%',
'height': 'auto',
'width': 'auto',
'display': 'inline'
});
bigImg.attr({
//src: img.attr('src'),
src: "/assets/display/" + img.attr('id') + "-max",
alt: img.attr('alt'),
title: img.attr('title')
});
var over = $('<div />').text(' ').css({
'height': '100%',
'width': '100%',
'background': 'rgba(0,0,0,.82)',
'position': 'fixed',
'top': 0,
'left': 0,
'padding': '20px',
'opacity': 0.0,
'cursor': 'pointer',
'z-index': '9999',
'text-align': 'center'
}).append(bigImg, close).bind('click', function() {
$(this).fadeOut(300, function() {
$(this).remove();
$('div#viewport').css('z-index', 'initial');
});
}).insertAfter(this).animate({
'opacity': 1
}, 300);
$('div#viewport').css('z-index', '4');
});
/\*\*
\* Pops up the Page Hits highlighting window.
\* @author WR
\*/
function popupPageHits() {
$("#searchresultsdiv").dialog({
width: 300,
height: 400,
resizable: true,
title: "Search Result Page Hits",
position: {
my: "right top",
at: "right top",
of: "#viewport"
}
});
lazyImages();
}
// Exact phrase match search has highlights.
if (overrideShowHitsPopup === 'yes') {
// Automatically show the popup on page load.
popupPageHits();
}
/\*
\* Refactoring Note:
\* The function 'initPop(idx)' (responsible for displaying OCR/Transcription results on Page load as default behaviour)
\* is moved to 'recollect3.js' as 'showOcrTranscriptionOnPageLoad(idx, texttype, textedit, textview)' to improve modularity
\* and separation of concerns.This change helps in maintaining and testing the OCR functionality independently.
\*/
if (texttype !== 'METADATA') {
console.log("T-type: " + texttype);
idx = transcriptionBlock.getPageHash();
console.log("T-idx: " + idx);
//Show default view (ORC/Transcript) on page load
transcriptionBlock.showOcrTranscriptionOnPageLoad(idx, texttype, textedit, textview)
var popLoaded = 1;
}
//@ST COSA-1324 : 2020-01-13. Function for image tag form validation.
function getFormValidation(obj, value, userLevel) {
// Old pattern that was creating issues with comma, see below
// var patternOld = /['<','>','&']/;
// Changed to new regex that accepts comma and still denies other characters https://recollectnz.atlassian.net/browse/R1X-6281
var pattern = /[<>&]/;
if (userLevel != "Administrator") {
if (pattern.test(value)) {
obj.previousElementSibling.style.opacity = 1;
$('.newrec').addClass('error\_form');
$('.submit')[1].children[0].setAttribute("disabled", "disabled");
} else {
obj.previousElementSibling.style.opacity = 0;
$('.newrec').removeClass('error\_form');
$('.submit')[1].children[0].removeAttribute("disabled");
} // if ENDS
} // if ENDS
} // function ENDS
$(document).ready(function() {
// @ST timeline script
var embed;
if (document.getElementById('timeline-embed') !== null) {
embed = document.getElementById('timeline-embed');
//embed.style.height = getComputedStyle(document.body).height;
window.timeline = new TL.Timeline('timeline-embed', Array, {
hash\_bookmark: false
});
window.addEventListener('resize', function() {
var embed = document.getElementById('timeline-embed');
//embed.style.height = getComputedStyle(document.body).height;
timeline.updateDisplay();
});
}
});
(function() {
//if it doesn't have "#back-forward" block set null
var $el = document.getElementById("back-forward") || null;
//if page doesn't have this element break function
if (!$el) return;
//small helpers
const getNewObj = (k, v) => {
return {
[k]: v
}
};
const parseReq = (str) => str.replace("?", "&").split("&").map(e => e.split("=")).filter(e => e[0] != "").map(e => getNewObj(e[0], e[1]));
const getValue = (obj) => Object.values(obj);
//encode array of the elements
var encoding = function(str) {
var result;
try {
result = btoa(unescape(encodeURIComponent(str)));
} catch (e) {
console.error("Error on ENCODING FUNCTION." + e);
}
return result;
}
//decode string
var decoding = function(str) {
var result;
try {
result = decodeURIComponent(escape(atob(decodeURIComponent(str))));
} catch (e) {
console.error("Error on DECODING FUNCTION." + e);
}
return result;
}
//parse string
var jsonParse = function(param) {
var result;
try {
result = JSON.parse(param);
} catch (e) {
console.error("Error on JSON PARSE FUNCTION." + e);
}
return result;
}
//XSS protection
var encodingHtmlEntities = function(str) {
return String(str).replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); //.replace(/&/g, '&')
}
//get localStorageKey from URL
const localStorageKey = parseReq(window.location.search).filter(e => Object.keys(e) == "lsk");
const otherKeys = parseReq(window.location.search).filter(e => Object.keys(e) != "lsk");
let searchParam = "";
otherKeys.forEach(e => {
searchParam += "&" + Object.keys(e) + "=" + Object.values(e);
});
//if don't have a key in URL break function
if ((localStorageKey && localStorageKey.length === 0)) return;
//get key from string
const KEY = localStorageKey[0].lsk;
//this key doesn't have a data break function
if (!window.localStorage.getItem(KEY) && !window.sessionStorage.getItem(KEY)) return;
var cleanLocalStorage = function() {
for (let key in window.sessionStorage) {
if ((key != KEY) && (key != "\_" + KEY)) {
window.sessionStorage.removeItem(key);
}
}
}
if (Object.keys(window.sessionStorage).length > 1) {
cleanLocalStorage();
}
//return current ID
var getCurrentId = function() {
let path = window.location.pathname.split('/');
return path[path.length - 1];
}
//get position of element in an array
var getPositionInArray = function(sessionStorage) {
for (let i = 0; i < sessionStorage.length; i++) {
if (Object.keys(sessionStorage[i])[0] == getCurrentId()) {
return i;
}
}
return 0;
}
//get range
var ss\_getRange = function(sessionStorage) {
const array = jsonParse(decoding(sessionStorage));
let position = Number(getPositionInArray(array));
return range = {
prev: array[position - 1] ? array[position - 1] : {},
current: array[position] ? array[position] : {},
next: array[position + 1] ? array[position + 1] : {},
position
}
}
//generate object of position, index, page and length
var getPosition = function() {
let arr = jsonParse(decoding(currentStorage.searchSet));
let position = {
page: currentStorage.page,
index: getPositionInArray(arr),
length: arr.length
};
return position;
}
var getByPosition = function(array, idx) {
return jsonParse(decoding(array))[idx];
}
if (!window.sessionStorage.getItem(KEY)) {
window.sessionStorage.setItem("\_" + KEY, window.localStorage.getItem(KEY));
window.localStorage.removeItem(KEY);
}
//get initial information from LocalStorage
const searchResult = jsonParse(decoding(window.sessionStorage.getItem("\_" + KEY)));
const itemsSet = searchResult.itemsSet;
const searchReq = decoding(searchResult.request);
const pageCount = jsonParse(searchResult.pageCount);
const countElem = jsonParse(searchResult.countElem);
//set local variable
let perPage = jsonParse(searchResult.perPage);
let requestWasSent = false;
//SESSION SECTION
let sessionKey = KEY;
//get sessionStorage by key, if it's not exist set null
let sessionStorage = window.sessionStorage.getItem(sessionKey) || null;
let sessionItemSet = "";
if (sessionStorage) {
sessionItemSet = JSON.parse(sessionStorage).searchSet;
} else {
sessionItemSet = itemsSet;
}
//create local state
let currentStorage = {
page: jsonParse(searchResult.currentPage),
prevSearchSet: "",
searchSet: sessionItemSet,
nextSearchSet: "",
current: ss\_getRange(itemsSet).current,
prev: ss\_getRange(itemsSet).prev,
next: ss\_getRange(itemsSet).next,
position: ss\_getRange(itemsSet).position
}
var setSessionStorage = function() {
window.sessionStorage.setItem(sessionKey, JSON.stringify(currentStorage))
}
//if sessionStorage empty set it with initialState of currentStorage
//if sessionStorage has this key update it with new value
if (!sessionStorage) {
let range = ss\_getRange(itemsSet);
setSessionStorage();
pageNumber = searchResult.currentPage;
} else {
let currentArray = jsonParse(sessionStorage).searchSet;
let currentPage = jsonParse(sessionStorage).page;
let currentRange = ss\_getRange(currentArray);
currentStorage.page = jsonParse(sessionStorage).page;
// currentStorage.current = ss\_getRange(itemsSet).current;
// currentStorage.prev = ss\_getRange(itemsSet).prev;
// currentStorage.next = ss\_getRange(itemsSet).next;
// currentStorage.position = ss\_getRange(itemsSet).position;
currentStorage.current = ss\_getRange(jsonParse(sessionStorage).searchSet).current;
currentStorage.prev = ss\_getRange(jsonParse(sessionStorage).searchSet).prev;
currentStorage.next = ss\_getRange(jsonParse(sessionStorage).searchSet).next;
currentStorage.position = ss\_getRange(jsonParse(sessionStorage).searchSet).position;
currentStorage.prevSearchSet = jsonParse(sessionStorage).prevSearchSet;
currentStorage.nextSearchSet = jsonParse(sessionStorage).nextSearchSet;
if (currentStorage.position === 0 && currentStorage.prevSearchSet != "") {
let prevSet = currentStorage.prevSearchSet;
currentStorage.prev = getByPosition(prevSet, jsonParse(decoding(prevSet)).length - 1);
}
if (currentStorage.position === jsonParse(decoding(currentArray)).length - 1 && currentStorage.nextSearchSet != "") {
let nextSet = currentStorage.nextSearchSet;
currentStorage.next = getByPosition(nextSet, 0);
}
setSessionStorage();
}
let nextPage = currentStorage.page;
//update set of nodes array
var updateLocalStorage = function(data, searchReq, pageNum) {
let newitemsSet = data.nodes.map(e => e.Node).map(e => {
let x = {
[e.id]: e.title
};
return x;
});
let newSet = encoding(JSON.stringify(newitemsSet));
let range = ss\_getRange(currentStorage.searchSet);
if (currentStorage.position == 0) {
currentStorage.prev = getByPosition(newSet, newitemsSet.length - 1);
currentStorage.prevSearchSet = newSet;
}
if (currentStorage.position == (jsonParse(decoding(currentStorage.searchSet)).length - 1) && jsonParse(decoding(currentStorage.searchSet)).length > 1) {
currentStorage.next = getByPosition(newSet, 0);
currentStorage.nextSearchSet = newSet;
}
setSessionStorage();
createButtonsBlock();
}
var sendRequest = function(direction) {
let pageNum = 1;
if (direction.page == 1) {
pageNum = direction.index == 0 ? 1 : (Number(direction.page) + 1);
} else if (direction.page > 1 && direction.page < pageCount) {
pageNum = direction.index == 0 ? (Number(direction.page) - 1) : (Number(direction.page) + 1);
} else {
pageNum = direction.index == 0 ? (Number(direction.page) - 1) : pageCount;
}
const regex = /(page=\d\*)/ius;
let otherReq = searchReq != "" ? (regex.test(searchReq)) ? searchReq.replace(regex, `page=${pageNum}`) : `${searchReq}&page=${pageNum}` : `?page=${pageNum}`;
let newRequest = (searchReq != "" && regex.test(searchReq)) ? searchReq.replace(regex, `page=${pageNum}`) : otherReq;
$.get('/nodes/search\_result/1' + newRequest, data => updateLocalStorage(data, newRequest, pageNum));
}
var getNewArrayOfIds = async function(position) {
if (position.index != 0 && position.index != position.length - 1) {
return;
}
if (((Number(position.index) == position.length - 1) && (Number(position.page) < pageCount)) ||
((Number(position.index) == 0) && (Number(position.page) > 1 && Number(position.page) <= pageCount))) {
if (!requestWasSent) {
await sendRequest(position);
requestWasSent = true;
}
}
}
var getURL = function(pathname = false) {
if (pathname) {
return window.location.origin + window.location.pathname;
}
return window.location.origin;
}
var getParam = function() {
return window.location.search
}
// Added directionForAria - to allow a screen reader to announce 'next item:item title.'
// Unsure if it's safe to change the exisiing data-dir for this - it may be referenced somewhere else.
var createBtn = function(id, title, direct, directionForAria) {
return `<span>
<a href="${getURL()}/nodes/view/${id}?lsk=${KEY}${searchParam}" aria-label='${directionForAria} Item:${title}' title="${encodingHtmlEntities(title)}" data-dir='${direct}'><i class='fa fa-chevron-${direct}'></i></a>
</span>`;
}
var createButtonsBlock = function() {
let rangePrev = Object.keys(currentStorage.prev).length > 0 ? currentStorage.prev : 0;
let rangeNext = Object.keys(currentStorage.next).length > 0 ? currentStorage.next : 0;
let prev = rangePrev != 0 ? rangePrev : "none";
let next = rangeNext != 0 ? rangeNext : "none";
let prevBtn = "<a href='#' style='pointer-events: none;'><i class='fa fa-chevron-left'></i></a>";
let nextBtn = "<a href='#' style='pointer-events: none;'><i class='fa fa-chevron-right'></a>";
if (prev != "none") {
prevBtn = createBtn(Object.keys(prev), Object.values(prev), "left", "Previous");
prevId = Object.keys(prev);
}
if (next != "none") {
nextBtn = createBtn(Object.keys(next), Object.values(next), "right", "Next");
nextId = Object.keys(next);
}
let pos = getPosition();
getNewArrayOfIds(pos);
let arrCount = perPage > 0 ? perPage : 24;
let searchPos = Number(pos.page) == 1 ? (pos.index + 1) : (((Number(pos.page) - 1) \* arrCount) + (pos.index + 1));
$el.innerHTML = `<div class="nav-btn left-btn">${prevBtn}</div>
<div class="nav-btn result-btn">Result ${searchPos} from ${countElem}</div>
<div class="nav-btn bingo right-btn">${nextBtn}</i></div>`;
$('[data-dir="left"]').one('click', () => {
if (pos.index == 0) {
nextPage = currentStorage.page - 1;
}
});
$('[data-dir="right"]').one('click', () => {
if (pos.index == pos.length - 1) {
nextPage = currentStorage.page + 1;
}
});
}
createButtonsBlock();
window.addEventListener('beforeunload', (event) => {
// DF 2023-02-15 R1X-8549 Should not call event.preventDefault() if we don't want
// to propmt the "Are you sure you want to leave the page"-dialog.
if (window.sessionStorage.getItem(sessionKey)) {
if (currentStorage.nextSearchSet != "" || currentStorage.prevSearchSet != "") {
if (currentStorage.page != 1 || currentStorage.page != pageCount) {
if (nextPage > currentStorage.page) {
currentStorage.prevSearchSet = currentStorage.searchSet;
currentStorage.searchSet = currentStorage.nextSearchSet;
currentStorage.nextSearchSet = "";
currentStorage.next = {};
}
if (currentStorage.page > nextPage) {
currentStorage.nextSearchSet = currentStorage.searchSet;
currentStorage.searchSet = currentStorage.prevSearchSet;
currentStorage.prevSearchSet = "";
currentStorage.prev = {};
}
currentStorage.page = nextPage;
}
}
setSessionStorage();
}
}, {
once: true
});
//TO HIDE PARAMS. IT REMOVES PARAMS FROM URL
// history.pushState("", null, getURL(true));
})()
#back-forward {
display: flex;
width: 100%;
max-width: 100%;
justify-content: space-between;
box-sizing: border-box;
/\* margin: 5px 0 5px 5px; \*/
border-radius: 4px;
}
.nav-btn {
padding: 5px;
background-color: #f0f0f0;
}
.left-btn {
border-radius: 2px 0 0 2px;
background-color: #fff;
border: 1px solid #e5e5ee;
}
.right-btn {
border-radius: 0 2px 2px 0;
background-color: #fff;
border: 1px solid #e5e5ee;
}
.result-btn {
/\* font-size: 1.1em;
font-weight: 700; \*/
width: 100%;
border-top: 1px solid #e5e5ee;
border-bottom: 1px solid #e5e5ee;
text-align: center;
}
#dialog-clone-form {
display: none;
}