Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. if(...){
  2. newa.playlist[t].num = $('.tagEditor .num').val();
  3. newa.playlist[t].name = $('.tagEditor .name').val();
  4. newa.playlist[t].artist = $('.tagEditor .artist').val();
  5. newa.playlist[t].album = $('.tagEditor .album').val();
  6. newa.playlist[t].date = $('.tagEditor .date').val();
  7. }else if(...){
  8. newp.playlist[t].num = $('.tagEditor .num').val();
  9. newp.playlist[t].name = $('.tagEditor .name').val();
  10. newp.playlist[t].artist = $('.tagEditor .artist').val();
  11. newp.playlist[t].album = $('.tagEditor .album').val();
  12. newp.playlist[t].date = $('.tagEditor .date').val();
  13. }else if(...){
  14. newv.playlist[t].num = $('.tagEditor .num').val();
  15. newv.playlist[t].name = $('.tagEditor .name').val();
  16. newv.playlist[t].artist = $('.tagEditor .artist').val();
  17. newv.playlist[t].album = $('.tagEditor .album').val();
  18. newv.playlist[t].date = $('.tagEditor .date').val();
  19. }
  20.  
  21. var fields = ['num', 'name', 'artist', 'album', 'date'],
  22. obj = newv;
  23.  
  24. if(...) obj = newa;
  25. if(...) obj = newp;
  26.  
  27. for(var i in fields) {
  28. obj.playlist[t][fields[i]] = $('.tagEditor .' + fields[i]).val();
  29. }
  30.  
  31. for (var i in newa.playlist[t])
  32. {
  33. newa.playlist[t][i] = $('.tagEditor .' + i).val();
  34. }
  35.  
  36. $.extractMetaData = (function (names/**array*/){
  37. return function (target/**jQuery|String*/){
  38. var data = {};
  39. $.each(names, function (i, name) {
  40. data[name] = $('.' + name, target).val();
  41. });
  42. return data;
  43. };
  44. })('num name artist album date'.split(' '));
  45.  
  46. // Usage
  47. newa.playlist[t] = $.extractMetaData('.tagEditor');
  48.  
  49. if(...){
  50. with( newa.playlist[t]){
  51. num = $('.tagEditor .num').val();
  52. name = $('.tagEditor .name').val();
  53. artist = $('.tagEditor .artist').val();
  54. album = $('.tagEditor .album').val();
  55. date = $('.tagEditor .date').val();
  56. }
  57. }else if(...){
  58. with( newp.playlist[t]){
  59. ...
  60.  
  61. var X;
  62. if(...){
  63. X = newa.playlist[t];
  64. X.num = $('.tagEditor .num').val();
  65. X.name = $('.tagEditor .name').val();
  66. X.artist = $('.tagEditor .artist').val();
  67. X.album = $('.tagEditor .album').val();
  68. X.date = $('.tagEditor .date').val();
  69. }else if(...){
  70. X = newp.playlist[t];
  71. ...
  72.  
  73. function xx(zz)
  74. {
  75. zz.num = $('.tagEditor .num').val();
  76. zz.name = $('.tagEditor .name').val();
  77. zz.artist = $('.tagEditor .artist').val();
  78. zz.album = $('.tagEditor .album').val();
  79. zz.date = $('.tagEditor .date').val();
  80. }
  81.  
  82. if (..) {
  83. xx(newa.playlist[t]);
  84. }
  85. else if (..)
  86. {
  87. xx(newv.playlist[t]);
  88. }
  89. else
  90. xx(newp.playlist[t]);
  91.  
  92. const props = [
  93. 'num',
  94. 'name',
  95. 'artist',
  96. 'album',
  97. 'date'
  98. ]
  99.  
  100. function getval(element, t){
  101. for (const prop of props){
  102. element.playlist[t][prop] = $(`.tagEditor ${prop}`).val()
  103. }
  104. }
  105.  
  106. if(...){
  107. getval(newa)
  108. }else if(...){
  109. getval(newp)
  110. }else if(...){
  111. getval(newv)
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement