process null dates with moment.js - momentjs

I need to process date strings with moment.js such that blank dates are accepted. Something like this:
if ((moment().isAfter(exDate))) or (moment(null)) {}
EXISTING CODE
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.1/moment.js"></script>
var exDate = moment(cccr_mems[i].cccrEXP, 'YYYY.MM.DD');
if (moment().isAfter(exDate)) {

Related

How to get date in UK format

The column dates are appearing as Sat 2/16, etc. instead of the UK format Sat 16/2. How do I change it?
default: 'en',
columnFormat: {
day: 'dddd d/M'
},
doesn't work.
You need to include the locale file and then set it in your calendar config
You can read everything about it here
You will need to load the locale JavaScript data file in order to use it. These files are included with the FullCalendar download in the locale/ directory. They must be loaded via a tag after the main FullCalendar library is loaded.
script src='fullcalendar/fullcalendar.js'></script>
<script src='fullcalendar/locale-all.js'></script> <!-- this is a file including all the locales -->
<script>
$(function() {
$('#calendar').fullCalendar({
locale: 'es' // This is an acronym for the locale you want to select
});
});

How to append querystring to GruntBuilder on Sails?

My assets are 'linked' like
<script src="/js/library-x.js"></script>
And I want to use
<script src="/js/library-x.js?v=GITHUB_LAST_COMMIT"></script>
Or even:
<script src="/js/library-x.js?v=NPM_PACKAGE_VERSION"></script>
PS: At config/globals.js I have something like:
module.exports.globals = {
....
package: require('../package.json')
};
The only problem is the grunt linker, that replace the string at my layout every time it lifts...

jquery datepicker max date min date control using two date picker

what I have : I have two datepicker calender control in jquery where 1st can only choose date current date and previous date but not future date for that I have written the code which works fine
<script type="text/javascript">
$(function () {
$("#from").datepicker({ maxDate: 0 });
});
</script>
Now I have to use another textbox with datepicker which can only select dates between the date selected in 1st textbox and current date.
Now having these conditions what code should I write for my second datepicker.
my project is in Asp .net using c#. Any help would be appreciated
Please try the below:
<script type = "text/javascript">
$(function () {
$("#from").datepicker({
onSelect: function (date) {
$("#to").datepicker("option","minDate", date);
$("#to").datepicker("option","maxDate", new Date());
},
maxDate: 0
});
});
</script>

How to set an API key when using Google's script loader?

I registered my project and generated a browser key at https://code.google.com/apis/console/.
Now how do I use that key when using the Google Script Loader?
I've been doing this, which works (with or without the key parameter), but even after several weeks the API console shows no requests:
<script src=//www.google.com/jsapi?key=my_key"></script>
<script>
google.load('maps', '3.10', { other_params : 'libraries=places&sensor=false', callback : ... })
</script>
The key is useless for the jsapi, you must append it to other_params:
<script>
google.load('maps', '3', {
other_params: 'key=my_key',
callback: function(){}
});
</script>
When using charts/loader you have to do something like this:
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {
'packages':['geochart'],
// Note: you will need to get a mapsApiKey for your project.
// See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings
'mapsApiKey': 'AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'
});
google.charts.setOnLoadCallback(drawRegionsMap);
...
</script>
Note the mapsApiKey property.
As described in https://developers.google.com/chart/interactive/docs/gallery/geochart

Calling a function of en external javascript file

In general... How can I make a call on a function of an external java script file?
More specific...
In the head tag i have
<script type="text/javascript" src="JScript/FontSize.js"></script>
The external javascript file, (that i would like to call) FontSize.js contains the following functions.
function checkCookie()
function setCookie(c_name, value, expiredays)
function getCookie(c_name)
function increaseFontSize()
function decreaseFontSize()`
The FontSize.js is located at the ~/Jscript/ directory
I guess the body on load should contain something like
<body onload="/JScript/Fontsize.js/checkCookie()">
Of course nothing works as it should because, i do not know how to make the call to a function to an external js file
You just call it as if it were local :)
<body onload="checkCookie()">
Or, do it in script:
window.onload = checkCookie;
When you declare a function and it's not in another object/namespace, it's just globally available, and you can call it as if it immediately preceded your current code. By default these functions will be on the window object, you can see a short demo here.
For example (doesn't matter where this function's defined, external or not):
function myFunc() { alert('hi'); }
myFunc();
window.myFunc(); //same call, unless there's *another* myFunc in a local-er scope
<html>
<head>
<script type="text/javascript" language="javascript" src="main.js"></script>
</head>
<body>
<!--The extranal main.js file contains samp() function.. -->
<script>
<!-- samp(); -->
</script>
</body>
</html>

Resources