Skip to content

Instantly share code, notes, and snippets.

@cmchap
Last active August 29, 2015 14:01
Show Gist options
  • Save cmchap/8b2f7a3a8372eab04542 to your computer and use it in GitHub Desktop.
Save cmchap/8b2f7a3a8372eab04542 to your computer and use it in GitHub Desktop.
CopyrightNotice: a jQuery plugin to create an always-up-to-date copyright notice
/*
* Javascript CopyrightNotice
*
* Copyright (c) 2014 Cory Chapman
* Licensed under the MIT license
*
* For more info on copyright see: http://www.bitlaw.com/copyright/formalities.html
*
* Example usage:
* $('.copyright').copyrightNotice({ byLine: 'Cory Chapman', published: false });
*
*/
(function($) {
$.fn.copyrightNotice = function(options) {
var settings = $.extend({
byLine: '[COPYRIGHT HOLDER NAME]',
published: true
}, options);
return this.each(function() {
var byLine = settings.byLine;
var published = settings.published;
var currentYear = new Date().getFullYear();
var copyrightText = '© ' + currentYear + ' ' + byLine;
if (published != true) {
copyrightText = 'Unpublished Work ' + copyrightText;
}
$(this).html(copyrightText);
});
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment