Skip to content
Browse files

Handler upgrade

  • Loading branch information...
1 parent dea416c commit 1263ce680e0ae47ff80c771de4c24ae7805a82f7 @jonathantneal jonathantneal committed Feb 16, 2012
Showing with 391 additions and 358 deletions.
  1. +65 −0 agents.json
  2. +160 −237 handler.methods.php
  3. +51 −121 handler.php
  4. +115 −0 keywords.json
View
65 agents.json
@@ -0,0 +1,65 @@
+{
+ "ie": {
+ "name": "Internet Explorer",
+ "prefix": "ms",
+ "type": "desktop",
+ "url": "http:\/\/www.microsoft.com\/windows\/internet-explorer\/",
+ "sniffer": "/msie[\\W\\w]*?([\\d\\.]+)/i"
+ },
+ "firefox": {
+ "name": "Firefox",
+ "prefix": "moz",
+ "type": "desktop",
+ "url": "http:\/\/www.firefox.com\/",
+ "sniffer": "/firefox\\/([\\d\\.]+)/i"
+ },
+ "chrome": {
+ "name": "Chrome",
+ "prefix": "webkit",
+ "type": "desktop",
+ "url": "http:\/\/www.google.com\/chrome",
+ "sniffer": "/chrome\\/([\\d\\.]+)/i"
+ },
+ "safari": {
+ "name": "Safari",
+ "prefix": "webkit",
+ "type": "desktop",
+ "url": "http:\/\/www.apple.com\/safari\/",
+ "sniffer": "/version\\/([\\d\\.]+)[\\W\\w]*?safari/i"
+ },
+ "opera": {
+ "name": "Opera",
+ "prefix": "o",
+ "type": "desktop",
+ "url": "http:\/\/www.opera.com\/",
+ "sniffer": "/opera[\\W\\w]*?version\\/([\\d\\.]+)|opera[\\W\\w]*?([\\d\\.]+)/i"
+ },
+ "ios_saf": {
+ "name": "iOS Safari",
+ "prefix": "webkit",
+ "type": "mobile",
+ "url": "http:\/\/www.apple.com\/iphone\/",
+ "sniffer": "/version\\/([\\d\\.]+)[\\W\\w]*?safari/i"
+ },
+ "op_mini": {
+ "name": "Opera Mini",
+ "prefix": "o",
+ "type": "mobile",
+ "url": "http:\/\/www.opera.com\/mobile\/",
+ "sniffer": "/opera\\s*mobi[\\W\\w]*?version\\/([\\d\\.]+)/i"
+ },
+ "op_mob": {
+ "name": "Opera Mobile",
+ "prefix": "o",
+ "type": "mobile",
+ "url": "http:\/\/www.opera.com\/mobile\/",
+ "sniffer": "/opera\\s*mini[\\W\\w]*?version\\/([\\d\\.]+)/i"
+ },
+ "android": {
+ "name": "Android Browser",
+ "prefix": "webkit",
+ "type": "mobile",
+ "url": "http:\/\/www.android.com\/",
+ "sniffer": "/android\\s*([\\d\\.]+)/i"
+ }
+}
View
397 handler.methods.php
@@ -4,6 +4,10 @@
Helper Methods
========================================================================== */
+function is_function() {
+ return reset(array_filter(func_get_args(), 'is_callable'));
+}
+
function is_set($val = undefined) {
return isset($val);
}
@@ -25,334 +29,268 @@ function first_match($pattern = '', $subject = '', $else_string = null) {
return first_set_in_array($matches);
}
-function get_file_json($filename = '', $assoc = true) {
- return json_decode(file_get_contents($filename), $assoc);
+function array_unset(& $array = array(), $propertyList = array()) {
+ foreach ($propertyList as $property) {
+ unset($array[$property]);
+ }
}
-function get_cached_array($array_string = '', $requested_features_array = array()) {
- $json_filename = 'data.json';
- if ($array_string === 'support') {
- $array_filename = 'cache/' . $array_string . '-' . implode('_', $requested_features_array) . '.php';
- } elseif ($array_string === 'features') {
- $array_filename = 'cache/' . $array_string . '-' . implode('_', $requested_features_array) . '.php';
- } else {
- $array_filename = 'cache/' . $array_string . '.php';
- }
+function file_get_json($filename = '', $associative = true) {
+ return json_decode(file_get_contents($filename), $associative);
+}
+
+function file_put_php($filename = '', $php_string = '') {
+ file_put_contents($filename, '<?php' . "\n\n" . $php_string . "\n\n" . '?>');
+}
+
+function file_set_array($filename = '', & $array = array(), $array_name = 'array') {
+ file_put_php($filename, '$' . $array_name . ' = ' . var_export($array, true) . ';');
+}
- $json_filetime = @filemtime($json_filename);
- $array_filetime = @filemtime($array_filename);
+function file_get_cached_json($json_filename = '', $json_fn = null, $rebuild = false) {
+ $php_filename = 'cache/' . $json_filename . '.php';
- $array_function = 'get_' . $array_string . '_array';
+ $json_filetime = @filemtime($json_filename);
+ $php_filetime = @filemtime($php_filename);
- if ($json_filetime != $array_filetime) {
- $json_array = get_file_json($json_filename);
+ if ($json_filetime !== $php_filetime || $rebuild) {
+ $json_array = @file_get_json($json_filename);
- $array_array = $array_function($json_array, $requested_features_array);
+ if ($json_fn) {
+ $json_array = $json_fn($json_array);
+ }
- file_put_contents($array_filename, '<?php $array_array = ' . var_export($array_array, true) . '; ?>');
+ file_set_array($php_filename, $json_array, 'json_array');
- touch($array_filename, $json_filetime);
+ touch($php_filename, $json_filetime);
} else {
- include $array_filename;
+ include $php_filename;
}
- return $array_array;
+ return $json_array;
}
-function readable_json( $jsonString)
-{
+function json_readable($json = null) {
$tabcount = 0;
- $result = '';
+ $return = '';
$inquote = false;
$tab = "\t";
$newline = "\n";
- for ($i = 0; $i < strlen($jsonString); $i++) {
- $char = $jsonString[$i];
+ $json = is_string($json) ? $json : json_encode($json);
- if ($char == '"' && $jsonString[ $i-1] != '\\') {
+ for ($i = 0; $i < strlen($json); $i++) {
+ $char = $json[$i];
+
+ if ($char == '"' && $json[ $i-1] != '\\') {
$inquote = !$inquote;
}
if ($inquote) {
- $result .= $char;
+ $return .= $char;
continue;
}
switch ($char) {
case '{':
- if ($i) $result .= $newline;
- $result .= str_repeat($tab, $tabcount) . $char . $newline . str_repeat( $tab, ++$tabcount);
- break;
+ if ($i) {
+ $return .= $newline;
+ }
+
+ $return .= str_repeat($tab, $tabcount) . $char . $newline . str_repeat( $tab, ++$tabcount);
- case '}':
- $result .= $newline . str_repeat( $tab, --$tabcount) . $char;
break;
+ case '}':
+ $return .= $newline . str_repeat( $tab, --$tabcount) . $char;
- case ',':
- $result .= $char;
- if( $jsonString[ $i+1] != '{') $result .= $newline . str_repeat($tab, $tabcount);
break;
+ case ',':
+ $return .= $char;
+
+ if ($json[ $i+1] != '{') {
+ $return .= $newline . str_repeat($tab, $tabcount);
+ }
- case ':':
- $result .= $char . ' ';
break;
+ case ':':
+ $return .= $char . ' ';
+ break;
default:
- $result .= $char;
+ $return .= $char;
}
}
- return $result;
+ return $return;
}
-
-
/* =============================================================================
- Get Keywords Array
+ Filters
========================================================================== */
-function get_keywords_array(&$json_array = array()) {
- $return_array = $json_array['keywords'];
+// returns filtered data from data.json
+
+function filter_datajson(& $json_array) {
+ $array =& $json_array['data'];
- foreach ($return_array as $keyword_name => &$keyword_words) {
- $return_array[$keyword_name] = '/^(' . preg_replace('/ /', 's*|', $keyword_words) . 's*)$/';
+ foreach ($array as & $value) {
+ $value['partial'] = filter_datajsonstats($value['stats'], '/[ay]/');
+ $value['supported'] = filter_datajsonstats($value['stats'], '/y/');
+
+ array_unset($value, explode(' ', 'keywords categories description links spec notes stats status usage_perc_y usage_perc_a'));
}
- return $return_array;
+ return $array;
}
-function filter_features_array(&$requested_features_array, &$keywords_array) {
- $return_array = array();
+// returns filtered stats from data.json stats
- foreach ($requested_features_array as $requested_feature_name) {
- $requested_feature_name = strtolower($requested_feature_name);
+function filter_datajsonstats($array = array(), $filter = '') {
+ foreach ($array as $agent_name =>& $agent_array) {
+ foreach ($agent_array as $agent_version =>& $agent_support) {
+ if (preg_match($filter, $agent_support)) {
+ $array[$agent_name] = $agent_version;
- if (isset($keywords_array[$requested_feature_name])) {
- array_push($return_array, $requested_feature_name);
- } else {
- $requested_feature_name = preg_replace('/[-_]/', '', $requested_feature_name);
-
- foreach ($keywords_array as $keyword_name =>& $keyword_words) {
- if (preg_match($keyword_words, $requested_feature_name)) {
- array_push($return_array, $keyword_name);
- }
+ break 1;
}
}
- }
- $return_array = array_unique($return_array);
+ if (is_array($array[$agent_name])) {
+ unset($array[$agent_name]);
+ }
+ }
- return $return_array;
+ return $array;
}
+// returns filtered keywords from keywords.json
-
-/* =============================================================================
- Get Agents Array
- ========================================================================== */
-
-function get_agents_array(&$json_array = array()) {
+function filter_keywords(& $json_array) {
$return_array = array();
- $agents_array =& $json_array['agents'];
-
- foreach ($agents_array as $agentid_string => &$agent_array) {
- $return_array[$agentid_string] = $agent_array;
- unset($return_array[$agentid_string]['abbr']);
- unset($return_array[$agentid_string]['versions']);
+ foreach ($json_array as $keyword_name => &$keyword_words) {
+ $return_array[$keyword_name] = '/^(' . preg_replace('/ /', '[s]*|', $keyword_words) . '[s]*)$/';
}
return $return_array;
}
+// returns filtered features from successful searches in keywords
+function filter_features(& $request_features_array = array(), & $keywords_array = array()) {
+ $return_array = array();
-/* =============================================================================
- Get Features Array
- ========================================================================== */
+ foreach ($request_features_array as $request_feature_name) {
+ $request_feature_name = strtolower($request_feature_name);
-function get_features_array(&$json_array = array(), &$requested_features_array = array()) {
- $return_array = array();
- $data_array = &$json_array['data'];
+ if (isset($keywords_array[$request_feature_name])) {
+ array_push($return_array, $request_feature_name);
+ } else {
+ $request_feature_name = preg_replace('/[^A-z0-9]/', '', $request_feature_name);
- if ($requested_features_array) {
- foreach ($requested_features_array as $feature_string) {
- if (isset($data_array[$feature_string])) {
- $return_array[$feature_string] = $data_array[$feature_string]['title'];
- } else {
- return;
+ foreach ($keywords_array as $keyword_name =>& $keyword_words) {
+ if (preg_match($keyword_words, $request_feature_name)) {
+ array_push($return_array, $keyword_name);
+ }
}
}
}
+ $return_array = array_unique($return_array);
+
return $return_array;
}
+// returns filtered support metrics from features, agents, and data
-
-/* =============================================================================
- Get Support Array
- ========================================================================== */
-
-function get_support_array($json_array = array(), &$requested_features_array = array()) {
- $agents_array =& $json_array['agents'];
- $data_array =& $json_array['data'];
-
- $agentslist_array = array(
- 'ie' => true,
- 'firefox' => true,
- 'chrome' => true,
- 'safari' => true,
- 'opera' => true,
- 'ios_saf' => true,
- 'op_mini' => true,
- 'op_mob' => true,
- 'android' => true
- );
-
+function filter_supportmetrics(& $option_features = array(), $agents_array = array(), & $data_array = array()) {
$return_array = array(
- 'byFeature' => array(),
- 'byAgent' => array(),
- 'agents' => array(),
- 'agentsProper' => array()
+ 'agents' =>& $agents_array,
+ 'features' => array(),
+ 'results' => array(),
+ 'result' => array()
);
- $error_array = array();
-
- $return_by_feature_array =& $return_array['byFeature'];
- $return_by_agent_array =& $return_array['byAgent'];
- $return_agents_array =& $return_array['agents'];
- $return_agents_proper_array =& $return_array['agentsProper'];
-
- foreach ($requested_features_array as &$feature_string) {
- $feature_array = @$data_array[$feature_string];
- $stats_array = @$feature_array['stats'];
-
- if ($stats_array) {
- $return_by_feature_array[$feature_string] = array();
-
- foreach ($stats_array as $agentid_string => $agentstats_array) {
- $agent_array = $agents_array[$agentid_string];
- $agent_name_string = $agent_array['name'];
- $version = get_agent_support_array($agentstats_array);
-
- if ($version) {
- $return_by_feature_array[$feature_string][$agentid_string] = $version;
- $return_by_agent_array[$agentid_string][$feature_string] = $version;
-
- if ($agentslist_array[$agentid_string]) {
- $return_agents_array[$agentid_string] = (version_compare(
- @$return_agents_array[$agentid_string],
- $version
- ) < 1) ? $version : @$return_agents_array[$agentid_string];
- $return_agents_proper_array[$agent_name_string] = $return_agents_array[$agentid_string];
- }
- } else {
- $agentslist_array[$agentid_string] = false;
- unset($return_agents_array[$agentid_string]);
- unset($return_agents_proper_array[$agent_name_string]);
- }
- }
- } else {
- array_push($error_array, $feature_string);
- }
+ foreach ($agents_array as & $agent_array) {
+ unset($agent_array['sniffer']);
}
- if (!empty($error_array)) {
- return array('supported' => false, 'error' => $error_array);
- } else {
- return $return_array;
- }
-}
+ foreach ($option_features as $feature_name) {
+ $property_array = first_set(@$data_array[$feature_name]['supported'], array());
-function get_agent_support_array($agent_stats_array = array()) {
- foreach ($agent_stats_array as $version => $supported) {
- if (preg_match('/[py]/', $supported)) {
- return $version;
- }
- }
+ $return_array['result'][$feature_name] = $property_array;
- return false;
-}
+ $return_array['features'][$feature_name] = $data_array[$feature_name]['title'];
+ $all_array =& $return_array['results'];
+ foreach ($agents_array as $agent_name =>& $unused_array) {
+ $agent_array = @$property_array[$agent_name];
-/* =============================================================================
- Get Unsupported Array
- ========================================================================== */
-
-function get_unsupported_array(&$support_array = array(), &$user_agent_array = array()) {
- $return_array = array();
-
- if ($support_array && @$support_array['byFeature']) {
- foreach($support_array['byFeature'] as $feature_string => &$feature_array) {
- if (
- !isset($feature_array[$user_agent_array['id']]) ||
- version_compare(@$feature_array[$user_agent_array['id']], @$user_agent_array['version']) > -1
- ) {
- array_push($return_array, $feature_string);
+ if ($agent_array) {
+ $all_array[$agent_name] = (version_compare(@$all_array[$agent_name], @$agent_array) < 1) ? $agent_array : $all_array[$agent_name];
+ } else {
+ unset($return_array['agents'][$agent_name]);
+ unset($agents_array[$agent_name]);
+ unset($all_array[$agent_name]);
}
}
- } else {
- return;
}
return $return_array;
}
+// returns filtered options from the get method
+
+function filter_options() {
+ // Set array
+ $array = array();
+ $key = 'option_';
+
+ // Set variables
+ $array[$key . 'callback'] = @$_GET['callback'];
+ $array[$key . 'features'] = explode(' ', @$_GET['features']);
+ $array[$key . 'format'] = first_match('/(html|js|json|php|xml)/', @$_GET['format'], 'js');
+ $array[$key . 'readable'] = isset($_GET['readable']);
+ $array[$key . 'noagent'] = isset($_GET['noagent']);
+ $array[$key . 'noagents'] = isset($_GET['noagents']);
+ $array[$key . 'nofeatures'] = isset($_GET['nofeatures']);
+ $array[$key . 'nocss'] = isset($_GET['nocss']);
+ $array[$key . 'noresult'] = isset($_GET['noresult']);
+ $array[$key . 'noresults'] = isset($_GET['noresults']);
+ $array[$key . 'style'] = (
+ isset($_GET['texticon']) || (isset($_GET['text']) && isset($_GET['icon'])) ? 'texticon' : (
+ isset($_GET['icon']) ? 'icon' : (
+ isset($_GET['text']) ? 'text' : 'button'
+ )
+ )
+ );
+ $array[$key . 'barebones'] = isset($_GET['barebones']);
+ return $array;
+}
-/* =============================================================================
- Get User Agent Array
- ========================================================================== */
+// returns user agent details
-function get_user_agent_array($agents_array) {
+function filter_useragent(& $agents_array) {
$user_agent_string = $_SERVER['HTTP_USER_AGENT'];
+ $return_array = array();
foreach($agents_array as $agent_string => &$agent_array) {
$agent_sniffer = $agent_array['sniffer'];
$agent_boolean = preg_match($agent_sniffer, $user_agent_string, $agent_matches);
if ($agent_boolean) {
- $return_array = $agent_array;
- $return_array['version'] = first_set(@$agent_matches[1], @$agent_matches[2]);
- $return_array['id'] = $agent_string;
-
- unset($return_array['prefix']);
- unset($return_array['sniffer']);
-
- return $return_array;
- }
- }
-}
-
-
-
-/* =============================================================================
- Get Alternatives Array
- ========================================================================== */
+ unset($agents_array[$agent_string]['sniffer']);
-function get_alternatives_array(&$agents_array = array(), &$support_array = array(), &$user_agent_array = array()) {
- $return_array = array();
- $user_agent_id_string = $user_agent_array['id'];
- $user_agent_type_string = $user_agent_array['type'];
-
- if (isset($support_array['agents'])) {
- foreach ($support_array['agents'] as $agent_string => &$agent_version) {
- if ($user_agent_id_string !== $agent_string && $user_agent_type_string === $agents_array[$agent_string]['type']) {
- $return_array[$agent_string] = $agents_array[$agent_string];
- $return_array[$agent_string]['version'] = $agent_version;
-
- unset($return_array[$agent_string]['prefix']);
- unset($return_array[$agent_string]['sniffer']);
- unset($return_array[$agent_string]['type']);
- }
+ $return_array = array_merge(
+ array('id' => $agent_string),
+ $agent_array,
+ array('version' => first_set(@$agent_matches[1], @$agent_matches[2]))
+ );
}
- } else {
- return;
}
return $return_array;
@@ -361,21 +299,6 @@ function get_alternatives_array(&$agents_array = array(), &$support_array = arra
/* =============================================================================
- Get Upgradable Array
- ========================================================================== */
-
-function get_upgradable_array(&$support_array = array(), $user_agent_array = array()) {
- $return_array = $user_agent_array;
-
- unset($return_array['type']);
- unset($return_array['version']);
-
- return !!@$support_array['agents'][$user_agent_array['id']] ? $return_array : false;
-}
-
-
-
-/* =============================================================================
HTML Encode
========================================================================== */
@@ -463,8 +386,8 @@ function html_encode(&$return_array = array(), $requested_style_string = '', $re
$html = preg_replace('/\s*<% unsupported %>|<% \/unsupported %>/', '', $html);
}
- $html = preg_replace('/<%= browserid %>/', $return_array['current']['id'], $html);
- $html = preg_replace('/<%= browserurl %>/', $return_array['current']['url'], $html);
+ $html = preg_replace('/<%= browserid %>/', $return_array['agent']['id'], $html);
+ $html = preg_replace('/<%= browserurl %>/', $return_array['agent']['url'], $html);
$html = preg_replace('/<%= alternatives %>/', html_encode_agents($return_array['alternatives'], $requested_style_string), $html);
$html = preg_replace('/<%= features %>/', html_encode_features($return_array), $html);
View
172 handler.php
@@ -1,156 +1,86 @@
<?php
-require_once 'handler.methods.php';
+include 'handler.methods.php';
/* =============================================================================
- Requests
+ Main
========================================================================== */
-// Get Requested Agent Boolean
-$requested_agent_boolean = !isset($_GET['noagent']);
-
-// Get Requested Callback String
-$requested_callback_string = @$_GET['callback'];
-
-// Get Requested Features List
-$requested_features_array = explode(' ', @$_GET['features']);
-
-// Get Requested Format String
-$requested_format_string = first_match('/(html|js|json|php|xml)/', @$_GET['format'], 'js');
+extract(filter_options());
-// Get Requested Pretty Boolean
-$requested_readable_boolean = isset($_GET['readable']);
+$agents_array = file_get_cached_json('agents.json', null);
+$data_array = file_get_cached_json('data.json', 'filter_datajson');
+$keywords_array = file_get_cached_json('keywords.json', 'filter_keywords');
-// Get Requested Style Boolean
-$requested_style_boolean = !isset($_GET['nostyle']);
+$option_features = filter_features($option_features, $keywords_array);
-// Get Requested Style String
-$requested_style_string = (
- isset($_GET['texticon']) ? 'texticon' : (
- isset($_GET['text']) ? 'text' : (
- isset($_GET['icon']) ? 'icon' : 'button'
- )
- )
-);
+$support_array = filter_supportmetrics($option_features, $agents_array, $data_array, 'supported');
-// Get Supported CSS Boolean
-$requested_support_boolean = isset($_GET['supported']);
+if (!$option_noagent) {
+ $useragent_array = filter_useragent($agents_array);
+ $support_array['agent'] = $useragent_array;
+ $support_array['supported'] = isset($support_array['results'][$useragent_array['id']]) && version_compare($useragent_array['version'], $support_array['results'][$useragent_array['id']]) > -1;
-/* =============================================================================
- Main
- ========================================================================== */
+ $support_array['upgradable'] = !$support_array['supported'] && isset($support_array['results'][$useragent_array['id']]);
-// Get JSON Arrays
-$keywords_array = get_cached_array('keywords', $requested_features_array);
-
-$requested_features_array = filter_features_array($requested_features_array, $keywords_array);
-
-$agents_array = get_cached_array('agents', $requested_features_array);
-$support_array = get_cached_array('support', $requested_features_array);
-$features_array = get_cached_array('features', $requested_features_array);
-
-// If user agent information is requested
-if ($requested_agent_boolean) {
- // Get User Agent Array
- $user_agent_array = get_user_agent_array($agents_array);
-
- // Get Extended Arrays
- $alternatives_array = get_alternatives_array($agents_array, $support_array, $user_agent_array);
- $upgradable_array = get_upgradable_array($support_array, $user_agent_array);
- $unsupported_array = get_unsupported_array($support_array, $user_agent_array);
-
- // Get Supporting Variables
- $supported_string = @$support_array['agents'][$user_agent_array['id']];
- $supported_boolean = $supported_string && version_compare($supported_string, $user_agent_array['version']) < 1;
- $error_boolean = isset($support_array['error']);
-
- // Set Return Array
- if (!$error_boolean) {
- if ($requested_support_boolean) {
- $return_array = array('supported' => $supported_boolean);
- } else {
- $return_array = array('features' => $features_array, 'current' => $user_agent_array, 'supported' => $supported_boolean);
- }
- } else {
- $return_array = $support_array;
+ if ($option_barebones) {
+ $support_array = array(
+ 'supported' => $support_array['supported'],
+ 'upgradable' => $support_array['upgradable']
+ );
}
+}
- // Extend Return Array
- if ($supported_boolean && !$requested_support_boolean) {
- $return_array['alternatives'] = $alternatives_array;
- } else if (!$error_boolean && !$requested_support_boolean) {
- if (isset($upgradable_array)) {
- $return_array['upgradable'] = $upgradable_array;
- }
+if ($option_noagents) {
+ unset($support_array['agents']);
+}
- $return_array['unsupported'] = $unsupported_array;
- $return_array['alternatives'] = $alternatives_array;
- }
-} else {
- $return_array = array('features' => $features_array, 'support' => $support_array);
+if ($option_nofeatures) {
+ unset($support_array['features']);
}
+if ($option_noresult) {
+ unset($support_array['result']);
+}
-// Ouput
-if ($requested_format_string === 'js' && $requested_callback_string) {
- $return_string = json_encode($return_array);
+if ($option_noresults) {
+ unset($support_array['results']);
+}
- if ($requested_readable_boolean) {
- $return_string = readable_json($return_string);
+if ($option_format === 'js' || $option_format === 'json' || $option_callback) {
+ if ($option_format === 'json' && !$option_callback) {
+ header('Content-Type: text/json');
+ } else {
+ header('Content-Type: text/javascript');
}
- header('Content-Type: text/javascript');
-
- exit($requested_callback_string . '(' . $return_string . ')');
-} elseif ($requested_format_string === 'js') {
- $return_string = json_encode($return_array);
-
- if ($requested_readable_boolean) {
- $return_string = readable_json($return_string);
+ if ($option_format === 'html') {
+ $support_array['html'] = '<html></html>';
}
- header('Content-Type: text/javascript');
-
- exit($return_string);
-} elseif ($requested_format_string === 'html' && $requested_callback_string) {
- $html = html_encode($return_array, $requested_style_string);
-
- $return_array['html'] = $html;
-
- $return_string = json_encode($return_array);
+ $string = json_encode($support_array);
- if ($requested_readable_boolean) {
- $return_string = readable_json($return_string);
+ if ($option_readable) {
+ $string = json_readable($support_array);
}
- header('Content-Type: text/javascript');
-
- exit($requested_callback_string . '(' . $return_string . ')');
-} elseif ($requested_format_string === 'html') {
-
- $html = html_encode($return_array, $requested_style_string, $requested_style_boolean);
-
- $html_container = file_get_contents('tpl/html.html');
-
- $html_container = preg_replace('/<%= title %>/', 'Can I Use API', $html_container);
- $html_container = preg_replace('/<%= content %>/', $html, $html_container);
-
- header('Content-Type: text/html');
-
- print($html_container);
+ if ($option_callback) {
+ $string = $option_callback . '(' . $string . ')';
+ }
+} else if ($option_format === 'html') {
+ print_r($support_array);
exit();
-} elseif ($requested_format_string === 'php') {
- header('Content-Type: text/plain');
+ header('Content-Type: text/html');
- exit('<?php' . "\n\n" . '$response = ' . var_export($return_array, true) . ';' . "\n\n" . '?>');
-} elseif ($requested_format_string === 'xml') {
+ $string = html_encode($support_array, $option_style, !$option_nocss);
+} else if ($option_format === 'xml') {
header('Content-Type: text/xml');
- $xml = xml_encode($return_array);
-
- exit($xml);
+ $string = xml_encode($support_array);
}
+exit($string);
+
?>
View
115 keywords.json
@@ -0,0 +1,115 @@
+{
+ "png-alpha": "32bitpng 32png alphapng alphatransparentpng png32 pngrgba pngtransparent rgbapng transparentpng",
+ "apng": "animatedpng apng pnganimated pnganimation",
+ "video": "video videoelement videotag",
+ "audio": "audio audioelement audiotag",
+ "contenteditable": "contenteditable editable editablecontent editablehtml htmleditable",
+ "dragndrop": "drag draganddrop dragdrop dragndrop drop dropanddrag dropndrag",
+ "queryselector": "javascriptselector jsselector selector selectorall queryselector queryselectorall",
+ "getelementsbyclassname": "byclass byclassname classname elementsbyclassname getelementsbyclassname",
+ "forms": "html5form htmlform webform",
+ "html5semantic": "html5element newelement",
+ "offline-apps": "offlineapp",
+ "webworkers": "webworker worker",
+ "fontface": "fontface webfont",
+ "eot": "eot",
+ "woff": "woff",
+ "multibackgrounds": "multibackground multiplebackground",
+ "border-image": "borderimage",
+ "background-img-opts": "backgroundimgopt",
+ "css-table": "csstable displaytable table tabledisplay",
+ "css-gencontent": "cssgencontent",
+ "css-fixed": "cssfixed fixed posfixed positionfixed",
+ "hashchange": "hash hashchange hashchangeevent hashevent onhashchange onhashchangeevent onhashevent",
+ "css-sel2": "csssel2",
+ "css-sel3": "csssel3",
+ "css-textshadow": "csstextshadow",
+ "css-boxshadow": "cssboxshadow",
+ "css3-colors": "css3colors rgba rgbacolors",
+ "css3-boxsizing": "boxsizing css3boxsizing",
+ "css-mediaqueries": "cssmediaqueries mediaqueries mediaquery",
+ "multicolumn": "multicolumn",
+ "border-radius": "borderradius",
+ "transforms2d": "transforms2d",
+ "use-strict": "usestrict",
+ "transforms3d": "transforms3d",
+ "sharedworkers": "sharedworkers",
+ "css-hyphens": "csshyphens",
+ "css-transitions": "csstransitions",
+ "font-feature": "fontfeature",
+ "css-animation": "cssanimation",
+ "css-gradients": "cssgradients",
+ "css-canvas": "csscanvas",
+ "css-reflections": "cssreflections",
+ "css-masks": "cssmasks",
+ "svg": "svg",
+ "svg-css": "svgcss",
+ "svg-smil": "svgsmil",
+ "svg-fonts": "svgfonts",
+ "svg-filters": "svgfilters",
+ "svg-html": "svghtml",
+ "svg-html5": "svghtml5",
+ "canvas": "canvas canvaselement",
+ "canvas-text": "canvastext",
+ "namevalue-storage": "namevaluestorage",
+ "sql-storage": "sqlstorage",
+ "indexeddb": "indexeddb",
+ "eventsource": "eventsource",
+ "x-doc-messaging": "xdocmessaging",
+ "datauri": "datauri",
+ "mathml": "mathml",
+ "xhtml": "xhtml",
+ "xhtmlsmil": "xhtmlsmil",
+ "wai-aria": "waiaria",
+ "geolocation": "geolocation",
+ "flexbox": "flexbox",
+ "webgl": "webgl",
+ "fileapi": "fileapi",
+ "websockets": "websocket socket",
+ "script-async": "scriptasync",
+ "cors": "cors",
+ "calc": "calc",
+ "ruby": "ruby",
+ "css-opacity": "cssopacity opacity alphatransparency",
+ "form-validation": "formvalidation",
+ "history": "history historyjs",
+ "json": "javascriptobjectnotation json",
+ "classlist": "classlist classobject domtokenlist tokenlist",
+ "text-overflow": "ellipsis overflow textoverflow",
+ "webm": "webm",
+ "mpeg4": "h264 aac avc m4a m4v mp4 mpg mpgvideo mpeg4 mpeg4video mpv",
+ "ogv": "ogv oggvideo",
+ "wordwrap": "wordwrap",
+ "progressmeter": "progressmeter",
+ "object-fit": "objectfit",
+ "xhr2": "xhr2",
+ "minmaxwh": "minmaxwh",
+ "details": "details",
+ "text-stroke": "textstroke",
+ "inline-block": "blockinline inlineblock ib",
+ "notifications": "notifications",
+ "stream": "stream",
+ "svg-img": "svgimg",
+ "datalist": "datalist",
+ "dataset": "dataset",
+ "css-grid": "cssgrid grid",
+ "menu": "menu",
+ "rem": "rem",
+ "ttf": "truetype truetypefont ttf",
+ "touch": "touch touchend touchevent touchmove touchstart ontouchend ontouchevent ontouchmove ontouchstart",
+ "matchesselector": "matchesselector",
+ "pointer-events": "pointerevents",
+ "blobbuilder": "blobbuilder",
+ "filereader": "filereader",
+ "filesystem": "filesystem",
+ "bloburls": "bloburls",
+ "typedarrays": "typedarrays",
+ "deviceorientation": "deviceorientation",
+ "script-defer": "scriptdefer",
+ "nav-timing": "navtiming",
+ "audio-api": "audioapi audiojavascript audiojs",
+ "css-regions": "region",
+ "fullscreen": "fullscreen",
+ "requestanimationframe": "requestanimationframe",
+ "matchmedia": "matchmedia"
+}

0 comments on commit 1263ce6

Please sign in to comment.
Something went wrong with that request. Please try again.