Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
Quack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
commul
Zeit.shift
Quack
Commits
ce46517c
Commit
ce46517c
authored
11 years ago
by
Toke Eskildsen
Browse files
Options
Downloads
Patches
Plain Diff
Added simple optional multiple URL-specified overlay boxes
parent
805d3a84
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
web/quack.css
+7
-0
7 additions, 0 deletions
web/quack.css
web/quack.js
+62
-1
62 additions, 1 deletion
web/quack.js
with
69 additions
and
1 deletion
web/quack.css
+
7
−
0
View file @
ce46517c
...
...
@@ -116,6 +116,13 @@ div.openseadragon-canvas canvas {
width
:
1px
;
}
.searchresultbox
{
opacity
:
0.8
;
filter
:
alpha
(
opacity
=
40
);
border
:
4px
solid
#3333DE
;
color
:
#3333DE
;
background-color
:
transparent
;
}
.highlight
{
opacity
:
0.4
;
filter
:
alpha
(
opacity
=
40
);
...
...
This diff is collapsed.
Click to expand it.
web/quack.js
+
62
−
1
View file @
ce46517c
...
...
@@ -133,13 +133,74 @@ function outOverlay(overlay) {
removeBackward
(
overlay
,
"
next
"
);
}
// URL parameter parsing
// http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter
function
getRes
()
{
var
input
=
window
.
location
.
href
;
// name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
// var regexS = "/[\\?&]" + name + "=([^&#]*)/g";
// var regex = new RegExp( regexS );
var
regex
=
/
[\\
?&
]
box=
([^
&#
]
*
)
/g
;
var
results
=
[];
var
tokens
;
while
(
tokens
=
regex
.
exec
(
input
))
{
results
.
push
(
decodeURIComponent
(
tokens
[
1
]));
// console.log('Pushing ' + decodeURIComponent(tokens[1]));
}
return
results
;
}
function
createDiv
(
id
,
className
,
content
)
{
var
msgContainer
=
document
.
createElement
(
'
div
'
);
msgContainer
.
id
=
id
;
// No setAttribute required
msgContainer
.
className
=
className
;
// No setAttribute required, note it's "className" to avoid conflict with JavaScript reserved word
msgContainer
.
appendChild
(
document
.
createTextNode
(
content
));
document
.
body
.
appendChild
(
msgContainer
);
return
msgContainer
;
}
// Helper for addResultBoxes that constructs a single box
// 0.036886,0.740071 0.898778x0.108414 I BYEN MED DE KENDTE
var
boxCounter
=
0
;
function
addResultBox
(
boxData
)
{
// console.log('Processing box ' + boxData);
var
parts
=
boxData
.
split
(
'
'
);
var
x
=
parseFloat
(
parts
[
0
].
split
(
'
,
'
)[
0
]);
var
y
=
parseFloat
(
parts
[
0
].
split
(
'
,
'
)[
1
]);
var
w
=
parseFloat
(
parts
[
1
].
split
(
'
x
'
)[
0
]);
var
h
=
parseFloat
(
parts
[
1
].
split
(
'
x
'
)[
1
]);
var
content
=
''
;
for
(
var
i
=
2
;
i
<
parts
.
length
;
i
++
)
{
if
(
i
>
2
)
{
content
+=
'
'
;
}
content
+=
parts
[
i
];
}
console
.
log
(
'
Creating overlay box for x=
'
+
x
+
'
, y=
'
+
y
+
'
, w=
'
+
w
+
'
, h=
'
+
h
+
'
, content=
'
+
content
);
myDragon
.
drawer
.
addOverlay
(
createDiv
(
'
searchresult
'
+
boxCounter
++
,
'
searchresultbox
'
,
content
),
new
OpenSeadragon
.
Rect
(
x
,
y
,
w
,
h
),
OpenSeadragon
.
OverlayPlacement
.
TOP_LEFT
,
''
);
}
// Looks for attributes with the name 'box'. A box contains x,y in relative coordinates,
// width x height i relative coordinates and optional context for the box. Sample:
// 0.036886,0.740071 0.898778x0.108414 I BYEN MED DE KENDTE
function
addResultBoxes
()
{
var
results
=
getRes
();
document
.
title
=
document
.
title
+
'
'
+
results
+
'
(length
'
+
results
.
length
+
'
)
'
;
for
(
var
i
=
0
;
i
<
results
.
length
;
i
++
)
{
addResultBox
(
results
[
i
]);
}
}
function
setupJS
()
{
// TODO: Check if this is an image page and if not, exit immediately
toggleGrid
();
toggleTextBlock
();
toggleBlown
();
addResultBoxes
();
//! Create a callback for eack overlay with the overlay-ID as argument
for
(
var
i
=
0
;
i
<
myDragon
.
overlays
.
length
;
i
++
)
{
id
=
myDragon
.
overlays
[
i
].
id
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment