VAText.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. VAText = function(w) {
  2. this.window = w ? w : window;
  3. this.isText = false;
  4. this.text = jQuery.proxy(this.text, this);
  5. this.reset = jQuery.proxy(this.reset, this);
  6. this.active = jQuery.proxy(this.active, this);
  7. }
  8. VAText.prototype = {
  9. active: function() {
  10. if (this.isText) {
  11. this.text();
  12. }
  13. },
  14. text: function() {
  15. this.isText = true;
  16. var c = jQuery(this.window.document)[0];
  17. jQuery(this.window.document).find("link, style").remove().end()
  18. .find("img").each(function() {
  19. var d = this.alt || this.title;
  20. if (d) {
  21. var e = c.createElement("span");
  22. e.innerHTML = d;
  23. this.parentNode.insertBefore(e, this)
  24. }
  25. jQuery(this).remove()
  26. })
  27. .end().find("iframe").each(function() {
  28. try {
  29. var g = this.contentWindow,
  30. d = g.document.getElementsByTagName("body")[0].innerHTML,
  31. h = c.createElement("div");
  32. h.innerHTML = d;
  33. this.parentNode.insertBefore(h, this)
  34. }
  35. catch (f) { }
  36. jQuery(this).remove()
  37. }).end().find("*").not("script, div[va=cross]").css("display", "block");
  38. },
  39. reset: function() {
  40. this.isText = false;
  41. this.window.location.reload();
  42. }
  43. }