This repository has been archived by the owner on Aug 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cards.html
161 lines (157 loc) · 6.4 KB
/
cards.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=300, height=500, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>PDF</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/FitText.js/1.1/jquery.fittext.min.js"></script>
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', 'data.json');
xhr.onreadystatechange = function () {
if(xhr.readyState === 4 && xhr.status === 200) {
var data = JSON.parse(xhr.responseText);
var cardHTML = ''; // '<ul class="bulleted">';
// console.log(data.length);
for (var i=0; i<data.length; i += 1) {
// For each card
cardNumber = i+1;
cardHTML += '<div class="card">';
// For each title
cardHTML += '<div class="front"><div class="inner">';
cardHTML += ('<h1>' + data[i].card[0].title + '</h1>');
console.log("Title: " + data[i].card[0].title);
cardHTML += ('<div class="deck">APUSH</div>');
cardHTML += ('<div class="number">' + cardNumber + '</div>');
cardHTML += '</div></div>';
cardHTML += '<div class="back"><div class="inner">';
cardHTML += '<ul>';
// For each item
for (var cardData=0; cardData<(data[i].card.length - 1); cardData += 1) {
if (cardData === 0 ) {} else {
cardHTML += ('<li>' + data[i].card[cardData].line + '</li>');
// console.log(data[i].card.length.length);
console.log("Bullet: " + data[i].card[cardData].line);
}
}
cardHTML += '</ul>';
cardHTML += '</div></div>';
cardHTML += '</div>';
}
// cardHTML += '</ul>';
document.getElementById('cards').innerHTML = cardHTML;
}
};
xhr.send();
</script>
<script>
// jquery-textfill.min.js | v0.6.0
(function(m){m.fn.textfill=function(r){function f(){a.debug&&"undefined"!=typeof console&&"undefined"!=typeof console.debug&&console.debug.apply(console,arguments)}function s(){"undefined"!=typeof console&&"undefined"!=typeof console.warn&&console.warn.apply(console,arguments)}function p(a,b,e,k,n,g){function d(a,b){var c=" / ";a>b?c=" > ":a==b&&(c=" = ");return c}f("[TextFill] "+a+" { font-size: "+b.css("font-sizfe")+",Height: "+b.height()+"px "+d(b.height(),e)+e+"px,Width: "+b.width()+d(b.width(),
k)+k+",minFontPixels: "+n+"px, maxFontPixels: "+g+"px }")}function q(a,b,e,k,f,g,d,h){for(p(a,b,f,g,d,h);d<h-1;){var l=Math.floor((d+h)/2);b.css("font-size",l);if(e.call(b)<=k){if(d=l,e.call(b)==k)break}else h=l;p(a,b,f,g,d,h)}b.css("font-size",h);e.call(b)<=k&&(d=h,p(a+"* ",b,f,g,d,h));return d}var a=m.extend({debug:!1,maxFontPixels:40,minFontPixels:4,innerTag:"span",widthOnly:!1,success:null,callback:null,fail:null,complete:null,explicitWidth:null,explicitHeight:null,changeLineHeight:!1},r);f("[TextFill] Start Debug");
this.each(function(){var c=m(a.innerTag+":visible:first",this),b=a.explicitHeight||m(this).height(),e=a.explicitWidth||m(this).width(),k=c.css("font-size"),n=parseFloat(c.css("line-height"))/parseFloat(k);f("[TextFill] Inner text: "+c.text());f("[TextFill] All options: ",a);f("[TextFill] Maximum sizes: { Height: "+b+"px, Width: "+e+"px }");var g=a.minFontPixels,d=0>=a.maxFontPixels?b:a.maxFontPixels,h=void 0;a.widthOnly||(h=q("Height",c,m.fn.height,b,b,e,g,d));var l=void 0,l=q("Width",c,m.fn.width,
e,b,e,g,d);a.widthOnly?(c.css({"font-size":l,"white-space":"nowrap"}),a.changeLineHeight&&c.parent().css("line-height",n*l+"px")):(g=Math.min(h,l),c.css("font-size",g),a.changeLineHeight&&c.parent().css("line-height",n*g+"px"));f("[TextFill] Finished { Old font-size: "+k+", New font-size: "+c.css("font-size")+" }");c.width()>e||c.height()>b&&!a.widthOnly?(c.css("font-size",k),a.fail&&a.fail(this),f("[TextFill] Failure { Current Width: "+c.width()+", Maximum Width: "+e+", Current Height: "+c.height()+
", Maximum Height: "+b+" }")):a.success?a.success(this):a.callback&&(s("callback is deprecated, use success, instead"),a.callback(this))});a.complete&&a.complete(this);f("[TextFill] End Debug");return this}})(window.jQuery);
</script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css">
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lora:400,700italic,700,400italic|Francois+One|Istok+Web:400,700|Crimson+Text:400,700|Sansita+One|Pontano+Sans' rel='stylesheet">
<style>
* {
box-sizing: border-box;
}
body {
font-family: Lora, 'Open Sans', Arial;
max-width: 300px;
overflow-x: hidden;
}
.card .front, .card .back {
position: relative;
width: 300px;
height: 500px;
display: inline-block;
padding: 12px;
/* box-shadow: 0 0 20px gray inset; */
font-size: 20px;
line-height: 1.2em;
oveflow: hidden;
}
.inner, ul {
/* width - padding */
width: 276px;
/* height - padding */
height: 478px;
}
.front {
background: white;
color: black;
}
h1 {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 2.2em;
line-height: 1.2em;
margin-top: 10px;
max-width: 300px;
word-break: keep-all;
word-wrap: break-word;
-webkit-hyphens: auto;
}
.deck {
/* font-family: 'Francois One', cursive; */
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: bold;
position: absolute;
bottom: 20px;
right: 65px;
text-align: center;
font-size: 14px;
line-height: 32px;
}
.number {
font-family: 'Sansita One', cursive;
position: absolute;
bottom: 20px;
right: 20px;
width: 32px;
height: 32px;
border-radius: 50%;
color: white;
background: black;
text-align: center;
font-size: 14px;
line-height: 32px;
}
.back {
background: black;
color: white;
}
ul {
margin-top: 0px;
margin-left: 0px;
padding-left: 0px;
font-size: 15px;
line-height: 1.2em;
}
li {
margin-left: 0px;
margin-bottom: 0.5em;
list-style: none;
}
li:not(:last-child) {
border-bottom: 1px solid lightGray;
padding-bottom: 0.5em;
}
</style>
<script>
$( document ).ready(function() {
setTimeout(function(){
// $(".inner").textfill({innerTag:"ul"});
$(".inner").textfill({innerTag:"h1"});
},2000);
});
</script>
</head>
<body>
<div id="cards">
</div>
</body>
</html>