Plugin Directory

Changeset 1753861


Ignore:
Timestamp:
10/27/2017 11:54:55 AM (8 years ago)
Author:
coinalyze
Message:

integrated more pairs; table header names customizable; decimal/thousands separator customizable

Location:
live-ticker-cryptocoin/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • live-ticker-cryptocoin/trunk/cryptocoin-live-ticker.php

    r1747902 r1753861  
    2323    public function widget( $args, $instance ) {
    2424        $pairs = explode(',', $instance['pairs']);
     25                $tableHeaders = explode(',', $instance['table_headers']);
     26               
     27                $decimalsSep = $instance['decimals_sep'];
     28                $thousandsSep = $instance['thousands_sep'];
     29               
     30               
    2531        $cacheDataTimeout = $instance['cache_data_timeout'];
    2632        $pairsData = clt_get_pair_data($pairs, $cacheDataTimeout);
     
    2935            <div class="pairs-data">
    3036                <div class="pairs-header">
    31                     <div>Pair</div>
    32                     <div>Rate</div>
    33                     <div>24H %</div>
    34                     <div>7D %</div>
     37                    <div><?php echo $tableHeaders[0] ?></div>
     38                    <div><?php echo $tableHeaders[1] ?></div>
     39                    <div><?php echo $tableHeaders[2] ?></div>
     40                    <div><?php echo $tableHeaders[3] ?></div>
    3541                </div>
    3642                <?php
     
    5763                    <div class="pair-data" id="pair-<?php echo $pair ?>">
    5864                        <div class="pair"><?php echo $pair ?></div>
    59                         <div class="price"><?php echo number_format($pairData['price'], 2) ?></div>
    60                         <div class="pchange-24hours<?php echo $pchange_24hoursClass ?>"><?php echo ($pairData['pchange_24hours'] > 0 ? '+' : '') . number_format($pairData['pchange_24hours'], 2) ?></div>
    61                         <div class="pchange-7days<?php echo $pchange_7daysClass ?>"><?php echo ($pairData['pchange_7days'] > 0 ? '+' : '') . number_format($pairData['pchange_7days'], 2) ?></div>
     65                        <div class="price"><?php echo number_format($pairData['price'], 2, $decimalsSep, $thousandsSep) ?></div>
     66                        <div class="pchange-24hours<?php echo $pchange_24hoursClass ?>"><?php echo ($pairData['pchange_24hours'] > 0 ? '+' : '') . number_format($pairData['pchange_24hours'], 2, $decimalsSep, $thousandsSep) ?></div>
     67                        <div class="pchange-7days<?php echo $pchange_7daysClass ?>"><?php echo ($pairData['pchange_7days'] > 0 ? '+' : '') . number_format($pairData['pchange_7days'], 2, $decimalsSep, $thousandsSep) ?></div>
    6268                    </div>
    6369                <?php
     
    7480    public function form( $instance ) {
    7581        $pairs = !empty( $instance['pairs'] ) ? $instance['pairs'] : 'BTCUSD,LTCUSD,ETHUSD';
     82                $tableHeaders = !empty( $instance['table_headers'] ) ? $instance['table_headers'] : 'Pair,Rate,24H %,7D %';
     83                $decimalsSep = isset( $instance['decimals_sep'] ) ? $instance['decimals_sep'] : '.';
     84                $thousandsSep = isset( $instance['thousands_sep'] ) ? $instance['thousands_sep'] : ',';
     85               
    7686        $cacheDataTimeout = !empty( $instance['cache_data_timeout'] ) ? $instance['cache_data_timeout'] : $GLOBALS['cltConfig']['cacheDataTimeout'];
    7787        $showCoinalyzeLink = !empty($instance['show_coinalyze_link']) ? $instance['show_coinalyze_link'] : 'on';
    7888        ?>
    7989        <p>
    80             <label for="<?php echo $this->get_field_id( 'pairs' ); ?>">Pairs to display, comma separated. Available pairs: <span style="font-size: 0.85em;"><?php echo implode(' ', $GLOBALS['cltConfig']['availablePairs']) ?></span></label>
    81             <input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'pairs' ); ?>" name="<?php echo $this->get_field_name( 'pairs' ); ?>" value="<?php echo esc_attr( $pairs ); ?>" />
     90                    <label for="<?php echo $this->get_field_id( 'pairs' ); ?>">Pairs to display, comma separated. Available pairs: <span style="font-size: 0.85em;"><?php echo implode(' ', $GLOBALS['cltConfig']['availablePairs']) ?></span></label>
     91                    <input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'pairs' ); ?>" name="<?php echo $this->get_field_name( 'pairs' ); ?>" value="<?php echo esc_attr( $pairs ); ?>" />
    8292        </p>
    8393        <p>
    84             <label for="<?php echo $this->get_field_id( 'cache_data_timeout' ); ?>">Cached data timeout in seconds, not lower than <?php echo $GLOBALS['cltConfig']['cacheDataTimeout'] ?></label>
    85             <input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'cache_data_timeout' ); ?>" name="<?php echo $this->get_field_name( 'cache_data_timeout' ); ?>" value="<?php echo esc_attr( $cacheDataTimeout ); ?>" />
     94                    <label for="<?php echo $this->get_field_id( 'table_headers' ); ?>">Table headers, comma separated</label>
     95                    <input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'table_headers' ); ?>" name="<?php echo $this->get_field_name( 'table_headers' ); ?>" value="<?php echo esc_attr( $tableHeaders ); ?>" />
     96        </p>
     97               
     98                <p>
     99                    <div style="display: inline-block; width: 45%;">
     100                        <label for="<?php echo $this->get_field_id( 'decimals_sep' ); ?>">Decimals separator</label>
     101                        <input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'decimals_sep' ); ?>" name="<?php echo $this->get_field_name( 'decimals_sep' ); ?>" value="<?php echo esc_attr( $decimalsSep ); ?>" />
     102                    </div>
     103                    <div style="display: inline-block; width: 45%; float: right;">
     104                        <label for="<?php echo $this->get_field_id( 'thousands_sep' ); ?>">Thousands separator</label>
     105                        <input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'thousands_sep' ); ?>" name="<?php echo $this->get_field_name( 'thousands_sep' ); ?>" value="<?php echo esc_attr( $thousandsSep ); ?>" />
     106                    </div>
     107                </p>
     108               
     109        <p>
     110                    <label for="<?php echo $this->get_field_id( 'cache_data_timeout' ); ?>">Cached data timeout in seconds, not lower than <?php echo $GLOBALS['cltConfig']['cacheDataTimeout'] ?></label>
     111                    <input style="width:100%;" type="text" id="<?php echo $this->get_field_id( 'cache_data_timeout' ); ?>" name="<?php echo $this->get_field_name( 'cache_data_timeout' ); ?>" value="<?php echo esc_attr( $cacheDataTimeout ); ?>" />
    86112        </p>
    87113        <p>
     
    95121        $instance = $old_instance;
    96122        $instance['pairs'] = str_replace(' ', '', $new_instance['pairs']);
     123                $instance['table_headers'] = $new_instance['table_headers'];
     124                $instance['decimals_sep'] = $new_instance['decimals_sep'];
     125                $instance['thousands_sep'] = $new_instance['thousands_sep'];
     126               
    97127        $instance['show_coinalyze_link'] = empty($new_instance['show_coinalyze_link']) ? 'off' : 'on';
    98128        $cacheDataTimeout = (int)$new_instance['cache_data_timeout'];
  • live-ticker-cryptocoin/trunk/include/common.php

    r1744439 r1753861  
    11<?php
    22$GLOBALS['cltConfig'] = array(
    3     'availablePairs' => array('BTCUSD', 'BTCEUR', 'LTCUSD', 'LTCEUR', 'LTCBTC', 'ETHUSD', 'ETHEUR', 'ETHBTC', 'XMRUSD', 'XRPUSD', 'XRPEUR', 'IOTUSD', 'DSHUSD', 'NEOUSD'),
     3    'availablePairs' => array('BTCUSD', 'BTCEUR', 'LTCUSD', 'LTCEUR', 'LTCBTC', 'ETHUSD', 'ETHEUR', 'ETHBTC', 'XMRUSD', 'XRPUSD', 'XRPEUR', 'IOTUSD', 'DSHUSD', 'NEOUSD', 'BTCJPY', 'ETHJPY', 'BTCGBP', 'BTCCAD', 'ETHCAD', 'BTCAUD', 'ETHAUD', 'LTCAUD', 'BTCCNY', 'LTCCNY'),
    44    'cacheDataTimeout' => 30,
    55    'dataApiUrl' => 'https://coinalyze.net/service-widgets/pairsdata/'
  • live-ticker-cryptocoin/trunk/readme.txt

    r1744439 r1753861  
    99== Description ==
    1010
    11 Display cryptocoins current price, 24 hours price change and 7 days price change on your website. You can select which coins/pairs to display. Supported pairs: BTCUSD BTCEUR LTCUSD LTCEUR LTCBTC ETHUSD ETHEUR ETHBTC XMRUSD XRPUSD XRPEUR IOTUSD DSHUSD NEOUSD
     11Display cryptocoins current price, 24 hours price change and 7 days price change on your website. You can select which coins/pairs to display. Supported pairs: BTCUSD BTCEUR LTCUSD LTCEUR LTCBTC ETHUSD ETHEUR ETHBTC XMRUSD XRPUSD XRPEUR IOTUSD DSHUSD NEOUSD BTCJPY ETHJPY BTCGBP BTCCAD ETHCAD BTCAUD ETHAUD LTCAUD BTCCNY LTCCNY
    1212
    1313The widget is highly customizable
Note: See TracChangeset for help on using the changeset viewer.