diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2019-10-15 00:00:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-15 00:00:47 +0300 |
commit | e86968b23507261f58a3f0e9f20d61d0e47ae331 (patch) | |
tree | 1e299086f5db9c14b7ba87e5159b1f7877a8cb8e /plugins/SEO | |
parent | 425654523dc835f1530a95b0a90fb5a7459198b1 (diff) |
Revert "no longer include Js in twig file (#14994)" (#15004)
This reverts commit 425654523dc835f1530a95b0a90fb5a7459198b1.
Diffstat (limited to 'plugins/SEO')
-rw-r--r-- | plugins/SEO/SEO.php | 8 | ||||
-rw-r--r-- | plugins/SEO/javascripts/rank.js | 13 | ||||
-rw-r--r-- | plugins/SEO/templates/getRank.twig | 87 |
3 files changed, 55 insertions, 53 deletions
diff --git a/plugins/SEO/SEO.php b/plugins/SEO/SEO.php index e0f7416c47..9fbdb51def 100644 --- a/plugins/SEO/SEO.php +++ b/plugins/SEO/SEO.php @@ -18,16 +18,10 @@ class SEO extends \Piwik\Plugin public function registerEvents() { return [ - 'Widget.filterWidgets' => 'filterWidgets', - 'AssetManager.getJavaScriptFiles' => 'getJsFiles', + 'Widget.filterWidgets' => 'filterWidgets' ]; } - public function getJsFiles(&$jsFiles) - { - $jsFiles[] = "plugins/SEO/javascripts/rank.js"; - } - /** * @param WidgetsList $list */ diff --git a/plugins/SEO/javascripts/rank.js b/plugins/SEO/javascripts/rank.js index fca04d1ab0..ef92aa8c3b 100644 --- a/plugins/SEO/javascripts/rank.js +++ b/plugins/SEO/javascripts/rank.js @@ -4,8 +4,9 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -var SEOWidget = { - getRank: function () { + +$(document).ready(function () { + function getRank() { var ajaxRequest = new ajaxHelper(); ajaxRequest.setLoadingElement('#ajaxLoadingSEO'); ajaxRequest.addParams({ @@ -21,4 +22,10 @@ var SEOWidget = { ajaxRequest.setFormat('html'); ajaxRequest.send(); } -} + + // click on Rank button + $('#rankbutton').on('click', function () { + getRank(); + return false; + }); +}); diff --git a/plugins/SEO/templates/getRank.twig b/plugins/SEO/templates/getRank.twig index d399368696..80aab34cdb 100644 --- a/plugins/SEO/templates/getRank.twig +++ b/plugins/SEO/templates/getRank.twig @@ -1,51 +1,52 @@ <div id='SeoRanks'> + <script type="text/javascript" src="plugins/SEO/javascripts/rank.js"></script> - <div align="left" class="row"> - <div class="col s8 input-field"> - <label for="seoUrl" class="active">{{ 'Installation_SetupWebSiteURL'|translate|capitalize }}</label> - <input type="text" id="seoUrl" size="15" value="{{ urlToRank }}" class="textbox "/> + <form method="post" style="padding: 8px;"> + <div align="left" class="row"> + <div class="col s8 input-field"> + <label for="seoUrl" class="active">{{ 'Installation_SetupWebSiteURL'|translate|capitalize }}</label> + <input type="text" id="seoUrl" size="15" value="{{ urlToRank }}" class="textbox "/> + </div> + <div class="col s4"> + <input type="submit" class="btn btn-small" style='margin-top: 2em' id="rankbutton" value="{{ 'SEO_Rank'|translate }}"/> + </div> </div> - <div class="col s4"> - <input type="button" - onclick="SEOWidget.getRank()" - class="btn btn-small" style='margin-top: 2em' id="rankbutton" value="{{ 'SEO_Rank'|translate }}"/> - </div> - </div> - {% import "ajaxMacros.twig" as ajax %} - {{ ajax.LoadingDiv('ajaxLoadingSEO') }} + {% import "ajaxMacros.twig" as ajax %} + {{ ajax.LoadingDiv('ajaxLoadingSEO') }} - <div id="rankStats" align="left" style="margin-top:10px;margin-left: 5px;font-size:14px;"> - {% if ranks is empty %} - {{ 'General_Error'|translate }} - {% else %} - {% set cleanUrl %} - <a href="http://{{ urlToRank }}" rel="noreferrer noopener" target="_blank">{{ urlToRank }}</a> - {% endset %} - {{ 'SEO_SEORankingsFor'|translate(cleanUrl)|raw }} - <table cellspacing="2" style="margin:auto;line-height:3.5em !important;margin-top:20px;"> + <div id="rankStats" align="left" style="margin-top:10px;margin-left: 5px;font-size:14px;"> + {% if ranks is empty %} + {{ 'General_Error'|translate }} + {% else %} + {% set cleanUrl %} + <a href="http://{{ urlToRank }}" rel="noreferrer noopener" target="_blank">{{ urlToRank }}</a> + {% endset %} + {{ 'SEO_SEORankingsFor'|translate(cleanUrl)|raw }} + <table cellspacing="2" style="margin:auto;line-height:3.5em !important;margin-top:20px;"> - {% for rank in ranks %} - <tr> - {% set seoLink %}{% if rank.logo_link is not empty %}<a class="linkContent" href="{{ rank.logo_link }}" - target="_blank" rel="noreferrer noopener" - {% if rank.logo_tooltip is not empty %}title="{{ rank.logo_tooltip }}"{% endif %}>{% endif %}{% endset %} - <td>{% if rank.logo_link is not empty %}{{ seoLink|raw }}{% endif %}<img width="24px" height="24px" - style='vertical-align:middle;margin-right:6px;' src='{{ rank.logo }}' border='0' - alt="{{ rank.label }}">{% if rank.logo_link is not empty %}</a>{% endif %} {{ rank.label|raw }} - </td> - <td> - <div style="margin-left:15px;"> - {% if rank.logo_link is not empty %}{{ seoLink|raw }}{% endif %} - {% if rank.rank %}{{ rank.rank|raw }}{% else %}-{% endif %} - {{ rank.rank_suffix }} - {% if rank.logo_link is not empty %}</a>{% endif %} - </div> - </td> - </tr> - {% endfor %} + {% for rank in ranks %} + <tr> + {% set seoLink %}{% if rank.logo_link is not empty %}<a class="linkContent" href="{{ rank.logo_link }}" + target="_blank" rel="noreferrer noopener" + {% if rank.logo_tooltip is not empty %}title="{{ rank.logo_tooltip }}"{% endif %}>{% endif %}{% endset %} + <td>{% if rank.logo_link is not empty %}{{ seoLink|raw }}{% endif %}<img width="24px" height="24px" + style='vertical-align:middle;margin-right:6px;' src='{{ rank.logo }}' border='0' + alt="{{ rank.label }}">{% if rank.logo_link is not empty %}</a>{% endif %} {{ rank.label|raw }} + </td> + <td> + <div style="margin-left:15px;"> + {% if rank.logo_link is not empty %}{{ seoLink|raw }}{% endif %} + {% if rank.rank %}{{ rank.rank|raw }}{% else %}-{% endif %} + {{ rank.rank_suffix }} + {% if rank.logo_link is not empty %}</a>{% endif %} + </div> + </td> + </tr> + {% endfor %} - </table> - {% endif %} - </div> + </table> + {% endif %} + </div> + </form> </div> |