creating annotation in mirador programmatically from javascript function - iiif

I am trying to programmatically create an annotation on a canvas in mirador by calling a javascript function outside mirador.
Basically, I have a textual representation of a scanned text that includes descriptions of certain phenomenon on the scan, such as handwritten additions. If the user clicks on that description, I want the phenomenon in question to be highlighted with a box on the specified canvas in an already opened mirador instance mymirador that has several windows showing different scans.
For this, I try to pass the annotation as JSON using the receiveAnnotation action, but the annotation is not displayed at the correct place.
Javascript (added linebreaks for convenience):
function openAnnotationInMirador() {
var item = '{"id": "url-to-canvas/annotation",
"type": "Annotation",
"motivation": "commenting",
"body": {
"type": "TextualBody",
"language": "en",
"value": "Some description"},
"target": "url-to-canvas/#xywh=100,100,200,200"}}';
mymirador.store.dispatch(Mirador.actions.receiveAnnotation('url-to-canvas/annotation', 'url-to-canvas', item));
}
Tha function is triggered by a simple html button with onclick: <button onclick="openAnnotationInMirador()">Mirador Test</button>.
I suspect the JSON to be incorrect, but I am quite at loss here. Any suggestions are very much appreciated!

The third parameter to the receiveAnnotation action creator function has to be a JavaScript object of a WebAnnotation AnnotationPage, with the actual annotation in its items array, in your case:
const annoPage = {
id: 'dummy://my.annotation/page',
type: 'AnnotationPage',
items: [
{
"id": "url-to-canvas/annotation",
"type": "Annotation",
"motivation": "commenting",
"body": {
"type": "TextualBody",
"language": "en",
"value": "Some description"},
"target": "url-to-canvas/#xywh=100,100,200,200"
}
}
]
}
When working with the Redux actions in Mirador, it's very useful to install the Redux DevTools Browser Extension with which you can inspect the actions created by Mirador itself.

Related

How to change a Google Slides presentation theme via Slides API?

This is a duplicate of this question. However, nobody has answered it.
So, how can you change a presentation's theme via the API? Is it even possible? I'm using Java, but that shouldn't affect the API.
Thanks
You can do two things:
Import a scheme from a master when creating your presentation - as suggested in the post you are refering to
Change the exsiting theme with a presentations.batchUpdate UpdatePagePropertiesRequest or UpdateShapePropertiesRequest request:
Thereby you can specify theme colors within the update request.
Sample from the documentation:
{
"requests": [
{
"updateShapeProperties": {
"objectId": copyElementId,
"fields": "shapeBackgroundFill.solidFill.color",
"shapeProperties": {
"shapeBackgroundFill": {
"solidFill": {
"color": {
"themeColor": "LIGHT2"
}
}
}
}
}
}
]
}
References:
Pages, Page Elements, and Properties
Kind of properties
ThemeColorType
ColorScheme
PageProperties
PredefinedLayout

'requiresSelection' proprety not working for object page action extension?

For different facets in object page in List Report, when I add any custom action and add property "requiresSelection" to true, action remains disabled.
Tried adding below code in manifest.json
"Sections": {
"to_PDL::com.sap.vocabularies.UI.v1.LineItem": {
"id": "to_PDL::com.sap.vocabularies.UI.v1.LineItem",
"Actions": {
"TestAction_Deactivate": {
"id": "TestAction_Deactivate",
"text": "Deactivate",
"press": "onDeactivate",
"requiresSelection" : true
}
}
}
}
In the official SAP docu it says for property :
“Property that indicates whether the action requires a selection of items (true) or not (false). The default value is true.”
This means, that first you have to select a row in the table. Then the action becomes enabled.
Does it work for you this way?

Reading Remote JSON and Getting Image from URL

In my iOS app I am trying to read in a JSON file and populate a table with its contents. Below is a sample of the JSON file.
Presently, I am reading the JSON into a mutable array called “items” and then populating the table cells like this.
// Populate the cell
if let showName = self.items[indexPath.row]["Show"] as? NSString {
cell.textLabel!.text = showName as! String
I would like to have the image for each JSON record appear in the cell as well and that is where I am getting tripped up.
I have the URL to the image but how do I get it into the table cell?
My entire approach may be wrong so I would appreciate being pointed in the right direction.
{
"shows": [{
"Day": "Sunday",
"Time": "12am",
"Show": “Show Name Here",
"imgPath": "http://remoteserver/image.jpg"
}, {
"Day": "Sunday",
"Time": "1am",
"Show": "Show Name Here",
"imgPath": “http://remoteserver/image.jpg"
}, {
"Day": "Sunday",
"Time": "2am",
"Show": "Show Name Here",
"imgPath": http://remoteserver/image.jpg"
}
I'd recommend using a library like SDWebImage for this. That will provide you with methods for loading an image into an imageview asynchronously, and let you set a placeholder while the image is downloading.
You can set an image from a url like this (copied from SDWebImage docs):
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:#"http://www.domain.com/path/to/image.jpg"]
placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
More info here: https://github.com/rs/SDWebImage
Apple has a example project for this using RSS. LazyTableImages This code is not in swift but will show exactly how apple handled this.
The problem it sounds like you are having is cells are being reused and your image is not being cleared or are being added to a reused cell.

JSON and Main.storyboard - swift 2

I want to create a website blocking app where parents can block any website they want by typing the link or any tags into UITextField. I can't work out how to have the user enter the links/tags into a UITextField ( i only know how to manually add the links/tags by accessing the .JSON file
in the code.
Any help would be appreciated,
thx,
Noja
P.S. The below code is in the .JSON file
[
{
"action": {
"type": "block"
},
"trigger": {
"url-filter": "example"
}
}
]

Pass ViewController's data to HTML file in Highcharts

I successfully loaded highcharts on iPad with static data. I want to pass dynamic data in from my ViewController to HTML file prepared for loading highcharts's script.
How can I pass the dynamic data? Please guide me for the same.
PS: I checked stackoverflow tutorials to pass dynamic data but none of them is talking about passing the data from ViewController to html file.
You can get data by ajax, like in the example:
http://jsfiddle.net/vw79L/
$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) {
// Create the chart
$('#container').highcharts({
rangeSelector : {
selected : 1
},
title : {
text : 'AAPL Stock Price'
},
series : [{
name : 'AAPL',
data : data,
tooltip: {
valueDecimals: 2
}
}]
});
});

Resources