Plugin Directory

Changeset 2658640


Ignore:
Timestamp:
01/17/2022 09:40:30 AM (4 years ago)
Author:
BaneD
Message:

v2.12

Location:
ziggeo
Files:
86 added
25 edited

Legend:

Unmodified
Added
Removed
  • ziggeo/trunk/CHANGELOG.md

    r2466038 r2658640  
    11This file contains the change log info for the `Ziggeo` (Ziggeo Core) plugin.
     2
     3= 2.11.2 =
     4* Changed: The Templates Editor is now moved to its own page. There have been no other changes except its move, making it easy to get to it, and separating it from the actual settings.
     5
     6= 2.11 =
     7* Improved: Ziggeo events can still be used as alert using [ziggeo_event event=verified message="my message" type=alert] however now you can add your custom code to be injected into the page and called once some event fires. All through Events Editor which includes the shortcode generator to add into your pages.
     8
     9= 2.10 =
     10* Fix: The analytics date was not correctly shown. This has been corrected now
     11* New Feature: Ziggeo events can now be used in WP. Just add [ziggeo_event event=verified message="my message" type=alert] and as soon as the verified event fires, your message will be shown. See all events you can use on the following page: https://ziggeo.com/docs/sdks/javascript/browser-interaction/events. (to be extended for more types)
     12* Added support for `rerecordableifexists` and `playermodeifexists`
     13
     14= 2.9 =
     15* Fix: In some scenarios the comments would get broken video player code. Now this has been fixed.
     16* Improvement: Added SDK pages to the plugin (requires you to download the SDK manually - for security reasons)
     17
     18= 2.8 =
     19* Fix: Toolbar buttons showing up again
     20* Fix: Some CSS errors were failing silently, these are now fixed.
     21* Improvement: Handling of parameters that accept custom text is now better
     22* Improvement: Changed the way the code parsing is done allowing the templates to be picked up on faster
     23* Improvement: Parsing templates by template ID has been improved
    224
    325= 2.7 =
  • ziggeo/trunk/addons.json

    r2344999 r2658640  
    1010            "wordpress": "https://wordpress.org/plugins/videowalls-for-ziggeo/",
    1111            "github": "https://github.com/Ziggeo/ziggeo-wp-videowalls-for-ziggeo"
     12        }
     13    },
     14    "ziggeo-media-for-acf": {
     15        "url": {
     16            "wordpress": "",
     17            "github": "https://github.com/Ziggeo/ziggeo-wp-media-for-advanced-custom-fields"
    1218        }
    1319    },
  • ziggeo/trunk/admin/menu.php

    r2331349 r2658640  
    1818    //Settings sub menu
    1919    ziggeo_p_add_menu_entry(array(
    20         'page_title'    => 'Ziggeo Video Settings',             //page title
    21         'menu_title'    => 'Settings',                          //menu title
    22         'capability'    => 'manage_options',                    //min capability to view
    23         'slug'          => 'ziggeo_video',                      //menu slug
    24         'callback'      => 'ziggeo_a_s_page')                   //function
     20        'page_title'    => 'Ziggeo Video Settings',             //page title
     21        'menu_title'    => 'Settings',                          //menu title
     22        'capability'    => 'manage_options',                    //min capability to view
     23        'slug'          => 'ziggeo_video',                      //menu slug
     24        'callback'      => 'ziggeo_a_s_page')                   //function
     25    );
     26
     27    //Templates Editor
     28    ziggeo_p_add_menu_entry(array(
     29        'page_title'    => 'Ziggeo Templates Editor',           //page title
     30        'menu_title'    => 'Templates Editor',                  //menu title
     31        'capability'    => 'manage_options',                    //min capability to view
     32        'slug'          => 'ziggeo_editor_templates',           //menu slug
     33        'callback'      => 'ziggeo_a_et_page')                  //function
     34    );
     35
     36    //Events Editor
     37    ziggeo_p_add_menu_entry(array(
     38        'page_title'    => 'Ziggeo Events editor',              //page title
     39        'menu_title'    => 'Events Editor',                     //menu title
     40        'capability'    => 'manage_options',                    //min capability to view
     41        'slug'          => 'ziggeo_editor_events',              //menu slug
     42        'callback'      => 'ziggeo_a_ee_page')                  //function
    2543    );
    2644
  • ziggeo/trunk/admin/page_sdk.php

    r2331349 r2658640  
    44defined('ABSPATH') or die();
    55
     6$msg = '';
     7
     8//Include the SDK if it is not included already;
     9if(ziggeo_p_include_sdk()) {
     10    ziggeo_p_sdk_init();
     11}
     12else {
     13    //The SDK was not possible to include for some reason. We should add a message about this.
     14    $msg = _e('The PHP SDK was not found or was not possible to include it. Please make sure that you have added it to your system and that file permissions are set properly.', 'ziggeo');
     15}
     16
    617?>
    718<div>
    8     <h2>PHP SDK Functionality</h2>
     19    <h2>PHP SDK Functionality <span id="ziggeo_title_app">(Default Application)</span></h2>
    920
    1021    <form action="options.php" method="post">
     
    1223        wp_nonce_field('ziggeo_nonce_action', 'ziggeo_sdk_nonce');
    1324        settings_errors();
     25
     26        if($msg !== '') {
     27            ?>
     28            <b><?php echo $msg; ?></b>
     29            <?php
     30        }
     31
    1432        ziggeo_a_sdk_text();
    1533        ?>
     
    2846    // Benefits would include grabbing and doing stuff from the background, such as getting the list of videos into your WP website (tokens), creating auth tokens on fly, capturing webhook calls, etc.
    2947
     48    //Here we could include the PHP SDK and have the index call made internally. This would be the safest way to do it
     49    //For now we go with JS implementation
     50
     51    $ziggeo_sdk = ziggeo_p_sdk_get_object(true);
     52    $plugin_options = ziggeo_get_plugin_options();
     53
     54    ?>
     55    <div id="ziggeo-sdk-pages">
     56        <div class="ziggeo_tabs">
     57            <div class="ziggeo_tab selected" data-tab="welcome">Welcome</div>
     58            <div class="ziggeo_tab" data-tab="applications">Applications</div>
     59            <div class="ziggeo_tab" data-tab="analytics">Analytics</div>
     60            <div class="ziggeo_tab" data-tab="authtokens">Auth Tokens</div>
     61            <div class="ziggeo_tab" data-tab="effectprofiles">Effect Profiles</div>
     62            <div class="ziggeo_tab" data-tab="metaprofiles">Meta Profiles</div>
     63            <div class="ziggeo_tab" data-tab="webhooks">Webhooks</div>
     64        </div>
     65        <?php
     66            /*
     67                Effect Profiles (create, apply)
     68                Auth tokens (create, update, get, delete) * server side + client side
     69            */
     70        ?>
     71        <div class="ziggeo-frame" style="" id="ziggeo_tab_welcome">
     72            <p>
     73                <?php
     74                    _e('Welcome to the pages utilizing Ziggeo PHP SDK in the background.', 'ziggeo');
     75                ?>
     76            </p>
     77            <p>
     78                <?php
     79                    _e('By default we are showing you the data for the application you have added into your Wordpress settings. If you want to add more than one application that will be possible through available options.', 'ziggeo');
     80                ?>
     81            </p>
     82        </div>
     83        <div class="ziggeo-frame" style="display:none;" id="ziggeo_tab_applications">
     84            <p>
     85                <?php
     86                    _e('This section will help you see details about your application(s).', 'ziggeo');
     87                ?>
     88            </p>
     89            <?php
     90                $tokens = ziggeo_p_get_keys();
     91
     92                //note: This code is connected to ziggeo_a_sdk_page_application_new_keys() so if any change happens to <li> bellow it should be reflected there as well.
     93            ?>
     94            <select id="applications_list"
     95                class="ziggeo-sdk-ajax-dropdown"
     96                data-action="applications_get_detail"
     97                data-operation="sdk_applications"
     98                data-results="applications_detail"
     99                data-value="token:applications_list">
     100                <?php
     101                    for($i = 0, $c = count($tokens); $i < $c; $i++) {
     102                        //echo '<li value="' . $tokens[$i]['app_token'] . '" tabIndex="0">' . $tokens[$i]['title'] . '</li>';
     103                        echo '<option value="' . $tokens[$i]['app_token'] . '">' . $tokens[$i]['title'] . '</option>';
     104                    }
     105                ?>
     106            </select>
     107            <div id="applications_detail">
     108
     109                <?php echo ziggeo_a_sdk_page_applications_get(); ?>
     110
     111            </div>
     112        </div>
     113        <div class="ziggeo-frame" style="display:none;" id="ziggeo_tab_analytics">
     114            Note: This requires Pro plan or higher. For your security we do not expose details such as to what plan some application belongs to nor if two applications are within same account. If you do not have the right plan, the bellow options will simply not work for you.
     115
     116            <div>
     117                <input id="analytics-from" type="hidden">
     118                <input id="analytics-to" type="hidden">
     119            </div>
     120            <div class="calendars">
     121                <div>
     122                    <label>From</label>
     123                    <label>To</label>
     124                </div>
     125                <div id="calendar_from"></div>
     126                <div id="calendar_to"></div>
     127                <br>
     128                <span class="ziggeo-ctrl-btn ziggeo-sdk-ajax"
     129                    data-action="analytics_get"
     130                    data-operation="sdk_analytics"
     131                    data-value="from:analytics-from,to:analytics-to,token:{app_token}"
     132                    data-results="{ziggeoPUISDKAnalyticsCreateGraphs}"
     133                    data-validate="notempty:analytics-from">Analize</span>
     134                <p>Please wait (this can take a minute or two)</p>
     135            </div>
     136            <div id="analytics_data" class="graphs hidden">
     137                <div class="ziggeo-graph">
     138                    <canvas id="ziggeo_graph_device_views_by_os" data-type="view:os">
     139                    </canvas>
     140                </div>
     141                <div class="ziggeo-graph">
     142                    <canvas id="ziggeo_graph_device_views_by_date" data-type="view:date">
     143                    </canvas>
     144                </div>
     145                <div class="ziggeo-graph">
     146                    <canvas id="ziggeo_graph_total_plays_by_country" data-type="play:country">
     147                   
     148                    </canvas>
     149                </div>
     150                <div class="ziggeo-graph">
     151                    <canvas id="ziggeo_graph_full_plays_by_country" data-type="full_play:country">
     152                    </canvas>
     153                </div>
     154                <div class="ziggeo-graph">
     155                    <canvas id="ziggeo_graph_total_plays_by_hour" data-type="play:hour">
     156                    </canvas>
     157                </div>
     158                <div class="ziggeo-graph">
     159                    <canvas id="ziggeo_graph_full_plays_by_hour" data-type="full_play:hour">
     160                    </canvas>
     161                </div>
     162                <div class="ziggeo-graph">
     163                    <canvas id="ziggeo_graph_total_plays_by_browser" data-type="play:browser">
     164                    </canvas>
     165                </div>
     166                <div class="ziggeo-graph">
     167                    <canvas id="ziggeo_graph_full_plays_by_browser" data-type="full_play:browser">
     168                    </canvas>
     169                </div>
     170                <div class="ziggeo-graph big" style="display:none;">
     171                    <canvas id="ziggeo_graph_big"></canvas>
     172                </div>
     173            </div>
     174        </div>
     175        <div class="ziggeo-frame" style="display:none;" id="ziggeo_tab_authtokens">
     176            <p>
     177                <?php
     178                    _e('Auth tokens area has not yet been added to this version of Ziggeo\'s Wordpress Core plugin.', 'ziggeo');
     179                ?>
     180            </p>
     181        </div>
     182        <div class="ziggeo-frame" style="display:none;" id="ziggeo_tab_effectprofiles">
     183            <p>
     184                <?php
     185                    _e('This section will help you see all of the effect profiles, create new, update and remove the existing ones.', 'ziggeo');
     186                ?>
     187            </p>
     188
     189            <div id="effect_profile_create">
     190                <h2>Create Effect Profile</h2>
     191                <label for="effect_profile_create_key">Key:</label>
     192                <input id="effect_profile_create_key" type="text" placeholder="optional"><br>
     193
     194                <label for="effect_profile_create_title" data-required="true">Title:</label>
     195                <input id="effect_profile_create_title" type="text" placeholder="only visible to you"><br>
     196
     197                <label for="effect_profile_create_default" type="checkbox">Create default stream using this effect profile?</label>
     198                <input id="effect_profile_create_default" type="checkbox"><br>
     199
     200                <label for="effect_profile_create_image_only" type="checkbox">Create image only stream using this effect profile?</label>
     201                <input id="effect_profile_create_image_only" type="checkbox"><br>
     202
     203                <span class="ziggeo-ctrl-btn ziggeo-sdk-ajax-form"
     204                      data-keys="key, title, default, image_only"
     205                      data-section="effect_profile_create"
     206                      data-action="effect_profile_create"
     207                      data-operation="sdk_effect_profiles"
     208                      data-update-type="clear">Create Effect Profile</span>
     209            </div>
     210
     211            <hr>
     212
     213            <div id="effect_profile_list">
     214            </div>
     215            <span class="ziggeo-ctrl-btn ziggeo-sdk-ajax"
     216                 data-action="effect_profile_get_all"
     217                 data-operation="sdk_effect_profiles"
     218                 data-results="effect_profile_list">Get All Effect Profiles</span>
     219        </div>
     220        <div class="ziggeo-frame" style="display:none;" id="ziggeo_tab_metaprofiles">
     221            <p>
     222                <?php
     223                    _e('Meta Profiles area has not yet been added to this version of Ziggeo\'s Wordpress Core plugin.', 'ziggeo');
     224                ?>
     225            </p>
     226        </div>
     227        <div class="ziggeo-frame" style="display:none;" id="ziggeo_tab_webhooks">
     228            <p>
     229                <?php
     230                    _e('Webhooks area has not yet been added to this version of Ziggeo\'s Wordpress Core plugin.', 'ziggeo');
     231                ?>
     232            </p>
     233        </div>
     234    </div>
     235
     236    <?php
    30237}
    31238
     239
     240
     241
     242
     243
    32244?>
  • ziggeo/trunk/admin/settings-tabs-expert.php

    r2331349 r2658640  
    134134    }
    135135
    136     /*
    137     //@ADD - set for next version
     136    //Field to accept the private token
    138137    function ziggeo_a_s_e_private_token_field() {
    139138        $option = ziggeo_get_plugin_options('p_token');
     
    146145    }
    147146
     147    //Field to accept the encryption token
    148148    function ziggeo_a_s_e_encryption_token_field() {
    149149        $option = ziggeo_get_plugin_options('e_token');
     
    154154        <?php
    155155    }
    156     */
    157156
    158157    //Sync field allowing everyone to sync the templates that are in files with templates that are in DB.
  • ziggeo/trunk/admin/settings-tabs-general.php

    r2378985 r2658640  
    1313
    1414    ?>
    15     </div>
    1615    <div class="ziggeo-frame" id="ziggeo-tab_general">
    1716    <?php
     
    198197    }
    199198
     199    // Option to turn on or off our code mixing with comments
     200    function ziggeo_a_s_g_modify_comments() {
     201        $option = ziggeo_get_plugin_options('modify_comments');
     202
     203        ?>
     204        <input id="ziggeo_modify_comments" name="ziggeo_video[modify_comments]" type="checkbox" value="1"
     205            <?php echo checked( 1, $option, false ); ?> />
     206        <label for="ziggeo_modify_comments">
     207            <?php _e('Check if you want our plugin to try and inject the needed code to your comments. Might not work with all themes.)', 'ziggeo');
     208            ?>
     209        </label>
     210        <?php
     211    }
     212
    200213    //Allows us to select if video comments are accepted on a post where comments are enabled
    201214    function ziggeo_a_s_g_accept_video_comments_field() {
  • ziggeo/trunk/admin/settings-validation.php

    r2378985 r2658640  
    1717    //List of all options that we accept
    1818    $allowed_options = array(
    19         //not shown
     19        // not shown
    2020            'version' => true,
    21         //templates tab
     21        // Templates Editor page
    2222            'templates_id' => true, 'templates_editor' => true, 'templates_manager' => true, 'feedback' => true,
    23         //general tab
     23        // General tab
    2424            'token' => true,
    2525            'recorder_config' => true, 'player_config' => true, 'disable_video_comments' => true, 'disable_text_comments' => true,
    26             'comments_recorder_template' => true, 'comments_player_template' => true, 'video_and_text' => true,
     26            'modify_comments' => true, 'comments_recorder_template' => true, 'comments_player_template' => true, 'video_and_text' => true,
    2727            'comment_roles' => true, 'integrations_recorder_template' => true, 'integrations_player_template' => true, 'default_lang' => true, 'vast_adserver' => true, 'vast_skipafter' => true, 'vast_muted' => true, 'vast_ad_title' => true, 'vast_ad_description' => true, 'vast_ad_id' => true, 'vast_ad_advertiser' => true,
    28         //integrations tab
     28        // Integrations tab
    2929            'integrations' => true,
    30         //experts tab
     30        // Experts tab
    3131            'dev_mode' => true, 'p_token' => true, 'e_token' => true, 'templates_save_to' => true, 'templates_clear' => true, 'webrtc_for_mobile' => true, 'webrtc_streaming' => true, 'webrtc_streaming_needed' => true, 'sauth_token' => true, 'use_auth' => true, 'use_version' => true, 'use_revision' => true
    3232    );
     
    3434    //Needed for checkboxes otherwise we would clear them
    3535    $clear_if_not_set = array(
     36        'modify_comments'           => true,
    3637        'disable_video_comments'    => true,
    3738        'disable_text_comments'     => true,
  • ziggeo/trunk/admin/settings.php

    r2378985 r2658640  
    1212        // for styling purposes -start-
    1313        add_settings_section('ziggeo_video_tabss', '', 'ziggeo_a_s_tabs_s_html', 'ziggeo_video');
    14         // templates tab
    15         add_settings_section('ziggeo_video_templates', '', 'ziggeo_a_s_t_text', 'ziggeo_video');
    1614        // general tab
    1715        add_settings_section('ziggeo_video_main', '', 'ziggeo_a_s_g_text', 'ziggeo_video');
     
    2725    //Add sections settings
    2826    //----------------------
    29         //-Templates section-
    30 
    31         // Templates list (shows templates, allows edit and delete)
    32         add_settings_field('ziggeo_templates_manager',
    33                             __('Manage your templates', 'ziggeo'),
    34                             'ziggeo_a_s_t_manager_field',
    35                             'ziggeo_video',
    36                             'ziggeo_video_templates');
    37 
    38         // Template ID field
    39         add_settings_field('ziggeo_templates_id',
    40                             __('Template ID', 'ziggeo'),
    41                             'ziggeo_a_s_t_id_field',
    42                             'ziggeo_video',
    43                             'ziggeo_video_templates');
    44 
    45         // Templates editor segment (lists available parameters and shows the editor textarea and dropbox for type of template to be created )
    46         add_settings_field('ziggeo_templates_editor',
    47                             __('Template Editor', 'ziggeo'),
    48                             'ziggeo_a_s_t_editor_field',
    49                             'ziggeo_video',
    50                             'ziggeo_video_templates');
    5127
    5228        //-General section-
     
    7248                            'ziggeo_video',
    7349                            'ziggeo_video_main');
     50
     51            //disables video comments
     52            add_settings_field('ziggeo_modify_comments',
     53                                __('Modify Comments', 'ziggeo'),
     54                                'ziggeo_a_s_g_modify_comments',
     55                                'ziggeo_video',
     56                                'ziggeo_video_main');
    7457
    7558            //disables video comments
     
    281264                            'ziggeo_video_expert');
    282265
    283         /* - set of for next version
    284         //@ADD option to turn on the SDK, if done, then we could tell them which version to download as well and from where and how to manually add it
    285         // * This would be preferred over adding the SDK manually as part of the plugin itself
    286 
    287266        // Ziggeo Private token
    288267        add_settings_field('ziggeo_private_token',
     
    298277                            'ziggeo_video',
    299278                            'ziggeo_video_expert');
    300         */
    301279
    302280        // Ziggeo Server Auth token
     
    353331    ?>
    354332    <br>
    355     <span id="ziggeo-tab_id_templates" class="ziggeo-tabName" style="border-top-left-radius: 8px;" onclick="ziggeoPUIChangeTab('templates');"><?php _ex('Templates Editor', '"Templates Editor" tab in settings', 'ziggeo'); ?></span>
    356     <span id="ziggeo-tab_id_general" class="ziggeo-tabName selected" onclick="ziggeoPUIChangeTab('general');"><?php _ex('General', '"General" tab in settings', 'ziggeo'); ?></span>
     333    <span id="ziggeo-tab_id_general" class="ziggeo-tabName selected" style="border-top-left-radius: 8px;" onclick="ziggeoPUIChangeTab('general');"><?php _ex('General', '"General" tab in settings', 'ziggeo'); ?></span>
    357334    <span id="ziggeo-tab_id_integrations" class="ziggeo-tabName" onclick="ziggeoPUIChangeTab('integrations');"><?php _ex('Integrations', '"Integrations" tab in settings', 'ziggeo'); ?></span>
    358335    <span id="ziggeo-tab_id_contact" class="ziggeo-tabName" onclick="ziggeoPUIChangeTab('contact');"><?php _ex('Contact Us', '"Contact Us" tab in settings', 'ziggeo'); ?></span>
     
    366343}
    367344
    368 //functions for the Templates tab
    369 include_once( ZIGGEO_ROOT_PATH . 'admin/settings-tabs-templates.php');
     345
    370346//functions for the general tab
    371347include_once( ZIGGEO_ROOT_PATH . 'admin/settings-tabs-general.php');
     
    426402}
    427403
     404// Inclusion of events editor page
     405function ziggeo_a_ee_page() {
     406    include_once(ZIGGEO_ROOT_PATH . 'admin/page_editor_events.php');
     407}
     408
     409// Adding the templates editor
     410function ziggeo_a_et_page() {
     411    include_once( ZIGGEO_ROOT_PATH . 'admin/page_editor_templates.php');
     412}
     413
    428414?>
  • ziggeo/trunk/admin/update.php

    r2314947 r2658640  
    122122    }
    123123
     124    // 2.12
     125    if(version_compare($options['version'], '2.12', '<')) {
     126        // We would be here if we were updating from some older revision. As such we should leave the comments as they were, with the defauilt of modifying comments set to true instead of false (the actual default).
     127        $defaults['modify_comments'] = ZIGGEO_YES;
     128    }
     129
    124130    //Using this method, we actually allow some new options to be added and saved even if they are not made through our plugin.
    125131    foreach($options as $option => $value) {
  • ziggeo/trunk/assets/css/admin-styles.css

    r2466038 r2658640  
    1616    4. Dashboard (SDK)
    1717    5. Dashboard (Addons)
    18     6. Global styles
    19     7. Post and page editors
    20     8. Third party or modules CSS (TO BE REMOVED IN FUTURE VERSIONS)
     18    6. Dashboard (Events Editor)
     19    7. Global styles
     20    8. Post and page editors
     21    9. Third party or modules CSS (TO BE REMOVED IN FUTURE VERSIONS)
    2122*/
    2223
     
    2526************************************************/
    2627
    27     .ziggeo-tabName {
     28    .ziggeo_tabs .ziggeo_tab:first-child {
     29        border-top-left-radius: 8px;
     30    }
     31    .ziggeo_tabs .ziggeo_tab:last-child {
     32        border-top-right-radius: 8px;
     33    }
     34    .ziggeo-tabName, .ziggeo_tab {
    2835        border: 1px solid gray;
    2936        border-bottom: none;
     
    4047        padding: 1em;
    4148    }
    42     .ziggeo-tabName.selected {
     49    .ziggeo-tabName.selected, .ziggeo_tab.selected {
    4350        border-top-left-radius: 8px;
    4451        border-top-right-radius: 8px;
     
    334341        }
    335342
     343        .disabled_option {
     344            opacity: 0.4;
     345            pointer-events: none;
     346        }
     347
    336348
    337349    /* Integrations tab
     
    668680************************************************/
    669681
    670     .ziggeo_adm_client_auth_simplifiers .ziggeo-ctrl-group {
     682    #ziggeo_tab_applications label {
     683        display: block;
     684        margin-top: 10px;
     685        margin-bottom: 4px;
     686    }
     687    #ziggeo_tab_applications textarea {
    671688        width: 50%;
    672         display: inline-block;
    673     }
    674 
    675     @media all (max-width: 800) {
    676         .ziggeo_adm_client_auth_simplifiers .ziggeo-ctrl-group {
     689        min-width: 300px;
     690    }
     691    #ziggeo_tab_applications input {
     692        width: 50%;
     693        min-width: 300px;
     694    }
     695
     696    #applications_list {
     697        min-width: 50%;
     698    }
     699    input.ziggeo_secret {
     700        filter: blur(4px);
     701        border: 1px solid gray;
     702        box-shadow: 0 0 10px black;
     703    }
     704    input.ziggeo_secret:hover {
     705        filter: blur(0);
     706        box-shadow: none;
     707        transition: filter 1s ease-in-out;
     708    }
     709
     710    .has_error {
     711        box-shadow: 0 0 2px orangered;
     712    }
     713
     714    .calendars {
     715        text-align: center;
     716        margin-bottom: 20px;
     717    }
     718    .calendars .hasDatepicker {
     719        display: inline-block;
     720    }
     721    .calendars label {
     722        min-width: 250px;
     723        display: inline-block;
     724    }
     725    .ziggeo-graph {
     726        width: calc(100% / 4 - 4px);
     727        background-image: radial-gradient(white, white, silver);
     728        display: inline-block;
     729        border: 2px solid gray;
     730        border-radius: 10px;
     731        box-sizing: border-box;
     732    }
     733    .ziggeo-graph.big {
     734        position: absolute;
     735        width: 60%;
     736        border: none transparent;
     737        box-shadow: 0 0 10px gray;
     738        top: 40px;
     739        right: 140px;
     740    }
     741    @media screen and (max-width: 720px) {
     742        .ziggeo-graph {
    677743            width: 100%;
    678744        }
    679745    }
    680 
    681     .ziggeo_adm_client_auth_simplifiers label {
    682         width: 40%;
    683         display: inline-block;
    684     }
    685     .ziggeo_adm_client_auth_simplifiers label + input {
    686         width: 58%;
    687         display: inline-block;
    688         box-sizing: border-box;
     746    @media screen and (min-width: 720px) and (max-width: 1024px) {
     747        .ziggeo-graph {
     748            width: calc(100% / 2 - 4px);
     749        }
     750    }
     751    #analytics_data {
     752        position: relative;
     753    }
     754    .analytics_data .ziggeo-graph.big {
     755        display: none;
     756        position: absolute;
     757    }
     758    .ziggeo-ctrl-btn.ziggeo-sdk-ajax + p {
     759        display: none;
     760    }
     761    .ziggeo-ctrl-btn.ziggeo-sdk-ajax.disabled + p {
     762        display: block;
     763    }
     764
     765    /*.ziggeosdk.effect_profiles_list li span {
     766        border-right: 2px groove lightgray;
     767        text-align: center;
     768        display: inline-block;
     769    }
     770
     771    .ziggeosdk.effect_profiles_list .count,
     772    .ziggeosdk.effect_profiles_list .owned {
     773        width: 30px;
     774    }
     775
     776    .ziggeosdk.effect_profiles_list .type,
     777    .ziggeosdk.effect_profiles_list .created {
     778        padding: 0 10px;
     779    }
     780
     781    .ziggeosdk.effect_profiles_list .volatile,
     782    .ziggeosdk.effect_profiles_list .image_only_effect,
     783    .ziggeosdk.effect_profiles_list .default_effect {
     784        width: 60px;
     785    }
     786
     787    .ziggeosdk.effect_profiles_list .token,
     788    .ziggeosdk.effect_profiles_list .key,
     789    .ziggeosdk.effect_profiles_list .title {
     790        /*width: 240px;* /
     791        width: 180px;
     792        overflow-y: scroll;
     793    }*/
     794
     795    .ziggeosdk.effect_profiles_list li > span {
     796        display: inline-block;
     797        box-sizing: border-box;
     798        line-height: 22px;
     799        font-size: 12px;
     800    }
     801
     802    .ziggeosdk.effect_profiles_list li > span .ziggeo-ctrl-btn {
     803        margin-left: 20px;
     804    }
     805
     806    .ziggeosdk.effect_profiles_list li > span:nth-child(2n+1) {
     807        width: 20%;
     808        text-align: left;
     809        border-right: 1px solid gray;
     810        padding-left: 20px;
     811    }
     812
     813    .ziggeosdk.effect_profiles_list li > span:first-child {
     814        padding-left: 0px;
     815        width: 10px;
     816        border-bottom: 1px dotted gray;
     817        border-right: none transparent;
     818    }
     819
     820    .ziggeosdk.effect_profiles_list li > span.count:nth-child(2) {
     821        padding-left: 0px;
     822        width: 90%;
     823        width: calc(100% - 10px);
     824        border-bottom: 1px dotted gray;
     825    }
     826
     827    .ziggeosdk.effect_profiles_list li > span:nth-child(2n) {
     828        width: 78%;
     829        padding-left: 20px;
     830    }
     831
     832    #ziggeo-sdk-pages .additional_info {
     833        width: 80%;
     834        margin-left: 20%;
     835        border-left: 1px solid gray;
     836    }
     837
     838    #ziggeo-sdk-pages .additional_info span {
     839        display: inline-block;
     840        box-sizing: border-box;
     841    }
     842
     843    #ziggeo-sdk-pages .additional_info span:only-child {
     844        width: 100%;
     845    }
     846    .additional_info span:nth-child(odd) {
     847        width: 20%;
     848        padding-left: 10px;
     849    }
     850    .additional_info span:nth-child(even) {
     851        width: 80%;
     852    }
     853    .additional_info .process {
     854        padding: 10px 0;
     855    }
     856    .additional_info .process:nth-child(2n+1) {
     857        background-color: #53c7f4;
     858    }
     859
     860    #ziggeo_tab_effectprofiles label {
     861        width: 180px;
     862        display: inline-block;
     863        margin: 10px 0;
     864    }
     865
     866    #ziggeo_tab_effectprofiles label + input[type="text"]{
     867        width: 50%;
     868        width: calc(100% - 200px);
     869        min-width: 50%;
     870    }
     871
     872    #ziggeo-sdk-pages [data-required="true"]::before {
     873        content: "*";
     874        color: red;
     875        font-size: 0.8em;
     876        font-variant-position: super;
     877    }
     878
     879    #effect_profile_list li.new {
     880        background: lightgreen;
     881        transition-property: background;
     882        transition-duration: 4s;
     883    }
     884
     885    #ziggeo_tab_effectprofiles .additional_options {
     886        margin: 10px 0;
     887    }
     888
     889    .video_preview_sd, .video_preview_hd {
     890        position: relative;
     891        overflow: hidden;
     892        background-color: lightgray;
     893        border: 2px ridge gray;
     894        margin: 4px;
     895        box-sizing: border-box;
     896    }
     897
     898    .video_preview_sd {
     899        width: 640px;
     900        height: 480px;
     901    }
     902
     903    .video_preview_hd {
     904        width: 1280px;
     905        height: 720px;
     906    }
     907
     908    #effect_profiles_watermark_preview {
     909        width: 20px;
     910        height: 20px;
     911        position: relative;
     912        background-size: 100%;
     913    }
     914    .effect_title {
     915        text-align: center;
     916        font-size: 20px;
     917        margin: 40px 0 20px 0;
     918    }
     919    .ziggeo_popup_form .panel_left,
     920    .ziggeo_popup_form .panel_right {
     921        width: 50%;
     922        box-sizing: border-box;
     923        min-height: 200px;
     924        background-size: auto 100%;
     925        background-repeat: no-repeat;
     926        background-position: center;
     927        display: inline-block;
     928    }
     929    .panel_left.text, .panel_right.text {
     930        width: 50%;
     931        box-sizing: border-box;
     932        display: inline-block;
     933        text-align: center;
     934        min-height: 0;
     935    }
     936    .ziggeo-ctrl-btn.show-on-hover {
     937        position: absolute;
     938        top: 50%;
     939        left: calc( 50% - 100px);
     940        width: 200px;
     941        margin: 0;
     942    }
     943    .ziggeo_effects_list {
     944        position: relative;
     945    }
     946    .ziggeo_effects_list .ziggeo-ctrl-btn.show-on-hover {
     947        position: absolute;
     948        top: 40%;
     949        left: calc( 50% - 100px);
     950        width: 200px;
     951        margin: 0;
     952        height: 60px;
     953        line-height: 60px;
     954        padding: 0;
     955        font-size: 16px;
     956        opacity: 0;
     957    }
     958    .ziggeo_effects_list:hover .show-on-hover {
     959        opacity: 1;
     960        transition: 0.2s opacity ease-in-out;
    689961    }
    690962
     
    7641036
    7651037/************************************************
    766     6. GLOBAL STYLES
     1038    6. DASHBOARD (EVENTS EDITOR)
     1039************************************************/
     1040
     1041    #ziggeo-ee-custom-code {
     1042        width: 100%;
     1043    }
     1044
     1045    .ziggeo-ee-custom-code-placeholder i {
     1046        color: purple;
     1047    }
     1048
     1049    #ziggeo-ee-shortcode {
     1050        margin-top: 20px;
     1051        width: 90%;
     1052    }
     1053
     1054
     1055
     1056/************************************************
     1057    7. GLOBAL STYLES
    7671058************************************************/
    7681059
     
    8641155
    8651156/************************************************
    866     7. POST AND PAGE EDITORS
     1157    8. POST AND PAGE EDITORS
    8671158************************************************/
    8681159
     
    9371228
    9381229/************************************************
    939     8. THIRD PARTY OR MODULES CSS (TO BE REMOVED IN FUTURE VERSIONS)
     1230    9. THIRD PARTY OR MODULES CSS (TO BE REMOVED IN FUTURE VERSIONS)
    9401231************************************************/
    9411232
  • ziggeo/trunk/assets/css/styles.css

    r2466038 r2658640  
    114114        text-align: center;
    115115        position:relative;
     116        margin: 2px;
     117        box-sizing: border-box;
    116118    }
    117119    .ziggeo-ctrl-btn.disabled {
     
    133135        border-radius: 10px;
    134136        margin: 0 4px;
     137        cursor: pointer;
     138    }
     139    .ziggeo-ctrl-btn.delete {
     140        background-image: linear-gradient(orange, red);
     141        transition: color .1s ease-in;
     142    }
     143
     144    .ziggeo-ctrl-btn.delete::before {
     145        content: "\f182";
     146        padding-right: 4px;
     147        font-family: dashicons;
    135148    }
    136149
     
    168181            border-radius: 0 10px 20px 20px;
    169182        }
    170 
     183        .ziggeo-ctrl-btn.close {
     184            position: absolute;
     185            top: 10px;
     186            right: 10px;
     187            border-radius: 50%;
     188            background-image: radial-gradient(orange,red);
     189            width: 20px;
     190            height: 20px;
     191            font-size: 14px;
     192            line-height: 16px;
     193            padding: 0;
     194        }
     195        .ziggeo-ctrl-btn.close::after {
     196            content: "x";
     197        }
    171198    .ziggeo-ctrl-group {
    172199        border: 4px double lightgray;
     
    177204    }
    178205
     206    .ziggeo-ctrl-form-popup::after {
     207        content: "\f504";
     208        font-family: dashicons;
     209        margin-left: 2px;
     210    }
     211
    179212    .ziggeo-ctrl-group label {
    180213        display: block;
    181214    }
    182 
     215    .ziggeo-ctrl-img-toggle {
     216        display: inline-block;
     217        width: 200px;
     218        height: 100px;
     219        border: 4px double gray;
     220        margin: 4px;
     221        box-sizing: border-box;
     222        border-radius: 40px 10px 80px 10px;
     223        line-height: 100px;
     224        text-align: left;
     225        padding: 8px;
     226        border-block-color: lightblue lightgreen;
     227        border-block-width: thin;
     228        vertical-align: bottom;
     229        cursor: pointer;
     230    }
     231    .ziggeo-ctrl-img-toggle.on {
     232        box-shadow: 0 0 20px 8px lightblue inset;
     233        border-right-color: green;
     234    }
     235    .ziggeo-ctrl-img-toggle.off {
     236        box-shadow: 0 0 10px 10px lightgray inset
     237    }
     238    .ziggeo-ctrl-img-toggle.disabled {
     239        cursor: not-allowed;
     240        box-shadow: none;
     241        background-color: transparent;
     242        color: gray;
     243        pointer-events: none;
     244    }
     245    .ziggeo-ctrl-img-toggle.on.disabled {
     246        border-right-color: lightgreen;
     247    }
     248    .ziggeo-list {
     249        margin-bottom: 20px;
     250        box-shadow: 2px 2px 2px lightgray;
     251    }
     252    .ziggeo-ctrl-editlist {
     253        list-style: none;
     254        border: 1px solid gray;
     255        background-image: linear-gradient(white, lightgray);
     256        padding: 4px;
     257        box-sizing: border-box;
     258        width: 300px;
     259        height: 32px;
     260        overflow: hidden;
     261        position: relative;
     262    }
     263    .ziggeo-ctrl-editlist::after {
     264        content: "\f140";
     265        position: absolute;
     266        top: 0;
     267        right: 0;
     268        display: block;
     269        height: 32px;
     270        width: 32px;
     271        text-align: center;
     272        line-height: 30px;
     273        border-left: 1px solid lightgray;
     274        font-family: dashicons;
     275        font-size: 30px;
     276        padding: 0;
     277        margin: 0;
     278        color: lightgray;
     279    }
     280    .ziggeo-ctrl-editlist:focus {
     281        overflow-y: auto;
     282        height: auto;
     283        border-left: none;
     284        background: none;
     285        border-bottom: 2px double lightgray;
     286        border-right: none;
     287    }
     288    .ziggeo-ctrl-editlist:focus::after {
     289        display: none;
     290    }
     291    .ziggeo-ctrl-editlist li {
     292        background-color: white;
     293        margin: 0;
     294        height: 30px;
     295        line-height: 28px;
     296        padding: 2px 4px;
     297        box-sizing: border-box;
     298    }
     299    .ziggeo-ctrl-editlist li:hover {
     300        background-color: lightgray;
     301    }
     302    .ziggeo-ctrl-editlist:not(focus) li {
     303        pointer-events: none;
     304    }
     305    .ziggeo-ctrl-editlist:focus li {
     306        pointer-events: all;
     307    }
     308
     309    /* Styles related to Ziggeo popup. Mostly to be used on admin side */
     310    .ziggeo_popup_form {
     311        position: fixed;
     312        top: 10%;
     313        left: 10%;
     314        right: 10%;
     315        bottom: 10%;
     316        overflow: auto;
     317        background-color: white;
     318        z-index: 9999;
     319        box-sizing: border-box;
     320        padding: 10px;
     321        box-shadow: 0 0 10px black;
     322        border: 2px groove white;
     323    }
     324    .ziggeo-btn-radio {
     325        padding: 2px 8px;
     326        display: inline-block;
     327        background-color: white;
     328        cursor: pointer;
     329    }
     330    .ziggeo-btn-radio::before {
     331        content: "";
     332        border: 1px solid gray;
     333        box-sizing: border-box;
     334        width: 10px;
     335        height: 10px;
     336        background-color: green;
     337        display: inline-block;
     338        margin-right: 8px;
     339    }
     340    .ziggeo-btn-radio.disabled {
     341        background-color: #eaeaea;
     342    }
     343    .ziggeo-btn-radio.disabled::before {
     344        background-color: lightgray;
     345    }
     346    .ziggeo-ctrl-radio-group {
     347        display: inline-block;
     348        padding: 4px;
     349        box-sizing: border-box;
     350        background-color: lightgray;
     351        margin: 10px 0;
     352        border: 1px solid gray;
     353        box-sizing: border-box;
     354    }
     355    .ziggeo-group-section label::before {
     356        content: "";
     357        display: block;
     358    }
     359    .ziggeo-group-section input[type="range"] {
     360        width: 90%;
     361        margin-bottom: 10px;
     362    }
     363    .ziggeo-group-section [type="range"] + span {
     364        width: 6%;
     365        display: inline-block;
     366        margin-bottom: 10px;
     367        vertical-align: top;
     368    }
    183369
    184370
  • ziggeo/trunk/assets/js/admin.js

    r2466038 r2658640  
    1313//      * ziggeoPUIFeedbackRemoval()
    1414//      * ziggeoPUIMessenger()
     15//      * ziggeoPUISDKInit()
    1516// 3. Templates Editor
    1617//      * ziggeoGetEditor()
     
    6162//      * ziggeoPUIAddonsInit()
    6263//      * ziggeoPUIAddonsSwitch()
     64// 9. SDK Page
     65//      *
     66// 10. Events Editor
     67//      *
     68// 11. General Settings
     69//      * ziggeoCommentsToggle
     70
     71
     72
    6373
    6474/////////////////////////////////////////////////
     
    114124        }
    115125
     126        if(document.getElementById('ziggeo-tab_templates')) {
     127            ziggeoPUIParametersQuickAddInit();
     128            ziggeoPUITemplatesManageInit();
     129            ziggeoPUIParametersShownInit();
     130            //lets always do this last
     131            ziggeoPUIHooksInit();
     132        }
     133
    116134        //Lets do this only if we are in the admin panel of our plugin
    117135        if(document.getElementById('ziggeo-tab_id_general')) {
     
    120138            ziggeoPUIParametersShownInit();
    121139            //lets always do this last
    122             ziggeoPUIHooksInit();
     140            //ziggeoPUIHooksInit();
    123141
    124142            //Lets check if we have any integrations and show message if not:
     
    129147            }
    130148
     149            // Comments area on/off on page load
     150            var _comments_area = document.getElementById('ziggeo_modify_comments');
     151            _comments_area.addEventListener('change', function(e) {
     152                ziggeoCommentsToggle(e);
     153            });
     154            ziggeoCommentsToggle(_comments_area);
    131155        }
    132156
     
    148172        if(document.getElementById('ziggeo-addons-nav')) {
    149173            ziggeoPUIAddonsInit();
     174        }
     175
     176        if(document.getElementById('ziggeo-sdk-pages')) {
     177            ziggeoPUISDKInit();
     178        }
     179
     180        if(document.getElementById('ziggeo-ee-event-id')) {
     181            ziggeoPUIEEInit();
    150182        }
    151183    });
     
    408440    }
    409441
     442    //Add functionality to the butons on the SDK page
     443    function ziggeoPUISDKInit() {
     444
     445        var i, l, j, c;
     446
     447        var tabs = document.getElementsByClassName('ziggeo_tab');
     448
     449        //Support for clicking on tabs
     450        for(i = 0, c = tabs.length; i < c; i++) {
     451            tabs[i].addEventListener('click', function(e) {
     452                var current = document.getElementsByClassName('ziggeo_tab selected')[0];
     453                current.className = 'ziggeo_tab';
     454                document.getElementById('ziggeo_tab_' + current.getAttribute('data-tab')).style.display = 'none';
     455
     456                var tab = e.target;
     457                tab.className += ' selected';
     458                document.getElementById('ziggeo_tab_' + tab.getAttribute('data-tab')).style.display = 'block';
     459            });
     460        }
     461
     462        // Set the click event for the fields within the application segment
     463        document.getElementById('ziggeo_tab_applications').addEventListener('click', function(event) {
     464            var current_element = event.target;
     465
     466            //Quick filter
     467            if(current_element.tagName !== 'SPAN') {
     468                return false;
     469            }
     470
     471            //Only do this on actual buttons
     472            if(current_element.className.indexOf('ziggeo-ctrl-btn') > -1) {
     473                //standard buttons
     474                if(current_element.className.indexOf('ziggeo-sdk-ajax') > -1) {
     475                    ziggeoPUISDKButtons(current_element);
     476                }
     477            }
     478            //image radio buttons (on/off)
     479            else if(current_element.className.indexOf('ziggeo-ctrl-img-toggle') > -1) {
     480                ziggeoPUISDKImageToggle(current_element);
     481            }
     482
     483        });
     484
     485        // Set the click event for the fields within the application segment
     486        document.getElementById('ziggeo_tab_analytics').addEventListener('click', function(event) {
     487            var current_element = event.target;
     488
     489            //Quick filter
     490            if(current_element.tagName !== 'SPAN') {
     491                return false;
     492            }
     493
     494            //Only do this on actual buttons
     495            if(current_element.className.indexOf('ziggeo-ctrl-btn') > -1) {
     496                //standard buttons
     497                if(current_element.className.indexOf('ziggeo-sdk-ajax') > -1) {
     498                    ziggeoPUISDKButtons(current_element);
     499                }
     500            }
     501
     502        });
     503
     504        // OnChange event handler for selects
     505        var dropdowns = document.getElementsByClassName('ziggeo-sdk-ajax-dropdown');
     506
     507        for(i = 0, c = dropdowns.length; i < c; i++) {
     508            var _current = dropdowns[i];
     509            _current.addEventListener('change', function() {
     510                ziggeoPUISDKDropdown(_current);
     511            });
     512        }
     513
     514        //Add calendars to our page
     515        jQuery('#calendar_from').datepicker({
     516            dateFormat: '@', // This makes it return Unix time.
     517            onSelect: function(str_date, instance) {
     518                document.getElementById('analytics-from').value = str_date;
     519            }
     520        });
     521
     522        jQuery('#calendar_to').datepicker({
     523            dateFormat: '@', // This makes it return Unix time.
     524            buttonText: "To",
     525            onSelect: function(str_date, instance) {
     526                document.getElementById('analytics-to').value = str_date;
     527            }
     528        });
     529
     530        //Set the click event
     531        document.getElementById('ziggeo_tab_effectprofiles').addEventListener('click', function(event) {
     532            var current_element = event.target;
     533
     534            //Quick filter
     535            if(current_element.tagName !== 'SPAN') {
     536                return false;
     537            }
     538
     539            //Only do this on actual buttons
     540            if(current_element.className.indexOf('ziggeo-ctrl-btn') > -1) {
     541                if(current_element.className.indexOf('ziggeo-sdk-ajax-form') > -1) {
     542                    ziggeoPUISDKEffectProfilesButtonForms(current_element);
     543                }
     544                else if(current_element.className.indexOf('ziggeo-ctrl-form-popup') > -1) {
     545                    ziggeoPUISDKEffectProfilesButtonFormPopup(current_element);
     546                }
     547                else if(current_element.className.indexOf('ziggeo-sdk-ajax') > -1) {
     548                    ziggeoPUISDKEffectProfilesButtons(current_element);
     549                }
     550            }
     551
     552        });
     553
     554        // This allows us to change the application that is used on the SDK page
     555        document.getElementById('applications_list').addEventListener('change', function(e) {
     556            var _current = e.target;
     557
     558            var text = _current[_current.selectedIndex].innerText;
     559            document.getElementById('ziggeo_title_app').innerText = '(' + text + ')';
     560
     561            if(!ZiggeoWP.sdk) {
     562                ZiggeoWP.sdk = {};
     563            }
     564
     565            ZiggeoWP.sdk.app_token = _current.value;
     566            ZiggeoWP.sdk.title = text;
     567        });
     568
     569    }
     570
     571    // Function to help us know if the given value is empty or not
     572    function ziggeoPValidateEmpty(value) {
     573        if(value === '') {
     574            return true;
     575        }
     576
     577        return false;
     578    }
     579
    410580
    411581
     
    20052175
    20062176
     2177
    20072178/////////////////////////////////////////////////
    20082179// 8. ADDONS PAGE                              //
     
    20492220
    20502221
     2222
     2223
     2224/////////////////////////////////////////////////
     2225// 9. SDK PAGE                                 //
     2226/////////////////////////////////////////////////
     2227
     2228    //Image toggle control on the SDK page
     2229    function ziggeoPUISDKImageToggle(btn_current) {
     2230        var i, c;
     2231
     2232        var data = {
     2233            'sdk_action' : btn_current.getAttribute('data-action'),
     2234            'operation'  : btn_current.getAttribute('data-operation'),
     2235            'value'      : btn_current.getAttribute('data-value')
     2236        };
     2237
     2238        // This allows us to get parameters that we do not hardcode into JS side.
     2239        var options = btn_current.getAttribute('data-options');
     2240
     2241        // This allows us to get additional options from within the control minimizing the JS codes
     2242        if(options) {
     2243            options = options.split(',');
     2244            for(i = 0, c = options.length; i < c; i++) {
     2245                var _current = options[i].split(':');
     2246                data[_current[0]] = btn_current.getAttribute('data-' + _current[1]);
     2247            }
     2248        }
     2249
     2250        //We need to switch the value. With toggle buttons it will always be current and we will only update it once we get back the response..
     2251        data.value = (data.value === 'on') ? 'off': 'on';
     2252
     2253        btn_current.className += ' disabled';
     2254
     2255        ziggeoAjax(data, function(response) {
     2256
     2257            //We should get back an object
     2258            response = JSON.parse(response);
     2259
     2260            if(response.status && response.status === 'success') {
     2261
     2262                if(response.result !== '' && response.result !== 'false' && response.result !== null) {
     2263
     2264                    //To clear current status
     2265                    btn_current.className = btn_current.className.replace(' on', '');
     2266                    btn_current.className = btn_current.className.replace(' off', '');
     2267
     2268                    //We now save the new value
     2269                    btn_current.setAttribute('data-value', data.value);
     2270
     2271                    if(data.value === 'on') {
     2272                        btn_current.className += ' on';
     2273                    }
     2274                    else {
     2275                        btn_current.className += ' off';
     2276                    }
     2277                }
     2278                else {
     2279                    alert('The initiated request is not seen as valid.');
     2280                }
     2281
     2282                btn_current.className = btn_current.className.replace(' disabled', '');
     2283            }
     2284            else {
     2285                ziggeoDevReport('Something wrong just happened.');
     2286            }
     2287        });
     2288    }
     2289
     2290    // Function to help us with standard dropdowns that are used to make changes within the dashboard through AJAX
     2291    // These are standard dropdowns with class "ziggeo-sdk-ajax-dropdown"
     2292    function ziggeoPUISDKDropdown(btn_current) {
     2293
     2294        var i, c;
     2295
     2296        var data = {
     2297            'sdk_action' : btn_current.getAttribute('data-action'),
     2298            'operation'  : btn_current.getAttribute('data-operation')
     2299        };
     2300
     2301        //Should we get value from sowewhere?
     2302        var value = btn_current.getAttribute('data-value');
     2303
     2304        //We should get the value
     2305        if(value) {
     2306            value = value.split(',');
     2307
     2308            for(i = 0, c = value.length; i < c; i++) {
     2309                var current = value[i].split(':');
     2310                data[current[0]] = document.getElementById(current[1]).value;
     2311            }
     2312        }
     2313
     2314        btn_current.className += ' disabled';
     2315
     2316        ziggeoAjax(data, function(response) {
     2317
     2318            //We should get back an object
     2319            response = JSON.parse(response);
     2320
     2321            if(response.status && response.status === 'success') {
     2322
     2323                if(response.result !== '' && response.result !== false && response.result !== 'false' &&
     2324                    response.result !== null) {
     2325                    if(btn_current.getAttribute('data-results')) {
     2326                        //We are expected to put the returned values somewhere
     2327                        //We might want to change this to function names so we call them with data instead, at least when the data returend is HTML
     2328                        document.getElementById(btn_current.getAttribute('data-results')).innerHTML = response.result;
     2329                    }
     2330                }
     2331                else {
     2332                    alert('The initiated request is not seen as valid.');
     2333                }
     2334
     2335                btn_current.className = btn_current.className.replace(' disabled', '');
     2336            }
     2337            else {
     2338                ziggeoDevReport('Something wrong just happened.');
     2339            }
     2340        });
     2341    }
     2342
     2343    //Function to handle the buttons on the SDK pages
     2344    function ziggeoPUISDKButtons(btn_current) {
     2345
     2346        var i, c;
     2347
     2348        var data = {
     2349            'sdk_action' : btn_current.getAttribute('data-action'),
     2350            'operation'  : btn_current.getAttribute('data-operation')
     2351        };
     2352
     2353        //We can add validation to our values
     2354        var validate = btn_current.getAttribute('data-validate');
     2355        var is_valid = true;
     2356
     2357        if(validate) {
     2358            validate = validate.split(',');
     2359
     2360            for(i = 0, c = validate.length; i < c; i++) {
     2361                var _current = validate[i].split(':');
     2362                var _validate = document.getElementById(_current[1]);
     2363
     2364                // We remove any previous info about the error being there (if any)
     2365                _validate.className = _validate.className.replace(' has_error', '');
     2366                switch(_current[0]) {
     2367                    case 'notempty':
     2368                        if(ziggeoPValidateEmpty(_validate.value)) {
     2369                            is_valid = false;
     2370                            _validate.className += ' has_error';
     2371                        }
     2372                        break;
     2373                }
     2374            }
     2375        }
     2376
     2377        //This way we do not do any action if the values do not pass validation
     2378        if(is_valid === false) {
     2379            return false;
     2380        }
     2381
     2382        //Should we get value from sowewhere?
     2383        var value = btn_current.getAttribute('data-value');
     2384
     2385        //We should get the value
     2386        if(value) {
     2387            value = value.split(',');
     2388
     2389            for(i = 0, c = value.length; i < c; i++) {
     2390                var current = value[i].split(':');
     2391                if(current[1].indexOf('{') > -1) {
     2392
     2393                    var segment = current[1].replace('{', '').replace('}', '');
     2394                    if(typeof ZiggeoWP.sdk === 'undefined' || typeof ZiggeoWP.sdk[segment] === 'undefined') {
     2395                        var segment_value = '';
     2396                    }
     2397                    else {
     2398                        var segment_value = ZiggeoWP.sdk[segment];
     2399                    }
     2400                    data[current[0]] = segment_value;
     2401                    //ZiggeoWP.sdk.app_token = _current.value;
     2402                    //ZiggeoWP.sdk.title = text;
     2403                }
     2404                else {
     2405                    data[current[0]] = document.getElementById(current[1]).value;
     2406                }
     2407            }
     2408        }
     2409
     2410        // This allows us to get parameters that we do not hardcode into JS side.
     2411        var options = btn_current.getAttribute('data-options');
     2412
     2413        // This allows us to get additional options from within the control minimizing the JS codes
     2414        if(options) {
     2415            options = options.split(',');
     2416            console.log('to be added');
     2417            //for(i = 0, c = options.length; i < c; i++) {
     2418            //  data[options[i]] = '';
     2419            //}
     2420        }
     2421
     2422        btn_current.className += ' disabled';
     2423
     2424        ziggeoAjax(data, function(response) {
     2425
     2426            //We should get back an object
     2427            response = JSON.parse(response);
     2428
     2429            if(response.status && response.status === 'success') {
     2430
     2431                if(response.result !== '' && response.result !== 'false' && response.result !== null) {
     2432                    if(btn_current.getAttribute('data-results')) {
     2433
     2434                        var _where_what = btn_current.getAttribute('data-results');
     2435
     2436                        //We have a function to call
     2437                        if(_where_what.indexOf('{') > -1) {
     2438                            _where_what = _where_what.replace('{', '').replace('}', '');
     2439                            if(typeof window[_where_what] === 'function') {
     2440                                window[_where_what](response.result);
     2441                            }
     2442                        }
     2443                        else {
     2444                            //We are expected to put the returned values somewhere
     2445                            document.getElementById(btn_current.getAttribute('data-results')).innerHTML = response.result;
     2446                        }
     2447                    }
     2448                }
     2449                else {
     2450                    alert('The initiated request is not seen as valid.');
     2451                }
     2452
     2453                btn_current.className = btn_current.className.replace(' disabled', '');
     2454            }
     2455            else {
     2456                ziggeoDevReport('Something wrong just happened.');
     2457            }
     2458        });
     2459    }
     2460
     2461
     2462    // Analytics
     2463    // ***********
     2464
     2465    //This function creates the graphs
     2466    // It is called when dates are changed, so everything is drawn first time, using the data we just got.
     2467    function ziggeoPUISDKAnalyticsCreateGraphs(data) {
     2468
     2469        var i,c,j,k,l,m;
     2470
     2471        var available = [
     2472            'device_views_by_os',
     2473            'device_views_by_date',
     2474            'total_plays_by_country',
     2475            'full_plays_by_country',
     2476            'total_plays_by_hour',
     2477            'full_plays_by_hour',
     2478            'total_plays_by_browser',
     2479            'full_plays_by_browser'
     2480        ];
     2481
     2482        var values = {
     2483            'device_views_by_os': {
     2484                label: 'os',
     2485                value: 'event_count',
     2486                chart_type: 'doughnut'
     2487            },
     2488            'device_views_by_date': {
     2489                label: 'type',
     2490                value: 'event_count',
     2491                chart_type: 'polarArea'
     2492                //date
     2493            },
     2494            'total_plays_by_country': {
     2495                label: 'country',
     2496                value: 'event_count',
     2497                chart_type: 'polarArea'
     2498            },
     2499            'full_plays_by_country': {
     2500                label: 'country',
     2501                value: 'event_count',
     2502                chart_type: 'radar'
     2503            },
     2504            'total_plays_by_hour': {
     2505                label: 'date',
     2506                value: 'event_count',
     2507                chart_type: 'polarArea'
     2508                //hour
     2509            },
     2510            'full_plays_by_hour': {
     2511                label: 'date',
     2512                value: 'event_count',
     2513                chart_type: 'radar'
     2514                //hour
     2515            },
     2516            'total_plays_by_browser': {
     2517                label: 'device_browser',
     2518                value: 'event_count',
     2519                chart_type: 'polarArea'
     2520                //device_os
     2521            },
     2522            'full_plays_by_browser': {
     2523                label: 'device_browser',
     2524                value: 'event_count',
     2525                chart_type: 'polarArea'
     2526                //device_os
     2527            }
     2528        }
     2529
     2530        var colors = [
     2531            '#FF6384',
     2532            '#4BC0C0',
     2533            '#FFCE56',
     2534            '#E7E9ED',
     2535            '#36A2EB',
     2536            '#F26354',
     2537            '#F29E54',
     2538            '#F2E854',
     2539            '#77F254',
     2540            '#54F2CD',
     2541            '#54C6F2',
     2542            '#9C54F2',
     2543            '#ED54F2',
     2544            '#F2549E',
     2545            '#F25454'
     2546        ];
     2547
     2548        var months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
     2549
     2550        //Sanity check
     2551        if(typeof ZiggeoWP.sdk !== 'undefined') {
     2552
     2553            if(typeof ZiggeoWP.sdk.charts !== 'undefined') {
     2554                //We need to clear out the existing charts
     2555                for(i = 0, c = ZiggeoWP.sdk.charts.length; i < c; i++) {
     2556                    ZiggeoWP.sdk.charts[i].destroy();
     2557                }
     2558            }
     2559
     2560            ZiggeoWP.sdk.charts = [];
     2561            ZiggeoWP.sdk.charts_data = {};
     2562        }
     2563        else {
     2564            ZiggeoWP.sdk = {
     2565                charts: [],
     2566                charts_data: {}
     2567            };
     2568        }
     2569
     2570        // handles per query (device_views_by_os)
     2571        for(i = 0, c = available.length; i < c; i++) {
     2572            var graph_info = data[available[i]];
     2573
     2574            if(typeof graph_info === 'string') {
     2575                //Something went wrong.
     2576                ziggeoDevReport('Something went wrong getting analytics data');
     2577                continue;
     2578            }
     2579
     2580            var graph_data = {
     2581                datasets: [],
     2582                labels: []
     2583            };
     2584
     2585            var extras = {
     2586                data: [],
     2587                backgroundColor: colors,
     2588                label: available[i].replace(/\_/g, ' ') // Used as legend
     2589            };
     2590
     2591            //Handles the analytics data of the query segment
     2592            for(j = 0, k = graph_info.analytics.length; j < k; j++) {
     2593                var _current = graph_info.analytics[j];
     2594
     2595                var _label = _current[values[available[i]].label];
     2596
     2597                if(available[i] === 'device_views_by_os') {
     2598                    //on first go, we want to strip some data
     2599                    _label = _label.replace(_label.slice(_label.lastIndexOf(' ')), '');
     2600                }
     2601                else if(available[i] === 'total_plays_by_hour' ||
     2602                        available[i] === 'full_plays_by_hour') {
     2603                    //on first go, we want to strip some data
     2604                    _label = String(_label).substr(0,4) + ', ' + months[ ((String(_label).substr(4,2)*1)-1) ];
     2605                }
     2606
     2607                var _found = false;
     2608                for(l = 0, m = graph_data.labels.length; l < m; l++) {
     2609                    if(graph_data.labels[l] === _label) {
     2610                        _found = true;
     2611
     2612                        extras.data[l] += _current.event_count;
     2613                    }
     2614                }
     2615
     2616                if(_found === false) {
     2617                    graph_data.labels.push(_label);
     2618                    extras.data.push(_current.event_count);
     2619                }
     2620            }
     2621
     2622            graph_data.datasets.push(extras);
     2623
     2624            var ctx = document.getElementById('ziggeo_graph_' + available[i]);
     2625            var config = {
     2626                data: graph_data,
     2627                type: values[available[i]].chart_type,
     2628                options: {
     2629                    responsive: true,
     2630                    plugins: {
     2631                        legend: {
     2632                            position: 'top',
     2633                        },
     2634                        title: {
     2635                            display: true,
     2636                            text: available[i].replace(/\_/g, ' ') // Used as legend
     2637                        }
     2638                    }
     2639                }
     2640            };
     2641
     2642            if(available[i] === 'device_views_by_os' ||
     2643                available[i] === 'device_views_by_date' ||
     2644                available[i] === 'full_plays_by_browser' ||
     2645                available[i] === 'total_plays_by_browser' ||
     2646                available[i] === 'full_plays_by_hour' ||
     2647                available[i] === 'total_plays_by_country' ||
     2648                available[i] === 'full_plays_by_country' ||
     2649                available[i] === 'total_plays_by_hour') {
     2650
     2651                config.options.onClick = (event, activeElements) => {
     2652                    if(activeElements.length === 0){
     2653                        return false;
     2654                    }
     2655                    chart_id = event.chart.canvas.id.replace('ziggeo_graph_', '');
     2656
     2657                    var chart = event.chart;
     2658                    var activePoints = chart.getElementsAtEventForMode(event, 'point', chart.options);
     2659                    var firstPoint = activePoints[0];
     2660                    var label = chart.data.labels[firstPoint.index];
     2661                    var value = chart.data.datasets[firstPoint.datasetIndex].data[firstPoint.index];
     2662
     2663                    //Create new "zoomed in" chart
     2664                    ziggeoPUISDKAnalyticsCreateGraphZoomedIn(ZiggeoWP.sdk.charts_data[chart_id], label, chart_id);
     2665                };
     2666            }
     2667
     2668            var chart = new Chart(ctx, config);
     2669
     2670            ctx.parentElement.setAttribute('chart_id', i);
     2671            ZiggeoWP.sdk.charts.push(chart);
     2672        }
     2673
     2674        ZiggeoWP.sdk.charts_data = data;
     2675        document.getElementById('analytics_data').className = 'graphs';
     2676    }
     2677
     2678    //This function is used to create the data shown in the big canvas used as a zoom in screen
     2679    function ziggeoPUISDKAnalyticsCreateGraphZoomedIn(data, zoom_value, query_type) {
     2680
     2681        var i,c,j,k;
     2682
     2683        var available = [
     2684            'device_views_by_os',
     2685            'device_views_by_date',
     2686            'total_plays_by_country',
     2687            'full_plays_by_country',
     2688            'total_plays_by_hour',
     2689            'full_plays_by_hour',
     2690            'total_plays_by_browser',
     2691            'full_plays_by_browser'
     2692        ];
     2693
     2694        var values = {
     2695            'device_views_by_os': {
     2696                label: 'os',
     2697                value: 'event_count',
     2698                chart_type: 'polarArea'
     2699            },
     2700            'device_views_by_date': {
     2701                label: 'type',
     2702                value: 'event_count',
     2703                chart_type: 'bar',
     2704                label_alt: 'date'
     2705            },
     2706            'total_plays_by_country': {
     2707                label: 'country',
     2708                value: 'event_count',
     2709                chart_type: 'radar',
     2710                label_alt: 'video_token'
     2711            },
     2712            'full_plays_by_country': {
     2713                label: 'country',
     2714                value: 'event_count',
     2715                chart_type: 'radar',
     2716                label_alt: 'video_token'
     2717            },
     2718            'total_plays_by_hour': {
     2719                label: 'date',
     2720                value: 'event_count',
     2721                chart_type: 'polarArea',
     2722                label_alt: 'hour'
     2723            },
     2724            'full_plays_by_hour': {
     2725                label: 'date',
     2726                value: 'event_count',
     2727                chart_type: 'polarArea',
     2728                label_alt: 'hour'
     2729            },
     2730            'total_plays_by_browser': {
     2731                label: 'device_browser',
     2732                value: 'event_count',
     2733                chart_type: 'polarArea',
     2734                label_alt: 'device_os'
     2735            },
     2736            'full_plays_by_browser': {
     2737                label: 'device_browser',
     2738                value: 'event_count',
     2739                chart_type: 'polarArea',
     2740                label_alt: 'device_os'
     2741            }
     2742        }
     2743
     2744        var colors = [
     2745            'rgba(255, 99, 132, 0.6)',  //#FF6384
     2746            'rgba(75, 192, 192, 0.6)',  //#4BC0C0
     2747            'rgba(255, 206, 86, 0.6)',  //#FFCE56
     2748            'rgba(231, 233, 237, 0.6)', //#E7E9ED
     2749            'rgba(54, 162, 235, 0.6)',  //#36A2EB
     2750            'rgba(242, 99, 84, 0.6)',   //#F26354
     2751            'rgba(242, 158, 84, 0.6)',  //#F29E54
     2752            'rgba(242, 232, 84, 0.6)',  //#F2E854
     2753            'rgba(119, 242, 84, 0.6)',  //#77F254
     2754            'rgba(84, 242, 205, 0.6)',  //#54F2CD
     2755            'rgba(84, 198, 242, 0.6)',  //#54C6F2
     2756            'rgba(156, 84, 242, 0.6)',  //#9C54F2
     2757            'rgba(237, 84, 242, 0.6)',  //#ED54F2
     2758            'rgba(242, 84, 158, 0.6)',  //#F2549E
     2759            'rgba(242, 84, 84, 0.6)'   //#F25454
     2760        ];
     2761
     2762        //get the reference to the big canvas
     2763        var big_chart = Chart.getChart('ziggeo_graph_big');
     2764
     2765        var months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
     2766
     2767        //If chart is not created already, this will be undefined, so we know we should destroy it if it is not undefined.
     2768        if(typeof big_chart !== 'undefined') {
     2769            big_chart.destroy();
     2770        }
     2771
     2772        var graph_info = data;
     2773
     2774        var graph_data = {
     2775            datasets: [],
     2776            labels: []
     2777        };
     2778
     2779        var extras = {
     2780            data: [],
     2781            backgroundColor: colors,
     2782            label: query_type.replace(/\_/g, ' ') // Used as legend
     2783        };
     2784
     2785        //Handles the analytics data of the query segment
     2786        for(i = 0, c = graph_info.analytics.length; i < c; i++) {
     2787            var _current = graph_info.analytics[i];
     2788
     2789            var _label = _current[values[query_type].label];
     2790
     2791            if(query_type === 'full_plays_by_hour' ||
     2792                query_type === 'total_plays_by_hour') {
     2793                _label = String(_label).substr(0,4) + ', ' + months[ ((String(_label).substr(4,2)*1)-1) ];
     2794            }
     2795
     2796            if(String(_label).indexOf(zoom_value) > -1) {
     2797
     2798                //We need to do it again, since we are getting days now
     2799                if(query_type === 'device_views_by_date') {
     2800                    var _label = _current[values[query_type].label_alt];
     2801                    _label = months[ ((String(_label).substr(4,2)*1)-1) ] + ' ' + String(_label).substr(6,2);
     2802                }
     2803                else if(query_type === 'full_plays_by_browser' ||
     2804                        query_type === 'total_plays_by_browser' ||
     2805                        query_type === 'full_plays_by_hour' ||
     2806                        query_type === 'total_plays_by_country' ||
     2807                        query_type === 'full_plays_by_country' ||
     2808                        query_type === 'total_plays_by_hour') {
     2809                    var _label = _current[values[query_type].label_alt];
     2810                }
     2811
     2812                if(query_type === 'full_plays_by_hour' ||
     2813                    query_type === 'total_plays_by_hour') {
     2814                    _label += ':00';
     2815                }
     2816
     2817                var _found = false;
     2818                for(j = 0, k = graph_data.labels.length; j < k; j++) {
     2819                    if(graph_data.labels[j] === _label) {
     2820                        _found = true;
     2821                        extras.data[j] += _current.event_count;
     2822                    }
     2823                }
     2824
     2825                if(_found === false) {
     2826                    graph_data.labels.push(_label);
     2827                    extras.data.push(_current.event_count);
     2828                }
     2829            }
     2830        }
     2831
     2832        graph_data.datasets.push(extras);
     2833
     2834        var ctx = document.getElementById('ziggeo_graph_big');
     2835        var config = {
     2836            data: graph_data,
     2837            type: values[query_type].chart_type,
     2838            options: {
     2839                responsive: true,
     2840                onClick: (event, activeElements) => {
     2841                    setTimeout(function() {
     2842                        var big_chart = Chart.getChart('ziggeo_graph_big');
     2843                        big_chart.destroy();
     2844                        ctx.parentElement.style.display = 'none';
     2845                    }, 400);
     2846
     2847                    return true;
     2848                },
     2849                plugins: {
     2850                    legend: {
     2851                        position: 'top',
     2852                    },
     2853                    title: {
     2854                        display: true,
     2855                        text: query_type.replace(/\_/g, ' ') + ' [' + zoom_value + ']'
     2856                    }
     2857                }
     2858            }
     2859        };
     2860
     2861        var chart = new Chart(ctx, config);
     2862        ctx.parentElement.style.display = 'block';
     2863    }
     2864
     2865
     2866    // Effect Profiles
     2867    // *****************
     2868
     2869    function ziggeoPUISDKEffectsProfileProcessList(data, token) {
     2870        var i, l, j, c;
     2871        var keys = ['token', 'title', 'type', 'description', 'configuration'];
     2872
     2873        var element_info = document.getElementById('ziggeo-sdk-effects-' + token);
     2874        element_info.innerText = '';
     2875
     2876        for(i = 0, l = data.length; i < l; i++) {
     2877
     2878            var element_row = document.createElement('div');
     2879            element_row.className = 'process';
     2880
     2881            for(j = 0, c = keys.length; j < c; j++) {
     2882                var span_k = document.createElement('span');
     2883                span_k.textContent = keys[j];
     2884
     2885                var span_t = document.createElement('span');
     2886                span_t.textContent = data[i][keys[j]];
     2887
     2888                element_row.appendChild(span_k);
     2889                element_row.appendChild(span_t);
     2890            }
     2891
     2892            var span_kt = document.createElement('span');
     2893            span_kt.textContent = 'Created at';
     2894
     2895            var span_tt = document.createElement('span');
     2896            span_tt.textContent = ziggeoUnixTimetoString(data[i].attrs.created,
     2897                                                         ZiggeoWP.format_date + ' ' + ZiggeoWP.format_time);
     2898
     2899            element_row.appendChild(span_kt);
     2900            element_row.appendChild(span_tt);
     2901
     2902            element_info.appendChild(element_row);
     2903        }
     2904
     2905        if(!element_row) {
     2906            var info = document.createElement('span');
     2907            info.textContent = 'This effect profile has no effect processes added to it.'
     2908            element_info.appendChild(info);
     2909        }
     2910    }
     2911
     2912    function ziggeoPUISDKEffectsProfileDelete(data, token) {
     2913
     2914        var elem = document.getElementById('effect-profile-' + token);
     2915
     2916        elem.parentElement.removeChild(elem);
     2917    }
     2918
     2919    function ziggeoPUISDKEffectsProfileCreate(data) {
     2920        var list = document.getElementById('effect_profile_list').getElementsByClassName('ziggeosdk effect_profiles_list')[0];
     2921
     2922        list.insertAdjacentHTML('afterbegin', data);
     2923    }
     2924
     2925    //Shows the form to create effect profile process
     2926    function ziggeoPUISDKEffectsProfileProcessCreateForm(effect_token) {
     2927        var _form = document.createElement('div');
     2928        _form.className = 'ziggeo_popup_form';
     2929        _form.setAttribute('data-token', effect_token);
     2930
     2931        //Initial switch between effect and watermark
     2932        var _switches = ['Effect Filter', 'Watermark'];
     2933
     2934        var _switch_placeholder = document.createElement('div');
     2935        _switch_placeholder.className = 'ziggeo-ctrl-radio-group';
     2936
     2937        for(i = 0; i < _switches.length; i++) {
     2938            var _switch = document.createElement('span');
     2939
     2940            _switch.className = 'ziggeo-btn-radio';
     2941
     2942            if(i > 0) {
     2943                _switch.className += ' disabled';
     2944            }
     2945
     2946            _switch.textContent = _switches[i];
     2947            _switch.setAttribute('data-section', ziggeoStringToSafe(_switches[i]));
     2948
     2949            _switch.addEventListener('click', function(e) {
     2950                var _current_element = e.currentTarget;
     2951
     2952                var _all_switches = _current_element.parentElement.getElementsByClassName('ziggeo-btn-radio');
     2953
     2954                for(j = 0, l = _all_switches.length; j < l; j++) {
     2955                    //just to be safe, we are going to remove the same if it is already present and add in either case
     2956                    _all_switches[j].className = _all_switches[j].className.replace(' disabled', '') + ' disabled';
     2957                    var _section_deselect = document.getElementById('ziggeo-group-' + _all_switches[j].getAttribute('data-section') + '-section');
     2958
     2959                    if(_section_deselect) {
     2960                        _section_deselect.style.maxHeight = '0px';
     2961                        _section_deselect.style.display = 'none';
     2962                    }
     2963
     2964                    _current_element.className = _current_element.className.replace(' disabled', '');
     2965                }
     2966
     2967                var _current_section = document.getElementById('ziggeo-group-' +
     2968                                                                       _current_element.getAttribute('data-section') +
     2969                                                                       '-section');
     2970
     2971                if(_current_section) {
     2972                    _current_section.style.display = 'block';
     2973                    _current_section.style.maxHeight = 'auto';
     2974                }
     2975
     2976            });
     2977
     2978            _switch_placeholder.appendChild(_switch);
     2979        }
     2980
     2981        _form.appendChild(_switch_placeholder);
     2982
     2983        // Create filter fields
     2984        var filter_section = document.createElement('div');
     2985        filter_section.className = 'ziggeo-group-section';
     2986        filter_section.id = 'ziggeo-group-effect_filter-section';
     2987
     2988            var filter_url = 'https://ziggeo.com/assets/imgs/features/filters/filter_'; //{name}.jpg
     2989            var filter_list = document.createElement('ul');
     2990            var available_filters = [
     2991                { name: 'gray', label: 'Black & White Effect' },
     2992                { name: 'lucis', label: 'Lucis Art Effect' },
     2993                { name: 'cartoon', label: 'Cartoon Effect' },
     2994                { name: 'edge', label: 'Edge Highlight Effect' },
     2995                { name: 'dhill', label: 'Dave Hill Effect' },
     2996                { name: 'charcoal', label: 'Charcoal Sketch Effect' },
     2997                { name: 'sketch', label: 'Sketch Effect' }
     2998            ];
     2999
     3000            for(i = 0, c = available_filters.length; i < c; i++) {
     3001                var effect_item = document.createElement('li');
     3002                effect_item.className = 'ziggeo_effects_list';
     3003
     3004                var title = document.createElement('div');
     3005                title.className = 'effect_title';
     3006                title.textContent = available_filters[i].label;
     3007                effect_item.appendChild(title);
     3008
     3009                var before = document.createElement('div');
     3010                before.className = 'panel_left';
     3011                before.style.backgroundImage = 'url("' + filter_url + 'before.jpg")';
     3012                effect_item.appendChild(before);
     3013
     3014                var after = document.createElement('div');
     3015                after.className = 'panel_right';
     3016                after.style.backgroundImage = 'url("' + filter_url + available_filters[i].name + '.jpg")';
     3017                effect_item.appendChild(after);
     3018
     3019                var before_text = document.createElement('div');
     3020                before_text.className = 'panel_right text';
     3021                before_text.textContent = 'Original Video Sample';
     3022                effect_item.appendChild(before_text);
     3023
     3024                var after_text = document.createElement('div');
     3025                after_text.className = 'panel_right text';
     3026                after_text.textContent = 'Example after effect is applied';
     3027                effect_item.appendChild(after_text);
     3028
     3029                var btn_apply = document.createElement('div');
     3030                btn_apply.className = 'ziggeo-ctrl-btn show-on-hover';
     3031                btn_apply.textContent = 'Apply this filter';
     3032                btn_apply.setAttribute('data-token', effect_token);
     3033                btn_apply.setAttribute('data-effect', available_filters[i].name);
     3034                btn_apply.addEventListener('click', function(e) {
     3035
     3036                    var current_btn = e.currentTarget;
     3037                    var token = current_btn.getAttribute('data-token');
     3038
     3039                    var data = {
     3040                        'effect_token': token,
     3041                        'effect':       current_btn.getAttribute('data-effect'),
     3042                        'operation':    'sdk_effect_profiles',
     3043                        'sdk_action':   'effect_profiles_create_filter'
     3044                    };
     3045
     3046                    ziggeoAjax(data, function(response) {
     3047                        //We should get back an object
     3048                        response = JSON.parse(response);
     3049
     3050                        if(response.status && response.status === 'success') {
     3051
     3052                            if(data.sdk_action === 'effect_profiles_create_filter') {
     3053                                //Devs do you want to see something here?
     3054                            }
     3055                        }
     3056                        else {
     3057                            ziggeoDevReport('Something wrong just happened.');
     3058                        }
     3059
     3060                        ziggeoPUICtrlClose(_form,
     3061                                           '#effect-profile-' + token + ' .additional_options .disabled');
     3062
     3063                        var btn = document.querySelector('#effect-profile-' + token + ' .additional_options [data-action="effect_profile_processes_list"]');
     3064                        if(btn) { btn.click(); }
     3065                    });
     3066                });
     3067
     3068                effect_item.appendChild(btn_apply);
     3069
     3070                filter_list.appendChild(effect_item);
     3071            }
     3072
     3073            filter_section.appendChild(filter_list);
     3074
     3075        // Create watermark fields
     3076        var watermark_section = document.createElement('div');
     3077        watermark_section.className = 'ziggeo-group-section';
     3078        watermark_section.id = 'ziggeo-group-watermark-section';
     3079        watermark_section.style.display = 'none';
     3080
     3081            var position_x = document.createElement('input');
     3082            position_x.id = 'ziggeo-effect-profile-watermark-position-x';
     3083            position_x.type = 'range';
     3084            // These are all percentages and they have to be divided by 100 when sent to server
     3085            position_x.min = 0;
     3086            position_x.max = 100;
     3087            position_x.value = 50;
     3088
     3089            var position_x_label = document.createElement('label');
     3090            position_x_label.for = position_x.id;
     3091            position_x_label.textContent = 'Position of watermark horizontally - presented in percentages of video starting from left (0) to right (100)';
     3092
     3093            var position_x_value = document.createElement('span');
     3094            position_x_value.id = 'ziggeo-effect-profile-watermark-position-x-value';
     3095            position_x_value.textContent = '0.50%';
     3096
     3097            watermark_section.appendChild(position_x_label);
     3098            watermark_section.appendChild(position_x);
     3099            watermark_section.appendChild(position_x_value);
     3100
     3101            position_x.addEventListener('input', function(e) {
     3102                position_x_value.textContent = (e.currentTarget.value / 100) + '%';
     3103
     3104                image_preview.setAttribute('image_data_x', e.currentTarget.value);
     3105
     3106                ziggeoPUISDKEffectsProfileProcessWatermarkImagePreview();
     3107            });
     3108
     3109            var position_y = document.createElement('input');
     3110            position_y.id = 'ziggeo-effect-profile-watermark-position-y';
     3111            position_y.type = 'range';
     3112            // These are all percentages and they have to be divided by 100 when sent to server
     3113            position_y.min = 0;
     3114            position_y.max = 100;
     3115            position_y.value = 50;
     3116
     3117            var position_y_label = document.createElement('label');
     3118            position_y_label.for = position_x.id;
     3119            position_y_label.textContent = 'Position of watermark vertically - presented in percentages of video starting from top (0) to bottom (100)';
     3120
     3121            var position_y_value = document.createElement('span');
     3122            position_y_value.id = 'ziggeo-effect-profile-watermark-position-y-value';
     3123            position_y_value.textContent = '0.50%';
     3124
     3125            position_y.addEventListener('input', function(e) {
     3126                position_y_value.textContent = (e.currentTarget.value / 100) + '%';
     3127
     3128                image_preview.setAttribute('image_data_y', e.currentTarget.value);
     3129
     3130                ziggeoPUISDKEffectsProfileProcessWatermarkImagePreview();
     3131            });
     3132
     3133            watermark_section.appendChild(position_y_label);
     3134            watermark_section.appendChild(position_y);
     3135            watermark_section.appendChild(position_y_value);
     3136
     3137            //Specify the image scale of your watermark (a value between 0.0 and 1.0)
     3138            var scale = document.createElement('input');
     3139            scale.id = 'ziggeo-effect-profile-watermark-scale';
     3140            scale.type = 'range';
     3141            // These are all percentages and they have to be divided by 100 when sent to server
     3142            scale.min = 0;
     3143            scale.max = 100;
     3144            scale.value = 25;
     3145
     3146            var scale_label = document.createElement('label');
     3147            scale_label.for = position_x.id;
     3148            scale_label.textContent = 'Factor to scale your image with - 1 leave as is, anything else will reduce it.';
     3149
     3150            var scale_value = document.createElement('span');
     3151            scale_value.id = 'ziggeo-effect-profile-watermark-scale-value';
     3152            scale_value.textContent = '0.25%';
     3153
     3154            scale.addEventListener('input', function(e) {
     3155                scale_value.textContent = (e.currentTarget.value / 100) + '%';
     3156
     3157                image_preview.setAttribute('image_data_scale', e.currentTarget.value);
     3158
     3159                ziggeoPUISDKEffectsProfileProcessWatermarkImagePreview();
     3160            });
     3161
     3162            watermark_section.appendChild(scale_label);
     3163            watermark_section.appendChild(scale);
     3164            watermark_section.appendChild(scale_value);
     3165
     3166            //Video resolution
     3167            var resolution = document.createElement('select');
     3168            resolution.id = 'ziggeo-effect-profile-watermark-resolution';
     3169            var option_sd = document.createElement('option');
     3170            option_sd.textContent = '640x480';
     3171            option_sd.value = '640x480';
     3172
     3173            var option_hd = document.createElement('option');
     3174            option_hd.textContent = '1280x720';
     3175            option_hd.value = '1280x720';
     3176
     3177            resolution.appendChild(option_sd);
     3178            resolution.appendChild(option_hd);
     3179
     3180            resolution.addEventListener('change', function() {
     3181                image_preview.setAttribute('image_data_resolution', this.value);
     3182
     3183                if(this.value === '640x480') {
     3184                    document.getElementById('effect_profiles_watermark_preview').parentElement.className = 'video_preview_sd';
     3185                }
     3186                else {
     3187                    document.getElementById('effect_profiles_watermark_preview').parentElement.className = 'video_preview_hd';
     3188                }
     3189
     3190                ziggeoPUISDKEffectsProfileProcessWatermarkImagePreview();
     3191            });
     3192
     3193            watermark_section.appendChild(resolution);
     3194
     3195            //File to be uploaded
     3196            var image_file = document.createElement('input');
     3197            image_file.id = 'ziggeo-effect-profile-watermark-image';
     3198            image_file.type = 'file';
     3199            image_file.accept = 'image/*';
     3200
     3201            image_file.addEventListener('change', function(e) {
     3202                var _fr = new FileReader();
     3203                _fr.readAsDataURL(e.target.files[0]);
     3204                _fr.onload = function (e2) {
     3205
     3206                    var image_file_handler = new Image();
     3207                    image_file_handler.src = e2.target.result;
     3208
     3209                    image_file_handler.onload = function () {
     3210                        //set the width and heigh of the image preview based on the actual file.
     3211                        // take into the account the scale factor as well.
     3212                        image_preview.textContent = '';
     3213                        image_preview.setAttribute('image_data_width', this.width);
     3214                        image_preview.setAttribute('image_data_height', this.height);
     3215                        image_preview.style.backgroundImage = 'url(' + e2.target.result + ')';
     3216
     3217                        ziggeoPUISDKEffectsProfileProcessWatermarkImagePreview();
     3218                    };
     3219                };
     3220            });
     3221
     3222            watermark_section.appendChild(image_file);
     3223
     3224            // Drag and drop preview
     3225            var video_preview = document.createElement('div');
     3226            video_preview.className = 'video_preview_sd';
     3227
     3228            var image_preview = document.createElement('div');
     3229            image_preview.id = "effect_profiles_watermark_preview";
     3230            image_preview.setAttribute('image_data_width', 320);
     3231            image_preview.setAttribute('image_data_height', 240);
     3232            image_preview.setAttribute('image_data_resolution', '640x480');
     3233            image_preview.setAttribute('image_data_scale', '25');
     3234            image_preview.setAttribute('image_data_x', '0.50');
     3235            image_preview.setAttribute('image_data_y', '0.50');
     3236            image_preview.style.left = '50%';
     3237            image_preview.style.top = '50%';
     3238            image_preview.style.width = (320 * 0.25) + 'px';
     3239            image_preview.style.height = (240 * 0.25) + 'px';
     3240            image_preview.textContent = 'Add Image First';
     3241
     3242            video_preview.appendChild(image_preview);
     3243            jQuery(image_preview).draggable({
     3244                //thanks: https://stackoverflow.com/a/11061751
     3245                drag: function(event, ui) {
     3246                    var pos = ui.position;
     3247
     3248                    //Make it impossible to escape the box
     3249                    var sizing = image_preview.getBoundingClientRect();
     3250
     3251                    if(pos.left < 0)    { pos.left = 0; }
     3252                    if(pos.top < 0)     { pos.top = 0; }
     3253                    if(image_preview.parentElement.className === 'video_preview_sd') {
     3254                        if(pos.left > 640) {
     3255                            pos.left = 640;
     3256                        }
     3257                        if(pos.top > 480) {
     3258                            pos.top = 480;
     3259                        }
     3260                    }
     3261                    if(image_preview.parentElement.className === 'video_preview_hd') {
     3262                        if(pos.left > 1280) {
     3263                            pos.left = 1280;
     3264                        }
     3265                        if(pos.top > 720) {
     3266                            pos.top = 720;
     3267                        }
     3268                    }
     3269
     3270                    image_preview.setAttribute('image_data_x', pos.left);
     3271                    image_preview.setAttribute('image_data_y', pos.top);
     3272
     3273                    ziggeoPUISDKEffectsProfileProcessWatermarkImagePreview(true);
     3274                }
     3275            });
     3276
     3277            var create_watermark = document.createElement('div');
     3278            create_watermark.className = 'ziggeo-ctrl-btn';
     3279            create_watermark.innerText = 'Create';
     3280            create_watermark.addEventListener('click', function(e) {
     3281
     3282                var data = new FormData();
     3283                var token = this.parentElement.parentElement.getAttribute('data-token')
     3284                data.append('position_x',   position_x.value / 100);
     3285                data.append('position_y',   position_y.value / 100);
     3286                data.append('scale',        scale.value / 100);
     3287                data.append('file',         image_file.files[0]);
     3288                data.append('sdk_action',   'effect_profiles_create_watermark');
     3289                data.append('operation',    'sdk_effect_profiles');
     3290                data.append('effect_token', token);
     3291
     3292                e.currentTarget.className += ' disabled';
     3293
     3294                ziggeoAjax(data, function(response) {
     3295                    //We should get back an object
     3296                    response = JSON.parse(response);
     3297
     3298                    if(response.status && response.status === 'success') {
     3299
     3300                        if(data.sdk_action === 'effect_profiles_create_watermark') {
     3301                            //Devs do you want to see something here?
     3302                        }
     3303                    }
     3304                    else {
     3305                        ziggeoDevReport('Something wrong just happened.');
     3306                    }
     3307
     3308                    ziggeoPUICtrlClose(_form,
     3309                                       '#effect-profile-' + token + ' .additional_options .disabled');
     3310
     3311                    var btn = document.querySelector('#effect-profile-' + token + ' .additional_options [data-action="effect_profile_processes_list"]');
     3312                    if(btn) { btn.click(); }
     3313                }, true);
     3314            });
     3315
     3316            watermark_section.appendChild(video_preview);
     3317            watermark_section.appendChild(create_watermark);
     3318
     3319        // Create a close button
     3320        var btn_close = document.createElement('div');
     3321        btn_close.className = 'ziggeo-ctrl-btn close';
     3322
     3323        btn_close.addEventListener('click', function(e) {
     3324
     3325            var token = this.parentElement.getAttribute('data-token');
     3326
     3327            ziggeoPUICtrlClose(e.currentTarget.parentElement,
     3328                               '#effect-profile-' + token + ' .additional_options .ziggeo-ctrl-form-popup.disabled');
     3329        });
     3330
     3331        _form.appendChild(filter_section);
     3332        _form.appendChild(watermark_section);
     3333        _form.appendChild(btn_close);
     3334
     3335        document.body.appendChild(_form);
     3336    }
     3337
     3338    // Destroys the element that is passed in _destroy and removes the "disabled" class in the elements found using the CSS query string / CSS rule in _show.
     3339    function ziggeoPUICtrlClose(_destroy, _show) {
     3340        var i, c = 0;
     3341        var to_show = document.querySelectorAll(_show);
     3342
     3343        for(i = 0, c = to_show.length; i < c; i++) {
     3344            to_show[i].className = to_show[i].className.replace(' disabled', '');
     3345        }
     3346
     3347        _destroy.parentElement.removeChild(_destroy);
     3348    }
     3349
     3350    //This function is used to set the image preview over the video preview element based on the settings
     3351    function ziggeoPUISDKEffectsProfileProcessWatermarkImagePreview(on_drag) {
     3352
     3353        //Get relevant elements
     3354        var preview = document.getElementById('effect_profiles_watermark_preview');
     3355        var position_x = document.getElementById('ziggeo-effect-profile-watermark-position-x');
     3356        var position_y = document.getElementById('ziggeo-effect-profile-watermark-position-y');
     3357        var position_x_v = document.getElementById('ziggeo-effect-profile-watermark-position-x-value');
     3358        var position_y_v = document.getElementById('ziggeo-effect-profile-watermark-position-y-value');
     3359        //var scale = document.getElementById('ziggeo-effect-profile-watermark-scale').value;
     3360
     3361        //get data
     3362        var _data = {};
     3363        _data.width = preview.getAttribute('image_data_width');
     3364        _data.height = preview.getAttribute('image_data_height');
     3365        _data.resolution = preview.getAttribute('image_data_resolution');
     3366        _data.scale = preview.getAttribute('image_data_scale');
     3367
     3368        if(on_drag === true) {
     3369            _data.x = preview.getAttribute('image_data_x');
     3370            _data.y = preview.getAttribute('image_data_y');
     3371        }
     3372        else {
     3373            _data.x = position_x.value;
     3374            _data.y = position_y.value;
     3375        }
     3376
     3377        if(_data.resolution === '640x480') {
     3378            var resolution_factor = { x: 640, y: 480};
     3379        }
     3380        else { //1280x720
     3381            var resolution_factor = { x: 1280, y: 720};
     3382        }
     3383
     3384        //Set the resolution of the image
     3385        preview.style.width = (_data.width * _data.scale / 100 ) + 'px';
     3386        preview.style.height = (_data.height * _data.scale / 100 ) + 'px';
     3387
     3388        //Set the value of the slider to match position of preview
     3389        if(on_drag === true) {
     3390            position_x.value = (_data.x / resolution_factor.x * 100).toFixed(2);
     3391            position_y.value = (_data.y / resolution_factor.y * 100).toFixed(2);
     3392
     3393            //Update the values shown next to sliders
     3394            position_x_v.textContent = (_data.x / resolution_factor.x).toFixed(2) + '%';
     3395            position_y_v.textContent = (_data.y / resolution_factor.y).toFixed(2) + '%';
     3396        }
     3397        else {
     3398            preview.style.left = (_data.x * resolution_factor.x / 100).toFixed(2) + 'px';
     3399            preview.style.top = (_data.y * resolution_factor.y / 100).toFixed(2) + 'px';
     3400        }
     3401    }
     3402
     3403    function ziggeoPUISDKEffectProfilesButtons(btn_current) {
     3404        var data = {
     3405            token        : btn_current.getAttribute('data-token'),
     3406            'sdk_action' : btn_current.getAttribute('data-action'),
     3407            'operation'  : btn_current.getAttribute('data-operation')
     3408        };
     3409
     3410        btn_current.className += ' disabled';
     3411
     3412        ziggeoAjax(data, function(response) {
     3413
     3414            //We should get back an object
     3415            response = JSON.parse(response);
     3416
     3417            if(response.status && response.status === 'success') {
     3418
     3419                if(data.sdk_action === 'effect_profile_get_all') {
     3420
     3421                    // #effect_profile_list
     3422                    var elem_where = document.getElementById(btn_current.getAttribute('data-results'));
     3423                    elem_where.insertAdjacentHTML('afterbegin', response.result);
     3424
     3425                    btn_current.className = btn_current.className.replace(' disabled', '');
     3426                }
     3427                else if(data.sdk_action === 'effect_profile_processes_list') {
     3428                    ziggeoPUISDKEffectsProfileProcessList(response.result, data.token);
     3429                    btn_current.className = btn_current.className.replace(' disabled', '');
     3430                }
     3431                else if(data.sdk_action === 'effect_profile_delete') {
     3432                    ziggeoPUISDKEffectsProfileDelete(response.result, data.token);
     3433                }
     3434
     3435            }
     3436            else {
     3437                ziggeoDevReport('Something wrong just happened.');
     3438            }
     3439        });
     3440    }
     3441
     3442    function ziggeoPUISDKEffectProfilesButtonForms(btn_current) {
     3443
     3444        var data = {
     3445            'sdk_action' : btn_current.getAttribute('data-action'),
     3446            'operation'  : btn_current.getAttribute('data-operation')
     3447        };
     3448
     3449        //Disable the button as we start working on it
     3450        btn_current.className += ' disabled';
     3451
     3452        //Lets prepare the data
     3453        var _keys = btn_current.getAttribute('data-keys').replace(/, /g, ',').split(',');
     3454        var _section = btn_current.getAttribute('data-section');
     3455        var _data = {};
     3456
     3457        for(j = 0, c = _keys.length; j < c; j++) {
     3458
     3459            var _field = document.getElementById(_section + '_' + _keys[j]);
     3460            if(_field.type === 'text') {
     3461                _data[_keys[j]] = _field.value;
     3462            }
     3463            else if(_field.type === 'checkbox') {
     3464                _data[_keys[j]] = (_field.checked) ? true : false
     3465            }
     3466        }
     3467
     3468        data.data = _data;
     3469
     3470        ziggeoAjax(data, function(response) {
     3471
     3472            //We should get back an object
     3473            response = JSON.parse(response);
     3474
     3475            if(response.status && response.status === 'success') {
     3476
     3477                if(data.sdk_action === 'effect_profile_create') {
     3478                    ziggeoPUISDKEffectsProfileCreate(response.result.data, response.result.token);
     3479                }
     3480                else if(data.sdk_action === 'effect_profile_processes_create') {
     3481                    //We just made a new profile process, let's get a fresh listing of the available processes
     3482                    // We should clear out the listed ones (if any) first
     3483                    var _target = document.getElementById('ziggeo-sdk-effects-' + response.result.token)
     3484                    _target.innerText = '';
     3485                    _target.parentElement.querySelector('[data-action="effect_profile_processes_list"]').click();
     3486                }
     3487
     3488            }
     3489            else {
     3490                ziggeoDevReport('Something wrong just happened.');
     3491            }
     3492
     3493            btn_current.className = btn_current.className.replace(' disabled', '');
     3494        });
     3495    }
     3496
     3497    function ziggeoPUISDKEffectProfilesButtonFormPopup(btn_current) {
     3498        switch(btn_current.getAttribute('data-form-name')) {
     3499            case 'effect_profile_processes_create':
     3500                ziggeoPUISDKEffectsProfileProcessCreateForm(btn_current.getAttribute('data-token'));
     3501                break;
     3502
     3503            default:
     3504                ziggeoDevReport('Unsure what form should be shown');
     3505        }
     3506
     3507        //Disable the button as we start working on it
     3508        btn_current.className += ' disabled';
     3509    }
     3510
     3511
     3512
     3513
     3514
     3515/////////////////////////////////////////////////
     3516// 10. EVENTS EDITOR                           //
     3517/////////////////////////////////////////////////
     3518
     3519    // Register functions that we need to make our Events Editor a bit interactive
     3520    function ziggeoPUIEEInit() {
     3521
     3522        var event_type = document.getElementById('ziggeo-ee-event-type'); // select
     3523
     3524        var event_alert_message = document.getElementById('ziggeo-ee-event-message');
     3525        var event_template_code = document.getElementById('ziggeo-ee-custom-code');
     3526
     3527        var event_code_inject_onload = document.getElementById('ziggeo-ee-onload');
     3528        var event_code_inject_onfire = document.getElementById('ziggeo-ee-onfire');
     3529
     3530        var codes_preview = document.getElementsByClassName('ziggeo-ee-custom-code-placeholder');
     3531
     3532        var btn_generate = document.getElementById('ziggeo-ee-btn-generate');
     3533        var btn_save = document.getElementById('ziggeo-ee-btn-save');
     3534
     3535        var i, c;
     3536
     3537        // Depending on what is selected different fields are shown
     3538        event_type.addEventListener('change', function() {
     3539            if(event_type.value === 'template') {
     3540                event_alert_message.parentElement.parentElement.style.display = 'none';
     3541                event_template_code.parentElement.parentElement.style.display = 'table-row';
     3542                event_code_inject_onload.parentElement.parentElement.style.display = 'table-row';
     3543                btn_save.style.display = 'inline-block';
     3544            }
     3545            else { // alert
     3546                event_alert_message.parentElement.parentElement.style.display = 'table-row';
     3547                event_template_code.parentElement.parentElement.style.display = 'none';
     3548                event_code_inject_onload.parentElement.parentElement.style.display = 'none';
     3549            }
     3550        });
     3551
     3552        event_code_inject_onfire.addEventListener('click', function() {
     3553            for(i = 0, c = codes_preview.length; i < c; i++) {
     3554                codes_preview[i].style.display = 'block';
     3555            }
     3556        })
     3557
     3558        event_code_inject_onload.addEventListener('click', function() {
     3559            for(i = 0, c = codes_preview.length; i < c; i++) {
     3560                codes_preview[i].style.display = 'none';
     3561            }
     3562        })
     3563
     3564        btn_generate.addEventListener('click', ziggeoPUIEEGenerateShortcode);
     3565        btn_save.addEventListener('click', ziggeoPUIEESaveTemplate);
     3566
     3567        // Set default UI
     3568        ziggeoPUIEEDefauts();
     3569
     3570    }
     3571
     3572    // Helper function to set everything to initial state
     3573    // Used on load and on save
     3574    function ziggeoPUIEEDefauts() {
     3575
     3576        // Event ID is important to be added for templates, however not really important for alerts
     3577        var event_id = document.getElementById('ziggeo-ee-event-id');
     3578        var event_to_listen_to = document.getElementById('ziggeo-ee-event'); // select
     3579        var event_type = document.getElementById('ziggeo-ee-event-type'); // select
     3580        var event_alert_message = document.getElementById('ziggeo-ee-event-message');
     3581        var event_template_code = document.getElementById('ziggeo-ee-custom-code');
     3582
     3583        var event_code_inject_onload = document.getElementById('ziggeo-ee-onload');
     3584        var event_code_inject_onfire = document.getElementById('ziggeo-ee-onfire');
     3585
     3586        var elem_shortcode = document.getElementById('ziggeo-ee-shortcode');
     3587
     3588        var codes_preview = document.getElementsByClassName('ziggeo-ee-custom-code-placeholder');
     3589
     3590        var btn_save = document.getElementById('ziggeo-ee-btn-save');
     3591
     3592        var i, c;
     3593
     3594        event_id.value = '';
     3595        event_to_listen_to.value = 'verified';
     3596        event_type.value = 'alert'
     3597        event_alert_message.value = '';
     3598        event_template_code.value = '';
     3599        event_code_inject_onload.checked = 'checked';
     3600
     3601        // Since we are hiding a row, we need to do this as page is loaded
     3602        event_alert_message.parentElement.parentElement.style.display = 'table-row';
     3603        event_template_code.parentElement.parentElement.style.display = 'none';
     3604        event_code_inject_onload.parentElement.parentElement.style.display = 'none';
     3605
     3606        btn_save.style.display = 'none';
     3607
     3608        for(i = 0, c = codes_preview.length; i < c; i++) {
     3609            codes_preview[i].style.display = 'none';
     3610        }
     3611
     3612        elem_shortcode.value = '';
     3613        elem_shortcode.style.display = 'none';
     3614    }
     3615
     3616    // This function captures the data and then sends it to the server through AJAX to save it.
     3617    // Once done, it resets the values
     3618    function ziggeoPUIEESaveTemplate() {
     3619
     3620        var event_id = document.getElementById('ziggeo-ee-event-id');
     3621        var event_to_listen_to = document.getElementById('ziggeo-ee-event'); // select
     3622        var event_template_code = document.getElementById('ziggeo-ee-custom-code');
     3623        var event_code_inject_onload = document.getElementById('ziggeo-ee-onload');
     3624        var event_code_inject_onfire = document.getElementById('ziggeo-ee-onfire');
     3625
     3626        // Save the same
     3627
     3628        var data = {
     3629            id: event_id.value,
     3630            event: event_to_listen_to.value,
     3631            code: event_template_code.value, //JSON.stringify(event_template_code.value),
     3632            inject_type: (event_code_inject_onload.checked) ? 'on_load' : 'on_fire',
     3633            operation: 'event_editor_save_template'
     3634        }
     3635
     3636        ziggeoAjax(data, function(result) {
     3637
     3638            console.log(result);
     3639
     3640            //ziggeoPUIEEDefauts();
     3641        });
     3642
     3643    }
     3644
     3645    // This function is used to capture the values from the fields and show a copy ready shortcode to be used.
     3646    // In case of templates, they have to be saved first to be usable
     3647    function ziggeoPUIEEGenerateShortcode() {
     3648
     3649        var event_id = document.getElementById('ziggeo-ee-event-id');
     3650        var event_to_listen_to = document.getElementById('ziggeo-ee-event'); // select
     3651        var event_type = document.getElementById('ziggeo-ee-event-type'); // select
     3652
     3653        var event_alert_message = document.getElementById('ziggeo-ee-event-message');
     3654        var event_template_code = document.getElementById('ziggeo-ee-custom-code');
     3655
     3656        var event_code_inject_onload = document.getElementById('ziggeo-ee-onload');
     3657        var event_code_inject_onfire = document.getElementById('ziggeo-ee-onfire');
     3658
     3659        var codes_preview = document.getElementsByClassName('ziggeo-ee-custom-code-placeholder');
     3660        var elem_shortcode = document.getElementById('ziggeo-ee-shortcode');
     3661
     3662        var shortcode = '[ziggeo_event ';
     3663        if(event_type.value === 'alert') {
     3664            //[ziggeo_event event=verified message="my message" type=alert]
     3665            shortcode += 'event=' + event_to_listen_to.value;
     3666            shortcode += ' message="' + event_alert_message.value.replace(/"/g, '&quot;').replace(/'/g, '&apos;') + '"';
     3667            shortcode += ' type=alert]';
     3668        }
     3669        else { // template
     3670            //[ziggeo_event id="event_id_set_in_editor" type=template]
     3671            shortcode += ' id="' + event_id.value;
     3672            shortcode += ' type=template]';
     3673        }
     3674
     3675        elem_shortcode.value = shortcode;
     3676        elem_shortcode.style.display = 'block';
     3677    }
     3678
     3679
     3680
     3681
     3682
     3683/////////////////////////////////////////////////
     3684// 11. GENERAL SETTINGS                        //
     3685/////////////////////////////////////////////////
     3686
     3687    // Function that helps us to hide the comment related options if the entire comments section has been disabled.
     3688    function ziggeoCommentsToggle(e) {
     3689
     3690        if(e.target) {
     3691            var current = e.target;
     3692        }
     3693        else {
     3694            var current = e;
     3695        }
     3696
     3697        var the_next = current.parentElement.parentElement.nextElementSibling;
     3698        var to_enable = current.checked;
     3699
     3700        while (the_next) {
     3701
     3702            // Check if we should stop
     3703            if(the_next.children[0].innerText === '') {
     3704                // We should stop
     3705                the_next = null;
     3706            }
     3707            else {
     3708                // Enable fields
     3709                if(to_enable === true) {
     3710                    the_next.className = the_next.className.replace('disabled_option', '');
     3711                    the_next = the_next.nextElementSibling;
     3712                }
     3713                else {
     3714                    // Disable Fields
     3715                    the_next.className += ' disabled_option';
     3716                    the_next = the_next.nextElementSibling;
     3717                }
     3718            }
     3719        }
     3720    }
  • ziggeo/trunk/assets/js/ziggeo_plugin.js

    r2374117 r2658640  
    1414//      * ziggeoAjax()
    1515//      * ziggeoInsertTextToPostEditor()
     16//      * ziggeoStringToSafe()
     17//      * ziggeoUnixTimetoString()
    1618// 3. API
    1719//      * ziggeoAPIGetVideo()
     
    288290
    289291    //AJAX handler
    290     function ziggeoAjax(data, callback) {
    291 
    292         data.action = 'ziggeo_ajax';
    293         data.ajax_nonce = ZiggeoWP.ajax_nonce;
     292    //data = the data to send
     293    //callback = function to call once the response is received
     294    //is_form_data = true if FormData is set as data, if it is an object, just ignore the same.
     295    function ziggeoAjax(data, callback, is_form_data) {
    294296
    295297        if(typeof ajaxurl === 'undefined') {
     
    297299        }
    298300
    299         jQuery.post(ajaxurl, data, function(response) {
    300             if(typeof callback !== 'undefined') {
    301                 callback(response);
    302             }
    303         });
     301        if(is_form_data === true) {
     302            data.append('action', 'ziggeo_ajax');
     303            data.append('ajax_nonce', ZiggeoWP.ajax_nonce);
     304
     305            jQuery.ajax({
     306                url : ajaxurl,
     307                type: "POST",
     308                data : data,
     309                processData: false,
     310                contentType: false,
     311                success:function(response) {
     312                    if(typeof callback !== 'undefined') {
     313                        callback(response);
     314                    }
     315                },
     316                error: function(response, error_info) {
     317                }
     318            });
     319        }
     320        else {
     321            data.action = 'ziggeo_ajax';
     322            data.ajax_nonce = ZiggeoWP.ajax_nonce;
     323
     324            jQuery.post(ajaxurl, data, function(response) {
     325                if(typeof callback !== 'undefined') {
     326                    callback(response);
     327                }
     328            });
     329        }
    304330    }
    305331
     
    322348            ziggeoDevReport('Unsupported editor detected. Can not pass the message that should be passed', 'error');
    323349        }
     350    }
     351
     352    //Function used to change spaces into underscores and all letters to lowercase
     353    function ziggeoStringToSafe(str) {
     354        return str.toLocaleLowerCase().replace(/ /g, '_');
     355    }
     356
     357    //Converts the UNIX timestamp into a readable time format using the format provided.
     358    // If not provided it will return time in  YYYY/MM/DD HH:MM:SS format
     359    // tried making it follow PHP file format: https://www.php.net/manual/en/datetime.format.php
     360    //
     361    //  Y    A full numeric representation of a year, 4 digits                      Examples: 1999 or 2003
     362    //  y    A two digit representation of a year                                   Examples: 99 or 03
     363    //  n    Numeric representation of a month, without leading zeros               1 through 12
     364    //  m    Numeric representation of a month, with leading zeros                  01 through 12
     365    //  M    A short textual representation of a month, three letters               Jan through Dec
     366    //  F    A full textual representation of a month, such as January or March     January through December
     367    //  j    Day of the month without leading zeros                                 1 to 31
     368    //  d    Day of the month, 2 digits with leading zeros                          01 to 31
     369    //  D    A textual representation of a day, three letters                       Mon through Sun
     370    //  l    (lowercase 'L') A full textual representation of the day of the week   Sunday through Saturday
     371    //  g    12-hour format of an hour without leading zeros                        1 through 12
     372    //  h    12-hour format of an hour with leading zeros                           01 through 12
     373    //  G    24-hour format of an hour without leading zeros                        0 through 23
     374    //  H    24-hour format of an hour with leading zeros                           00 through 23
     375    //  i    Minutes with leading zeros                                             00 to 59
     376    //  s    Seconds with leading zeros                                             00 through 59
     377    //  a    Lowercase Ante meridiem and Post meridiem                              am or pm
     378    //  A    Uppercase Ante meridiem and Post meridiem                              AM or PM
     379    function ziggeoUnixTimetoString(unix_timestamp, format){
     380
     381        if(typeof unix_timestamp === 'undefined') {
     382            ziggeoDevReport('no timestamp was provided', 'error');
     383            return '';
     384        }
     385
     386        if(typeof format !== 'string') {
     387            format = 'Y/M/d H:i:s';
     388        }
     389
     390        var months_s = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
     391        var months_l = ['January','February','March','April','May','June','July','August','September','October','November','December'];
     392        var days_s = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
     393        var days_l = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
     394        var meridiem_s = ['am', 'pm'];
     395        var meridiem_l = ['AM', 'PM'];
     396
     397        var time = new Date(unix_timestamp * 1000);
     398
     399        // year
     400        var yyyy = time.getFullYear();                              // 2021
     401        var yy = yyyy.toString().slice(2);                          // 21
     402
     403        // month
     404        var m = time.getMonth()+1;                                  // 4
     405        var mm = (m < 10) ? '0' + m.toString() : m;                 // 04
     406        var mmm = months_s[m-1];                                    // Apr
     407        var mmmm = months_l[m-1];                                   // April
     408
     409        // day
     410        var d = time.getDate();                                     // 4
     411        var dd = (d < 10) ? '0' + d.toString() : d;                 // 04
     412        var ddd = days_s[time.getDay()];                            // Sun
     413        var dddd = days_l[time.getDay()];                           // Sunday
     414
     415        // hour
     416        var h_24 = time.getHours();                                 // 8
     417        var hh_24 = (h_24 < 10) ? '0' + h_24.toString() : h_24;     // 08
     418
     419        var h_12 = (h_24 > 12) ? h_24 - 12: h_24;                   // 8
     420        var hh_12 = (h_12 < 10) ? '0' + h_12.toString() : h_12;     // 08
     421
     422        // meridiem mark
     423        var meridiem_mark = (hh_24 > 12) ? 1 : 0;
     424
     425        // minute
     426        var min = time.getMinutes();                                // 8
     427        min = (min > 10) ? min : '0' + min.toString();              // 08
     428
     429        // seconds
     430        var sec = time.getSeconds();                                // 8
     431        sec = (sec > 10) ? sec : '0' + sec.toString();              // 08
     432
     433        //We need to do this in order that will not catch any numbers given in format.
     434        var result = format.replace('Y', 'xx_01').replace('y', 'xx_02');
     435        result = result.replace('n', 'xx_03').replace('m', 'xx_04');
     436        result = result.replace('j', 'xx_05').replace('d', 'xx_06');
     437        result = result.replace('g', 'xx_07').replace('h', 'xx_08');
     438        result = result.replace('G', 'xx_09').replace('H', 'xx_10');
     439        result = result.replace('i', 'xx_11').replace('s', 'xx_12');
     440        result = result.replace('a', 'xx_13').replace('A', 'xx_14');
     441        result = result.replace('l', 'xx_15').replace('F', 'xx_16');
     442        result = result.replace('M', 'xx_17').replace('D', 'xx_18');
     443
     444        // Now to get actual values..
     445        result = result.replace('xx_01', yyyy).replace('xx_02', yy);
     446        result = result.replace('xx_03', m).replace('xx_04', mm);
     447        result = result.replace('xx_05', d).replace('xx_06', dd);
     448        result = result.replace('xx_07', h_12).replace('xx_08', hh_12);
     449        result = result.replace('xx_09', h_24).replace('xx_10', hh_24);
     450        result = result.replace('xx_11', min).replace('xx_12', sec);
     451        result = result.replace('xx_13', meridiem_s[meridiem_mark]).replace('xx_14', meridiem_l[meridiem_mark]);
     452        result = result.replace('xx_15', dddd).replace('xx_16', mmmm);
     453        result = result.replace('xx_17', mmm).replace('xx_18', ddd);
     454
     455        return result;
    324456    }
    325457
  • ziggeo/trunk/core/assets.php

    r2378985 r2658640  
    101101    wp_register_style('ziggeo-admin-css', ZIGGEO_ROOT_URL . 'assets/css/admin-styles.css', array());
    102102    wp_enqueue_style('ziggeo-admin-css');
     103
     104
     105    if(get_current_screen()->id === 'ziggeo-video_page_ziggeo_sdk') {
     106        //Adding support for charts
     107        wp_register_script('chart-js', 'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.2.0/chart.min.js');
     108        wp_enqueue_script('chart-js');
     109        //This is usually added into Admin, however just being safe
     110        wp_enqueue_script('jquery-ui-datepicker');
     111        //To add support for the drag and drop on our SDK pages
     112        wp_enqueue_script("jquery-ui-draggable");
     113    }
     114
    103115}
    104116
  • ziggeo/trunk/core/header.php

    r2466038 r2658640  
    3333            integrations_code_recorder: "<?php echo ziggeo_p_get_template_code_safe($options['integrations_recorder_template']); ?>",
    3434            integrations_code_player: "<?php echo ziggeo_p_get_template_code_safe($options['integrations_player_template']); ?>",
     35            format_date: "<?php echo get_option('date_format') ?>",
     36            format_time: "<?php echo get_option('time_format') ?>",
    3537
    3638            //Hooks object
  • ziggeo/trunk/core/simplifiers.php

    r2466038 r2658640  
    251251        'recorder_config'                   => '',
    252252        'player_config'                     => '',
     253        'modify_comments'                   => ZIGGEO_NO,
    253254        'disable_video_comments'            => '',
    254255        'disable_text_comments'             => '',
     
    398399}
    399400
     401// Use this function to include the
     402// Devs: On true, you will need to also call ziggeo_p_sdk_init() function (see core/sdk.php)
     403function ziggeo_p_include_sdk() {
     404    //Includes the additional functionality for the SDK
     405    if(file_exists(ZIGGEO_ROOT_PATH . 'sdk/Ziggeo.php')) {
     406        include_once(ZIGGEO_ROOT_PATH . '/core/sdk.php');
     407        include_once(ZIGGEO_ROOT_PATH . '/sdk/Ziggeo.php');
     408        return true;
     409    }
     410
     411    return false;
     412}
     413
     414// Function to tell you if you can call the SDK functions or if it is not possible to do it at this time.
     415function ziggeo_p_sdk_usable() {
     416    global $ziggeo_sdk;
     417
     418    if(!file_exists(ZIGGEO_ROOT_PATH . 'sdk/Ziggeo.php')) {
     419        return false;
     420    }
     421
     422    if($ziggeo_sdk === null) {
     423        return false;
     424    }
     425
     426    return true;
     427}
     428
     429// Function to get back all of the tokens that are added to the list (requires at least app token and private key)
     430// returns the list of all key combos or the match to provided one
     431function ziggeo_p_get_keys($app_token = null) {
     432    //Get the default ones
     433    $options = ziggeo_get_plugin_options();
     434    $applications = get_option('ziggeo_keys');
     435
     436    $the_list = [];
     437
     438    $the_list[] = array(
     439                        'app_token'     => $options['token'],
     440                        'private'       => $options['p_token'],
     441                        'encryption'    => $options['e_token'],
     442                        'title'         => 'Default Application'
     443    );
     444
     445    if(is_array($applications)) {
     446        return array_merge($the_list, $applications);
     447    }
     448    else {
     449        return $the_list;
     450    }
     451
     452}
    400453
    401454?>
  • ziggeo/trunk/core/templates.php

    r2466038 r2658640  
    459459    if(!function_exists('ziggeo_comments_template')) {
    460460        function ziggeo_comments_template($comment_template) {
    461             return ZIGGEO_ROOT_PATH . "templates/handle_comments.php";
    462         }
    463     }
    464 
    465 
    466 
    467 
     461           
     462            $option = ziggeo_get_plugin_options('modify_comments');
     463            if($option === ZIGGEO_YES) {
     464                return ZIGGEO_ROOT_PATH . "templates/handle_comments.php";
     465            }
     466        }
     467    }
     468
     469
     470
     471
  • ziggeo/trunk/info.json

    r2466038 r2658640  
    22    "wp": {
    33        "required": "3.0.1",
    4         "tested": "5.6",
     4        "tested": "5.8.3",
    55        "repo_url": "https://wordpress.org/plugins/ziggeo/",
    66        "alternative_repo_url": "https://github.com/Ziggeo/ziggeo-wordpress-plugin"
     
    99        "name": "ziggeo-core",
    1010        "title": "Ziggeo Video Posts and Comments",
    11         "version": "2.8",
     11        "version": "2.12",
    1212        "author": "Ziggeo",
    1313        "logo": "https://raw.githubusercontent.com/Ziggeo/ziggeo-wordpress-plugin/master/assets/images/logo.png",
     
    1515        "tags": "video, video service, record video, video playback, gallery, ziggeo",
    1616        "description": "This plugin allows you to bring video to your Wordpress website or blog, through use of powerful Ziggeo API. Since we all know that video is future, make sure you are part of it.",
    17         "highlight": "Widget parser improvement",
     17        "highlight": "Ziggeo Events Editor has been added to our Wordpress plugin",
    1818        "info_url": "https://raw.githubusercontent.com/Ziggeo/ziggeo-wordpress-plugin/master/info.json",
    1919        "addon_url": "https://ziggeo.com/integrations/wordpress",
  • ziggeo/trunk/parsers/content_parser.php

    r2466038 r2658640  
    2828    $attrs_str = '';
    2929
    30     //We have to combine the attrs array into key + value
    31     foreach($attrs as $key => $value) {
    32         $attrs_str .= ' ' . $key . "='" . $value . "'";
     30    if($attrs === '') {
     31        $attrs_str = ZIGGEO_DEFAULTS_RECORDER;
     32    }
     33    else {
     34        //We have to combine the attrs array into key + value
     35        foreach($attrs as $key => $value) {
     36            $attrs_str .= ' ' . $key . "='" . $value . "'";
     37        }
    3338    }
    3439
    3540    return ziggeo_p_content_filter($tag . $attrs_str . ']');
    3641}
     42
     43// Support for event shortcodes
     44add_shortcode('ziggeo_event', function($attrs) {
     45
     46    // Defaults
     47    $event = 'verified';
     48    $type = 'alert';
     49    $msg = 'Captured media has been verified';
     50    $id = false;
     51    $saved_events = false;
     52    $extra_code = '';
     53    $inject_type = 'on_load';
     54
     55    if(isset($attrs['event'])) {
     56        $event = $attrs['event'];
     57    }
     58
     59    if(isset($attrs['type'])) {
     60        $type = $attrs['type'];
     61    }
     62
     63    if(isset($attrs['message'])) {
     64        $msg = $attrs['message'];
     65    }
     66
     67    if(isset($attrs['id'])) {
     68        $id = $attrs['id'];
     69
     70        $saved_events = get_option('ziggeo_events');
     71
     72        if(isset($saved_events[$id])) {
     73            $extra_code = stripcslashes($saved_events[$id]['code']);
     74            $event = $saved_events[$id]['event'];
     75            $inject_type = $saved_events[$id]['inject_type'];
     76        }
     77        else {
     78            $type === 'ignore'; // We do not want to output anything since the template was not found
     79            // @here - We could add some error reporting of sorts to notify that the event with ID is missing.. Anyone needs something like that? Let us know :)
     80        }
     81    }
     82
     83    if($type === 'alert') {
     84        $code = '<script>';
     85            $code .= 'ziggeo_app.embed_events.on("' . $event . '", function (embedding, attr1, attr2, attr3, attr4) {';
     86                $code .= 'alert("' . $msg . '")'; // We do not escape the strings at this time
     87            $code .= '});';
     88        $code .= '</script>';
     89    }
     90    elseif($type === 'template') {
     91        if($inject_type === 'on_fire') {
     92            $code = '<script>';
     93            $code .= 'ziggeo_app.embed_events.on("' . $event . '", function (embedding, attr1, attr2, attr3, attr4) {';
     94                $code .= $extra_code;
     95            $code .= '});';
     96            $code .= '</script>';
     97        }
     98        else {
     99            $code = $extra_code;
     100        }
     101    }
     102
     103    return $code;
     104});
    37105
    38106//Old and general Ziggeo shortcode support
     
    43111//We are updating this in such a way that we will keep the old calls, so that we have backwards compatibility, but in the same time, we are adding another call that will check for us if there are any tags matching new templates. We must do it like this, since using regex we will be able to find this in all locations that we want, while if we use shortcode, it will only work (out of the box) if the shortcode is within the section covered by 'the_content' filter.
    44112function ziggeo_p_content_filter($content) {
     113
     114    // To not parse the ziggeo events
     115    if(stripos($content, '[ziggeo_event') > -0) {
     116        return $content;
     117    }
    45118
    46119    //This way we are making it work fine with WPv5 saving where we would parse the content while we should not (like saving the post)
  • ziggeo/trunk/parsers/recorder_parser.php

    r2344999 r2658640  
    9999        'input-bind',
    100100        'form-accept',
    101         'recordings' //this generally tells us that it is recorder, without inspecting value we can not know if it is a rerecorder
     101        'recordings', //this generally tells us that it is recorder, without inspecting value we can not know if it is a rerecorder
     102        'playermodeifexists' // Player is shown however this is added on recorder, to turn recorder into player when exitings
    102103    );
    103104
  • ziggeo/trunk/parsers/rerecorder_parser.php

    r2344999 r2658640  
    4545        'early-rerecord',
    4646        'rerecordable',
     47        'rerecordableifexists',
    4748        'force-overwrite',
    4849        'delete-old-streams'
  • ziggeo/trunk/parsers/template_parser.php

    r2466038 r2658640  
    8383    foreach($tmp_str as $key => $value) {
    8484        $value = trim($value, " \t\n\r\0\x0B".chr(0xC2).chr(0xA0));
    85         if( $value !== '' && $value !== '[' && $value !== '[ziggeo' && $value !== ']' && $value !== '""'&& $value !== '"'
    86             && $value !== 'player' && $value !== 'recorder' && $value !== 'rerecorder') {
     85
     86        if( $value !== '' && $value !== '[' && $value !== '[ziggeo' && $value !== ']' && $value !== '""' &&
     87            $value !== '"' && $value !== 'player' && $value !== 'recorder' && $value !== 'rerecorder') {
    8788
    8889            //@TODO
     
    9697            }
    9798            else {
     99                // This part makes it not support the boolean parameters (which seems not needed, leaving for now, will be removed in future)
    98100                $tmp_str2 .= ' ' . $value;
    99101            }
  • ziggeo/trunk/readme.txt

    r2466038 r2658640  
    33Tags: video, video service, record video, video playback, gallery, ziggeo
    44Requires at least: 3.0.1
    5 Tested up to: 5.6
    6 Stable tag: 2.8
     5Tested up to: 5.8.3
     6Stable tag: 2.12
    77License: GPLv2 or later
    88Requires PHP: 5.2.4
     
    265265== Upgrade notice ==
    266266
    267 = 2.8 =
    268 * Fix: Toolbar buttons showing up again
    269 * Fix: Some CSS errors were failing silently, these are now fixed.
    270 * Improvement: Handling of parameters that accept custom text is now better
    271 * Improvement: Changed the way the code parsing is done allowing the templates to be picked up on faster
    272 * Improvement: Parsing templates by template ID has been improved
     267= 2.12 =
     268Improved: The comments integration is now disabled by default (on new installs) and allows everyone to disable our plugin from outputting any codes to the comments unless you want it to. This adds additional support for custom handling in various themes you might be using.
    273269
    274270== Changelog ==
  • ziggeo/trunk/templates/comments_video_required.php

    r2306416 r2658640  
    117117            ziggeo_app.embed_events.on("verified", function (embedding) {
    118118
    119                 var ziggeoToken = document.getElementById('ziggeo_video_token');
     119                var ziggeo_token = document.getElementById('ziggeo_video_token');
    120120                <?php
    121121                if($template_player) {
    122122                    ?>
    123123                        //Lets add the default value into the box
    124                         ziggeoToken.value = '<?php echo $template_player ?>';
     124                        ziggeo_token.value = '[ziggeoplayer ' + '<?php echo $template_player ?>';
    125125                        //Now we have both the token and the template. We should search the template to see if token="" is present and if so, just insert the video token into quotes, otherwise, we would need to add the token attribute and show it up.
    126                         if( (indexS = ziggeoToken.value.indexOf(' video') ) > -1 ||
    127                             (indexS = ziggeoToken.value.indexOf(' ziggeo-video') ) > -1) {
     126                        if( (indexS = ziggeo_token.value.indexOf(' video') ) > -1 ||
     127                            (indexS = ziggeo_token.value.indexOf(' ziggeo-video') ) > -1) {
    128128
    129129                            //Lets grab the ending as well
    130                             var indexE = ziggeoToken.value.indexOf(' ', indexS);
    131                             ziggeoToken.value = ziggeoToken.value.substr(0, indexS) + ' video="' + embedding.get('video') + '"' + ziggeoToken.value.substr(index + indexE + 2)
     130                            var indexE = ziggeo_token.value.indexOf(' ', indexS);
     131                            ziggeo_token.value = ziggeo_token.value.substr(0, indexS) + ' video="' + embedding.get('video') + '"' + ziggeo_token.value.substr(index + indexE + 2)
     132                        }
     133                        else {
     134                            ziggeo_token.value += ' ziggeo-video="' + embedding.get('video') + '" ]';
    132135                        }
    133136                    <?php
     
    136139                elseif( !empty($template_player) ) {
    137140                    ?>
    138                     ziggeoToken.value = '[ziggeoplayer <?php echo $template_player; ?> video="' + embedding.get('video') + '" ]';
     141                    ziggeo_token.value = '[ziggeoplayer <?php echo $template_player; ?> video="' + embedding.get('video') + '" ]';
    139142                    <?php
    140143                    //[ziggeo ziggeo-width=480 ziggeo-height=360 video="token" ]
     
    143146                else {
    144147                    ?>
    145                     ziggeoToken.value = '[ziggeoplayer]' + embedding.get('video') + '[/ziggeoplayer]';
     148                    ziggeo_token.value = '[ziggeoplayer]' + embedding.get('video') + '[/ziggeoplayer]';
    146149                    <?php
    147150                }
  • ziggeo/trunk/ziggeo.php

    r2466038 r2658640  
    55Description: Plugin for adding videos to your website quickly and easily. It is powered by Ziggeo and allows you to add video posts and video comments and so much more.
    66Author: Ziggeo
    7 Version: 2.8
     7Version: 2.12
    88Author URI: https://ziggeo.com
    99Text Domain: ziggeo
     
    3131
    3232//plugin version - this way other plugins can get it as well and we will be updating this file for each version change as is
    33 define('ZIGGEO_VERSION', '2.8');
     33define('ZIGGEO_VERSION', '2.12');
    3434
    3535//Best to state default code in one location, then just call for it when needed.
     
    113113    }
    114114
     115    //For SDK AJAX options, so we only add them if we are on admin side
     116    if(file_exists(ZIGGEO_ROOT_PATH . 'sdk/Ziggeo.php')) {
     117        include_once(ZIGGEO_ROOT_PATH . '/admin/page_sdk_ajax.php');
     118    }
     119
     120    include_once(ZIGGEO_ROOT_PATH . 'admin/page_editor_events_ajax.php');
    115121}
    116122
Note: See TracChangeset for help on using the changeset viewer.