kendo-datetimepicker: how to set min/max - kendo-ui

How can I set the min/max after the datetimepicker has been created?
With the datepicker I can do something like this:
var start = $("#start").kendoDatePicker();
start.max(endDate);
However, the datetimepicker won't allow that.
I get the error as
"Uncaught TypeError: start.max is not a function"

Do it like kendo doc here does, just like this i limit min to yesterday and max to tomorrow :
var datepicker = $("#datepicker").data("kendoDatePicker");
var $today = new Date();
var $yesterday = new Date($today);
$yesterday.setDate($today.getDate() - 1);
var $tomorrow = new Date($today);
$tomorrow.setDate($today.getDate() + 1);
var min = datepicker.min($yesterday);
var max = datepicker.max($tomorrow);
Here is the kendo dojo as working example

Related

"TypeError: Cannot read property 'getEvents' of undefined" when trying to delete calendar events from Google Sheets

I'm using a code that I've found for deleting bulk events from google calendar, based on values from google sheets (the code is in the google sheet script editor).
It's working when I'm using it on my personal calendar, but when I try to delte events from a google classroom calendar (which I'm its manager), I get the error message "TypeError: Cannot read property 'getEvents' of undefined". Do you have any idea why this is happening?
function delete_google_calendar()
{
var spreadsheet = SpreadsheetApp.getActiveSheet();
var startYear = spreadsheet.getRange("B67").getValue();
var startMonth = spreadsheet.getRange("F67").getValue();
var startDay = spreadsheet.getRange("H67").getValue();
var endYear = spreadsheet.getRange("B68").getValue();
var endMonth = spreadsheet.getRange("F68").getValue();
var endDay = spreadsheet.getRange("H68").getValue();
var fromDate = new Date(startYear,startMonth,startDay,0,0,0);
var toDate = new Date(endYear,endMonth,endDay,0,0,0);
var calendarId = "mandel-institute.org.il_classroom682af58e#group.calendar.google.com";
// First number: Year
//Second number: Month (January=0)
//Third number: Day
var calendar = CalendarApp.getCalendarsByName(calendarId)[0];
var events = calendar.getEvents(fromDate, toDate);
for(var i=0; i<events.length;i++){
var ev = events[i];
ev.deleteEvent();
}
}
Apps Script offers to methods for retrieving calendars: getCalendarsByName(name) and getCalendarById(id)
Thereby, since you have a caledar id available, you need to use the method getCalendarById(id):
var calendar = CalendarApp.getCalendarById(calendarId)
Since the id identifies a calendar unambiguously only one calendar (instead of an array) will be returned, so skip the [0].

Returning certain rows which meet a criteria - Google Apps Script

What I am trying to do is: I have a list, with N being a date and O being a checkbox. I need to get the rows which =N < Today() && O=False, then return A:B of those corresponding rows. I've tried it every which way, and I can't get it to work. Any suggestions?
function msg1(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var wscl = ss.getSheetByName('Connection List');
var contact = wscl.getRange("A2:B").getValues();
var msg1date = wscl.getRange("N2:N").getValues();
var msg1sent = wscl.getRange("O2:O").getValues();
var MILLIS_PER_DAY = 1000 * 60 * 60 * 24;
var now = new Date();
var yesterday = new Date(now.getTime() - MILLIS_PER_DAY);
for(var i=0;i<msg1sent.length;i++){
if(msg1sent =="FALSE"&& msg1date < yesterday){
var row=i+1;
}
}
}
If you use getValues() of a checkbox it returns true or false booleans. If you use getDisplayValues() it returns "TRUE" or "FALSE" strings. And for the dates I just used valueOf() but you can also use getTime(). The easiest way to figure all of this out is to create some intermediate temporary variables and view them in the Script Debugger and you can see all of the return values there.
function msg1(){
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Connection List');
var ct=sh.getRange(2,1,sh.getLastRow()-1,2).getValues();
var date=sh.getRange(2,14,sh.getLastRow()-1,1).getValues();//date
var sent=sh.getRange(2,15,sh.getLastRow()-1,1).getValues();//checkbox
var dt=new Date();
var rows=[];
var today=new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()).valueOf();//0000 or midnight
for(var i=0;i<sent.length;i++){
var t1=sent[i][0];
var t2=new Date(date[i][0]).valueOf();
var t3=today;
if(sent[i][0]==false && new Date(date[i][0]).valueOf()<today){
rows.push(ct[i]);
}
}
Logger.log(rows);
}
If you use getDisplayValues() then it would look like this:
function msg1(){
var ss=SpreadsheetApp.getActive();
var sh=ss.getSheetByName('Connection List');
var ct=sh.getRange(2,1,sh.getLastRow()-1,2).getValues();
var date=sh.getRange(2,14,sh.getLastRow()-1,1).getValues();//date
var sent=sh.getRange(2,15,sh.getLastRow()-1,1).getDisplayValues();//checkbox
var dt=new Date();
var rows=[];
var today=new Date(dt.getFullYear(),dt.getMonth(),dt.getDate()).valueOf();
for(var i=0;i<sent.length;i++){
var t1=sent[i][0];
var t2=new Date(date[i][0]).valueOf();
var t3=today;
if(sent[i][0]=="FALSE" && new Date(date[i][0]).valueOf()<today){
rows.push(ct[i]);
}
}
Logger.log(rows);
}

Trouble using the Moment module

Here is some Parse cloud code I am having problem with:
var moment = require('moment');
Parse.Cloud.define
("myCloudFunction", function(request, response)
{
var now = moment();
var later = moment("2017-07-09T20:00:00");
var x = 7;
if (later.isAfter(now)) x = x-1;
else x = x+1;
console.log(x);
});
I get this error message when I run it:
Error: TypeError: Object Sun Jul 09 2017 20:00:00 GMT+0000 (UTC) has no method 'isAfter' at main.js:406:12 (Code: 141, Version: 1.2.18)
Of course I have simplified things to come to the point of my question.
What am I doing wrong?
The hosted version of moment.js file used by Cloud Code is stuck at version 1.7.2 and the isAfter method is 2.0+.
Download a new copy of moment.js and put it in your cloud/ folder, then require it like this:
var moment = require('cloud/moment.js');
The line var moment = require('moment'); needs to be outside the function as it defines a requirement for the whole file. I usually put all my require statements up the top of the file.
So your above code should look like this:
var moment = require('moment');
Parse.Cloud.define
("myCloudFunction", function(request, response)
{
var now = moment();
var later = moment("2017-07-09T20:00:00");
var x = 7;
if (later.isAfter(now)) x = x-1;
else x = x+1;
console.log(x);
});
It appears that some of the functions are no working even in the native moment.js supported by parse (moment v1.7.2)... while using add function it doesn't work... only when working with my downloaded version of moment (2.8.4)
See for yourselves with below code:
var moment = require('moment');
var moment2 = require('cloud/moment.js');
Parse.Cloud.define ("momentChecks", function(request, response)
{
var later = moment("2017-07-09T20:00:00");
var later2 = moment("2017-07-09T20:00:00");
var later3 = moment2("2017-07-09T20:00:00");
later.add(1, 'days').format("dddd, MMMM Do YYYY, h:mm:ss a");
later2.add(2, 'days').format("dddd, MMMM Do YYYY, h:mm:ss a");
later3.add(2, 'days').format("dddd, MMMM Do YYYY, h:mm:ss a");
var message = "\nlater: " + later.format() + "\nlater2: " + later2.format() + "\nlater3: " + later3.format();
console.log(message);
response.success(message);
});

How to pass a input value into a function using GAS

I will try and keep this brief. I am attempting to make a google web app in google spreadsheet that will allow me to enter a values for min and max.
I have been able to create the GUI and add it to the panel. But I can't seem to pass the integer being entered into another function. I've tried everything, I'm relatively new to creating Google Script so I'm sorry if this comes across as a bit of a noobish problem.
Here is all the code so far :
function onOpen() {
var ss = SpreadsheetApp.getActive();
var menuEntries = [];
menuEntries.push({name: "Open Dialog", functionName: "showDialog"});
ss.addMenu("Min/Max", menuEntries);
}
//creating a panel to add the min and max of low to high for scoring
function showDialog() {
max = 10;
var app = UiApp.createApplication();
app.setTitle("My Applicaition");
var panel = app.createVerticalPanel();
var textBox = app.createTextBox();
var label = app.createLabel("Set the min value for 'Low'");
//had to create a hidden element with id="min" for a global value that can be updated
var min = app.createHidden().setValue('0').setName('min').setId('min');
textBox.setName('myTextBox').setId('myTextBox');
var button = app.createButton('Submit');
panel.add(label);
panel.add(textBox);
panel.add(min);
panel.add(button);
//click handler for setting the value of min to the new value
var clickHandler = app.createServerClickHandler("responedToSubmit");
button.addClickHandler(clickHandler);
clickHandler.addCallbackElement(panel);
app.add(panel);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}
function responedToSubmit(e) {
var app = UiApp.getActiveApplication();
var textBoxValue = e.parameter.myTextBox;
Logger.log(e.parameter.min);
if (typeof textBoxValue != "number") {
var num = parseInt(textBoxValue);
app.getElementById('min').setValue(num);
Logger.log("textBoxValue is = "+textBoxValue+"\n min value is = "+e.parameter.min);
} else {
throw "value needs to be set as number";
}
return app.close();
}
This is where I believe things aren't going according to plan :
function responedToSubmit(e) {
var app = UiApp.getActiveApplication();
var textBoxValue = e.parameter.myTextBox;
Logger.log(e.parameter.min);
if (typeof textBoxValue != "number") {
var num = parseInt(textBoxValue);
app.getElementById('min').setValue(num);
Logger.log("textBoxValue is = "+textBoxValue+"\n min value is = "+e.parameter.min);
} else {
throw "value needs to be set as number";
}
return app.close();
}
I find that each time I test the .setValue() will not update the value of 'min' and I cannot see why. Can you please help?
You need to add textBox element to callBack elements list of your clickHandler.
Try this:
//click handler for setting the value of min to the new value
var clickHandler = app.createServerClickHandler("responedToSubmit");
clickHandler.addCallbackElement(panel);
clickHandler.addCallbackElement(textBox);
button.addClickHandler(clickHandler);
app.add(panel);

Pass a variable into ScrollTo

SOLVED
Here's the result:
window.onload = function timeScroll()
{
var current_date = new Date();
hour_value = current_date.getHours();
var big_number = hour_value*833.3
$(window).scrollTop(big_number)
}
PREVIOUS QUESTION
I'm working on a page, that takes the time of day (hour) and uses that time to scroll to a particular point on the page. I multiply the getHour in order to get a variable I've called big_number. However, I can't seem to pass that variable into my scroll function.
This tells me that it's calculating the number correctly:
window.onload = function timeScroll()
{
var current_date = new Date();
hour_value = current_date.getHours();
var big_number = hour_value*833.3
window.alert(big_number);
}
I'm looking to do something like this:
window.onload = function timeScroll()
{
var current_date = new Date();
hour_value = current_date.getHours();
var big_number = hour_value*833.3
**scrollTo(x,big_number)**
}
Anything you've got helps. Also, here's the site live...
http://newmedia.emerson.edu/~caleb_ungewitter/weather/index.html

Resources