- nowywykop-sztuk-3-a-dokladniej-kolorowe/21140900/";
- }
- } else {
- alert('Problem z pobraniem wyniku, zgłoś to @xcccx!\n\n\nKOD BŁĘDU:\n'+endomondoData.error.type)
- }
- return;
- }
- doCalculations(endomondoData);
- return;
- }
- if (timerCount == 100) {
- clearInterval(waitingTimer);
- alert('Problem z pobraniem wyniku, zgłoś to @xcccx!');
- }}, 100);
- } else {
- console.log('Nie potrafie pobrac danych :(');
- alert('Nie wiem co ty za link podałeś/aś. :(\n\nLista obsługiwanych portali:\nendomondo.com\n\n\nKorzystasz z czegoś innego? Daj znać @xcccx!');
- return;
- }
- return
- }
- doCalculations();
- });
- function doCalculations (trainingData) {
- $.ajax({
- url: "https://a.wykop.pl/search/entries/appkey,6ffOu3twFy",
- type: "POST",
- data: {
- 'q': '#' + tag
- },
- datatype: "json"
- }).success(
- function (data) {
- console.log(trainingData);
- if (trainingData) {
- var liczby = [Math.round(endomondoData.distance * 100) / 100];
- } else {
- var liczby = $('#odejmowanie').val().replace(/\,/g, '.').split('-');
- }
- var baza = (data[0].body.split('<br \/>')[0].split('=')[1].replace(/\s+/g, '')).replace(',', '.').replace('km', '');
- var wynik = baza;
- var wyniktxt = baza;
- $.each(liczby, function (i, val) {
- wynik -= val;
- wyniktxt += " - " + val;
- });
- wynik = Math.round(wynik * 100) / 100;
- if (baza.toString().length > 3) {
- var space = baza.toString().indexOf(".") != -1 ? baza.toString().indexOf(".")-3 : baza.toString().length-3;
- wyniktxt = wyniktxt.substring(0, space) + ' ' + wyniktxt.substring(space, this.length)
- }
- if (wynik.toString().length > 3) {
- var space = wynik.toString().indexOf(".") != -1 ? wynik.toString().indexOf(".")-3 : wynik.toString().length-3;
- wynik += '';
- wynik = wynik.substring(0, space) + ' ' + wynik.substring(space, this.length)
- }
- wyniktxt += " = " + wynik;
- if (trainingData) {
- var time = trainingData.duration;
- if (time > 3599) {
- var hours = Math.floor(time / 3600);
- time = time - hours * 3600;
- var minutes = Math.floor(time / 60);
- var seconds = time - minutes * 60;
- time = hours +'g:'+minutes+'m:'+seconds+'s';
- } else {
- var minutes = Math.floor(time / 60);
- var seconds = time - minutes * 60;
- time = minutes+'m:'+seconds+'s';
- }
- var info = '\n';
- info += '\nDystans: '+liczby+' km';
- info += '\nCzas trwania: '+time;
- if (trainingData.sport == 0) {
- var pace = trainingData.speed_avg;
- var mins = Math.floor(60/pace);
- var secs = Math.round((60/pace - mins) * 60);
- pace = mins+':'+secs+' min/km';
- info += '\nŚrednie tempo: '+pace;
- var paceMax = trainingData.speed_max;
- mins = Math.floor(60/paceMax);
- secs = Math.round((60/paceMax - mins) * 60);
- paceMax = mins+':'+secs+' min/km';
- info += '\nMaksymalne tempo: '+paceMax;
- } else {
- info += '\nŚrednia prędkość: '+Math.floor(trainingData.speed_avg*100 / 100)+'km/h';
- info += '\nMaksymalna prędkość: '+Math.floor(trainingData.speed_max*100 / 100)+'km/h';
- }
- wyniktxt += info + '\n\n';
- }
- var textVal = $('#commentFormContainer textarea').val();
- if(insertFooter) textVal+="\nWynik obliczony za pomocą [skryptu](https://www.wykop.pl/wpis/8267364/dodatek-do-nowywykop-sztuk-3-a-dokladniej-kolorowe/21140900/)";
- if(trainingData) textVal+=", dane o treningu pobrane z Endomondo.";
- $('#commentFormContainer textarea').val(wyniktxt.replace(/\./g, ',') + textVal).css({'min-height' : '250px'}).focus();
- }).fail(function () {
- alert('Bład pobierania ostatniego wyniku');
- });
- }
- var myNick = $('.logged-user .avatar').attr('alt');
- $('.plusujwszystkie').click(function (e) {
- if ($(this).hasClass('done')) {
- $('#itemsStream div[data-type="entry"]').each(function() {
- if ($(this).find('.plus').hasClass('voted')) { $(this).find('.button.mikro.ajax').click(); }
- })
- $(this).removeClass('done').text('Plusuj wpisy');
- } else {
- $('#itemsStream div[data-type="entry"]').each(function() {
- if (!$(this).find('.plus').hasClass('voted')) { $(this).find('.button.mikro.ajax').click(); }
- })
- $(this).addClass('done').text('Cofnij plusy');
- }
- });
- }
- console.log('+ Załadowano odejmowanie w tagach');
- }`