mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-03-16 22:10:25 +00:00
Merge branch 'master' of https://github.com/jquery/jquery-mobile
This commit is contained in:
commit
ac8a7c7cb9
13 changed files with 153 additions and 57 deletions
15
Makefile
15
Makefile
|
|
@ -111,15 +111,12 @@ docs: init css js
|
|||
# ... Update the JavaScript and CSS paths
|
||||
@@find tmp/${NAME} -type f \
|
||||
\( -name '*.html' -o -name '*.php' \) \
|
||||
-exec sed -i '' 's|js/"|${NAME}.min.js"|g' {} \; \
|
||||
-exec sed -i '' 's|css/themes/default/|${NAME}.min.css|g' {} \; \
|
||||
-exec sed -i '' 's|js/jquery.js"|jquery.js"|g' {} \;
|
||||
# ... And then move it the finished directory
|
||||
-exec perl -pi -e \
|
||||
's|js/"|${NAME}.min.js"|g;s|css/themes/default/|${NAME}.min.css|g;s|js/jquery.js"|jquery.js"|g' {} \;
|
||||
# ... Move and zip up the the whole folder
|
||||
@@zip -rq ${OUTPUT}/${NAME}.docs.zip tmp/${NAME}
|
||||
@@mv tmp/${NAME} ${OUTPUT}/demos
|
||||
# Last, zip up the the whole folder
|
||||
@@zip -rq tmp/${NAME}.zip ${OUTPUT}
|
||||
@@mv tmp/${NAME}.zip ${OUTPUT}/${NAME}.docs.zip
|
||||
# Remove the temporary files
|
||||
# Finish by removing the temporary files
|
||||
@@rm -rf tmp
|
||||
# -------------------------------------------------
|
||||
|
||||
|
|
@ -182,7 +179,7 @@ nightlies: init js css zip docs
|
|||
# Time to put these on the CDN
|
||||
@@mkdir -p tmp/nightlies
|
||||
@@mv ${OUTPUT} tmp/nightlies/$$(date "+%Y%m%d")
|
||||
@@scp -r nightlies/* jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/nightlies/
|
||||
@@scp -r tmp/nightlies/* jqadmin@code.origin.jquery.com:/var/www/html/code.jquery.com/mobile/nightlies/
|
||||
# Do some cleanup to wrap it up
|
||||
@@rm -rf tmp
|
||||
# -------------------------------------------------
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -15,6 +15,16 @@ Clone this repo and build the js and css files (you'll need Git and Make install
|
|||
A full version and a minified version of the jQuery Mobile JavaScript and CSS files will be created
|
||||
in a folder named "compiled". There is also now a Structure only css file so you can add your own theme on top of it.
|
||||
|
||||
How to build a self-contained version of the Docs/Demos
|
||||
=======================================================
|
||||
Once you have your own cloned repo on your computer:
|
||||
|
||||
make docs
|
||||
|
||||
The docs will be built and available in the compiled/demos folder. You can move this folder to your web server or
|
||||
other location. It has no dependencies on anything other than a basic HTML web server.
|
||||
|
||||
|
||||
Submitting bugs
|
||||
===============
|
||||
If you think you've found a bug, please report it by following these instructions:
|
||||
|
|
|
|||
|
|
@ -35,41 +35,41 @@
|
|||
|
||||
<a href="lists-ul.html" data-role="button" data-icon="arrow-r" data-iconpos="right">Basic list example</a>
|
||||
|
||||
<p><strong>Style note</strong>: all standard, non-inset lists have a -15px margin to negate the 15px of padding on the content area to make lists fill to the edges of the screen. If you add other widgets above or below a list, the negative margin may make these elements overlap so you'll need to add additional spacing in your custom CSS.</p>
|
||||
<p><strong>Style note on non-inset lists</strong>: all standard, non-inset lists have a -15px margin to negate the 15px of padding on the content area to make lists fill to the edges of the screen. If you add other widgets above or below a list, the negative margin may make these elements overlap so you'll need to add additional spacing in your custom CSS.</p>
|
||||
<h2>Nested lists</h2>
|
||||
<p>By nesting child <code>ul</code> or <code>ol</code> inside list items, you can create nested lists. When a list item with a child list is clicked, the framework will generate a new ui-page populated with the title of the parent in the header and the list of child elements. These dynamic nested lists are styled with the "b" theme swatch (blue in the default theme) to indicate that you are in a secondary level of navigation. Lists can be nested multiple level deep and all pages and linking will be automatically handled by the framework.</p>
|
||||
<p>To set the swatch color of the child list views, <code> data-theme</code> attribute on each list inside.</p>
|
||||
<p>By nesting child <code>ul</code> or <code>ol</code> inside list items, you can create nested lists. When a list item with a child list is clicked, the framework will generate a new ui-page populated with the title of the parent in the header and the list of child elements. These dynamic nested lists are styled with the "b" theme swatch (blue in the default theme) to indicate that you are in a secondary level of navigation. Lists can be nested multiple levels deep and all pages and linking will be automatically handled by the framework.</p>
|
||||
<p>To <a href="../lists/lists-themes.html">set the swatch color</a> of the child list views, set the <code>data-theme</code> attribute on each list inside.</p>
|
||||
<a href="lists-nested.html" data-role="button" data-icon="arrow-r" data-iconpos="right">Nested list example</a>
|
||||
|
||||
<h2>Numbered lists</h2>
|
||||
<p>Lists can also be created from ordered lists <code>(ol)</code> which is useful when presented items that are in a sequence such as search results or a movie queue. When the enhanced markup is applied to the list view, jQuery Mobile will try to first use CSS to add numbers to the list and, if not supported, will fall back to injecting numbers with JavaScript.</p>
|
||||
<p>Lists can also be created from ordered lists <code>(ol)</code> which is useful when presenting items that are in a sequence such as search results or a movie queue. When the enhanced markup is applied to the list view, jQuery Mobile will try to first use CSS to add numbers to the list and, if not supported, will fall back to injecting numbers with JavaScript.</p>
|
||||
|
||||
<a href="lists-ol.html" data-role="button" data-icon="arrow-r" data-iconpos="right">Numbered list example</a>
|
||||
|
||||
<h2>Read-only lists</h2>
|
||||
<p>List views can also be used to display a non-interactive list of items, usually as an inset list. This list is built from an unordered or ordered list that don't have linked list items. The framework defaults to styling these list with the "c" theme swatch (flat white in the default theme) and sets the text size to a smaller size than the clickable lists to save a bit of space.</p>
|
||||
|
||||
<a href="lists-readonly.html" data-role="button" data-icon="arrow-r" data-iconpos="right">Read-only list example</a>
|
||||
<a href="lists-readonly-inset.html" data-role="button" data-icon="arrow-r" data-iconpos="right">Read-only list example</a>
|
||||
|
||||
<h2>Split button lists</h2>
|
||||
<p>In cases where there is more than one possible action per list item, a split button can be used to offer two independently clickable items -- the list item and a small arrow icon in the far right. To make a split list item, simply add a second link inside the <code>li</code> and the framework will add a vertical divider line, style the link as an icon-only arrow button, and sets the <code>title</code> attribute of the link to the text the link for accessibility. </p>
|
||||
<p>In cases where there is more than one possible action per list item, a split button can be used to offer two independently clickable items -- the list item and a small arrow icon in the far right. To make a split list item, simply add a second link inside the <code>li</code> and the framework will add a vertical divider line, style the link as an icon-only arrow button, and set the <code>title</code> attribute of the link to the text the link for accessibility. </p>
|
||||
<p>You can set the icon for the right split icon by specifying a <code>data-split-icon</code> attribute with the <a href="../buttons/buttons-themes.html">icon name</a> you want. The theme swatch color of the split button can be set by specifying a swatch letter in the <code>data-split-theme</code> attribute</p>
|
||||
|
||||
<a href="lists-split.html" data-role="button" data-icon="arrow-r" data-iconpos="right">Split list example</a>
|
||||
|
||||
|
||||
<h2>List dividers</h2>
|
||||
<p>List items can be turned into dividers to organize and group the list items. This is done by adding the <code> data-role="list-divider"</code> to any list item. These items are styled with the body swatch "b" by default (light gray in the default theme) but you can specify a theme for dividers by adding the <code>data-dividertheme</code> attribute to the list element (ul or ol) and specifying a theme swatch letter.</p>
|
||||
<p>List items can be turned into dividers to organize and group the list items. This is done by adding the <code> data-role="list-divider"</code> to any list item. These items are styled with the body swatch "b" by default (light gray in the default theme) but you can specify a theme for dividers by adding the <code>data-dividertheme</code> attribute to the list element (<code>ul</code> or <code>ol</code>) and specifying a theme swatch letter.</p>
|
||||
|
||||
<a href="lists-divider.html" data-role="button" data-icon="arrow-r" data-iconpos="right">List divider example</a>
|
||||
|
||||
|
||||
<h2>Search filter</h2>
|
||||
<p>jQuery Mobile provides a very easy way to filter a list with a simple client-side search feature. To make a list filterable, simply add the <code>data-filter="true"</code> attribute to the list. The framework will then append a search box above the list and add the behavior to filter out list items that don't contain the current search string as the user types. The input's placeholder text defaults to "Filter items...". To configure the placeholder text in the search input, you can either bind to the <code>mobileinit</code> event and set the <code>$.mobile.listview.prototype.options.filterPlaceholder</code> option to a string of your choosing, or use the data-attribute <code>data-filter-placeholder</code> on your listview. By default the search box will inherit its theme from its parent. The search box theme can be configured using the data-attribute <code>data-filter-theme</code> on your listview.</p>
|
||||
<p>jQuery Mobile provides a very easy way to filter a list with a simple client-side search feature. To make a list filterable, simply add the <code>data-filter="true"</code> attribute to the list. The framework will then append a search box above the list and add the behavior to filter out list items that don't contain the current search string as the user types. The input's placeholder text defaults to "Filter items...". To configure the placeholder text in the search input, you can either <a href="../api/globalconfig.html">bind to the <code>mobileinit</code> event</a> and set the <code>$.mobile.listview.prototype.options.filterPlaceholder</code> option to a string of your choosing, or use the data-attribute <code>data-filter-placeholder</code> on your listview. By default the search box will inherit its theme from its parent. The search box theme can be configured using the data-attribute <code>data-filter-theme</code> on your listview.</p>
|
||||
|
||||
<a href="lists-search.html" data-role="button" data-icon="arrow-r" data-iconpos="right">Search filter example</a>
|
||||
|
||||
<p>If you want to change the way in which list items are filtered, ie fuzzy search or matching from the beginning of the string, you can configure the callback used internally by defining <code>$.mobile.listview.prototype.options.filterCallback</code> during <code>mobileinit</code> or after the widget has been created with <code>$("#mylist").listview('option', 'filterCallback', yourFilterFunction)</code>. Any function defined for the callback will be provided two arguments. First, the text of the current list item and second the value being searched for. A truthy value will result in a hidden list item. The default callback which filters entries without the <code>searchValue</code> as a substring is described below:
|
||||
<p>If you want to change the way in which list items are filtered, ie fuzzy search or matching from the beginning of the string, you can configure the callback used internally by defining <code>$.mobile.listview.prototype.options.filterCallback</code> during <code>mobileinit</code> or after the widget has been created with <code>$("#mylist").listview('option', 'filterCallback', yourFilterFunction)</code>. Any function defined for the callback will be provided two arguments. First, the text of the current list item and second, the value being searched for. A truthy value will result in a hidden list item. The default callback which filters entries without the <code>searchValue</code> as a substring is described below:
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
|
|
@ -81,7 +81,7 @@ function( text, searchValue ){
|
|||
</pre>
|
||||
|
||||
<h2>Text formatting & counts</h2>
|
||||
<p>The framework includes text formatting conventions for common list patterns like header/descriptions, secondary information, counts through HTML semantic markup. </p>
|
||||
<p>The framework includes text formatting conventions for common list patterns like header/descriptions, secondary information and counts through semantic HTML markup.</p>
|
||||
|
||||
<ul>
|
||||
<li>To add a count indicator to the right of the list item, wrap the number in an element with a class of <code>ui-li-count</code></li>
|
||||
|
|
@ -92,7 +92,7 @@ function( text, searchValue ){
|
|||
<a href="lists-formatting.html" data-role="button" data-icon="arrow-r" data-iconpos="right">List with text formatting</a>
|
||||
|
||||
<h2>Thumbnails & icons</h2>
|
||||
<p>To add thumbnails to the left of a list item, simply add an image inside a list item as the first child element. The framework will scale the image to 80 pixels square. To use standard 16x16 pixel icons in list items, add the class of <code>ui-li-icon</code> to the image element to size.</p>
|
||||
<p>To add thumbnails to the left of a list item, simply add an image inside a list item as the first child element. The framework will scale the image to 80 pixels square. To use standard 16x16 pixel icons in list items, add the class of <code>ui-li-icon</code> to the image element.</p>
|
||||
<a href="lists-thumbnails.html" data-role="button" data-icon="arrow-r" data-iconpos="right">List with thumbnail images</a>
|
||||
<a href="lists-icons.html" data-role="button" data-icon="arrow-r" data-iconpos="right">List with icon images</a>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
<p>Usually, it's a good idea to store your app's pages in several single-page templates instead of one large multi-page template. This minimizes the size of the page's DOM.</p>
|
||||
|
||||
<p>When using single-page templates, you can prefetch pages into the DOM so that they're available instantly when the user visits them. To prefetch a page, add the <code>data-prefetch</code> attribute to a link that points to the page. jQuery Mobile then loads the target page in the background after the primary page has loaded and the pagecreate event has triggered. For example:</p>
|
||||
<p>When using single-page templates, you can prefetch pages into the DOM so that they're available instantly when the user visits them. To prefetch a page, add the <code>data-prefetch</code> attribute to a link that points to the page. jQuery Mobile then loads the target page in the background after the primary page has loaded and the <code>pagecreate</code> event has triggered. For example:</p>
|
||||
|
||||
<pre><code>
|
||||
<a href="prefetchThisPage.html" data-prefetch> ... </a>
|
||||
|
|
@ -51,7 +51,7 @@ $.mobile.loadPage( <var>pageUrl</var>, { showLoadMsg: false } );
|
|||
|
||||
<p>For animated page transitions to work, the pages you're transitioning from and to both need to be in the DOM. However, keeping old pages in the DOM quickly fills the browser's memory, and can cause some mobile browsers to slow down or even crash.</p>
|
||||
|
||||
<p>jQuery Mobile therefore has a simple mechanism to keep the DOM tidy. Whenever it loads a page via Ajax, jQuery Mobile flags the page to be removed from the DOM when you navigate away from it later (technically, on the pagehide event). If you revisit a removed page, the browser may be able to retrieve the page's HTML file from its cache. If not, it refetches the file from the server. (In the case of nested list views, jQuery Mobile removes all the pages that make up the nested list once you navigate to a page that's not part of the list.)</p>
|
||||
<p>jQuery Mobile therefore has a simple mechanism to keep the DOM tidy. Whenever it loads a page via Ajax, jQuery Mobile flags the page to be removed from the DOM when you navigate away from it later (technically, on the <code>pagehide</code> event). If you revisit a removed page, the browser may be able to retrieve the page's HTML file from its cache. If not, it refetches the file from the server. (In the case of nested list views, jQuery Mobile removes all the pages that make up the nested list once you navigate to a page that's not part of the list.)</p>
|
||||
|
||||
<p>Pages inside a multi-page template aren't affected by this feature at all - jQuery Mobile only removes pages loaded via Ajax.</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
|
||||
<div data-role="content">
|
||||
<div class="content-primary">
|
||||
<p>Since jQuery Mobile uses an Ajax-powered navigation system, there are a few helpful things to know when writing scripts that manipulate your content. You can explore the mobile API in more detail by reading up on <a href="../api/globalConfig.html">global configuration options</a>, <a href="../api/events.html">events</a>, and <a href="../api/methods.html">methods</a> or dig into the technical details of the <a href="page-navmodel.html">Ajax navigation model</a>.</p>
|
||||
<p>Since jQuery Mobile uses an Ajax-powered navigation system, there are a few helpful things to know when writing scripts that manipulate your content. You can explore the mobile API in more detail by reading up on <a href="../api/globalconfig.html">global configuration options</a>, <a href="../api/events.html">events</a>, and <a href="../api/methods.html">methods</a> or dig into the technical details of the <a href="page-navmodel.html">Ajax navigation model</a>.</p>
|
||||
|
||||
<h2>Scripts & styles in the head</h2>
|
||||
|
||||
<p>When the user clicks a link in a jQuery Mobile-driven site, the default behavior of the navigation system is to use that link's href to formulate an Ajax request (instead of allowing the browser's default link behavior of requesting that href with full page load). When that Ajax request goes out, the framework will receive its entire text content, but it will only inject the <em>contents of the response's <code>body</code> element (or more specifically the <code>data-role="page"</code> element, if it's provided)</em>, meaning nothing in the <code>head</code> of the page will be used (with the exception of the page title, which is fetched specifically).</p>
|
||||
<p>When the user clicks a link in a jQuery Mobile-driven site, the default behavior of the navigation system is to use that link's <code>href</code> to formulate an Ajax request (instead of allowing the browser's default link behavior of requesting that <code>href</code> with full page load). When that Ajax request goes out, the framework will receive its entire text content, but it will only inject the <em>contents of the response's <code>body</code> element (or more specifically the <code>data-role="page"</code> element, if it's provided)</em>, meaning nothing in the <code>head</code> of the page will be used (with the exception of the page title, which is fetched specifically).</p>
|
||||
|
||||
<p> This means that any scripts and styles referenced the <code>head</code> of a page won't have any effect <em>when a page is loaded via Ajax</em>, but they <strong>will execute if the page is requested normally via HTTP</strong>. When scripting jQuery Mobile sites, both scenarios need to be considered. The reason that the <code>head</code> of a page is ignored when requested via Ajax is that the potential of re-executing the same JavaScript is very high (it's common to reference the same scripts in every page of a site). Due to the complexity of attempting to work around that issue, we leave the task of executing page-specific scripts to the developer, and assume <code>head</code> scripts are only expected to execute once per browsing session.</p>
|
||||
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
<h2>pagecreate = DOM ready</h2>
|
||||
|
||||
<p>One of the first things people learn in jQuery is to use the $(document).ready() function for executing DOM-specific code as soon as the DOM is ready (which often occurs long before the <code>onload</code> event). However, in jQuery Mobile site and apps, pages are requested and injected into the same DOM as the user navigates, so the DOM ready event is not as useful, as it only executes for the first page. To execute code whenever a new page is loaded and created in jQuery Mobile, you can bind to the <a href="../api/events.html"><code>pagecreate</code></a> event. </p>
|
||||
<p>One of the first things people learn in jQuery is to use the <code>$(document).ready()</code> function for executing DOM-specific code as soon as the DOM is ready (which often occurs long before the <code>onload</code> event). However, in jQuery Mobile site and apps, pages are requested and injected into the same DOM as the user navigates, so the DOM ready event is not as useful, as it only executes for the first page. To execute code whenever a new page is loaded and created in jQuery Mobile, you can bind to the <a href="../api/events.html"><code>pagecreate</code></a> event. </p>
|
||||
|
||||
<p>The <code>pagecreate</code> event is triggered on a page when it is initialized, right after initialization occurs. Most of jQuery Mobile's official widgets auto-initialize themselves based on this event, and you can set up your code to do the same.</p>
|
||||
<pre><code>
|
||||
|
|
@ -74,8 +74,8 @@ $.mobile.loadPage( "about/us.html" );
|
|||
</code></pre>
|
||||
|
||||
<h2>Enhancing new markup</h2>
|
||||
<p>The page plugin dispatches a “pagecreate” event, which most widgets use to auto-initialize themselves. As long as a widget plugin script is referenced, it will automatically enhance any instances of the widgets it finds on the page.</p>
|
||||
<p>However, if you generate new markup client-side or load in content via Ajax and inject it into a page, you can trigger the <code>create</code> event to handle the auto-initialization for all the plugins contained within the new markup. This can be triggered on any element (even the page div itself), saving you the task of manually initializing each plugin (listview button, select, etc.).</p>
|
||||
<p>The page plugin dispatches a <code>pagecreate</code> event, which most widgets use to auto-initialize themselves. As long as a widget plugin script is referenced, it will automatically enhance any instances of the widgets it finds on the page.</p>
|
||||
<p>However, if you generate new markup client-side or load in content via Ajax and inject it into a page, you can trigger the <code>create</code> event to handle the auto-initialization for all the plugins contained within the new markup. This can be triggered on any element (even the page <code>div</code> itself), saving you the task of manually initializing each plugin (listview button, select, etc.).</p>
|
||||
<p>For example, if a block of HTML markup (say a login form) was loaded in through Ajax, trigger the <code>create</code> event to automatically transform all the widgets it contains (<a href="http://jquerymobile.com/test/docs/forms/textinputs/index.html">inputs</a> and <a href="http://jquerymobile.com/test/docs/buttons/index.html">buttons</a> in this case) into the enhanced versions. The code for this scenario would be:</p>
|
||||
<pre style="margin: 25px 0;"><code style="font-size: 12px;">$( ...new markup that contains widgets... ).appendTo( ".ui-page" ).trigger( "create" );
|
||||
</code></pre>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
|
|||
collapsibleHeading = $el.children( o.heading ).first(),
|
||||
collapsibleContent = collapsible.wrapInner( "<div class='ui-collapsible-content'></div>" ).find( ".ui-collapsible-content" ),
|
||||
collapsibleSet = $el.closest( ":jqmData(role='collapsible-set')" ).addClass( "ui-collapsible-set" ),
|
||||
colllapsiblesInSet = collapsibleSet.children( ":jqmData(role='collapsible')" );
|
||||
collapsiblesInSet = collapsibleSet.children( ":jqmData(role='collapsible')" );
|
||||
|
||||
// Replace collapsibleHeading if it's a legend
|
||||
if ( collapsibleHeading.is( "legend" ) ) {
|
||||
|
|
@ -84,14 +84,14 @@ $.widget( "mobile.collapsible", $.mobile.widget, {
|
|||
});
|
||||
}
|
||||
|
||||
colllapsiblesInSet.first()
|
||||
collapsiblesInSet.first()
|
||||
.find( "a" )
|
||||
.first()
|
||||
.addClass( "ui-corner-top" )
|
||||
.find( ".ui-btn-inner" )
|
||||
.addClass( "ui-corner-top" );
|
||||
|
||||
colllapsiblesInSet.last()
|
||||
collapsiblesInSet.last()
|
||||
.jqmData( "collapsible-last", true )
|
||||
.find( "a" )
|
||||
.first()
|
||||
|
|
|
|||
|
|
@ -30,7 +30,9 @@
|
|||
"aria-labelledby": buttonId
|
||||
}).attr( "data-" + $.mobile.ns + "theme", widget.options.theme ).appendTo( listbox ),
|
||||
|
||||
header = $( "<div>" ).attr( "data-" + $.mobile.ns + "theme", widget.options.theme ).prependTo( listbox ),
|
||||
header = $( "<div>", {
|
||||
"class": "ui-header ui-bar-" + widget.options.theme
|
||||
}).prependTo( listbox ),
|
||||
|
||||
headerTitle = $( "<h1>", {
|
||||
"class": "ui-title"
|
||||
|
|
|
|||
|
|
@ -1,21 +1,48 @@
|
|||
<?php
|
||||
$db = new PDO('sqlite:./stats.db');
|
||||
$db->query('CREATE TABLE IF NOT EXISTS stats (id INTEGER, agent TEXT, point TEXT, value REAL, time TIMESTAMP, pathname TEXT, PRIMARY KEY (id))');
|
||||
$db->query('CREATE TABLE IF NOT EXISTS stats (id INTEGER, agent TEXT, agent_version Text, agent_full TEXT, point TEXT, value REAL, time TIMESTAMP, pathname TEXT, PRIMARY KEY (id))');
|
||||
|
||||
// making a sad attempt here to provide a clean REST-respecting url scheme.
|
||||
// stats with a GET returns - wait for it - the stats, and a post with the
|
||||
// the right params will create a new entry
|
||||
if ( $_SERVER['REQUEST_METHOD'] == "GET" ) {
|
||||
$json = Array();
|
||||
$st = $db->prepare( 'SELECT point, avg(value) as avg_value, pathname, strftime(\'%Y-%m-%d\', time) as day FROM stats GROUP BY pathname, point, strftime(\'%Y-%m-%d\', time) ORDER BY time;' );
|
||||
$st->execute();
|
||||
$agent = (empty($_GET['agent'])) ? '' : urldecode($_GET['agent']);
|
||||
$data_point = (empty($_GET['data_point'])) ? '' : urldecode($_GET['data_point']);
|
||||
|
||||
$st = $db->prepare( '
|
||||
SELECT agent, agent_version, point, avg(value) as avg_value,
|
||||
pathname, strftime(\'%Y-%m-%d\', time) as day
|
||||
FROM stats
|
||||
WHERE (agent_full like \'%Mobile%\' or agent_full like \'%mobile%\')
|
||||
and agent like :agent and point like :data_point
|
||||
GROUP BY agent, agent_version, pathname, point, strftime(\'%Y-%m-%d\', time)
|
||||
ORDER BY time;
|
||||
');
|
||||
|
||||
$st->execute(array(
|
||||
':agent' => '%' . $agent . '%',
|
||||
':data_point' => '%' . $data_point . '%'
|
||||
));
|
||||
|
||||
$result = $st->fetchAll(PDO::FETCH_ASSOC);
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($result);
|
||||
} elseif ( $_POST['datapoint'] && $_POST['value'] && $_POST['agent'] && $_POST['pathname']) {
|
||||
$st = $db->prepare('INSERT INTO stats (agent, point, value, pathname, time) VALUES (:agent, :data_point, :value, :pathname, DATETIME(\'now\'))');
|
||||
|
||||
} elseif ( $_POST['datapoint'] &&
|
||||
$_POST['value'] &&
|
||||
$_POST['agent'] &&
|
||||
$_POST['pathname'] &&
|
||||
$_POST['agentVersion'] ) {
|
||||
|
||||
$st = $db->prepare('
|
||||
INSERT INTO stats (agent, agent_full, agent_version, point, value, pathname, time)
|
||||
VALUES (:agent, :agent_full, :agent_version, :data_point, :value, :pathname, DATETIME(\'now\'))
|
||||
');
|
||||
|
||||
$st->execute(array(
|
||||
':agent' => $_POST['agent'],
|
||||
':agent_full' => $_POST['agentFull'],
|
||||
':agent_version' => $_POST['agentVersion'],
|
||||
':data_point' => $_POST['datapoint'],
|
||||
':value' => $_POST['value'],
|
||||
':pathname' => $_POST['pathname']
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@ window.Perf = (function($, Perf) {
|
|||
currentRev: undefined,
|
||||
|
||||
report: function( data, after ) {
|
||||
var self = this;
|
||||
$.extend(data, {
|
||||
pathname: location.pathname,
|
||||
agent: this.agent(),
|
||||
agentFull: window.navigator.userAgent,
|
||||
agentVersion: this.agentVersion()
|
||||
});
|
||||
|
||||
data.pathname = location.pathname;
|
||||
|
||||
$.post( self.reportUrl, data, after );
|
||||
$.post( this.reportUrl, data, after );
|
||||
},
|
||||
|
||||
poll: function() {
|
||||
|
|
@ -34,8 +37,44 @@ window.Perf = (function($, Perf) {
|
|||
$.get( self.revUrl, function( data ) {
|
||||
self.currentRev = data;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
agent: function() {
|
||||
var agent = window.navigator.userAgent;
|
||||
|
||||
for( name in this.agents ) {
|
||||
if( agent.indexOf( this.agents[name] ) > -1 ) {
|
||||
return this.agents[name];
|
||||
}
|
||||
}
|
||||
|
||||
return agent;
|
||||
},
|
||||
|
||||
agentVersion: function() {
|
||||
var agent = window.navigator.userAgent;
|
||||
|
||||
agent.search(this.vRegexs[this.agent()] || "");
|
||||
|
||||
return RegExp.$1 ? RegExp.$1 : "0.0";
|
||||
},
|
||||
|
||||
agents: {
|
||||
ANDROID: "Android",
|
||||
WP: "Windows Phone OS",
|
||||
IPHONE: "iPhone OS",
|
||||
IPAD: "iPad; U; CPU OS",
|
||||
BLACKBERRY: "BlackBerry"
|
||||
},
|
||||
|
||||
vRegexs: {}
|
||||
});
|
||||
|
||||
Perf.vRegexs[Perf.agents.ANDROID] = /([0-9].[0-9].[0-9]);/;
|
||||
Perf.vRegexs[Perf.agents.WP] = /Windows Phone OS ([0-9].[0-9]);/;
|
||||
Perf.vRegexs[Perf.agents.IPHONE] = /iPhone OS ([0-9]_[0-9])/;
|
||||
Perf.vRegexs[Perf.agents.IPAD] = /iPad; U; CPU OS ([0-9]_[0-9])/;
|
||||
Perf.vRegexs[Perf.agents.BLACKBERRY] = /BlackBerry ([0-9]{4})/;
|
||||
|
||||
return Perf;
|
||||
})(jQuery, window.Perf || {});
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
// report the time taken for a full app boot
|
||||
Perf.report({
|
||||
agent: window.navigator.userAgent,
|
||||
datapoint: "fullboot",
|
||||
value: Perf.pageLoadEnd - Perf.pageLoadStart
|
||||
});
|
||||
|
|
@ -30,7 +29,6 @@
|
|||
// record the time taken to load and enhance the page
|
||||
// start polling for a new revision
|
||||
Perf.report({
|
||||
agent: window.navigator.userAgent,
|
||||
datapoint: "pageload",
|
||||
value: Perf.pageCreateStart - Perf.pageLoadStart,
|
||||
after: function() {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,5 @@ table {
|
|||
|
||||
div.visualize {
|
||||
float: left;
|
||||
margin-left: 100px;
|
||||
margin-right: 50px;
|
||||
margin: 0 50px 70px 100px;
|
||||
}
|
||||
|
|
@ -1,16 +1,37 @@
|
|||
(function($) {
|
||||
// TODO this is entire thing sucks
|
||||
$(function() {
|
||||
$.get("../", function(data) {
|
||||
var searchMap = (function() {
|
||||
var searchSplit, searchMap = {};
|
||||
|
||||
if ( !location.search ){
|
||||
return searchMap;
|
||||
}
|
||||
|
||||
searchSplit = location.search.replace(/^\?/, "").split( /&|;/ );
|
||||
|
||||
for( var i = 0; i < searchSplit.length; i++ ) {
|
||||
var kv = searchSplit[i].split(/=/);
|
||||
searchMap[ kv[0] ] = kv[1];
|
||||
}
|
||||
|
||||
return searchMap;
|
||||
})();
|
||||
|
||||
$.get("../", searchMap, function(data) {
|
||||
$.each(data, function( i, avg ) {
|
||||
var $table = $( "#" + avg.point + "[data-pathname='" + avg.pathname + "']");
|
||||
var tablename = avg.point + " " + avg.agent + " " + avg.pathname + " " + avg.agent_version,
|
||||
$table = $( "table > caption:contains(" + tablename + ")");
|
||||
|
||||
if( !$table.length ) {
|
||||
$table = $( "<table>", {
|
||||
id: avg.point,
|
||||
"data-pathname": avg.pathname
|
||||
$table = $( "<table></table>", {
|
||||
"data-pathname": avg.pathname,
|
||||
"data-point": avg.point,
|
||||
"data-agent": avg.agent,
|
||||
"data-agent": avg.agent_version
|
||||
});
|
||||
|
||||
$table.append( "<caption>" + avg.point + " " + avg.pathname + "</caption>");
|
||||
$table.append( "<caption>" + tablename + "</caption>");
|
||||
$table.append( "<thead><tr></tr></thead>" );
|
||||
$table.append( "<tbody><tr></tr></tbody>" );
|
||||
}
|
||||
|
|
@ -19,7 +40,7 @@
|
|||
var $heading = $table.find("thead > tr > th:contains(" + avg.day + ")");
|
||||
|
||||
if( !$heading.length ) {
|
||||
$heading = $("<th>", {
|
||||
$heading = $("<th></th>", {
|
||||
text: avg.day,
|
||||
scope: "column"
|
||||
});
|
||||
|
|
@ -31,7 +52,7 @@
|
|||
$row = $table.find( "tbody > tr" );
|
||||
|
||||
if( !$rowHeading.length ) {
|
||||
$rowHeading = $("<th>", {
|
||||
$rowHeading = $("<th></th>", {
|
||||
text: avg.point,
|
||||
scope: "row"
|
||||
});
|
||||
|
|
@ -41,10 +62,10 @@
|
|||
|
||||
$row.append( "<td>" + avg.avg_value + "</td>" );
|
||||
|
||||
$("#tables").append($table);
|
||||
$("#tables").append($table);
|
||||
});
|
||||
|
||||
$("#tables table").visualize({ type: "line", width: 400, height: 400 }).appendTo("#graphs");
|
||||
$("#tables table").visualize({ type: "bar", width: 400, height: 400 }).appendTo("#graphs");
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
@ -147,14 +147,17 @@
|
|||
function() {
|
||||
var collapsibles = $.mobile.activePage.find( ".ui-collapsible" );
|
||||
ok( collapsibles.eq(0).find( ".ui-collapsible-heading-toggle" ).hasClass( "ui-btn-up-a" ), "Heading of first collapsible should have class ui-btn-up-a");
|
||||
ok( !collapsibles.eq(0).find( ".ui-collapsible-content" ).hasClass( "ui-body-a" ), "Content of first collapsible should NOT have class ui-btn-up-a");
|
||||
ok( !collapsibles.eq(0).find( ".ui-collapsible-content" ).is( ".ui-body-a,.ui-body-b,.ui-body-c" ), "Content of first collapsible should NOT have class ui-btn-up-[a,b,c]");
|
||||
ok( collapsibles.eq(0).find( ".ui-collapsible-content" ).hasClass( "ui-body-d" ), "Content of first collapsible should NOT have class ui-btn-up-d");
|
||||
ok( collapsibles.eq(1).find( ".ui-collapsible-heading-toggle" ).hasClass( "ui-btn-up-b" ), "Heading of second collapsible should have class ui-btn-up-b");
|
||||
ok( !collapsibles.eq(1).find( ".ui-collapsible-content" ).is( ".ui-body-a,.ui-body-c,.ui-body-d" ), "Content of second collapsible should NOT have class ui-btn-up-[a,c,d]");
|
||||
ok( collapsibles.eq(1).find( ".ui-collapsible-content" ).hasClass( "ui-body-b" ), "Content of second collapsible should have class ui-btn-up-b");
|
||||
ok( collapsibles.eq(2).find( ".ui-collapsible-heading-toggle" ).hasClass( "ui-btn-up-d" ), "Heading of third collapsible should have class ui-btn-up-d");
|
||||
ok( !collapsibles.eq(2).find( ".ui-collapsible-content" ).is( ".ui-body-a,.ui-body-b,.ui-body-c" ), "Content of third collapsible should NOT have class ui-btn-up-[a,b,c]");
|
||||
ok( collapsibles.eq(2).find( ".ui-collapsible-content" ).hasClass( "ui-body-d" ), "Content of third collapsible should have class ui-btn-up-d");
|
||||
ok( !collapsibles.eq(2).find( ".ui-collapsible-content" ).hasClass( "ui-collapsible-content-collapsed" ), "Content of third collapsible should NOT have class ui-collapsible-content-collapsed");
|
||||
ok( collapsibles.eq(3).find( ".ui-collapsible-heading-toggle" ).hasClass( "ui-btn-up-d" ), "Heading of fourth collapsible should have class ui-btn-up-d");
|
||||
ok( !collapsibles.eq(3).find( ".ui-collapsible-content" ).is( ".ui-body-a,.ui-body-b,.ui-body-c" ), "Content of fourth collapsible should NOT have class ui-btn-up-[a,b,c]");
|
||||
ok( collapsibles.eq(3).find( ".ui-collapsible-content" ).hasClass( "ui-body-d" ), "Content of fourth collapsible should have class ui-btn-up-d");
|
||||
start();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue