Skip to content
Snippets Groups Projects
Commit d4d9102e authored by Tim van Dijen's avatar Tim van Dijen
Browse files

consentAdmin: move inline JS/CSS to assets

parent db9e0ed8
No related branches found
No related tags found
No related merge requests found
<?php <?php
$this->data['head'] = '<link rel="stylesheet" type="text/css" href="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/css/consentAdmin.css").'" />'."\n"; $this->data['head'] = '<link rel="stylesheet" type="text/css" href="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/css/consentAdmin.css").'" />'."\n";
$this->data['head'] .= '<script type="text/javascript" src="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/js/consentAdmin.js").'"></script>'; $this->data['head'] .= '<script type="text/javascript" src="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/js/consentAdmin.js").'"></script>';
$this->data['head'] .= '<script type="text/javascript" src="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/js/consentSimpleAjax.js").'"></script>';
// default theme // default theme
$this->includeAtTemplateBase('includes/header.php'); $this->includeAtTemplateBase('includes/header.php');
?> ?>
...@@ -13,7 +12,7 @@ ...@@ -13,7 +12,7 @@
<table> <table>
<tr> <tr>
<th width="80%"><?php echo $this->t('{consentAdmin:consentadmin:service_provider_header}') ?></th> <th width="80%"><?php echo $this->t('{consentAdmin:consentadmin:service_provider_header}') ?></th>
<th width="140"><?php echo $this->t('{consentAdmin:consentadmin:status_header}') ?></th> <th><?php echo $this->t('{consentAdmin:consentadmin:status_header}') ?></th>
</tr> </tr>
<?php <?php
$spList = $this->data['spList']; $spList = $this->data['spList'];
...@@ -23,7 +22,7 @@ ...@@ -23,7 +22,7 @@
$attributes_text = $this->t('{consentAdmin:consentadmin:attributes_text}'); $attributes_text = $this->t('{consentAdmin:consentadmin:attributes_text}');
foreach ($spList as $spName => $spValues) { foreach ($spList as $spName => $spValues) {
if (!is_null($spValues['serviceurl'])) { if (!is_null($spValues['serviceurl'])) {
$htmlSpName = '<a href="'.$spValues['serviceurl'].'" style="color: black; font-weight: bold;">'.htmlspecialchars($spValues['name']).'</a>'; $htmlSpName = '<a class="serviceUrl" href="'.$spValues['serviceurl'].'">'.htmlspecialchars($spValues['name']).'</a>';
} else { } else {
$htmlSpName = htmlspecialchars($spValues['name']); $htmlSpName = htmlspecialchars($spValues['name']);
} }
...@@ -36,8 +35,8 @@ ...@@ -36,8 +35,8 @@
<tr class="$row_class"> <tr class="$row_class">
<td> <td>
<table> <table>
<tr class="$row_class"><td><span class='caSPName'><span title='$spDescription'>$htmlSpName</span>&emsp;<span style="font-size: 80%;"onclick="javascript:toggleShowAttributes('$show_spid');"><span id='showing_$show_spid'>$show_text</span><span id='hiding_$show_spid' style='display:none;'>$hide_text</span>$attributes_text</span></span></td></tr> <tr class="$row_class"><td><span class='caSPName'><span title='$spDescription'>$htmlSpName</span>&emsp;<span class="show_hide" id="show_hide_$show_spid"><span id='showing_$show_spid'>$show_text</span><span id='hiding_$show_spid'>$hide_text</span> $attributes_text</span></span></td></tr>
<tr><td colspan="2" class="caAttributes"><div id="attributes_$show_spid" style="display: none;"> <tr><td colspan="2" class="caAttributes"><div id="attributes_$show_spid">
TRSTART; TRSTART;
$attributes = $spValues['attributes_by_sp']; $attributes = $spValues['attributes_by_sp'];
if ($this->data['showDescription']) { if ($this->data['showDescription']) {
...@@ -62,7 +61,7 @@ TRSTART; ...@@ -62,7 +61,7 @@ TRSTART;
</table> </table>
</td> </td>
<td class='caAllowed'><input onclick="javascript:checkConsent(this.value, $show_spid, this.checked)" value='$consentValue' type='checkbox' $checkedAttr /><span id="consentText$show_spid">$consentText</span></td> <td class='caAllowed'><input id="checkbox_$show_spid" class="checkbox" value='$consentValue' type='checkbox' $checkedAttr /><span id="consentText_$show_spid">$consentText</span></td>
TRSTART; TRSTART;
echo "</tr>\n"; echo "</tr>\n";
$show_spid++; $show_spid++;
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
{% block postload %} {% block postload %}
<script src="{{ baseurlpath }}assets/js/consentAdmin.js"></script> <script src="{{ baseurlpath }}assets/js/consentAdmin.js"></script>
<script src="{{ baseurlpath }}assets/js/consentSimpleAjax.js"></script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
...@@ -36,18 +35,18 @@ ...@@ -36,18 +35,18 @@
{% if spValues.serviceurl is defined %} {% if spValues.serviceurl is defined %}
{{ spValues.name|escape('html') }} {{ spValues.name|escape('html') }}
{% else %} {% else %}
<a href="{{ spValues.serviceurl }}" style="color: black; font-weight: bold">{{ spValues.name|escape('html') }}</a> <a class="serviceUrl" href="{{ spValues.serviceurl }}">{{ spValues.name|escape('html') }}</a>
{% endif %} {% endif %}
</span> </span>
<span style="font-size: 80%" onclick="javascript:toggleShowAttributes({{ loop.index0 }});"> <span class="show_hide" id="show_hide_{{ loop.index0 }}">
<span id="showing_{{ loop.index0 }}">{{ '{consentAdmin:consentadmin:show}'|trans }}</span> <span id="showing_{{ loop.index0 }}">{{ '{consentAdmin:consentadmin:show}'|trans }}</span>
<span id="hiding_{{ loop.index0 }}" style="display: none">{{ '{consentAdmin:consentadmin:hide}'|trans }}</span> <span id="hiding_{{ loop.index0 }}">{{ '{consentAdmin:consentadmin:hide}'|trans }}</span>
{{ '{consentAdmin:consentadmin:attributes_text}'|trans }} {{ '{consentAdmin:consentadmin:attributes_text}'|trans }}
</span> </span>
</span> </span>
</td> </td>
<td class="caAttributes"> <td class="caAttributes">
<div id="attributes_{{ loop.index0 }}" style="display: none"> <div id="attributes_{{ loop.index0 }}">
{% if showDescription %} {% if showDescription %}
<p>{{ '{consentAdmin:consentadmin:consentadmin_purpose}'|trans }}{{ spValues.description|escape('html') }}</p> <p>{{ '{consentAdmin:consentadmin:consentadmin_purpose}'|trans }}{{ spValues.description|escape('html') }}</p>
{% endif %} {% endif %}
...@@ -69,7 +68,7 @@ ...@@ -69,7 +68,7 @@
</div> </div>
</td> </td>
<td class="caAllowed"> <td class="caAllowed">
<input onclick="javascript:checkConsent(this.value, {{ loop.index0 }}, this.checked)" value='{{ spValues.consentValue }}' type='checkbox'{% if spValues.consentStatus == 'ok'%} checked="checked"{% endif %} /><span id="consentText{{ loop.index0 }}">{% if spValues.consentStatus == 'changed' %}attributes has changed{% endif %}</span> <input class="checkbox" id="checkbox_{{ loop.index0 }}" value='{{ spValues.consentValue }}' type='checkbox'{% if spValues.consentStatus == 'ok'%} checked="checked"{% endif %} /><span id="consentText_{{ loop.index0 }}">{% if spValues.consentStatus == 'changed' %}attributes has changed{% endif %}</span>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
......
...@@ -20,3 +20,20 @@ tr.row1 td { ...@@ -20,3 +20,20 @@ tr.row1 td {
a.orange { a.orange {
color: #ffd633; color: #ffd633;
} }
span.show_hide {
font-size: 80%;
}
a.serviceUrl {
color: black;
font-weight: bold;
}
span[id^='hiding_'], span[id*='hiding_'] {
display: none;
}
div[id^='attributes_'], div[id*='attributes_'] {
display: none;
}
function setConsentText(consentStatus, show_spid) { var xmlHttp;
document.getElementById("consentText" + show_spid).innerHTML = consentStatus;
function checkConsent()
{
var show_spid = this.id.charAt(this.id.length-1);
var checkbox = document.getElementById("checkbox_"+show_spid);
xmlHttp = GetXmlHttpObject()
if (xmlHttp == null) {
alert("Browser does not support HTTP Request")
return
}
var url = "consentAdmin.php"
url = url+"?cv="+checkbox.value
url = url+"&action="+checkbox.checked
url = url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function() {
if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
document.getElementById("consentText_" + show_spid).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", url, true)
xmlHttp.send(null)
} }
// This function creates an XMLHttpRequest
function GetXmlHttpObject()
{
var xmlHttp = null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) {
//Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function toggleShowAttributes()
{
var show_spid = this.id.charAt(this.id.length-1);
var disp = document.getElementById('attributes_' + show_spid);
var showing = document.getElementById('showing_' + show_spid);
var hiding = document.getElementById('hiding_' + show_spid);
disp.style.display = (disp.style.display == 'none' ? 'block' : 'none');
showing.style.display = (disp.style.display == 'none' ? 'inline' : 'none');
hiding.style.display = (disp.style.display == 'none' ? 'none' : 'inline');
}
document.addEventListener(
'DOMContentLoaded',
function () {
var show_hide = document.getElementsByClassName("show_hide");
for (var i = 0; i < show_hide.length; i++) {
show_hide[i].addEventListener(
'click',
toggleShowAttributes
);
}
var checkbox = document.getElementsByClassName("checkbox");
for (var i = 0; i < checkbox.length; i++) {
checkbox[i].addEventListener(
'click',
checkConsent
);
}
}
);
var xmlHttp;
function checkConsent(consentValue, show_spid, checkAction)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) {
alert ("Browser does not support HTTP Request")
return
}
var url="consentAdmin.php"
url=url+"?cv="+consentValue
url=url+"&action="+checkAction
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=function() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
setConsentText(xmlHttp.responseText, show_spid);
}
}
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
// This function will be automaticly called when the Ajax call is done returning data
function stateChanged() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
//Alert("Status of consent:" + xmlHttp.responseText );
}
}
// This function creates an XMLHttpRequest
function GetXmlHttpObject() {
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function toggleShowAttributes(show_spid) {
var disp = document.getElementById('attributes_' + show_spid);
//var showhide = document.getElementById('showhide_' + show_spid);
var showing = document.getElementById('showing_' + show_spid);
var hiding = document.getElementById('hiding_' + show_spid);
disp.style.display = (disp.style.display == 'none' ? 'block' : 'none');
//showhide.innerHTML = (disp.style.display == 'none' ? 'Show' : 'Hide')
showing.style.display = (disp.style.display == 'none' ? 'inline' : 'none');
hiding.style.display = (disp.style.display == 'none' ? 'none' : 'inline');
//alert('hiding display'+hiding.display);
}
...@@ -150,7 +150,7 @@ if (!empty($_GET['action'])) { ...@@ -150,7 +150,7 @@ if (!empty($_GET['action'])) {
// Remove services, whitch have consent disabled // Remove services, whitch have consent disabled
if (isset($idp_metadata['consent.disable'])) { if (isset($idp_metadata['consent.disable'])) {
foreach ($idp_metadata['consent.disable'] AS $disable) { foreach ($idp_metadata['consent.disable'] as $disable) {
if (array_key_exists($disable, $all_sp_metadata)) { if (array_key_exists($disable, $all_sp_metadata)) {
unset($all_sp_metadata[$disable]); unset($all_sp_metadata[$disable]);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment