Stelford Titanium Calendar not adding events to ical on ios - ios

I have some code that is supposed to use the stelford calendar to add events to my ical on an iphone 3gs with ios 5.1.1 however when I test it out on the phone It doesn't add it to my calendar. If anyone could help that would be great!
//Calendar Dates
var sd = new Date();
sd.setYear(startYear);
sd.setMonth(startMonth);
sd.setDate(startDay);
sd.setHours(startHour);
sd.setMinutes(startMinute);
var ed = new Date();
ed.setYear(endYear);
ed.setMonth(endMonth);
ed.setDate(endDay);
ed.setHours(endHour);
ed.setMinutes(endMinute);
btn2.addEventListener('click',function(e){
var ticalendar = require("com.ti.calendar");
var ev = ticalendar.createItem({
title: meetName,
startDate: sd,
endDate: ed,
location: meetLoc
});
var p = ev.saveEvent();
Ti.API.info(p);
alert('Event Saved to Your Calendar!');
});
Thanks for any help.

Try This.
var sd = new Date();
var ed = new Date();
ed = ed.setMinutes(59);
btn2.addEventListener('click',function(e){
var ticalendar = require("com.ti.calendar");
var ev = ticalendar.createItem({
title: "meetName",
startDate: sd,
endDate: ed,
location: "meetLoc"
});
var p = ev.saveEvent();
Ti.API.info(p);
if(p.error!="none"){
alert("Error :- " + p.error );
}else{
alert("Add Successfully");
}
alert('Event Saved to Your Calendar!');
});
I think this is help for you Cheers:)

Related

Locking Cell after entering Data only one time via Google Apps Script

getting error at TypeError: Cannot read property 'range' of undefined code.gs.2
function protectOnEdit(event) {
var range = event.range();
var Col= parseInt(range.getColumn());
console.log(Col);
if(Col==3)
{
var timeZone = Session.getScriptTimeZone();
var stringDate = Utilities.formatDate(new Date(), timeZone, 'dd/MM/yy HH:mm');
var description = 'Protected on ' + stringDate;
var protection = range.protect().setDescription(description);
var me = Session.getEffectiveUser();
//user who installed trigger
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
}
}
it was working fine before but now it's not...

Google Sheets: Trigger script IF value

Can someone please help me with this script?
function HistoryTrigger() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
if (sheet.getName() == "Status") {
var activeCell = sheet.getRange("G11");
if (activeCell.getValue() ="OK") {
recordHistory();
}
}
}
function recordHistory() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Historie");
var source = sheet.getRange("A2:B2");
var values = source.getValues();
values[0][0] = new Date();
sheet.appendRow(values[0]);
};
I want the trigger to start when Status!G11="OK", then start recordHistory().
try:
if (activeCell.getValue() =="OK") {
double == is proper syntax for if statements.
You may run this functoin with onEdit:
function onEdit(e) {
if (e.range.getSheet().getName() === 'Status') { HistoryTrigger(); }
}
It'll check each time user change something. It will run when G11 is OK on sheet 'Status'.
To combine all together, I suggest passing e into HistoryTrigger:
function onEdit(e) {
HistoryTrigger(e);
}
function HistoryTrigger(e) {
var ss = e.range.getSheet();
if (ss.getName() === 'Status') {
var activeCell = ss.getRange("G11");
if (activeCell.getValue() == "OK") {
recordHistory();
}
}
}
function recordHistory() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Historie");
var source = sheet.getRange("A2:B2");
var values = source.getValues();
values[0][0] = new Date();
sheet.appendRow(values[0]);
};

Firefox SDK: correct way to play audio from the url in 2015 year?

I want to add ability to my addon to play audio from URL. At MDN I not found information about this. I found this and this and this and this answers - but this is about local file and what the correct answer for 2015 year?
I have an answer from 2016 ;)
That code will not work with Multi-process Firefox (will be released in 2016):
var window = require('sdk/window/utils').getMostRecentBrowserWindow();
var audio = new window.Audio('http://example.com/audio.mp3');
vaudio.play();
Because sdk/window/utils. To understand why read this topic on MDN.
Solution is page-worker:
main.js:
var pageWorkers = require("sdk/page-worker");
var audioWorker = pageWorkers.Page({
contentURL: './blank.html', //blank html file in `data` directory
contentScriptFile: './worker.js'
});
// for example i want to play song from url
var url = 'http://some-url.com/some-song.mp3';
// send msg to worker to play this url
audioWorker.port.emit('play', url);
worker.js
var audio = new window.Audio;
self.port.on('play', function(url) {
audio.src = url;
audio.play();
});
It works in my extension and will work with new Multi-process Firefox release.
#Noitidart Future is coming and at 2015 you can write much less code!
var window = require('sdk/window/utils').getMostRecentBrowserWindow();
var audio = new window.Audio('http://example.com/audio.mp3');
audio.play();
This works for me Im not sure how 2015 it is, but i wrote like a couple months ago:
Cu.import('resource://gre/modules/osfile.jsm');
Cu.import('resource://gre/modules/Services.jsm');
function audioContextCheck() {
if (typeof Services.appShell.hiddenDOMWindow.AudioContext !== 'undefined') {
return new Services.appShell.hiddenDOMWindow.AudioContext();
} else if (typeof Services.appShell.hiddenDOMWindow.mozAudioContext !== 'undefined') {
return new Services.appShell.hiddenDOMWindow.mozAudioContext();
} else {
throw new Error('AudioContext not supported');
}
}
var audioContext = audioContextCheck();
var audioBuffer;
var getSound = new XMLHttpRequest();
getSound.open('get', OS.Path.toFileURI(OS.Path.join(OS.Constants.Path.desktopDir, 'zirzir.mp3')), true);
getSound.responseType = 'arraybuffer';
getSound.onload = function() {
audioContext.decodeAudioData(getSound.response, function(buffer) {
audioBuffer = buffer;
var playSound = audioContext.createBufferSource();
playSound.buffer = audioBuffer;
playSound.connect(audioContext.destination);
playSound.start(audioContext.currentTime);
});
};

Can't select future dates in phonegap app after iOS 7 upgrade

I am using phone gap date picker plugin for iOS, which was working fine, but can't select future date after iOS7 upgrade .
This is my js code,
// Handling for iOS and Android
$('.appointmentTime').on('click', function(e) {
var currentField = $(this);
window.plugins.datePicker.show((function() {
var o = {
date: new Date(),
mode: 'time', // date or time or blank for both
allowOldDates: true
};
if (myConfig.deviceType === myConfig.deviceTypeEnum.IOS) {
o.allowFutureDates = true;
}
return o;
})(), function(returnDate) {
var selectedDate;
selectedDate = new Date(returnDate);
currentField.blur();
});
}

Can't access to event posted values

i'm writing a little google apps script which allow to select several names among a list of developpers. But in my doPost(e) method, i can't access to the array of posted values (it's undefinded), event if i check all the checkboxes...
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
// add the new menu
var menuEntries = [];
menuEntries.push({name: "Edit page", functionName: "start"})
ss.addMenu("My tools", menuEntries);
}
function start() {
var app = UiApp.createApplication();
app.setTitle("Edit page");
var formPanel = app.createFormPanel();
var mainPanel = app.createVerticalPanel();
var gridPanel = app.createGrid(1, 2);
// developpers
var developperPanel = app.createVerticalPanel()
var developpers = [];
developpers.push( "John", "Peter", "Max", "Johnny" );
for (var i = 1; i < developpers.length; ++i) {
var checkbox = app.createCheckBox(developpers[i]).setName("dev"+i);
developperPanel.add(checkbox);
}
gridPanel.setWidget(0,0,app.createLabel("Developpers : "));
gridPanel.setWidget(0,1,developperPanel);
// submit button
mainPanel.add(gridPanel);
mainPanel.add(app.createSubmitButton().setText("OK"));
formPanel.add(mainPanel);
app.add(formPanel);
var ss = SpreadsheetApp.getActive();
ss.show(app);
}
function doPost(e) {
var app = UiApp.getActiveApplication();
app.add(app.createLabel(e.values[0])); // Here is the error.
return app;
}
In the exemple, the list is fixed but in my real script, i create the list thanks to the Spreadsheet.
Thanks
Max
The correct way to see the checkboxes values is using e.parameter[name], like you said yourself on a comment. Here is some code example:
function start() {
//...
var developpers = ["John", "Peter", "Max", "Johnny"];
//you were skiping the first developer
for (var i = 0; i < developpers.length; ++i) { //array starts on zero, not one
var checkbox = app.createCheckBox(developpers[i]).setName("dev"+i);
developperPanel.add(checkbox);
}
//...
}
function doPost(e) {
var app = UiApp.getActiveApplication();
var developpers = ["John", "Peter", "Max", "Johnny"]; //repeat it here or make it global, if it's static like this
var checked = [];
for( var i in developpers )
if( e.parameter['dev'+i] == 'true' )
checked.push(developpers[i]);
app.add(app.createLabel(checked));
return app;
}
You should use e.parameter.yourCheckBoxName
for example:
function doPost(e) {
var app = UiApp.getActiveApplication();
app.add(app.createLabel(e.parameter.dev1); // Access checkbox by its name
return app;
}
This would show status of check box "Peter", when it is checked. You can modify based on your need.

Resources