Facebook
From 123456, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 193
  1. nowywykop-sztuk-3-a-dokladniej-kolorowe/21140900/";
  2.                                         }
  3.                                         } else {
  4.                                         alert('Problem z pobraniem wyniku, zgłoś to @xcccx!\n\n\nKOD BŁĘDU:\n'+endomondoData.error.type)
  5.                                     }
  6.                                     return;
  7.                                 }
  8.                                 doCalculations(endomondoData);
  9.                                 return;
  10.                             }
  11.                             if (timerCount == 100) {
  12.                                 clearInterval(waitingTimer);
  13.                                 alert('Problem z pobraniem wyniku, zgłoś to @xcccx!');
  14.                             }}, 100);
  15.                                                
  16.                     } else {
  17.                         console.log('Nie potrafie pobrac danych :(');
  18.                         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!');
  19.                         return;
  20.                     }
  21.                     return
  22.                 }
  23.                 doCalculations();
  24.                         });
  25.            
  26.             function doCalculations (trainingData) {
  27.                 $.ajax({
  28.                                         url: "https://a.wykop.pl/search/entries/appkey,6ffOu3twFy",
  29.                                         type: "POST",
  30.                                         data: {
  31.                                                 'q': '#' + tag
  32.                                         },
  33.                                         datatype: "json"
  34.                                 }).success(
  35.                                         function (data) {
  36.                         console.log(trainingData);
  37.                         if (trainingData) {
  38.                                 var liczby = [Math.round(endomondoData.distance * 100) / 100];  
  39.                         } else {
  40.                             var liczby = $('#odejmowanie').val().replace(/\,/g, '.').split('-');
  41.                         }
  42.                                                 var baza = (data[0].body.split('<br \/>')[0].split('=')[1].replace(/\s+/g, '')).replace(',', '.').replace('km', '');
  43.                                                 var wynik = baza;
  44.                                                 var wyniktxt = baza;
  45.                                                 $.each(liczby, function (i, val) {
  46.                                                         wynik -= val;
  47.                                                         wyniktxt += " - " + val;
  48.                                                 });
  49.                                                 wynik = Math.round(wynik * 100) / 100;
  50.  
  51.                         if (baza.toString().length > 3) {
  52.                             var space = baza.toString().indexOf(".") != -1 ? baza.toString().indexOf(".")-3 : baza.toString().length-3;
  53.                             wyniktxt = wyniktxt.substring(0, space) + ' ' + wyniktxt.substring(space, this.length)
  54.                         }
  55.                         if (wynik.toString().length > 3) {
  56.                             var space = wynik.toString().indexOf(".") != -1 ? wynik.toString().indexOf(".")-3 : wynik.toString().length-3;
  57.                             wynik += '';
  58.                             wynik = wynik.substring(0, space) + ' ' + wynik.substring(space, this.length)
  59.                         }
  60.  
  61.                                                 wyniktxt += " = " + wynik;  
  62.                        
  63.                         if (trainingData) {
  64.                         var time = trainingData.duration;
  65.                             if (time > 3599) {
  66.                              var hours = Math.floor(time / 3600);
  67.                                                                  time = time - hours * 3600;
  68.                              var minutes = Math.floor(time / 60);
  69.                                                          var seconds = time - minutes * 60;
  70.                                 time = hours +'g:'+minutes+'m:'+seconds+'s';
  71.                             } else {
  72.                              var minutes = Math.floor(time / 60);
  73.                                                          var seconds = time - minutes * 60;
  74.                                 time = minutes+'m:'+seconds+'s';
  75.                             }
  76.                            
  77.                         var info = '\n';
  78.                             info += '\nDystans: '+liczby+' km';
  79.                             info += '\nCzas trwania: '+time;
  80.                             if (trainingData.sport == 0) {
  81.                                 var pace = trainingData.speed_avg;
  82.                                 var mins = Math.floor(60/pace);
  83.                                 var secs = Math.round((60/pace - mins) * 60);
  84.                                 pace = mins+':'+secs+' min/km';
  85.                                 info += '\nŚrednie tempo: '+pace;
  86.                                
  87.                                 var paceMax = trainingData.speed_max;
  88.                                 mins = Math.floor(60/paceMax);
  89.                                 secs = Math.round((60/paceMax - mins) * 60);
  90.                                 paceMax = mins+':'+secs+' min/km';
  91.                                 info += '\nMaksymalne tempo: '+paceMax;
  92.                             } else {
  93.                                 info += '\nŚrednia prędkość: '+Math.floor(trainingData.speed_avg*100 / 100)+'km/h';
  94.                                 info += '\nMaksymalna prędkość: '+Math.floor(trainingData.speed_max*100 / 100)+'km/h';
  95.                                
  96.                             }
  97.                             wyniktxt += info + '\n\n';
  98.                         }
  99.                        
  100.                         var textVal = $('#commentFormContainer textarea').val();
  101.                                                                        
  102.                         if(insertFooter) textVal+="\nWynik obliczony za pomocą [skryptu](https://www.wykop.pl/wpis/8267364/dodatek-do-nowywykop-sztuk-3-a-dokladniej-kolorowe/21140900/)";
  103.                         if(trainingData) textVal+=", dane o treningu pobrane z Endomondo.";
  104.                        
  105.                         $('#commentFormContainer textarea').val(wyniktxt.replace(/\./g, ',') + textVal).css({'min-height' : '250px'}).focus();
  106.                                         }).fail(function () {
  107.                                         alert('Bład pobierania ostatniego wyniku');
  108.                                 });
  109.             }
  110.  
  111.                         var myNick = $('.logged-user .avatar').attr('alt');
  112.  
  113.                         $('.plusujwszystkie').click(function (e) {
  114.                                 if ($(this).hasClass('done')) {
  115.                                        
  116.                                         $('#itemsStream div[data-type="entry"]').each(function() {
  117.                                                 if ($(this).find('.plus').hasClass('voted')) { $(this).find('.button.mikro.ajax').click(); }
  118.                                         })
  119.                                        
  120.                                        
  121.                                         $(this).removeClass('done').text('Plusuj wpisy');
  122.                                 } else {
  123.                                        
  124.                                         $('#itemsStream div[data-type="entry"]').each(function() {
  125.                                                 if (!$(this).find('.plus').hasClass('voted')) { $(this).find('.button.mikro.ajax').click(); }
  126.                                         })
  127.                                        
  128.                                         $(this).addClass('done').text('Cofnij plusy');
  129.                                 }
  130.  
  131.  
  132.                         });
  133.  
  134.                 }
  135.  
  136.        
  137.         console.log('+ Załadowano odejmowanie w tagach');
  138.         }`