Skip to content

Instantly share code, notes, and snippets.

@elnikkis
Created December 23, 2014 13:14
Show Gist options
  • Save elnikkis/5f58c176863caaa4140e to your computer and use it in GitHub Desktop.
Save elnikkis/5f58c176863caaa4140e to your computer and use it in GitHub Desktop.
(function(d,f,s){
s=d.createElement("script");
s.src="//code.jquery.com/jquery-2.1.3.min.js";
s.onload=function(){f(jQuery.noConflict(1))};
d.body.appendChild(s);
})(document,function($){
//onloadうぜーーー
//のろいをとく
var x = setTimeout('');
for(var i=0;i<x;i++){clearTimeout(i);}
// 休講情報: table#grvCancel
// 補講情報: table#grvSupplement
var t1 = '#grvCancel';
var t2 = '#grvSupplement';
var filter = function(t_id, value){
$(t_id+' tr').css('visibility', 'visible');
if(value != 'ALL'){
$(t_id+" tr:not(:contains('" +value+ "'))").css('visibility', 'collapse');
$(t_id+' tr:first').css('visibility', 'visible');
}
};
// trにtdを用意する
line1 = $('<tr id="line1">');
line2 = $('<tr id="line2">');
for(var i=0; i<9; i++){
line1.append('<td>');
line2.append('<td>');
}
$('#grvCancel tr:first').after(line1);
$('#grvSupplement tr:first').after(line2);
// table:'#grvCancel', list:選択肢, nth: カラム, tnum: テーブル番号
var add = function(table, list, nth, tnum){
var gradeList = $('<select>').attr('name', table).css({width: '100%'});
for(var i=0; i<list.length; i++){
$('<option>').attr('value', list[i]).text(list[i])
.appendTo(gradeList);
}
$('#line'+tnum+' td:eq('+nth+')').css({
margin: '0',
padding: '0',
//fontSize: '15px'
}).append(gradeList);
//gradeListイベントを追加
gradeList.change(function(){
console.log(this.value);
filter(this.name, this.value);
//filter(t2);
});
};
var grade = ['ALL', 'B1', 'B2', 'B3', 'B4', 'M1', 'M2', 'D1', 'D2', 'D3'];
var cour = ['ALL', '共通', '機械', '電気・電子情報', '情報・知能', '環境・生命', '建築・都市'];
add('#grvCancel', grade, 5, 1);
add('#grvCancel', cour, 6, 1);
add('#grvSupplement', grade, 5, 2);
add('#grvSupplement', cour, 6, 2);
// ch.childrenの並び
// 番号, 休講日(ソート), 時限(fil), 時間割名(fil), 担当教員(search), 開講年次(学年fil), 開講学科(fil), 学生への連絡, 補講の予定
//隠したい要素にvisibility: collapse;を設定する
// 自分用なら下の行をコメントアウトすると最初からフィルターされて(ばぐあり!)便利
//filter('#grvCancel', 'B3');
//filter('#grvSupplement', '情報・知能');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment