Skip to content
Snippets Groups Projects
Commit ab3a7a4d authored by Ghislain Loas's avatar Ghislain Loas
Browse files

dev #79082 : improve js

parent aceba3e8
Branches
Tags
6 merge requests!2890Master,!2889Master,!2888Master,!2887Master,!2878Dev#79082 explo amelioration du force https,!2873Dev#79082 explo amelioration du force https
Pipeline #5255 failed with stage
in 29 minutes and 1 second
......@@ -11,7 +11,7 @@ $html = [$this->renderForm($this->searchform),
$this->button((new Class_Entity(['Text' => $this->_('Sélectionner les URL acceptant le HTTPS'),
'Attribs' => ['onclick' => '',
'id' => 'test_all_https_protocol']]))),
'id' => 'select_all_https_protocol']]))),
$this->button((new Class_Entity(['Text' => $this->_('Mettre à jour les URL selectionnées en HTTPS dans les contenus'),
'Attribs' => ['onclick' => '',
......
<?php
echo $this->tag('span',
$this->_('Ko'),
$this->_('Non'),
['title' => $this->response->getMessage(),
'class' => 'error']);
<?php
echo $this->tag('span', $this->_('Ok'), ['class' => 'notice']);
echo $this->tag('span', $this->_('Oui'), ['class' => 'notice']);
......@@ -64,6 +64,7 @@ class Class_UrlManager_Description {
'https://', $instance->getUrl()))]);
return $view->tag('div', '' ,
['data-test-url' => $url,
'data-selectable' => '0',
'data-id' => $instance->getId(),
'data-protocol' => 'https']);
})
......
......@@ -23,12 +23,12 @@
html.find('#test_all_http_protocol').click(function(event) {
event.preventDefault();
testProtocolOnAllLinks('http');
testProtocolOnAllLinks();
});
html.find('#test_all_https_protocol').click(function(event) {
html.find('#select_all_https_protocol').click(function(event) {
event.preventDefault();
testProtocolOnAllLinks('https');
selectAllHttpsProtocol();
});
html.find('[data-selected-status]').click(function(event) {
......@@ -48,6 +48,7 @@
url : $(this).attr('data-convert'),
type : "GET",
dataType : "html",
async: false
});
});
setTimeout(function() {window.location.reload();}, 1000);
......@@ -58,15 +59,15 @@
if (element.attr('data-selected-status') == 1) {
element.find('img').attr('src', element.attr('data-image-not-selected'));
element.attr('data-selected-status', 0);
return true;
return;
}
element.find('img').attr('src', element.attr('data-image-selected'));
element.attr('data-selected-status', 1);
}
function testProtocolOnAllLinks(protocol) {
html.find('div[data-protocol="' + protocol + '"]').each(function() {
function testProtocolOnAllLinks() {
html.find('div[data-protocol^="http"]').each(function() {
var element = $(this);
var url = element.attr('data-test-url');
var id = element.attr('data-id');
......@@ -75,9 +76,45 @@
url : url,
type : "GET",
dataType : "html",
success : function(code_html, statut) {
return element.append(code_html);
success : function(data) {
if ('error' != $(data).attr('class'))
element.attr('data-selectable', true);
element.html(data);
}});
});}
});
}
function selectAllHttpsProtocol() {
html.find('[data-selected-status]').each(function() {
var element = $(this);
element.find('img').attr('src', element.attr('data-image-not-selected'));
element.attr('data-selected-status', 0);
});
html.find('div[data-protocol="https"]').each(function() {
var element = $(this);
var new_status = element.closest('tr').find('[data-selected-status]');
var selectable = element.attr('data-selectable');
if (false != selectable)
return selectUrl($(new_status));
var url = element.attr('data-test-url');
var id = element.attr('data-id');
$.ajax({
url : url,
type : "GET",
dataType : "html",
success : function(data) {
if ('error' != $(data).attr('class')) {
element.attr('data-selectable', true);
selectUrl($(new_status));
}
return element.html(data);
}});
});
}
};
} (jQuery));
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