本文整理汇总了TypeScript中angular.IWindowService类的典型用法代码示例。如果您正苦于以下问题:TypeScript IWindowService类的具体用法?TypeScript IWindowService怎么用?TypeScript IWindowService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IWindowService类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: switch
this.addFilter = (filter: string) => {
let itemNameFilter = false;
if (filter === 'item name') {
itemNameFilter = true;
filter = $window.prompt($i18next.t('Filter.EnterName')) || '';
filter = filter.trim();
}
if (filter === 'notes:value') {
itemNameFilter = true;
filter = $window.prompt($i18next.t('Filter.EnterNote')) || '';
filter = `notes:"${filter.trim()}"`;
}
if (
filter.indexOf('light:') === 0 ||
filter.indexOf('quality:') === 0 ||
filter.indexOf('stack:') === 0
) {
const type = filter.split(':');
const lightFilterType = type[1];
let light = $window.prompt(`Enter a ${type[0]} value:`);
if (light) {
light = light.trim();
} else {
return;
}
filter = `${type[0]}:`;
switch (lightFilterType) {
case 'value':
filter += light;
break;
case '>value':
filter += `>${light}`;
break;
case '>=value':
filter += `>=${light}`;
break;
case '<value':
filter += `<${light}`;
break;
case '<=value':
filter += `<=${light}`;
break;
default:
filter = '';
break;
}
}
const text = SearchService.query;
if (itemNameFilter) {
SearchService.query = filter + (text.length ? ` ${text}` : '');
} else if (`${text} `.indexOf(`${filter} `) < 0) {
SearchService.query = text.length > 0 ? `${text} ${filter}` : filter;
}
};
示例2:
unsubscribe: () => {
suspended = true;
if (scheduler) {
scheduler.next(false);
scheduler.unsubscribe();
}
scheduler = null;
source = null;
this.$timeout.cancel(pendingRun);
document.removeEventListener('visibilitychange', watchDocumentVisibility);
this.$window.removeEventListener('offline', suspendScheduler);
this.$window.removeEventListener('online', resumeScheduler);
}
示例3: reportException
vm.driveSync = () => {
if ($window.confirm($i18next.t('Storage.GDriveSignInWarning'))) {
return SyncService.GoogleDriveStorage.authorize()
.then(vm.forceSync)
.catch((e) => {
$window.alert($i18next.t('Storage.GDriveSignInError') + e.message);
reportException('Google Drive Signin', e);
});
}
return null;
};
示例4: FileReader
vm.importData = () => {
const reader = new FileReader();
reader.onload = () => {
// TODO: we're kinda trusting that this is the right data here, no validation!
SyncService.set(JSON.parse(reader.result), true)
.then(() => $q.all(SyncService.adapters.map(refreshAdapter)));
$window.alert($i18next.t('Storage.ImportSuccess'));
};
const file = (element(document.getElementById('importFile')!)[0] as HTMLInputElement).files![0];
if (file) {
reader.readAsText(file);
} else {
$window.alert($i18next.t('Storage.ImportNoFile'));
}
};
示例5: Set
vm.applyRandomLoadout = (e) => {
e.preventDefault();
if (vm.disableRandomLoadout || !$window.confirm($i18next.t('Loadouts.Randomize'))) {
return null;
}
const store = vm.stores.find((s) => s.current);
if (!store) {
return null;
}
const types = new Set([
'Class',
'Primary',
'Special',
'Heavy',
'Kinetic',
'Energy',
'Power',
'Helmet',
'Gauntlets',
'Chest',
'Leg',
'ClassItem',
'Artifact',
'Ghost'
]);
const storeService = (store.destinyVersion === 2 ? D2StoresService : dimStoreService);
// Any item equippable by this character in the given types
const applicableItems = storeService.getAllItems().filter((i) => types.has(i.type) && i.canBeEquippedBy(store));
// Use "random" as the value function
const loadout = optimalLoadout(applicableItems, () => Math.random(), $i18next.t('Loadouts.Random'));
vm.disableRandomLoadout = true;
return dimLoadoutService
.applyLoadout(store, loadout, true)
.finally(() => {
vm.disableRandomLoadout = false;
});
};
示例6:
reader.onload = () => {
// TODO: we're kinda trusting that this is the right data here, no validation!
SyncService.set(JSON.parse(reader.result), true)
.then(() => $q.all(SyncService.adapters.map(refreshAdapter)));
$window.alert($i18next.t('Storage.ImportSuccess'));
};
示例7: createScheduler
public createScheduler(pollSchedule = SETTINGS.pollSchedule): IScheduler {
let scheduler = new Subject();
let lastRunTimestamp = new Date().getTime();
let pendingRun: IPromise<void> = null;
let suspended = false;
// When creating the timer, use last run as the dueTime (first arg); zero can lead to concurrency issues
// where the scheduler will fire shortly after being subscribed to, resulting in surprising immediate refreshes
let source = Observable.timer(pollSchedule, pollSchedule);
const run = (): void => {
if (suspended) {
return;
}
this.$timeout.cancel(pendingRun);
lastRunTimestamp = new Date().getTime();
scheduler.next(true);
pendingRun = null;
};
source.subscribe(run);
const suspendScheduler = (): void => {
this.$log.debug('auto refresh suspended');
suspended = true;
};
const scheduleNextRun = (delay: number) => {
// do not schedule another run if a run is pending
suspended = false;
pendingRun = pendingRun || this.$timeout(run, delay);
};
const resumeScheduler = (): void => {
suspended = false;
const now = new Date().getTime();
this.$log.debug('auto refresh resumed');
if (now - lastRunTimestamp > pollSchedule) {
run();
} else {
scheduleNextRun(pollSchedule - (now - lastRunTimestamp));
}
};
const watchDocumentVisibility = (): void => {
this.$log.debug('document visibilityState changed to: ', document.visibilityState);
if (document.visibilityState === 'visible') {
resumeScheduler();
} else {
suspendScheduler();
}
};
const scheduleImmediate = (): void => {
run();
suspended = true;
scheduleNextRun(pollSchedule);
};
document.addEventListener('visibilitychange', watchDocumentVisibility);
this.$window.addEventListener('offline', suspendScheduler);
this.$window.addEventListener('online', resumeScheduler);
scheduler.next(true);
return {
subscribe: scheduler.subscribe.bind(scheduler),
scheduleImmediate: scheduleImmediate,
unsubscribe: () => {
suspended = true;
if (scheduler) {
scheduler.next(false);
scheduler.unsubscribe();
}
scheduler = null;
source = null;
this.$timeout.cancel(pendingRun);
document.removeEventListener('visibilitychange', watchDocumentVisibility);
this.$window.removeEventListener('offline', suspendScheduler);
this.$window.removeEventListener('online', resumeScheduler);
}
};
}