-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemeModel.js
More file actions
47 lines (42 loc) · 1.14 KB
/
Copy pathMemeModel.js
File metadata and controls
47 lines (42 loc) · 1.14 KB
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
MemeGenerator.MemeModel = (function() {
var that = {},
SERVER_URL = "http://132.199.139.24/~baa56852/meme-generator/api/memes.php",
BASEURL = "http://132.199.139.24/~baa56852/meme-generator/memes/",
sample = [];
init = function() {
_getInfoFromServer();
return that;
},
//ajax holt sich vom server informationen
_getInfoFromServer = function () {
$.ajax({
url: SERVER_URL,
type: "GET",
contentType: "text/javascript",
dataType: "jsonp",
success: _processServerResponse
});
},
_processServerResponse = function (data) {
_improveData(data);
_finishSample();
},
//bringt daten in passendes format
_improveData = function (data) {
for (var key in data.memes) {
var sampleElement = {
className: "listElement",
title: data.memes[key].title,
url: BASEURL + data.memes[key].url,
dataUrl: "test2",
};
sample.push(sampleElement);
}
}
//gibt daten weiter an die samplesview
_finishSample = function (event) {
$('body').trigger('onSampleAvailable', [sample]);
};
that.init = init;
return that;
})();