diff options
author | Kumar Rishabh <shailrishabh@gmail.com> | 2017-06-29 11:54:06 +0530 |
---|---|---|
committer | Deepak S <deepak.s@linux.intel.com> | 2017-07-21 06:20:14 +0000 |
commit | 1f6b18a1974c1b53a079b21b6be39af86deb2432 (patch) | |
tree | 7a9eba2bf86ea1ee651836dbf58ac998d4a92933 /VNF_Catalogue/public/javascripts/index_search_max.js | |
parent | b8351286a53658bee2471430aaafac4eb72bdfde (diff) |
VNF_Catalogue Codebase
Catalogue of Open Source VNFs consist in helping the end users to get
information of the VNF we can deploy on top of an OPNFV solution
[Deepak]: Removed all swp files.
Change-Id: Ib2ea7330e964f1b684f32aedf631accd580df968
Signed-off-by: Kumar Rishabh <shailrishabh@gmail.com>
Signed-off-by: Deepak S <deepak.s@linux.intel.com>
Diffstat (limited to 'VNF_Catalogue/public/javascripts/index_search_max.js')
-rw-r--r-- | VNF_Catalogue/public/javascripts/index_search_max.js | 145 |
1 files changed, 145 insertions, 0 deletions
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');
+ }
+ });
+ });
+
+});
|