Last active
September 16, 2018 15:36
-
-
Save monry/1e28ee0fb0d42720bf0c22b9bfa11ac4 to your computer and use it in GitHub Desktop.
Copy workshop participations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rows = 10; | |
var useDisplayName = true; | |
var typeMaps = [ | |
{ type: '参加者', priority: 1, className: 'participation_table_area' }, | |
{ type: '補欠者', priority: 2, className: 'waitlist_table_area' }, | |
{ type: 'キャンセル', priority: 3, className: 'cancelled_table_area' }, | |
]; | |
var list = []; | |
for (let typeMap of typeMaps) { | |
$(`div.${typeMap.className} p.user_info`) | |
.each((index, u) => { | |
list.push({ | |
typeMap: typeMap, | |
imageURL: $(u).find('img').attr('src'), | |
displayName: $(u).find('img').attr('alt'), | |
userName: $(u).find('span.user_name').text().replace(/^\((.*)\)$/, "$1"), | |
}); | |
}); | |
} | |
list = list.sort((a, b) => { | |
if (a.typeMap.priority > b.typeMap.priority) { | |
return 1; | |
} | |
if (a.typeMap.priority < b.typeMap.priority) { | |
return -1; | |
} | |
if (a.displayName.toLowerCase() > b.displayName.toLowerCase()) { | |
return 1; | |
} | |
if (a.displayName.toLowerCase() < b.displayName.toLowerCase()) { | |
return -1; | |
} | |
return 0; | |
}); | |
var result = ''; | |
for (var i = 0; i < Math.ceil(list.length / rows); i++) { | |
for (var j = 0; j < rows; j++) { | |
var index = i * rows + j; | |
if (list.length <= index) { | |
break; | |
} | |
if (j > 0) { | |
result += '\t'; | |
} | |
result += ''; // Skip column for checkbox | |
result += '\t'; | |
result += `=IMAGE("${list[index].imageURL}")`; | |
result += '\t'; | |
result += useDisplayName ? list[index].displayName : list[index].userName; | |
} | |
result += '\n'; | |
} | |
copy(result); // Copy result text into clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usege
Customize
列数
var rows = 1;
とすれば直列な一覧表が作れます出力するユーザ名を変更
useDisplayName
をfalse
にすれば某IT勉強会支援プラットフォーム上のユーザ名を出力可能です