JAVASCRIPT 24
Iframe.js Guest on 20th April 2021 04:41:29 PM
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3.   var iframe_template, utils;
  4.  
  5.   utils = require('./utils');
  6.  
  7.   iframe_template = "<!DOCTYPE html>\n<html>\n<head>\n  <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n  <script src=\"{{ sockjs_url }}\"></script>\n  <script>\n    document.domain = document.domain;\n    SockJS.bootstrap_iframe();\n  </script>\n</head>\n<body>\n  <h2>Don't panic!</h2>\n  <p>This is a SockJS hidden iframe. It's used for cross domain magic.</p>\n</body>\n</html>";
  8.  
  9.   exports.app = {
  10.     iframe: function(req, res) {
  11.       var content, context, k, quoted_md5;
  12.       context = {
  13.         '{{ sockjs_url }}': this.options.sockjs_url
  14.       };
  15.       content = iframe_template;
  16.       for (k in context) {
  17.         content = content.replace(k, context[k]);
  18.       }
  19.       quoted_md5 = '"' + utils.md5_hex(content) + '"';
  20.       if ('if-none-match' in req.headers && req.headers['if-none-match'] === quoted_md5) {
  21.         res.statusCode = 304;
  22.         return '';
  23.       }
  24.       res.setHeader('Content-Type', 'text/html; charset=UTF-8');
  25.       res.setHeader('ETag', quoted_md5);
  26.       return content;
  27.     }
  28.   };
  29.  
  30. }).call(this);

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.