Move capitalizeFirstLetter() to netdisco.js as common utility function

This commit is contained in:
Eric A. Miller
2014-05-28 23:37:55 -04:00
parent 12da0badaf
commit b90bf5bccc
2 changed files with 15 additions and 14 deletions

View File

@@ -156,6 +156,11 @@ function device_form_state(e) {
} }
} }
//utility function for views
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
$(document).ready(function() { $(document).ready(function() {
// sidebar form fields should change colour and have bin/copy icon // sidebar form fields should change colour and have bin/copy icon
$('.nd_field-copy-icon').hide(); $('.nd_field-copy-icon').hide();

View File

@@ -42,10 +42,6 @@
[% END %] [% END %]
<script type="text/javascript"> <script type="text/javascript">
function capitaliseFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
$(document).ready(function() { $(document).ready(function() {
var table = $('#data-table').dataTable({ var table = $('#data-table').dataTable({
"deferRender": true, "deferRender": true,
@@ -58,32 +54,32 @@ $(document).ready(function() {
} }
}, { }, {
"data": 'description', "data": 'description',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?description=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>'; return '<a href="[% uri_for('/report/moduleinventory') %]?description=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
} }
}, { }, {
"data": 'name', "data": 'name',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?name=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>'; return '<a href="[% uri_for('/report/moduleinventory') %]?name=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
} }
}, { }, {
"data": 'class', "data": 'class',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitaliseFirstLetter(data)) + '</a>'; return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitalizeFirstLetter(data)) + '</a>';
} }
}, { }, {
"data": 'type', "data": 'type',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?type=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>'; return '<a href="[% uri_for('/report/moduleinventory') %]?type=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
} }
}, { }, {
"data": 'model', "data": 'model',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?model=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>'; return '<a href="[% uri_for('/report/moduleinventory') %]?model=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
} }
}, { }, {
"data": 'serial', "data": 'serial',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?serial=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>'; return '<a href="[% uri_for('/report/moduleinventory') %]?serial=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
} }
}, { }, {
@@ -104,12 +100,12 @@ $(document).ready(function() {
} }
[% ELSE %] { [% ELSE %] {
"data": 'class', "data": 'class',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitaliseFirstLetter(data)) + '</a>'; return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitalizeFirstLetter(data)) + '</a>';
} }
}, { }, {
"data": 'count', "data": 'count',
"render": function(data, type, full, meta) { "render": function(data, type, row, meta) {
return data.replace(/\B(?=(\d{3})+(?!\d))/g, ","); return data.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
} }
} }