mainfrm_pane.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. function OnInitializeData() {
  5. OnAllList();
  6. }
  7. function OnCloseForm() {
  8. }
  9. function OnException(err) {
  10. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  11. }
  12. //////////////////////////////////////////////////////////////////////////
  13. // Callback Functions.
  14. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  15. function OnAllList(){
  16. callStudent(11);
  17. }
  18. var g_studengs = [
  19. '宫照堰*',
  20. '杨蕊源*',
  21. '梁含璋#',
  22. '余天然',
  23. '黄千骏',
  24. '曹宝泉',
  25. '鞠欣睿',
  26. '王鑫宇',
  27. '邓钧',
  28. '宋岩',
  29. '丹增达哇'
  30. ];
  31. function getRandomArrayElements(arr, count) {
  32. var shuffled = arr.slice(0),
  33. i = arr.length,
  34. min = i - count,
  35. temp, index;
  36. while (i-- > min) {
  37. index = Math.floor((i + 1) * Math.random());
  38. temp = shuffled[index];
  39. shuffled[index] = shuffled[i];
  40. shuffled[i] = temp;
  41. }
  42. return shuffled.slice(min);
  43. }
  44. function callStudent(num) {
  45. var students = getRandomArrayElements(g_studengs, num);
  46. ui.list.table = [
  47. ['姓名']
  48. ].concat((students.map(item => {
  49. return [item];
  50. })));
  51. var idx = 0;
  52. var colors = students.map(item => { //@item.@String colors.@Array
  53. if (item.indexOf('*') !== -1) {return [idx++, 0, '#00FF00'];}
  54. if (item.indexOf('#') !== -1) {return [idx++, 0, '#00FFFF'];}
  55. return [idx++, 0, '#FFFF00'];
  56. });
  57. colors.forEach(item => {
  58. ui.list.color = item;
  59. });
  60. ui.list.head_size = [0];
  61. }
  62. function OnSingle() {
  63. callStudent(1);
  64. model.Test(ui.list.table);
  65. }
  66. function OnMulti() {
  67. callStudent(5);
  68. model.Test(ui.list.table);
  69. }
  70. //////////////////////////////////////////////////////////////////////////
  71. // Utils Functions.
  72. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  73. /*Usage of BLOCK_EVENT
  74. BLOCK_EVENT(()=>{
  75. ui.[name].[var] = ...;
  76. });
  77. */
  78. function BLOCK_EVENT(cb) {
  79. ui.block_event = true;
  80. cb();
  81. ui.block_event = false;
  82. }