forked from nicolas-raoul/Anki-Android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard_template.html
62 lines (60 loc) · 1.47 KB
/
card_template.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<html>
<head>
<link rel="stylesheet" type="text/css" href="file:///android_asset/flashcard_css" />
<script type="text/javascript">
function init() {
var imgs = document.getElementsByTagName('img');
var n = imgs.length;
while (n--) {
var img = imgs[n];
if(img.src != "file:///android_asset/media_playback_start2.png")
{
addEvent(img, 'load', resizeImage);
}
}
}
function addEvent(obj, ev, fn) {
if (obj.addEventListener) {
obj.addEventListener(ev, fn, false);
} else if (obj.attachEvent) {
obj.attachEvent('on' + ev, fn);
}
}
function resizeImage(e)
{
if (!e) var e = window.event;
var img = e.currentTarget || e.srcElement;
availableWidth = window.ankidroid.getAvailableWidth();
var newImg = new Image();
newImg.src = img.src;
var imageHeight = newImg.height;
var imageWidth = newImg.width;
if(imageHeight != 0 && imageWidth != 0)
{
if(imageWidth > availableWidth)
{
var scaleFactor = imageWidth / availableWidth;
imageHeight = imageHeight / scaleFactor;
imageWidth = imageWidth / scaleFactor;
}
img.height = imageHeight;
img.width = imageWidth;
}
else
{
img.height = 0;
img.width = 0;
img.src = img.src;
}
}
</script>
<style>::style::</style>
</head>
<body class="mobile">
<span class="card">::content::</span>
<script type="text/javascript">
init();
window.location.href = "#question"
</script>
</body>
</html>