<commit_before><?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Clicky analytics functionality.
 *
 * @package     MMI Analytics
 * @author      Me Make It
 * @copyright   (c) 2010 Me Make It
 * @license     http://www.memakeit.com/license
 */
class Kohana_MMI_Analytics_Clicky extends Kohana_MMI_Analytics
{
    /**
     * @var string service name
     */
    protected $_service = self::CLICKY;

    /**
     * Get analytics javascript.
     *
     * @return  string
     */
    public function get_js()
    {
        $config = Arr::get(self::_get_config(TRUE), $this->_service, array());
        $id = Arr::get($config, 'id', '');
return <<<EOJS
<script type="text/javascript">
//<![CDATA[
    var jsHost = (('https:' == document.location.protocol) ? 'https://' : 'http://');
    document.write(unescape('%3Cscript src="' + jsHost + 'static.getclicky.com/js" type="text/javascript"%3E%3C/script%3E'));
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
    clicky.init($id);
//]]>
</script>
EOJS;
    }
} // End Kohana_MMI_Analytics_Clicky<commit_msg>added asynchronous javascript<commit_after><?php defined('SYSPATH') OR die('No direct access allowed.');
/**
 * Clicky analytics.
 *
 * @package     MMI Analytics
 * @author      Me Make It
 * @copyright   (c) 2010 Me Make It
 * @license     http://www.memakeit.com/license
 */
class Kohana_MMI_Analytics_Clicky extends Kohana_MMI_Analytics
{
    /**
     * @var string service name
     */
    protected $_service = self::CLICKY;

    /**
     * Get analytics JavaScript.
     *
     * @return  string
     */
    public function get_js()
    {
        $config = Arr::get(self::_get_config(TRUE), $this->_service, array());
        $asynchronous = Arr::get($config, 'asynchronous', TRUE);
        $id = Arr::get($config, 'id', 'UA-XXXXX-X');
        if ($asynchronous)
        {
            return $this->_get_asynchronous_js($id);
        }
        else
        {
            return $this->_get_js($id);
        }
    }

    /**
     * Get synchronous JavaScript.
     *
     * @param   string  tracking id
     * @return  string
     */
    protected function _get_js($id)
    {
return <<<EOJS
<script type="text/javascript">
//<![CDATA[
    var jsHost = (('https:' === document.location.protocol) ? 'https://' : 'http://');
    document.write(unescape('%3Cscript src="' + jsHost + 'static.getclicky.com/js" type="text/javascript"%3E%3C/script%3E'));
    clicky.init($id);
//]]>
</script>
EOJS;
    }

    /**
     * Get asynchronous JavaScript.
     *
     * @param   string  tracking id
     * @return  string
     */
    protected function _get_asynchronous_js($id)
    {
return <<<EOJS
<script type="text/javascript">
//<![CDATA[
    var clicky = { log: function(){ return; }, goal: function(){ return; } };
    var clicky_site_id = $id;
    (function() {
      var s = document.createElement('script');
      s.type = 'text/javascript';
      s.async = true;
      s.src = (document.location.protocol === 'https:' ? 'https://static.getclicky.com' : 'http://static.getclicky.com') + '/js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s);
    })();
//]]>
</script>
EOJS;
    }
} // End Kohana_MMI_Analytics_Clicky
{'fraction_non_alphanumeric': 0.17713760343242416, 'fraction_numerical': 0.0055163959546429666, 'mean_word_length': 2.7777777777777777, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 19, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3002158', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1084, 'n_words': 218}