summaryrefslogtreecommitdiffstats
path: root/VNF_Catalogue/public/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'VNF_Catalogue/public/javascripts')
-rw-r--r--VNF_Catalogue/public/javascripts/global.js110
-rw-r--r--VNF_Catalogue/public/javascripts/index.js109
-rw-r--r--VNF_Catalogue/public/javascripts/index_search_max.js145
-rw-r--r--VNF_Catalogue/public/javascripts/mode_edit.js82
-rw-r--r--VNF_Catalogue/public/javascripts/mode_edit_project.js105
-rw-r--r--VNF_Catalogue/public/javascripts/search_results.js227
6 files changed, 778 insertions, 0 deletions
diff --git a/VNF_Catalogue/public/javascripts/global.js b/VNF_Catalogue/public/javascripts/global.js
new file mode 100644
index 00000000..13be15a5
--- /dev/null
+++ b/VNF_Catalogue/public/javascripts/global.js
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Kumar Rishabh and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+
+$(document).ready( function() {
+ $('select').material_select();
+ $('.modal').modal();
+ $(".button-collapse").sideNav();
+ $('.carousel').carousel();
+
+ $('#Search').click(function() {
+ var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
+ window.location.href = '/search_projects?tags=' + tags;
+ return false;
+ });
+
+ $('#SearchSpan').click(function(){
+ var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
+ window.location.href = '/search_projects?tags=' + tags;
+ return false;
+ });
+
+ $('div.form-group-custom i.material-icons').click(function(e){
+ var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
+ window.location.href = '/search_projects?tags=' + tags;
+ return false;
+ });
+
+ $("#add_project_button").on('click',function(){
+ event.preventDefault();
+ var vnf_name = $("#vnf_name").val() ;
+
+ var formData = new FormData($('form#add_project_form')[0]);
+ var license = $('#license option:selected').val();
+ formData.append('license', license);
+ var opnfv_indicator = $('#opnfv_indicator option:selected').val();
+ formData.append('opnfv_indicator', opnfv_indicator);
+
+ $.ajax({
+ url: '/add_project',
+ type: 'post',
+ //dataType: 'json',
+ processData: false, // tell jQuery not to process the data
+ contentType: false, // tell jQuery not to set contentType
+ data: formData,
+ success: function(data) {
+ $('#modal1').modal('close');
+ $('form#add_project_form').trigger('reset');
+ Materialize.toast('Successfully submitted the VNF!', 3000, 'rounded');
+ },
+ error: function (error) {
+ if(error['responseJSON']) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ } else if(error['responseText']) {
+ var response_message = JSON.parse(error['responseText']);
+ Materialize.toast(response_message['error'], 3000, 'rounded');
+ }
+ //$('#modal1').modal('open');
+ }
+ });
+ });
+ $("#add_tag_button").on('click',function(){
+ event.preventDefault();
+ var tag_name = $("#tag_name").val() ;
+
+ $.ajax({
+ url: '/add_tag',
+ type: 'post',
+ dataType: 'json',
+ data: $('form#add_tag_form').serialize(),
+ success: function(data) {
+ $('#modal2').modal('close');
+ $('form#add_tag_form').trigger('reset');
+ Materialize.toast('Successfully submitted the TAG!', 3000, 'rounded');
+ },
+ error: function (error) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ }
+ });
+ });
+
+ var QueryString = function () {
+ // This function is anonymous, is executed immediately and
+ // the return value is assigned to QueryString!
+ var query_string = {};
+ var query = window.location.search.substring(1);
+ var vars = query.split("&");
+ for (var i=0;i<vars.length;i++) {
+ var pair = vars[i].split("=");
+ // If first entry with this name
+ if (typeof query_string[pair[0]] === "undefined") {
+ query_string[pair[0]] = decodeURIComponent(pair[1]);
+ // If second entry with this name
+ } else if (typeof query_string[pair[0]] === "string") {
+ var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
+ query_string[pair[0]] = arr;
+ // If third or later entry with this name
+ } else {
+ query_string[pair[0]].push(decodeURIComponent(pair[1]));
+ }
+ }
+ return query_string;
+ };
+
+});
diff --git a/VNF_Catalogue/public/javascripts/index.js b/VNF_Catalogue/public/javascripts/index.js
new file mode 100644
index 00000000..0e5ea7ff
--- /dev/null
+++ b/VNF_Catalogue/public/javascripts/index.js
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Kumar Rishabh and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+
+$(document).ready( function() {
+ $('select').material_select();
+ $('.modal').modal();
+ $(".button-collapse").sideNav();
+ $('.carousel').carousel();
+
+ $('#Search').click(function() {
+ var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
+ window.location.href = '/search_projects?tags=' + tags;
+ return false;
+ });
+
+ $('#SearchSpan').click(function(){
+ var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
+ window.location.href = '/search_projects?tags=' + tags;
+ return false;
+ });
+
+ $('div.form-group-custom i.material-icons').click(function(e){
+ var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
+ window.location.href = '/search_projects?tags=' + tags;
+ return false;
+ });
+
+ $("#add_project_button").on('click',function(){
+ event.preventDefault();
+ var vnf_name = $("#vnf_name").val() ;
+
+ var formData = new FormData($('form#add_project_form')[0]);
+ var license = $('#license option:selected').val();
+ formData.append('license', license);
+ var opnfv_indicator = $('#opnfv_indicator option:selected').val();
+ formData.append('opnfv_indicator', opnfv_indicator);
+
+ $.ajax({
+ url: '/add_project',
+ type: 'post',
+ //dataType: 'json',
+ processData: false, // tell jQuery not to process the data
+ contentType: false, // tell jQuery not to set contentType
+ data: formData,
+ success: function(data) {
+ $('#modal1').modal('close');
+ $('form#add_project_form').trigger('reset');
+ Materialize.toast('Successfully submitted the VNF!', 3000, 'rounded');
+ },
+ error: function (error) {
+ if(error['responseJSON']) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ } else if(error['responseText']) {
+ var response_message = JSON.parse(error['responseText']);
+ Materialize.toast(response_message['error'], 3000, 'rounded');
+ }
+ //$('#modal1').modal('open');
+ }
+ });
+ });
+ $("#add_tag_button").on('click',function(){
+ event.preventDefault();
+ var tag_name = $("#tag_name").val() ;
+
+ $.ajax({
+ url: '/add_tag',
+ type: 'post',
+ dataType: 'json',
+ data: $('form#add_tag_form').serialize(),
+ success: function(data) {
+ $('#modal2').modal('close');
+ $('form#add_tag_form').trigger('reset');
+ Materialize.toast('Successfully submitted the TAG!', 3000, 'rounded');
+ },
+ error: function (error) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ }
+ });
+ });
+
+ $("#lines_of_code").on('click',function(){
+ event.preventDefault();
+ var json_data = {};
+ json_data['order_key'] = 'lines_of_code';
+ alert('here');
+ $.ajax({
+ url: '/search_max',
+ type: 'post',
+ dataType: 'json',
+ data: 'lines_of_code',
+ success: function(data) {
+ $('#modal2').modal('close');
+ $('form#add_tag_form').trigger('reset');
+ Materialize.toast('Successfully submitted the TAG!', 3000, 'rounded');
+ },
+ error: function (error) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ }
+ });
+ });
+
+
+});
diff --git a/VNF_Catalogue/public/javascripts/index_search_max.js b/VNF_Catalogue/public/javascripts/index_search_max.js
new file mode 100644
index 00000000..b9693117
--- /dev/null
+++ b/VNF_Catalogue/public/javascripts/index_search_max.js
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Kumar Rishabh and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+
+$(document).ready( function() {
+ //alert('index saeerch max ....');
+ var lines_of_code_string = `
+ <div class="box-container">
+ <div class="col-md-3">
+ <div class="content-box">
+ <div class="content-data">
+ <h1 class="content-title"><a href="/project_profile?vnf_id=%vnf_id">%vnf_name%</a></h1>
+ <div class="box"><img class="img-size commit-icon" src="/uploads/%photo_url%"/>
+ <h3 class="commits">%lines_of_code%<br/>Lines Of Code</h3>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ `;
+
+ var no_of_developers_string = `
+ <div class="box-container">
+ <div class="col-md-3">
+ <div class="content-box">
+ <div class="content-data">
+ <h1 class="content-title"><a href="/project_profile?vnf_id=%vnf_id">%vnf_name%</a></h1>
+ <div class="box"><img class="img-size commit-icon" src="/uploads/%photo_url%"/>
+ <h3 class="commits">%no_of_developers%<br/>No Of Developers</h3>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ `;
+
+ var no_of_stars_string = `
+ <div class="box-container">
+ <div class="col-md-3">
+ <div class="content-box">
+ <div class="content-data">
+ <h1 class="content-title"><a href="/project_profile?vnf_id=%vnf_id">%vnf_name%</a></h1>
+ <div class="box"><img class="img-size commit-icon" src="/uploads/%photo_url%"/>
+ <h3 class="commits">%no_of_stars%<br/>No Of Stars</h3>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ `;
+
+ var search_max_result = function(string1, result) {
+ var string_replacement = {};
+ //alert(JSON.stringify(result));
+
+ for (var k in result) {
+ if (result.hasOwnProperty(k)) {
+ string_replacement['%' + k + '%'] = result[k];
+ if(!string_replacement['%' + k + '%']) {
+ string_replacement['%' + k + '%'] = -1;
+ }
+ }
+ }
+ //alert(JSON.stringify(string_replacement));
+
+ string1 = string1.replace(/%\w+%/g, function(all) {
+ return string_replacement[all] || all;
+ });
+ //alert(JSON.stringify(string1));
+ return string1;
+ };
+
+ $("#lines_of_code").on('click',function(){
+ event.preventDefault();
+ var json_data = {};
+ json_data['order_key'] = 'lines_of_code';
+ $.ajax({
+ url: '/search_max',
+ type: 'post',
+ dataType: 'json',
+ data: json_data,
+ success: function(data) {
+ html_string = '';
+ for(var result in data) {
+ html_string += search_max_result(lines_of_code_string, data[result]);
+ }
+ $('#content').html(html_string);
+
+ },
+ error: function (error) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ }
+ });
+ });
+
+ $("#no_of_developers").on('click',function(){
+ event.preventDefault();
+ var json_data = {};
+ json_data['order_key'] = 'no_of_developers';
+ $.ajax({
+ url: '/search_max',
+ type: 'post',
+ dataType: 'json',
+ data: json_data,
+ success: function(data) {
+ html_string = '';
+ for(var result in data) {
+ html_string += search_max_result(no_of_developers_string, data[result]);
+ }
+ $('#content').html(html_string);
+ },
+ error: function (error) {
+ Materialize.toast('', 3000, 'rounded');
+ }
+ });
+ });
+
+ $("#no_of_stars").on('click',function(){
+ event.preventDefault();
+ var json_data = {};
+ json_data['order_key'] = 'no_of_stars';
+ $.ajax({
+ url: '/search_max',
+ type: 'post',
+ dataType: 'json',
+ data: json_data,
+ success: function(data) {
+ html_string = '';
+ for(var result in data) {
+ html_string += search_max_result(no_of_stars_string, data[result]);
+ }
+ $('#content').html(html_string);
+ },
+ error: function (error) {
+ Materialize.toast('', 3000, 'rounded');
+ }
+ });
+ });
+
+});
diff --git a/VNF_Catalogue/public/javascripts/mode_edit.js b/VNF_Catalogue/public/javascripts/mode_edit.js
new file mode 100644
index 00000000..2047a92a
--- /dev/null
+++ b/VNF_Catalogue/public/javascripts/mode_edit.js
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Kumar Rishabh and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+
+$(document).ready( function() {
+
+ //getVnfs : get 5 main VNFs using typeahead
+ var getVnfs = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('vnf_name'),
+ queryTokenizer: Bloodhound.tokenizers.obj.whitespace('vnf_name'),
+ remote: {
+ url: '/search_vnf?key=%QUERY',
+ wildcard: '%QUERY'
+ },
+ limit: 5
+ });
+
+ getVnfs.initialize();
+ $('#scrollable-dropdown-menu #vnf_name.typeahead').typeahead(
+ {
+ hint: true,
+ highlight: true,
+ minLength: 1
+ },
+ {
+ name: 'vnf_name',
+ display: 'vnf_name',
+ limit: 5,
+ source: getVnfs.ttAdapter()
+ });
+
+ //getTags : get 5 main tags using typeahead
+ var getTags = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('tag_name'),
+ queryTokenizer: Bloodhound.tokenizers.obj.whitespace('tag_name'),
+ remote: {
+ url: '/search_tag?key=%QUERY',
+ wildcard: '%QUERY'
+ },
+ limit: 5
+ });
+
+ getTags.initialize();
+ $('#scrollable-dropdown-menu #tag_name.typeahead').typeahead(
+ {
+ hint: true,
+ highlight: true,
+ minLength: 1
+ },
+ {
+ name: 'tag_name',
+ display: 'tag_name',
+ limit: 5,
+ source: getTags.ttAdapter()
+ });
+
+ $("#add_vnf_tag_association_button").on('click',function(){
+ event.preventDefault();
+ var vnf_name = $("#vnf_name").val() ;
+
+ $.ajax({
+ url: '/vnf_tag_association',
+ type: 'post',
+ dataType: 'json',
+ data: $('form#add_vnf_tag_association_form').serialize(),
+ success: function(data) {
+ $('#modal3').modal('close');
+ $('form#add_vnf_tag_association_form').trigger('reset');
+ Materialize.toast('Successfully added the TAG to the VNF!', 3000, 'rounded');
+ },
+ error: function (error) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ }
+ });
+ });
+
+});
diff --git a/VNF_Catalogue/public/javascripts/mode_edit_project.js b/VNF_Catalogue/public/javascripts/mode_edit_project.js
new file mode 100644
index 00000000..cb457385
--- /dev/null
+++ b/VNF_Catalogue/public/javascripts/mode_edit_project.js
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Kumar Rishabh and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+
+$(document).ready( function() {
+
+ //getVnfs : get 5 main VNFs using typeahead
+ var getVnfs = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('vnf_name'),
+ queryTokenizer: Bloodhound.tokenizers.obj.whitespace('vnf_name'),
+ remote: {
+ url: '/search_vnf?key=%QUERY',
+ wildcard: '%QUERY'
+ },
+ limit: 5
+ });
+
+ getVnfs.initialize();
+ $('#scrollable-dropdown-menu #vnf_name.typeahead').typeahead(
+ {
+ hint: true,
+ highlight: true,
+ minLength: 1
+ },
+ {
+ name: 'vnf_name',
+ display: 'vnf_name',
+ limit: 5,
+ source: getVnfs.ttAdapter()
+ });
+
+ //getTags : get 5 main tags using typeahead
+ var getTags = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('tag_name'),
+ queryTokenizer: Bloodhound.tokenizers.obj.whitespace('tag_name'),
+ remote: {
+ url: '/search_tag?key=%QUERY',
+ wildcard: '%QUERY'
+ },
+ limit: 5
+ });
+
+ getTags.initialize();
+ $('#scrollable-dropdown-menu #tag_name.typeahead').typeahead(
+ {
+ hint: true,
+ highlight: true,
+ minLength: 1
+ },
+ {
+ name: 'tag_name',
+ display: 'tag_name',
+ limit: 5,
+ source: getTags.ttAdapter()
+ });
+
+ $("#add_vnf_tag_association_button").on('click',function(){
+ event.preventDefault();
+ var vnf_name = $("#vnf_name").val() ;
+
+ $.ajax({
+ url: '/vnf_tag_association',
+ type: 'post',
+ dataType: 'json',
+ data: $('form#add_vnf_tag_association_form').serialize(),
+ success: function(data) {
+ $('#modal3').modal('close');
+ $('form#add_vnf_tag_association_form').trigger('reset');
+ Materialize.toast('Successfully added the TAG to the VNF!', 3000, 'rounded');
+ },
+ error: function (error) {
+ Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
+ }
+ });
+ });
+ alert('here');
+ $("#modal_href").click(function() {
+ //Do stuff when clicked
+ var json_data = {};
+ json_data['vnf_id'] = QueryString()['vnf_id'];
+
+ alert('here here');
+
+ $.ajax({
+ url: '/project_profile',
+ type: 'post',
+ dataType: 'json',
+ data: json_data,
+ success: function(data) {
+ Materialize.toast(data, 3000, 'rounded');
+ },
+ error: function (error) {
+ Materialize.toast('', 3000, 'rounded');
+ }
+ });
+ });
+ var openSolution = function() {
+ alert('here');
+ };
+});
diff --git a/VNF_Catalogue/public/javascripts/search_results.js b/VNF_Catalogue/public/javascripts/search_results.js
new file mode 100644
index 00000000..4dfb921b
--- /dev/null
+++ b/VNF_Catalogue/public/javascripts/search_results.js
@@ -0,0 +1,227 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Kumar Rishabh and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+
+$(document).ready( function() {
+ var search_result_string_1 = `
+ <div class = "container container-custom">
+ <div class="card card-shadow-custom horizontal">
+ <div class="row row-custom">
+
+ <div class="col s5 card-title-div-custom">
+ <span class="card-title card-title-span-custom">
+ <a class="custom-href" href="/project_profile?vnf_id=%vnf_id%">%vnf_name%</a>
+ </span>
+ </div>
+
+ <div class="col s5 card-title-div-custom">
+ <i class="material-icons">grade</i>
+ <span class="card-title">PenguinScore: 42</span>
+ </div>
+
+ <div class="col s2 card-title-div-custom-right">
+ <form action="#">
+ <input id="search_result_1" type="checkbox" name="%vnf_name%"/>
+ <label for="search_result_1">Compare</label>
+ </form>
+ </div>
+
+ <div class="col s4 card-image card-image-custom">
+ <img class="img-size card-image-picture-custom" src="/uploads/%photo_url%"/>
+ </div>
+
+ <div class="col s8 card-stacked">
+ <div class="card-content">
+ <p>
+ <div class="collection collection-custom">
+ <a class="collection-item" href="#!">
+ <span>
+ <i class="material-icons">code</i>
+ Lines Of Code: %lines_of_code%
+ </span>
+ </a>
+ <a class="collection-item" href="#!">
+ <span>
+ <i class="material-icons">person</i>
+ Number of Developers: %no_of_developers%;
+ </span>
+ </a>
+ <a class="collection-item" href="#!">
+ <span>
+ <i class="material-icons">star</i>
+ Number of Stars: %no_of_stars%
+ </span>
+ </a>
+ <a class="collection-item" href="#!">
+ <span>
+ <i class="material-icons">description</i>
+ Number of Versions: %versions%
+ </span>
+ </a>
+ </div>
+ </p>
+ </div>
+ <div class="card-action">
+ Tags:
+ `;
+ var search_result_string_2 = `
+ <div class="chip"><a class="a-custom" href="#!">tag1</a></div>
+ <div class="chip"><a class="a-custom" href="#!">Tag2</a></div>
+ <div class="chip"><a class="a-custom" href="#!">Tag3</a></div>
+ <div class="chip"><a class="a-custom" href="#!">Tag4</a></div>
+ <div class="chip"><a class="a-custom" href="#!">Tag5</a></div>
+ `;
+ var search_result_string_3 = `
+ <a class="a-custom-more" href="/project_profile?vnf_id=%vnf_id%">
+ more
+ </a>
+ </div>
+ </div>
+
+ <div class="divider"></div>
+
+ <div class="card-action-custom col s12 card-action">
+ License: <a href="#">%license%</a>
+ Complexity: <a href="#">Atomic</a>
+ Activity: <a href="#">Medium</a>
+ OPNFV Indicator: <a href="#">%opnfv_indicator%</a>
+ </div>
+
+ </div>
+ </div></div>
+ `;
+
+ //var replace_search_result_string = function(search_result_string,
+ var search_result = function(string1, string3, result) {
+ var string_replacement = {};
+ //alert(JSON.stringify(result));
+
+ for (var k in result) {
+ if (result.hasOwnProperty(k)) {
+ string_replacement['%' + k + '%'] = result[k];
+ if(!string_replacement['%' + k + '%']) {
+ string_replacement['%' + k + '%'] = -1;
+ }
+ }
+ }
+ //alert(JSON.stringify(string_replacement));
+
+ string1 = string1.replace(/%\w+%/g, function(all) {
+ return string_replacement[all] || all;
+ });
+
+ for(index in string_replacement['%tags%']) {
+ string1 += '<div class="chip"><a class="a-custom" href="#!">';
+ string1 += string_replacement['%tags%'][index]['tag_name'];
+ string1 += '</a></div>';
+ }
+
+ string3 = string3.replace(/%\w+%/g, function(all) {
+ return string_replacement[all] || all;
+ });
+
+ return string1 + string3;
+ };
+
+
+
+ var QueryString = function () {
+ // This function is anonymous, is executed immediately and
+ // the return value is assigned to QueryString!
+ var query_string = {};
+ var query = window.location.search.substring(1);
+ var vars = query.split("&");
+ for (var i=0;i<vars.length;i++) {
+ var pair = vars[i].split("=");
+ // If first entry with this name
+ if (typeof query_string[pair[0]] === "undefined") {
+ query_string[pair[0]] = decodeURIComponent(pair[1]);
+ // If second entry with this name
+ } else if (typeof query_string[pair[0]] === "string") {
+ var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
+ query_string[pair[0]] = arr;
+ // If third or later entry with this name
+ } else {
+ query_string[pair[0]].push(decodeURIComponent(pair[1]));
+ }
+ }
+ return query_string;
+ };
+
+ $('#pagination-long').materializePagination({
+ align: 'center',
+ lastPage: 5,
+ firstPage: 1,
+ urlParameter: 'page',
+ useUrlParameter: true,
+ onClickCallback: function(requestedPage){
+ var json_data = {};
+ json_data['tags'] = QueryString()['tags'];
+ json_data['page'] = requestedPage;
+
+ console.log(json_data);
+
+ $.ajax({
+ url: '/search_projects_results',
+ type: 'post',
+ dataType: 'json',
+ data: json_data,
+ success: function(data) {
+ //alert(JSON.stringify(data));
+ html_string = '';
+ for(var result in data) {
+ html_string += search_result(search_result_string_1, search_result_string_3, data[result]);
+ }
+ $('#content').html(html_string);
+ //Materialize.toast(data, 3000, 'rounded');
+ },
+ error: function (error) {
+ Materialize.toast('', 3000, 'rounded');
+ }
+ });
+
+ //window.location.href = '/search_projects?tags=' + parameters['tags'] + '&page=' + requestedPage;
+ //return false;
+ }
+ });
+
+ /*$('#pagination-long').pagination({
+ align: 'center',
+ lastPage: 5,
+ firstPage: 1,
+ //urlParameter: 'page',
+ useUrlParameter: false,
+ onClickCallback: function(requestedPage){
+ var query_string = {};
+ var query = window.location.search.substring(1);
+ console.log(query);
+ var vars = query.split("&");
+ console.log(vars);
+ vars['page'] = requestedPage;
+ console.log(vars);
+ var parameters = QueryString();
+
+ console.log(parameters);
+
+
+ window.location.href = '/search_projects?tags=' + parameters['tags'];
+ //return false;
+ }
+ var query_string = {};
+ var query = window.location.search.substring(1);
+ console.log(query);
+ var vars = query.split("&");
+ console.log(vars);
+ vars['page'] = requestedPage;
+ console.log(vars);
+
+ });*/
+
+
+
+});