From 0adeba33ea1cc6be0cf2a2cc336f111e2a5452da Mon Sep 17 00:00:00 2001 From: goedzo Date: Wed, 19 Jul 2017 20:18:28 +0200 Subject: [PATCH 1/2] Dev Update --- css/main.css | 25 +++++++++++++++++++++++++ js/main.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/css/main.css b/css/main.css index 892ac12..45d1f27 100644 --- a/css/main.css +++ b/css/main.css @@ -149,6 +149,31 @@ html, body { .log-date { color: #666; } + + +#event-panel { + display: none; + position: fixed; + height: 50vh; + width: 660px; + z-index: 5; + left: 10px; + bottom: 10px; +} +#event-panel .card { + overflow-y: scroll; + height: 100%; + margin: 0; +} +.event-item { + padding: .3em 0 .3em 0; + font-size: 14px; +} +.event-date { + color: #666; +} + + .bot-0 { background-color: #A93226 !important; } diff --git a/js/main.js b/js/main.js index 9f2517a..8b6d999 100644 --- a/js/main.js +++ b/js/main.js @@ -284,6 +284,12 @@ var mapView = { $('#logs-button').click(function() { $('#logs-panel').toggle(); }); + + $('#events-button').click(function() { + $('#events-panel').toggle(); + }); + + // Init tooltip $(document).ready(function() { $('.tooltipped').tooltip({ @@ -313,6 +319,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')); }); @@ -1394,6 +1406,38 @@ var mapView = { } }; + // Adds events to event panel + event: function(event_object) { + var self = mapView; + var timeout = event_object.timeout + var logColor = ''; + var logBGColor = ''; + if (typeof timeout == 'undefined') { + timeout = 3000; + } + if (typeof event_object.color !== 'undefined' && event_object.color != '') { + logColor = 'color: ' + event_object.color + ';'; + } + if (typeof event_object.bgcolor !== 'undefined' && event_object.bgcolor != '') { + logBGColor = 'background-color: ' + event_object.bgcolor + ';'; + } + var currentDate = new Date(); + var time = ('0' + currentDate.getHours()).slice(-2) + ':' + ('0' + (currentDate.getMinutes())).slice(-2); + $("#logs-output").prepend("
\ + " + time + "

" + event_object.message + "

"); + if (!$('#event-panel').is(":visible")) { + //Materialize.toast(event_object.message, timeout); + } + + self.logCount = $(".event-item").length; + if (self.logCount > 100) { + $(".event-item:last-child").remove(); + } + } +}; + + + if (!String.prototype.format) { String.prototype.format = function() { var args = arguments; From 81054c56323e55ba9a33d763e9425da50b8077a8 Mon Sep 17 00:00:00 2001 From: goedzo Date: Thu, 20 Jul 2017 01:35:25 +0200 Subject: [PATCH 2/2] Implemented Status window in web-ui Web-ui now shows the status messages on screen. It's a window called "events". In settings this window can be hidden. --- css/main.css | 20 ++++++++++--- index.html | 18 +++++++++++ js/main.js | 84 +++++++++++++++++++++++++++++++++++----------------- 3 files changed, 91 insertions(+), 31 deletions(-) diff --git a/css/main.css b/css/main.css index 45d1f27..a7cb4a7 100644 --- a/css/main.css +++ b/css/main.css @@ -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; @@ -134,7 +143,7 @@ html, body { height: 50vh; width: 660px; z-index: 5; - left: 10px; + left: 680px; bottom: 10px; } #logs-panel .card { @@ -151,8 +160,7 @@ html, body { } -#event-panel { - display: none; +#events-panel { position: fixed; height: 50vh; width: 660px; @@ -160,7 +168,7 @@ html, body { left: 10px; bottom: 10px; } -#event-panel .card { +#events-panel .card { overflow-y: scroll; height: 100%; margin: 0; @@ -170,7 +178,11 @@ html, body { font-size: 14px; } .event-date { + color: #888; +} +.event-type { color: #666; + display:none; } diff --git a/index.html b/index.html index ee84fd3..b4ab87a 100644 --- a/index.html +++ b/index.html @@ -58,6 +58,10 @@
+
  • + Events + Events +
  • Logs Logs @@ -101,6 +105,20 @@ +
    +
    +
    +
    + × + Events +
    +
    +
    +
    +
    +
    + +
    diff --git a/js/main.js b/js/main.js index 8b6d999..9ea43ba 100644 --- a/js/main.js +++ b/js/main.js @@ -2,7 +2,7 @@ var socket_io = []; -var events = { +var eventsColors = { api_error: 'red', badges: 'blue', bot_exit: 'red', @@ -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 = { @@ -308,6 +310,7 @@ var mapView = { submenuIndex = itemIndex; self.currentUserId = userId; self.buildMenu(userId, itemIndex); + self.updateEvents(); } }); @@ -397,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); }, @@ -444,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) { @@ -454,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; @@ -812,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; @@ -1359,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 100) { $(".log-item:last-child").remove(); } - } -}; - - // Adds events to event panel - event: function(event_object) { + }, + + printevent: function(event_object) { var self = mapView; var timeout = event_object.timeout - var logColor = ''; - var logBGColor = ''; - if (typeof timeout == 'undefined') { - timeout = 3000; - } - if (typeof event_object.color !== 'undefined' && event_object.color != '') { - logColor = 'color: ' + event_object.color + ';'; - } + var eventColor = ''; + var eventBGColor = ''; + + var eventType = event_object.event; + eventColor = 'color: ' + eventsColors[eventType] + ';'; + if (typeof event_object.bgcolor !== 'undefined' && event_object.bgcolor != '') { - logBGColor = 'background-color: ' + event_object.bgcolor + ';'; + eventBGColor = 'background-color: ' + event_object.bgcolor + ';'; } - var currentDate = new Date(); + var currentDate = new Date(event_object.timestamp); var time = ('0' + currentDate.getHours()).slice(-2) + ':' + ('0' + (currentDate.getMinutes())).slice(-2); - $("#logs-output").prepend("
    \ - " + time + "

    " + event_object.message + "

    "); - if (!$('#event-panel').is(":visible")) { - //Materialize.toast(event_object.message, timeout); - } + $("#events-output").prepend("
    \ + " + time + "[" + event_object.event + "] " + event_object.message + "
    "); - self.logCount = $(".event-item").length; - if (self.logCount > 100) { + self.eventCount = $(".event-item").length; + if (self.eventCount > 100) { $(".event-item:last-child").remove(); } } @@ -1438,6 +1467,7 @@ var mapView = { + if (!String.prototype.format) { String.prototype.format = function() { var args = arguments;