Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String.prototype.getInitials = function (glue) {
- if (typeof glue == "undefined") {
- var glue = true;
- }
- var initials = this.replace(/[^a-zA-Z- ]/g, "").match(/\b\w/g);
- if (glue) {
- return initials.join('');
- }
- return initials;
- };
- String.prototype.capitalize = function () {
- return this.toLowerCase().replace(/\b\w/g, function (m) {
- return m.toUpperCase();
- });
- };
- $(function () {
- var mustache = new RegExp(/{{\s*[\w\.]+\s*}}/g);
- $('.scaffold-user').each(function (i) {
- var _name = faker.fake("{{name.firstName}} {{name.lastName}}");
- var _initials = _name.getInitials();
- var _this = this
- var _nameInterpolate = function () {
- var content = $(_this).find('.scaffold-name').text();
- if (/{{\s*[\w\.]+\s*}}/g.test(content) === true) {
- var newContent = content.replace(mustache, _name);
- return newContent;
- }
- else {
- return _name;
- }
- }
- $(this).find('.scaffold-name').text(_nameInterpolate());
- $(this).find('.scaffold-initials').html(_initials);
- $(this).find('.scaffold-email').html(faker.internet.email());
- });
- $('.scaffold-email').each(function () {
- $(this).text(faker.internet.email());
- });
- $('.scaffold-date-future').each(function () {
- $(this).text(faker.date.future());
- });
- $('.scaffold-date-past').each(function () {
- var _date = faker.date.past();
- var value = moment(_date).format('MMMM Do, YYYY');
- $(this).text(value);
- });
- $('.scaffold-number').each(function (i) {
- var max = this.attr('data-num-max') || 100;
- var _num = faker.random.number(max)
- $(this).text(_num);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement