Skip to content

Instantly share code, notes, and snippets.

@obiPlabon
Last active January 26, 2017 12:07
Show Gist options
  • Save obiPlabon/494805aa1a2d24d359dee9dfeb823dce to your computer and use it in GitHub Desktop.
Save obiPlabon/494805aa1a2d24d359dee9dfeb823dce to your computer and use it in GitHub Desktop.
Code snippet from http://উত্তরাধিকার.বাংলা/
/**
* Code snippet from http://উত্তরাধিকার.বাংলা/
*
* Really inspiring if you wanna know code smell
* and how to write bad code
*/
function determine_ashaba(sel_rel_arr,ashabas_from_qh,exclude_from_qh,qhs)
{
var ashabas = [];
var rel_arr = sel_rel_arr;
//substruct exclude from qh
$.each(exclude_from_qh, function(i, val){
rel_arr.splice( rel_arr.indexOf(val), 1);
});
$.each(qhs, function(i, val){
rel_arr.splice( rel_arr.indexOf(val), 1);
});
$.each(ashabas_from_qh, function(i, val){
if(rel_arr.indexOf(val) == -1)
{
rel_arr.push(val);
}
});
//console.log(rel_arr);
////////////find out ashaba///////////////////
if(sel_rel_arr.indexOf("3") != -1)
{
if(sel_rel_arr.indexOf("4") != -1)
{
ashabas.push("3");
ashabas.push("4");
}
else
{
ashabas.push("3");
}
}
else
{
if(sel_rel_arr.indexOf("5") != -1)
{
if(sel_rel_arr.indexOf("6") != -1)
{
ashabas.push("5");
ashabas.push("6");
}
else
{
ashabas.push("5");
}
}
else
{
////////////////start class 2/////////////
if(sel_rel_arr.indexOf("7") != -1)
{
//omars law
if(sel_rel_arr.indexOf("8") != -1)
{
ashabas.push("7");
ashabas.push("8");
}
else
{
ashabas.push("7");
}
}
else
{
if(sel_rel_arr.indexOf("9") != -1)
{
ashabas.push("9");
}
else
{
////////////////start class 3/////////////
if(sel_rel_arr.indexOf("12") != -1 || sel_rel_arr.indexOf("13") != -1)
{
if(sel_rel_arr.indexOf("12") != -1)
{
ashabas.push("12");
}
if(sel_rel_arr.indexOf("13") != -1)
{
ashabas.push("13");
}
}
else
{
if(sel_rel_arr.indexOf("14") != -1 || sel_rel_arr.indexOf("15") != -1)
{
if(sel_rel_arr.indexOf("14") != -1)
{
ashabas.push("14");
}
if(sel_rel_arr.indexOf("15") != -1)
{
ashabas.push("15");
}
}
else
{
if(sel_rel_arr.indexOf("18") != -1)
{
ashabas.push("18");
}
else
{
if(sel_rel_arr.indexOf("19") != -1)
{
ashabas.push("19");
}
else
{
if(sel_rel_arr.indexOf("20") != -1)
{
ashabas.push("20");
}
else
{
if(sel_rel_arr.indexOf("21") != -1)
{
ashabas.push("21");
}
else
{
////////////////start class 4/////////////
if(sel_rel_arr.indexOf("22") != -1)
{
ashabas.push("22");
}
else
{
if(sel_rel_arr.indexOf("23") != -1)
{
ashabas.push("23");
}
else
{
if(sel_rel_arr.indexOf("24") != -1)
{
ashabas.push("24");
}
else
{
if(sel_rel_arr.indexOf("25") != -1)
{
ashabas.push("25");
}
else
{
if(sel_rel_arr.indexOf("26") != -1)
{
ashabas.push("26");
}
else
{
if(sel_rel_arr.indexOf("27") != -1)
{
ashabas.push("27");
}
else
{
if(sel_rel_arr.indexOf("28") != -1)
{
ashabas.push("28");
}
else
{
if(sel_rel_arr.indexOf("29") != -1)
{
ashabas.push("29");
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
/////////////////////////////////////////////
return { ashabas : ashabas};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment