-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipsum-everything.js
65 lines (59 loc) · 1.74 KB
/
ipsum-everything.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
;(function($, window, document, undefined) {
$.fn.ipsum = function(options) {
var defaults = {paras: 1, type: "hipster-latin"},
self = this,
url = "";
options = $.extend({}, defaults, options);
switch(options.type.toLowerCase()) {
case "hipster":
url = "http://hipsterjesus.com/api/?paras=";
break;
case "hipster-centric":
url = "http://hipsterjesus.com/api/?type=hipster-centric¶s=";
break;
case "bacon":
url = "https://baconipsum.com/api/?type=meat-and-filler¶s=";
break;
case "bacon-all-meat":
url = "https://baconipsum.com/api/?type=all-meat¶s=";
break;
case "skate":
url = "https://jsonp.nodejitsu.com/?callback=?&url=http://skateipsum.com/get/";
break;
case "baseball":
url = "https://jsonp.nodejitsu.com/?callback=?&url=http://baseballipsum.apphb.com/api/?paras=";
break;
case "pony":
url = "http://ponyipsum.com/api/?type=pony-and-filler¶s=";
break;
case "all-pony":
url = "http://ponyipsum.com/api/?type=all-pony¶s=";
break;
case "science":
url = "https://jsonp.nodejitsu.com/?callback=?&url=http://scienceipsum.com/api/paragraphs/";
}
url += options.paras;
if (options.type.toLowerCase() === "skate") {
url += "/0/JSON";
}
$.getJSON(url, function(data) {
var output = "";
switch (options.type.toLowerCase()) {
case "hipster":
case "hipster-centric":
output = data.text;
break;
case "science":
for (var i = 0; i < data.paragraphs.length; i++) {
output += "<p>" + data.paragraphs[i] + "</p>";
}
break;
default:
for (var j = 0; j < data.length; j++) {
output += "<p>" + data[j] + "</p>";
}
}
self.html(output);
});
};
})(jQuery, window, document);