diff --git a/main/inc/lib/fixlinks.js b/main/inc/lib/fixlinks.js index 77e3bb0f46..1a5145b182 100644 --- a/main/inc/lib/fixlinks.js +++ b/main/inc/lib/fixlinks.js @@ -10,6 +10,12 @@ $(document).ready(function() { var link = 'If video does not work, try clicking here.'; var embed = $("#"+this.id).find('embed').first(); + var hasHttp = embed.attr('src').indexOf("http"); + + if (hasHttp < 0) { + return true; + } + var height = embed.attr('height'); var width = embed.attr('width'); var src = embed.attr('src').replace('https', 'http'); @@ -36,11 +42,17 @@ $(document).ready(function() { var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26)); var uniqid = randLetter + Date.now(); var openerId = uniqid +'_opener'; - var link = 'If iframe does not work, try clicking here.'; + var link = 'Open website.'; var embed = $(this); var height = embed.attr('height'); var width = embed.attr('width'); var src = embed.attr('src'); + + var n = src.indexOf("youtube.com"); + if (n > 0) { + return true; + } + var completeUrl = url + 'width='+embed.attr('width')+ '&height='+height+ '&type=iframe'+ @@ -51,9 +63,9 @@ $(document).ready(function() { if (result.length == 0) { if (embed.next().attr('class') != 'generated') { - $(this).parent().append(link + '
'); + $(this).prepend(link + '
'); $('#' + openerId).click(function () { - width = 1024; + width = 1280; height = 640; var win = window.open(completeUrl, "Video", "width=" + width + ", " + "height=" + height + ""); win.document.title = 'Video'; @@ -64,9 +76,39 @@ $(document).ready(function() { var anchors = $(document).find('a').not('.generated'); anchors.each(function (value, obj) { - if ($(this).next().attr('class') != 'generated') { + if ($(this).next().attr('class') != 'generated' ) { + var content = $(this).html(); + content = content.replace('
', ''); + content = content.replace('
', ''); + content = $.trim(content); + if (content == '') { + return true; + } + + if ($(this).attr('href')) { + var hasLocalhost = $(this).attr('href').indexOf(location.host); + + if (hasLocalhost > 0) { + return true; + } + + var hasJs = $(this).attr('href').indexOf('javascript'); + if (hasJs >= 0) { + return true; + } + } + + if ($(this).attr('class')) { + var hasAccordion = $(this).attr('class').indexOf('accordion-toggle'); + if (hasAccordion >= 0) { + return true; + } + } + var src = $(this).attr('href'); + src = url+'&type=link&src='+src; src = src.replace('https', 'http'); + $(this).attr('href', src); var myAnchor = $('').attr("href", src).attr('target', '_blank').attr('class', 'generated'); $(this).after(myAnchor); $(this).after('-'); diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index e46a19734a..99cc98f164 100755 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -2130,7 +2130,6 @@ function attach_glossary_into_scorm(type) { }); } - if (type == 'fix_links') { $(document).ready(function() { var objects = $("iframe").contents().find('object'); @@ -2140,7 +2139,6 @@ function attach_glossary_into_scorm(type) { var url = "http://"+location.host + coursePath+"/courses/proxy.php?"; objects.each(function (value, obj) { - var dialogId = this.id +'_dialog'; var openerId = this.id +'_opener'; @@ -2148,6 +2146,12 @@ function attach_glossary_into_scorm(type) { '

If video does not work, try clicking here.
'; var embed = $("iframe").contents().find("#"+this.id).find('embed').first(); + var hasHttp = embed.attr('src').indexOf("http"); + + if (hasHttp < 0) { + return true; + } + var height = embed.attr('height'); var width = embed.attr('width'); var src = embed.attr('src').replace('https', 'http'); @@ -2178,7 +2182,7 @@ function attach_glossary_into_scorm(type) { var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26)); var uniqid = randLetter + Date.now(); var openerId = uniqid +'_opener'; - var link = 'If iframe does not work, try clicking here. '; + var link = 'Open website '; var embed = $(this); var height = embed.attr('height'); var width = embed.attr('width'); @@ -2191,11 +2195,16 @@ function attach_glossary_into_scorm(type) { '&width='+width; var result = $("iframe").contents().find('#'+openerId); + var n = src.indexOf("youtube.com"); + if (n > 0) { + return true; + } + if (result.length == 0) { - if (embed.next().attr('class') != 'generated') { - $(this).parent().append(link + '
'); + if (embed.prev().attr('class') != 'generated') { + $(this).parent().prepend(link + '
'); $("iframe").contents().find('#' + openerId).click(function() { - width = 1024; + width = 1280; height = 640; var win = window.open(completeUrl, "Video", "width=" + width + ", " + "height=" + height + ""); win.document.title = 'Video'; @@ -2206,15 +2215,45 @@ function attach_glossary_into_scorm(type) { var anchors = $("iframe").contents().find('a').not('.generated'); anchors.each(function (value, obj) { - var src = $(this).attr('href'); - src = src.replace('https', 'http'); - var myAnchor = $('').attr("href", src).attr('target', '_blank').attr('class', 'generated'); - $(this).after(myAnchor); - $(this).after('-'); + if ($(this).next().attr('class') != 'generated') { + var content = $(this).html(); + content = content.replace('
', ''); + content = content.replace('
', ''); + content = $.trim(content); + if (content == '') { + return true; + } + + if ($(this).attr('href')) { + var hasLocalhost = $(this).attr('href').indexOf(location.host); + if (hasLocalhost > 0) { + return true; + } + + var hasJs = $(this).attr('href').indexOf('javascript'); + if (hasJs >= 0) { + return true; + } + } + + if ($(this).attr('class')) { + var hasAccordion = $(this).attr('class').indexOf('accordion-toggle'); + if (hasAccordion >= 0) { + return true; + } + } + + var src = $(this).attr('href'); + src = url+'&type=link&src='+src; + src = src.replace('https', 'http'); + $(this).attr('href', src); + var myAnchor = $('').attr("href", src).attr('target', '_blank').attr('class', 'generated'); + $(this).after(myAnchor); + $(this).after('-'); + } }); }); } - } }