├── .gitignore ├── CHANGES ├── LICENSE ├── MANIFEST.in ├── Makefile ├── README.rst ├── examples ├── hello.py └── templates │ └── hello.html ├── flask_profile ├── __init__.py ├── static │ ├── css │ │ └── profiler.css │ ├── img │ │ ├── asc.gif │ │ ├── bg.gif │ │ ├── desc.gif │ │ └── profile.png │ └── js │ │ ├── jquery.js │ │ ├── jquery.tablesorter.js │ │ └── profiler.js └── templates │ └── _profile │ └── profiler.html └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.pyc 3 | *.pyo 4 | dist 5 | build 6 | *.egg 7 | *.egg-info 8 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | Changelog 2 | --------- 3 | 4 | Version 0.1 5 | ``````````` 6 | 7 | First public preview release. 8 | 9 | 10 | Version 0.2 11 | ``````````` 12 | 13 | Released on May 17th 2016 14 | 15 | - Fixed css/js url in profiler.html 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 by Shipeng Feng. 2 | 3 | Some rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | * The names of the contributors may not be used to endorse or 18 | promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE CHANGES *.py 2 | recursive-include flask_profile/static * 3 | recursive-include flask_profile/templates * 4 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | clean-pyc: 2 | find . -name '*.pyc' -exec rm -f {} + 3 | find . -name '*.pyo' -exec rm -f {} + 4 | find . -name '*~' -exec rm -f {} + 5 | 6 | lines: 7 | find . -name "*.py"|xargs cat|wc -l 8 | 9 | release: 10 | python setup.py register 11 | python setup.py sdist upload 12 | python setup.py bdist_wheel upload 13 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Flask-Profile 2 | ============= 3 | 4 | A profiler extension for finding bottlenecks in Flask application. 5 | 6 | Installation 7 | ------------ 8 | 9 | :: 10 | 11 | $ pip install Flask-Profile 12 | 13 | Usage 14 | ----- 15 | 16 | .. code:: python 17 | 18 | from flask import Flask, render_template_string 19 | from flask.ext.profile import Profiler 20 | 21 | app = Flask(__name__) 22 | # Flask-Profile is only actived under debug mode 23 | app.debug = True 24 | Profiler(app) 25 | 26 | @app.route('/') 27 | def index(): 28 | return render_template_string('hello') 29 | 30 | app.run() 31 | 32 | You can also create the object once and configure the application later: 33 | 34 | .. code:: python 35 | 36 | profiler = Profiler() 37 | 38 | def create_app(): 39 | app = Flask(__name__) 40 | profiler.init_app(app) 41 | return app 42 | 43 | 44 | If you want the profiler collects data including Extensions, please make sure 45 | that the Extension is used after Flask-Profile: 46 | 47 | .. code:: python 48 | 49 | from flask.ext.session import Session 50 | from flask.ext.profile import Profiler 51 | 52 | Profiler(app) 53 | Session(app) 54 | 55 | .. note:: 56 | 57 | This only works if your response is one html page because the 58 | profiling result is showed in html. 59 | You can click the column name to sort in the page. 60 | 61 | Better 62 | ------ 63 | 64 | If you feel anything wrong, feedbacks or pull requests are welcome. 65 | -------------------------------------------------------------------------------- /examples/hello.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Simple Hello 4 | ~~~~~~~~~~~~ 5 | 6 | Simple app to demo Flask-Profile. 7 | 8 | :copyright: (c) 2014 by Shipeng Feng. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | import urllib 12 | 13 | from flask import Flask, render_template 14 | from flask.ext.profile import Profiler 15 | 16 | 17 | app = Flask(__name__) 18 | app.debug = True 19 | Profiler(app) 20 | 21 | 22 | @app.route('/') 23 | def index(): 24 | # urllib.urlopen('http://www.apple.com') 25 | return render_template('hello.html') 26 | 27 | 28 | if __name__ == "__main__": 29 | app.run() 30 | -------------------------------------------------------------------------------- /examples/templates/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello 6 | 7 | 8 |

Hello, world!

9 | 10 | 11 | -------------------------------------------------------------------------------- /flask_profile/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | flaskext.profile 4 | ~~~~~~~~~~~~~~~~ 5 | 6 | Adds profiling to Flask. 7 | 8 | :copyright: (c) 2014 by Shipeng Feng. 9 | :license: BSD, see LICENSE for more details. 10 | """ 11 | 12 | import pstats 13 | import os 14 | import sys 15 | 16 | try: 17 | import cProfile as profile 18 | except ImportError: 19 | import profile 20 | 21 | from flask import Blueprint, request, render_template, current_app 22 | 23 | 24 | # Profile blueprint used to render template and serving static files 25 | blueprint = Blueprint('_profile', __name__, static_folder='static', 26 | static_url_path='/static', template_folder='templates', 27 | url_prefix='/_profile') 28 | 29 | 30 | def insensitive_replace(string, target, replacement): 31 | """string.replace() that is case insensitive. 32 | """ 33 | no_case = string.lower() 34 | index = no_case.rfind(target.lower()) 35 | if index >= 0: 36 | return string[:index] + replacement + string[index + len(target):] 37 | else: 38 | return string 39 | 40 | 41 | def filename_format(filename): 42 | """Format the profiler filename. 43 | """ 44 | if not os.path.isabs(filename): 45 | if filename.startswith(('{', '<')) or \ 46 | filename.startswith('.' + os.path.sep): 47 | return filename 48 | return os.path.join('.', filename) 49 | 50 | if filename.startswith(current_app.root_path): 51 | return os.path.join('', filename[len(current_app.root_path):]) 52 | 53 | prefix = '' 54 | prefix_len = 0 55 | for path in sys.path: 56 | current_prefix = os.path.commonprefix([path, filename]) 57 | if len(current_prefix) > prefix_len: 58 | prefix = current_prefix 59 | prefix_len = len(prefix) 60 | filename = filename[prefix_len:] 61 | return os.path.join('', filename) 62 | 63 | 64 | class Profiler(object): 65 | """Profiler Extension. 66 | """ 67 | 68 | def __init__(self, app=None): 69 | self.app = app 70 | if app is not None: 71 | self.init_app(app) 72 | 73 | def init_app(self, app): 74 | """This is used to set up profiler for your flask app object. 75 | 76 | :param app: the Flask app object. 77 | """ 78 | if app.debug: 79 | app.register_blueprint(blueprint) 80 | app.before_request(ProfilerTool.before_request) 81 | app.after_request(ProfilerTool.after_request) 82 | 83 | 84 | class ProfilerTool(object): 85 | """Profiler. 86 | """ 87 | 88 | def __init__(self): 89 | self.profiler = profile.Profile() 90 | self.stats = None 91 | self.profiler.enable() 92 | 93 | def disable(self): 94 | self.profiler.disable() 95 | self.stats = pstats.Stats(self.profiler) 96 | 97 | @property 98 | def func_calls(self): 99 | """Get collected profiling data. 100 | """ 101 | func_calls = [] 102 | if not self.stats: 103 | return func_calls 104 | 105 | for func in self.stats.sort_stats(1).fcn_list: 106 | info = self.stats.stats[func] 107 | stat = {} 108 | 109 | # Number of calls 110 | if info[0] != info[1]: 111 | stat['ncalls'] = "%d/%d" % (info[1], info[0]) 112 | else: 113 | stat['ncalls'] = info[1] 114 | 115 | # Total time 116 | stat['tottime'] = info[2] * 1000 117 | 118 | # Time per call 119 | if info[1]: 120 | stat['percall'] = info[2] * 1000 / info[1] 121 | else: 122 | stat['percall'] = 0 123 | 124 | # Cumulative time spent in this and all subfunctions 125 | stat['cumtime'] = info[3] * 1000 126 | 127 | # Cumulative time per primitive call 128 | if info[0]: 129 | stat['percall_cum'] = info[3] * 1000 / info[0] 130 | else: 131 | stat['percall_cum'] = 0 132 | 133 | # Filename 134 | filename = pstats.func_std_string(func) 135 | stat['filename'] = filename_format(filename) 136 | 137 | func_calls.append(stat) 138 | 139 | return func_calls 140 | 141 | @property 142 | def total_time(self): 143 | if self.stats: 144 | return float(self.stats.total_tt) * 1000 145 | 146 | @property 147 | def content(self): 148 | """HTML content for your profile stats. 149 | """ 150 | return render_template('_profile/profiler.html', 151 | total_time=self.total_time, 152 | func_calls=self.func_calls) 153 | 154 | @classmethod 155 | def before_request(cls): 156 | request._profiler_tool = ProfilerTool() 157 | 158 | @classmethod 159 | def after_request(cls, response): 160 | request._profiler_tool.disable() 161 | if response.status_code == 200 and \ 162 | response.headers['content-type'].startswith('text/html'): 163 | html = response.data.decode(response.charset) 164 | html = insensitive_replace( 165 | html, '', request._profiler_tool.content + '') 166 | html = html.encode(response.charset) 167 | response.response = [html] 168 | response.content_length = len(html) 169 | return response 170 | -------------------------------------------------------------------------------- /flask_profile/static/css/profiler.css: -------------------------------------------------------------------------------- 1 | #_profileContent { 2 | font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Geneva', 'Verdana', sans-serif; 3 | color: #000; 4 | font-size: 15px; 5 | } 6 | #_profileContentWrapper { 7 | position: fixed; 8 | background-color: #fff; 9 | margin: 0px; 10 | top: 0px; 11 | left: 0px; 12 | right: 0px; 13 | bottom: 0px; 14 | padding: 28px 20px 20px 20px; 15 | overflow: auto; 16 | z-index: 99999999; 17 | } 18 | #_profileContent h1 { 19 | font-size: 32px; 20 | margin: 0 0 0.3em 0; 21 | } 22 | #_profileContent h2 { 23 | font-size: 16px; 24 | margin: 1.3em 8px 0 8px; 25 | padding: 9px; 26 | background-color: #11557C; 27 | color: white; 28 | } 29 | #_profileContent h1, h2 { 30 | font-weight: normal; 31 | } 32 | #_profileContent em { 33 | font-style: normal; 34 | color: #A5D6D9; 35 | font-weight: normal; 36 | } 37 | #_profileContent .profileContentDetail { 38 | margin: 0 8px 0 8px; 39 | font-size: 14px; 40 | } 41 | #_profileContent .profileContentFooter { 42 | font-size: 13px; 43 | text-align: right; 44 | margin: 30px 8px 0 0; 45 | color: #86989B; 46 | } 47 | 48 | /* tablesorted */ 49 | #_profileContent table.tablesorter { 50 | width: 100%; 51 | } 52 | #_profileContent table.tablesorter thead th { 53 | background: url(../img/bg.gif) center right no-repeat; 54 | padding-right: 20px; 55 | cursor: pointer; 56 | } 57 | #_profileContent table.tablesorter tr.profileContentTrOdd { 58 | background-color: #fff; 59 | } 60 | #_profileContent table.tablesorter tr.profileContentTrEven { 61 | background-color: #E8EFF0; 62 | } 63 | #_profileContent table.tablesorter thead .headerSortUp { 64 | background-image: url(../img/asc.gif); 65 | } 66 | #_profileContent table.tablesorter thead .headerSortDown { 67 | background-image: url(../img/desc.gif); 68 | } 69 | #_profileContent table.tablesorter thead .headerSortDown, #_profileContent table.tablesorter thead .headerSortUp { 70 | background-color: #8dbdd8; 71 | } 72 | 73 | /* handle */ 74 | #_profileContent #flaskProfileHandle { 75 | position: fixed; 76 | background: #fff; 77 | border: 1px solid #11557C; 78 | top: 30px; 79 | right: 0; 80 | z-index: 100000000; 81 | opacity: 0.75; 82 | } 83 | 84 | #_profileContent a#flaskShowProfileButton { 85 | display: block; 86 | height: 75px; 87 | width: 30px; 88 | border-right: none; 89 | border-bottom: 4px solid #fff; 90 | border-top: 4px solid #fff; 91 | border-left: 4px solid #fff; 92 | color: #fff; 93 | font-size: 10px; 94 | font-weight: bold; 95 | text-decoration: none; 96 | text-align: center; 97 | text-indent: -999999px; 98 | background: #11557C url(../img/profile.png) no-repeat left center; 99 | opacity: 0.5; 100 | } 101 | 102 | #_profileContent a#flaskShowProfileButton:hover { 103 | background-color: #11557C; 104 | padding-right: 6px; 105 | border-top-color: #FFFF00; 106 | border-left-color: #FFFF00; 107 | border-bottom-color: #FFFF00; 108 | opacity: 1.0; 109 | } 110 | -------------------------------------------------------------------------------- /flask_profile/static/img/asc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengsp/flask-profile/d0a8abc7ab79f6762a8031548956ac0e4fdf2045/flask_profile/static/img/asc.gif -------------------------------------------------------------------------------- /flask_profile/static/img/bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengsp/flask-profile/d0a8abc7ab79f6762a8031548956ac0e4fdf2045/flask_profile/static/img/bg.gif -------------------------------------------------------------------------------- /flask_profile/static/img/desc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengsp/flask-profile/d0a8abc7ab79f6762a8031548956ac0e4fdf2045/flask_profile/static/img/desc.gif -------------------------------------------------------------------------------- /flask_profile/static/img/profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fengsp/flask-profile/d0a8abc7ab79f6762a8031548956ac0e4fdf2045/flask_profile/static/img/profile.png -------------------------------------------------------------------------------- /flask_profile/static/js/jquery.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery JavaScript Library v1.5 3 | * http://jquery.com/ 4 | * 5 | * Copyright 2011, John Resig 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | * http://jquery.org/license 8 | * 9 | * Includes Sizzle.js 10 | * http://sizzlejs.com/ 11 | * Copyright 2011, The Dojo Foundation 12 | * Released under the MIT, BSD, and GPL Licenses. 13 | * 14 | * Date: Mon Jan 31 08:31:29 2011 -0500 15 | */ 16 | (function(a,b){function b$(a){return d.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function bX(a){if(!bR[a]){var b=d("<"+a+">").appendTo("body"),c=b.css("display");b.remove();if(c==="none"||c==="")c="block";bR[a]=c}return bR[a]}function bW(a,b){var c={};d.each(bV.concat.apply([],bV.slice(0,b)),function(){c[this]=a});return c}function bJ(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var e=a.dataTypes,f=a.converters,g,h=e.length,i,j=e[0],k,l,m,n,o;for(g=1;g=0===c})}function N(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function F(a,b){return(a&&a!=="*"?a+".":"")+b.replace(q,"`").replace(r,"&")}function E(a){var b,c,e,f,g,h,i,j,k,l,m,n,p,q=[],r=[],s=d._data(this,u);typeof s==="function"&&(s=s.events);if(a.liveFired!==this&&s&&s.live&&!a.target.disabled&&(!a.button||a.type!=="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var t=s.live.slice(0);for(i=0;ic)break;a.currentTarget=f.elem,a.data=f.handleObj.data,a.handleObj=f.handleObj,p=f.handleObj.origHandler.apply(f.elem,arguments);if(p===!1||a.isPropagationStopped()){c=f.level,p===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function C(a,b,c){c[0].type=a;return d.event.handle.apply(b,c)}function w(){return!0}function v(){return!1}function f(a,c,f){if(f===b&&a.nodeType===1){f=a.getAttribute("data-"+c);if(typeof f==="string"){try{f=f==="true"?!0:f==="false"?!1:f==="null"?null:d.isNaN(f)?e.test(f)?d.parseJSON(f):f:parseFloat(f)}catch(g){}d.data(a,c,f)}else f=b}return f}var c=a.document,d=function(){function I(){if(!d.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(I,1);return}d.ready()}}var d=function(a,b){return new d.fn.init(a,b,g)},e=a.jQuery,f=a.$,g,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,i=/\S/,j=/^\s+/,k=/\s+$/,l=/\d/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=navigator.userAgent,w,x=!1,y,z="then done fail isResolved isRejected promise".split(" "),A,B=Object.prototype.toString,C=Object.prototype.hasOwnProperty,D=Array.prototype.push,E=Array.prototype.slice,F=String.prototype.trim,G=Array.prototype.indexOf,H={};d.fn=d.prototype={constructor:d,init:function(a,e,f){var g,i,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!e&&c.body){this.context=c,this[0]=c.body,this.selector="body",this.length=1;return this}if(typeof a==="string"){g=h.exec(a);if(!g||!g[1]&&e)return!e||e.jquery?(e||f).find(a):this.constructor(e).find(a);if(g[1]){e=e instanceof d?e[0]:e,k=e?e.ownerDocument||e:c,j=m.exec(a),j?d.isPlainObject(e)?(a=[c.createElement(j[1])],d.fn.attr.call(a,e,!0)):a=[k.createElement(j[1])]:(j=d.buildFragment([g[1]],[k]),a=(j.cacheable?d.clone(j.fragment):j.fragment).childNodes);return d.merge(this,a)}i=c.getElementById(g[2]);if(i&&i.parentNode){if(i.id!==g[2])return f.find(a);this.length=1,this[0]=i}this.context=c,this.selector=a;return this}if(d.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return d.makeArray(a,this)},selector:"",jquery:"1.5",length:0,size:function(){return this.length},toArray:function(){return E.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var e=this.constructor();d.isArray(a)?D.apply(e,a):d.merge(e,a),e.prevObject=this,e.context=this.context,b==="find"?e.selector=this.selector+(this.selector?" ":"")+c:b&&(e.selector=this.selector+"."+b+"("+c+")");return e},each:function(a,b){return d.each(this,a,b)},ready:function(a){d.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(E.apply(this,arguments),"slice",E.call(arguments).join(","))},map:function(a){return this.pushStack(d.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:D,sort:[].sort,splice:[].splice},d.fn.init.prototype=d.fn,d.extend=d.fn.extend=function(){var a,c,e,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i==="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!=="object"&&!d.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;y.resolveWith(c,[d]),d.fn.trigger&&d(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!x){x=!0;if(c.readyState==="complete")return setTimeout(d.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",A,!1),a.addEventListener("load",d.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",A),a.attachEvent("onload",d.ready);var b=!1;try{b=a.frameElement==null}catch(e){}c.documentElement.doScroll&&b&&I()}}},isFunction:function(a){return d.type(a)==="function"},isArray:Array.isArray||function(a){return d.type(a)==="array"},isWindow:function(a){return a&&typeof a==="object"&&"setInterval"in a},isNaN:function(a){return a==null||!l.test(a)||isNaN(a)},type:function(a){return a==null?String(a):H[B.call(a)]||"object"},isPlainObject:function(a){if(!a||d.type(a)!=="object"||a.nodeType||d.isWindow(a))return!1;if(a.constructor&&!C.call(a,"constructor")&&!C.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a){}return c===b||C.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!=="string"||!b)return null;b=d.trim(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return a.JSON&&a.JSON.parse?a.JSON.parse(b):(new Function("return "+b))();d.error("Invalid JSON: "+b)},parseXML:function(b,c,e){a.DOMParser?(e=new DOMParser,c=e.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),e=c.documentElement,(!e||!e.nodeName||e.nodeName==="parsererror")&&d.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(a){if(a&&i.test(a)){var b=c.getElementsByTagName("head")[0]||c.documentElement,e=c.createElement("script");e.type="text/javascript",d.support.scriptEval()?e.appendChild(c.createTextNode(a)):e.text=a,b.insertBefore(e,b.firstChild),b.removeChild(e)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,e){var f,g=0,h=a.length,i=h===b||d.isFunction(a);if(e){if(i){for(f in a)if(c.apply(a[f],e)===!1)break}else for(;g1?(g=Array(c),d.each(b,function(a,b){d.when(b).then(function(b){g[a]=arguments.length>1?E.call(arguments,0):b,--c||e.resolveWith(f,g)},e.reject)})):e!==a&&e.resolve(a);return f},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}d.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.subclass=this.subclass,a.fn.init=function b(b,c){c&&c instanceof d&&!(c instanceof a)&&(c=a(c));return d.fn.init.call(this,b,c,e)},a.fn.init.prototype=a.fn;var e=a(c);return a},browser:{}}),y=d._Deferred(),d.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){H["[object "+b+"]"]=b.toLowerCase()}),w=d.uaMatch(v),w.browser&&(d.browser[w.browser]=!0,d.browser.version=w.version),d.browser.webkit&&(d.browser.safari=!0),G&&(d.inArray=function(a,b){return G.call(b,a)}),i.test(" ")&&(j=/^[\s\xA0]+/,k=/[\s\xA0]+$/),g=d(c),c.addEventListener?A=function(){c.removeEventListener("DOMContentLoaded",A,!1),d.ready()}:c.attachEvent&&(A=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",A),d.ready())});return a.jQuery=a.$=d}();(function(){d.support={};var b=c.createElement("div");b.style.display="none",b.innerHTML="
a";var e=b.getElementsByTagName("*"),f=b.getElementsByTagName("a")[0],g=c.createElement("select"),h=g.appendChild(c.createElement("option"));if(e&&e.length&&f){d.support={leadingWhitespace:b.firstChild.nodeType===3,tbody:!b.getElementsByTagName("tbody").length,htmlSerialize:!!b.getElementsByTagName("link").length,style:/red/.test(f.getAttribute("style")),hrefNormalized:f.getAttribute("href")==="/a",opacity:/^0.55$/.test(f.style.opacity),cssFloat:!!f.style.cssFloat,checkOn:b.getElementsByTagName("input")[0].value==="on",optSelected:h.selected,deleteExpando:!0,optDisabled:!1,checkClone:!1,_scriptEval:null,noCloneEvent:!0,boxModel:null,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableHiddenOffsets:!0},g.disabled=!0,d.support.optDisabled=!h.disabled,d.support.scriptEval=function(){if(d.support._scriptEval===null){var b=c.documentElement,e=c.createElement("script"),f="script"+d.now();e.type="text/javascript";try{e.appendChild(c.createTextNode("window."+f+"=1;"))}catch(g){}b.insertBefore(e,b.firstChild),a[f]?(d.support._scriptEval=!0,delete a[f]):d.support._scriptEval=!1,b.removeChild(e),b=e=f=null}return d.support._scriptEval};try{delete b.test}catch(i){d.support.deleteExpando=!1}b.attachEvent&&b.fireEvent&&(b.attachEvent("onclick",function j(){d.support.noCloneEvent=!1,b.detachEvent("onclick",j)}),b.cloneNode(!0).fireEvent("onclick")),b=c.createElement("div"),b.innerHTML="";var k=c.createDocumentFragment();k.appendChild(b.firstChild),d.support.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,d(function(){var a=c.createElement("div"),b=c.getElementsByTagName("body")[0];if(b){a.style.width=a.style.paddingLeft="1px",b.appendChild(a),d.boxModel=d.support.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,d.support.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",d.support.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
";var e=a.getElementsByTagName("td");d.support.reliableHiddenOffsets=e[0].offsetHeight===0,e[0].style.display="",e[1].style.display="none",d.support.reliableHiddenOffsets=d.support.reliableHiddenOffsets&&e[0].offsetHeight===0,a.innerHTML="",b.removeChild(a).style.display="none",a=e=null}});var l=function(a){var b=c.createElement("div");a="on"+a;if(!b.attachEvent)return!0;var d=a in b;d||(b.setAttribute(a,"return;"),d=typeof b[a]==="function"),b=null;return d};d.support.submitBubbles=l("submit"),d.support.changeBubbles=l("change"),b=e=f=null}})();var e=/^(?:\{.*\}|\[.*\])$/;d.extend({cache:{},uuid:0,expando:"jQuery"+(d.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?d.cache[a[d.expando]]:a[d.expando];return!!a&&!d.isEmptyObject(a)},data:function(a,c,e,f){if(d.acceptData(a)){var g=d.expando,h=typeof c==="string",i,j=a.nodeType,k=j?d.cache:a,l=j?a[d.expando]:a[d.expando]&&d.expando;if((!l||f&&l&&!k[l][g])&&h&&e===b)return;l||(j?a[d.expando]=l=++d.uuid:l=d.expando),k[l]||(k[l]={}),typeof c==="object"&&(f?k[l][g]=d.extend(k[l][g],c):k[l]=d.extend(k[l],c)),i=k[l],f&&(i[g]||(i[g]={}),i=i[g]),e!==b&&(i[c]=e);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[c]:i}},removeData:function(b,c,e){if(d.acceptData(b)){var f=d.expando,g=b.nodeType,h=g?d.cache:b,i=g?b[d.expando]:d.expando;if(!h[i])return;if(c){var j=e?h[i][f]:h[i];if(j){delete j[c];if(!d.isEmptyObject(j))return}}if(e){delete h[i][f];if(!d.isEmptyObject(h[i]))return}var k=h[i][f];d.support.deleteExpando||h!=a?delete h[i]:h[i]=null,k?(h[i]={},h[i][f]=k):g&&(d.support.deleteExpando?delete b[d.expando]:b.removeAttribute?b.removeAttribute(d.expando):b[d.expando]=null)}},_data:function(a,b,c){return d.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=d.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),d.fn.extend({data:function(a,c){var e=null;if(typeof a==="undefined"){if(this.length){e=d.data(this[0]);if(this[0].nodeType===1){var g=this[0].attributes,h;for(var i=0,j=g.length;i-1)return!0;return!1},val:function(a){if(!arguments.length){var c=this[0];if(c){if(d.nodeName(c,"option")){var e=c.attributes.value;return!e||e.specified?c.value:c.text}if(d.nodeName(c,"select")){var f=c.selectedIndex,g=[],h=c.options,j=c.type==="select-one";if(f<0)return null;for(var k=j?f:0,l=j?f+1:h.length;k=0;else if(d.nodeName(this,"select")){var f=d.makeArray(e);d("option",this).each(function(){this.selected=d.inArray(d(this).val(),f)>=0}),f.length||(this.selectedIndex=-1)}else this.value=e}})}}),d.extend({attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,e,f){if(!a||a.nodeType===3||a.nodeType===8||a.nodeType===2)return b;if(f&&c in d.attrFn)return d(a)[c](e);var g=a.nodeType!==1||!d.isXMLDoc(a),h=e!==b;c=g&&d.props[c]||c;if(a.nodeType===1){var i=j.test(c);if(c==="selected"&&!d.support.optSelected){var n=a.parentNode;n&&(n.selectedIndex,n.parentNode&&n.parentNode.selectedIndex)}if((c in a||a[c]!==b)&&g&&!i){h&&(c==="type"&&k.test(a.nodeName)&&a.parentNode&&d.error("type property can't be changed"),e===null?a.nodeType===1&&a.removeAttribute(c):a[c]=e);if(d.nodeName(a,"form")&&a.getAttributeNode(c))return a.getAttributeNode(c).nodeValue;if(c==="tabIndex"){var o=a.getAttributeNode("tabIndex");return o&&o.specified?o.value:l.test(a.nodeName)||m.test(a.nodeName)&&a.href?0:b}return a[c]}if(!d.support.style&&g&&c==="style"){h&&(a.style.cssText=""+e);return a.style.cssText}h&&a.setAttribute(c,""+e);if(!a.attributes[c]&&(a.hasAttribute&&!a.hasAttribute(c)))return b;var p=!d.support.hrefNormalized&&g&&i?a.getAttribute(c,2):a.getAttribute(c);return p===null?b:p}h&&(a[c]=e);return a[c]}});var o=/\.(.*)$/,p=/^(?:textarea|input|select)$/i,q=/\./g,r=/ /g,s=/[^\w\s.|`]/g,t=function(a){return a.replace(s,"\\$&")},u="events";d.event={add:function(c,e,f,g){if(c.nodeType!==3&&c.nodeType!==8){d.isWindow(c)&&(c!==a&&!c.frameElement)&&(c=a);if(f===!1)f=v;else if(!f)return;var h,i;f.handler&&(h=f,f=h.handler),f.guid||(f.guid=d.guid++);var j=d._data(c);if(!j)return;var k=j[u],l=j.handle;typeof k==="function"?(l=k.handle,k=k.events):k||(c.nodeType||(j[u]=j=function(){}),j.events=k={}),l||(j.handle=l=function(){return typeof d!=="undefined"&&!d.event.triggered?d.event.handle.apply(l.elem,arguments):b}),l.elem=c,e=e.split(" ");var m,n=0,o;while(m=e[n++]){i=h?d.extend({},h):{handler:f,data:g},m.indexOf(".")>-1?(o=m.split("."),m=o.shift(),i.namespace=o.slice(0).sort().join(".")):(o=[],i.namespace=""),i.type=m,i.guid||(i.guid=f.guid);var p=k[m],q=d.event.special[m]||{};if(!p){p=k[m]=[];if(!q.setup||q.setup.call(c,g,o,l)===!1)c.addEventListener?c.addEventListener(m,l,!1):c.attachEvent&&c.attachEvent("on"+m,l)}q.add&&(q.add.call(c,i),i.handler.guid||(i.handler.guid=f.guid)),p.push(i),d.event.global[m]=!0}c=null}},global:{},remove:function(a,c,e,f){if(a.nodeType!==3&&a.nodeType!==8){e===!1&&(e=v);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=d.hasData(a)&&d._data(a),w=s&&s[u];if(!s||!w)return;typeof w==="function"&&(s=w,w=w.events),c&&c.type&&(e=c.handler,c=c.type);if(!c||typeof c==="string"&&c.charAt(0)==="."){c=c||"";for(h in w)d.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+d.map(m.slice(0).sort(),t).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=w[h];if(!p)continue;if(!e){for(j=0;j=0&&(a.type=f=f.slice(0,-1),a.exclusive=!0),e||(a.stopPropagation(),d.event.global[f]&&d.each(d.cache,function(){var b=d.expando,e=this[b];e&&e.events&&e.events[f]&&d.event.trigger(a,c,e.handle.elem)}));if(!e||e.nodeType===3||e.nodeType===8)return b;a.result=b,a.target=e,c=d.makeArray(c),c.unshift(a)}a.currentTarget=e;var h=e.nodeType?d._data(e,"handle"):(d._data(e,u)||{}).handle;h&&h.apply(e,c);var i=e.parentNode||e.ownerDocument;try{e&&e.nodeName&&d.noData[e.nodeName.toLowerCase()]||e["on"+f]&&e["on"+f].apply(e,c)===!1&&(a.result=!1,a.preventDefault())}catch(j){}if(!a.isPropagationStopped()&&i)d.event.trigger(a,c,i,!0);else if(!a.isDefaultPrevented()){var k,l=a.target,m=f.replace(o,""),n=d.nodeName(l,"a")&&m==="click",p=d.event.special[m]||{};if((!p._default||p._default.call(e,a)===!1)&&!n&&!(l&&l.nodeName&&d.noData[l.nodeName.toLowerCase()])){try{l[m]&&(k=l["on"+m],k&&(l["on"+m]=null),d.event.triggered=!0,l[m]())}catch(q){}k&&(l["on"+m]=k),d.event.triggered=!1}}},handle:function(c){var e,f,g,h,i,j=[],k=d.makeArray(arguments);c=k[0]=d.event.fix(c||a.event),c.currentTarget=this,e=c.type.indexOf(".")<0&&!c.exclusive,e||(g=c.type.split("."),c.type=g.shift(),j=g.slice(0).sort(),h=new RegExp("(^|\\.)"+j.join("\\.(?:.*\\.)?")+"(\\.|$)")),c.namespace=c.namespace||j.join("."),i=d._data(this,u),typeof i==="function"&&(i=i.events),f=(i||{})[c.type];if(i&&f){f=f.slice(0);for(var l=0,m=f.length;l-1?d.map(a.options,function(a){return a.selected}).join("-"):"":a.nodeName.toLowerCase()==="select"&&(c=a.selectedIndex);return c},B=function B(a){var c=a.target,e,f;if(p.test(c.nodeName)&&!c.readOnly){e=d._data(c,"_change_data"),f=A(c),(a.type!=="focusout"||c.type!=="radio")&&d._data(c,"_change_data",f);if(e===b||f===e)return;if(e!=null||f){a.type="change",a.liveFired=b;return d.event.trigger(a,arguments[1],c)}}};d.event.special.change={filters:{focusout:B,beforedeactivate:B,click:function(a){var b=a.target,c=b.type;if(c==="radio"||c==="checkbox"||b.nodeName.toLowerCase()==="select")return B.call(this,a)},keydown:function(a){var b=a.target,c=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")return B.call(this,a)},beforeactivate:function(a){var b=a.target;d._data(b,"_change_data",A(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in z)d.event.add(this,c+".specialChange",z[c]);return p.test(this.nodeName)},teardown:function(a){d.event.remove(this,".specialChange");return p.test(this.nodeName)}},z=d.event.special.change.filters,z.focus=z.beforeactivate}c.addEventListener&&d.each({focus:"focusin",blur:"focusout"},function(a,b){function c(a){a=d.event.fix(a),a.type=b;return d.event.handle.call(this,a)}d.event.special[b]={setup:function(){this.addEventListener(a,c,!0)},teardown:function(){this.removeEventListener(a,c,!0)}}}),d.each(["bind","one"],function(a,c){d.fn[c]=function(a,e,f){if(typeof a==="object"){for(var g in a)this[c](g,e,a[g],f);return this}if(d.isFunction(e)||e===!1)f=e,e=b;var h=c==="one"?d.proxy(f,function(a){d(this).unbind(a,h);return f.apply(this,arguments)}):f;if(a==="unload"&&c!=="one")this.one(a,e,f);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},d.attrFn&&(d.attrFn[b]=!0)}),function(){function s(a,b,c,d,e,f){for(var g=0,h=d.length;g0){k=j;break}}j=j[a]}d[g]=k}}}function r(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,g=!1,h=!0;[0,0].sort(function(){h=!1;return 0});var i=function(b,d,e,g){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!=="string")return e;var l,m,o,p,q,r,s,u,v=!0,w=i.isXML(d),x=[],y=b;do{a.exec(""),l=a.exec(y);if(l){y=l[3],x.push(l[1]);if(l[2]){p=l[3];break}}}while(l);if(x.length>1&&k.exec(b))if(x.length===2&&j.relative[x[0]])m=t(x[0]+x[1],d);else{m=j.relative[x[0]]?[d]:i(x.shift(),d);while(x.length)b=x.shift(),j.relative[b]&&(b+=x.shift()),m=t(b,m)}else{!g&&x.length>1&&d.nodeType===9&&!w&&j.match.ID.test(x[0])&&!j.match.ID.test(x[x.length-1])&&(q=i.find(x.shift(),d,w),d=q.expr?i.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:n(g)}:i.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),m=q.expr?i.filter(q.expr,q.set):q.set,x.length>0?o=n(m):v=!1;while(x.length)r=x.pop(),s=r,j.relative[r]?s=x.pop():r="",s==null&&(s=d),j.relative[r](o,s,w)}else o=x=[]}o||(o=m),o||i.error(r||b);if(f.call(o)==="[object Array]")if(v)if(d&&d.nodeType===1)for(u=0;o[u]!=null;u++)o[u]&&(o[u]===!0||o[u].nodeType===1&&i.contains(d,o[u]))&&e.push(m[u]);else for(u=0;o[u]!=null;u++)o[u]&&o[u].nodeType===1&&e.push(m[u]);else e.push.apply(e,o);else n(o,e);p&&(i(p,h,e,g),i.uniqueSort(e));return e};i.uniqueSort=function(a){if(p){g=h,a.sort(p);if(g)for(var b=1;b0},i.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=j.order.length;e":function(a,b){var c,d=typeof b==="string",e=0,f=a.length;if(d&&!/\W/.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(/\\/g,"")},TAG:function(a,b){return a[1].toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||i.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&i.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(/\\/g,"");!f&&j.attrMap[g]&&(a[1]=j.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(/\\/g,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=i(b[3],null,null,c);else{var g=i.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(j.match.POS.test(b[0])||j.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!i(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){return"text"===a.type},radio:function(a){return"radio"===a.type},checkbox:function(a){return"checkbox"===a.type},file:function(a){return"file"===a.type},password:function(a){return"password"===a.type},submit:function(a){return"submit"===a.type},image:function(a){return"image"===a.type},reset:function(a){return"reset"===a.type},button:function(a){return"button"===a.type||a.nodeName.toLowerCase()==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=j.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||i.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,k=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=j.attrHandle[c]?j.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=j.setFilters[e];if(f)return f(a,c,b,d)}}},k=j.match.POS,l=function(a,b){return"\\"+(b-0+1)};for(var m in j.match)j.match[m]=new RegExp(j.match[m].source+/(?![^\[]*\])(?![^\(]*\))/.source),j.leftMatch[m]=new RegExp(/(^(?:.|\r|\n)*?)/.source+j.match[m].source.replace(/\\(\d+)/g,l));var n=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(o){n=function(a,b){var c=0,d=b||[];if(f.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length==="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(j.find.ID=function(a,c,d){if(typeof c.getElementById!=="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!=="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},j.filter.ID=function(a,b){var c=typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(j.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!=="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(j.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=i,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){i=function(b,e,f,g){e=e||c;if(!g&&!i.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return n(e.getElementsByTagName(b),f);if(h[2]&&j.find.CLASS&&e.getElementsByClassName)return n(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return n([e.body],f);if(h&&h[3]){var k=e.getElementById(h[3]);if(!k||!k.parentNode)return n([],f);if(k.id===h[3])return n([k],f)}try{return n(e.querySelectorAll(b),f)}catch(l){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e.getAttribute("id"),o=m||d,p=e.parentNode,q=/^\s*[+~]/.test(b);m?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),q&&p&&(e=e.parentNode);try{if(!q||p)return n(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(r){}finally{m||e.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)i[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector,d=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(e){d=!0}b&&(i.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!i.isXML(a))try{if(d||!j.match.PSEUDO.test(c)&&!/!=/.test(c))return b.call(a,c)}catch(e){}return i(c,null,null,[a]).length>0})}(),function(){var a=c.createElement("div");a.innerHTML="
";if(a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;j.order.splice(1,0,"CLASS"),j.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!=="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?i.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?i.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:i.contains=function(){return!1},i.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var t=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=j.match.PSEUDO.exec(a))e+=c[0],a=a.replace(j.match.PSEUDO,"");a=j.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(var g=c;g0},closest:function(a,b){var c=[],e,f,g=this[0];if(d.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(e=0,f=a.length;e-1:d(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=L.test(a)?d(a,b||this.context):null;for(e=0,f=this.length;e-1:d.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b)break}}c=c.length>1?d.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a==="string")return d.inArray(this[0],a?d(a):this.parent().children());return d.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a==="string"?d(a,b):d.makeArray(a),e=d.merge(this.get(),c);return this.pushStack(N(c[0])||N(e[0])?e:d.unique(e))},andSelf:function(){return this.add(this.prevObject)}}),d.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return d.dir(a,"parentNode")},parentsUntil:function(a,b,c){return d.dir(a,"parentNode",c)},next:function(a){return d.nth(a,2,"nextSibling")},prev:function(a){return d.nth(a,2,"previousSibling")},nextAll:function(a){return d.dir(a,"nextSibling")},prevAll:function(a){return d.dir(a,"previousSibling")},nextUntil:function(a,b,c){return d.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return d.dir(a,"previousSibling",c)},siblings:function(a){return d.sibling(a.parentNode.firstChild,a)},children:function(a){return d.sibling(a.firstChild)},contents:function(a){return d.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:d.makeArray(a.childNodes)}},function(a,b){d.fn[a]=function(c,e){var f=d.map(this,b,c),g=K.call(arguments);G.test(a)||(e=c),e&&typeof e==="string"&&(f=d.filter(e,f)),f=this.length>1&&!M[a]?d.unique(f):f,(this.length>1||I.test(e))&&H.test(a)&&(f=f.reverse());return this.pushStack(f,a,g.join(","))}}),d.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?d.find.matchesSelector(b[0],a)?[b[0]]:[]:d.find.matches(a,b)},dir:function(a,c,e){var f=[],g=a[c];while(g&&g.nodeType!==9&&(e===b||g.nodeType!==1||!d(g).is(e)))g.nodeType===1&&f.push(g),g=g[c];return f},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var P=/ jQuery\d+="(?:\d+|null)"/g,Q=/^\s+/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,S=/<([\w:]+)/,T=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};X.optgroup=X.option,X.tbody=X.tfoot=X.colgroup=X.caption=X.thead,X.th=X.td,d.support.htmlSerialize||(X._default=[1,"div
","
"]),d.fn.extend({text:function(a){if(d.isFunction(a))return this.each(function(b){var c=d(this);c.text(a.call(this,b,c.text()))});if(typeof a!=="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return d.text(this)},wrapAll:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapAll(a.call(this,b))});if(this[0]){var b=d(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapInner(a.call(this,b))});return this.each(function(){var b=d(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){d(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){d.nodeName(this,"body")||d(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=d(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,d(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,e;(e=this[c])!=null;c++)if(!a||d.filter(a,[e]).length)!b&&e.nodeType===1&&(d.cleanData(e.getElementsByTagName("*")),d.cleanData([e])),e.parentNode&&e.parentNode.removeChild(e);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&d.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!0:a,b=b==null?a:b;return this.map(function(){return d.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(P,""):null;if(typeof a!=="string"||V.test(a)||!d.support.leadingWhitespace&&Q.test(a)||X[(S.exec(a)||["",""])[1].toLowerCase()])d.isFunction(a)?this.each(function(b){var c=d(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);else{a=a.replace(R,"<$1>");try{for(var c=0,e=this.length;c1&&l0?this.clone(!0):this).get();d(f[h])[b](j),e=e.concat(j)}return this.pushStack(e,a,f.selector)}}),d.extend({clone:function(a,b,c){var e=a.cloneNode(!0),f,g,h;if(!d.support.noCloneEvent&&(a.nodeType===1||a.nodeType===11)&&!d.isXMLDoc(a)){f=a.getElementsByTagName("*"),g=e.getElementsByTagName("*");for(h=0;f[h];++h)$(f[h],g[h]);$(a,e)}if(b){Z(a,e);if(c&&"getElementsByTagName"in a){f=a.getElementsByTagName("*"),g=e.getElementsByTagName("*");if(f.length)for(h=0;f[h];++h)Z(f[h],g[h])}}return e},clean:function(a,b,e,f){b=b||c,typeof b.createElement==="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var g=[];for(var h=0,i;(i=a[h])!=null;h++){typeof i==="number"&&(i+="");if(!i)continue;if(typeof i!=="string"||U.test(i)){if(typeof i==="string"){i=i.replace(R,"<$1>");var j=(S.exec(i)||["",""])[1].toLowerCase(),k=X[j]||X._default,l=k[0],m=b.createElement("div");m.innerHTML=k[1]+i+k[2];while(l--)m=m.lastChild;if(!d.support.tbody){var n=T.test(i),o=j==="table"&&!n?m.firstChild&&m.firstChild.childNodes:k[1]===""&&!n?m.childNodes:[];for(var p=o.length-1;p>=0;--p)d.nodeName(o[p],"tbody")&&!o[p].childNodes.length&&o[p].parentNode.removeChild(o[p])}!d.support.leadingWhitespace&&Q.test(i)&&m.insertBefore(b.createTextNode(Q.exec(i)[0]),m.firstChild),i=m.childNodes}}else i=b.createTextNode(i);i.nodeType?g.push(i):g=d.merge(g,i)}if(e)for(h=0;g[h];h++)!f||!d.nodeName(g[h],"script")||g[h].type&&g[h].type.toLowerCase()!=="text/javascript"?(g[h].nodeType===1&&g.splice.apply(g,[h+1,0].concat(d.makeArray(g[h].getElementsByTagName("script")))),e.appendChild(g[h])):f.push(g[h].parentNode?g[h].parentNode.removeChild(g[h]):g[h]);return g},cleanData:function(a){var b,c,e=d.cache,f=d.expando,g=d.event.special,h=d.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&d.noData[j.nodeName.toLowerCase()])continue;c=j[d.expando];if(c){b=e[c]&&e[c][f];if(b&&b.events){for(var k in b.events)g[k]?d.event.remove(j,k):d.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[d.expando]:j.removeAttribute&&j.removeAttribute(d.expando),delete e[c]}}}});var ba=/alpha\([^)]*\)/i,bb=/opacity=([^)]*)/,bc=/-([a-z])/ig,bd=/([A-Z])/g,be=/^-?\d+(?:px)?$/i,bf=/^-?\d/,bg={position:"absolute",visibility:"hidden",display:"block"},bh=["Left","Right"],bi=["Top","Bottom"],bj,bk,bl,bm=function(a,b){return b.toUpperCase()};d.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return d.access(this,a,c,!0,function(a,c,e){return e!==b?d.style(a,c,e):d.css(a,c)})},d.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bj(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0},cssProps:{"float":d.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,e,f){if(a&&a.nodeType!==3&&a.nodeType!==8&&a.style){var g,h=d.camelCase(c),i=a.style,j=d.cssHooks[h];c=d.cssProps[h]||h;if(e===b){if(j&&"get"in j&&(g=j.get(a,!1,f))!==b)return g;return i[c]}if(typeof e==="number"&&isNaN(e)||e==null)return;typeof e==="number"&&!d.cssNumber[h]&&(e+="px");if(!j||!("set"in j)||(e=j.set(a,e))!==b)try{i[c]=e}catch(k){}}},css:function(a,c,e){var f,g=d.camelCase(c),h=d.cssHooks[g];c=d.cssProps[g]||g;if(h&&"get"in h&&(f=h.get(a,!0,e))!==b)return f;if(bj)return bj(a,c,g)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]},camelCase:function(a){return a.replace(bc,bm)}}),d.curCSS=d.css,d.each(["height","width"],function(a,b){d.cssHooks[b]={get:function(a,c,e){var f;if(c){a.offsetWidth!==0?f=bn(a,b,e):d.swap(a,bg,function(){f=bn(a,b,e)});if(f<=0){f=bj(a,b,b),f==="0px"&&bl&&(f=bl(a,b,b));if(f!=null)return f===""||f==="auto"?"0px":f}if(f<0||f==null){f=a.style[b];return f===""||f==="auto"?"0px":f}return typeof f==="string"?f:f+"px"}},set:function(a,b){if(!be.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),d.support.opacity||(d.cssHooks.opacity={get:function(a,b){return bb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style;c.zoom=1;var e=d.isNaN(b)?"":"alpha(opacity="+b*100+")",f=c.filter||"";c.filter=ba.test(f)?f.replace(ba,e):c.filter+" "+e}}),c.defaultView&&c.defaultView.getComputedStyle&&(bk=function(a,c,e){var f,g,h;e=e.replace(bd,"-$1").toLowerCase();if(!(g=a.ownerDocument.defaultView))return b;if(h=g.getComputedStyle(a,null))f=h.getPropertyValue(e),f===""&&!d.contains(a.ownerDocument.documentElement,a)&&(f=d.style(a,e));return f}),c.documentElement.currentStyle&&(bl=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!be.test(d)&&bf.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bj=bk||bl,d.expr&&d.expr.filters&&(d.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!d.support.reliableHiddenOffsets&&(a.style.display||d.css(a,"display"))==="none"},d.expr.filters.visible=function(a){return!d.expr.filters.hidden(a)});var bo=/%20/g,bp=/\[\]$/,bq=/\r?\n/g,br=/#.*$/,bs=/^(.*?):\s*(.*?)\r?$/mg,bt=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bu=/^(?:GET|HEAD)$/,bv=/^\/\//,bw=/\?/,bx=/)<[^<]*)*<\/script>/gi,by=/^(?:select|textarea)/i,bz=/\s+/,bA=/([?&])_=[^&]*/,bB=/^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/,bC=d.fn.load,bD={},bE={};d.fn.extend({load:function(a,b,c){if(typeof a!=="string"&&bC)return bC.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}var g="GET";b&&(d.isFunction(b)?(c=b,b=null):typeof b==="object"&&(b=d.param(b,d.ajaxSettings.traditional),g="POST"));var h=this;d.ajax({url:a,type:g,dataType:"html",data:b,complete:function(a,b,e){e=a.responseText,a.isResolved()&&(a.done(function(a){e=a}),h.html(f?d("
").append(e.replace(bx,"")).find(f):e)),c&&h.each(c,[e,b,a])}});return this},serialize:function(){return d.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?d.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||by.test(this.nodeName)||bt.test(this.type))}).map(function(a,b){var c=d(this).val();return c==null?null:d.isArray(c)?d.map(c,function(a,c){return{name:b.name,value:a.replace(bq,"\r\n")}}):{name:b.name,value:c.replace(bq,"\r\n")}}).get()}}),d.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){d.fn[b]=function(a){return this.bind(b,a)}}),d.each(["get","post"],function(a,b){d[b]=function(a,c,e,f){d.isFunction(c)&&(f=f||e,e=c,c=null);return d.ajax({type:b,url:a,data:c,success:e,dataType:f})}}),d.extend({getScript:function(a,b){return d.get(a,null,b,"script")},getJSON:function(a,b,c){return d.get(a,b,c,"json")},ajaxSetup:function(a){d.extend(!0,d.ajaxSettings,a),a.context&&(d.ajaxSettings.context=a.context)},ajaxSettings:{url:location.href,global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":d.parseJSON,"text xml":d.parseXML}},ajaxPrefilter:bF(bD),ajaxTransport:bF(bE),ajax:function(a,e){function w(a,c,e,l){if(t!==2){t=2,p&&clearTimeout(p),o=b,m=l||"",v.readyState=a?4:0;var n,q,r,s=e?bI(f,v,e):b,u,w;if(a>=200&&a<300||a===304){if(f.ifModified){if(u=v.getResponseHeader("Last-Modified"))d.lastModified[f.url]=u;if(w=v.getResponseHeader("Etag"))d.etag[f.url]=w}if(a===304)c="notmodified",n=!0;else try{q=bJ(f,s),c="success",n=!0}catch(x){c="parsererror",r=x}}else r=c,a&&(c="error",a<0&&(a=0));v.status=a,v.statusText=c,n?i.resolveWith(g,[q,c,v]):i.rejectWith(g,[v,c,r]),v.statusCode(k),k=b,f.global&&h.trigger("ajax"+(n?"Success":"Error"),[v,f,n?q:r]),j.resolveWith(g,[v,c]),f.global&&(h.trigger("ajaxComplete",[v,f]),--d.active||d.event.trigger("ajaxStop"))}}typeof e!=="object"&&(e=a,a=b),e=e||{};var f=d.extend(!0,{},d.ajaxSettings,e),g=(f.context=("context"in e?e:d.ajaxSettings).context)||f,h=g===f?d.event:d(g),i=d.Deferred(),j=d._Deferred(),k=f.statusCode||{},l={},m,n,o,p,q=c.location,r=q.protocol||"http:",s,t=0,u,v={readyState:0,setRequestHeader:function(a,b){t===0&&(l[a.toLowerCase()]=b);return this},getAllResponseHeaders:function(){return t===2?m:null},getResponseHeader:function(a){var b;if(t===2){if(!n){n={};while(b=bs.exec(m))n[b[1].toLowerCase()]=b[2]}b=n[a.toLowerCase()]}return b||null},abort:function(a){a=a||"abort",o&&o.abort(a),w(0,a);return this}};i.promise(v),v.success=v.done,v.error=v.fail,v.complete=j.done,v.statusCode=function(a){if(a){var b;if(t<2)for(b in a)k[b]=[k[b],a[b]];else b=a[v.status],v.then(b,b)}return this},f.url=(""+(a||f.url)).replace(br,"").replace(bv,r+"//"),f.dataTypes=d.trim(f.dataType||"*").toLowerCase().split(bz),f.crossDomain||(s=bB.exec(f.url.toLowerCase()),f.crossDomain=s&&(s[1]!=r||s[2]!=q.hostname||(s[3]||(s[1]==="http:"?80:443))!=(q.port||(r==="http:"?80:443)))),f.data&&f.processData&&typeof f.data!=="string"&&(f.data=d.param(f.data,f.traditional)),bG(bD,f,e,v),f.type=f.type.toUpperCase(),f.hasContent=!bu.test(f.type),f.global&&d.active++===0&&d.event.trigger("ajaxStart");if(!f.hasContent){f.data&&(f.url+=(bw.test(f.url)?"&":"?")+f.data);if(f.cache===!1){var x=d.now(),y=f.url.replace(bA,"$1_="+x);f.url=y+(y===f.url?(bw.test(f.url)?"&":"?")+"_="+x:"")}}if(f.data&&f.hasContent&&f.contentType!==!1||e.contentType)l["content-type"]=f.contentType;f.ifModified&&(d.lastModified[f.url]&&(l["if-modified-since"]=d.lastModified[f.url]),d.etag[f.url]&&(l["if-none-match"]=d.etag[f.url])),l.accept=f.dataTypes[0]&&f.accepts[f.dataTypes[0]]?f.accepts[f.dataTypes[0]]+(f.dataTypes[0]!=="*"?", */*; q=0.01":""):f.accepts["*"];for(u in f.headers)l[u.toLowerCase()]=f.headers[u];if(!f.beforeSend||f.beforeSend.call(g,v,f)!==!1&&t!==2){for(u in {success:1,error:1,complete:1})v[u](f[u]);o=bG(bE,f,e,v);if(o){t=v.readyState=1,f.global&&h.trigger("ajaxSend",[v,f]),f.async&&f.timeout>0&&(p=setTimeout(function(){v.abort("timeout")},f.timeout));try{o.send(l,w)}catch(z){status<2?w(-1,z):d.error(z)}}else w(-1,"No Transport")}else w(0,"abort"),v=!1;return v},param:function(a,c){var e=[],f=function(a,b){b=d.isFunction(b)?b():b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=d.ajaxSettings.traditional);if(d.isArray(a)||a.jquery)d.each(a,function(){f(this.name,this.value)});else for(var g in a)bH(g,a[g],c,f);return e.join("&").replace(bo,"+")}}),d.extend({active:0,lastModified:{},etag:{}});var bK=d.now(),bL=/(\=)\?(&|$)|()\?\?()/i;d.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return d.expando+"_"+bK++}}),d.ajaxPrefilter("json jsonp",function(b,c,e){e=typeof b.data==="string";if(b.dataTypes[0]==="jsonp"||c.jsonpCallback||c.jsonp!=null||b.jsonp!==!1&&(bL.test(b.url)||e&&bL.test(b.data))){var f,g=b.jsonpCallback=d.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h=a[g],i=b.url,j=b.data,k="$1"+g+"$2";b.jsonp!==!1&&(i=i.replace(bL,k),b.url===i&&(e&&(j=j.replace(bL,k)),b.data===j&&(i+=(/\?/.test(i)?"&":"?")+b.jsonp+"="+g))),b.url=i,b.data=j,a[g]=function(a){f=[a]},b.complete=[function(){a[g]=h;if(h)f&&d.isFunction(h)&&a[g](f[0]);else try{delete a[g]}catch(b){}},b.complete],b.converters["script json"]=function(){f||d.error(g+" was not called");return f[0]},b.dataTypes[0]="json";return"script"}}),d.ajaxSetup({accepts:{script:"text/javascript, application/javascript"},contents:{script:/javascript/},converters:{"text script":function(a){d.globalEval(a);return a}}}),d.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),d.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var bM=d.now(),bN={},bO,bP;d.ajaxSettings.xhr=a.ActiveXObject?function(){if(a.location.protocol!=="file:")try{return new a.XMLHttpRequest}catch(b){}try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(c){}}:function(){return new a.XMLHttpRequest};try{bP=d.ajaxSettings.xhr()}catch(bQ){}d.support.ajax=!!bP,d.support.cors=bP&&"withCredentials"in bP,bP=b,d.support.ajax&&d.ajaxTransport(function(b){if(!b.crossDomain||d.support.cors){var c;return{send:function(e,f){bO||(bO=1,d(a).bind("unload",function(){d.each(bN,function(a,b){b.onreadystatechange&&b.onreadystatechange(1)})}));var g=b.xhr(),h;b.username?g.open(b.type,b.url,b.async,b.username,b.password):g.open(b.type,b.url,b.async),(!b.crossDomain||b.hasContent)&&!e["x-requested-with"]&&(e["x-requested-with"]="XMLHttpRequest");try{d.each(e,function(a,b){g.setRequestHeader(a,b)})}catch(i){}g.send(b.hasContent&&b.data||null),c=function(a,e){if(c&&(e||g.readyState===4)){c=0,h&&(g.onreadystatechange=d.noop,delete bN[h]);if(e)g.readyState!==4&&g.abort();else{var i=g.status,j,k=g.getAllResponseHeaders(),l={},m=g.responseXML;m&&m.documentElement&&(l.xml=m),l.text=g.responseText;try{j=g.statusText}catch(n){j=""}i=i===0?!b.crossDomain||j?k?304:0:302:i==1223?204:i,f(i,j,l,k)}}},b.async&&g.readyState!==4?(h=bM++,bN[h]=g,g.onreadystatechange=c):c()},abort:function(){c&&c(0,1)}}}});var bR={},bS=/^(?:toggle|show|hide)$/,bT=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,bU,bV=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];d.fn.extend({show:function(a,b,c){var e,f;if(a||a===0)return this.animate(bW("show",3),a,b,c);for(var g=0,h=this.length;g=0;a--)c[a].elem===this&&(b&&c[a](!0),c.splice(a,1))}),b||this.dequeue();return this}}),d.each({slideDown:bW("show",1),slideUp:bW("hide",1),slideToggle:bW("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){d.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),d.extend({speed:function(a,b,c){var e=a&&typeof a==="object"?d.extend({},a):{complete:c||!c&&b||d.isFunction(a)&&a,duration:a,easing:c&&b||b&&!d.isFunction(b)&&b};e.duration=d.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in d.fx.speeds?d.fx.speeds[e.duration]:d.fx.speeds._default,e.old=e.complete,e.complete=function(){e.queue!==!1&&d(this).dequeue(),d.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig||(b.orig={})}}),d.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(d.fx.step[this.prop]||d.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a=parseFloat(d.css(this.elem,this.prop));return a||0},custom:function(a,b,c){function g(a){return e.step(a)}var e=this,f=d.fx;this.startTime=d.now(),this.start=a,this.end=b,this.unit=c||this.unit||"px",this.now=this.start,this.pos=this.state=0,g.elem=this.elem,g()&&d.timers.push(g)&&!bU&&(bU=setInterval(f.tick,f.interval))},show:function(){this.options.orig[this.prop]=d.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),d(this.elem).show()},hide:function(){this.options.orig[this.prop]=d.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=d.now(),c=!0;if(a||b>=this.options.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),this.options.curAnim[this.prop]=!0;for(var e in this.options.curAnim)this.options.curAnim[e]!==!0&&(c=!1);if(c){if(this.options.overflow!=null&&!d.support.shrinkWrapBlocks){var f=this.elem,g=this.options;d.each(["","X","Y"],function(a,b){f.style["overflow"+b]=g.overflow[a]})}this.options.hide&&d(this.elem).hide();if(this.options.hide||this.options.show)for(var h in this.options.curAnim)d.style(this.elem,h,this.options.orig[h]);this.options.complete.call(this.elem)}return!1}var i=b-this.startTime;this.state=i/this.options.duration;var j=this.options.specialEasing&&this.options.specialEasing[this.prop],k=this.options.easing||(d.easing.swing?"swing":"linear");this.pos=d.easing[j||k](this.state,i,0,1,this.options.duration),this.now=this.start+(this.end-this.start)*this.pos,this.update();return!0}},d.extend(d.fx,{tick:function(){var a=d.timers;for(var b=0;b
";d.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),e=b.firstChild,f=e.firstChild,h=e.nextSibling.firstChild.firstChild,this.doesNotAddBorder=f.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,f.style.position="fixed",f.style.top="20px",this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15,f.style.position=f.style.top="",e.style.overflow="hidden",e.style.position="relative",this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),a=b=e=f=g=h=null,d.offset.initialize=d.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;d.offset.initialize(),d.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(d.css(a,"marginTop"))||0,c+=parseFloat(d.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var e=d.css(a,"position");e==="static"&&(a.style.position="relative");var f=d(a),g=f.offset(),h=d.css(a,"top"),i=d.css(a,"left"),j=e==="absolute"&&d.inArray("auto",[h,i])>-1,k={},l={},m,n;j&&(l=f.position()),m=j?l.top:parseInt(h,10)||0,n=j?l.left:parseInt(i,10)||0,d.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):f.css(k)}},d.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),e=bZ.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(d.css(a,"marginTop"))||0,c.left-=parseFloat(d.css(a,"marginLeft"))||0,e.top+=parseFloat(d.css(b[0],"borderTopWidth"))||0,e.left+=parseFloat(d.css(b[0],"borderLeftWidth"))||0;return{top:c.top-e.top,left:c.left-e.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&(!bZ.test(a.nodeName)&&d.css(a,"position")==="static"))a=a.offsetParent;return a})}}),d.each(["Left","Top"],function(a,c){var e="scroll"+c;d.fn[e]=function(c){var f=this[0],g;if(!f)return null;if(c!==b)return this.each(function(){g=b$(this),g?g.scrollTo(a?d(g).scrollLeft():c,a?c:d(g).scrollTop()):this[e]=c});g=b$(f);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:d.support.boxModel&&g.document.documentElement[e]||g.document.body[e]:f[e]}}),d.each(["Height","Width"],function(a,c){var e=c.toLowerCase();d.fn["inner"+c]=function(){return this[0]?parseFloat(d.css(this[0],e,"padding")):null},d.fn["outer"+c]=function(a){return this[0]?parseFloat(d.css(this[0],e,a?"margin":"border")):null},d.fn[e]=function(a){var f=this[0];if(!f)return a==null?null:this;if(d.isFunction(a))return this.each(function(b){var c=d(this);c[e](a.call(this,b,c[e]()))});if(d.isWindow(f)){var g=f.document.documentElement["client"+c];return f.document.compatMode==="CSS1Compat"&&g||f.document.body["client"+c]||g}if(f.nodeType===9)return Math.max(f.documentElement["client"+c],f.body["scroll"+c],f.documentElement["scroll"+c],f.body["offset"+c],f.documentElement["offset"+c]);if(a===b){var h=d.css(f,e),i=parseFloat(h);return d.isNaN(i)?h:i}return this.css(e,typeof a==="string"?a:a+"px")}})})(window); 17 | -------------------------------------------------------------------------------- /flask_profile/static/js/jquery.tablesorter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * TableSorter 2.0 - Client-side table sorting with ease! 4 | * Version 2.0.5b 5 | * @requires jQuery v1.2.3 6 | * 7 | * Copyright (c) 2007 Christian Bach 8 | * Examples and docs at: http://tablesorter.com 9 | * Dual licensed under the MIT and GPL licenses: 10 | * http://www.opensource.org/licenses/mit-license.php 11 | * http://www.gnu.org/licenses/gpl.html 12 | * 13 | */ 14 | /** 15 | * 16 | * @description Create a sortable table with multi-column sorting capabilitys 17 | * 18 | * @example $('table').tablesorter(); 19 | * @desc Create a simple tablesorter interface. 20 | * 21 | * @example $('table').tablesorter({ sortList:[[0,0],[1,0]] }); 22 | * @desc Create a tablesorter interface and sort on the first and secound column column headers. 23 | * 24 | * @example $('table').tablesorter({ headers: { 0: { sorter: false}, 1: {sorter: false} } }); 25 | * 26 | * @desc Create a tablesorter interface and disableing the first and second column headers. 27 | * 28 | * 29 | * @example $('table').tablesorter({ headers: { 0: {sorter:"integer"}, 1: {sorter:"currency"} } }); 30 | * 31 | * @desc Create a tablesorter interface and set a column parser for the first 32 | * and second column. 33 | * 34 | * 35 | * @param Object 36 | * settings An object literal containing key/value pairs to provide 37 | * optional settings. 38 | * 39 | * 40 | * @option String cssHeader (optional) A string of the class name to be appended 41 | * to sortable tr elements in the thead of the table. Default value: 42 | * "header" 43 | * 44 | * @option String cssAsc (optional) A string of the class name to be appended to 45 | * sortable tr elements in the thead on a ascending sort. Default value: 46 | * "headerSortUp" 47 | * 48 | * @option String cssDesc (optional) A string of the class name to be appended 49 | * to sortable tr elements in the thead on a descending sort. Default 50 | * value: "headerSortDown" 51 | * 52 | * @option String sortInitialOrder (optional) A string of the inital sorting 53 | * order can be asc or desc. Default value: "asc" 54 | * 55 | * @option String sortMultisortKey (optional) A string of the multi-column sort 56 | * key. Default value: "shiftKey" 57 | * 58 | * @option String textExtraction (optional) A string of the text-extraction 59 | * method to use. For complex html structures inside td cell set this 60 | * option to "complex", on large tables the complex option can be slow. 61 | * Default value: "simple" 62 | * 63 | * @option Object headers (optional) An array containing the forces sorting 64 | * rules. This option let's you specify a default sorting rule. Default 65 | * value: null 66 | * 67 | * @option Array sortList (optional) An array containing the forces sorting 68 | * rules. This option let's you specify a default sorting rule. Default 69 | * value: null 70 | * 71 | * @option Array sortForce (optional) An array containing forced sorting rules. 72 | * This option let's you specify a default sorting rule, which is 73 | * prepended to user-selected rules. Default value: null 74 | * 75 | * @option Boolean sortLocaleCompare (optional) Boolean flag indicating whatever 76 | * to use String.localeCampare method or not. Default set to true. 77 | * 78 | * 79 | * @option Array sortAppend (optional) An array containing forced sorting rules. 80 | * This option let's you specify a default sorting rule, which is 81 | * appended to user-selected rules. Default value: null 82 | * 83 | * @option Boolean widthFixed (optional) Boolean flag indicating if tablesorter 84 | * should apply fixed widths to the table columns. This is usefull when 85 | * using the pager companion plugin. This options requires the dimension 86 | * jquery plugin. Default value: false 87 | * 88 | * @option Boolean cancelSelection (optional) Boolean flag indicating if 89 | * tablesorter should cancel selection of the table headers text. 90 | * Default value: true 91 | * 92 | * @option Boolean debug (optional) Boolean flag indicating if tablesorter 93 | * should display debuging information usefull for development. 94 | * 95 | * @type jQuery 96 | * 97 | * @name tablesorter 98 | * 99 | * @cat Plugins/Tablesorter 100 | * 101 | * @author Christian Bach/christian.bach@polyester.se 102 | */ 103 | 104 | (function ($) { 105 | $.extend({ 106 | tablesorter: new 107 | function () { 108 | 109 | var parsers = [], 110 | widgets = []; 111 | 112 | this.defaults = { 113 | cssHeader: "header", 114 | cssAsc: "headerSortUp", 115 | cssDesc: "headerSortDown", 116 | cssChildRow: "expand-child", 117 | sortInitialOrder: "asc", 118 | sortMultiSortKey: "shiftKey", 119 | sortForce: null, 120 | sortAppend: null, 121 | sortLocaleCompare: true, 122 | textExtraction: "simple", 123 | parsers: {}, widgets: [], 124 | widgetZebra: { 125 | css: ["even", "odd"] 126 | }, headers: {}, widthFixed: false, 127 | cancelSelection: true, 128 | sortList: [], 129 | headerList: [], 130 | dateFormat: "us", 131 | decimal: '/\.|\,/g', 132 | onRenderHeader: null, 133 | selectorHeaders: 'thead th', 134 | debug: false 135 | }; 136 | 137 | /* debuging utils */ 138 | 139 | function benchmark(s, d) { 140 | log(s + "," + (new Date().getTime() - d.getTime()) + "ms"); 141 | } 142 | 143 | this.benchmark = benchmark; 144 | 145 | function log(s) { 146 | if (typeof console != "undefined" && typeof console.debug != "undefined") { 147 | console.log(s); 148 | } else { 149 | alert(s); 150 | } 151 | } 152 | 153 | /* parsers utils */ 154 | 155 | function buildParserCache(table, $headers) { 156 | 157 | if (table.config.debug) { 158 | var parsersDebug = ""; 159 | } 160 | 161 | if (table.tBodies.length == 0) return; // In the case of empty tables 162 | var rows = table.tBodies[0].rows; 163 | 164 | if (rows[0]) { 165 | 166 | var list = [], 167 | cells = rows[0].cells, 168 | l = cells.length; 169 | 170 | for (var i = 0; i < l; i++) { 171 | 172 | var p = false; 173 | 174 | if ($.metadata && ($($headers[i]).metadata() && $($headers[i]).metadata().sorter)) { 175 | 176 | p = getParserById($($headers[i]).metadata().sorter); 177 | 178 | } else if ((table.config.headers[i] && table.config.headers[i].sorter)) { 179 | 180 | p = getParserById(table.config.headers[i].sorter); 181 | } 182 | if (!p) { 183 | 184 | p = detectParserForColumn(table, rows, -1, i); 185 | } 186 | 187 | if (table.config.debug) { 188 | parsersDebug += "column:" + i + " parser:" + p.id + "\n"; 189 | } 190 | 191 | list.push(p); 192 | } 193 | } 194 | 195 | if (table.config.debug) { 196 | log(parsersDebug); 197 | } 198 | 199 | return list; 200 | }; 201 | 202 | function detectParserForColumn(table, rows, rowIndex, cellIndex) { 203 | var l = parsers.length, 204 | node = false, 205 | nodeValue = false, 206 | keepLooking = true; 207 | while (nodeValue == '' && keepLooking) { 208 | rowIndex++; 209 | if (rows[rowIndex]) { 210 | node = getNodeFromRowAndCellIndex(rows, rowIndex, cellIndex); 211 | nodeValue = trimAndGetNodeText(table.config, node); 212 | if (table.config.debug) { 213 | log('Checking if value was empty on row:' + rowIndex); 214 | } 215 | } else { 216 | keepLooking = false; 217 | } 218 | } 219 | for (var i = 1; i < l; i++) { 220 | if (parsers[i].is(nodeValue, table, node)) { 221 | return parsers[i]; 222 | } 223 | } 224 | // 0 is always the generic parser (text) 225 | return parsers[0]; 226 | } 227 | 228 | function getNodeFromRowAndCellIndex(rows, rowIndex, cellIndex) { 229 | return rows[rowIndex].cells[cellIndex]; 230 | } 231 | 232 | function trimAndGetNodeText(config, node) { 233 | return $.trim(getElementText(config, node)); 234 | } 235 | 236 | function getParserById(name) { 237 | var l = parsers.length; 238 | for (var i = 0; i < l; i++) { 239 | if (parsers[i].id.toLowerCase() == name.toLowerCase()) { 240 | return parsers[i]; 241 | } 242 | } 243 | return false; 244 | } 245 | 246 | /* utils */ 247 | 248 | function buildCache(table) { 249 | 250 | if (table.config.debug) { 251 | var cacheTime = new Date(); 252 | } 253 | 254 | var totalRows = (table.tBodies[0] && table.tBodies[0].rows.length) || 0, 255 | totalCells = (table.tBodies[0].rows[0] && table.tBodies[0].rows[0].cells.length) || 0, 256 | parsers = table.config.parsers, 257 | cache = { 258 | row: [], 259 | normalized: [] 260 | }; 261 | 262 | for (var i = 0; i < totalRows; ++i) { 263 | 264 | /** Add the table data to main data array */ 265 | var c = $(table.tBodies[0].rows[i]), 266 | cols = []; 267 | 268 | // if this is a child row, add it to the last row's children and 269 | // continue to the next row 270 | if (c.hasClass(table.config.cssChildRow)) { 271 | cache.row[cache.row.length - 1] = cache.row[cache.row.length - 1].add(c); 272 | // go to the next for loop 273 | continue; 274 | } 275 | 276 | cache.row.push(c); 277 | 278 | for (var j = 0; j < totalCells; ++j) { 279 | cols.push(parsers[j].format(getElementText(table.config, c[0].cells[j]), table, c[0].cells[j])); 280 | } 281 | 282 | cols.push(cache.normalized.length); // add position for rowCache 283 | cache.normalized.push(cols); 284 | cols = null; 285 | }; 286 | 287 | if (table.config.debug) { 288 | benchmark("Building cache for " + totalRows + " rows:", cacheTime); 289 | } 290 | 291 | return cache; 292 | }; 293 | 294 | function getElementText(config, node) { 295 | 296 | var text = ""; 297 | 298 | if (!node) return ""; 299 | 300 | if (!config.supportsTextContent) config.supportsTextContent = node.textContent || false; 301 | 302 | if (config.textExtraction == "simple") { 303 | if (config.supportsTextContent) { 304 | text = node.textContent; 305 | } else { 306 | if (node.childNodes[0] && node.childNodes[0].hasChildNodes()) { 307 | text = node.childNodes[0].innerHTML; 308 | } else { 309 | text = node.innerHTML; 310 | } 311 | } 312 | } else { 313 | if (typeof(config.textExtraction) == "function") { 314 | text = config.textExtraction(node); 315 | } else { 316 | text = $(node).text(); 317 | } 318 | } 319 | return text; 320 | } 321 | 322 | function appendToTable(table, cache) { 323 | 324 | if (table.config.debug) { 325 | var appendTime = new Date() 326 | } 327 | 328 | var c = cache, 329 | r = c.row, 330 | n = c.normalized, 331 | totalRows = n.length, 332 | checkCell = (n[0].length - 1), 333 | tableBody = $(table.tBodies[0]), 334 | rows = []; 335 | 336 | 337 | for (var i = 0; i < totalRows; i++) { 338 | var pos = n[i][checkCell]; 339 | 340 | rows.push(r[pos]); 341 | 342 | if (!table.config.appender) { 343 | 344 | //var o = ; 345 | var l = r[pos].length; 346 | for (var j = 0; j < l; j++) { 347 | tableBody[0].appendChild(r[pos][j]); 348 | } 349 | 350 | // 351 | } 352 | } 353 | 354 | 355 | 356 | if (table.config.appender) { 357 | 358 | table.config.appender(table, rows); 359 | } 360 | 361 | rows = null; 362 | 363 | if (table.config.debug) { 364 | benchmark("Rebuilt table:", appendTime); 365 | } 366 | 367 | // apply table widgets 368 | applyWidget(table); 369 | 370 | // trigger sortend 371 | setTimeout(function () { 372 | $(table).trigger("sortEnd"); 373 | }, 0); 374 | 375 | }; 376 | 377 | function buildHeaders(table) { 378 | 379 | if (table.config.debug) { 380 | var time = new Date(); 381 | } 382 | 383 | var meta = ($.metadata) ? true : false; 384 | 385 | var header_index = computeTableHeaderCellIndexes(table); 386 | 387 | $tableHeaders = $(table.config.selectorHeaders, table).each(function (index) { 388 | 389 | this.column = header_index[this.parentNode.rowIndex + "-" + this.cellIndex]; 390 | // this.column = index; 391 | this.order = formatSortingOrder(table.config.sortInitialOrder); 392 | 393 | 394 | this.count = this.order; 395 | 396 | if (checkHeaderMetadata(this) || checkHeaderOptions(table, index)) this.sortDisabled = true; 397 | if (checkHeaderOptionsSortingLocked(table, index)) this.order = this.lockedOrder = checkHeaderOptionsSortingLocked(table, index); 398 | 399 | if (!this.sortDisabled) { 400 | var $th = $(this).addClass(table.config.cssHeader); 401 | if (table.config.onRenderHeader) table.config.onRenderHeader.apply($th); 402 | } 403 | 404 | // add cell to headerList 405 | table.config.headerList[index] = this; 406 | }); 407 | 408 | if (table.config.debug) { 409 | benchmark("Built headers:", time); 410 | log($tableHeaders); 411 | } 412 | 413 | return $tableHeaders; 414 | 415 | }; 416 | 417 | // from: 418 | // http://www.javascripttoolbox.com/lib/table/examples.php 419 | // http://www.javascripttoolbox.com/temp/table_cellindex.html 420 | 421 | 422 | function computeTableHeaderCellIndexes(t) { 423 | var matrix = []; 424 | var lookup = {}; 425 | var thead = t.getElementsByTagName('THEAD')[0]; 426 | var trs = thead.getElementsByTagName('TR'); 427 | 428 | for (var i = 0; i < trs.length; i++) { 429 | var cells = trs[i].cells; 430 | for (var j = 0; j < cells.length; j++) { 431 | var c = cells[j]; 432 | 433 | var rowIndex = c.parentNode.rowIndex; 434 | var cellId = rowIndex + "-" + c.cellIndex; 435 | var rowSpan = c.rowSpan || 1; 436 | var colSpan = c.colSpan || 1 437 | var firstAvailCol; 438 | if (typeof(matrix[rowIndex]) == "undefined") { 439 | matrix[rowIndex] = []; 440 | } 441 | // Find first available column in the first row 442 | for (var k = 0; k < matrix[rowIndex].length + 1; k++) { 443 | if (typeof(matrix[rowIndex][k]) == "undefined") { 444 | firstAvailCol = k; 445 | break; 446 | } 447 | } 448 | lookup[cellId] = firstAvailCol; 449 | for (var k = rowIndex; k < rowIndex + rowSpan; k++) { 450 | if (typeof(matrix[k]) == "undefined") { 451 | matrix[k] = []; 452 | } 453 | var matrixrow = matrix[k]; 454 | for (var l = firstAvailCol; l < firstAvailCol + colSpan; l++) { 455 | matrixrow[l] = "x"; 456 | } 457 | } 458 | } 459 | } 460 | return lookup; 461 | } 462 | 463 | function checkCellColSpan(table, rows, row) { 464 | var arr = [], 465 | r = table.tHead.rows, 466 | c = r[row].cells; 467 | 468 | for (var i = 0; i < c.length; i++) { 469 | var cell = c[i]; 470 | 471 | if (cell.colSpan > 1) { 472 | arr = arr.concat(checkCellColSpan(table, headerArr, row++)); 473 | } else { 474 | if (table.tHead.length == 1 || (cell.rowSpan > 1 || !r[row + 1])) { 475 | arr.push(cell); 476 | } 477 | // headerArr[row] = (i+row); 478 | } 479 | } 480 | return arr; 481 | }; 482 | 483 | function checkHeaderMetadata(cell) { 484 | if (($.metadata) && ($(cell).metadata().sorter === false)) { 485 | return true; 486 | }; 487 | return false; 488 | } 489 | 490 | function checkHeaderOptions(table, i) { 491 | if ((table.config.headers[i]) && (table.config.headers[i].sorter === false)) { 492 | return true; 493 | }; 494 | return false; 495 | } 496 | 497 | function checkHeaderOptionsSortingLocked(table, i) { 498 | if ((table.config.headers[i]) && (table.config.headers[i].lockedOrder)) return table.config.headers[i].lockedOrder; 499 | return false; 500 | } 501 | 502 | function applyWidget(table) { 503 | var c = table.config.widgets; 504 | var l = c.length; 505 | for (var i = 0; i < l; i++) { 506 | 507 | getWidgetById(c[i]).format(table); 508 | } 509 | 510 | } 511 | 512 | function getWidgetById(name) { 513 | var l = widgets.length; 514 | for (var i = 0; i < l; i++) { 515 | if (widgets[i].id.toLowerCase() == name.toLowerCase()) { 516 | return widgets[i]; 517 | } 518 | } 519 | }; 520 | 521 | function formatSortingOrder(v) { 522 | if (typeof(v) != "Number") { 523 | return (v.toLowerCase() == "desc") ? 1 : 0; 524 | } else { 525 | return (v == 1) ? 1 : 0; 526 | } 527 | } 528 | 529 | function isValueInArray(v, a) { 530 | var l = a.length; 531 | for (var i = 0; i < l; i++) { 532 | if (a[i][0] == v) { 533 | return true; 534 | } 535 | } 536 | return false; 537 | } 538 | 539 | function setHeadersCss(table, $headers, list, css) { 540 | // remove all header information 541 | $headers.removeClass(css[0]).removeClass(css[1]); 542 | 543 | var h = []; 544 | $headers.each(function (offset) { 545 | if (!this.sortDisabled) { 546 | h[this.column] = $(this); 547 | } 548 | }); 549 | 550 | var l = list.length; 551 | for (var i = 0; i < l; i++) { 552 | h[list[i][0]].addClass(css[list[i][1]]); 553 | } 554 | } 555 | 556 | function fixColumnWidth(table, $headers) { 557 | var c = table.config; 558 | if (c.widthFixed) { 559 | var colgroup = $(''); 560 | $("tr:first td", table.tBodies[0]).each(function () { 561 | colgroup.append($('').css('width', $(this).width())); 562 | }); 563 | $(table).prepend(colgroup); 564 | }; 565 | } 566 | 567 | function updateHeaderSortCount(table, sortList) { 568 | var c = table.config, 569 | l = sortList.length; 570 | for (var i = 0; i < l; i++) { 571 | var s = sortList[i], 572 | o = c.headerList[s[0]]; 573 | o.count = s[1]; 574 | o.count++; 575 | } 576 | } 577 | 578 | /* sorting methods */ 579 | 580 | function multisort(table, sortList, cache) { 581 | 582 | if (table.config.debug) { 583 | var sortTime = new Date(); 584 | } 585 | 586 | var dynamicExp = "var sortWrapper = function(a,b) {", 587 | l = sortList.length; 588 | 589 | // TODO: inline functions. 590 | for (var i = 0; i < l; i++) { 591 | 592 | var c = sortList[i][0]; 593 | var order = sortList[i][1]; 594 | // var s = (getCachedSortType(table.config.parsers,c) == "text") ? 595 | // ((order == 0) ? "sortText" : "sortTextDesc") : ((order == 0) ? 596 | // "sortNumeric" : "sortNumericDesc"); 597 | // var s = (table.config.parsers[c].type == "text") ? ((order == 0) 598 | // ? makeSortText(c) : makeSortTextDesc(c)) : ((order == 0) ? 599 | // makeSortNumeric(c) : makeSortNumericDesc(c)); 600 | var s = (table.config.parsers[c].type == "text") ? ((order == 0) ? makeSortFunction("text", "asc", c) : makeSortFunction("text", "desc", c)) : ((order == 0) ? makeSortFunction("numeric", "asc", c) : makeSortFunction("numeric", "desc", c)); 601 | var e = "e" + i; 602 | 603 | dynamicExp += "var " + e + " = " + s; // + "(a[" + c + "],b[" + c 604 | // + "]); "; 605 | dynamicExp += "if(" + e + ") { return " + e + "; } "; 606 | dynamicExp += "else { "; 607 | 608 | } 609 | 610 | // if value is the same keep orignal order 611 | var orgOrderCol = cache.normalized[0].length - 1; 612 | dynamicExp += "return a[" + orgOrderCol + "]-b[" + orgOrderCol + "];"; 613 | 614 | for (var i = 0; i < l; i++) { 615 | dynamicExp += "}; "; 616 | } 617 | 618 | dynamicExp += "return 0; "; 619 | dynamicExp += "}; "; 620 | 621 | if (table.config.debug) { 622 | benchmark("Evaling expression:" + dynamicExp, new Date()); 623 | } 624 | 625 | eval(dynamicExp); 626 | 627 | cache.normalized.sort(sortWrapper); 628 | 629 | if (table.config.debug) { 630 | benchmark("Sorting on " + sortList.toString() + " and dir " + order + " time:", sortTime); 631 | } 632 | 633 | return cache; 634 | }; 635 | 636 | function makeSortFunction(type, direction, index) { 637 | var a = "a[" + index + "]", 638 | b = "b[" + index + "]"; 639 | if (type == 'text' && direction == 'asc') { 640 | return "(" + a + " == " + b + " ? 0 : (" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : (" + a + " < " + b + ") ? -1 : 1 )));"; 641 | } else if (type == 'text' && direction == 'desc') { 642 | return "(" + a + " == " + b + " ? 0 : (" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : (" + b + " < " + a + ") ? -1 : 1 )));"; 643 | } else if (type == 'numeric' && direction == 'asc') { 644 | return "(" + a + " === null && " + b + " === null) ? 0 :(" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : " + a + " - " + b + "));"; 645 | } else if (type == 'numeric' && direction == 'desc') { 646 | return "(" + a + " === null && " + b + " === null) ? 0 :(" + a + " === null ? Number.POSITIVE_INFINITY : (" + b + " === null ? Number.NEGATIVE_INFINITY : " + b + " - " + a + "));"; 647 | } 648 | }; 649 | 650 | function makeSortText(i) { 651 | return "((a[" + i + "] < b[" + i + "]) ? -1 : ((a[" + i + "] > b[" + i + "]) ? 1 : 0));"; 652 | }; 653 | 654 | function makeSortTextDesc(i) { 655 | return "((b[" + i + "] < a[" + i + "]) ? -1 : ((b[" + i + "] > a[" + i + "]) ? 1 : 0));"; 656 | }; 657 | 658 | function makeSortNumeric(i) { 659 | return "a[" + i + "]-b[" + i + "];"; 660 | }; 661 | 662 | function makeSortNumericDesc(i) { 663 | return "b[" + i + "]-a[" + i + "];"; 664 | }; 665 | 666 | function sortText(a, b) { 667 | if (table.config.sortLocaleCompare) return a.localeCompare(b); 668 | return ((a < b) ? -1 : ((a > b) ? 1 : 0)); 669 | }; 670 | 671 | function sortTextDesc(a, b) { 672 | if (table.config.sortLocaleCompare) return b.localeCompare(a); 673 | return ((b < a) ? -1 : ((b > a) ? 1 : 0)); 674 | }; 675 | 676 | function sortNumeric(a, b) { 677 | return a - b; 678 | }; 679 | 680 | function sortNumericDesc(a, b) { 681 | return b - a; 682 | }; 683 | 684 | function getCachedSortType(parsers, i) { 685 | return parsers[i].type; 686 | }; /* public methods */ 687 | this.construct = function (settings) { 688 | return this.each(function () { 689 | // if no thead or tbody quit. 690 | if (!this.tHead || !this.tBodies) return; 691 | // declare 692 | var $this, $document, $headers, cache, config, shiftDown = 0, 693 | sortOrder; 694 | // new blank config object 695 | this.config = {}; 696 | // merge and extend. 697 | config = $.extend(this.config, $.tablesorter.defaults, settings); 698 | // store common expression for speed 699 | $this = $(this); 700 | // save the settings where they read 701 | $.data(this, "tablesorter", config); 702 | // build headers 703 | $headers = buildHeaders(this); 704 | // try to auto detect column type, and store in tables config 705 | this.config.parsers = buildParserCache(this, $headers); 706 | // build the cache for the tbody cells 707 | cache = buildCache(this); 708 | // get the css class names, could be done else where. 709 | var sortCSS = [config.cssDesc, config.cssAsc]; 710 | // fixate columns if the users supplies the fixedWidth option 711 | fixColumnWidth(this); 712 | // apply event handling to headers 713 | // this is to big, perhaps break it out? 714 | $headers.click( 715 | 716 | function (e) { 717 | var totalRows = ($this[0].tBodies[0] && $this[0].tBodies[0].rows.length) || 0; 718 | if (!this.sortDisabled && totalRows > 0) { 719 | // Only call sortStart if sorting is 720 | // enabled. 721 | $this.trigger("sortStart"); 722 | // store exp, for speed 723 | var $cell = $(this); 724 | // get current column index 725 | var i = this.column; 726 | // get current column sort order 727 | this.order = this.count++ % 2; 728 | // always sort on the locked order. 729 | if(this.lockedOrder) this.order = this.lockedOrder; 730 | 731 | // user only whants to sort on one 732 | // column 733 | if (!e[config.sortMultiSortKey]) { 734 | // flush the sort list 735 | config.sortList = []; 736 | if (config.sortForce != null) { 737 | var a = config.sortForce; 738 | for (var j = 0; j < a.length; j++) { 739 | if (a[j][0] != i) { 740 | config.sortList.push(a[j]); 741 | } 742 | } 743 | } 744 | // add column to sort list 745 | config.sortList.push([i, this.order]); 746 | // multi column sorting 747 | } else { 748 | // the user has clicked on an all 749 | // ready sortet column. 750 | if (isValueInArray(i, config.sortList)) { 751 | // revers the sorting direction 752 | // for all tables. 753 | for (var j = 0; j < config.sortList.length; j++) { 754 | var s = config.sortList[j], 755 | o = config.headerList[s[0]]; 756 | if (s[0] == i) { 757 | o.count = s[1]; 758 | o.count++; 759 | s[1] = o.count % 2; 760 | } 761 | } 762 | } else { 763 | // add column to sort list array 764 | config.sortList.push([i, this.order]); 765 | } 766 | }; 767 | setTimeout(function () { 768 | // set css for headers 769 | setHeadersCss($this[0], $headers, config.sortList, sortCSS); 770 | appendToTable( 771 | $this[0], multisort( 772 | $this[0], config.sortList, cache) 773 | ); 774 | }, 1); 775 | // stop normal event by returning false 776 | return false; 777 | } 778 | // cancel selection 779 | }).mousedown(function () { 780 | if (config.cancelSelection) { 781 | this.onselectstart = function () { 782 | return false 783 | }; 784 | return false; 785 | } 786 | }); 787 | // apply easy methods that trigger binded events 788 | $this.bind("update", function () { 789 | var me = this; 790 | setTimeout(function () { 791 | // rebuild parsers. 792 | me.config.parsers = buildParserCache( 793 | me, $headers); 794 | // rebuild the cache map 795 | cache = buildCache(me); 796 | }, 1); 797 | }).bind("updateCell", function (e, cell) { 798 | var config = this.config; 799 | // get position from the dom. 800 | var pos = [(cell.parentNode.rowIndex - 1), cell.cellIndex]; 801 | // update cache 802 | cache.normalized[pos[0]][pos[1]] = config.parsers[pos[1]].format( 803 | getElementText(config, cell), cell); 804 | }).bind("sorton", function (e, list) { 805 | $(this).trigger("sortStart"); 806 | config.sortList = list; 807 | // update and store the sortlist 808 | var sortList = config.sortList; 809 | // update header count index 810 | updateHeaderSortCount(this, sortList); 811 | // set css for headers 812 | setHeadersCss(this, $headers, sortList, sortCSS); 813 | // sort the table and append it to the dom 814 | appendToTable(this, multisort(this, sortList, cache)); 815 | }).bind("appendCache", function () { 816 | appendToTable(this, cache); 817 | }).bind("applyWidgetId", function (e, id) { 818 | getWidgetById(id).format(this); 819 | }).bind("applyWidgets", function () { 820 | // apply widgets 821 | applyWidget(this); 822 | }); 823 | if ($.metadata && ($(this).metadata() && $(this).metadata().sortlist)) { 824 | config.sortList = $(this).metadata().sortlist; 825 | } 826 | // if user has supplied a sort list to constructor. 827 | if (config.sortList.length > 0) { 828 | $this.trigger("sorton", [config.sortList]); 829 | } 830 | // apply widgets 831 | applyWidget(this); 832 | }); 833 | }; 834 | this.addParser = function (parser) { 835 | var l = parsers.length, 836 | a = true; 837 | for (var i = 0; i < l; i++) { 838 | if (parsers[i].id.toLowerCase() == parser.id.toLowerCase()) { 839 | a = false; 840 | } 841 | } 842 | if (a) { 843 | parsers.push(parser); 844 | }; 845 | }; 846 | this.addWidget = function (widget) { 847 | widgets.push(widget); 848 | }; 849 | this.formatFloat = function (s) { 850 | var i = parseFloat(s); 851 | return (isNaN(i)) ? 0 : i; 852 | }; 853 | this.formatInt = function (s) { 854 | var i = parseInt(s); 855 | return (isNaN(i)) ? 0 : i; 856 | }; 857 | this.isDigit = function (s, config) { 858 | // replace all an wanted chars and match. 859 | return /^[-+]?\d*$/.test($.trim(s.replace(/[,.']/g, ''))); 860 | }; 861 | this.clearTableBody = function (table) { 862 | if ($.browser.msie) { 863 | function empty() { 864 | while (this.firstChild) 865 | this.removeChild(this.firstChild); 866 | } 867 | empty.apply(table.tBodies[0]); 868 | } else { 869 | table.tBodies[0].innerHTML = ""; 870 | } 871 | }; 872 | } 873 | }); 874 | 875 | // extend plugin scope 876 | $.fn.extend({ 877 | tablesorter: $.tablesorter.construct 878 | }); 879 | 880 | // make shortcut 881 | var ts = $.tablesorter; 882 | 883 | // add default parsers 884 | ts.addParser({ 885 | id: "text", 886 | is: function (s) { 887 | return true; 888 | }, format: function (s) { 889 | return $.trim(s.toLocaleLowerCase()); 890 | }, type: "text" 891 | }); 892 | 893 | ts.addParser({ 894 | id: "digit", 895 | is: function (s, table) { 896 | var c = table.config; 897 | return $.tablesorter.isDigit(s, c); 898 | }, format: function (s) { 899 | return $.tablesorter.formatFloat(s); 900 | }, type: "numeric" 901 | }); 902 | 903 | ts.addParser({ 904 | id: "currency", 905 | is: function (s) { 906 | return /^[£$€?.]/.test(s); 907 | }, format: function (s) { 908 | return $.tablesorter.formatFloat(s.replace(new RegExp(/[£$€]/g), "")); 909 | }, type: "numeric" 910 | }); 911 | 912 | ts.addParser({ 913 | id: "ipAddress", 914 | is: function (s) { 915 | return /^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(s); 916 | }, format: function (s) { 917 | var a = s.split("."), 918 | r = "", 919 | l = a.length; 920 | for (var i = 0; i < l; i++) { 921 | var item = a[i]; 922 | if (item.length == 2) { 923 | r += "0" + item; 924 | } else { 925 | r += item; 926 | } 927 | } 928 | return $.tablesorter.formatFloat(r); 929 | }, type: "numeric" 930 | }); 931 | 932 | ts.addParser({ 933 | id: "url", 934 | is: function (s) { 935 | return /^(https?|ftp|file):\/\/$/.test(s); 936 | }, format: function (s) { 937 | return jQuery.trim(s.replace(new RegExp(/(https?|ftp|file):\/\//), '')); 938 | }, type: "text" 939 | }); 940 | 941 | ts.addParser({ 942 | id: "isoDate", 943 | is: function (s) { 944 | return /^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(s); 945 | }, format: function (s) { 946 | return $.tablesorter.formatFloat((s != "") ? new Date(s.replace( 947 | new RegExp(/-/g), "/")).getTime() : "0"); 948 | }, type: "numeric" 949 | }); 950 | 951 | ts.addParser({ 952 | id: "percent", 953 | is: function (s) { 954 | return /\%$/.test($.trim(s)); 955 | }, format: function (s) { 956 | return $.tablesorter.formatFloat(s.replace(new RegExp(/%/g), "")); 957 | }, type: "numeric" 958 | }); 959 | 960 | ts.addParser({ 961 | id: "usLongDate", 962 | is: function (s) { 963 | return s.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/)); 964 | }, format: function (s) { 965 | return $.tablesorter.formatFloat(new Date(s).getTime()); 966 | }, type: "numeric" 967 | }); 968 | 969 | ts.addParser({ 970 | id: "shortDate", 971 | is: function (s) { 972 | return /\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(s); 973 | }, format: function (s, table) { 974 | var c = table.config; 975 | s = s.replace(/\-/g, "/"); 976 | if (c.dateFormat == "us") { 977 | // reformat the string in ISO format 978 | s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$1/$2"); 979 | } else if (c.dateFormat == "uk") { 980 | // reformat the string in ISO format 981 | s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3/$2/$1"); 982 | } else if (c.dateFormat == "dd/mm/yy" || c.dateFormat == "dd-mm-yy") { 983 | s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$1/$2/$3"); 984 | } 985 | return $.tablesorter.formatFloat(new Date(s).getTime()); 986 | }, type: "numeric" 987 | }); 988 | ts.addParser({ 989 | id: "time", 990 | is: function (s) { 991 | return /^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(s); 992 | }, format: function (s) { 993 | return $.tablesorter.formatFloat(new Date("2000/01/01 " + s).getTime()); 994 | }, type: "numeric" 995 | }); 996 | ts.addParser({ 997 | id: "metadata", 998 | is: function (s) { 999 | return false; 1000 | }, format: function (s, table, cell) { 1001 | var c = table.config, 1002 | p = (!c.parserMetadataName) ? 'sortValue' : c.parserMetadataName; 1003 | return $(cell).metadata()[p]; 1004 | }, type: "numeric" 1005 | }); 1006 | // add default widgets 1007 | ts.addWidget({ 1008 | id: "zebra", 1009 | format: function (table) { 1010 | if (table.config.debug) { 1011 | var time = new Date(); 1012 | } 1013 | var $tr, row = -1, 1014 | odd; 1015 | // loop through the visible rows 1016 | $("tr:visible", table.tBodies[0]).each(function (i) { 1017 | $tr = $(this); 1018 | // style children rows the same way the parent 1019 | // row was styled 1020 | if (!$tr.hasClass(table.config.cssChildRow)) row++; 1021 | odd = (row % 2 == 0); 1022 | $tr.removeClass( 1023 | table.config.widgetZebra.css[odd ? 0 : 1]).addClass( 1024 | table.config.widgetZebra.css[odd ? 1 : 0]) 1025 | }); 1026 | if (table.config.debug) { 1027 | $.tablesorter.benchmark("Applying Zebra widget", time); 1028 | } 1029 | } 1030 | }); 1031 | })(jQuery); -------------------------------------------------------------------------------- /flask_profile/static/js/profiler.js: -------------------------------------------------------------------------------- 1 | var _flaskProfileBackupOriginalHtml; 2 | 3 | $(document).ready(function() { 4 | $('#_profileContent table.tablesorter') 5 | .tablesorter() 6 | .bind('sortStart', function() { 7 | $(this).find('tbody tr') 8 | .removeClass('profileContentTrEven') 9 | .removeClass('profileContentTrOdd'); 10 | }) 11 | .bind('sortEnd', function() { 12 | $(this).find('tbody tr').each(function(idx, elem) { 13 | var even = idx % 2 == 0; 14 | $(elem) 15 | .toggleClass('profileContentTrEven', even) 16 | .toggleClass('profileContentTrOdd', !even); 17 | }); 18 | }); 19 | 20 | $('#flaskShowProfileButton').click(function() { 21 | $('#_profileContentWrapper').toggle(); 22 | return false; 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /flask_profile/templates/_profile/profiler.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 37 | 38 |
39 | « 40 |
41 | 42 | 43 | 44 | 45 |
46 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | """ 2 | Flask-Profile 3 | ------------- 4 | 5 | A profiler extension for finding bottlenecks in Flask application. 6 | 7 | Links 8 | ````` 9 | 10 | * `documentation `_ 11 | * `development version 12 | `_ 13 | 14 | """ 15 | from setuptools import setup 16 | 17 | 18 | setup( 19 | name='Flask-Profile', 20 | version='0.2', 21 | url='https://github.com/fengsp/flask-profile', 22 | license='BSD', 23 | author='Shipeng Feng', 24 | author_email='fsp261@gmail.com', 25 | description='Flask Application Profiler', 26 | long_description=__doc__, 27 | packages=['flask_profile'], 28 | include_package_data=True, 29 | zip_safe=False, 30 | platforms='any', 31 | install_requires=[ 32 | 'Flask >= 0.7' 33 | ], 34 | classifiers=[ 35 | 'Environment :: Web Environment', 36 | 'Intended Audience :: Developers', 37 | 'License :: OSI Approved :: BSD License', 38 | 'Operating System :: OS Independent', 39 | 'Programming Language :: Python', 40 | 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', 41 | 'Topic :: Software Development :: Libraries :: Python Modules' 42 | ] 43 | ) 44 | --------------------------------------------------------------------------------