- 1
- 2
- 3
- 4
<form action="..." ...>
...
  <input type="button" ... onclick="$('form').submit();" />
</form>Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
Всего: 8
+161
<form action="..." ...>
...
  <input type="button" ... onclick="$('form').submit();" />
</form>
            Живет на свете один c# девелопер, который всегда всем говорит: "я не верстальщик - я c# девелопер. я не js программист - я c# девелопер" ну и т.д. И вот однажды он решил самостоятельно сделать функционал поиска...
(На самом деле на стороне сервера еще гуще развивались события...но это уже другая история...) с серверным c# кодом вы можете ознакомится тут http://govnokod.ru/user/5616/codes
        
+102
switch (occupation.name)
{
	case "architecture and engineering occupations:":
		if (occupation.isNB)
		{
			if (occupation.maleId == ex_nb_id)
			{
				model.ArchitectureAndEngineeringOccupationsMalePercentageNB = occupation.percent;
			}
			if (occupation.femaleId == ex_nb_id)
			{
				model.ArchitectureAndEngineeringOccupationsFemalePercentageNB = occupation.percent;
			}
		}
		else
		{
			if (occupation.maleId == ex_city_id)
			{
				model.ArchitectureAndEngineeringOccupationsMalePercentageCity = occupation.percent;
			}
			if (occupation.femaleId == ex_city_id)
			{
				model.ArchitectureAndEngineeringOccupationsFemalePercentageCity = occupation.percent;
			}
		}
	break;
	case "arts, design, entertainment, sports, and media occupations:":
		if (occupation.isNB)
		{
			if (occupation.maleId == ex_nb_id)
			{
				model.ArtsDesignEntertainmentSportsAndMediaOccupationsMalePercentageNB = occupation.percent;
			}
			if (occupation.femaleId == ex_nb_id)
			{
				model.ArtsDesignEntertainmentSportsAndMediaOccupationsFemalePercentageNB = occupation.percent;
			}
		}
		else
		{
			if (occupation.maleId == ex_city_id)
			{
				model.ArtsDesignEntertainmentSportsAndMediaOccupationsMalePercentageCity = occupation.percent;
			}
			if (occupation.femaleId == ex_city_id)
			{
				model.ArtsDesignEntertainmentSportsAndMediaOccupationsFemalePercentageCity = occupation.percent;
			}
		}
	break;
	case "business and financial operations occupations:":
		if (occupation.isNB)
		{
			if (occupation.maleId == ex_nb_id)
			{
				model.BusinessAndFinancialOperationsOccupationsMalePercentageNB = occupation.percent;
			}
			if (occupation.femaleId == ex_nb_id)
			{
				model.BusinessAndFinancialOperationsOccupationsFemalePercentageNB = occupation.percent;
			}
		}
		else
		{
			if (occupation.maleId == ex_city_id)
			{
				model.BusinessAndFinancialOperationsOccupationsMalePercentageCity = occupation.percent;
			}
			if (occupation.femaleId == ex_city_id)
			{
				model.BusinessAndFinancialOperationsOccupationsFemalePercentageCity = occupation.percent;
			}
		}
	break;
	case "community and social services occupations:":
		if (occupation.isNB)
		{
			if (occupation.maleId == ex_nb_id)
			{
				model.CommunityAndSocialServicesOccupationsMalePercentageNB = occupation.percent;
			}
			if (occupation.femaleId == ex_nb_id)
			{
				model.CommunityAndSocialServicesOccupationsFemalePercentageNB = occupation.percent;
			}
		}
		else
		{
			if (occupation.maleId == ex_city_id)
			{
				model.CommunityAndSocialServicesOccupationsMalePercentageCity = occupation.percent;
			}
			if (occupation.femaleId == ex_city_id)
			{
				model.CommunityAndSocialServicesOccupationsFemalePercentageCity = occupation.percent;
			}
		}эх жаль здесь ограничение на 100 строк всего лишь...не поместилось всего 200+ отборного ветвления. известный до боли мегапрограммер наваял очередной шедевр)))) по мотивам http://govnokod.ru/10448 и http://govnokod.ru/10313 и еще http://govnokod.ru/12136...
+136
private BusinessSocialProfile GetSocialProfileLink(string searchProvider, string searchKey)
{
	var link = new BusinessSocialProfile { Name = searchProvider, Url = "#" };
	
	if (searchProvider.Contains("city", StringComparison.InvariantCultureIgnoreCase))
	{
		link.Url = cityLink;
		link.Logo = "/citysearch.png";
		link.ImageStyle = "margin-top:-8px";
	}
	else if (searchProvider.Contains("google", StringComparison.InvariantCultureIgnoreCase))
	{
		link.Url = googleLink;
		link.Logo = "/google.png";
	}
	else if (searchProvider.Contains("yelp", StringComparison.InvariantCultureIgnoreCase))
	{
		link.Url = yelpLink;
		link.Logo = "/yelp.png";
		link.ImageStyle = "margin-top:-8px";
	}
	else if (searchProvider.Contains("manta", StringComparison.InvariantCultureIgnoreCase))
	{
		link.Url = mantaLink;
		link.Logo = "/manta.png";
	}
	else if (searchProvider.Contains("patch", StringComparison.InvariantCultureIgnoreCase))
	{
		link.Url = patchLink;
		link.Logo = "/patch.png";
	}
	else
	{
		link.Url = "#";
		link.Logo = string.Empty;
		link.Name = string.Empty;
	}
	return link;
}уже до боли известный девелопер ;) а для чего еще нужна бизнесс-логика...?
+136
for (var attempt = 0; attempt < 3; attempt++)
{
    var result = (from neighborhood in this.DataContext.Neighborhoods
        join city in this.DataContext.Cities on neighborhood.CityId equals city.Id
        where !string.IsNullOrEmpty(neighborhood.Latitude) && (neighborhood.Id <= 31028 || attempt == 2) &&
        (attempt == 0 && !string.IsNullOrEmpty(location.city) ? (city.Name.Equals(location.city, StringComparison.InvariantCultureIgnoreCase)) : true)
    select new...).ToList();
}просто linq, просто where;) От создателя xml-парсера (http://govnokod.ru/11870), обработки postback-запросов (http://govnokod.ru/10313), "обычного switch-а" (http://govnokod.ru/10448, http://govnokod.ru/10474), а еще конкатинации sql строк без параметров (но там слишком много, поэтому не выложу(:)
+137
private string ExtractNodeValue(string text, string nodeName)
{
    string result = string.Empty;
    int slength = ("<" + nodeName + ">").Length;
    int sindex = text.IndexOf("<" + nodeName + ">");
    int eindex = text.IndexOf("</" + nodeName + ">");
    if (sindex > 0 && eindex > 0)
        result = text.Substring(sindex + slength, eindex - sindex - slength);
    return result;
}
string request = string.Format("http://maps.google.com/maps/geo?ll={0},{1}&hl=en&output=xml&key=abcdefg", location.latitude, location.longitude);
Logger.Log(request);
HttpWebRequest httprequest = (HttpWebRequest)WebRequest.Create(request);
WebResponse responce = httprequest.GetResponse();
Stream str = responce.GetResponseStream();
XmlTextReader reader = new XmlTextReader(str);
reader.XmlResolver = null;
XmlDocument doc = new XmlDocument();
doc.Load(reader);
str.Close();
reader.Close();
XmlNodeList listResponse = doc.ChildNodes[1].ChildNodes[0].ChildNodes;
foreach (XmlNode nodePlace in listResponse)
{
    if (nodePlace.Name == "Placemark")
    {
        string text = nodePlace.InnerXml;
        string Country = ExtractNodeValue(text, "CountryName");
        if ((this.DataContext.Countries.Count(x => x.Name == location.countryName) == 0 || string.IsNullOrWhiteSpace(location.countryName)) &&
            !string.IsNullOrWhiteSpace(Country))
        {
            location.countryName = Country;
        }
        string Region = ExtractNodeValue(text, "AdministrativeAreaName");
        if (this.DataContext.States.Count(x => x.AlphaCode == location.region || x.Name == location.region) == 0 &&
            !string.IsNullOrWhiteSpace(Region))
        {
            location.region = Region;
        }
        string City = ExtractNodeValue(text, "LocalityName");
        if (this.DataContext.Cities.Count(x => x.Name == location.city) == 0 &&
            !string.IsNullOrWhiteSpace(City))
        {
            location.city = City;
        }
        break;
    }
}отличный парсиг xml.
+101
private void FillLocalService(int SelectedPageIndex)
        {
            //Set category by search
            string search = inputSearch.Value == inputSearchValue ? string.Empty : inputSearch.Value;
            if (inputSearch.Value != inputSearchValue && !string.IsNullOrWhiteSpace(inputSearch.Value))
            {
                if (inputSearch.Value.StartsWith("landscap", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Landscapers";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("baby sitter", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Baby sitters";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("doctor", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Doctor";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("cleaning service", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Cleaning services";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("pet sitter", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Pet sitters";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("handyman", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Handyman";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("electrical service", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Electrical services";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("tutor", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Tutor";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("dog walker", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Dog walker";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("plumb", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Plumbing";
                    search = string.Empty;
                }
                else if (inputSearch.Value.StartsWith("Caterer", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Caterers";
                    search = string.Empty;
                }
                else if (inputSearch.Value.Equals("misc", StringComparison.InvariantCultureIgnoreCase))
                {
                    SelectedCategory = "Misc";
                    search = string.Empty;
                }
            }
200+ строк кода
}тот же девелопер, та же .aspx страница)))))
+112
switch (SelectedCategory)
            {
                case "Landscapers":
                    inputSearch.Value = "Landscapers";
                    break;
                case "Baby sitters":
                    inputSearch.Value = "Baby sitters";
                    break;
                case "Doctor":
                    inputSearch.Value = "Doctor";
                    break;
                case "Cleaning services":
                    inputSearch.Value = "Cleaning services";
                    break;
                case "Pet sitters":
                    inputSearch.Value = "Pet sitters";
                    break;
                case "Handyman":
                    inputSearch.Value = "Handyman";
                    break;
                case "Electrical services":
                    inputSearch.Value = "Electrical services";
                    break;
                case "Tutor":
                    inputSearch.Value = "Tutor";
                    break;
                case "Dog walker":
                    inputSearch.Value = "Dog walker";
                    break;
                case "Plumbing":
                    inputSearch.Value = "Plumbing";
                    break;
                case "Caterers":
                    inputSearch.Value = "Caterers";
                    break;
                case "Misc":
                    inputSearch.Value = "Misc";
                    break;
            }обычный switch
+96
if (IsPostBack)
            {
                string PostBackerID = Request.Form.Get("__EVENTTARGET");
                string PostBackerArg = Request.Form.Get("__EVENTARGUMENT");
                if (PostBackerID == "ctl00$cphMainContent$pagerID")
                {
                    CurrentReviewPage = int.Parse(PostBackerArg);
                    FillReviews();
                }
                else if (PostBackerID == "ctl00$cphMainContent$Like")
                {
                    FillLike();
                }
                else if (PostBackerID == "ctl00$cphMainContent$review")
                {
                    AddReview(PostBackerArg);
                }
                else if (PostBackerID == "ctl00$cphMainContent$Follow")
                {
                    FillFollow();
                }
                else if (PostBackerID == "ctl00$cphMainContent$WebResultpagerID")
                {
                    CurrentWebResultPage = int.Parse(PostBackerArg);
                    FillWebResults();
                }
                else if (PostBackerID == "ctl00$cphMainContent$WebResultCluster" || PostBackerID == "ctl00$cphMainContent$HiddenButton")
                {
                    CurrentWebResultPage = 0;
                    int SelectedClusterID = int.Parse(PostBackerArg);
                    if (AllClusters != null && AllClusters.ContainsKey(SelectedClusterID))
                    {
                        SelectedClusterName = AllClusters[SelectedClusterID];
                        FillWebResults();
                    }
                }
            }компактная логика всей страницы...