Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. ...
  2. <tr>
  3. <th scope="row">322</th>
  4. <td>OK</td>
  5. <td><pre>Текст id:6774076|PRODUCT|123_D текст
  6. текст текст текст текст текст текст
  7. текст текст текст текст текст текст
  8. текст текст текст
  9. текст id:224076|CATEGORY|123_D
  10. </pre>
  11. </td>
  12. </tr>
  13. ...
  14.  
  15. $(document).ready(function () {
  16.  
  17. $(document).find('body').each(function () {
  18.  
  19. let old_html = $(this).html();
  20. let regexp = /id:(w+)|(w+)|(w+)/gm;
  21. let to_replace = [];
  22.  
  23. match = regexp.exec(old_html);
  24. while (match != null) {
  25. let id= match[1];
  26. let obj= match[2];
  27. let element= match[3];
  28.  
  29. if (obj=== 'CATEGORY') {
  30. to_replace.push({
  31. 'from': match[0],
  32. 'to': 'id:<a href="/category?id=' + id + '&element=' + element+ '">' + id + '</a>|' + obj + '|' + element
  33. })
  34. }
  35. match = regexp.exec(old_html);
  36. }
  37.  
  38. for (var i = 0; i < to_replace.length; i++) {
  39. old_html.replace(to_replace[i].from,to_replace[i].to)
  40. }
  41. });
  42.  
  43. $(this).html(old_html)
  44.  
  45. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement