From b3ee105e720a3d243c1a7c8247b4687816542e03 Mon Sep 17 00:00:00 2001
From: Tim van Dijen <tvdijen@gmail.com>
Date: Sat, 25 Aug 2018 16:18:19 +0200
Subject: [PATCH] reduce complexity

---
 modules/discopower/templates/disco.twig      | 34 +++++++-------------
 modules/oauth/templates/registry.list.twig   |  4 +--
 modules/statistics/templates/statistics.twig |  4 +--
 3 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/modules/discopower/templates/disco.twig b/modules/discopower/templates/disco.twig
index e9c892d3f..8e7082304 100644
--- a/modules/discopower/templates/disco.twig
+++ b/modules/discopower/templates/disco.twig
@@ -2,11 +2,11 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}assets/css/style.css" rel="stylesheet" type="text/css" media="screen">
+    <link href="{{ baseurlpath }}style.css" rel="stylesheet" type="text/css" media="screen" />
 {% endblock %}
 {% block postload %}
-    <script type="text/javascript" src="{{ baseurlpath }}assets/js/jquery.livesearch.js"></script>
-    <script type="text/javascript" src="{{ baseurlpath }}assets/js/{{ score }}.js"></script>
+    <script type="text/javascript" src="{{ baseurlpath }}js/jquery.livesearch.js"></script>
+    <script type="text/javascript" src="{{ baseurlpath }}js/{{ score }}.js"></script>
     {{ search|raw }}
 {% endblock %}
 
@@ -15,43 +15,31 @@
     <div class="favourite">{{ '{disco:previous_auth}'|trans }}
         <strong>{{ faventry.translated|escape('html') }}</strong>
         <form id="idpselectform" method="get" action="{{ urlpattern }}">
-            <input type="hidden" name="entityID" value="{{ entityID|escape('html') }}">
-            <input type="hidden" name="return" value="{{ return|escape('html') }}">
-            <input type="hidden" name="returnIDParam" value="{{ returnIDParam|escape('html') }}">
-            <input type="hidden" name="idpentityid" value="{{ faventry.entityid|escape('html') }}">
-            <input type="submit" name="formsubmit" id="favouritesubmit" value="{{ '{disco:login_at}'|trans }} {{ faventry.translated|escape('html') }}" autofocus> 
+            <input type="hidden" name="entityID" value="{{ entityID|escape('html') }}" />
+            <input type="hidden" name="return" value="{{ return|escape('html') }}" />
+            <input type="hidden" name="returnIDParam" value="{{ returnIDParam|escape('html') }}" />
+            <input type="hidden" name="idpentityid" value="{{ faventry.entityid|escape('html') }}" />
+            <input type="submit" name="formsubmit" id="favouritesubmit" value="{{ '{disco:login_at}'|trans }} {{ faventry.translated|escape('html') }}" /> 
 	</form>
     </div>
     {% endif %}
 
     <div id="tabdiv">
         <ul class="tabset_tabs">
-        {% set i = 1 %}
         {% for tab, idps in idplist %}
             {% if idps is not empty %}
-            {% if i == 1 %}
-            <li class="tab-link current" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li>
-            {% set i = 2 %}
-            {% else %}
-            <li class="tab-link" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li>
-            {% endif %}
+            <li class="tab-link{% if loop.first %}current{% endif %}" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li>
             {% endif %}
         {% endfor %}
         </ul>
 
-        {% set i = 1 %}
         {% for tab, idps in idplist %}
         {% if idps is not empty %}
-          {% if i == 1 %}
-          <div id="{{ tab }}" class="tabset_content current">
-          {% set i = 2 %}
-          {% else %}
-          <div id="{{ tab }}" class="tabset_content">
-          {% endif %}
+          <div id="{{ tab }}" class="tabset_content{% if loop.first %} current{% endif %}">
           <div class="inlinesearch">
               <p>Incremental search...</p>
               <form id="idpselectform" method="get">
-                  <input class="inlinesearch" type="text" value="" name="query_{{ tab }}" id="query_{{ tab }}">
+                  <input class="inlinesearch" type="text" value="" name="query_{{ tab }}" id="query_{{ tab }}" />
               </form>
           </div>
           <div class="metalist" id="list_{{ tab }}">
diff --git a/modules/oauth/templates/registry.list.twig b/modules/oauth/templates/registry.list.twig
index c479cc202..86bc5a679 100644
--- a/modules/oauth/templates/registry.list.twig
+++ b/modules/oauth/templates/registry.list.twig
@@ -12,7 +12,7 @@
 
     <table class="metalist" style="width: 100%;">
     {% for key, entryc in entries.mine %}
-        {% if loop.index0  % 2 == 0 %}
+        {% if loop.index0 is even %}
             {% set class = 'even' %}
         {% else %}
             {% set class = 'odd' %}
@@ -36,7 +36,7 @@
 
     <table class="metalist" style="width: 100%">
     {% for key, entryc in entries.others %}
-        {% if loop.index0  % 2 == 0 %}
+        {% if loop.index0 is even %}
             {% set class = 'even' %}
         {% else %}
             {% set class = 'odd' %}
diff --git a/modules/statistics/templates/statistics.twig b/modules/statistics/templates/statistics.twig
index 822e587e7..796e45310 100644
--- a/modules/statistics/templates/statistics.twig
+++ b/modules/statistics/templates/statistics.twig
@@ -154,7 +154,7 @@
                     <th class="category">Data range</th>
                 </tr>
                 {% for key, value in summaryDataset %}
-                {% if loop.index0  % 2 == 0 %}
+                {% if loop.index0 is even %}
                     {% set class = 'even' %}
                 {% else %}
                     {% set class = 'odd' %}
@@ -195,7 +195,7 @@
                 </tr>
                 {% for slot, dd in debugdata %}
 
-                {% if loop.index0 % 2 == 0 %}
+                {% if loop.index0 is even %}
                     {% set class = 'even' %}
                 {% else %}
                     {% set class = 'odd' %}
-- 
GitLab