Skip to content

Commit

Permalink
Merged release/v0.8 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mrwhale committed Sep 5, 2016
2 parents 62aee76 + b5cadca commit ad1da94
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dist.zip

# Ignore installed node modules
node_modules/

testpin.json
# ignore pngs i create
*.png

Expand Down
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,43 @@

Pebble app to display upcoming, live and completed CSGO match details

This app is currently in beta, and the basic functionality works. displays all upcoming CSGO match information,
This app is currently in beta, and the basic functionality works. Displays all upcoming CSGO match information,
as well as completed match information with extra detials listed if you click through (see screenshots for example)

App can be found here:
http://apps.getpebble.com/en_US/application/57c24bc35e3c3db4850002af

This app is built entirely with [pebbleJS](https://pebble.github.io/pebblejs/). If it gets enough liking, I will consider re-writing the watch part in c (so its native, performance and battery boost etc)
Originally written in pebblejs as it was super easy, didnt have to worry about appmessage and could get a prototype up pretty quick

### How to use
1. Install the app!
2. Scroll through the menu to view details!
..* Press the select button on any completed Match to show more details

### Features
* view live, upcoming and completed CSGO match details
* view more information for completed matches
* Pin upcoming matches to your timeline, and be reminded when they start

### screenshots


### Upcoming features in 1.0 release
1. Configuration page
..* Filter results how you want. Choose what tournaments you want to see, what teams you wish to only see, and what type
..* Filter results how you want. Choose what tournaments you want to see, what teams you wish to only see, and what type, and how many
2. Pin upcoming matches to your timeline with long press!
3. Colour!
4. Diorite support (os4.0)

### Feature ideas for later releases
1. Add reminder/timeline pin for live games
2. More filters. Filter the results based on more things
4. List and view team information
3. Statistics. Get team stats
4. Upcoming "card" to show team vs team stats based on previous match ups and percentage to win
5. live match "card" to display current game info.

### How to use
1. Install the app!
2. Scroll through the menu to view details!
..* Press the select button on any completed Match to show more details
### Credits
[pebbleJS](https://pebble.github.io/pebblejs/)

16 changes: 6 additions & 10 deletions appinfo.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"appKeys": {},
"capabilities": [
"configurable"
],
"companyName": "harrysibenaler@gmail.com",
"companyName": "MrWhale",
"longName": "CS on the GO",
"resources": {
"media": [
{
"file": "images/menu_icon.png",
"file": "images/CSontheGO-inverted-icon.png",
"menuIcon": true,
"name": "IMAGE_MENU_ICON",
"type": "bitmap"
},
{
"file": "images/logo_splash.png",
"name": "IMAGE_LOGO_SPLASH",
"type": "bitmap"
"file": "images/CSontheGO-inverted-splash2.png",
"name": "IMAGE_LOGO_CSGO_SPLASH",
"type": "png"
},
{
"file": "images/tile_splash.png",
Expand All @@ -34,8 +31,7 @@
"shortName": "CSontheGO",
"targetPlatforms": [
"aplite",
"basalt",
"chalk"
"basalt"
],
"uuid": "5a4dc87b-bc0a-480d-aade-6dbf5da39e1c",
"versionCode": 1,
Expand Down
63 changes: 62 additions & 1 deletion src/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var UI = require('ui');
var Vector2 = require('vector2');
var timeline = require('./timeline2.js');
//var PIN_ID = "CSontheGOTest";

//todo display messages on errors when cant load etc
// Hysuo65lk
Expand All @@ -21,7 +23,7 @@ var splashWindow = new UI.Window();
var splashImage = new UI.Image({
position: new Vector2(0, 0),
size: new Vector2(144, 168),
image: 'images/logo_splash.png'
image: 'IMAGE_LOGO_CSGO_SPLASH'
})
splashWindow.add(splashImage);
splashWindow.show();
Expand Down Expand Up @@ -404,6 +406,65 @@ detect whta stage its in
wind.show();
});

menu.on('longSelect',function(e){
//on longselect for an upcoming match, lets add a pin to timeline dude
//Only do it for upcoming matches
if(e.sectionIndex === 0 || e.sectionIndex === 2){
return;
}
var pinCard = new UI.Card({
body: 'Adding Pin...'
});
pinCard.show()
//create pin
// Need to make the epoch time into milliseconds to conform to what js needs
var timeMs = json.upcomingMatches[e.itemIndex]['timestamp'] * 1000;
var datePin = new Date(timeMs).toISOString();
console.log("date " + datePin);
//Lets also create the body text here
body = json.upcomingMatches[e.itemIndex]['homeTeam'] + " vs " + json.upcomingMatches[e.itemIndex]['awayTeam'] + "\n" + json.upcomingMatches[e.itemIndex]['tournament'];
var PIN_ID = 'csonthego' + e.itemIndex + timeMs;
var pin = {
'id': PIN_ID,
'time': datePin,
'layout': {
'type': 'genericPin',
'title': json.upcomingMatches[e.itemIndex]['homeNick'] + " vs " + json.upcomingMatches[e.itemIndex]['awayNick'],
'body': body,
'tinyIcon': 'system://images/SCHEDULED_EVENT'
},
"reminders": [
{
"time": datePin,
"layout": {
"type": "genericReminder",
"tinyIcon": 'system://images/SCHEDULED_EVENT',
"title": json.upcomingMatches[e.itemIndex]['homeNick'] + " vs " + json.upcomingMatches[e.itemIndex]['awayNick'] + " match is starting.."
}
}]
};
console.log('Inserting pin in the future: ' + JSON.stringify(pin));

timeline.insertUserPin(pin, function(responseText){

console.log('Result: ' + responseText);
if(responseText === "OK"){
pinCard.body("Successfully added pin!");
//todo lets buzz or do an onscreen notification!
//Add a card with successfully added notification and hide in 3s
setTimeout(function() {
pinCard.hide();
}, 1500);
}else{
//display card with error message :(
pinCard.title("Not successful");
pinCard.body("Did not add because of: " + responseText);
}
});

});


function amReady(){
splashWindow.hide()
menu.show();
Expand Down
86 changes: 86 additions & 0 deletions src/js/timeline2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// The timeline public URL root
var API_URL_ROOT = 'https://timeline-api.getpebble.com/';

/**
* Send a request to the Pebble public web timeline API.
* @param pin The JSON pin to insert. Must contain 'id' field.
* @param type The type of request, either PUT or DELETE.
* @param topics Array of topics if a shared pin, 'null' otherwise.
* @param apiKey Timeline API key for this app, available from dev-portal.getpebble.com
* @param callback The callback to receive the responseText after the request has completed.
*/
function timelineRequest(pin, type, topics, apiKey, callback) {
// User or shared?
var url = API_URL_ROOT + 'v1/' + ((topics != null) ? 'shared/' : 'user/') + 'pins/' + pin.id;

// Create XHR
var xhr = new XMLHttpRequest();
xhr.onload = function () {
console.log('timeline: response received: ' + this.responseText);
callback(this.responseText);
};
xhr.open(type, url);

// Set headers
xhr.setRequestHeader('Content-Type', 'application/json');
if(topics != null) {
xhr.setRequestHeader('X-Pin-Topics', '' + topics.join(','));
xhr.setRequestHeader('X-API-Key', '' + apiKey);
}

// Get token
Pebble.getTimelineToken(function(token) {
// Add headers
xhr.setRequestHeader('X-User-Token', '' + token);

// Send
xhr.send(JSON.stringify(pin));
console.log('timeline: request sent.');
}, function(error) { console.log('timeline: error getting timeline token: ' + error); });
}

/**
* Insert a pin into the timeline for this user.
* @param pin The JSON pin to insert.
* @param callback The callback to receive the responseText after the request has completed.
*/
function insertUserPin(pin, callback) {
timelineRequest(pin, 'PUT', null, null, callback);
}

/**
* Delete a pin from the timeline for this user.
* @param pin The JSON pin to delete.
* @param callback The callback to receive the responseText after the request has completed.
*/
function deleteUserPin(pin, callback) {
timelineRequest(pin, 'DELETE', null, null, callback);
}

/**
* Insert a pin into the timeline for these topics.
* @param pin The JSON pin to insert.
* @param topics Array of topics to insert pin to.
* @param apiKey Timeline API key for this app, available from dev-portal.getpebble.com
* @param callback The callback to receive the responseText after the request has completed.
*/
function insertSharedPin(pin, topics, apiKey, callback) {
timelineRequest(pin, 'PUT', topics, apiKey, callback);
}

/**
* Delete a pin from the timeline for these topics.
* @param pin The JSON pin to delete.
* @param topics Array of topics to delete pin from.
* @param apiKey Timeline API key for this app, available from dev-portal.getpebble.com
* @param callback The callback to receive the responseText after the request has completed.
*/
function deleteSharedPin(pin, topics, apiKey, callback) {
timelineRequest(pin, 'DELETE', topics, apiKey, callback);
}

// Export
module.exports.insertUserPin = insertUserPin;
module.exports.deleteUserPin = deleteUserPin;
module.exports.insertSharedPin = insertSharedPin;
module.exports.deleteSharedPin = deleteSharedPin;

0 comments on commit ad1da94

Please sign in to comment.