forked from baspete/flipstatus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.js
More file actions
71 lines (62 loc) · 1.81 KB
/
Copy pathcustom.js
File metadata and controls
71 lines (62 loc) · 1.81 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
sf.plugins.rss = {
dataType: 'json',
// get tweets
url: function(options){
var base_url = "plugins/rss/parse.php";
// pick up the query from the page URL
var urlString = sf.util.getUrlParam("rss");
console.log("rss:",urlString)
return base_url + "?url=" + urlString;
},
formatData: function(response){
var newResponse = [];
for(var i=0;i<response.results.length;i++){
// console.log("Tweet Data:",response.results[i]);
//
// Get the author
var from_user = response.results[i].from_user;
// Set the status based on the age
var status = "1";
var now = new Date();
var created = new Date(response.results[i].created_at);
var age = Math.round((now - created)/(1000 * 60)); // minutes
if(age < 60){
status = "0";
}
console.log(age < 60)
// set hours and minutes
var hrs = created.getHours();
if(hrs < 10){
hrs = "0"+hrs;
}
var mins = created.getMinutes();
if(mins < 10){
mins = "0"+mins;
}
timestamp = hrs.toString() + mins.toString();
// Split the tweet text into rows and add each row to newResponse[]
// with a timestamp only on the first one
var text = response.results[i].from_user+": "+response.results[i].text;
var rows = sf.util.splitString(text, sf.options.numChars);
for(var j=0;j<rows.length;j++){
var row = {
"timestamp":timestamp,
"text":rows[j],
"status":status
};
timestamp = "";
from_user = "";
status = "";
newResponse.push(row);
}
// Add a blank row between tweets
var blankRow = {
"timestamp":"",
"text":"",
"status":""
}
newResponse.push(blankRow);
}
return newResponse;
}
};