removing phone, senses, social
This commit is contained in:
Родитель
bd831d9eaf
Коммит
ce6c7aa843
|
@ -1,92 +0,0 @@
|
||||||
///<reference path='refs.ts'/>
|
|
||||||
module TDev.RT {
|
|
||||||
//? An calendar appointment
|
|
||||||
//@ stem("a") immutable ctx(general,gckey,walltap) cap(calendar)
|
|
||||||
export class Appointment
|
|
||||||
extends RTValue
|
|
||||||
{
|
|
||||||
private _subject: string = undefined;
|
|
||||||
private _details: string = undefined;
|
|
||||||
private _location: string = undefined;
|
|
||||||
private _startTime: DateTime = undefined;
|
|
||||||
private _endTime: DateTime = undefined;
|
|
||||||
private _source: string = undefined;
|
|
||||||
private _organizer: Contact = undefined;
|
|
||||||
private _attendees: Collection<Contact> = undefined;
|
|
||||||
|
|
||||||
private _is_private: boolean = false;
|
|
||||||
private _is_all_day_event: boolean = false;
|
|
||||||
private _status: string = undefined;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super()
|
|
||||||
}
|
|
||||||
|
|
||||||
static mk(subject: string, details: string, location: string, startTime: DateTime, endTime: DateTime, source : string, organizer : Contact, attendees : Collection<Contact>, isPrivate : boolean, isAllDay :boolean, status :string): Appointment {
|
|
||||||
var a = new Appointment();
|
|
||||||
a._subject = subject;
|
|
||||||
a._details = details;
|
|
||||||
a._location = location;
|
|
||||||
a._startTime = startTime;
|
|
||||||
a._endTime = endTime;
|
|
||||||
a._source = source;
|
|
||||||
a._organizer = organizer;
|
|
||||||
a._attendees = attendees;
|
|
||||||
a._is_private = isPrivate;
|
|
||||||
a._is_all_day_event = isAllDay;
|
|
||||||
a._status = status;
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Indicates if this appointment is private
|
|
||||||
public is_private(): boolean { return this._is_private; }
|
|
||||||
|
|
||||||
//? Indicates if this is an all day event
|
|
||||||
public is_all_day_event(): boolean { return this._is_all_day_event; }
|
|
||||||
|
|
||||||
//? Gets your status (free, tentative, busy, outofoffice)
|
|
||||||
public status(): string { return this._status || ''; }
|
|
||||||
|
|
||||||
//? Gets the organizer
|
|
||||||
public organizer(): Contact { return this._organizer; }
|
|
||||||
|
|
||||||
//? Gets the end time
|
|
||||||
public end_time(): DateTime { return this._endTime; }
|
|
||||||
|
|
||||||
//? Gets the location
|
|
||||||
public start_time(): DateTime { return this._startTime; }
|
|
||||||
|
|
||||||
//? Gets the location
|
|
||||||
public location(): string { return this._location || ''; }
|
|
||||||
|
|
||||||
//? Gets the subject
|
|
||||||
public subject(): string { return this._subject || ''; }
|
|
||||||
|
|
||||||
//? Gets the details
|
|
||||||
public details(): string { return this._details || ''; }
|
|
||||||
|
|
||||||
//? Gets the source of this appointment (facebook, etc...)
|
|
||||||
public source(): string { return this._source || ''; }
|
|
||||||
|
|
||||||
//? Gets the list of attendees. Each contact contains a name and email address.
|
|
||||||
public attendees(): Collection<Contact> { return this._attendees || Collection.mkAny(Contact); }
|
|
||||||
|
|
||||||
//? Posts the appointment to the wall
|
|
||||||
public post_to_wall(s: IStackFrame): void
|
|
||||||
{
|
|
||||||
super.post_to_wall(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getViewCore(s: IStackFrame, b:BoxBase): HTMLElement {
|
|
||||||
var d = div("item");
|
|
||||||
d.appendChild(div("item-title", this.subject()));
|
|
||||||
d.appendChild(div("item-subtitle", this.location() + ", " + this.start_time() + ":" + this.end_time()));
|
|
||||||
d.appendChild(div("item-subtle", this.source()));
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public debuggerDisplay(clickHandler: () => any): HTMLElement {
|
|
||||||
return this.getViewCore(null, null).withClick(clickHandler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -96,18 +96,6 @@ module TDev.RT {
|
||||||
//? Creates an invalid Contact Collection instance
|
//? Creates an invalid Contact Collection instance
|
||||||
export function contact_collection() : Collection<Contact> { return undefined; }
|
export function contact_collection() : Collection<Contact> { return undefined; }
|
||||||
|
|
||||||
//? Creates an invalid Appointment instance
|
|
||||||
//@ cap(calendar)
|
|
||||||
export function appointment() : Appointment { return undefined; }
|
|
||||||
|
|
||||||
//? Creates an invalid Appointment Collection instance
|
|
||||||
//@ cap(calendar)
|
|
||||||
export function appointment_collection() : Collection<Appointment> { return undefined; }
|
|
||||||
|
|
||||||
//? Creates an invalid Motion instance
|
|
||||||
//@ cap(motion)
|
|
||||||
export function motion() : Motion { return undefined; }
|
|
||||||
|
|
||||||
//? Creates an invalid Camera instance
|
//? Creates an invalid Camera instance
|
||||||
export function camera() : Camera { return undefined; }
|
export function camera() : Camera { return undefined; }
|
||||||
|
|
||||||
|
|
|
@ -1,80 +0,0 @@
|
||||||
///<reference path='refs.ts'/>
|
|
||||||
module TDev.RT {
|
|
||||||
//? Describes the motion of the device
|
|
||||||
//@ ctx(general,walltap) cap(motion)
|
|
||||||
export class Motion
|
|
||||||
extends RTValue
|
|
||||||
{
|
|
||||||
private _acceleration: Vector3;
|
|
||||||
private _rotation_speed: Vector3;
|
|
||||||
private _gravity: Vector3;
|
|
||||||
private _time: DateTime;
|
|
||||||
private _yaw: number;
|
|
||||||
private _pitch: number;
|
|
||||||
private _roll: number;
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//? Gets the linear acceleration of the device, in gravitational units.
|
|
||||||
//@ tandre
|
|
||||||
public acceleration(): Vector3 {
|
|
||||||
return this._acceleration;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Gets the device rotation speed in degrees per sec.
|
|
||||||
//@ tandre
|
|
||||||
public rotation_speed(): Vector3 {
|
|
||||||
return this._rotation_speed;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Gets the gravity vector associated with this reading.
|
|
||||||
//@ tandre
|
|
||||||
public gravity(): Vector3 {
|
|
||||||
return this._gravity;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Gets a timestamp indicating the time at which the reading was calculated.
|
|
||||||
//@ tandre
|
|
||||||
public time(): DateTime {
|
|
||||||
return this._time;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Gets the yaw of the attitude in degrees
|
|
||||||
//@ tandre
|
|
||||||
public yaw(): number {
|
|
||||||
return this._yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Gets the pitch of the attitude in degrees
|
|
||||||
//@ tandre
|
|
||||||
public pitch(): number {
|
|
||||||
return this._pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Gets the roll of the attitude in degrees
|
|
||||||
//@ tandre
|
|
||||||
public roll(): number {
|
|
||||||
return this._roll;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Displays the motion reading to the wall.
|
|
||||||
public post_to_wall(s : IStackFrame): void {
|
|
||||||
var rt = s.rt;
|
|
||||||
if (this.acceleration())
|
|
||||||
rt.postBoxedText('acc: ' + this.acceleration.toString(), s.pc);
|
|
||||||
if (this.rotation_speed())
|
|
||||||
rt.postBoxedText('rot: ' + this.rotation_speed.toString(), s.pc);
|
|
||||||
if (this.gravity())
|
|
||||||
rt.postBoxedText('g: ' + this.gravity().toString(), s.pc);
|
|
||||||
if (this.yaw())
|
|
||||||
rt.postBoxedText('yaw: ' + this.yaw.toString(), s.pc);
|
|
||||||
if (this.pitch())
|
|
||||||
rt.postBoxedText('pitch: ' + this.pitch.toString(), s.pc);
|
|
||||||
if (this.roll())
|
|
||||||
rt.postBoxedText('roll: ' + this.roll.toString(), s.pc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
25
lib/Phone.ts
25
lib/Phone.ts
|
@ -34,19 +34,6 @@ module TDev.RT {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//? Chooses a phone number from the contact list
|
|
||||||
//@ cap(contacts) flow(SourceContacts) returns(Link) uiAsync
|
|
||||||
export function choose_phone_number(r: ResumeCtx)
|
|
||||||
{
|
|
||||||
Social.chooseContactAsync().done(c => {
|
|
||||||
var url: string = c ? (c.phone_number() || c.work_phone() || c.home_phone()) : "";
|
|
||||||
if (url)
|
|
||||||
r.resumeVal(Link.mk(url, LinkKind.phoneNumber));
|
|
||||||
else
|
|
||||||
r.resumeVal(undefined);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Allows the user to save the phone number
|
//? Allows the user to save the phone number
|
||||||
//@ cap(contacts) flow(SinkContacts)
|
//@ cap(contacts) flow(SinkContacts)
|
||||||
export function save_phone_number(phone_number: string): void {
|
export function save_phone_number(phone_number: string): void {
|
||||||
|
@ -73,18 +60,6 @@ module TDev.RT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//? Chooses an address from the contacts
|
|
||||||
//@ cap(contacts) flow(SourceContacts) returns(Link) uiAsync
|
|
||||||
export function choose_address(r: ResumeCtx) {
|
|
||||||
Social.chooseContactAsync().done((c : Contact) => {
|
|
||||||
var url: string = c ? (c.home_address() || c.work_address()) : "";
|
|
||||||
if (url)
|
|
||||||
r.resumeVal(Link.mk(url, LinkKind.address));
|
|
||||||
else
|
|
||||||
r.resumeVal(undefined);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Indicates if the phone is on 'battery' or 'external' power source.
|
//? Indicates if the phone is on 'battery' or 'external' power source.
|
||||||
//@ returns(string) quickAsync
|
//@ returns(string) quickAsync
|
||||||
export function power_source(r : ResumeCtx) { //: string {
|
export function power_source(r : ResumeCtx) { //: string {
|
||||||
|
|
|
@ -308,17 +308,10 @@ module TDev.RT {
|
||||||
export function has_motion() : boolean
|
export function has_motion() : boolean
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
//? Gets the current motion that combines data from the accelerometer, compass and gyroscope if available.
|
|
||||||
//@ stub cap(motion)
|
|
||||||
//@ tandre
|
|
||||||
export function motion() : Motion
|
|
||||||
{ return undefined; }
|
|
||||||
|
|
||||||
//? Gets the current orientation in degrees if available. (x,y,z) is also called (pitch, roll, yaw) or (alpha, beta, gamma).
|
//? Gets the current orientation in degrees if available. (x,y,z) is also called (pitch, roll, yaw) or (alpha, beta, gamma).
|
||||||
//@ cap(orientation) returns(Vector3) quickAsync
|
//@ cap(orientation) returns(Vector3) quickAsync
|
||||||
export function orientation(r : ResumeCtx)
|
export function orientation(r : ResumeCtx)
|
||||||
{
|
{
|
||||||
|
|
||||||
DeviceOrientation.orientation(r);
|
DeviceOrientation.orientation(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
147
lib/Social.ts
147
lib/Social.ts
|
@ -52,153 +52,6 @@ module TDev.RT {
|
||||||
//@ [result].writesMutable
|
//@ [result].writesMutable
|
||||||
export function create_place(name: string, location: Location_): Place { return Place.mk(name, location); }
|
export function create_place(name: string, location: Location_): Place { return Place.mk(name, location); }
|
||||||
|
|
||||||
//? Searches for recent messages in a social network (twitter, facebook)
|
|
||||||
//@ async flow(SinkSafe) returns(Collection<Message>) obsolete
|
|
||||||
//@ [result].writesMutable
|
|
||||||
//@ [network].deflStrings("facebook", "twitter")
|
|
||||||
export function search(network: string, terms: string, r: ResumeCtx) // : Collection<Message>
|
|
||||||
{
|
|
||||||
var links = Collections.create_message_collection();
|
|
||||||
r.resumeVal(links);
|
|
||||||
|
|
||||||
/*
|
|
||||||
var url = Cloud.getPrivateApiUrl('runtime/social/search?network=' + encodeURIComponent(network) + '&query=' + encodeURIComponent(terms));
|
|
||||||
var request = WebRequest.mk(url, undefined);
|
|
||||||
request
|
|
||||||
.sendAsync()
|
|
||||||
.then((response: WebResponse) =>
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
var json = response.content_as_json();
|
|
||||||
if (json) {
|
|
||||||
var links = Collections.create_message_collection();
|
|
||||||
for (var i = 0; i < json.count(); ++i) {
|
|
||||||
var m = json.at(i);
|
|
||||||
var msg = Social.create_message(m.string("message"));
|
|
||||||
msg.set_from(m.string('from'));
|
|
||||||
if (m.contains_key('time'))
|
|
||||||
msg.set_time(m.time('time'));
|
|
||||||
msg.set_link(m.string('link'));
|
|
||||||
msg.set_picture_link(m.string('picturelink'));
|
|
||||||
msg.set_source(m.string('source'));
|
|
||||||
var loc = m.field('loc');
|
|
||||||
if (loc)
|
|
||||||
msg.set_location(Location_.mkShort(loc.number('latitude'), loc.number('longitude')));
|
|
||||||
links.add(msg);
|
|
||||||
}
|
|
||||||
r.resumeVal(links);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
Time.log('social search failed');
|
|
||||||
}
|
|
||||||
r.resumeVal(undefined);
|
|
||||||
}).done();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Searches for places nearby. The distance is in meters.
|
|
||||||
//@ obsolete flow(SinkSafe) stub()
|
|
||||||
//@ [result].writesMutable
|
|
||||||
//@ [network].defl("facebook") [location].deflExpr('senses->current_location') [distance].defl(1000)
|
|
||||||
export function search_places_nearby(network: string, terms: string, location: Location_, distance: number): Collection<Place> {
|
|
||||||
return Collections.create_place_collection();
|
|
||||||
}
|
|
||||||
|
|
||||||
var _fakeContacts: Contact[] = [
|
|
||||||
Contact.mkFake("Orlando", "N.", "Gee", "orlando0@adventure-works.com", "245-555-0173", "1.jpg"),
|
|
||||||
Contact.mkFake("Janet", "M.", "Gates", "janet1@adventure-works.com", "710-555-0173", "9.jpg"),
|
|
||||||
Contact.mkFake("Donna", "F.", "Carreras", "donna0@adventure-works.com", "279-555-0130", "10.jpg"),
|
|
||||||
Contact.mkFake("Lucy", null, "Harrington", "lucy0@adventure-works.com", "828-555-0186", "32.jpg"),
|
|
||||||
Contact.mkFake("Rosmarie","J.", "Carroll", "rosmarie0@adventure-works.com", "244-555-0112", "42.jpg"),
|
|
||||||
Contact.mkFake("Dominic", "P.", "Gash", "dominic0@adventure-works.com", "192-555-0173", "5.jpg"),
|
|
||||||
Contact.mkFake("Kathleen", "M.", "Garza", "kathleen0@adventure-works.com", "150-555-0127", "72.jpg"),
|
|
||||||
Contact.mkFake("Johnny", "A.", "Caprio", "johnny0@adventure-works.com", "112-555-0191","28.jpg"),
|
|
||||||
Contact.mkFake("Christopher", "R.", "Beck","christopher1@adventure-works.com", "1 (11) 500 555-0132", "48.jpg"),
|
|
||||||
Contact.mkFake("Donald", "L.", "Blanton", "donald0@adventure-works.com", "357-555-0161", "184.jpg")
|
|
||||||
];
|
|
||||||
|
|
||||||
//? Retrieves the list of contacts
|
|
||||||
//@ async hidden cap(contacts) flow(SourceContacts) returns(Collection<Contact>)
|
|
||||||
//@ [network].defl("phone")
|
|
||||||
export function contacts(network:string, r : ResumeCtx)
|
|
||||||
{
|
|
||||||
search_contacts("", r);
|
|
||||||
}
|
|
||||||
|
|
||||||
export var askCalendarAccessAsync = (r: ResumeCtx): Promise => { // boolean
|
|
||||||
return r.rt.host.askSourceAccessAsync("calendar", "your calendar and appointments.", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
export var askContactsAccessAsync = (r : ResumeCtx): Promise => { // boolean
|
|
||||||
return r.rt.host.askSourceAccessAsync("contacts", "your contact list.", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
export var searchContactsAsync = (prefix: string): Promise => { // Collection<Contact>
|
|
||||||
var prefix = prefix.toUpperCase();
|
|
||||||
var cs: Contact[] = [];
|
|
||||||
_fakeContacts.forEach((c) => {
|
|
||||||
if (c.name().toUpperCase().indexOf(prefix) > -1)
|
|
||||||
cs.push(c.clone());
|
|
||||||
});
|
|
||||||
return Promise.as(Collection.mkAny(Contact, cs));
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Searches for contacts by name.
|
|
||||||
//@ async cap(contacts) flow(SourceContacts) returns(Collection<Contact>)
|
|
||||||
export function search_contacts(prefix:string, r : ResumeCtx)
|
|
||||||
{
|
|
||||||
Social.askContactsAccessAsync(r)
|
|
||||||
.then((allow) => {
|
|
||||||
if (allow) return Social.searchContactsAsync(prefix);
|
|
||||||
else return Promise.as(Collection.mkAny(Contact));
|
|
||||||
}).done(cs => r.resumeVal(cs));
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Chooses an email from the contact list
|
|
||||||
//@ cap(contacts) flow(SourceContacts) returns(Link) uiAsync
|
|
||||||
//@ [result].writesMutable
|
|
||||||
export function choose_email(r : ResumeCtx)
|
|
||||||
{
|
|
||||||
Social.chooseContactAsync().done(c => {
|
|
||||||
var url : string = c ? (c.email() || c.work_email() || c.personal_email()) : "";
|
|
||||||
if (url)
|
|
||||||
r.resumeVal(Link.mk(url, LinkKind.email));
|
|
||||||
else
|
|
||||||
r.resumeVal(undefined);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export var chooseContactAsync = (): Promise => {
|
|
||||||
var c = _fakeContacts[Math_.random(_fakeContacts.length)].clone();
|
|
||||||
return Promise.as(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Chooses a contact from the contact list
|
|
||||||
//@ cap(contacts) flow(SourceContacts) returns(Contact) uiAsync
|
|
||||||
//@ [result].writesMutable
|
|
||||||
export function choose_contact(r: ResumeCtx) {
|
|
||||||
Social.chooseContactAsync().done(c => r.resumeVal(c));
|
|
||||||
}
|
|
||||||
|
|
||||||
export var searchAppointmentsAsync = (start: DateTime, end: DateTime): Promise => { // Collection<Appointment>
|
|
||||||
Util.log('returning fake appointments');
|
|
||||||
return Promise.as(Collection.mkAny(Appointment));
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Searches for appointments in a given time range
|
|
||||||
//@ async cap(calendar) flow(SourceCalendar) returns(Collection<Appointment>)
|
|
||||||
//@ [start].deflExpr('time->now') [end].deflExpr('time->tomorrow')
|
|
||||||
export function search_appointments(start:DateTime, end:DateTime, r : ResumeCtx) // : Collection<Appointment>
|
|
||||||
{
|
|
||||||
Social.askCalendarAccessAsync(r)
|
|
||||||
.then((allow) => {
|
|
||||||
if (allow) return Social.searchAppointmentsAsync(start, end);
|
|
||||||
else return Promise.as(Collection.mkAny(Appointment));
|
|
||||||
}).done(cs => r.resumeVal(cs));
|
|
||||||
}
|
|
||||||
|
|
||||||
//? Creates a new contact
|
//? Creates a new contact
|
||||||
//@ [nickname].writesMutable
|
//@ [nickname].writesMutable
|
||||||
//@ [result].writesMutable
|
//@ [result].writesMutable
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
///<reference path='../rt/refs.ts'/>
|
///<reference path='../rt/refs.ts'/>
|
||||||
///<reference path='App.ts'/>
|
///<reference path='App.ts'/>
|
||||||
///<reference path='Appointment.ts'/>
|
|
||||||
///<reference path='Event.ts'/>
|
///<reference path='Event.ts'/>
|
||||||
///<reference path='Bazaar.ts'/>
|
///<reference path='Bazaar.ts'/>
|
||||||
///<reference path='Board.ts'/>
|
///<reference path='Board.ts'/>
|
||||||
|
@ -35,7 +34,6 @@
|
||||||
///<reference path='Math.ts'/>
|
///<reference path='Math.ts'/>
|
||||||
///<reference path='Media.ts'/>
|
///<reference path='Media.ts'/>
|
||||||
///<reference path='Message.ts'/>
|
///<reference path='Message.ts'/>
|
||||||
///<reference path='Motion.ts'/>
|
|
||||||
///<reference path='Number.ts'/>
|
///<reference path='Number.ts'/>
|
||||||
///<reference path='NumberMap.ts'/>
|
///<reference path='NumberMap.ts'/>
|
||||||
///<reference path='Page.ts'/>
|
///<reference path='Page.ts'/>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче