Skip to content

Modules

Aferdita Muriqi edited this page May 25, 2020 · 2 revisions

R2D2BC

Modules

Bookmarks

<script>
    
    D2Reader.load({
        url: new URL("http....."),
        rights: {
            enableBookmarks: true
        },
        api: {
            addBookmark: function (bookmark) {
                return new Promise(function (resolve, reject) {
                    bookmark.id = Math.random()
                    resolve(
                        bookmark
                    )
                })
            },
            deleteBookmark: function (bookmark) {
                return new Promise(function (resolve, reject) {
                    resolve(
                        bookmark
                    )
                })
            }
        }
    }).then(instance => {
        console.log("D2Reader loaded ", instance);
    }).catch(error => {
        console.error("error.message ", error.message);
    });

</script>

Bookmark API

D2Reader.saveBookmark()

<button onclick="javascript:D2Reader.saveBookmark()">add bookmark</button>

D2Reader.deleteBookmark(<#json#>)

<button onclick="javascript:D2Reader.deleteBookmark({id:123})">delete bookmark</button>

Annotations

<script>
    
    D2Reader.load({
        url: new URL("http....."),
        rights: {
            enableAnnotations: true
        },
        api: {
            addAnnotation: function (highlight) {
                return new Promise(function (resolve, reject) {
                    highlight.id = Math.random()
                    resolve(
                        highlight
                    )
                })
            },
            deleteAnnotation: function (highlight) {
                return new Promise(function (resolve, reject) {
                    resolve()
                })
            },
            selectedAnnotation: function (highlight) {
            		return new Promise(function (resolve, reject) {
                    resolve()
                })
            }
        }
    }).then(instance => {
        console.log("D2Reader loaded ", instance);
    }).catch(error => {
        console.error("error.message ", error.message);
    });

</script>

Annotation API

D2Reader.deleteAnnotation(<#json#>)

<button onclick="javascript:D2Reader.deleteAnnotation({id:123})">delete annotation</button>