當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular.IWindowService類代碼示例

本文整理匯總了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;
    }
  };
開發者ID:bhollis,項目名稱:DIM,代碼行數:59,代碼來源:filter-link.component.ts

示例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);
 }
開發者ID:jcwest,項目名稱:deck,代碼行數:13,代碼來源:scheduler.factory.ts

示例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;
 };
開發者ID:delphiactual,項目名稱:DIM,代碼行數:11,代碼來源:storage.component.ts

示例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'));
   }
 };
開發者ID:delphiactual,項目名稱:DIM,代碼行數:15,代碼來源:storage.component.ts

示例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;
      });
  };
開發者ID:delphiactual,項目名稱:DIM,代碼行數:43,代碼來源:random-loadout.component.ts

示例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'));
 };
開發者ID:delphiactual,項目名稱:DIM,代碼行數:6,代碼來源:storage.component.ts

示例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);
      }
    };
  }
開發者ID:jcwest,項目名稱:deck,代碼行數:83,代碼來源:scheduler.factory.ts


注:本文中的angular.IWindowService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。