-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
90 lines (82 loc) · 2.45 KB
/
script.js
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
function wrap(){
html2canvas($(".mag-wrap"), {
onrendered: function(canvas) {
myImage = canvas.toDataURL("image/png");
download(myImage);
}
});
}
function download(a){
$("#downloadLink").html('<a href="'+a+'" download="imaginator.png"><img class="downloadImg" src="https://cdn2.iconfinder.com/data/icons/snipicons/500/download-48.png"/></a>');
}
$('#fancy-text').keyup( function(){
var value = $(this).val();
$('.quote').text(value);
setTimeout(function () {
wrap();
}, 200);
});
$('form').submit(function(e) {
//e.preventDefault;
return false;
});
function randomQuote(){
link = "http://api.forismatic.com/api/1.0/?method=getQuote&key=457653&format=jsonp&lang=en&jsonp=?";
$.getJSON(link, function(json){
$(".quote").html(json.quoteText);
});
}
function randomScheme(){
bg = ['#B71C1C','#F44336','#E91E63','#880E4F','#4A148C','#9C27B0','#673AB7','#311B92','#3F51B5','#1A237E','#fffff','#0D47A1','#03A9F4','#039BE5','#76FF03','#C6FF00','#FBC02D','#FFD600','#FFAB00','#FF6F00','#FF5722'];
font = ['#B71C1C','#F44336','#E91E63','#880E4F','#4A148C','#9C27B0','#673AB7','#311B92','#3F51B5','#1A237E','#fffff','#0D47A1','#03A9F4','#039BE5','#76FF03','#C6FF00','#FBC02D','#FFD600','#FFAB00','#FF6F00','#FF5722'];
bgI = Math.floor((Math.random()*21)+1);
fontI = Math.floor((Math.random()*21)+1);
if(fontI === bgI){
randomScheme();
}
bgChange(bg[bgI]);
quoteChange(font[fontI]);
}
function bgChange(a) {
$(".mag").css('background-color',a);
}
function quoteChange(a){
$(".quote").css('color',a);
}
$(document).ready(function(){
//combination
randomScheme();
randomQuote();
setTimeout(function (){
wrap();
}, 200);
$("#bg").change(function() {
bgColor = $("#bg").val();
bgChange(bgColor);
});
$("#font").change(function() {
fontColor = $("#font").val();
quoteChange(fontColor);
});
$("#random").on('click', function(){
randomQuote();
randomScheme();
setTimeout(function (){
wrap();
}, 200);
});
$("#changeCombination").on('click', function() {
randomScheme();
});
});
//twitter share
! function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
p = /^http:/.test(d.location) ? 'http' : 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + '://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'twitter-wjs');