Advertisement
PhilllChabbb

Vanilla Forum Mediator Plugin Vine/Twitter addition

Apr 15th, 2015
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. This is additional features for the excellent Mediator plugin created by Seon-Wook Park alias Swook.
  2. Swook page : http://www.swook.net/
  3. Mediator plugin page : http://vanillaforums.org/addon/mediator-plugin
  4.  
  5. Note : The code is more a hack then anything, I'm an amateur in JS. Just here for people who'd like the feature. :D
  6.  
  7. ------------------- ▼ JS Edit (mediator.js) ▼ -----------------------------
  8.  
  9. //Place inside function Check (i, elem) {...}
  10. if (urlo.host == 'vine.co' || urlo.host == 'www.vine.co')
  11. return ReplaceVine(urlo.file, elem, $elem);
  12.  
  13. //Place inside function Check (i, elem) {...}
  14. if (urlo.host == 'twitter.com' || urlo.host == 'www.twitter.com'){
  15. var user = url.match(/^http[s]?:\/\/.*?\/([a-zA-Z-_\d+]+).*$/)[1];
  16. return ReplaceTwitter(user, urlo.file, elem, $elem);
  17. }
  18.  
  19. function ReplaceVine (hash, elem, $elem) {
  20. var newel = $('<iframe>');
  21. newel.prop('src', '//vine.co/v/'+ hash+ '/embed/simple')
  22. CommonSetting(newel, $elem, 'Vine');
  23. $elem.replaceWith(newel);
  24. }
  25.  
  26. function ReplaceTwitter(user, hash, elem, $elem) {
  27. var newel = $('<iframe>');
  28. newel.prop('src', 'http://twitframe.com/show?url=https%3A%2F%2Ftwitter.com%2F' + user + '%2Fstatus%2F' + hash)
  29. TwitterSetting(newel, $elem, 'Twitter');
  30. $elem.replaceWith(newel);
  31. }
  32.  
  33. function TwitterSetting (newel, $elem, type) {
  34. $elem.addClass('Mediator');
  35. type = type ? ' '+ type : '';
  36. $elem.wrap('<center class="Mediator'+ type +'"/>');
  37. return;
  38. }
  39.  
  40. ------------------- ▼ CSS Edit (style.css) ▼ -----------------------------
  41.  
  42. center.Vine iframe {
  43. width: 480px;
  44. height: 480px;
  45. }
  46.  
  47. center.Twitter iframe {
  48. width: 480px;
  49. height: 300px;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement