Example #1
0
        each(result[2], (prerequisite, k) => {
          // remove stuff and generate link
          prerequisite = trim(prerequisite, ' .');
          output += `<a href="courses?title=${encodeURIComponent(prerequisite)}">${prerequisite}</a>`;

          // add comma if there are more prerequisites
          if (result[2].length > k + 1) {
            output += ',&nbsp;';
          }
        });
Example #2
0
    const fetchParams = () => {
      const params = $routeParams;

      $scope.filter = {
        code: params.code,
        course: params.course,
        teachers_str: params.teacher,
        fields_str: params.field,
        'fields_str#~': params.pm ? '(PM)' : null,
      };

      if (!isUndefined(params.timeframe)) {
        $scope.timeframe = params.timeframe;

        params.timeframe = params.timeframe.toLowerCase();
        if (params.timeframe.charAt(0) === 'w' || params.timeframe.charAt(0) === 's') {
          $scope.filter['term#='] = params.timeframe.charAt(0);
          params.timeframe = params.timeframe.slice(1);
        }

        // eslint-disable-next-line max-len
        const pattern = /(?:^(?:20)?(\d{2})$)|(?:(?:20)?(\d{2})([+-])(?:(?:20)?(\d{2}))?)|(?:([WS])S?(?:20)?(\d{2}))|([WS])/i;
        const r = compact(pattern.exec(trim(params.timeframe)));

        if (!isEmpty(r)) {
          if (isEmpty(r[2])) {
            $scope.filter['year#='] = `20${r[1]}`;
          } else if (r[2] === '+') {
            // year lower limit
            $scope.filter['year#<'] = `20${r[1]}`;
          } else if (r[2] === '-') {
            if (!isEmpty(r[3])) {
              // years range
              $scope.filter['year#<'] = `20${r[1]}`;
              $scope.filter['year#>'] = `20${r[3]}`;
            } else {
              // year upper limit
              $scope.filter['year#>'] = `20${r[1]}`;
            }
          }
        }
      }

      $scope.filter = pickBy($scope.filter);
      $scope.regulation_id = params.regulation ? parseInt(params.regulation, 10) : '';
    };
Example #3
0
      (query, oldQuery) => {
        if (query === oldQuery) {
          return;
        }

        const match = query.match(/^([ws])?s?(\d{2,4})?:? (.*)$/i);
        if (match) {
          this.search.filter = pickBy({
            term: isEmpty(match[1]) ? '' : match[1].toUpperCase(),
            year: isEmpty(match[2]) ? '' : `20${match[2]}`.slice(-4),
            course: trim(match[3]),
          });
        } else {
          // this is just a backup if the regex above fails
          this.search.filter = { course: query };
        }

        this.applyFilter();
      },
(some(null, null): false);
(sortedIndex(null, null): 0);
(sortedIndexBy(null, null, null): 0);
(sortedIndexOf(null, null): -1);
(sortedLastIndex(null, null): 0);
(sortedLastIndexBy(null, null, null): 0);
(sortedLastIndexOf(null, null): -1);
(startCase(null): '');
(startsWith(null, null, null): false);
(template(null, null): Function);
(times(null, null): Array<*>);
(toFinite(null): 0);
(toInteger(null): 0);
(toLength(null): 0);
(toLower(null): '');
(toNumber(null): 0);
(toSafeInteger(null): 0);
(toString(null): '');
(toUpper(null): '');
(trim(null, null): '');
(trimEnd(null, null): '');
(trimStart(null, null): '');
(truncate(null, null): '');
(unescape(null): '');
(uniqueId(null): string);
(upperCase(null): '');
(upperFirst(null): '');
(each(null, null): null);
(eachRight(null, null): null);
(first(null): void);