PageSourceSearch

https://researchmap.jp/js/press_releases/press_releases.js?1753674007

js researchmap.jp collected 2026-10-01 08:46:31 UTC 21,202 bytes, 713 lines download raw bytes

1/**
2 * PressRelease edit Javascript
3 */
4NetCommonsApp.controller('PressReleasesEdit', [
5  '$scope',
6  'NetCommonsWysiwyg',
7  '$filter',
8  'NC3_URL',
9  function ($scope, NetCommonsWysiwyg, $filter, NC3_URL) {
10    /**
11     * tinymce
12     *
13     * @type {object}
14     */
15    $scope.tinymce = NetCommonsWysiwyg.new();
16
17    $scope.init = function (data, err, targetCvTypeId) {
18      $scope.data = data;
19      $scope.err = err;
20      $scope.pressRelease = data.pressRelease;
21      $scope.targetCvTypeId = targetCvTypeId;
22    };
23
24    $scope.addInstitution = function ($event, idx) {
25      var institution;
26      institution = new Object();
27      institution.name = '';
28      $scope.data.pressReleaseInstitution.push(institution);
29      if ($event) {
30        $event.stopPropagation();
31      }
32    };
33    $scope.deleteInstitution = function ($event, idx) {
34      var institutions = $scope.data.pressReleaseInstitution;
35      if (institutions.length < 2) {
36        return;
37      }
38      $scope.data.pressReleaseInstitution.splice(idx, 1);
39
40      if ($event) {
41        $event.stopPropagation();
42      }
43    };
44    $scope.addLink = function ($event, idx) {
45      var link;
46      link = new Object();
47      link.name = '';
48      $scope.data.pressReleaseLink.push(link);
49      if ($event) {
50        $event.stopPropagation();
51      }
52    };
53    $scope.deleteLink = function ($event, idx) {
54      var links = $scope.data.pressReleaseLink;
55      if (links.length < 2) {
56        return;
57      }
58      $scope.data.pressReleaseLink.splice(idx, 1);
59      $scope.err.pressReleaseLink.splice(idx, 1);
60
61      if ($event) {
62        $event.stopPropagation();
63      }
64    };
65  },
66]);
67
68/**
69 * PressRelease featured Javascript
70 */
71NetCommonsApp.controller('PressReleaseFeaturedController', [
72  '$scope',
73  '$http',
74  '$location',
75  '$window',
76  'NC3_URL',
77  function ($scope, $http, $location, $window, NC3_URL) {
78    /**
79     * データ
80     */
81    $scope.dateRange = undefined;
82    $scope.rankingData = undefined;
83
84    $scope.loading = true;
85
86    const ITEM_PER_PAGE = 10;
87    const DATE_RANGE_KINDS = ['seven_days', 'twenty_eight_days', 'ninety_days'];
88
89    /**
90     * Initialize
91     *
92     * @return {void}
93     */
94    $scope.initialize = function (blockId, frameId) {
95      $scope.blockId = blockId;
96      $scope.frameId = frameId;
97      $scope.rankingData = {};
98      for (const dateRangeKind of DATE_RANGE_KINDS) {
99        $scope.rankingData[dateRangeKind] = {
100          'loading': true,
101          'nextPage': true,
102          'featuredReleases': [],
103        };
104      }
105      $scope.showFeaturedItemsInit();
106    };
107
108    /**
109     * 初回データ取得&表示
110     *
111     * @return {void}
112     */
113    $scope.showFeaturedItemsInit = function () {
114      const url = getFeaturedUrl();
115      $http.get(NC3_URL + url).then(
116        function (response) {
117          $scope.loading = false;
118          // タブの設定
119          const data = response.data;
120          $scope.dateRange = data['paging']['PressReleaseFeatured.date_range'];
121
122          // ランキングの格納
123          const ranking = $scope.rankingData[$scope.dateRange];
124          ranking.nextPage = data['paging'].nextPage;
125          angular.forEach(data['featuredPressReleases'], function (value) {
126            ranking.featuredReleases.push(value);
127          });
128
129          // blockingの終了
130          for (const dateRangeKind of DATE_RANGE_KINDS) {
131            $scope.rankingData[dateRangeKind].loading = false;
132          }
133        },
134        function (response) {
135          $scope.loading = false;
136        }
137      );
138    };
139
140    /**
141     * データ取得&表示
142     *
143     * @return {void}
144     */
145    $scope.showFeaturedItems = function () {
146      const ranking = $scope.rankingData[$scope.dateRange];
147      ranking.loading = true;
148
149      const url = [getFeaturedUrl(), '&range=', $scope.dateRange].join('');
150
151      $http.get(NC3_URL + url).then(
152        function (response) {
153          const data = response.data;
154          angular.forEach(data['featuredPressReleases'], function (value) {
155            ranking.featuredReleases.push(value);
156          });
157          ranking.nextPage = data['paging'].nextPage;
158          ranking.loading = false;
159        },
160        function (response) { }
161      );
162    };
163
164    function getFeaturedUrl() {
165      const itemCount = $scope.getRankingData().featuredReleases.length;
166      if (itemCount % ITEM_PER_PAGE !== 0) {
167        console.error('invalid path');
168      }
169      const currentPage = (itemCount - (itemCount % ITEM_PER_PAGE)) / ITEM_PER_PAGE + 1;
170      return [
171        '/press_releases/press_releases/featured/', $scope.blockId,
172        '/page:', currentPage,
173        '.json?frame_id=', $scope.frameId,
174      ].join('');
175    }
176
177    /**
178     * 初期化中であるかを判定する
179     */
180    $scope.isInitializing = function() {
181      return !$scope.dateRange;
182    }
183
184    /**
185     * Ranking を取得する
186     */
187    $scope.getRankingData = function () {
188      if ($scope.dateRange) {
189        return $scope.rankingData[$scope.dateRange];
190      } else {
191          return {
192            'loading': true,
193            'nextPage': true,
194            'featuredReleases': [],
195          };
196      }
197    }
198
199    /**
200     * Range を変更する
201     */
202
203    $scope.changeRange = function (range) {
204      if ($scope.dateRange === range || !$scope.dateRange) {
205        return;
206      }
207      $scope.dateRange = range;
208      initializeFeaturedItems();
209    };
210
211    function initializeFeaturedItems() {
212      const ranking = $scope.getRankingData();
213      if (!ranking.loading && ranking.nextPage && ranking.featuredReleases.length === 0) {
214        $scope.showFeaturedItems();
215      }
216    }
217  }
218]);
219/**
220 * PressRelease featured Javascript
221 */
222NetCommonsApp.controller('PressReleaseController', [
223  '$scope',
224  '$http',
225  '$location',
226  '$window',
227  'NC3_URL',
228  function ($scope, $http, $location, $window, NC3_URL) {
229    // CONST DEF
230    const KEY_DEF_LIMIT_COMBOBOX = ' button.dropdown-toggle';
231    const KEY_DEF_CATEGORY_COMBOBOX =
232      ' button.category-dropdown-toggle .nc-category-ellipsis';
233    const DEF_SEARCH_COUNT_DATA = '%d';
234
235    /**
236     *
237     * @type {boolean}
238     */
239    $scope.loading = true;
240
241    /**
242     * element id html onInitLimitCombobox
243     * @param {* key selector} keyID
244     */
245    $scope.onInitLimitCombobox = function (keyID) {
246      getElements(keyID + ' a').forEach((res, index) => {
247        res.addEventListener('click', function (event) {
248          if (!isNotEmpty($scope.searchWord)) {
249            // stop change url
250            event.preventDefault();
251            // get url param
252            unLinkUrl(this.getAttribute('href'), [
253              'limit',
254              'sort',
255              'direction',
256            ]);
257            // change combobox text
258            changeTextCombobox(
259              keyID + KEY_DEF_LIMIT_COMBOBOX,
260              this.innerText,
261              true
262            );
263            changeAllLinkInComboboxReSearch();
264            // change data to empty and call api
265            resetChangeCombobox();
266            // clear search word
267            $scope.getAllDataPressRelease();
268          }
269        });
270      });
271    };
272    /**
273     * element id html onInitCategoryCombobox
274     * @param {* key selector} keyID
275     */
276    $scope.onInitCategoryCombobox = function (keyID) {
277      getElements(keyID + ' a').forEach((res, index) => {
278        res.addEventListener('click', function (event) {
279          // stop change url
280          event.preventDefault();
281          // get url param
282          unLinkUrl(
283            this.getAttribute('href'),
284            ['category_id'],
285            ['category_id']
286          );
287          // change combobox text
288          changeTextCombobox(keyID + KEY_DEF_CATEGORY_COMBOBOX, this.innerText);
289          changeAllLinkInComboboxReSearch();
290          // change data to empty and call api
291          resetChangeCombobox();
292          $scope.getAllDataPressRelease();
293        });
294      });
295    };
296
297    $scope.onInitGroupReSearchCombobox = function (keyID) {
298      const comboboxList = getElements(keyID + ' .btn-group');
299      switch (comboboxList.length) {
300        case 1:
301          $scope.research_area_discipline_number_combobox =
302            comboboxList.item(0);
303          break;
304        case 2:
305          $scope.research_area_discipline_number_combobox =
306            comboboxList.item(0);
307          $scope.research_area_item_number_combobox = comboboxList.item(1);
308          break;
309      }
310      // execute unlink url get research_area_discipline_number_combobox, research_area_item_number_combobox
311      unLinkUrl(window.location.href, [
312        'research_area_discipline_number',
313        'research_area_item_number',
314        'sort',
315        'direction',
316      ]);
317      changeAllLinkInComboboxReSearch();
318    };
319
320    /**
321     * データ
322     */
323    $scope.PressReleases = [];
324    /**
325     * Initialize
326     *
327     * @return {void}
328     */
329    $scope.initialize = function (
330      blockId,
331      frameId,
332      limit = 10,
333      textNotFound,
334      searchWord,
335      countRecordFormat
336    ) {
337      $scope.currentPage = 0;
338      $scope.paging = new Object();
339      $scope.blockId = blockId;
340      $scope.frameId = frameId;
341      $scope.tagId = $window.location.href.match('tag_id=([0-9]+)');
342      $scope.limit = limit;
343      $scope.textNotFound = textNotFound;
344      $scope.$parent.sending = true;
345      $scope.textShow = '';
346      $scope.searchWord = searchWord;
347      $scope.countRecordFormat = countRecordFormat;
348    };
349    $scope.onClickButtonMore = function () {
350      $scope.currentPage++;
351      $scope.getAllDataPressRelease();
352    };
353    /**
354     * データ取得&表示
355     *
356     * @return {void}
357     */
358    $scope.getAllDataPressRelease = function () {
359      // execute unlink url get research_area_discipline_number_combobox, research_area_item_number_combobox
360      unLinkUrl(window.location.href, [
361        'research_area_discipline_number',
362        'research_area_item_number',
363        'sort',
364        'direction',
365      ]);
366      var url = '/press_releases/press_releases/list/' + $scope.blockId;
367      var getPage = $scope.currentPage + 1;
368      url +=
369        addParamUrl('category_id') +
370        addParamUrl('limit') +
371        addParamUrl('sort') +
372        addParamUrl('direction');
373      url +=
374        addParamUrl('research_area_discipline_number') +
375        addParamUrl('research_area_item_number');
376      url += '/page:' + getPage;
377      url += isNotEmpty($scope.searchWord)
378        ? '?search_word=' + $scope.searchWord
379        : '';
380      url += isNotEmpty($scope.searchWord) ?
381        '&frame_id=' + $scope.frameId :
382        '?frame_id=' + $scope.frameId;
383      if (isNotEmpty($scope.tagId)) {
384        url += (isNotEmpty($scope.searchWord) || isNotEmpty($scope.frameId))?
385          '&tag_id=' + $scope.tagId[1] :
386          '?tag_id=' + $scope.tagId[1];
387      }
388      $http.get(NC3_URL + url).then(
389        function (response) {
390          $scope.loading = false;
391          var data = response.data;
392          $scope.paging = data['paging'];
393          angular.forEach(data['listPressReleases'], function (value) {
394            $scope.PressReleases.push(value);
395          });
396          $scope.$parent.sending = false;
397          if (data['listPressReleases'].length === 0) {
398            $scope.textShow = $scope.textNotFound;
399          } else {
400            $scope.textShow = '';
401          }
402          $scope.countRecord = changeCountData(
403            $scope.countRecordFormat,
404            DEF_SEARCH_COUNT_DATA,
405            $scope.paging.count
406          );
407        },
408        function (response) {
409          $scope.loading = false;
410          $scope.$parent.sending = false;
411          $scope.textShow = $scope.textNotFound;
412        }
413      );
414    };
415    /**
416     * Function change Text Value in Combobox
417     * @param {* key selector} elementKey
418     * @param {* value text to change} valueChange
419     * @param {* iss add caret or not} isAddCaret
420     */
421    function changeTextCombobox(elementKey, valueChange, isAddCaret = false) {
422      const element = angular.element(elementKey);
423      if (element.length > 0) {
424        element.get(0).innerText = valueChange;
425        if (isAddCaret) {
426          element.get(0).innerHTML += '<span class="caret"></span>';
427        }
428      }
429    }
430    /**
431     * Function get param url and ref to scope
432     * @param {* raw url} urlString
433     * @param {* array key need to get in raw url} arraySearch
434     * @param {* array key need to remove when not found data in raw url} arrRemove
435     * @returns
436     */
437    function unLinkUrl(urlString, arraySearch = [], arrRemove = []) {
438      const datas = urlString.substring(
439        urlString.indexOf($scope.blockId + '') + ($scope.blockId + '').length,
440        urlString.indexOf('?')
441      );
442      if (datas.length > 0) {
443        var objects = datas.split('/');
444        objects.forEach((res) => {
445          var object = res.split(':');
446          if (object.length === 2 && arraySearch.indexOf(object[0]) !== -1) {
447            $scope[object[0]] = object[1];
448          }
449        });
450        return;
451      }
452      arrRemove.forEach((e) => {
453        if (arraySearch.indexOf(e) !== -1) {
454          $scope[e] = undefined;
455        }
456      });
457    }
458    function changeAllLinkInComboboxReSearch() {
459      const arrObjectCombobox = [];
460      if ($scope.limit) {
461        arrObjectCombobox.push({ key: 'limit', value: $scope.limit });
462      }
463      if ($scope.category_id) {
464        arrObjectCombobox.push({
465          key: 'category_id',
466          value: $scope.category_id,
467        });
468      }
469      // change link in comboboxlink;
470      if ($scope.research_area_discipline_number_combobox) {
471        changeLinkHref(
472          getElementsInDoc(
473            'a',
474            $scope.research_area_discipline_number_combobox
475          ),
476          arrObjectCombobox
477        );
478      }
479      if ($scope.research_area_item_number_combobox) {
480        changeLinkHref(
481          getElementsInDoc('a', $scope.research_area_item_number_combobox),
482          arrObjectCombobox
483        );
484      }
485    }
486    /**
487     * Function add Param to link api
488     * @param {*} key
489     * @returns key:$scope[key] orr ''
490     */
491    function addParamUrl(key) {
492      return $scope[key] ? '/' + key + ':' + $scope[key] : '';
493    }
494    function resetChangeCombobox() {
495      $scope.currentPage = 0;
496      $scope.$parent.sending = true;
497      $scope.textShow = '';
498      $scope.countRecord = '';
499      $scope.PressReleases = [];
500    }
501    function changeCountData(stringFormat, searchData, changeData) {
502      return stringFormat.replace(searchData, changeData);
503    }
504    function changeLinkHref(nodeList, arrChange) {
505      nodeList.forEach((res) => {
506        let url = res
507          .getAttribute('href')
508          .replace(`?frame_id=${$scope.frameId}`, '');
509        arrChange.forEach((element) => {
510          const data = url.match(element.key + ':\\d*');
511          if (isNotEmpty(data)) {
512            url = url.replace(data, `${element.key}:${element.value}`);
513          } else {
514            url += `/${element.key}:${element.value}`;
515          }
516        });
517        res.setAttribute('href', `${url}?frame_id=${$scope.frameId}`);
518      });
519    }
520    /**SHARE FUNCTION JS **/
521    function getElements(key) {
522      return document.querySelectorAll(key);
523    }
524    function getElementsInDoc(key, elementDoc) {
525      return elementDoc.querySelectorAll(key);
526    }
527    function isNotEmpty(objectValue) {
528      return objectValue && objectValue.length > 0;
529    }
530  },
531]);
532
533NetCommonsApp.directive('htmlBindingDataTemplate', function () {
534  return {
535    restrict: 'E',
536    scope: {
537      item: '=',
538      alias: '=',
539      atrr: '=',
540    },
541    controller: function ($scope, $sce) {
542      const atrr = $scope.atrr;
543      const alias = $scope.alias;
544      if (checkExists($scope.item[atrr], alias)) {
545        $scope.templateHTMLBinding = $sce.trustAsHtml($scope.item[atrr][alias]);
546      }
547      function checkExists(objectValue, keyCheck) {
548        return objectValue && objectValue[keyCheck];
549      }
550    },
551    template: `<ng-template ng-if="templateHTMLBinding" ng-bind-html="templateHTMLBinding">
552                </ng-template>`,
553  };
554});
555/**
556 * PressReleasesReSearchArea Javascript
557 */
558NetCommonsApp.controller('PressReleasesReSearchAreaController', [
559  '$scope',
560  '$timeout',
561  '$location',
562  '$window',
563  'NC3_URL',
564  function ($scope, $timeout, $location, $window, NC3_URL) {
565    /**
566     * CONST DEF
567     */
568    const KEY_ID_AREA_BUTTON_SCROLL = 'press_release-research_area_button_';
569    const KEY_RESEARCH_AREA_DISCIPLINE_NUMBER =
570      'research_area_discipline_number';
571    const KEY_RESEARCH_AREA_ITEM_NUMBER = 'research_area_item_number';
572    const PRESS_RELEASE_RESEARCH_SHOW_COMBOBOX =
573      'press_release-research-show-combobox';
574    const PRESS_RELEASE_RESEARCH_SHOW = 'press_release-research-show';
575    const SIZE_LAYOUT = {
576      SMALL: 576,
577      MEDIUM: 768,
578      LARGE: 992,
579      EXTRALARGE: 1200,
580    };
581    /**
582     * データ
583     */
584    detectMob();
585    /**
586     * Init get data in combobox KEY_RESEARCH_AREA_DISCIPLINE_NUMBER
587     * @param {*} selectDisciplineNumber
588     * @param {*} keyID
589     * @param {*} frameId
590     */
591    $scope.initialize = function (selectDisciplineNumber, keyID, frameId) {
592      $scope.selectDisciplineNumber = selectDisciplineNumber;
593      $scope.frameId = frameId;
594      $scope.$parent.PressReleasesReSearchAreaDisciplineNumber =
595        getAllDataIncombobox(
596          keyID,
597          selectDisciplineNumber,
598          KEY_RESEARCH_AREA_DISCIPLINE_NUMBER
599        ).map((item) => {
600          if (item.label) item.label = item.label.replace(/(.+)/, '');
601          return item;
602        });
603      removeBindingAngularTagWhenPhpExecute();
604    };
605    /**
606     * Init get data in combobox KEY_RESEARCH_AREA_ITEM_NUMBER
607     * @param {*} selectItemNumber
608     * @param {*} keyID
609     * @param {*} frameId
610     */
611    $scope.initializeItemNumber = function (selectItemNumber, keyID, frameId) {
612      $scope.selectItemNumber = selectItemNumber;
613      $scope.frameId = frameId;
614      $scope.$parent.PressReleasesReSearchAreaItemNumber = getAllDataIncombobox(
615        keyID,
616        selectItemNumber,
617        KEY_RESEARCH_AREA_ITEM_NUMBER
618      );
619    };
620    /**
621     * function when binding last element in html
622     */
623    $scope.$parent.finished = function () {
624      $timeout(() => {
625        const element = getElements(
626          `#${KEY_ID_AREA_BUTTON_SCROLL}${$scope.selectItemNumber}`
627        );
628        if (element.length > 0) {
629          element.item(0).scrollIntoView({
630            behavior: 'smooth',
631            block: 'start',
632            inline: 'start',
633          });
634        }
635      }, 100);
636    };
637    /**
638     * execute element html and get data
639     * @param {*} keyID id element
640     * @param {*} selectData data user select
641     * @param {*}
641 atrrKey param define
642     * @returns list data {url,id,isSelect}
643     */
644    function getAllDataIncombobox(keyID, selectData, atrrKey) {
645      const comboboxList = getElements(keyID + ' li');
646      const listRes = [];
647      angular.forEach(comboboxList, (res, index) => {
648        const aLink = getElementsInDoc('a', res);
649        let href = '';
650        let isSelect = false;
651        if (aLink.length > 0) {
652          href = aLink.item(0).getAttribute('href');
653          const patt = new RegExp(`${atrrKey}:${selectData}`);
654          if (patt.test(href) && selectData.length > 0) {
655            isSelect = true;
656          }
657          if (selectData.length === 0 && index === 0) {
658            isSelect = true;
659          }
660        }
661        listRes.push({
662          id: res.getAttribute('data-id'),
663          label: res.getAttribute('data-label'),
664          url: $window.location.origin + href + '',
665          isSelect: isSelect,
666        });
667      });
668      return listRes;
669    }
670    /**
671     * get child element
672     * @param {*} key
673     * @param {*} elementDoc
674     * @returns child element
675     */
676    function getElementsInDoc(key, elementDoc) {
677      return elementDoc.querySelectorAll(key);
678    }
679    /**
680     * return element
681     */
682    function getElements(key) {
683      return document.querySelectorAll(key);
684    }
685    /**
686     * detect on moblie
687     * @returns
688     */
689    function detectMob() {
690      $scope.isOnMobile = $window.innerWidth <= SIZE_LAYOUT.MEDIUM;
691      $scope.$parent.isOnMobile = $window.innerWidth <= SIZE_LAYOUT.MEDIUM;
692      $window.addEventListener('resize', (event) => {
693        executeResize();
694      });
695    }
696    function executeResize() {
697      $scope.isOnMobile = $window.innerWidth <= SIZE_LAYOUT.MEDIUM;
698      $scope.$apply();
699      $scope.$parent.isOnMobile = $window.innerWidth <= SIZE_LAYOUT.MEDIUM;
700      $scope.$parent.$apply();
701      removeBindingAngularTagWhenPhpExecute();
702    }
703    function removeBindingAngularTagWhenPhpExecute() {
704      getElements(`#${PRESS_RELEASE_RESEARCH_SHOW_COMBOBOX}`)
705        .item(0)
706        .classList.add(PRESS_RELEASE_RESEARCH_SHOW);
707      const classD = getElements(`.press_release-research-hidden`);
708      if ($scope.isOnMobile && classD.length > 0) {
709        classD.item(0).classList.remove('press_release-research-hidden');
710      }
711    }
712  },
713]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.