Plugin Directory

Changeset 870528


Ignore:
Timestamp:
03/06/2014 11:31:45 AM (12 years ago)
Author:
kjbenk
Message:

Option to change price color.

Location:
show-stock-quotes/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • show-stock-quotes/trunk/include/js/kjb_quotes.js

    r869077 r870528  
    88jQuery(document).ready(function($) {
    99   
    10     if (typeof(stock_array) != "undefined" && stock_array !== null) {
    11         for (var i = 0; i < stock_array.length; i++) {
     10    if (typeof(passed_data) != "undefined" && passed_data !== null) {
     11        for (var i = 0; i < passed_data.out.length; i++) {
    1212       
    1313            var url = "http://query.yahooapis.com/v1/public/yql";
    14             var data = encodeURIComponent("select * from yahoo.finance.quotes where symbol in ('" + stock_array[i] + "')");
     14            var data = encodeURIComponent("select * from yahoo.finance.quotes where symbol in ('" + passed_data.out[i] + "')");
    1515       
    1616            $.getJSON(url, 'q=' + data + "&format=json&diagnostics=true&env=http%3A%2F%2Fdatatables.org%2Falltables.env")
     
    2323                   
    2424                        if (data.query.results.quote.Change <= 0) {
    25                             $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none; color:red; text-align:right');
     25                            if (passed_data.quote_display_color == 'change') {
     26                                $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none; color:red; text-align:right');
     27                            }else {
     28                                $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none; text-align:right');
     29                            }
     30                           
    2631                            $(".kjb_show_stock_quotes_change_" + data.query.results.quote.Symbol).attr('style', 'border: none; color:red; text-align:right');
    2732                        }else{
    28                             $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none;color:green; text-align:right');                   
     33                            if (passed_data.quote_display_color == 'change') {
     34                             $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none;color:green; text-align:right');               
     35                            }else {
     36                                $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none; text-align:right');
     37                            }
     38                             
    2939                            $(".kjb_show_stock_quotes_change_" + data.query.results.quote.Symbol).attr('style', 'border: none;color:green; text-align:right');
    3040                        }
     
    3747                       
    3848                        if (data.query.results.quote.LastTradePriceOnly == 0) {
    39                             $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none;color:red; text-align:right');
     49                            if (passed_data.quote_display_color == 'change') {
     50                                $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none;color:red; text-align:right');
     51                            }else {
     52                                $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).attr('style', 'border: none; text-align:right');
     53                            }
     54                           
    4055                            $(".kjb_show_stock_quotes_change_" + data.query.results.quote.Symbol).attr('style', 'border: none;color:red; text-align:right');
    4156                            $(".kjb_show_stock_quotes_quote_" + data.query.results.quote.Symbol).text('Invalid');
  • show-stock-quotes/trunk/readme.txt

    r869077 r870528  
    3131== Changelog ==
    3232
     33= 1.4 =
     34-   Option to change price color from normal (same color as ticker) to same color as change (green or red).
     35
    3336= 1.3.1 =
    3437-   Rounds to the nearest second decimal place.
  • show-stock-quotes/trunk/show_stock_quotes.php

    r869077 r870528  
    44Plugin URI: http://kylebenkapps.com/wordpress-plugins/
    55Description: Show stock quotes updated in real-time.
    6 Version: 1.3.1
     6Version: 1.4
    77Author: Kyle Benk
    88Author URI: http://kylebenkapps.com
     
    8787    /** @see WP_Widget::update */
    8888    function update($new_instance, $old_instance) {             
    89         $instance = $old_instance;
     89        $instance = array();
     90       
     91        $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
     92        $instance['quote_display_color'] = ( ! empty( $new_instance['quote_display_color'] ) ) ? strip_tags( $new_instance['quote_display_color'] ) : '';
    9093       
    9194        foreach ($this->options as $val) {
     
    105108        }
    106109       
     110        if (isset($instance['quote_display_color'])){
     111            $quote_display_color = $instance['quote_display_color'];
     112        }else{
     113            $quote_display_color = 'change';       
     114        }
     115       
    107116       
    108117        ?>
     118       
     119        <!-- Title -->
     120       
    109121        <p>
    110         <label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php _e( 'Title' ); ?></label>
    111         <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
    112         <br /><br />
    113         <label>Stocks Tickers</label>
    114         <ol>
    115        
    116         <?php
    117         for ($i = 1; $i < 21; $i++) {
    118             $stock = isset($instance['stock_'.$i]) ? $instance['stock_'.$i] : '';
     122            <label for="<?php echo $this->get_field_name( 'title' ); ?>"><?php _e( 'Title' ); ?></label>
     123            <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
     124        </p>
     125       
     126        <!-- Quote Display Color -->
     127       
     128        <p>
     129            <label><?php _e( 'Quote Display Color' ); ?></label><br/>
     130           
     131            <input type="radio" id="<?php echo $this->get_field_id( 'quote_display_color' ); ?>" name="<?php echo $this->get_field_name( 'quote_display_color' ); ?>" value="black" <?php echo isset($quote_display_color) && $quote_display_color == 'black' ? "checked" : ""; ?>/><label><?php _e('Same as symbol'); ?></label><br/>
     132            <input type="radio" id="<?php echo $this->get_field_id( 'quote_display_color' ); ?>" name="<?php echo $this->get_field_name( 'quote_display_color' ); ?>" value="change" <?php echo isset($quote_display_color) && $quote_display_color == 'change' ? "checked" : ""; ?>/><label><?php _e('Same as change color'); ?></label>
     133        </p>
     134       
     135        <!-- Stock Tickers -->
     136       
     137        <p>
     138            <label><?php _e( 'Stock Tickers' ); ?></label>
     139            <ol>
     140           
     141            <?php
     142            for ($i = 1; $i < 21; $i++) {
     143                $stock = isset($instance['stock_'.$i]) ? $instance['stock_'.$i] : '';
     144                ?>
     145                <li><input class="widefat" id="<?php echo $this->get_field_id( 'stock_'.$i ); ?>" name="<?php echo $this->get_field_name( 'stock_'.$i); ?>" type="text" value="<?php echo esc_attr( $stock ); ?>" /></li>
     146                <?php
     147            }
    119148            ?>
    120             <li><input class="widefat" id="<?php echo $this->get_field_id( 'stock_'.$i ); ?>" name="<?php echo $this->get_field_name( 'stock_'.$i); ?>" type="text" value="<?php echo esc_attr( $stock ); ?>" /></li>
    121             <?php
    122         }
    123         ?>
    124         </ol>
     149            </ol>
    125150        </p>
    126151        <?php
     
    162187        }
    163188       
    164         wp_localize_script('kjb_quotes_js_src', 'stock_array', $out);
     189        $passed_data = array(
     190            'out'                   => $out,
     191            'quote_display_color'   => $ticker_info['quote_display_color']
     192        );
     193       
     194        wp_localize_script('kjb_quotes_js_src', 'passed_data', $passed_data);
    165195           
    166196           
  • show-stock-quotes/trunk/uninstall.php

    r750206 r870528  
    1 
     1<?php
    22if(!defined('WP_UNINSTALL_PLUGIN') )
    33    die();
     4?>
Note: See TracChangeset for help on using the changeset viewer.