1 /*******************************************************************************
\r
2 * Copyright (c) 2017 Kumar Rishabh and others.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Apache License, Version 2.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.apache.org/licenses/LICENSE-2.0
\r
8 *******************************************************************************/
\r
10 $(document).ready( function() {
\r
11 $('select').material_select();
\r
12 $('.modal').modal();
\r
13 $(".button-collapse").sideNav();
\r
14 $('.carousel').carousel();
\r
16 $('#Search').click(function() {
\r
17 var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
\r
18 window.location.href = '/search_projects?tags=' + tags;
\r
22 $('#SearchSpan').click(function(){
\r
23 var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
\r
24 window.location.href = '/search_projects?tags=' + tags;
\r
28 $('div.form-group-custom i.material-icons').click(function(e){
\r
29 var tags = $('#Tags').val().toLowerCase().split(/[ ,]+/);
\r
30 window.location.href = '/search_projects?tags=' + tags;
\r
34 $("#add_project_button").on('click',function(){
\r
35 event.preventDefault();
\r
36 var vnf_name = $("#vnf_name").val() ;
\r
38 var formData = new FormData($('form#add_project_form')[0]);
\r
39 var license = $('#license option:selected').val();
\r
40 formData.append('license', license);
\r
41 var opnfv_indicator = $('#opnfv_indicator option:selected').val();
\r
42 formData.append('opnfv_indicator', opnfv_indicator);
\r
45 url: '/add_project',
\r
48 processData: false, // tell jQuery not to process the data
\r
49 contentType: false, // tell jQuery not to set contentType
\r
51 success: function(data) {
\r
52 $('#modal1').modal('close');
\r
53 $('form#add_project_form').trigger('reset');
\r
54 Materialize.toast('Successfully submitted the VNF!', 3000, 'rounded');
\r
56 error: function (error) {
\r
57 if(error['responseJSON']) {
\r
58 Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
\r
59 } else if(error['responseText']) {
\r
60 var response_message = JSON.parse(error['responseText']);
\r
61 Materialize.toast(response_message['error'], 3000, 'rounded');
\r
63 //$('#modal1').modal('open');
\r
67 $("#add_tag_button").on('click',function(){
\r
68 event.preventDefault();
\r
69 var tag_name = $("#tag_name").val() ;
\r
75 data: $('form#add_tag_form').serialize(),
\r
76 success: function(data) {
\r
77 $('#modal2').modal('close');
\r
78 $('form#add_tag_form').trigger('reset');
\r
79 Materialize.toast('Successfully submitted the TAG!', 3000, 'rounded');
\r
81 error: function (error) {
\r
82 Materialize.toast(error['responseJSON']['error'], 3000, 'rounded');
\r
87 var QueryString = function () {
\r
88 // This function is anonymous, is executed immediately and
\r
89 // the return value is assigned to QueryString!
\r
90 var query_string = {};
\r
91 var query = window.location.search.substring(1);
\r
92 var vars = query.split("&");
\r
93 for (var i=0;i<vars.length;i++) {
\r
94 var pair = vars[i].split("=");
\r
95 // If first entry with this name
\r
96 if (typeof query_string[pair[0]] === "undefined") {
\r
97 query_string[pair[0]] = decodeURIComponent(pair[1]);
\r
98 // If second entry with this name
\r
99 } else if (typeof query_string[pair[0]] === "string") {
\r
100 var arr = [ query_string[pair[0]],decodeURIComponent(pair[1]) ];
\r
101 query_string[pair[0]] = arr;
\r
102 // If third or later entry with this name
\r
104 query_string[pair[0]].push(decodeURIComponent(pair[1]));
\r
107 return query_string;
\r