Commit bc359166 authored by Patrick Barroca's avatar Patrick Barroca 🐧

hotline #89508 : call babelio in HTTPS

parent c4856400
- ticket #89508 : Babelthèque : compatibilité HTTPS
\ No newline at end of file
(function() {
var getJSQueryString = function(script) {
var
scripts = document.getElementsByTagName('script'),
i,
curScript;
var getJSQueryString = function(script) {
var
scripts = document.getElementsByTagName('script'),
i,
curScript;
for (i = 0; i < scripts.length; ++i) {
curScript = scripts[i];
for (i = 0; i < scripts.length; ++i) {
curScript = scripts[i];
if (curScript.src.match(script)) {
return (curScript.src.match(/\?(.*)/) || [undefined])[1];
}
}
}
if (curScript.src.match(script)) {
return (curScript.src.match(/\?(.*)/) || [undefined])[1];
}
}
}
var getJSParams = function(script) {
var
qs = getJSQueryString(script),
search = /([^&=]+)=?([^&]*)/g,
urlParams = {};
var getJSParams = function(script) {
var
qs = getJSQueryString(script),
search = /([^&=]+)=?([^&]*)/g,
urlParams = {};
while (match = search.exec(qs))
while (match = search.exec(qs))
urlParams[match[1]] = match[2];
return urlParams;
}
return urlParams;
}
var getJSParamNamed = function (script, name) {
return getJSParams(script)[name];
}
var getJSParamNamed = function (script, name) {
return getJSParams(script)[name];
}
var bwid = getJSParamNamed('babeltheque.js', 'bwid');
var bwid = getJSParamNamed('babeltheque.js', 'bwid');
window.loadBabelthequeScript = function(isbn) {
insertBabelthequeISBNTag(isbn);
$.getScript('http://www.babeltheque.com/bw_' + bwid +'.js');
}
window.loadBabelthequeScript = function(isbn) {
insertBabelthequeISBNTag(isbn);
$.getScript('https://www.babelio.com/bw_' + bwid +'.js');
}
})();
$.fn.babelthequeTag=function(info) {
return this.each(function() {
$(this).append('<div id="BW_'+info+'"></div>');
});
return this.each(function() {
$(this).append('<div id="BW_'+info+'"></div>');
});
}
var insertBabelthequeISBNTag = function(isbn) {
if (!$('input#BW_id_isbn').length)
$('body').append('<input type="hidden" id="BW_id_isbn" value="'+isbn+'"\>');
if (!$('input#BW_id_isbn').length)
$('body').append('<input type="hidden" id="BW_id_isbn" value="'+isbn+'"\>');
}
var blocNoticeAfterLoad = function (info, isbn, target) {
if ("" == isbn)
return;
if ("" == isbn)
return;
var callback = $(window).attr(info + 'NoticeAfterLoad');
if (undefined == callback)
return;
var callback = $(window).attr(info + 'NoticeAfterLoad');
if (undefined == callback)
return;
callback(target);
loadBabelthequeScript(isbn);
callback(target);
loadBabelthequeScript(isbn);
}
var tagsNoticeAfterLoad = function(target) {
target.prepend('<div id="BW_etiquettes"></div>');
target.prepend('<div id="BW_etiquettes"></div>');
}
var avisNoticeAfterLoad = function(target) {
var tr_critiques = target.find('table tr:nth-child(2)');
var tr_critiques = target.find('table tr:nth-child(2)');
if (!tr_critiques.find('ul').length)
$('<ul></ul>').appendTo(tr_critiques);
if (!tr_critiques.find('ul').length)
$('<ul></ul>').appendTo(tr_critiques);
var ul_critiques = tr_critiques.find('ul');
$('<li class="notes_avis_babeltheque"><span id="BW_notes"></span><span id="BW_critiques"></span> <span id="BW_critiques_pro"></span></li>')
.appendTo(ul_critiques);
var ul_critiques = tr_critiques.find('ul');
$('<li class="notes_avis_babeltheque"><span id="BW_notes"></span><span id="BW_critiques"></span> <span id="BW_critiques_pro"></span></li>')
.appendTo(ul_critiques);
}
var videosNoticeAfterLoad = function(target) {
target.find('td:contains("Aucune vidéo")').remove();
target.prepend('<div id="BW_videos"></div>');
target.find('td:contains("Aucune vidéo")').remove();
target.prepend('<div id="BW_videos"></div>');
}
var resumeNoticeAfterLoad = function(target) {
target.find('td:contains("Aucune information")').remove();
target.babelthequeTag('citations');
target.find('td:contains("Aucune information")').remove();
target.babelthequeTag('citations');
}
var babelthequeNoticeAfterLoad = function(target) {
target.empty().babelthequeTag('suggestions');
target.empty().babelthequeTag('suggestions');
}
......@@ -964,18 +964,15 @@ class NoticeAjaxControllerExemplairesTest extends NoticeAjaxControllerExemplaire
class NoticeAjaxControllerBabelthequeTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
Class_Notice::getLoader()
->newInstanceWithId(157675)
->setIsbn('978-2-226-21993-0');
$this->fixture('Class_Notice', ['id' => 157675,
'isbn' => '978-2-226-21993-0']);
Class_AdminVar::getLoader()
->newInstanceWithId('BABELTHEQUE_JS')
->setValeur('http://www.babeltheque.com/bw_85.js');
Class_AdminVar::set('BABELTHEQUE_JS', 'https://www.babelio.com/bw_85.js');
$this->dispatch('/opac/noticeajax/babeltheque?id_notice=N157675', true);
}
......@@ -983,7 +980,7 @@ class NoticeAjaxControllerBabelthequeTest extends AbstractControllerTestCase {
/** @test */
public function responseShouldContainsBabelthequeScript() {
$this->assertXPath('//script[@src="http://www.babeltheque.com/bw_85.js"]');
$this->assertXPath('//script[@src="https://www.babelio.com/bw_85.js"]');
}
......@@ -1008,8 +1005,6 @@ class NoticeAjaxControllerBabelthequeTest extends AbstractControllerTestCase {
class NoticeAjaxControllerBabelthequeWithoutOptionTest extends AbstractControllerTestCase {
public function setUp() {
parent::setUp();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment