- 1
- 2
- 3
- 4
- 5
getControlValues : function(isSimpleValue){
return this._getControlData(function(tab){
return tab.getControlValues(isSimpleValue);
});
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+156
getControlValues : function(isSimpleValue){
return this._getControlData(function(tab){
return tab.getControlValues(isSimpleValue);
});
}
Образец "самодокументируемого кода"
Маленький метод, но как много в нем загадок.
+47
private function getLastDate($year, $month)
{
$next_year = $year;
$next_month = $month + 1;
if ($next_month == 13) {
$next_month = 1;
$next_year++;
}
$next_time = mktime(0, 0, 0, $next_month, 1, intval($next_year));
$lastdate = strtotime('-1 day', $next_time);
$last_day = date('d', $lastdate);
return $last_day;
}
date('t', strtotime("$year-$month-01"));
+33
class Chatter : public QListBoxItem {
[...]
private:
static ChatterRef *chatters[MAX_NUM_CHATTERS];
[...]
friend int main(int, char *argv[]); // to destroy chatters[]
};
Сам проект: http://www.qtchat.org/qtchat/
Пример дается в этой книге: http://books.google.ru/books?id=8lYbNfsAVT4C&dq=qtchat&source=g bs_navlinks_s как пример friend-функций
+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.
+154
if((typeof folder!='undefined')&&folder!='untag'){
if((typeof cache[type].files[folder]!='undefined')&&caches){
pagination.create(cache[type].files[folder].count, false, cache[type].files[folder]);
show.loading(false);
return;
}
var params = {
'tag':folder
};
}
Вот глянул свой код полугодовалой давности, нужно было добавить пару фич. Охренел, 3 тысячи строк подобного вида и не одного комментария. Я себя ненавижу
+153
// Очистка полей формы
function clearForm(formName) {
//var ff = document.getElementById(formName);
var ff = document.forms[formName];
for (var i=0; i<ff.elements.length; i++) {
if (ff.elements[i].type == "text") ff.elements[i].value="";
if (ff.elements[i].type == "select-one") ff.elements[i].value="";
if (ff.elements[i].type == "checkbox") ff.elements[i].checked=false;
if (ff.elements[i].type == "radio") {
ff.elements[i].value="0";
ff.elements[i].checked=false;
}
}
}
Действительно, зачем this.form.reset() использовать?
+140
$i = 0; // Счетчик
+35
assert( -(PHP_INT_MAX + 1) === -PHP_INT_MAX - 1 );
assert( -(PHP_INT_MAX + 2) === -PHP_INT_MAX - 2 );
+130
<div id="busyList" class="busyList">
<div id="busyList" class="busyList">...</div>
<div id="busyList" class="busyList">...</div>
<div id="busyList" class="busyList">...</div>
<div id="busyList" class="busyList">...</div>
<div id="busyList" class="busyList">...</div>
<div id="busyList" class="busyList">...</div>
</div>
Как-то даже грустно становится...
+126
private Listener<BaseEvent> blurListener = new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
Component item = getComponent(be);
if(focusedItem == item) {
focusedItem = item;
}
}
}
Даже боюсь предположить, зачем это.