Skip to content

Commit

Permalink
Search no longer re-runs when advanced dialog opens
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimon committed Jun 23, 2022
1 parent 3635d1b commit 1b70673
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 26 deletions.
50 changes: 50 additions & 0 deletions public/annotorious.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Annotorious | Geotagging Widget</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@recogito/[email protected]/dist/annotorious.min.css">
<script src="https://cdn.jsdelivr.net/npm/@recogito/[email protected]/dist/annotorious.min.js"></script>
</head>
<body>
<div id="content">
<img id="image" src="Epitome_theatri_Ortelianii.jpg">
</div>
</div>
<script>
window.onload = function() {
// Geotagging widget config
const config = {
tileUrl: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
defaultOrigin: [ 48, 16 ],
// defaultZoom: 12
search: 'osm'
}

anno = Annotorious.init({
image: 'image',
widgets: [
{ widget: recogito.GeoTagging(config) },
{ widget: 'COMMENT' },
{ widget: 'TAG', vocabulary: [ 'Animal', 'Building', 'Waterbody'] }
]
});

anno.on('createAnnotation', function (annotation) {
console.log('created', annotation);
});

anno.on('updateAnnotation', function(annotation, previous) {
console.log('updated', previous, 'with', annotation);
});

anno.on('deleteAnnotation', function(annotation) {
console.log('deleted', annotation);
});

anno.loadAnnotations('annotations.w3c.json');
}
</script>
</body>
</html>
77 changes: 52 additions & 25 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,76 @@
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Annotorious | Geotagging Widget</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@recogito/[email protected]/dist/annotorious.min.css">
<script src="https://cdn.jsdelivr.net/npm/@recogito/[email protected]/dist/annotorious.min.js"></script>
<title>RecogitoJS | Development</title>
<link href="https://fonts.googleapis.com/css?family=Lato&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/@recogito/[email protected]/dist/recogito.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/@recogito/[email protected]/dist/recogito.min.js"></script>
<style>
html, body {
padding:10px 20px;
margin:0;
}

h1 {
font-size:22px;
margin-top:30px;
margin-bottom:20px;
}

#content {
max-width:920px;
font-family:'Lato', sans-serif;
font-size:17px;
line-height:27px;
}
</style>
</head>
<body>
<div id="content">
<img id="image" src="Epitome_theatri_Ortelianii.jpg">
<div id="content" class="plaintext">
<h1>Homer: The Odyssey</h1>
<p>
<strong>Tell me, O muse,</strong> of that ingenious hero who travelled far and wide after he had sacked
the famous town of Troy. Many cities did he visit, and many were the nations with whose manners and customs
he was acquainted; moreover he suffered much by sea while trying to save his own life and bring his men safely
home; but do what he might he could not save his men, for they perished through their own sheer folly in eating
the cattle of the Sun-god Hyperion; so the god prevented them from ever reaching home. Tell me, too, about all
these things, O daughter of Jove, from whatsoever source you may know them.
</p>
<p>
<strong>So now all who escaped death in battle</strong> or by shipwreck had got safely home except Ulysses,
and he, though he was longing to return to his wife and country, was detained by the goddess Calypso, who
had got him into a large cave and wanted to marry him. But as years went by, there came a time when the gods
settled that he should go back to Ithaca; even then, however, when he was among his own people, his troubles
were not yet over; nevertheless all the gods had now begun to pity him except Neptune, who still persecuted
him without ceasing and would not let him get home.
</p>
</div>
</div>
<script>

<script type="text/javascript">
window.onload = function() {
// Geotagging widget config
const config = {
tileUrl: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
defaultOrigin: [ 48, 16 ],
// defaultZoom: 12
search: 'osm'
}
};

anno = Annotorious.init({
image: 'image',
widgets: [
var r = Recogito.init({
content: 'content',
allowEmpty: true,
widgets: [
{ widget: recogito.GeoTagging(config) },
{ widget: 'COMMENT' },
{ widget: 'TAG', vocabulary: [ 'Animal', 'Building', 'Waterbody'] }
]
});

anno.on('createAnnotation', function (annotation) {
console.log('created', annotation);
r.on('createAnnotation', function(a) {
console.log('created', a);
});

anno.on('updateAnnotation', function(annotation, previous) {
r.on('updateAnnotation', function(annotation, previous) {
console.log('updated', previous, 'with', annotation);
});

anno.on('deleteAnnotation', function(annotation) {
console.log('deleted', annotation);
});

anno.loadAnnotations('annotations.w3c.json');
}
};
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion src/search/SearchInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const SearchInput = props => {

useEffect(() => {
// If there's an initial search, run query
if (search) query();
if (search && props.initialSearch) query();
}, []);

const onKeyDown = evt => {
Expand Down
1 change: 1 addition & 0 deletions src/toolbar/WhenExpanded.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const WhenExpanded = props => {

<div className="r6o-geotagging-toolbar-left">
<SearchInput
initialSearch
config={props.config}
quote={props.quote}
onSearch={props.onSearch} />
Expand Down

0 comments on commit 1b70673

Please sign in to comment.