- 1
- 2
Бесят пидоры, которые переопределяют действие "Ctrl+F" в браузере
на свой сраный никому не нужный поиск.
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
0
Бесят пидоры, которые переопределяют действие "Ctrl+F" в браузере
на свой сраный никому не нужный поиск.
+1
var XMLHttpRequest = function(XHR, type, listener) {
return function() {
var xhr = new XHR;
xhr.addEventListener(type, listener);
return xhr;
};
}(XMLHttpRequest, 'loadend', function(e) {
if (this.status == 0) {
console.log(e.type, 'network error');
} else {
console.log(e.type, this.status);
}
});
// js-library code...
+1
xhr.upload.addEventListener('progress', function (e) {
if (e.lengthComputable) {
let percents = Math.round(e.loaded / e.total * 100)
$(`#preloader-${preloaderId}`).html(`${percents}%`)
$(`#preloader-${preloaderId}`).append(`<style>#preloader-${preloaderId}:before{ width: ${percents * 0.94}px;}</style>`);
}
}, false);
Прогрессбар на псевдоэлементах.
+1
function natRound() {
var out = []
, fib = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233] // etc
, _data = function() { // random values
var out = []
, count = Math.round( Math.random() * 100)
;
for(var i=0; i < count; i++ ) {
out.push( Math.random() * 100 ); // in km
}
return out.sort(function(a,b){ return a-b; });
}()
, roundTo = function (value) {
var i = fib.length;
while(i--) {
if ( value < fib[i] ) continue;
return i? i: value; // natural sorting
}
}
;
for( var i=0; i<_data.length; i++ ) {
out.push( 'Value: [' + _data[i] + ']; Sort = [' + roundTo(_data[i]) + ']' );
}
return out;
}
Необходимо было учесть дискретность при сортировке расстояний в километрах.
Например, в синтаксисе Elastic это выглядит так:
"ranges" => [
[ "to" => 1 ],
[ "from" => 1, "to" => 3 ],
[ "from" => 3, "to" => 5 ],
[ "from" => 5],
// etc
]
+7
go 23239
govno gopa barebuh suka
pidor jopa
Это — особый диалект «JavaScript», используемый в «Google»: https://www.youtube.com/watch?v=-XRLl9LEZ7c&t=16 (16-я секунда, https://i.imgur.com/O8AwR9B.png).
Именно поэтому я за «Google».
+4
this.checkArrayErrors() ? (this.canSend = true) : (this.canSend = false);
Код разраба, который не прошел испытательный срок и сказал что к нему придираются.
−1
document.onmousemove = (el) => {
if (this.rot) {
var s_x = el.pageX, s_y = el.pageY;
if (s_x !== o_x && s_y !== o_y){
var s_rad = Math.atan2(s_y - o_y, s_x - o_x);
s_rad -= Math.atan2(h_y - o_y, h_x - o_x);
var dgr = (s_rad * (360 / (2 * Math.PI)));
element.initPositions.rotateDeg = dgr;
element.styles.transform = 'rotate(' + dgr + 'deg)';
}
}
};
А, как я сразу не понял, что это просто ротейт елемента...
+1
function htmlspecialchars (s) {
const el = document.createElement('span');
el.innerText = s;
return el.innerHTML.replace(/<br>/g, "\n");
}
Почему в жепаскрипте нет прямого доступа к этой функции? Почему я должен для этого работать с DOM или сам писать эту поеботу на рагулярках? Почему асё так анально?
+1
<script>
window["flags"] = {
"purcTOFlag": "true" == "true" ? true : false,
"ENBL_CANCEL_POLICY": "true" == "true" ? true : false,
"ENBL_BACKUP_CHECK_OLD_DEVICES": "false" == "true" ? true : false,
"ENBL_DIRECT_ACCESS_LINKS": "true" == "true" ? true : false,
"ENBL_NEW_ABG_URL": "true" == "true" ? true : false,
"cr_9839666": "true" == "true" ? true : false,
"cubaCRFlag": "true" == "true" ? true : false,
"cubaMultiCityCRFlag": "true" == "true" ? true : false,
"youthCRFlag": "true" == "true" ? true : false,
"ENABLE_AFOP_MODE": "true" == "true" ? true : false,
"SHARE_ITINERARY_ON_FACEBOOK": "false" == "true" ? true : false,
"cr_11668201": "true" == "true" ? true : false,
"hotelCRFlag": "true" == "true" ? true : false,
"cr_adoshareitinerary": "false" == "true" ? true : false,
"ROUNDOFF_AMOUNT_FOR_US_EDITION": "true" == "true" ? true : false,
"hideSeatPromotionalBanner": "true" == "true" ? true : false,
"enablePremiumRougeCR": "true" == "true" ? true : false,
"availFareSplit": "true" == "true" ? true : false,
"improvedMixedCabin": "true" == "true" ? true : false,
"adoPassengerPrepopulate": "true" == "true" ? true : false,
"adoIataInformation": "true" == "true" ? true : false,
"premiumRougeSeatSelection": "true" == "true" ? true : false,
"displayIntlTerminal": "true" == "true" ? true : false,
"continueDisabledLightboxIsEnabled": "true" == "true" ? true : false,
"createAeroplanFromConf": "true" == "true" ? true : false,
"contOnAvailPage": "true" == "true" ? true : false,
"alpiSpecialAssistanceCRFlag": "true" == "true" ? true : false,
"removePaxTitle": "false" == "true" ? true : false,
"perDiemInsurance": "true" == "true" ? true : false,
"isVisaCheckoutEnabled": "true" == "true" ? true : false,
"isCashRewardEnabled": "true" == "true" ? true : false,
"masterPassCRFlag": "true" == "true" ? true : false,
"masterPassAllowedEdition": "CA\-en:CA\-fr:CA\-zh",
"youthphase2CRFlag": "true" == "true" ? true : false,
"isCitylistPerfEnabled": "true" == "true" ? true : false,
"isSingleTravelOptionEnabled": "false" == "true" ? true : false,
"retainPaymentInformation": "true" == "true" ? true : false,
"hotelChildAgeCR": "true" == "true" ? true : false,
"displayGeoFirst": "true" == "true" ? true : false,
"displayDiscAvail": "true" == "true" ? true : false,
"premiumRougeUpsell": "true" == "true" ? true : false,
"enableReplaceOpinionLabs": "true" == "true" ? true : false,
"displayOalRef": "true" == "true" ? true : false,
"newTravelOptionsLayoutFlag": "true" == "true" ? true : false,
"hotelWidgetAPI": "true" == "true" ? true : false,
"enableCombinedPhoneNo": "true" == "true" ? true : false,
"hideTripSummaryForMobile": "true" == "true" ? true : false,
"enableSecureAttribute": "true" == "true" ? true : false,
"enhancedPreviewSeatMap": "true" == "true" ? true : false,
"enhancedSeatMap": "true" == "true" ? true : false,
"firstClassCabinCR": "true" == "true" ? true : false,
.
.
}
Taken from aircanada.com. Enjoy!
−2
<template>
<div class="side-effects">
<div class="side-effects__text" v-html="text"></div>
</div>
</template>
<script>
export default {
name: 'SideEffects',
data () {
return {
text: '<strong>JORNAY PM can cause serious side effects, including: </strong>' +
'<ul>' +
'<li>' +
'<strong>Abuse and dependence.</strong> JORNAY PM contains methylphenidate. JORNAY PM, other methylphenidate-containing products, and\n' +
'amphetamines have a high chance for abuse and can cause physical and psychological dependence. Your healthcare provider should check\n' +
'you or your child for signs of abuse and dependence before and during treatment with JORNAY PM.' +
'<ul>' +
'<li>Tell your healthcare provider if you or your child has ever abused or been dependent on alcohol, prescription medicines, or street\n' +
'drugs. </li>' +
'<li> Your healthcare provider can tell you more about the differences between physical and psychological dependence and drug addiction. </li>' +
'</ul>' +
'</li>' +
'<li>' +
'<p class="mb-0"><strong>Heart-related problems, including:</strong></p>' +
'<ul>' +
'<li>sudden death, stroke, and heart attack in adults</li>' +
'<li>sudden death in children who have heart problems or heart defects</li>' +
'<li> increased blood pressure and heart rate </li>' +
'</ul>' +
'</li>' +
'</ul>' +
'Your healthcare provider should check you or your child carefully for heart problems before starting JORNAY PM. Tell your healthcare provider\n' +
'if you or your child has any heart problems, heart defects, or high blood pressure.' +
' <p>Your healthcare provider should check your or your child’s blood pressure and heart rate regularly during treatment with JORNAY PM. </p>' +
'<p><strong>Call your healthcare provider right away or go to the nearest hospital emergency room right away if you or your child has any signs of\n' +
'heart problems such as chest pain, shortness of breath, or fainting during treatment with JORNAY PM. </strong></p>' +
'<ul>' +
'<li>' +
'<strong>Mental (psychiatric) problems, including:</strong>' +
'<ul>' +
'<li>new or worse behavior and thought problems</li>' +
'<li>new or worse bipolar illness</li>' +
'<li>new psychotic symptoms (such as hearing voices, or seeing or believing things that are not real) or new manic symptoms </li>' +
'</ul>' +
'</li>' +
'</ul>' +
'Tell your healthcare provider about any mental problems you or your child has, or about a family history of suicide, bipolar illness, or\n' +
'depression. ' +
'<p><strong>Call your healthcare provider right away if you or your child have any new or worsening mental symptoms or problems during treatment\n' +
'with JORNAY PM, especially hearing voices, seeing or believing things that are not real, or new manic symptoms</strong></p>' +
'<strong>JORNAY PM can cause other serious side effects, including:</strong>' +
'<ul>' +
'<li>See <strong>“What is the most important information I should know about JORNAY PM?” </strong></li>' +
'<li><strong>Painful and prolonged erections (priapism). </strong>Priapism has happened in males who take products that contain methylphenidate. If you or\n' +
'your child develops priapism, get medical help right away</li>' +
'<li>' +
'<strong>Circulation problems in fingers and toes (peripheral vasculopathy, including Raynaud’s phenomenon). Signs and symptoms may\n' +
'include:</strong>' +
'<ul>' +
'<li>fingers or toes may feel numb, cool, or painful</li>' +
'<li> fingers or toes may change color from pale, to blue, to red </li>' +
'</ul>' +
'</li>' +
'</ul>' +
'Tell your healthcare provider if you or your child has numbness, pain, skin color change, or sensitivity to temperature in the fingers or toes. ' +
'<strong>Call your healthcare provider right away if you or your child has any signs of unexplained wounds appearing on fingers or toes during\n' +
'treatment with JORNAY PM.</strong>' +
'<ul>' +
'<li>' +
'<strong>Slowing of growth (height and weight) in children</strong> Children should have their height and weight checked often during treatment with\n' +
'JORNAY PM. JORNAY PM treatment may be stopped if your child is not gaining weight or height. ' +
'</li>' +
'</ul>' +
'<strong>The most common side effects of methylphenidate products in children, adolescents, and adults with ADHD include:</strong>' +
'<ul>' +
'<li>decreased appetite</li>' +
'<li>stomach pain</li>' +
'<li>irritability</li>' +
'<li>trouble sleeping</li>' +
'<li>weight loss</li>' +
'<li>mood swings (affect lability)</li>' +
'<li>nausea</li>' +
'<li>anxiety</li>' +
'<li>increased heart rate</li>' +
'<li>vomiting</li>' +
'<li>dizziness</li>' +
'<li>increased blood pressure</li>' +
'<li>indigestion</li>' +
'</ul>' +
'<strorg>The most common side effects of JORNAY PM in children age 6 to 12 with ADHD include: </strorg>';
}
}
}
</script>
Так вот зачем нужна data и v-html (VueJS)