Skip to content

Commit

Permalink
Merge pull request #1 from PokemonGoF/master
Browse files Browse the repository at this point in the history
a
  • Loading branch information
Kijax authored Jul 20, 2017
2 parents 0e4990a + ab1311b commit dea62b7
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 6 deletions.
39 changes: 38 additions & 1 deletion css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ html, body {
cursor: pointer;
line-height: 18px;
}

#close-events {
float: left;
font-size: 16px;
cursor: pointer;
line-height: 18px;
}


.items, .trainerinfo {
overflow-y: scroll;
overflow-x: hidden;
Expand Down Expand Up @@ -134,7 +143,7 @@ html, body {
height: 50vh;
width: 660px;
z-index: 5;
left: 10px;
left: 680px;
bottom: 10px;
}
#logs-panel .card {
Expand All @@ -149,6 +158,34 @@ html, body {
.log-date {
color: #666;
}


#events-panel {
position: fixed;
height: 50vh;
width: 660px;
z-index: 5;
left: 10px;
bottom: 10px;
}
#events-panel .card {
overflow-y: scroll;
height: 100%;
margin: 0;
}
.event-item {
padding: .3em 0 .3em 0;
font-size: 14px;
}
.event-date {
color: #888;
}
.event-type {
color: #666;
display:none;
}


.bot-0 {
background-color: #A93226 !important;
}
Expand Down
18 changes: 18 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
</div>
<br>
</li>
<li>
Events
<a class="indigo waves-effect waves-light btn" id="events-button">Events</a>
</li>
<li>
Logs
<a class="indigo waves-effect waves-light btn" id="logs-button">Logs</a>
Expand Down Expand Up @@ -101,6 +105,20 @@
</div>
</div>

<div id="events-panel">
<div class="card black">
<div class="card-content white-text">
<div style="position: fixed; width: 605px; margin-top: -10px; padding-top: 10px;" class="black">
<span id="close-events">×</span>
<b>Events</b>
<hr style="margin-bottom: 0;" />
</div>
<div id="events-output" style="padding-top: 35px;"></div>
</div>
</div>
</div>


<div id="map"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.js"></script>
<script type="text/javascript" src="config/userdata.js"></script>
Expand Down
84 changes: 79 additions & 5 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var socket_io = [];

var events = {
var eventsColors = {
api_error: 'red',
badges: 'blue',
bot_exit: 'red',
Expand Down Expand Up @@ -108,7 +108,9 @@ var events = {
used_lucky_egg: 'white',
gained_candy: 'white',
//player_data: 'white',
moving_to_pokemon_throught_fort: 'white'
moving_to_pokemon_throught_fort: 'white',
pokemon_vip_caught: 'green',
pokemon_caugt: 'blue'
}

var moveTypes = {
Expand Down Expand Up @@ -284,6 +286,12 @@ var mapView = {
$('#logs-button').click(function() {
$('#logs-panel').toggle();
});

$('#events-button').click(function() {
$('#events-panel').toggle();
});


// Init tooltip
$(document).ready(function() {
$('.tooltipped').tooltip({
Expand All @@ -302,6 +310,7 @@ var mapView = {
submenuIndex = itemIndex;
self.currentUserId = userId;
self.buildMenu(userId, itemIndex);
self.updateEvents();
}
});

Expand All @@ -313,6 +322,12 @@ var mapView = {
$('#logs-panel').toggle();
});

$('body').on('click', '#close-events', function() {
$('#events-panel').toggle();
});



$('body').on('click', '.tFind', function() {
self.findBot($(this).closest('ul').data('user-id'));
});
Expand Down Expand Up @@ -385,7 +400,9 @@ var mapView = {
});
self.placeTrainer();
self.addCatchable();
self.placeEvents();
setInterval(self.updateTrainer, 1000);
setInterval(self.updateEvents, 500);
setInterval(self.addCatchable, 1000);
setInterval(self.addInventory, 5000);
},
Expand Down Expand Up @@ -432,8 +449,8 @@ var mapView = {
}, retry_time * 1000);
});

for (var k in events){
if (events.hasOwnProperty(k)) {
for (var k in eventsColors){
if (eventsColors.hasOwnProperty(k)) {
//let renk = events[k];
if (typeof socket_io[user_index] !== 'undefined') {
socket_io[user_index].on(k+':'+self.settings.users[user_index].username, function (data) {
Expand All @@ -442,7 +459,7 @@ var mapView = {
$("div.bot-name").find("[data-bot-id='" + data['account'] + "']").text(data['data']['stats_raw']['username'])
}
if(data['data']['msg'] != null && data['data']['msg'] !== prevMsg){
var renk = events[data['event']];
var renk = eventsColors[data['event']];
if (logThis.test(data['event'])) {
if (data['event'] == 'vip_pokemon') {
timeOut = 8000;
Expand Down Expand Up @@ -800,6 +817,10 @@ var mapView = {
}
}
},
placeEvents: function() {
var self = mapView;
loadJSON('events-' + self.settings.users[self.currentUserId].username + '.json?'+Date.now(), self.eventsFunc, self.errorFunc, 0);
},
sortAndShowBagItems: function(user_id) {
var self = this,
current_user_bag_items = self.user_data[self.settings.users[user_id].username].bagItems;
Expand Down Expand Up @@ -1347,6 +1368,33 @@ var mapView = {
}
}
},
eventsFunc: function(data, user_index) {
var self = mapView,
coords = self.pathcoords[self.settings.users[user_index].username][self.pathcoords[self.settings.users[user_index].username].length - 1];
//alert(JSON.stringify(data[0]));

//alert(JSON.stringify(tEvent.event.friendly_msg));

//first clear all messages
$(".event-item").empty();

//Print them in different order, so that newest is always on top.
for (var i = 0; i<data.length;i++) {
var tEvent = data[i];
self.printevent({
message: tEvent.event.friendly_msg,
event: tEvent.event.event,
timestamp: tEvent.event.timestamp,
level: tEvent.event.level
});

}

},
updateEvents: function() {
var self = mapView;
loadJSON('events-' + self.settings.users[self.currentUserId].username + '.json?'+Date.now(), self.eventsFunc, self.errorFunc, 0);
},
calc_cp: function(base_attack, base_defense, base_stamina, iv_attack, iv_defense, iv_stamina, cp_multiplier) {
var bAttack = (base_attack + iv_attack),
bDefense = Math.sqrt(base_defense + iv_defense),
Expand Down Expand Up @@ -1391,9 +1439,35 @@ var mapView = {
if (self.logCount > 100) {
$(".log-item:last-child").remove();
}
},

printevent: function(event_object) {
var self = mapView;
var timeout = event_object.timeout
var eventColor = '';
var eventBGColor = '';

var eventType = event_object.event;
eventColor = 'color: ' + eventsColors[eventType] + ';';

if (typeof event_object.bgcolor !== 'undefined' && event_object.bgcolor != '') {
eventBGColor = 'background-color: ' + event_object.bgcolor + ';';
}
var currentDate = new Date(event_object.timestamp);
var time = ('0' + currentDate.getHours()).slice(-2) + ':' + ('0' + (currentDate.getMinutes())).slice(-2);
$("#events-output").prepend("<div class='event-item'>\
<span class='event-date'>" + time + "</span><span class='event-type'>[" + event_object.event + "] </span><span style='" + eventColor + "padding: 2px 5px;" + eventBGColor + "'>" + event_object.message + "</span></div>");

self.eventCount = $(".event-item").length;
if (self.eventCount > 100) {
$(".event-item:last-child").remove();
}
}
};




if (!String.prototype.format) {
String.prototype.format = function() {
var args = arguments;
Expand Down

0 comments on commit dea62b7

Please sign in to comment.