123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- ////////////////////////////////////////////////////////////////////////////
- // System Pre-define Functions
- // 95099372-ef3e-11ea-9c81-bf848405c62e
- function OnInitializeData() {
- OnAllList();
- }
- function OnCloseForm() {
- }
- function OnException(err) {
- //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
- }
- //////////////////////////////////////////////////////////////////////////
- // Callback Functions.
- // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
- function OnAllList(){
- callStudent(11);
- }
- var g_studengs = [
- '宫照堰*',
- '杨蕊源*',
- '梁含璋#',
- '余天然',
- '黄千骏',
- '曹宝泉',
- '鞠欣睿',
- '王鑫宇',
- '邓钧',
- '宋岩',
- '丹增达哇'
- ];
- function getRandomArrayElements(arr, count) {
- var shuffled = arr.slice(0),
- i = arr.length,
- min = i - count,
- temp, index;
- while (i-- > min) {
- index = Math.floor((i + 1) * Math.random());
- temp = shuffled[index];
- shuffled[index] = shuffled[i];
- shuffled[i] = temp;
- }
- return shuffled.slice(min);
- }
- function callStudent(num) {
- var students = getRandomArrayElements(g_studengs, num);
- ui.list.table = [
- ['姓名']
- ].concat((students.map(item => {
- return [item];
- })));
- var idx = 0;
- var colors = students.map(item => { //@item.@String colors.@Array
- if (item.indexOf('*') !== -1) {return [idx++, 0, '#00FF00'];}
- if (item.indexOf('#') !== -1) {return [idx++, 0, '#00FFFF'];}
- return [idx++, 0, '#FFFF00'];
- });
- colors.forEach(item => {
- ui.list.color = item;
- });
- ui.list.head_size = [0];
- }
- function OnSingle() {
- callStudent(1);
- model.Test(ui.list.table);
- }
- function OnMulti() {
- callStudent(5);
- model.Test(ui.list.table);
- }
- //////////////////////////////////////////////////////////////////////////
- // Utils Functions.
- // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
- /*Usage of BLOCK_EVENT
- BLOCK_EVENT(()=>{
- ui.[name].[var] = ...;
- });
- */
- function BLOCK_EVENT(cb) {
- ui.block_event = true;
- cb();
- ui.block_event = false;
- }
|