-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
72 lines (59 loc) · 1.74 KB
/
main.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
$.ajaxSetup({
error:function(x,e,errorThrown) {
console.log(x.getStatusCode());
$("#status").prepend("Error!");
}
});
//EDIT THESE LINES
//Title of the blog
var TITLE = "Мобильный форум";
//RSS url
var RSS = "http://www.mforum.ru/rss/news.xml";
//Stores entries
var entries = [];
var selectedEntry = "";
//listen for detail links
$(".contentLink").live("click", function() {
selectedEntry = $(this).data("entryid");
});
onDeviceReady: function() {
// adbuddiz.setAndroidPublisherKey("a9b7d05a-c791-41b1-a3b0-ca629af013a7");
// adbuddiz.setIOSPublisherKey("TEST_PUBLISHER_KEY_IOS");
// adbuddiz.cacheAds();
// adbuddiz.showAd();
app.receivedEvent('deviceready');
}
//Listen for main page
$("#mainPage").live("pageinit", function() {
//Set the title
$("h1", this).text(TITLE);
$.get(RSS, {}, function(res, code) {
entries = [];
var xml = $(res);
var items = xml.find("item");
$.each(items, function(i, v) {
entry = {
title:$(v).find("title").text(),
link:$(v).find("link").text(),
description:$.trim($(v).find("description").text())
};
entries.push(entry);
});
//now draw the list
var s = '';
$.each(entries, function(i, v) {
s += '<li><a href="#contentPage" class="contentLink" data-entryid="'+i+'">' + v.title + '</a></li>';
});
$("#linksList").html(s);
$("#linksList").listview("refresh");
});
});
//Listen for the content page to load
$("#contentPage").live("pageshow", function(prepage) {
//Set the title
$("h1", this).text(entries[selectedEntry].title);
var contentHTML = "";
contentHTML += entries[selectedEntry].description;
contentHTML += '<p/><a href="'+entries[selectedEntry].link + '">Источник</a>';
$("#entryText",this).html(contentHTML);
});