Commit acf1516c authored by Canek Peláez's avatar Canek Peláez
Browse files

Small refactoring; handle small screens better.

parent ba4cefd1
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: word-count 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-18 22:09-0500\n"
"PO-Revision-Date: 2021-10-18 22:10-0500\n"
"PO-Revision-Date: 2021-10-18 23:48-0500\n"
"Last-Translator: Canek Peláez <canek@ciencias.unam.mx>\n"
"Language-Team: Spanish\n"
"Language: Spanish\n"
@@ -116,7 +116,7 @@ msgstr ""
#: tab-barcharts.php:18 tab-piecharts.php:18 tab-stats.php:20 tab-tables.php:18
#: tab-stats.php:25
msgid "Bar charts"
msgstr "G. de barras"
msgstr "Gráficas de barras"

#: tab-barcharts.php:35 tab-piecharts.php:35 tab-stats.php:40 tab-tables.php:35
#: tab-stats.php:45
@@ -142,7 +142,7 @@ msgstr "Estadísticas de páginas"
#: tab-barcharts.php:21 tab-piecharts.php:21 tab-stats.php:23 tab-tables.php:21
#: tab-stats.php:28
msgid "Pie charts"
msgstr "G. de pastel"
msgstr "Gráficas de pastel"

#: tab-stats.php:29 tab-stats.php:34
msgid "Posts statistics"
+43 −7
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
define('WC_ROWS_PER_PAGE', 20);
global $wpdb;

$taburl = get_site_url() . '/wp-admin/plugins.php?page=word-count&wc-tab=';

function get_wc_tab() {
    $wc_tab = !empty($_GET["wc-tab"]) ? $_GET["wc-tab"] : 'tab-stats';
    if ($wc_tab != 'tab-stats'     && $wc_tab != 'tab-tables'    &&
@@ -31,8 +33,43 @@ function echoPage($type, $page, $current, $sep = ' | ', $filter = '') {
    echo $sep;
}

if (!empty($_POST['Recount'])) {
    check_admin_referer('word-count-page_options');
function tab_headers($taburl = '', $selected = 'stats') {
    $tab_stats = __('Statistics', 'word-count');
    $tab_tables = __('Tables', 'word-count');
    $tab_barcharts = __('Bar charts', 'word-count');
    $tab_piecharts = __('Pie charts', 'word-count');
    $sel_st = $sel_ta = $sel_bc = $sel_pc = '';
    switch ($selected) {
    case 'stats':     $sel_st = 'selected'; break;
    case 'tables':    $sel_ta = 'selected'; break;
    case 'barcharts': $sel_bc = 'selected'; break;
    case 'piecharts': $sel_pc = 'selected'; break;
    }
    echo "<div class=\"wc-tabs-headers\">";
    echo "  <span class =\"wc-tab-header $sel_st\">";
    echo "    <a href=\"${taburl}tab-stats\">$tab_stats</a>";
    echo "  </span>";
    echo "  <span class=\"wc-tab-header $sel_ta\">";
    echo "    <a href=\"${taburl}tab-tables\">$tab_tables</a>";
    echo "  </span>";
    echo "  <span class=\"wc-tab-header $sel_bc\">";
    echo "    <a href=\"${taburl}tab-barcharts\">$tab_barcharts</a>";
    echo "  </span>";
    echo "  <span class=\"wc-tab-header $sel_pc\">";
    echo "    <a href=\"${taburl}tab-piecharts\">$tab_piecharts</a>";
    echo "  </span>";
    echo "</div>";
}

function count_again_button() {
    $value = __('Count again', 'word-count');
    echo "<p class=\"submit\">";
    echo "<input type=\"submit\" name=\"Recount\" " .
        "class=\"button\" value=\"$value\" />";
    echo "</p>";
}

if (!empty($_GET['Recount'])) {
    $wc_options = get_option('word_count_options');
    $wc_options['words_counted'] = false;
    $wc_options['counting_words'] = false;
@@ -78,8 +115,8 @@ class WordCounter {
    }

    doUpdate() {
        document.getElementById('wc_progress').value = this.progressValue;
        document.getElementById('wc_progress').childNodes[0].nodeValue =
        document.getElementById('wc-progress').value = this.progressValue;
        document.getElementById('wc-progress').childNodes[0].nodeValue =
            this.progressValue + '%';
    }

@@ -106,10 +143,9 @@ let wc = new WordCounter("<?php echo get_site_url(); ?>",
                         <?php echo $total; ?>);
wc.launchInterval();
</script>
<div style="margin-left: 100px; margin-top: 100px;">
<div class="progress-container">
  <h2><?php _e("Word counting in progress:", 'word-count'); ?></h2>
  <progress style="width: 600px; height: 4em; vertical-align: top;" id="wc_progress"
            value="0" max="100">0%</progress>
  <progress id="wc-progress" value="0" max="100">0%</progress>
</div>
<?php
} else {
+14 −0
Original line number Diff line number Diff line
div.progress-container {
    margin-left: 50px;
    margin-top: 50px;
}

progress#wc-progress {
    min-width: 300px;
    max-width: 1200px;
    height: 4em;
    vertical-align: top;
}

table.wc-table {
    max-width: 800px;
    background-color: #fff;
@@ -53,6 +65,8 @@ th.left {
    display: inline-block;
    width: 22%;
    max-width: 150px;
    text-align: center;
    vertical-align: middle;
    height: 50px;
    background-color: #777;
    color: #eee;
+1 −7
Original line number Diff line number Diff line
<?php
$taburl = get_site_url() . '/wp-admin/plugins.php?page=word-count&wc-tab='
?>
<form method="get" action="<?php echo admin_url('admin.php'); ?>">
  <input type="hidden" name="page" value="word-count" />
  <input type="hidden" name="wc-tab" value="<?php echo get_wc_tab(); ?>" />
@@ -29,11 +26,8 @@ include WORD_COUNT__PLUGIN_DIR . '/top-20-barcharts.php';
$post_type = 'page';
$sec_title = __('Top 20 pages', 'word-count');;
include WORD_COUNT__PLUGIN_DIR . '/top-20-barcharts.php';
count_again_button();
?>
        <p class="submit">
          <input type="submit" name="Recount" class="button"
                 value=<?php _e('Count again', 'word-count'); ?> />
        </p>
      </div>
    </div>
  </div>
+1 −7
Original line number Diff line number Diff line
<?php
$taburl = get_site_url() . '/wp-admin/plugins.php?page=word-count&wc-tab='
?>
<form method="get" action="<?php echo admin_url('admin.php'); ?>">
  <input type="hidden" name="page" value="word-count" />
  <input type="hidden" name="wc-tab" value="<?php echo get_wc_tab(); ?>" />
@@ -29,11 +26,8 @@ include WORD_COUNT__PLUGIN_DIR . '/top-20-piecharts.php';
$post_type = 'page';
$sec_title = __('Top 20 pages', 'word-count');;
include WORD_COUNT__PLUGIN_DIR . '/top-20-piecharts.php';
count_again_button();
?>
        <p class="submit">
          <input type="submit" name="Recount" class="button"
                 value=<?php _e('Count again', 'word-count'); ?> />
        </p>
      </div>
    </div>
  </div>
Loading