- 1
- 2
- 3
- 4
- 5
- 6
- 7
function check_all(){
<?
if(!empty($this->params["show"])) foreach($this->params["show"] as $key_ar => $ar){
echo "document.getElementById('id[".$ar["id"]."]').checked=true; \n";
}
?>
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+162
function check_all(){
<?
if(!empty($this->params["show"])) foreach($this->params["show"] as $key_ar => $ar){
echo "document.getElementById('id[".$ar["id"]."]').checked=true; \n";
}
?>
}
Вот так в проектах одной из ведущих компаний по разработке сайтов в моем городе пишут функции для выбора всех checkbox.
p.s. сам код в HTML файле. $this->params["show"] это массив данных полученный после запроса к mysql (фактически выборка данных из справочника)
p.p.s на сайте даже jquery подключен.
+156
var unsolved_issues = <?=$unsolved_messages_count?>;
var unsolved_by_cats = Array();
<?foreach($issues_by_cats as $key => $val):?>
unsolved_by_cats['<?=$key?>'] = '<?=$val?>';
<?endforeach?>
PHPшный foreach непонятно зачем, нашел в совместно разрабатываемом проекте.
+159
function calls() {
//document.frm_param.form.value="client_calls";
//document.frm_param.title_.value="Работа с клиентом | Звонки";
s_url="$bill_cgi$?form=calls"+
"&date_begin=01.01.1990"+
"&date_end=01.01.2010"+
"&call_type=100"+
"&phone="+
"&to_phone="+
"&client=$client$"+
"&town_code="+
"&direction="+
"&zone="+
"&order_by=date_"+
"&order_by2="+
"&group_by="+
"&calls_recalc="+
"&calls_print=1";
window.top.location=s_url;
}
(c) Руслан Залата
+159
for (i = 1; i < <?php echo count($prog[1])?>; i++){
if (document.getElementById('module'+i).checked)
module_tmp= Math.abs($('#module'+i).val())+module_tmp;
+158
// create singelton object, see below
function singelton(classDesc) {
return classDesc;
}
var LetterTypeAction = singelton(
{
selectLetterType : function(controlId, index) {
letterTypeManager.selectLetterType(controlId, index);
},
addLetterType : function() {
letterTypeManager.addLetterType();
},
saveLetterType : function() {
var tempLetterType = new LetterTypeDef();
tempLetterType.setId(currentLetterType.getId());
tempLetterType.setAbbreviation(TextUtils.trim(ControlUtils.getValueById(letterTypeAbbrId)));
tempLetterType.setDescription(TextUtils.trim(ControlUtils.getValueById(letterTypeDescrId)));
letterTypeManager.saveLetterType(tempLetterType);
},
changeLetterType : function() {
letterTypeManager.changeLetterType();
},
deleteLetterType : function() {
letterTypeManager.deleteLetterType(currentLetterType);
},
cancelLetterType : function() {
letterTypeManager.cancelLetterType();
},
sortLetterType : function(columnId) {
letterTypeManager.sortLetterType(columnId);
}
}
);
новый паттерн проектирования, добавляющий в код мусор
+177
function yap(){
return function(){
yap();
}
}
Вот такое оно, функциональное програмирование
+165
function trim(str) {
str = str.replace(/^\s\s*/, '');
let ws = /\s/;
let i = str.length;
while (ws.test(str.charAt(--i)));
return str.slice(0, i + 1);
}
Очень суровый товарищ.
Посмотреть: https://addons.mozilla.org/ru/firefox/files/browse/106116 (bootstrap.js)
Если вдруг будет откорректировано, вот нужная версия: https://addons.mozilla.org/ru/firefox/addon/264089/versions/0.3.7.3
P.S. let: https://developer.mozilla.org/en/JavaScript/Reference/Statements/let
+160
// http://www.domw.net/js.js
function open(name){
document.getElementById(name).style.display = ''
}
// http://www.domw.net/
<a href="http://lite.webim.ru/decoda/webim/client.php?locale=ru" target="_blank" onclick="if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 && window.event.preventDefault) window.event.preventDefault();this.newWindow = window.open('http://lite.webim.ru/decoda/webim/client.php?locale=ru', 'webim', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=600,height=420,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;" style="font-size:14px;padding-left:30px;color:#A77934">Нашли ошибку?</a>
+166
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
ЖИСТОКЕ
+173
function isNullorUndefined(val) {
var u;
return ((u === val) || (val == null));
}
Из онлайн примеров одного разработчика элементов интерфейса (за большие бабки продают между прочим).