SHOW:
|
|
- or go back to the newest paste.
| 1 | function doGet() {
| |
| 2 | var app = UiApp.createApplication().setTitle('DHS: Kurzweil Calendar');
| |
| 3 | ||
| 4 | //Create a panel which holds all the form elelemnts | |
| 5 | var vertMainPanel = app.createVerticalPanel().setId('vertMainPanel').setStyleAttribute('padding','30px');
| |
| 6 | ||
| 7 | //Create the form elelemnts | |
| 8 | var lblTeacherName = app.createLabel('Teacher Name:');
| |
| 9 | var txtTeacherName = app.createTextBox().setName('txtTeacherName');
| |
| 10 | ||
| 11 | var lblExt = app.createLabel('Ext:');
| |
| 12 | var txtExt = app.createTextBox().setName('txtExt');
| |
| 13 | ||
| 14 | var lblDate = app.createLabel('Date:');
| |
| 15 | var boxDate = app.createDateBox().setId('boxDate').setName('boxDate').setFormat(UiApp.DateTimeFormat.DATE_SHORT);
| |
| 16 | ||
| 17 | var lbxSubject = app.createListBox().setId('lbxSubject').setName('lbxSubject');
| |
| 18 | var lstSubjItems = ['-- Select One --','Algebra I (OCS)','Algebra II','Algebra II (Honors)','Agriscience Applications','Agriscience Applications (OCS)','Anatomy and Physiology', | |
| 19 | 'Anatomy and Physiology (Honors)','Animal Science','American Sign Language II','Apparel I','Art History (AP)','Advanced Functions and Modeling', | |
| 20 | 'Automotive Computer System Diagnostics','Automotive Brakes','Automotive Service','Automotive Service (OCS)', 'Benchmarks','Bible History','Biology','Biology (AP)', | |
| 21 | 'Biology (Honors)','Biology (OCS)','Biomedical Technology','Biotechnology and Agriscience','Calculus AB (AP)','Calculus BC (AP)','Carpentry I','Carpentry I (OCS)', | |
| 22 | 'Carpentry III','Chemistry','Chemistry (AP)','Chemistry (Honors)','Choral Arts (Beginning)','Civics and Economics','Civics and Economics (Honors)','Computer Programming I', | |
| 23 | 'Computer Science (AP)','Computer Technology','Concert Band II (Beginning)', 'Concert Band II (Proficient)','Core and Sustainable Construction', | |
| 24 | 'Core and Sustainable Construction (OCS)','Digital Media I','Digitial Media I (OCS)','Digital Media II','Discrete Mathematics','Drafting I','Drafting Architecture II (Honors)', | |
| 25 | 'Drafting Architecture III (Honors)','Earth and Environmental Science','Earth and Environmental Sceince (AP)','Earth and Environmental Science (Honors)','Early Childhood Ed I', | |
| 26 | 'eCommerce I (Honors)','English I','English I (Honors)','English II','English II (Honors)','English II (OCS)','English III','English III (Honors)', | |
| 27 | 'English III (OCS)','English IV','English IV (Honors)','English IV (OCS)','English Lang and Comp (AP)','English Language Arts II','English Language Arts III', | |
| 28 | 'Engish Literature (AP)','European History (AP)','Fashion Merchandising','Financial Management (OCS)','Foods I','Foods I (OCS)','Foods II - Enterprise', | |
| 29 | 'Foods II - Advanced (OCS)','French I','French II','French III (Honors)','Functional Finances','Geometry', 'Geometry (Honors)','German I','German II','German III (Honors)', | |
| 30 | 'Health and Physical Education','Health Sciences (Advanced Studies)','Health Team Relations','Human Geography (AP)','Holocaust and Peace Studies','Horticulture I', | |
| 31 | 'Horticulture I (OCS)','Horticulture II','Horticulture II (OCS)','Integrated Math I','Interior Design I','Introduction to Math','Japanese I','JROTC I','JROTC II', | |
| 32 | 'JROTC III','JROTC IV','Latin I','Latim II','Latin III (Honors)','Leadership Development','Marketing Management','Masonry I','Masonry I (OCS)','Masonry III', | |
| 33 | 'Microsoft Excel and Access','Microsoft Word PowerPoint and Publisher','Multimedia and Webpage Design','Music Business and Recording (Beginning)','Occupational Preparations I', | |
| 34 | 'Occupational Preparations II','Occupational Preparations III','Occupational Preparations IV','Parent and Child Development','Parent and Child Development (OCS)', | |
| 35 | 'Personal Finance', 'Personal Finance (OCS)','Physical Science','Physics (Honors)','Pre-Calculus (Honors)','Professional Management and Leadership I', | |
| 36 | 'Professional Management and Leadership II','Psychology','Physcology (AP)','Psychology (Honors)','SAT Preparation','Science and Technical Visualization I', | |
| 37 | 'Science and Technical Visualization II','Social Studies (OCS)','Spanish I','Spanish II','Spanish III (Honors)','Spanish IV (Honors)','Special Topics of Mathematics', | |
| 38 | 'Symphonic Band II (Beginning)','Symphonic Band II (Intermediate)','Symphonic Band II (Proficient)','Technology Engineering and Design','Theatre Arts (Beginning)', | |
| 39 | 'Theatre Arts (Intermediate)','US History','US History (AP)','US History (Honors)','Visual Arts (Beginning)','Visual Arts (Intermediate)','Visual Arts (Proficient)', | |
| 40 | 'Visual Arts (Advanced)','Visual Arts Specialization in Ceramics (Advanced)','Vocal Ensemble (Intermediate)','Vocal Ensemble (Proficient)','Wind Ensemble II (Intermediate)', | |
| 41 | 'Wind Ensemble II (Proficient)','Wind Ensemble II (Advanced)','World Geography','World History','World History','World History (Honors)']; | |
| 42 | lstSubjItems.sort(); | |
| 43 | ||
| 44 | for (var l = 0; l < lstSubjItems.length; l++) {
| |
| 45 | lbxSubject.addItem(lstSubjItems[l]); | |
| 46 | } | |
| 47 | ||
| 48 | var lbxPeriod = app.createListBox().setId('lbxPeriod').setName('lbxPeriod');
| |
| 49 | var lstPrdItems = ['-- Select One --','1st Period','2nd Period','3rd Period','4th Period']; | |
| 50 | lstPrdItems.sort(); | |
| 51 | ||
| 52 | for (var l = 0; l < lstPrdItems.length; l++) {
| |
| 53 | lbxPeriod.addItem(lstPrdItems[l]); | |
| 54 | } | |
| 55 | ||
| 56 | var lblStudentNum = app.createLabel('Number of Students:');
| |
| 57 | var txtStudentNum = app.createTextBox().setName('txtStudentNum');
| |
| 58 | ||
| 59 | var txtRadioGrp1 = app.createTextBox().setName('txtRadioGrp1').setVisible(false);
| |
| 60 | var txtRadioGrp2 = app.createTextBox().setName('txtRadioGrp2').setVisible(false);
| |
| 61 | var txtElementsID = app.createTextBox().setName('txtElementsID');
| |
| 62 | var txtQuiaLink = app.createTextBox().setName('txtQuiaLink');
| |
| 63 | var txtElementsIDP = app.createHorizontalPanel().add(app.createLabel('enter a value')).add(txtElementsID).setVisible(false);
| |
| 64 | var txtQuiaLinkP = app.createHorizontalPanel().add(app.createLabel('enter a value')).add(txtQuiaLink).setVisible(false);
| |
| 65 | var txtQuiaPass = app.createTextBox().setName('txtQuiaPass').setVisible(false);
| |
| 66 | //Create Source Radio Button Group | |
| 67 | - | var radSource1 = app.createRadioButton('group1', 'Hard-Copy').setFormValue('Hard-Copy').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Hard-Copy'));
|
| 67 | + | var radSource1 = app.createRadioButton('group1', 'Hard-Copy').setValue(true).setFormValue('Hard-Copy').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Hard-Copy'));
|
| 68 | var radSource2 = app.createRadioButton('group1', 'Electronic-Copy').setFormValue('Electronic-Copy').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Electronic-Copy'));
| |
| 69 | //Create Type Radio Button Group | |
| 70 | - | var radSource3 = app.createRadioButton('group2', 'Teacher-Made Exam').setFormValue('Teacher-Made Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp2).setText('Teacher-Made Exam'));
|
| 70 | + | var radSource3 = app.createRadioButton('group2', 'Teacher-Made Exam').setFormValue('Teacher-Made Exam').setValue(true).addClickHandler(app.createClientHandler().forTargets(txtRadioGrp2).setText('Teacher-Made Exam'));
|
| 71 | var radSource4 = app.createRadioButton('group2', 'Elements Exam').setFormValue('Elements Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Elements Exam'));
| |
| 72 | var radSource5 = app.createRadioButton('group2', 'Quia Exam').setFormValue('Quia Exam').addClickHandler(app.createClientHandler().forTargets(txtRadioGrp1).setText('Quia Exam'));
| |
| 73 | ||
| 74 | var btnCreate = app.createButton('Create Event');
| |
| 75 | ||
| 76 | //Client Handlers for textBoxes | |
| 77 | var showTxtElementHandler = app.createClientHandler().forTargets(txtElementsIDP).setVisible(true); | |
| 78 | var hideTxtElementHandler = app.createClientHandler().forTargets(txtElementsIDP).setVisible(false); | |
| 79 | radSource4.addClickHandler(showTxtElementHandler); | |
| 80 | radSource3.addClickHandler(hideTxtElementHandler); | |
| 81 | radSource5.addClickHandler(hideTxtElementHandler); | |
| 82 | ||
| 83 | var showtxtQuiaLinkHandler = app.createClientHandler().forTargets(txtQuiaLinkP).setVisible(true); | |
| 84 | var hidetxtQuiaLinkHandler = app.createClientHandler().forTargets(txtQuiaLinkP).setVisible(false); | |
| 85 | radSource5.addClickHandler(showtxtQuiaLinkHandler); | |
| 86 | radSource3.addClickHandler(hidetxtQuiaLinkHandler); | |
| 87 | radSource4.addClickHandler(hidetxtQuiaLinkHandler); | |
| 88 | ||
| 89 | //Create handler which will execute 'createEvents(e)' on clicking the button | |
| 90 | var evtHandler = app.createServerClickHandler('createEvents');
| |
| 91 | evtHandler.addCallbackElement(vertMainPanel); | |
| 92 | //Add this handler to the button | |
| 93 | btnCreate.addClickHandler(evtHandler); | |
| 94 | ||
| 95 | //Add all the elemnts to the panel | |
| 96 | - | vertMainPanel.add(lblTeacherName) |
| 96 | + | var grid = app.createGrid(13,2).setCellPadding(2); |
| 97 | - | .add(txtTeacherName) |
| 97 | + | vertMainPanel.add(grid); |
| 98 | - | .add(lblExt) |
| 98 | + | grid.setWidget(0,0,lblTeacherName) |
| 99 | - | .add(txtExt) |
| 99 | + | .setWidget(0,1,txtTeacherName) |
| 100 | - | .add(lblDate) |
| 100 | + | .setWidget(1,0,lblExt) |
| 101 | - | .add(boxDate) |
| 101 | + | .setWidget(1,1,txtExt) |
| 102 | - | .add(lbxSubject) |
| 102 | + | .setWidget(2,0,lblDate) |
| 103 | - | .add(lbxPeriod) |
| 103 | + | .setWidget(2,1,boxDate) |
| 104 | - | .add(lblStudentNum) |
| 104 | + | .setText(3,0,'Period') |
| 105 | - | .add(txtStudentNum) |
| 105 | + | .setWidget(4,0,lbxPeriod) |
| 106 | - | .add(radSource1) |
| 106 | + | .setText(3,1,'Subject') |
| 107 | - | .add(radSource2) |
| 107 | + | .setWidget(4,1,lbxSubject) |
| 108 | - | .add(txtRadioGrp1) |
| 108 | + | .setWidget(5,0,lblStudentNum) |
| 109 | - | .add(radSource3) |
| 109 | + | .setWidget(5,1,txtStudentNum) |
| 110 | - | .add(radSource4) |
| 110 | + | .setWidget(6,0,radSource1) |
| 111 | - | .add(txtElementsIDP) |
| 111 | + | .setWidget(6,1,radSource2) |
| 112 | - | .add(radSource5) |
| 112 | + | .setWidget(7,0,txtRadioGrp1) |
| 113 | - | .add(txtQuiaLinkP) |
| 113 | + | .setWidget(8,0,radSource3) |
| 114 | - | .add(txtQuiaPass) |
| 114 | + | .setWidget(9,0,radSource4) |
| 115 | - | .add(txtRadioGrp2) |
| 115 | + | .setWidget(9,1,txtElementsIDP) |
| 116 | - | .add(btnCreate) |
| 116 | + | .setWidget(10,0,radSource5) |
| 117 | .setWidget(10,1,txtQuiaLinkP) | |
| 118 | .setWidget(11,0,txtQuiaPass) | |
| 119 | .setWidget(11,1,txtRadioGrp2) | |
| 120 | .setWidget(12,0,btnCreate); | |
| 121 | ||
| 122 | //Add this panel to the application | |
| 123 | app.add(vertMainPanel); | |
| 124 | ||
| 125 | //Return the application | |
| 126 | return app; | |
| 127 | } | |
| 128 | ||
| 129 | function createEvents(e){
| |
| 130 | ||
| 131 | //Get the active application | |
| 132 | var app = UiApp.getActiveApplication(); | |
| 133 | ||
| 134 | try{
| |
| 135 | //Get the entries | |
| 136 | var ssTeacher = e.parameter.txtTeacherName; | |
| 137 | var ssExt = e.parameter.txtExt; | |
| 138 | var ssSubject = e.parameter.lbxSubject; | |
| 139 | var ssPeriod = e.parameter.lbxPeriod; | |
| 140 | var ssStudentNum = e.parameter.txtStudentNum; | |
| 141 | var ssSource = e.parameter.txtRadioGrp1; | |
| 142 | var ssType = e.parameter.txtRadioGrp2; | |
| 143 | var eventDate = e.parameter.boxDate; | |
| 144 | var eventCalSubject = ssPeriod + ": " + ssTeacher + " (" + ssStudentNum + ")";
| |
| 145 | var eventCalDetails = "Extension: " + ssExt + "\n" + | |
| 146 | "Subject: " + ssSubject + "\n\n" + | |
| 147 | - | var cal = CalendarApp.getCalendarById('davie.k12.nc.us_d2mv2eb8aspuant1vb5j6r3sis@group.calendar.google.com');//Change the calendar id
|
| 147 | + | |
| 148 | "Type: " + ssType + "\n"; | |
| 149 | - | cal.createAllDayEvent(eventCalSubject, eventDate, {description:eventCalDetails});
|
| 149 | + | |
| 150 | //Get the calendar | |
| 151 | // var cal = CalendarApp.getCalendarById('davie.k12.nc.us_d2mv2eb8aspuant1vb5j6r3sis@group.calendar.google.com');//Change the calendar id
| |
| 152 | //Create the events | |
| 153 | // cal.createAllDayEvent(eventCalSubject, eventDate, {description:eventCalDetails});
| |
| 154 | ||
| 155 | //Log the entries in a spreadsheet | |
| 156 | var sheet = SpreadsheetApp.openById('0Aur3owCpuUY-dGJIOGZ1LXhqT2FNMGVXSGNJazFnUmc#gid=0').getActiveSheet();//Change the spreadhseet key to yours
| |
| 157 | var lastRow = sheet.getLastRow(); | |
| 158 | var targetRange = sheet.getRange(lastRow+1, 1, 1, 10).setValues([[new Date(),eventDate,ssTeacher,ssExt,ssSubject,ssPeriod,ssSource,ssType,ssStudentNum,'Event created']]); | |
| 159 | return app; | |
| 160 | ||
| 161 | //Show the confirmation message | |
| 162 | app.add(app.createLabel('Kurzweil Calendar Event created successfully...'));
| |
| 163 | //Make the form panel invisible | |
| 164 | app.getElementById('vertMainPanel').setVisible(false);
| |
| 165 | return app; | |
| 166 | } | |
| 167 | ||
| 168 | //If an error occurs, show it on the panel | |
| 169 | catch(e){
| |
| 170 | app.add(app.createLabel('Error occured: '+ e));
| |
| 171 | return app; | |
| 172 | } | |
| 173 | } |