- 1
- 2
- 3
function print(){
window.print() ;
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+165
function print(){
window.print() ;
}
+170
$(".fast-view .slide a").click(function() {
$(this).parent().parent().parent().parent().parent().parent().parent().find(".fast-view-list .tab").css("display", "none");
$(this).parent().parent().parent().parent().parent().parent().parent().find($(this).attr("href")).css("display", "block");
return false;
});
+160
function displayFilterElements(typeList){
_filter.form.elements["name1"].closest("tr").hidden = (typeList === "Type1") ? false : true;
_filter.form.elements["name2"].closest("tr").hidden = (typeList === "Type1") ? false : true;
_filter.form.elements["nam3"].closest("tr").hidden = (typeList === "Type1") ? false : true;
_filter.form.elements["name4"].closest("tr").hidden = (typeList === "Type1") ? false : true;
_filter.form.elements["name5"].closest("tr").hidden = (typeList === "Type1") ? false : true;
_filter.form.elements["name6"].closest("tr").hidden = (typeList === "Type1") ? false : true;
_filter.form.elements["name7"].closest("tr").hidden = (typeList === "Type1") ? false : true;
_filter.form.elements["name8"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name9"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name10"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name11"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name12"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name13"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name14"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name15"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name16"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name17"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name18"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name19"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name20"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name21"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name22"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name23"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name24"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name25"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name26"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name27"].closest("tr").hidden = (typeList === "Type2") ? false : true;
_filter.form.elements["name28"].closest("tr").hidden = (typeList === "Type3") ? true : false;
_filter.form.elements["name29"].closest("tr").hidden = (typeList === "Type3") ? false : true;
};
function stateFilterElements(){
let select = false;
["name1", "name2", "name3", "name4", "name5", "name6", "name7", "name8", "name9", "name10", "name11", "name12", "name13"].forEach(function(fieldName){
if ($.query.hashJSON.has(fieldName))
select = true;
});
return select;
}
Получил в доработку модуль сотрудника. Идентификаторы изменены для публикации, не в них суть.
+158
$('#Leasing_payment_sum').keyup(function(){
if($(this).val()/$(this).val()){
var result = $(this).val()*1+$(this).val()*0.18;
$('#Leasing_payment_sum_with_nds').val(result.toFixed(2));
}
});
Удивляет проверка...
+158
eps=0.001;
s1=new Source(1000,0.17);
mx=new Mixer(1000);
mb=new Mem(0.15,0.95);
sp=new Splitter(0.80);
s2=new Sink();
s3=new Sink();
mx.in1=s1.out1;
mx.in2=sp.out2;
mb.in1=mx.out1;
sp.in1=mb.out2;
s3.in1=sp.out1;
s2.in1=mb.out1;
for (i=0;i<50;i++){
mx.calc();
mb.calc();
sp.calc();
}
function Stream(v,c){
this.v=v||null;
this.c=c||null;
this.selfCheck=false;
this.Show=function(){//how to add default values?
return "volume="+this.v+",conc="+this.c+",selfCheck:"+this.selfCheck+"; ";
}
}
function Source(v,c){
this.out1=new Stream(v,c);
this.calc=function(){};
}
function Sink(){
this.in1=null;
this.calc=function(){};
}
function Mixer(fixedV){
this.fv=fixedV;
this.in1=null;
this.in2=null;
this.out1=new Stream();
this.calc=function(){
this.out1.v=this.fv;//||this.in1.v+this.in2.v;
this.in2.v=this.in2.v||0;
this.in2.c=this.in2.c||0;
this.in1.v=this.out1.v-this.in2.v;
this.out1.c =(this.in1.v*this.in1.c+this.in2.v*this.in2.c)/this.out1.v;
this.out1.selfCheck=Math.abs
((this.in1.v*this.in1.c+this.in2.v*this.in2.c)-(this.out1.v*this.out1.c))<eps;
}
}
function Splitter(kS){
this.in1=null;
this.ks=kS||0.05;
this.out1=new Stream();
this.out2=new Stream();
this.calc=function(){
this.out1.v=this.in1.v*(1-this.ks);
this.out2.v=this.in1.v*(this.ks);
this.out1.c=this.in1.c;
this.out2.c=this.in1.c;
}
}
function Mem(kV,kC) {
this.kv = kV||0.15;
this.kc = kC||0.95;
this.in1 = null;
this.out1 = new Stream();
this.out2 = new Stream();
this.calc = function () {
this.out1.v = this.in1.v * this.kv;
this.out1.c = this.in1.c * (1 - this.kc);
this.out2.v = this.in1.v * (1 - this.kv);
this.out2.c = (this.in1.v * this.in1.c - this.out1.v * this.out1.c) / this.out2.v;
this.out1.selfCheck = this.out2.selfCheck = Math.abs
(this.in1.v * this.in1.c - (this.out1.v * this.out1.c + this.out2.v * this.out2.c)) < eps;
}
}
+157
/**
* Checks if the same user added to more than one role
* @private
*/
_checkUsersConficts: function() {
var adminUsers = this._usersGrids[TI.constants.RoleLevels.ADMIN].getStore().getRange().map(function(rec) {
return rec.get(this.COLUMN_EMAIL);
}, this);
var editorUsers = this._usersGrids[TI.constants.RoleLevels.EDITOR].getStore().getRange().map(function(rec) {
return rec.get(this.COLUMN_EMAIL);
}, this);
var readerUsers = this._usersGrids[TI.constants.RoleLevels.READER].getStore().getRange().map(function(rec) {
return rec.get(this.COLUMN_EMAIL);
}, this);
//let's use dumb approach. probably later will have time for some more sophisticated algorithm ¯\_(ツ)_/¯
var conflictAdminEditor = adminUsers.intersect(editorUsers);
var conflictAdminReader = adminUsers.intersect(readerUsers);
var conflictEditorReader = editorUsers.intersect(readerUsers);
return conflictAdminEditor
.concat(conflictAdminReader)
.concat(conflictEditorReader)
.unique();
}
Да чо там, больше ролей не добавлялось уже очень давно и не предполагается.
+159
jQuery('#btn-submit-calck').on('click',function () {
var GDO = jQuery('#GDO').val().replace(',', '.');
var GAZ = jQuery('#GAZ').val().replace(',', '.');
var BENZIN = jQuery('#BENZIN').val().replace(',', '.');
var ROZHOD = jQuery('#ROZHOD').val().replace(',', '.');
var PROBEG = jQuery('#PROBEG').val().replace(',', '.');
var RESULT = ((GDO * 100)/((BENZIN-GAZ*1.1)*ROZHOD*PROBEG));
jQuery('#RESULTO').text(Math.round(RESULT));
jQuery('#EKONOM').text(Math.round(((BENZIN-GAZ*1.1)*ROZHOD*PROBEG)/100));
jQuery('#1GOD').text(Math.round((((BENZIN-GAZ*1.1)*ROZHOD*PROBEG)/100)*365));
return false;
});
+155
logs.splice.apply(logs, [j, 1].concat(line.split("\n")));
+168
generator=function(a,q){m=Math;no='';nb=' ';
rnd=function(r,w){return((m.round(((+new Date)*m.random())%r)||0)+(w||0));};
ff=function(ff){ma=function(ma1,ma2){return(m.max(ma1,ma2));};return(ma(ma(rnd(rnd(ff)),rnd(rnd(ff))),ma(rnd(rnd(ff)),rnd(rnd(ff)))));};
sumb=function(x,y){return(String.fromCharCode(rnd(m.abs((y||1)-1),m.abs(x||32))));};
sor=function(o){return(o.sort(function(){return(0.5-m.random())}));};
a=Number(a||0);
q=q||[];
q=function(z){r=0;for(j=0;j<z.length;j++){r+=z[j]};return(r);}(q)?q:(Array(4+4+4+4+4+4+4+4
+4+4+4 +4+4+4
+1).join('1').split(no));sx=function(p,u){g=q.length;return(Number(q[p>g?g:p])?u:no);};len=Array();for(r=0;r<rnd(a,a*5);r++){e=[
sumb(958)
,sumb(97,26)
,sumb(945,25)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(945,25)
,sumb(97,26)
,sumb(945,25)
,sumb(97,26)
,sumb(945,25)
,sumb(97,26)
,sumb(945,25)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(97,26)
,sumb(223)
,sumb(228)
,sumb(230)
,sumb(231)
,sumb(239)
,sumb(240)
,sumb(241)
,sumb(235)
,sumb(246)
И это было написано ручками, не использовался никакой uglify
И этот проект мне достался в наследство на новой работе.
КМП.
+159
<p>
<script>// <![CDATA[
if (navigator.appVersion.indexOf("Win") != -1) {
document.getElementById("windows").style.display = "inline";
} else if (navigator.appVersion.indexOf("Mac") != -1) {
document.getElementById("osx").style.display = "inline";
} else if (navigator.appVersion.indexOf("Linux") != -1) {
document.getElementById("linux").style.display = "inline";
} else {
document.getElementById("windows").style.display = "inline";
document.getElementById("osx").style.display = "inline";
document.getElementById("linux").style.display = "inline";
}
// ]]></script>
</p>
Недавно один Java-pазработчик не смог разобраться, как пофиксеть баг в WordPress и решил переписать наш корпоративный сайт на Java мотивируя это тем, что будет намного легче поддерживать и развивать новую ситсему. Что из этого получилось видно на наглядном примере js-кода в верстке.