diff --git a/media/js/config.js b/media/js/config.js index 5a23b44a0c507207c02b96c50fab41887ebd4dc4..451cdfc8c237c73a69d16cfbaa0236e42caafbb9 100644 --- a/media/js/config.js +++ b/media/js/config.js @@ -6,6 +6,12 @@ var SitePath = g_SitePath; // Далее юзаем глобальные переменные с префиксом "g" +var singleNumRegexp = /\w_(\d+)/; +var parseID = function($this) { + singleNumRegexp.lastIndex = 0; + return +singleNumRegexp.exec($this.attr('id'))[1]; +}; + // Common.js $.postJSON = function (url, data, callback) { return $.post(url, data, callback, 'json'); diff --git a/media/js/discipline/rating/common.js b/media/js/discipline/rating/common.js index 872f200a306c7b46504cc2a06a34408e24a2de75..34c33e100bc75abe0a76feaa688b45b26f4ac6eb 100644 --- a/media/js/discipline/rating/common.js +++ b/media/js/discipline/rating/common.js @@ -1,8 +1,4 @@ class Base { - static parseID($this) { - return +/\w_(\d+)/.exec($this.attr('id'))[1]; - } - static parsePosition($this) { let doubleNumReg = /[A-Za-z_]+(\d+)[A-Za-z_]+(\d+)/; return doubleNumReg.exec($this.attr('id')).splice(1, 2); @@ -84,7 +80,7 @@ class RateInfo { var jCurSubmoduleHead = this.$submodulesHead.children(`.col_${col}:first`); var submodule = +jCurSubmoduleInfo.attr('id'); - var student = Base.parseID($this.siblings('.studentCell')); + var student = parseID($this.siblings('.studentCell')); var maxRate = +this.$submodulesMaxRate.children(`.col_${col}`).text(); // Проверяем допустимое значение (только для добора) diff --git a/media/js/discipline/rating/exam.js b/media/js/discipline/rating/exam.js index cd507c0abfbfaed9dba8f7ffcb695a96695dc44b..a95cc3b7a6c20e0520b9a1adcf59609bbffd9d72 100644 --- a/media/js/discipline/rating/exam.js +++ b/media/js/discipline/rating/exam.js @@ -253,7 +253,7 @@ $(function () { // Ведомость в формате excel $('body').on('click', '.downloadExcelStatement', function () { - var groupID = Base.parseID($(this)); + var groupID = parseID($(this)); var $stageSelector = $('#stageSelector_' + groupID); $.fileDownload(URLdir + 'handler/FileCreator/GenerateFinalForm', { diff --git a/media/js/semesterSwitcher.js b/media/js/semesterSwitcher.js index 7a59244aa8029e87cfb7203a6206c37e73a785d0..aba838d7d088489a136c21869d10c260887dabbc 100644 --- a/media/js/semesterSwitcher.js +++ b/media/js/semesterSwitcher.js @@ -1,3 +1,5 @@ +var getSemester; + $(function () { let $semesters = $('.semesterSwitcher').first(), $switch = $('#changeSemester'), @@ -12,4 +14,7 @@ $(function () { id: e.target.id.split('-')[1] }).done(_ => window.location.replace(URLdir)); }); -}); \ No newline at end of file + + getSemester = () => parseID($semesters); +}); + diff --git a/~dev_rating/application/views/base.twig b/~dev_rating/application/views/base.twig index 3b97b9547c70d5eb9375b8872fcc410b9493faa5..98bdb7bb8c33442adc9f305c952f8eabde8d42ee 100644 --- a/~dev_rating/application/views/base.twig +++ b/~dev_rating/application/views/base.twig @@ -21,7 +21,7 @@ <i class="fa fa-angle-down"></i> </a> <div class="semesterSwitcherBtn"> - <div class="semesterSwitcher" style="display: none;"> + <div class="semesterSwitcher" id="semester_{{ User.SemesterID }}" style="display: none;"> <ul> {% for i in SemesterList %} <li><a href="#" id="S-{{ i.ID }}" class="switchSemester">{{ i.Num }} семестр {{ i.Year }}/{{ i.Year + 1 }}</a></li>