[php] test

Viewer

  1. <?php 
  2. $var = 'var selectedScenes = location.search.split(\'n=\')[1];
  3.  
  4. if (selectedScenes != undefined) {
  5.     selectedScenes = selectedScenes.split(",");
  6.  
  7.     var rows = $(\'table tbody tr td:first-child\')
  8.  
  9.     rows.each(function (index) {
  10.         var sceneNum = $(this).text();
  11.  
  12.         if (selectedScenes.indexOf(sceneNum) == -1) {
  13.             $(this).closest(\'tr\').remove();
  14.         }
  15.     });
  16. }
  17.  
  18. var clipboard = new Clipboard(".btn-copy-to-clipboard");
  19.  
  20. clipboard.on(\'success\', function (e) {
  21.     $(".copy_message").text("Copied to clipboard").show();
  22.     $("#embedding_modal").modal("hide")
  23. });
  24.  
  25. $(".btn-embed").on("click", function (event) {
  26.     $(".copy_message").hide();
  27.     var row = $(event.target).closest("tr");
  28.     var embed_code = embed_generator.generate_embeding_code(row[0]);
  29.     $("#embed_code_textarea").val(embed_code.tags)
  30.     $(".video_title_span").text(embed_code.title)
  31.     $(\'#embedding_modal\').modal(\'show\')
  32. })
  33.  
  34. var embed_generator = {};
  35. embed_generator["generate_embeding_code"] = function (row) {
  36.     var children = row.children;
  37.     var poster_image = row.getAttribute(\'data-poster-url\');
  38.     var title = children[1].textContent.trim();
  39.     var video_type = children[5].textContent.trim();
  40.     var video_format = video_type == "180" ? "STEREO_180_LR" : "STEREO_360_TB"
  41.     var stream_urls = [];
  42.     var anchors_node = children[8].querySelectorAll(\'a\')
  43.     var a_l = anchors_node.length;
  44.     stream_urls.push(anchors_node[a_l - 2].href)
  45.     stream_urls.push(anchors_node[a_l - 1].href)
  46.  
  47.     var completeTrailerList = [];
  48.     for (var i = 0; i < anchors_node.length; i++) {
  49.         completeTrailerList.push({
  50.             quality: anchors_node[i].textContent,
  51.             url: anchors_node[i].href,
  52.             index: i
  53.         });
  54.     }
  55.     var fallback = getFallbackURL(completeTrailerList, video_format, title, poster_image);
  56.     var video_tag = document.createElement("dl8-video");
  57.     video_tag.title = title;
  58.  
  59.     var poster = document.createAttribute("poster");
  60.     poster.value = poster_image;
  61.     video_tag.attributes.setNamedItem(poster);
  62.  
  63.     var format_attribute = document.createAttribute("format");
  64.     format_attribute.value = video_format;
  65.     video_tag.attributes.setNamedItem(format_attribute);
  66.  
  67.     var display_mode = document.createAttribute("display-mode");
  68.     display_mode.value = "inline";
  69.     video_tag.attributes.setNamedItem(display_mode);
  70.  
  71.     var width = document.createAttribute("width");
  72.     width.value = "100%";
  73.     video_tag.attributes.setNamedItem(width);
  74.  
  75.     var cors_fallback_url = document.createAttribute("cors-fallback-url");
  76.     cors_fallback_url.value = getFallbackURL(completeTrailerList, video_format, title, poster_image);
  77.     video_tag.attributes.setNamedItem(cors_fallback_url);
  78.  
  79.     /**
  80.      * >>> videoSourceOrder <<<
  81.      * 
  82.      * hardcoded list that represents the order 
  83.      * we want the video ualities to appear in the delightvr 
  84.      * dropdown. The order is derived from the original 
  85.      * order from the affiliate resource page, as in -
  86.      * Oculus / HTC Vive    0
  87.      * Gear VR / Daydream   1
  88.      * PSVR                 2
  89.      * Mobile HQ            3
  90.      * Mobile LQ            4
  91.      * Streaming high       5 
  92.      * Streaming low        6
  93.      */
  94.     var videoSourceOrder = [5, 3, 4, 2, 1, 0];
  95.     for (var i = 0; i < videoSourceOrder.length; i++) {
  96.         var index = videoSourceOrder[i];
  97.         if (completeTrailerList[index]) {
  98.             var video_url = completeTrailerList[index].url;
  99.             var new_source = document.createElement("source");
  100.             new_source.src = video_url;
  101.             var type = video_url.match("webm") ? "webm" : "mp4";
  102.             new_source.type = "video/" + type;
  103.             var quality_attr = document.createAttribute("quality");
  104.             quality_attr.value = completeTrailerList[index].quality;
  105.             new_source.attributes.setNamedItem(quality_attr);
  106.             video_tag.appendChild(new_source);
  107.         }
  108.     }
  109.  
  110.     return {
  111.         tags: video_tag.outerHTML,
  112.         title: title
  113.     }
  114. }
  115.  
  116.  
  117. function getUrlVars() {
  118.     var vars = [], hash;
  119.     var hashes = window.location.href.slice(window.location.href.indexOf(\'?\') + 1).split(\'&\');
  120.     for (var i = 0; i < hashes.length; i++) {
  121.         hash = hashes[i].split(\'=\');
  122.         vars.push(hash[0]);
  123.         vars[hash[0]] = hash[1];
  124.     }
  125.     return vars;
  126. }
  127.  
  128. function getFallbackURL(completeTrailerList, video_format, title, poster_image) {
  129.     var baseUrl = "https://p.badoinkvr.com/vr_fallback/?" + "format=" + video_format + "&main_title=" + title + "&poster_image=" + poster_image;
  130.     var filesAndQualities = "";
  131.     for (var i = 0; i < completeTrailerList.length; i++) {
  132.         filesAndQualities += \'&url_\' + i + \'=\' + completeTrailerList[i].url + \'&title_\' + i + \'=\' + completeTrailerList[i].quality;
  133.     }
  134.  
  135.     return baseUrl + filesAndQualities;
  136. }
  137.  
  138. //add deep video links
  139. var table = $(\'table\');
  140. var affiliateUrlTemplate = table[0].getAttribute(\'data-affiliate-url-template\');
  141. var aid = getUrlVars()[\'aid\'];
  142. table.find(\'tr:first\').append("<td><b>Video Link</b></td>");
  143.  
  144. $.each(
  145.     table.find(\'tr\').splice(1, table.find(\'tr\').length),
  146.     function () {
  147.         var sceneId = $(this).find("a[data-sceneId]").first().data(\'sceneid\');
  148.         var sceneUrl = $(this).attr(\'data-scene-url\');
  149.  
  150.         if (typeof aid != \'undefined\' && typeof sceneId != \'undefined\') {
  151.             url = sceneUrl + affiliateUrlTemplate + aid;
  152.         }
  153.         else {
  154.             url = \'\';
  155.         }
  156.         $(this).append(\'<td><span class="sceneUrl">\' + url + \'</span></td>\')
  157.     }
  158. );
  159.  
  160. function getLinksForReddit() {
  161.     var btnReddit = $(\'.btn-reddit\');
  162.  
  163.     btnReddit.on(\'click\', function(){
  164.         var linksBlock = [];
  165.         var flag = \'\';
  166.         var el = $(this).closest(\'tr\').find(\'.videoLink\');
  167.         var names;
  168.  
  169.         el.each(function(i,e){
  170.             if(el.hasClass(\'extra5k\') && el.hasClass(\'extraQuest\')) {
  171.                 flag = \'all\';
  172.             }
  173.             if(el.hasClass(\'extra5k\') && !el.hasClass(\'extraQuest\')) {
  174.                 flag = \'extra5k\';
  175.             }
  176.             if(!el.hasClass(\'extra5k\') && el.hasClass(\'extraQuest\')) {
  177.                 flag = \'extraQuest\';
  178.             }
  179.             if(!el.hasClass(\'extra5k\') && !el.hasClass(\'extraQuest\')) {
  180.                 flag = \'normal\';
  181.             }
  182.             linksBlock.push(\'- [link](\' + $(this).attr(\'href\') + \'),\')
  183.         });
  184.  
  185.         if(flag == \'all\') {
  186.             var names = [\'Oculus / HTC Vive - 5K\', \'Oculus Go / Oculus Quest\', \'Oculus Rift (S) / HTC Vive\', \'Gear VR / Daydream\', \'PSVR\', \'Mobile HQ\', \'Mobile LQ\'];
  187.         }
  188.  
  189.         if(flag == \'extra5k\') {
  190.             var names = [\'Oculus / HTC Vive - 5K\', \'Oculus Rift (S) / HTC Vive\', \'Gear VR / Daydream\', \'PSVR\', \'Mobile HQ\', \'Mobile LQ\'];
  191.         }
  192.  
  193.         if(flag == \'extraQuest\') {
  194.             var names = [\'Oculus Go / Oculus Quest\', \'Oculus Rift (S) / HTC Vive\', \'Gear VR / Daydream\', \'PSVR\', \'Mobile HQ\', \'Mobile LQ\'];
  195.         }
  196.  
  197.         if(flag == \'normal\') {
  198.             var names = [\'Oculus Rift (S) / HTC Vive\', \'Gear VR / Daydream\', \'PSVR\', \'Mobile HQ\', \'Mobile LQ\'];
  199.         }
  200.  
  201.         var arrayCombined = $.map(names, function(v, i) {
  202.             return [linksBlock[i].replace(\'[link]\', \'[\' + v + \']\')];
  203.         });
  204.  
  205.         var result = arrayCombined.toString().replace(/,/g, \'\\n\');
  206.  
  207.         new Clipboard(\'.btn-reddit\', {
  208.             text: function() {
  209.                 return result;
  210.             }
  211.         });
  212.     })
  213. }
  214.  
  215. $(document).ready(function(){
  216.     getLinksForReddit();
  217. })';

Editor

You can edit this paste and save as new: