diff --git a/konamicode.admin.inc b/konamicode.admin.inc index 46b048c..ebe1ef4 100644 --- a/konamicode.admin.inc +++ b/konamicode.admin.inc @@ -186,3 +186,122 @@ function konamicode_konamicode_snowfall_settings() { ); return $form; } + +/** + * Implements hook_konamicode_BROWSERPONIES_settings(). + */ +function konamicode_konamicode_browserponies_settings() { + $form['konamicode_browserponies_baseurl'] = array( + '#type' => 'textfield', + '#title' => t('Base URL'), + '#description' => t('Base URL of the Browser Ponies files'), + '#default_value' => variable_get('konamicode_browserponies_baseurl', 'http://panzi.github.io/Browser-Ponies'), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_showLoadProgress'] = array( + '#type' => 'checkbox', + '#title' => t('Show Download Progress Bar'), + '#default_value' => variable_get('konamicode_browserponies_showLoadProgress', true), + ); + + $form['konamicode_browserponies_fadeDuration'] = array( + '#type' => 'textfield', + '#title' => t('Fade Duration'), + '#description' => t('Amount of time in milliseconds for the ponies to appear on the screen'), + '#default_value' => variable_get('konamicode_browserponies_fadeDuration', 500), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_audioEnabled'] = array( + '#type' => 'checkbox', + '#title' => t('Enable audio if browser supports HTML 5 Audio'), + '#default_value' => variable_get('konamicode_browserponies_audioEnabled', false), + ); + + $form['konamicode_browserponies_volume'] = array( + '#type' => 'textfield', + '#title' => t('Audio Volume'), + '#description' => t('Enter a value between 0 and 1 (eg. 0.1, 0.2, etc)'), + '#default_value' => variable_get('konamicode_browserponies_volume', 1), + ); + + $form['konamicode_browserponies_fps'] = array( + '#type' => 'textfield', + '#title' => t('Frames Per Second'), + '#description' => t('The lower the number, the better the performance'), + '#default_value' => variable_get('konamicode_browserponies_fps', 25), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_showFps'] = array( + '#type' => 'checkbox', + '#title' => t('Show Frames per Second'), + '#default_value' => variable_get('konamicode_browserponies_showFps', false), + ); + + $form['konamicode_browserponies_speed'] = array( + '#type' => 'textfield', + '#title' => t('Speed Multiplier'), + '#description' => t('How fast are these ponies going?'), + '#default_value' => variable_get('konamicode_browserponies_speed', 3), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_speakProbability'] = array( + '#type' => 'textfield', + '#title' => t('Random Speak Probability'), + '#description' => t('Enter a value between 0 and 1 (eg. 0.1, 0.2, etc)'), + '#default_value' => variable_get('konamicode_browserponies_speakProbability', 0.1), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_applejack'] = array( + '#type' => 'textfield', + '#title' => t('Applejack'), + '#description' => t('Enter the number of Applejack ponies on the screen'), + '#default_value' => variable_get('konamicode_browserponies_applejack', 1), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_fluttershy'] = array( + '#type' => 'textfield', + '#title' => t('Fluttershy'), + '#description' => t('Enter the number of Fluttershy ponies on the screen'), + '#default_value' => variable_get('konamicode_browserponies_fluttershy', 1), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_pinkiepie'] = array( + '#type' => 'textfield', + '#title' => t('Pinkiepie'), + '#description' => t('Enter the number of Pinkiepie ponies on the screen'), + '#default_value' => variable_get('konamicode_browserponies_pinkiepie', 1), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_rainbowdash'] = array( + '#type' => 'textfield', + '#title' => t('Rainbowdash'), + '#description' => t('Enter the number of Rainbowdash ponies on the screen'), + '#default_value' => variable_get('konamicode_browserponies_rainbowdash', 1), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_rarity'] = array( + '#type' => 'textfield', + '#title' => t('Rarity'), + '#description' => t('Enter the number of Rarity ponies on the screen'), + '#default_value' => variable_get('konamicode_browserponies_rarity', 1), + '#required' => TRUE, + ); + + $form['konamicode_browserponies_twilightsparkle'] = array( + '#type' => 'textfield', + '#title' => t('Twilight Sparkle'), + '#description' => t('Enter the number of Twilight Sparkle ponies on the screen'), + '#default_value' => variable_get('konamicode_browserponies_twilightsparkle', 1), + '#required' => TRUE, + ); + return $form; +} diff --git a/konamicode.js b/konamicode.js index de5576c..a5f235c 100644 --- a/konamicode.js +++ b/konamicode.js @@ -222,3 +222,15 @@ Drupal.konamicode_gg = function() { } jQuery('#konamicode-gg')[0].play(); }; + +/** + * The Browser Ponies Code action. + */ +Drupal.konamicode_browserponies = function() { + (function (config) { + BrowserPonies.setBaseUrl(Drupal.settings.browserponies.baseurl); + BrowserPonies.loadConfig(BrowserPoniesBaseConfig); + BrowserPonies.loadConfig(config); + }) + (Drupal.settings.browserponies); +}; diff --git a/konamicode.module b/konamicode.module index f940948..4b20536 100644 --- a/konamicode.module +++ b/konamicode.module @@ -128,6 +128,9 @@ function konamicode_konamicode() { // http://www.youtube.com/watch?v=y1x_jq1YTBA 'gg' => t('GG'), + + // https://github.com/panzi/Browser-Ponies + 'browserponies' => t('Browser Ponies'), ); } @@ -228,3 +231,37 @@ function konamicode_konamicode_gg() { ); drupal_add_js($settings, array('type' => 'setting', 'scope' => JS_DEFAULT)); } + +/** + * Implements hook_konamicode_BROWSERPONIES(). + */ +function konamicode_konamicode_browserponies() { + global $base_url; + $path = variable_get('konamicode_browserponies_baseurl', 'http://panzi.github.io/Browser-Ponies'); + $settings = array( + 'browserponies' => array( + 'browserponies' => drupal_get_path('module', 'konamicode'), + 'baseurl' => $path . '/', + 'fadeDuration' => (int)variable_get('konamicode_browserponies_fadeDuration', 500), + 'volume' => (int)variable_get('konamicode_browserponies_volume', 1), + 'fps' => (int)variable_get('konamicode_browserponies_fps', 25), + 'speed' => (int)variable_get('konamicode_browserponies_speed', 3), + 'audioEnabled' => variable_get('konamicode_browserponies_audioEnabled', false), + 'showFps' => variable_get('konamicode_browserponies_showFps', false), + 'showLoadProgress' => variable_get('konamicode_browserponies_showLoadProgress', true), + 'speakProbability' => (int)variable_get('konamicode_browserponies_speakProbability', 0.1), + 'spawn' => array( + 'applejack' => (int)variable_get('konamicode_browserponies_applejack', 1), + 'fluttershy' => (int)variable_get('konamicode_browserponies_fluttershy', 1), + 'pinkie pie' => (int)variable_get('konamicode_browserponies_pinkiepie', 1), + 'rainbow dash' => (int)variable_get('konamicode_browserponies_rainbowdash', 1), + 'rarity' => (int)variable_get('konamicode_browserponies_rarity', 1), + 'twilight sparkle' => (int)variable_get('konamicode_browserponies_twilightsparkle', 1), + ), + 'autostart' => variable_get('konamicode_browserponies_autostart', true), + ), + ); + drupal_add_js($settings, array('type' => 'setting', 'scope' => JS_DEFAULT)); + drupal_add_js($path . '/basecfg.js', 'file'); + drupal_add_js($path . '/browserponies.js', 'file'); +}