Commit 2ecb65b8 authored by Regis's avatar Regis

extract param helper to pagination dir

parent bff8e5ba
/* global Vue, gl */
/* eslint-disable no-param-reassign, no-plusplus */
//= require ./param_helper.js.es6
((gl) => {
const PAGINATION_UI_BUTTON_LIMIT = 4;
const SPREAD = '...';
......@@ -9,16 +11,6 @@
const FIRST = '<< First';
const LAST = 'Last >>';
const getParameterByName = (name) => {
const url = window.location.href;
name = name.replace(/[[\]]/g, '\\$&');
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
const results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
};
gl.VueGlPagination = Vue.extend({
props: [
'change',
......@@ -27,7 +19,7 @@
methods: {
changepage(e) {
let pagenum = this.pageInfo.page;
let apiScope = getParameterByName('scope');
let apiScope = gl.getParameterByName('scope');
if (!apiScope) apiScope = 'all';
......
/* eslint-disable no-param-reassign */
((w) => {
w.getParameterByName = (name) => {
const url = window.location.href;
name = name.replace(/[[\]]/g, '\\$&');
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
const results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
};
})(window.gl || (window.gl = {}));
......@@ -2,16 +2,6 @@
/* eslint-disable no-param-reassign, no-bitwise*/
((gl) => {
const getParameterByName = (name) => {
const url = window.location.href;
name = name.replace(/[[\]]/g, '\\$&');
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
const results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
};
gl.VuePipelines = Vue.extend({
components: {
runningPipeline: gl.VueRunningPipeline,
......@@ -38,8 +28,8 @@
},
props: ['scope', 'store'],
created() {
const pagenum = getParameterByName('p');
const scope = getParameterByName('scope');
const pagenum = gl.getParameterByName('p');
const scope = gl.getParameterByName('scope');
if (pagenum) this.pagenum = pagenum;
if (scope) this.apiScope = scope;
this.store.fetchDataLoop.call(this, Vue, this.pagenum, this.scope, this.apiScope);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment