Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. String.prototype.getInitials = function (glue) {
  2. if (typeof glue == "undefined") {
  3. var glue = true;
  4. }
  5.  
  6. var initials = this.replace(/[^a-zA-Z- ]/g, "").match(/\b\w/g);
  7.  
  8. if (glue) {
  9. return initials.join('');
  10. }
  11.  
  12. return initials;
  13. };
  14.  
  15. String.prototype.capitalize = function () {
  16. return this.toLowerCase().replace(/\b\w/g, function (m) {
  17. return m.toUpperCase();
  18. });
  19. };
  20.  
  21.  
  22. $(function () {
  23. var mustache = new RegExp(/{{\s*[\w\.]+\s*}}/g);
  24. $('.scaffold-user').each(function (i) {
  25. var _name = faker.fake("{{name.firstName}} {{name.lastName}}");
  26. var _initials = _name.getInitials();
  27. var _this = this
  28. var _nameInterpolate = function () {
  29. var content = $(_this).find('.scaffold-name').text();
  30. if (/{{\s*[\w\.]+\s*}}/g.test(content) === true) {
  31. var newContent = content.replace(mustache, _name);
  32. return newContent;
  33. }
  34. else {
  35. return _name;
  36. }
  37. }
  38.  
  39. $(this).find('.scaffold-name').text(_nameInterpolate());
  40. $(this).find('.scaffold-initials').html(_initials);
  41. $(this).find('.scaffold-email').html(faker.internet.email());
  42. });
  43.  
  44. $('.scaffold-email').each(function () {
  45. $(this).text(faker.internet.email());
  46. });
  47.  
  48. $('.scaffold-date-future').each(function () {
  49. $(this).text(faker.date.future());
  50. });
  51.  
  52. $('.scaffold-date-past').each(function () {
  53. var _date = faker.date.past();
  54. var value = moment(_date).format('MMMM Do, YYYY');
  55. $(this).text(value);
  56. });
  57.  
  58. $('.scaffold-number').each(function (i) {
  59. var max = this.attr('data-num-max') || 100;
  60. var _num = faker.random.number(max)
  61. $(this).text(_num);
  62. });
  63. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement