├── peavy_demo ├── __init__.py ├── requirements.txt ├── templates │ ├── registration │ │ ├── logged_out.html │ │ └── login.html │ ├── base.html │ └── home.html ├── models.py ├── forms.py ├── urls.py ├── static │ └── main.css ├── views.py └── settings.py ├── peavy ├── migrations │ ├── __init__.py │ ├── 0002_auto.py │ ├── 0004_drop_message_index.py │ ├── 0003_add_user_pk.py │ └── 0001_initial.py ├── templatetags │ ├── __init__.py │ └── peavy.py ├── static │ └── peavy │ │ ├── img │ │ ├── first.png │ │ ├── last.png │ │ ├── next.png │ │ ├── prev.png │ │ └── loading.gif │ │ ├── css │ │ └── peavy.css │ │ └── js │ │ ├── jquery.infinitescroll.min.js │ │ └── jquery-1.5.1.min.js ├── __init__.py ├── urls.py ├── signals.py ├── middleware.py ├── routers.py ├── tests.py ├── templates │ └── peavy │ │ ├── base.html │ │ └── dashboard.html ├── filters.py ├── admin.py ├── models.py ├── views.py └── handlers.py ├── .gitignore ├── MANIFEST.in ├── tests.py ├── LICENSE.txt ├── setup.py └── README.rst /peavy_demo/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /peavy/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /peavy/templatetags/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.pyc 3 | *.egg 4 | *.egg-info 5 | dist 6 | build 7 | .idea -------------------------------------------------------------------------------- /peavy_demo/requirements.txt: -------------------------------------------------------------------------------- 1 | django-peavy 2 | South>=0.7.6 3 | psycopg2>=2.4.3 4 | -------------------------------------------------------------------------------- /peavy/static/peavy/img/first.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fairview/django-peavy/HEAD/peavy/static/peavy/img/first.png -------------------------------------------------------------------------------- /peavy/static/peavy/img/last.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fairview/django-peavy/HEAD/peavy/static/peavy/img/last.png -------------------------------------------------------------------------------- /peavy/static/peavy/img/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fairview/django-peavy/HEAD/peavy/static/peavy/img/next.png -------------------------------------------------------------------------------- /peavy/static/peavy/img/prev.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fairview/django-peavy/HEAD/peavy/static/peavy/img/prev.png -------------------------------------------------------------------------------- /peavy/static/peavy/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fairview/django-peavy/HEAD/peavy/static/peavy/img/loading.gif -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE.txt 2 | include README.rst 3 | recursive-include peavy/templates * 4 | recursive-include peavy/static * 5 | -------------------------------------------------------------------------------- /peavy/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | django-peavy makes it easy to collect and monitor Django application logging. 3 | """ 4 | VERSION = (0, 9, 0) 5 | 6 | 7 | def get_version(): 8 | return '.'.join((str(d) for d in VERSION)) 9 | -------------------------------------------------------------------------------- /peavy/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls.defaults import * 2 | 3 | urlpatterns = patterns('peavy.views', 4 | url(r'^$', 'dashboard', name='dashboard'), 5 | url(r'^debug/(?P[^/]+)/$', 'debug_page', name='debug_page'), 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /peavy_demo/templates/registration/logged_out.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | {% block title %}{% trans "Logged out" %}{% endblock %} 4 | 5 | {% block main %} 6 |

{% trans "You are logged out." %}

7 |

{% trans "Thanks for visiting!" %}

8 | {% endblock main %} 9 | -------------------------------------------------------------------------------- /peavy_demo/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class Quote(models.Model): 4 | text = models.TextField() 5 | show = models.CharField(max_length=256) 6 | character = models.CharField(max_length=256) 7 | submitter = models.CharField(max_length=256) 8 | timestamp = models.DateTimeField(auto_now_add=True) 9 | 10 | class Meta: 11 | ordering = ['-timestamp'] 12 | 13 | -------------------------------------------------------------------------------- /peavy_demo/templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | {% load i18n %} 3 | 4 | 5 | 6 | django-peavy demo 7 | 8 | 9 | 10 |
11 | {% block main %}{% endblock main %} 12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /peavy/signals.py: -------------------------------------------------------------------------------- 1 | from django.core.signals import got_request_exception 2 | from django.db import transaction 3 | 4 | @transaction.commit_on_success 5 | def exception_handler(request=None, **kwargs): 6 | logger = logging.getLogger('peavy.signals.exception_handler') 7 | 8 | if transaction.is_dirty(): 9 | transaction.rollback() 10 | 11 | logger.exception('Exception: {0}'.format(exc_type), exc_info=True) 12 | 13 | got_request_exception.connect(exception_handler) 14 | 15 | -------------------------------------------------------------------------------- /peavy_demo/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.utils.translation import gettext_lazy as _ 3 | 4 | from peavy_demo.models import Quote 5 | 6 | class QuoteForm(forms.ModelForm): 7 | submitter = forms.CharField(label=_("Your name")) 8 | show = forms.CharField(label=_("The show")) 9 | character = forms.CharField(label=_("The character")) 10 | text = forms.CharField(widget=forms.Textarea, label=_("The quote")) 11 | 12 | class Meta: 13 | model = Quote 14 | exclude = ['timestamp'] 15 | -------------------------------------------------------------------------------- /tests.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | os.environ["DJANGO_SETTINGS_MODULE"] = 'peavy_demo.settings' 5 | test_dir = os.path.dirname(__file__) 6 | sys.path.insert(0, test_dir) 7 | 8 | print "DJANGO_SETTINGS_MODULE:", os.getenv('DJANGO_SETTINGS_MODULE') 9 | print "sys.path:", sys.path 10 | 11 | from django.test.utils import get_runner 12 | from django.conf import settings 13 | 14 | 15 | def main(): 16 | if 'south' in settings.INSTALLED_APPS: 17 | from south.management.commands import patch_for_test_db_setup 18 | patch_for_test_db_setup() 19 | 20 | test_runner = get_runner(settings)(interactive=False, verbosity=2) 21 | failures = test_runner.run_tests(['peavy']) 22 | sys.exit(failures) 23 | 24 | if __name__ == '__main__': 25 | main() 26 | -------------------------------------------------------------------------------- /peavy_demo/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf import settings 2 | from django.conf.urls.defaults import include, patterns, url 3 | 4 | from django.contrib import admin 5 | 6 | admin.autodiscover() 7 | 8 | urlpatterns = patterns('', 9 | url(r'^$', 'peavy_demo.views.home', name='home'), 10 | (r'^admin/', include(admin.site.urls)), 11 | url(r'^accounts/login/$', 'django.contrib.auth.views.login', name='login'), 12 | url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', name='logout'), 13 | (r'^peavy/', include('peavy.urls', namespace='peavy')), 14 | ) 15 | 16 | if 'devserver' == getattr(settings, 'APP_SERVER', None): 17 | urlpatterns += patterns( 18 | '', 19 | (r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}), 20 | ) 21 | -------------------------------------------------------------------------------- /peavy/middleware.py: -------------------------------------------------------------------------------- 1 | from threading import local 2 | import uuid 3 | 4 | class RequestThreadlocal(local): 5 | request = object() 6 | 7 | class RequestLoggingMiddleware(object): 8 | """ 9 | RequestLoggingMiddleware enables better logging of Django requests. 10 | 11 | It assigns a unique ID to each request, using the Python uuid module, and 12 | keeps a threadlocal reference to the request that logging filters or 13 | adapters can use to access request attributes. 14 | 15 | It should be installed first in your MIDDLEWARE_CLASSES setting, so that 16 | the request information is available for logging as early as possible. 17 | """ 18 | 19 | context = RequestThreadlocal() 20 | 21 | def process_request(self, request): 22 | request.uuid = uuid.uuid4().hex 23 | self.context.request = request 24 | return None 25 | -------------------------------------------------------------------------------- /peavy_demo/static/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: Helvetica, Arial, sans-serif; 3 | background: #000; 4 | color: #ddd; 5 | padding: 2em; 6 | } 7 | 8 | a { 9 | color: #9cd; 10 | } 11 | 12 | input, textarea { 13 | margin: 0 0 1em 0; 14 | float: left; 15 | clear: right; 16 | } 17 | 18 | label { 19 | display: block; 20 | float: left; 21 | clear: left; 22 | width: 25%; 23 | } 24 | 25 | .controls { 26 | float: none; 27 | clear: both; 28 | padding-left: 25%; 29 | } 30 | 31 | table { 32 | margin: 1em 0; 33 | font-size: .9em; 34 | } 35 | 36 | td { 37 | text-align: left; 38 | vertical-align: top; 39 | padding: 4px 20px 4px 4px; 40 | } 41 | 42 | th { 43 | text-align: left; 44 | background: #f0f0f0; 45 | color: #000; 46 | padding: 4px 20px 4px 4px; 47 | font-size: .75em; 48 | text-transform: uppercase; 49 | } 50 | -------------------------------------------------------------------------------- /peavy_demo/templates/registration/login.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %} 3 | {% block title %}{% trans "Log in" %}{% endblock %} 4 | 5 | {% block main %} 6 | 7 |

{% trans "Log in" %}

8 | 9 | {% if form.errors %} 10 |

{% trans "Please correct the errors below" %}:

11 | {% endif %} 12 | 13 |
14 | {% csrf_token %} 15 |
16 |
{% if form.username.errors %} {{ form.username.errors|join:", " }}{% endif %}
17 |
{{ form.username }}
18 |
{% if form.password.errors %} {{ form.password.errors|join:", " }}{% endif %}
19 |
{{ form.password }}
20 |
21 |
22 |
23 | 24 | {% endblock main %} 25 | -------------------------------------------------------------------------------- /peavy_demo/views.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from django.core.urlresolvers import reverse 4 | from django.db import transaction 5 | from django.http import HttpResponseRedirect 6 | from django.shortcuts import render_to_response 7 | from django.template import RequestContext 8 | 9 | from peavy_demo.forms import QuoteForm 10 | from peavy_demo.models import Quote 11 | 12 | @transaction.commit_on_success 13 | def home(request): 14 | logger = logging.getLogger('peavy_demo.views.home') 15 | 16 | if request.method == 'POST': 17 | form = QuoteForm(request.POST) 18 | if form.is_valid(): 19 | quote = form.save() 20 | logger.info('Quote from {0} in {1} submitted by {2}'.format(quote.character, quote.show, quote.submitter)) 21 | 22 | return HttpResponseRedirect(reverse('home')) 23 | else: 24 | form = QuoteForm() 25 | 26 | data = { 27 | 'form': form, 28 | 'quotes': Quote.objects.all() 29 | } 30 | 31 | return render_to_response('home.html', data, context_instance=RequestContext(request)) 32 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2012 Fairview Computing LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /peavy/routers.py: -------------------------------------------------------------------------------- 1 | class DjangoDBRouter(object): 2 | """ 3 | Routes all database operations on peavy models to settings.PEAVY_DATABASE_NAME. 4 | """ 5 | 6 | def db_for_read(self, model, **hints): 7 | from django.conf import settings 8 | db_name = getattr(settings, 'PEAVY_DATABASE_NAME', 'peavy') 9 | 10 | db = None 11 | if model._meta.app_label == 'peavy': 12 | db = db_name 13 | return db 14 | 15 | def db_for_write(self, model, **hints): 16 | from django.conf import settings 17 | db_name = getattr(settings, 'PEAVY_DATABASE_NAME', 'peavy') 18 | 19 | db = None 20 | if model._meta.app_label == 'peavy': 21 | db = db_name 22 | return db 23 | 24 | def allow_relation(self, obj1, obj2, **hints): 25 | allow = None 26 | 27 | if obj1._meta.app_label == 'peavy' and obj2._meta.app_label == 'peavy': 28 | allow = True 29 | return allow 30 | 31 | def allow_syncdb(self, db, model): 32 | from django.conf import settings 33 | db_name = getattr(settings, 'PEAVY_DATABASE_NAME', 'peavy') 34 | 35 | allow = None 36 | if db == db_name: 37 | allow = model._meta.app_label in ['peavy', 'south'] 38 | elif model._meta.app_label == 'peavy': 39 | allow = False 40 | return allow 41 | -------------------------------------------------------------------------------- /peavy/tests.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from django.db import transaction 4 | from django.test import TransactionTestCase 5 | 6 | from peavy.models import LogRecord 7 | from peavy_demo.models import Quote 8 | 9 | 10 | class TransactionTest(TransactionTestCase): 11 | multi_db = True 12 | 13 | def testTransactionSeparation(self): 14 | """ 15 | This test verifies that this means a rollback of an application write 16 | does not undo the logging made in that code. 17 | """ 18 | logger = logging.getLogger('peavy.tests.TransactionTest.testTransactionSeparation') 19 | 20 | try: 21 | with transaction.commit_on_success(): 22 | 23 | Quote.objects.create( 24 | submitter='Anonymous Browncoat', 25 | show='Firefly', 26 | character='Wash', 27 | text='Ah, curse your sudden but inevitable betrayal!' 28 | ) 29 | 30 | logger.info('Someone left a quote!') 31 | 32 | # peavy has just committed the log entry; now raise an 33 | # exception to undo the quote creation 34 | raise ValueError('As in: Fox miscalculated the value of Firefly.') 35 | 36 | except ValueError: 37 | pass 38 | 39 | self.assertTrue(Quote.objects.count() == 0, 'The quote was not rolled back.') 40 | self.assertTrue(LogRecord.objects.count() == 1, 'The log entry was not made.') 41 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | peavy = __import__('peavy') 4 | 5 | with open('README.rst') as file: 6 | long_description = file.read() 7 | 8 | setup( 9 | author='Fairview Computing LLC', 10 | author_email='john@fairviewcomputing.com', 11 | classifiers=[ 12 | 'Development Status :: 3 - Alpha', 13 | 'Environment :: Web Environment', 14 | 'Framework :: Django', 15 | 'Intended Audience :: Developers', 16 | 'License :: OSI Approved :: MIT License', 17 | 'Operating System :: OS Independent', 18 | 'Programming Language :: Python', 19 | 'Topic :: System :: Logging', 20 | ], 21 | description=peavy.__doc__, 22 | long_description=long_description, 23 | download_url='http://github.com/fairview/django-peavy/downloads', 24 | install_requires=[ 25 | 'Django>=1.3', 26 | 'South>=0.7.6' 27 | ], 28 | license="MIT License", 29 | name='django-peavy', 30 | packages=[ 31 | 'peavy', 32 | 'peavy.migrations', 33 | 'peavy.templatetags', 34 | ], 35 | package_data={ 36 | 'peavy': [ 37 | 'README.rst', 38 | 'LICENSE.txt', 39 | 'templates/*/*.html', 40 | 'static/*/*/*', 41 | ], 42 | }, 43 | tests_require=[ 44 | 'Django>=1.3', 45 | 'South>=0.7.6', 46 | 'psycopg2>=2.4.3', # 2.4.2 causes trouble with Django 1.3(.1) unit tests 47 | ], 48 | test_suite='tests.main', 49 | url='http://github.com/fairview/django-peavy', 50 | version=peavy.get_version(), 51 | zip_safe=True, 52 | ) 53 | -------------------------------------------------------------------------------- /peavy/templates/peavy/base.html: -------------------------------------------------------------------------------- 1 | 2 | {% load url from future %} 3 | 4 | 5 | peavy :: {% block title %}{% endblock title %} 6 | 7 | 8 | 9 | {% block page_style %}{% endblock %}{% block extra_head %}{% endblock %} 10 | 11 | 12 |
13 | 21 |
22 | 23 |
24 | {% block content %}{% endblock content %} 25 |
26 | 31 | {% block js_includes %} 32 | 33 | {% endblock js_includes %} 34 | {% block js %}{% endblock js %} 35 | 36 | 37 | -------------------------------------------------------------------------------- /peavy/filters.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | from peavy.middleware import RequestLoggingMiddleware 4 | 5 | class BasicFilter(logging.Filter): 6 | """ 7 | Adds basic request info (unique ID, user, client IP) into the log record. 8 | """ 9 | 10 | def filter(self, record): 11 | request = RequestLoggingMiddleware.context.request 12 | 13 | record.uuid = getattr(request, "uuid", "?") 14 | if hasattr(request, "user"): 15 | record.user_pk = getattr(request.user, 'pk', None) 16 | record.username = request.user.username 17 | else: 18 | record.user_pk = None 19 | record.username = "?" 20 | meta = getattr(request, "META", {}) 21 | record.client_ip = meta.get("REMOTE_ADDR", "?") 22 | return True 23 | 24 | class MetaFilter(logging.Filter): 25 | """ 26 | Adds all the request metadata to the log record. 27 | """ 28 | 29 | def filter(self, record): 30 | request = RequestLoggingMiddleware.context.request 31 | 32 | meta = getattr(request, "META", {}) 33 | for key, value in meta.items(): 34 | if hasattr(record, key): 35 | continue 36 | setattr(record, "META_" + key, value) 37 | 38 | return True 39 | 40 | class RequestIDFilter(logging.Filter): 41 | """Adds request id to logs""" 42 | 43 | def filter(self, record): 44 | request = RequestLoggingMiddleware.context.request 45 | record.uuid = getattr(request, "uuid", "?") 46 | meta = getattr(request, "META", {}) 47 | record.client_ip = meta.get("REMOTE_ADDR", "?") 48 | return True 49 | -------------------------------------------------------------------------------- /peavy/admin.py: -------------------------------------------------------------------------------- 1 | from django.utils.translation import gettext_lazy as _ 2 | 3 | from django.contrib import admin 4 | 5 | from peavy.models import LogRecord 6 | 7 | class LogRecordAdmin(admin.ModelAdmin): 8 | list_display = ('timestamp', 'application', 'origin_server', 'client_ip', 'username', 'logger', 'level', 'message') 9 | list_filter = ('application', 'origin_server', 'username', 'logger', 'level') 10 | search_fields = ('application', 'origin_server', 'client_ip', 'username', 'logger', 'level', 'message') 11 | 12 | fieldsets = ( 13 | ( 14 | _('Server details'), 15 | { 16 | 'fields': ( 17 | 'timestamp', 18 | 'application', 19 | 'origin_server' 20 | ) 21 | } 22 | ), 23 | ( 24 | _('Request details'), 25 | { 26 | 'fields': ( 27 | 'client_ip', 28 | 'user_pk', 29 | 'username', 30 | ) 31 | } 32 | ), 33 | ( 34 | _('Logging details'), 35 | { 36 | 'fields': ( 37 | 'logger', 38 | 'level', 39 | 'message' 40 | ) 41 | } 42 | ), 43 | ( 44 | _('Exception details'), 45 | { 46 | 'fields': ( 47 | 'stack_trace', 48 | 'debug_page' 49 | ) 50 | } 51 | ) 52 | ) 53 | 54 | readonly_fields = LogRecord._meta.get_all_field_names() 55 | 56 | admin.site.register(LogRecord, LogRecordAdmin) 57 | -------------------------------------------------------------------------------- /peavy_demo/templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends "base.html" %} 2 | {% load i18n %}{% load url from future %} 3 | 4 | 5 | {% block main %} 6 |

{% trans "django-peavy demo" %}

7 | 8 | {% url "peavy:dashboard" as peavy_dashboard %} 9 |

10 | {% blocktrans %} 11 | Tell us one of your favorite quotes from a movie or TV series. You can then check the logs to see the record of your submission. 12 | {% endblocktrans %} 13 |

14 |
15 |
16 | {{form.submitter.label_tag}} 17 | {{form.submitter}} 18 | {{form.submitter.errors}} 19 |
20 | 21 |
22 | {{form.show.label_tag}} 23 | {{form.show}} 24 | {{form.show.errors}} 25 |
26 | 27 |
28 | {{form.character.label_tag}} 29 | {{form.character}} 30 | {{form.character.errors}} 31 |
32 | 33 |
34 | {{form.text.label_tag}} 35 | {{form.text}} 36 | {{form.text.errors}} 37 |
38 | 39 |
40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | {% for quote in quotes %} 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | {% empty %} 64 | 65 | 66 | 67 | {% endfor %} 68 | 69 |
{% trans "Submitted at" %}{% trans "Submitted by" %}{% trans "Show" %}{% trans "Character" %}{% trans "Quote" %}
{{quote.timestamp|date:"F j, Y g:i a"}}{{quote.submitter}}{{quote.show}}{{quote.character}}{{quote.text}}
{% trans "No quotes yet. Sad." %}
70 | {% endblock main %} 71 | -------------------------------------------------------------------------------- /peavy/migrations/0002_auto.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | import datetime 3 | from south.db import db 4 | from south.v2 import SchemaMigration 5 | from django.db import models 6 | 7 | class Migration(SchemaMigration): 8 | 9 | def forwards(self, orm): 10 | 11 | # Adding index on 'LogRecord', fields ['timestamp'] 12 | db.create_index('peavy_logrecord', ['timestamp']) 13 | 14 | 15 | def backwards(self, orm): 16 | 17 | # Removing index on 'LogRecord', fields ['timestamp'] 18 | db.delete_index('peavy_logrecord', ['timestamp']) 19 | 20 | 21 | models = { 22 | 'peavy.logrecord': { 23 | 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'LogRecord'}, 24 | 'application': ('django.db.models.fields.CharField', [], {'default': "'sandbox'", 'max_length': '256', 'db_index': 'True'}), 25 | 'client_ip': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '128', 'blank': 'True'}), 26 | 'debug_page': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 27 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 28 | 'level': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 29 | 'logger': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}), 30 | 'message': ('django.db.models.fields.TextField', [], {'db_index': 'True'}), 31 | 'origin_server': ('django.db.models.fields.CharField', [], {'default': "'kaze.jkcl.local'", 'max_length': '256', 'db_index': 'True'}), 32 | 'stack_trace': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 33 | 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}), 34 | 'user': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}), 35 | 'uuid': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}) 36 | } 37 | } 38 | 39 | complete_apps = ['peavy'] 40 | -------------------------------------------------------------------------------- /peavy/migrations/0004_drop_message_index.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | from south.db import db 3 | from south.v2 import SchemaMigration 4 | 5 | 6 | class Migration(SchemaMigration): 7 | 8 | def forwards(self, orm): 9 | # Removing index on 'LogRecord', fields ['message'] 10 | db.delete_index('peavy_logrecord', ['message']) 11 | 12 | def backwards(self, orm): 13 | # Adding index on 'LogRecord', fields ['message'] 14 | db.create_index('peavy_logrecord', ['message']) 15 | 16 | models = { 17 | 'peavy.logrecord': { 18 | 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'LogRecord'}, 19 | 'application': ('django.db.models.fields.CharField', [], {'default': "'sandbox'", 'max_length': '256', 'db_index': 'True'}), 20 | 'client_ip': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '128', 'blank': 'True'}), 21 | 'debug_page': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 22 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 23 | 'level': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 24 | 'logger': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}), 25 | 'message': ('django.db.models.fields.TextField', [], {}), 26 | 'origin_server': ('django.db.models.fields.CharField', [], {'default': "'kaze.jkcl.local'", 'max_length': '256', 'db_index': 'True'}), 27 | 'stack_trace': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 28 | 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}), 29 | 'user_pk': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 30 | 'username': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}), 31 | 'uuid': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}) 32 | } 33 | } 34 | 35 | complete_apps = ['peavy'] 36 | -------------------------------------------------------------------------------- /peavy/migrations/0003_add_user_pk.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | import datetime 3 | from south.db import db 4 | from south.v2 import SchemaMigration 5 | from django.db import models 6 | 7 | class Migration(SchemaMigration): 8 | 9 | def forwards(self, orm): 10 | 11 | # Adding field 'LogRecord.user_pk' 12 | db.add_column('peavy_logrecord', 'user_pk', self.gf('django.db.models.fields.IntegerField')(db_index=True, null=True, blank=True), keep_default=False) 13 | 14 | # rename user to username 15 | db.rename_column('peavy_logrecord', 'user', 'username') 16 | 17 | 18 | def backwards(self, orm): 19 | 20 | # Deleting field 'LogRecord.user_pk' 21 | db.delete_column('peavy_logrecord', 'user_pk') 22 | 23 | # rename username back to user 24 | db.rename_column('peavy_logrecord', 'username', 'user') 25 | 26 | models = { 27 | 'peavy.logrecord': { 28 | 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'LogRecord'}, 29 | 'application': ('django.db.models.fields.CharField', [], {'default': "'sandbox'", 'max_length': '256', 'db_index': 'True'}), 30 | 'client_ip': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '128', 'blank': 'True'}), 31 | 'debug_page': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 32 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 33 | 'level': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 34 | 'logger': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}), 35 | 'message': ('django.db.models.fields.TextField', [], {'db_index': 'True'}), 36 | 'origin_server': ('django.db.models.fields.CharField', [], {'default': "'kaze.jkcl.local'", 'max_length': '256', 'db_index': 'True'}), 37 | 'stack_trace': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 38 | 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now', 'db_index': 'True'}), 39 | 'user': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}), 40 | 'user_pk': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}), 41 | 'uuid': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}) 42 | } 43 | } 44 | 45 | complete_apps = ['peavy'] 46 | -------------------------------------------------------------------------------- /peavy/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | import datetime 3 | from south.db import db 4 | from south.v2 import SchemaMigration 5 | from django.db import models 6 | 7 | class Migration(SchemaMigration): 8 | 9 | def forwards(self, orm): 10 | 11 | # Adding model 'LogRecord' 12 | db.create_table('peavy_logrecord', ( 13 | ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), 14 | ('timestamp', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)), 15 | ('application', self.gf('django.db.models.fields.CharField')(default='?', max_length=256, db_index=True)), 16 | ('origin_server', self.gf('django.db.models.fields.CharField')(default='?', max_length=256, db_index=True)), 17 | ('client_ip', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=128, blank=True)), 18 | ('user', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=256, blank=True)), 19 | ('uuid', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=256, blank=True)), 20 | ('logger', self.gf('django.db.models.fields.CharField')(max_length=1024, db_index=True)), 21 | ('level', self.gf('django.db.models.fields.CharField')(max_length=32, db_index=True)), 22 | ('message', self.gf('django.db.models.fields.TextField')(db_index=True)), 23 | ('stack_trace', self.gf('django.db.models.fields.TextField')(blank=True)), 24 | ('debug_page', self.gf('django.db.models.fields.TextField')(blank=True)), 25 | )) 26 | db.send_create_signal('peavy', ['LogRecord']) 27 | 28 | 29 | def backwards(self, orm): 30 | 31 | # Deleting model 'LogRecord' 32 | db.delete_table('peavy_logrecord') 33 | 34 | 35 | models = { 36 | 'peavy.logrecord': { 37 | 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'LogRecord'}, 38 | 'application': ('django.db.models.fields.CharField', [], {'default': "'?'", 'max_length': '256', 'db_index': 'True'}), 39 | 'client_ip': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '128', 'blank': 'True'}), 40 | 'debug_page': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 41 | 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 42 | 'level': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'}), 43 | 'logger': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'db_index': 'True'}), 44 | 'message': ('django.db.models.fields.TextField', [], {'db_index': 'True'}), 45 | 'origin_server': ('django.db.models.fields.CharField', [], {'default': "'?'", 'max_length': '256', 'db_index': 'True'}), 46 | 'stack_trace': ('django.db.models.fields.TextField', [], {'blank': 'True'}), 47 | 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), 48 | 'user': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}), 49 | 'uuid': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '256', 'blank': 'True'}) 50 | } 51 | } 52 | 53 | complete_apps = ['peavy'] 54 | -------------------------------------------------------------------------------- /peavy/models.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, timedelta, tzinfo 2 | import socket 3 | 4 | from django.conf import settings 5 | from django.db import models 6 | from django.utils.translation import gettext_lazy as _ 7 | 8 | try: 9 | import pytz 10 | except ImportError: 11 | pytz = None 12 | 13 | ZERO = timedelta(0) 14 | 15 | 16 | class UTC(tzinfo): 17 | """ 18 | UTC implementation taken from Python's docs. 19 | 20 | Used only when pytz isn't available. 21 | """ 22 | 23 | def __repr__(self): 24 | return "" 25 | 26 | def utcoffset(self, dt): 27 | return ZERO 28 | 29 | def tzname(self, dt): 30 | return "UTC" 31 | 32 | def dst(self, dt): 33 | return ZERO 34 | 35 | 36 | def now(): 37 | if getattr(settings, 'USE_TZ', False): 38 | if pytz: 39 | utc = pytz.utc 40 | else: 41 | utc = UTC() 42 | return datetime.utcnow().replace(tzinfo=utc) 43 | else: 44 | return datetime.now() 45 | 46 | 47 | class LogRecord(models.Model): 48 | """ 49 | A simple bucket for the usual logging info (logger, level, message) plus a 50 | unique request ID for tracking all the log records made in a given request, 51 | the server logging the request, the client's IP address, the name of the 52 | application, and for requests with errors, a stack trace and a copy of 53 | Django's server error page. 54 | """ 55 | timestamp = models.DateTimeField(db_index=True, default=now) 56 | 57 | application = models.CharField( 58 | max_length=256, 59 | default=getattr( 60 | settings, 61 | 'PEAVY_APP_NAME', 62 | settings.ROOT_URLCONF.split('.')[0] 63 | ), 64 | help_text=_("The application logging this record."), 65 | db_index=True 66 | ) 67 | 68 | origin_server = models.CharField( 69 | max_length=256, 70 | help_text=_("The server logging this record."), 71 | default=socket.gethostname, 72 | db_index=True 73 | ) 74 | 75 | client_ip = models.CharField( 76 | max_length=128, 77 | help_text=_("The IP address of the client making the request."), 78 | blank=True, 79 | db_index=True 80 | ) 81 | 82 | user_pk = models.IntegerField( 83 | blank=True, 84 | null=True, 85 | db_index=True, 86 | help_text=_("The primary key of the user making the request in which this record was logged."), 87 | ) 88 | 89 | username = models.CharField( 90 | max_length=256, 91 | help_text=_("The username of the user making the request in which this record was logged."), 92 | blank=True, 93 | db_index=True 94 | ) 95 | 96 | uuid = models.CharField( 97 | max_length=256, 98 | help_text=_("The UUID of the Django request in which this record was logged."), 99 | blank=True, 100 | db_index=True 101 | ) 102 | 103 | logger = models.CharField( 104 | max_length=1024, 105 | help_text=_("The name of the logger of the record."), 106 | db_index=True 107 | ) 108 | 109 | level = models.CharField( 110 | max_length=32, 111 | help_text=_("The level of the log record (DEBUG, INFO...)"), 112 | db_index=True 113 | ) 114 | 115 | message = models.TextField() 116 | stack_trace = models.TextField(blank=True) 117 | debug_page = models.TextField(blank=True) 118 | 119 | class Meta: 120 | ordering = ('-timestamp',) 121 | permissions = ( 122 | ("view_logs", "Can view log records"), 123 | ) 124 | 125 | def __unicode__(self): 126 | return unicode(self.pk) 127 | -------------------------------------------------------------------------------- /peavy/views.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | from django.conf import settings 4 | from django.contrib.auth.decorators import permission_required, user_passes_test 5 | from django.core.paginator import EmptyPage, Paginator 6 | from django.core.urlresolvers import reverse 7 | from django.db.models import Count, Sum, Q 8 | from django import http 9 | from django.shortcuts import get_object_or_404, render_to_response 10 | from django.template import RequestContext 11 | from django.utils.translation import ugettext as _ 12 | 13 | from peavy.models import LogRecord 14 | 15 | @permission_required("peavy.view_logs") 16 | def dashboard(request): 17 | """ 18 | The main view: all the logs, with filters and pagination. 19 | """ 20 | 21 | records = LogRecord.objects.all() 22 | 23 | applications = request.GET.getlist("application") 24 | if applications: 25 | records = records.filter(application__in=applications) 26 | 27 | client_ips = request.GET.getlist("client_ip") 28 | if client_ips: 29 | records = records.filter(client_ip__in=client_ips) 30 | 31 | levels = request.GET.getlist("level") 32 | if levels: 33 | records = records.filter(level__in=levels) 34 | 35 | loggers = request.GET.getlist("logger") 36 | if loggers: 37 | records = records.filter(logger__in=loggers) 38 | 39 | origin_servers = request.GET.getlist("origin_server") 40 | if origin_servers: 41 | records = records.filter(origin_server__in=origin_servers) 42 | 43 | request_ids = request.GET.getlist("request_id") 44 | if request_ids: 45 | records = records.filter(uuid__in=request_ids) 46 | 47 | show_anonymous_users = False 48 | user_pks = [] 49 | for pk in request.GET.getlist("user_pk"): 50 | if pk == "None": 51 | show_anonymous_users = True 52 | else: 53 | user_pks.append(pk) 54 | 55 | user_pk_filter = None 56 | 57 | if show_anonymous_users: 58 | user_pk_filter = Q(user_pk__isnull=True) 59 | 60 | if user_pks: 61 | if not user_pk_filter: 62 | user_pk_filter = Q(user_pk__in=user_pks) 63 | else: 64 | user_pk_filter |= Q(user_pk__in=user_pks) 65 | 66 | if user_pk_filter: 67 | records = records.filter(user_pk_filter) 68 | 69 | usernames = request.GET.getlist("username") 70 | if usernames: 71 | records = records.filter(username__in=usernames) 72 | 73 | message_filters = request.GET.getlist("message") 74 | if message_filters: 75 | message_query = None 76 | for term in message_filters: 77 | if not term: 78 | continue 79 | if message_query is None: 80 | message_query = Q(message__iregex=term) 81 | else: 82 | message_query &= Q(message__iregex=term) 83 | if message_query is not None: 84 | records = records.filter(message_query) 85 | 86 | page_number = int(request.GET.get("page", 1)) 87 | count = int(request.GET.get("count", 20)) 88 | 89 | paginator = Paginator(object_list=records, per_page=count, allow_empty_first_page=True) 90 | 91 | if page_number < 1: 92 | redirect = re.sub("page=\d+", "page=%s" % paginator.num_pages, request.get_full_path()) 93 | return http.HttpResponseRedirect(redirect) 94 | if page_number > paginator.num_pages: 95 | redirect = re.sub("page=\d+", "page=1", request.get_full_path()) 96 | return http.HttpResponseRedirect(redirect) 97 | 98 | records = paginator.page(page_number) 99 | 100 | data = { 101 | "records": records, 102 | } 103 | 104 | return render_to_response( 105 | "peavy/dashboard.html", 106 | data, 107 | context_instance = RequestContext(request) 108 | ) 109 | 110 | @user_passes_test(lambda u: u.is_superuser) 111 | def debug_page(request, record_id): 112 | """ 113 | For log records with exception information, return the copy of Django's 114 | error page for the request. As this can contain sensitive information like 115 | passwords in POST data, restrict the view to superusers. 116 | """ 117 | 118 | record = get_object_or_404(LogRecord, pk=record_id) 119 | return http.HttpResponse(record.debug_page) 120 | -------------------------------------------------------------------------------- /peavy/handlers.py: -------------------------------------------------------------------------------- 1 | import logging 2 | import traceback 3 | 4 | class ExceptionLoggingHandler(logging.Handler): 5 | """ 6 | A handler that collects exception information, including a stack trace and 7 | a full Django error page. 8 | """ 9 | 10 | def get_debug_page(self, record, request): 11 | """ 12 | Given a logging.LogRecord and a Django request that encountered an 13 | exception, create a Django server error debugging page. 14 | """ 15 | 16 | from django.views.debug import ExceptionReporter 17 | 18 | debug_page = "" 19 | if record.exc_info: 20 | exc_info = record.exc_info 21 | reporter = ExceptionReporter(request, *exc_info) 22 | debug_page = reporter.get_traceback_html() or "" 23 | return debug_page 24 | 25 | def get_stack_trace(self, record, request): 26 | """ 27 | Given a logging.LogRecord and a Django request that encountered an 28 | exception, collect a stack trace. 29 | """ 30 | 31 | from django.views.debug import ExceptionReporter 32 | 33 | stack_trace = "" 34 | if record.exc_info: 35 | exc_info = record.exc_info 36 | reporter = ExceptionReporter(request, *exc_info) 37 | stack_trace = "\n".join( 38 | traceback.format_exception(*record.exc_info) 39 | ) 40 | return stack_trace 41 | 42 | class DjangoDBHandler(ExceptionLoggingHandler): 43 | """ 44 | A handler that stores log records in a Django model. 45 | """ 46 | 47 | def emit(self, record): 48 | from django.db import transaction 49 | 50 | from peavy.middleware import RequestLoggingMiddleware 51 | from peavy.models import LogRecord 52 | 53 | self.format(record) 54 | 55 | request = getattr(RequestLoggingMiddleware.context, "request", None) 56 | 57 | stack_trace = self.get_stack_trace(record, request) 58 | debug_page = self.get_debug_page(record, request) 59 | 60 | from django.conf import settings 61 | db_name = getattr(settings, "PEAVY_DATABASE_NAME", "peavy") 62 | 63 | with transaction.commit_on_success(using=db_name): 64 | LogRecord.objects.using(db_name).create( 65 | logger = record.name, 66 | level = record.levelname, 67 | message = record.msg, 68 | uuid = getattr(record, "uuid", "?"), 69 | client_ip = getattr(record, "client_ip", "?"), 70 | username = getattr(record, "username", "?"), 71 | user_pk = getattr(record, "user_pk", None), 72 | stack_trace = stack_trace, 73 | debug_page = debug_page 74 | ) 75 | 76 | class AdminEmailHandler(ExceptionLoggingHandler): 77 | """ 78 | A handler that sends an abridged error notification to settings.ADMINS; the 79 | email includes the traceback and a link to the dashboard for reviewing the 80 | request's log records, but no sensitive data like request.POST. 81 | """ 82 | 83 | def emit(self, record): 84 | from peavy.middleware import RequestLoggingMiddleware 85 | from django.core import mail 86 | from django.core.urlresolvers import reverse 87 | from django.contrib.sites.models import Site 88 | 89 | subject = "%s: %s" % ( 90 | record.levelname, 91 | record.msg 92 | ) 93 | 94 | try: 95 | request = getattr(RequestLoggingMiddleware.context, "request", None) 96 | site = Site.objects.get_current() 97 | request_link = ( 98 | "View the log entries for this request:\n\n" 99 | "https://%s%s?request_id=%s\n" % ( 100 | site.domain, 101 | reverse("peavy:dashboard"), 102 | record.uuid 103 | ) 104 | ) 105 | 106 | except Exception, e: 107 | print e 108 | request = None 109 | request_link = "Link to request log records unavailable." 110 | 111 | stack_trace = "" 112 | if record.exc_info: 113 | stack_trace = self.get_stack_trace(record, request) 114 | 115 | message = "%s\n\n%s" % (request_link, stack_trace) 116 | 117 | mail.mail_admins( 118 | subject, 119 | message, 120 | fail_silently=True 121 | ) 122 | -------------------------------------------------------------------------------- /peavy_demo/settings.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | ADMIN_MEDIA_PREFIX = '/static/admin/' 4 | DATABASE_ROUTERS = ['peavy.routers.DjangoDBRouter'] 5 | DATABASES = { 6 | 'default': { 7 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 8 | 'NAME': 'peavy_demo', 9 | 'USER': 'peavy_demo', 10 | 'PASSWORD': 'peavy_demo', 11 | 'TEST_CHARSET': 'UTF8' 12 | }, 13 | 'peavy': { 14 | 'ENGINE': 'django.db.backends.postgresql_psycopg2', 15 | 'NAME': 'peavy_demo_peavy', 16 | 'USER': 'peavy_demo', 17 | 'PASSWORD': 'peavy_demo', 18 | 'TEST_CHARSET': 'UTF8' 19 | } 20 | } 21 | DEBUG = True 22 | DIRNAME = os.path.dirname(__file__) 23 | EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' 24 | 25 | INSTALLED_APPS = ( 26 | 'peavy', 27 | 'peavy_demo', 28 | 'django.contrib.admin', 29 | 'django.contrib.admindocs', 30 | 'django.contrib.auth', 31 | 'django.contrib.contenttypes', 32 | 'django.contrib.humanize', 33 | 'django.contrib.messages', 34 | 'django.contrib.sessions', 35 | 'django.contrib.sitemaps', 36 | 'django.contrib.sites', 37 | 'django.contrib.staticfiles', 38 | 'south', 39 | ) 40 | 41 | LANGUAGE_CODE = 'en-us' 42 | LOGGING = { 43 | 'version': 1, 44 | 'disable_existing_loggers': True, 45 | 'formatters': { 46 | 'default': { 47 | 'format': '[%(asctime)s %(name)s %(levelname)s] %(message)s' 48 | }, 49 | 'basic': { 50 | 'format': '[%(asctime)s %(uuid)s %(user_pk)s:%(username)s %(name)s %(levelname)s] %(message)s' 51 | }, 52 | 'meta': { 53 | 'format': '[%(asctime)s %(client_ip)s %(uuid)s %(user_pk)s:%(username)s %(name)s %(levelname)s] %(message)s' 54 | }, 55 | }, 56 | 'filters': { 57 | 'basic': { 58 | '()': 'peavy.filters.BasicFilter', 59 | }, 60 | 'meta': { 61 | '()': 'peavy.filters.MetaFilter', 62 | } 63 | }, 64 | 'handlers': { 65 | 'null': { 66 | 'level': 'DEBUG', 67 | 'class': 'django.utils.log.NullHandler', 68 | }, 69 | 'console': { 70 | 'level': 'DEBUG', 71 | 'class': 'logging.StreamHandler', 72 | 'filters': ['basic', 'meta'], 73 | 'formatter': 'basic' 74 | }, 75 | 'mail_admins': { 76 | 'level': 'ERROR', 77 | 'class': 'peavy.handlers.AdminEmailHandler', 78 | 'filters': ['basic', 'meta'], 79 | 'formatter': 'meta' 80 | }, 81 | 'peavy': { 82 | 'level': 'INFO', 83 | 'class': 'peavy.handlers.DjangoDBHandler', 84 | 'filters': ['basic', 'meta'], 85 | 'formatter': 'meta' 86 | } 87 | }, 88 | 'loggers': { 89 | 'django': { 90 | 'handlers': ['null'], 91 | 'propagate': True, 92 | 'level': 'INFO', 93 | }, 94 | 'django.request': { 95 | 'handlers': ['peavy', 'mail_admins'], 96 | 'level': 'ERROR', 97 | 'propagate': False, 98 | }, 99 | 'peavy': { 100 | 'handlers': ['console', 'peavy'], 101 | 'level': 'DEBUG', 102 | }, 103 | 'peavy_demo': { 104 | 'handlers': ['console', 'peavy'], 105 | 'level': 'DEBUG', 106 | }, 107 | } 108 | } 109 | LOGIN_REDIRECT_URL = '/' 110 | MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage' 111 | MIDDLEWARE_CLASSES = ( 112 | 'django.middleware.common.CommonMiddleware', 113 | 'django.contrib.sessions.middleware.SessionMiddleware', 114 | 'django.contrib.messages.middleware.MessageMiddleware', 115 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 116 | 'django.middleware.locale.LocaleMiddleware', 117 | 'django.middleware.transaction.TransactionMiddleware', 118 | 'peavy.middleware.RequestLoggingMiddleware', 119 | ) 120 | ROOT_URLCONF = 'peavy_demo.urls' 121 | SECRET_KEY = 'jj7ck0*b%s)7r7dq%9&#!vvj=w&)3kie=cf_s*=ai43$u4be-v' 122 | SITE_ID = 1 123 | STATIC_URL = '/static/' 124 | STATIC_ROOT = os.path.abspath(os.path.join(DIRNAME, 'static')) 125 | TEMPLATE_CONTEXT_PROCESSORS = ( 126 | 'django.contrib.auth.context_processors.auth', 127 | 'django.core.context_processors.debug', 128 | 'django.core.context_processors.i18n', 129 | 'django.core.context_processors.request', 130 | 'django.core.context_processors.static', 131 | 'django.contrib.messages.context_processors.messages', 132 | ) 133 | TEMPLATE_DEBUG = True 134 | TIME_ZONE = 'America/New_York' 135 | USE_I18N = True 136 | -------------------------------------------------------------------------------- /peavy/templatetags/peavy.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | from django.conf import settings 4 | from django import http 5 | from django import template 6 | from django.utils.html import fix_ampersands 7 | from django.utils.safestring import mark_safe 8 | from django.utils.translation import ugettext_lazy as _ 9 | 10 | register = template.Library() 11 | 12 | PAGE_RE = re.compile("[\?&]page=\d+") 13 | class PageNavigatorNode(template.Node): 14 | """ 15 | Renders page navigation markup for a page of a django.core.paginator.Paginator. 16 | """ 17 | def __init__(self, page, base_url): 18 | self.page = page 19 | self.base_url = base_url 20 | 21 | def render(self, context): 22 | page = template.Variable(self.page).resolve(context) 23 | url = template.Variable(self.base_url).resolve(context) 24 | url = PAGE_RE.sub("", url) 25 | url = url.replace("%", "%%") 26 | 27 | pages = page.paginator.num_pages 28 | 29 | page_link = u'' % (url, url.find("?") == -1 and "?" or "&", settings.STATIC_URL) 30 | first = getattr(settings, "PAGE_ICON_FIRST", "peavy/img/first.png") 31 | prev = getattr(settings, "PAGE_ICON_PREV", "peavy/img/prev.png") 32 | next = getattr(settings, "PAGE_ICON_NEXT", "peavy/img/next.png") 33 | last = getattr(settings, "PAGE_ICON_LAST", "peavy/img/last.png") 34 | 35 | output = "" 36 | if page.paginator.num_pages > 1: 37 | output = u'" 46 | return mark_safe(fix_ampersands(output)) 47 | 48 | @register.tag 49 | def pagenavigator(parser, argument_string): 50 | argv = argument_string.split_contents() 51 | argc = len(argv) 52 | if argc == 3: 53 | return PageNavigatorNode(argv[1], argv[2]) 54 | 55 | raise template.TemplateSyntaxError("The %s tag requires a paginator page and a base URL." % argv[0]) 56 | 57 | class QueryStringNode(template.Node): 58 | """ 59 | Updates the current query string of the request with the supplied 60 | parameters and values. 61 | 62 | Values are first looked up as variables in the request context; if the 63 | variable is not found they'll be used as given. 64 | 65 | You can add or delete specific values, or by passing an empty value, remove 66 | all values for a parameter. The order in which you pass the parameters is 67 | the order in which the operations will be applied to the query string. 68 | 69 | Add several parameters: 70 | 71 | {% query_string "level=ERROR" "level=WARN" "logger=record.logger" %} 72 | 73 | Delete a value, if present: 74 | 75 | {% query_string "level-=record.level" %} 76 | 77 | Clear all values for a certain parameter, then add one for it: 78 | 79 | {% query_string "level=" "level=CRITICAL" %} 80 | 81 | """ 82 | parameters = [] 83 | 84 | def __init__(self, parameters): 85 | self.parameters = parameters 86 | 87 | def render(self, context): 88 | 89 | operations = [] 90 | 91 | for p in self.parameters: 92 | if '-=' in p: 93 | # handle requests to delete a specific value 94 | k, v = p.split('-=', 1) 95 | operations.append(('delete', k, v)) 96 | else: 97 | k, v = p.split('=', 1) 98 | if not v: 99 | # handle requests to remove all values 100 | operations.append(('clear', k, v)) 101 | else: 102 | # add a value for the key 103 | operations.append(('add', k, v)) 104 | request = template.Variable('request').resolve(context) 105 | 106 | qs = request.GET.copy() 107 | for operation, k, v in operations: 108 | try: 109 | k = template.Variable(k).resolve(context) 110 | except template.VariableDoesNotExist, e: 111 | # OK, we'll use the key as given 112 | pass 113 | 114 | if operation == 'clear': 115 | if k in qs: 116 | del qs[k] 117 | continue 118 | 119 | try: 120 | v = template.Variable(v).resolve(context) 121 | except template.VariableDoesNotExist, e: 122 | # OK, we'll use the value as given 123 | pass 124 | 125 | if operation == 'add': 126 | values = qs.getlist(k) 127 | if v not in values: 128 | # repeating parameters is OK, but there's no point repeating 129 | # the same values 130 | values.append(v) 131 | qs.setlist(k, values) 132 | 133 | elif operation == 'delete': 134 | if k in qs: 135 | values = qs.getlist(k) 136 | qs.setlist(k, [val for val in values if val != v]) 137 | 138 | query_string = qs.urlencode() 139 | if query_string: 140 | return '?' + query_string 141 | else: 142 | return '' 143 | 144 | @register.tag 145 | def query_string(parser, argument_string): 146 | argv = argument_string.split_contents() 147 | argc = len(argv) 148 | 149 | return QueryStringNode(argv[1:]) 150 | -------------------------------------------------------------------------------- /peavy/static/peavy/css/peavy.css: -------------------------------------------------------------------------------- 1 | /** reset */ 2 | /* 3 | style.css contains a reset, font normalization and some base styles. 4 | 5 | credit is left where credit is due. 6 | additionally, much inspiration was taken from these projects: 7 | yui.yahooapis.com/2.8.1/build/base/base.css 8 | camendesign.com/design/ 9 | praegnanz.de/weblog/htmlcssjs-kickstart 10 | */ 11 | 12 | /* 13 | html5doctor.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline) 14 | v1.4 2009-07-27 | Authors: Eric Meyer & Richard Clark 15 | html5doctor.com/html-5-reset-stylesheet/ 16 | */ 17 | 18 | html, body, div, span, object, iframe, 19 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 20 | abbr, address, cite, code, 21 | del, dfn, em, img, ins, kbd, q, samp, 22 | small, strong, sub, sup, var, 23 | b, i, 24 | dl, dt, dd, ol, ul, li, 25 | fieldset, form, label, legend, 26 | table, caption, tbody, tfoot, thead, tr, th, td, 27 | article, aside, figure, footer, header, 28 | hgroup, menu, nav, section, menu, 29 | time, mark, audio, video { 30 | margin:0; 31 | padding:0; 32 | border:0; 33 | outline:0; 34 | font-size:100%; 35 | vertical-align:baseline; 36 | background:transparent; 37 | } 38 | 39 | article, aside, figure, footer, header, 40 | hgroup, nav, section { display:block; } 41 | 42 | ul { list-style:none; } 43 | 44 | li { 45 | max-width: 48em; 46 | } 47 | 48 | blockquote, q { quotes:none; } 49 | 50 | blockquote:before, blockquote:after, 51 | q:before, q:after { content:''; content:none; } 52 | 53 | a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; } 54 | 55 | ins { background-color:#ff9; color:#000; text-decoration:none; } 56 | 57 | mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; } 58 | 59 | del { text-decoration: line-through; } 60 | 61 | abbr[title], dfn[title] { border-bottom:1px dotted #000; cursor:help; } 62 | 63 | hr { display:block; height:1px; border:0; border-top:1px solid #ccc; margin:1em 0; padding:0; } 64 | 65 | /* END RESET CSS */ 66 | 67 | a { 68 | color: #fff; 69 | text-decoration: none; 70 | } 71 | 72 | a:hover { 73 | text-decoration: underline; 74 | } 75 | 76 | body { 77 | overflow-y: scroll; 78 | background: #000; 79 | margin: 0; 80 | padding: 0; 81 | color: #ddd; 82 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 83 | } 84 | 85 | footer { 86 | margin-top: 2em; 87 | padding: 0 .25em; 88 | font-size: .75em; 89 | text-align: right; 90 | } 91 | 92 | footer li { 93 | display: inline; 94 | } 95 | 96 | nav { 97 | font-size: .75em; 98 | margin-bottom: .25em; 99 | padding: .5em; 100 | background: #333; 101 | box-shadow: 0 4px 2px #3F3F3F; 102 | text-transform: uppercase; 103 | overflow: auto; 104 | } 105 | 106 | nav ul { 107 | overflow: auto; 108 | } 109 | 110 | nav li { 111 | float: left; 112 | } 113 | 114 | nav li.search { 115 | float: right; 116 | margin: 0; 117 | padding: 0; 118 | } 119 | 120 | nav a { 121 | padding: 2px; 122 | } 123 | 124 | nav input { 125 | font-size: .75em; 126 | } 127 | 128 | ul { 129 | list-style: none; 130 | margin: 0; 131 | padding: 0; 132 | } 133 | li { 134 | margin: .25em 1em .25em 0; 135 | } 136 | 137 | .clear { 138 | float: none; 139 | clear: both; 140 | } 141 | 142 | .delete { 143 | color: #f00; 144 | font-size: .75em; 145 | font-weight: bold; 146 | padding: 2px; 147 | margin: 0 .5em 0 0; 148 | } 149 | 150 | .hint { 151 | color: #aaa; 152 | } 153 | 154 | #content { 155 | position: relative; 156 | } 157 | 158 | .page_navigator { 159 | text-align: right; 160 | font-size: .75em; 161 | text-transform: uppercase; 162 | } 163 | 164 | .page_navigator img { 165 | vertical-align: bottom; 166 | } 167 | 168 | #map { 169 | background: #333333; 170 | border-bottom-right-radius: 10px; 171 | border-top-right-radius: 10px; 172 | font-size: 0.75em; 173 | margin: 1em 0; 174 | padding: 0.25em; 175 | position: fixed; 176 | width: 6em; 177 | white-space: nowrap; 178 | } 179 | 180 | #filters { 181 | font-size: .75em; 182 | margin: .25em 0 .5em 10em; 183 | padding: 0 0 .25em 0; 184 | border-bottom: 1px solid #333; 185 | } 186 | 187 | #filters li { 188 | padding-left: 1em; 189 | } 190 | 191 | #filters a:hover { 192 | text-decoration: none; 193 | } 194 | 195 | #filters img { 196 | vertical-align: bottom; 197 | padding: 0 4px 0 0 ; 198 | } 199 | 200 | #records { 201 | padding: .5em 0; 202 | } 203 | 204 | .record { 205 | cursor: pointer; 206 | padding-left: 10em; 207 | border: 1px solid transparent; 208 | } 209 | 210 | .record.highlight { 211 | border-left: 1px solid #999; 212 | border-right: 1px solid #999; 213 | } 214 | 215 | .record.highlight-first { 216 | border-top: 1px solid #999; 217 | } 218 | 219 | .record.highlight-last { 220 | border-bottom: 1px solid #999; 221 | } 222 | 223 | .timestamp { 224 | float: left; 225 | clear: left; 226 | color: #777; 227 | padding: .25em 0 .5em 0; 228 | font-size: .75em; 229 | font-family: Menlo, Courier, monospace; 230 | white-space: nowrap; 231 | } 232 | 233 | .detail { 234 | float: left; 235 | clear: right; 236 | max-width: 80%; 237 | padding: 0 0 .5em 1em; 238 | } 239 | 240 | .detail.critical .message, 241 | .detail.error .message { 242 | color: #f30; 243 | } 244 | 245 | .detail.warn .message { 246 | color: #fc3; 247 | } 248 | 249 | .detail .meta { 250 | font-size: .75em; 251 | padding-top: .25em; 252 | display: none; 253 | } 254 | 255 | .detail .meta div { 256 | float: left; 257 | margin: .25em .5em .25em 0; 258 | } 259 | 260 | .detail .meta div.debug, 261 | .detail .meta div.debug { 262 | float: none; 263 | clear: both; 264 | } 265 | 266 | .detail .meta div.debug a { 267 | color: #fff; 268 | } 269 | 270 | @media print { 271 | nav { display: none; } 272 | } 273 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | django-peavy 3 | ============ 4 | 5 | ``django-peavy`` is a tool for improving your Django application logging. 6 | 7 | Features 8 | -------- 9 | 10 | * Middleware to tag each request with a unique ID. 11 | 12 | * Logging filters to capture request metadata like user, remote IP, and headers. 13 | 14 | * Logging handlers for: 15 | 16 | * Capturing exception information, including a copy of the Django server 17 | error page, in a database. 18 | 19 | * Sending error notifications to admins without revealing sensitive 20 | information like the contents of request.POST. 21 | 22 | * A database router for sending log records to a separate database. 23 | 24 | * A simple user interface for browsing log records in the database. 25 | 26 | Installation 27 | ------------ 28 | 29 | Start with Django 1.3 or higher; peavy is intended for use with the new logging 30 | configuration first available in that version. 31 | 32 | To install, simply run:: 33 | 34 | pip install django-peavy 35 | 36 | Configuration 37 | ------------- 38 | 39 | 1. Add ``peavy`` to your ``INSTALLED_APPS`` setting. 40 | 41 | 2. Add the peavy database router:: 42 | 43 | DATABASE_ROUTERS = ['peavy.routers.DjangoDBRouter'] 44 | 45 | 3. Create a dedicated database for logging. 46 | 47 | If you want to name it something other than 'peavy', you'll need to specify 48 | it in ``settings.PEAVY_DATABASE_NAME``. 49 | 50 | The separate database makes schema management a little trickier than usual. 51 | It needs to contain South's migration history table as well as Peavy's log 52 | records. 53 | 54 | So first, run syncdb on your default database:: 55 | 56 | $ django-admin.py syncdb 57 | 58 | And of course if you have other apps using South, migrate them:: 59 | 60 | $ django-admin.py migrate 61 | 62 | This will actually create peavy tables in your default database. Sorry for 63 | the debris; South isn't yet obeying database routers. 64 | 65 | Now on to peavy's database:: 66 | 67 | $ django-admin.py syncdb --database=peavy 68 | 69 | Then run Peavy's South migrations:: 70 | 71 | $ django-admin.py migrate peavy --database=peavy 72 | 73 | (Of course, if you chose a different name for the database, use that in 74 | these last two commands.) 75 | 76 | If you omit the app name, you may encounter errors with other apps whose 77 | migrations South tries to run. 78 | 79 | 4. Add the logging configuration. For example:: 80 | 81 | LOGGING = { 82 | 'version': 1, 83 | 'disable_existing_loggers': True, 84 | 'formatters': { 85 | 'default': { 86 | 'format': '[%(asctime)s %(name)s %(levelname)s] %(message)s' 87 | }, 88 | 'basic': { 89 | 'format': '[%(asctime)s %(uuid)s %(user_pk)s:%(username)s %(name)s %(levelname)s] %(message)s' 90 | }, 91 | 'meta': { 92 | 'format': '[%(asctime)s %(client_ip)s %(uuid)s %(user_pk)s:%(username)s %(name)s %(levelname)s] %(message)s' 93 | }, 94 | }, 95 | 'filters': { 96 | 'basic': { 97 | '()': 'peavy.filters.BasicFilter', 98 | }, 99 | 'meta': { 100 | '()': 'peavy.filters.MetaFilter', 101 | } 102 | }, 103 | 'handlers': { 104 | 'null': { 105 | 'level':'DEBUG', 106 | 'class':'django.utils.log.NullHandler', 107 | }, 108 | 'console': { 109 | 'level':'DEBUG', 110 | 'class':'logging.StreamHandler', 111 | 'filters': ['basic', 'meta'], 112 | 'formatter': 'basic' 113 | }, 114 | 'mail_admins': { 115 | 'level': 'ERROR', 116 | 'class': 'peavy.handlers.AdminEmailHandler', 117 | 'filters': ['basic', 'meta'], 118 | 'formatter': 'meta' 119 | }, 120 | 'peavy': { 121 | 'level': 'INFO', 122 | 'class': 'peavy.handlers.DjangoDBHandler', 123 | 'filters': ['basic', 'meta'], 124 | 'formatter': 'meta' 125 | } 126 | }, 127 | 'loggers': { 128 | 'django': { 129 | 'handlers': ['null'], 130 | 'propagate': True, 131 | 'level':'INFO', 132 | }, 133 | 'django.request': { 134 | 'handlers': ['peavy', 'mail_admins'], 135 | 'level': 'ERROR', 136 | 'propagate': False, 137 | }, 138 | 'myapp': { 139 | 'handlers': ['console', 'peavy'], 140 | 'level':'DEBUG', 141 | } 142 | } 143 | } 144 | 145 | 5. Add ``peavy.middleware.RequestLoggingMiddleware`` to MIDDLEWARE_CLASSES. 146 | 147 | 6. Add ``django.core.context_processors.request`` to TEMPLATE_CONTEXT_PROCESSORS. 148 | 149 | The last two steps can be skipped if you don't want the UI. 150 | 151 | 7. If desired, add ``peavy.urls`` to your URL configuration to get the UI:: 152 | 153 | urlpatterns += patterns('', 154 | (r'^peavy/', include('peavy.urls', namespace='peavy')), 155 | ) 156 | 157 | 8. Run ``manage.py collectstatic`` to copy peavy's media into place. 158 | 159 | Demo Application 160 | ---------------- 161 | 162 | Peavy comes with an example application that demonstrates how to log with it, 163 | and lets you check out the UI. To run it: 164 | 165 | 1. Create a virtualenv for it, then activate the virtualenv. 166 | 167 | 2. Copy the example application from your copy of django-peavy into the virtualenv:: 168 | 169 | $ rsync -av peavy_demo/ $VIRTUAL_ENV/peavy_demo/ 170 | 171 | 3. Install its requirements with pip:: 172 | 173 | $ pip install -r $VIRTUAL_ENV/peavy_demo/requirements.txt 174 | 175 | 4. Set up the PostgreSQL databases to match the Django settings (see step 2 176 | under Configuration, above). You can of course use another database, but it 177 | has to support concurrent transactions (so sqlite is out), and you'll have 178 | to adjust the settings and install the adapter yourself. 179 | 180 | 5. Adjust your PYTHONPATH to pick up the demo app:: 181 | 182 | $ export PYTHONPATH=$VIRTUAL_ENV:$PYTHONPATH 183 | 184 | 6. Set the DJANGO_SETTINGS_MODULE environment variable:: 185 | 186 | $ export DJANGO_SETTINGS_MODULE=peavy_demo.settings 187 | 188 | 7. Run the devserver:: 189 | 190 | $ django-admin.py runserver 191 | 192 | 8. Browse to http://localhost:8000/, enter a movie quote, then check the logging 193 | at http://localhost:8000/peavy/. 194 | 195 | Notes 196 | ----- 197 | 198 | Q. Why "peavy"? 199 | A. See http://en.wikipedia.org/wiki/Peavey_%28tool%29. It's a lumberjack tool, 200 | and it's OK. Oh, come on, it's *required*. 201 | 202 | Future 203 | ------ 204 | 205 | * support for logging to other sinks: message queues, non-relational databases. 206 | -------------------------------------------------------------------------------- /peavy/templates/peavy/dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends "peavy/base.html" %} 2 | {% load i18n humanize peavy %}{% load url from future %} 3 | 4 | {% block title %}{% trans "dashboard" %}{% endblock title %} 5 | 6 | {% block extra_head %} 7 | 8 | {% endblock extra_head %} 9 | 10 | {% block extra_nav %} 11 | 22 | {% endblock extra_nav %} 23 | 24 | {% block content %} 25 | {% pagenavigator records request.get_full_path %} 26 |
27 | {% if request.GET %} 28 |
29 |
Filters:
30 |
    31 | {% for key, values in request.GET.iterlists %} 32 | {% for value in values %} 33 |
  • X{{key}} = {{value}}
  • 34 | {% endfor %} 35 | {% endfor %} 36 |
37 |
38 | {% endif %} 39 |
40 | {% for record in records.object_list %} 41 |
42 |
{{record.timestamp|date:"Y-m-d"}} {{record.timestamp|date:"H:i:s"}}
43 |
44 |
{{record.message|linebreaksbr}}
45 |
46 | {% if record.stack_trace %} 47 |
{{record.stack_trace|linebreaksbr}}
48 | {% endif %} 49 |
50 | {{record.logger}} 53 |
54 |
55 | {{record.level}} 58 |
59 | 64 | 69 | 74 | 79 |
80 | {{record.uuid}} 83 |
84 | {% if record.debug_page and user.is_superuser %} 85 |
86 | View debug page. 87 |
88 | {% endif %} 89 |
90 |
91 |
92 |
93 | {% endfor %} 94 |
95 | {% endblock content %} 96 | 97 | {% block js_includes %} 98 | {{block.super}} 99 | 100 | 101 | {% endblock js_includes %} 102 | 103 | {% block js %} 104 | 173 | {% endblock js %} 174 | -------------------------------------------------------------------------------- /peavy/static/peavy/js/jquery.infinitescroll.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | // Infinite Scroll jQuery plugin 3 | // copyright Paul Irish, licensed GPL & MIT 4 | // version 2.0b1.110420 5 | 6 | // home and docs: http://www.infinite-scroll.com 7 | */ 8 | (function($){$.fn.infinitescroll=function infscr(options,callback){function areSelectorsValid(opts){var debug=$.fn.infinitescroll._debug;for(var key in opts){if(key.indexOf&&key.indexOf("Selector")>-1&&$(opts[key]).length===0){debug("Your "+key+" found no elements.");return false}return true}}function determinePath(path){if($.isFunction(opts.pathParse)){debug("pathParse");return[path]}else{if(path.match(/^(.*?)\b2\b(.*?$)/)){path=path.match(/^(.*?)\b2\b(.*?$)/).slice(1)}else{if(path.match(/^(.*?)2(.*?$)/)){if(path.match(/^(.*?page=)2(\/.*|$)/)){path=path.match(/^(.*?page=)2(\/.*|$)/).slice(1);return path}path=path.match(/^(.*?)2(.*?$)/).slice(1)}else{if(path.match(/^(.*?page=)1(\/.*|$)/)){path=path.match(/^(.*?page=)1(\/.*|$)/).slice(1);return path}else{debug("Sorry, we couldn't parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.");props.isInvalidPage=true}}}}debug("determinePath",path);return path}function hiddenHeight(element){var height=0;$(element).children().each(function(){height=height+$(this).outerHeight(false)});return height}function generateInstanceID(element){var number=$(element).length+$(element).html().length+$(element).attr("class").length+$(element).attr("id").length;opts.infid=number}if(typeof options=="string"){var command=options,argument=callback,validCommand=(command=="pause"||command=="destroy"||command=="retrieve"||command=="binding"),debug=$.fn.infinitescroll._debug;argument=argument||null;command=(validCommand)?$.fn.infinitescroll[command](argument):debug("Invalid command");return false}var opts=$.infinitescroll.opts=$.extend({},$.infinitescroll.defaults,options),props=$.infinitescroll,innerContainerHeight,box,frag,desturl,pause,error,errorStatus,method,result;callback=$.fn.infinitescroll._callback=callback||function(){},debug=$.fn.infinitescroll._debug,error=$.fn.infinitescroll._error,pause=$.fn.infinitescroll.pause,destroy=$.fn.infinitescroll.destroy,binding=$.fn.infinitescroll.binding;if(!areSelectorsValid(opts)){return false}opts.container=opts.container||document.documentElement;opts.contentSelector=opts.contentSelector||this;opts.infid=(opts.infid==0)?generateInstanceID(opts.contentSelector):opts.infid;opts.loadMsgSelector=opts.loadMsgSelector||opts.contentSelector;var relurl=/(.*?\/\/).*?(\/.*)/,path=$(opts.nextSelector).attr("href");if(!path){debug("Navigation selector not found");return}opts.path=determinePath(path);props.loadingMsg=$('
Loading...
'+opts.loadingText+"
");(new Image()).src=opts.loadingImg;opts.binder=(opts.container.nodeName=="HTML")?$(window):$(opts.container);innerContainerHeight=(opts.container.nodeName=="HTML")?$(document).height():innerContainerHeight=hiddenHeight(opts.container);debug("Scrolling in: ",(opts.container.nodeName=="HTML")?"window":opts.container);opts.pixelsFromNavToBottom=innerContainerHeight+(opts.container==document.documentElement?0:$(opts.container).offset().top)-$(opts.navSelector).offset().top;binding("bind");opts.binder.trigger("smartscroll.infscr."+opts.infid);return this};$.infinitescroll={defaults:{debug:false,binder:$(window),preload:false,nextSelector:"div.navigation a:first",loadingImg:"http://www.infinite-scroll.com/loading.gif",loadingText:"Loading the next set of posts...",donetext:"Congratulations, you've reached the end of the internet.",navSelector:"div.navigation",contentSelector:null,loadMsgSelector:null,loadingMsgRevealSpeed:"fast",extraScrollPx:150,itemSelector:"div.post",animate:false,pathParse:undefined,dataType:"html",appendCallback:true,bufferPx:40,orientation:"height",errorCallback:function(){},currPage:1,infid:0,isDuringAjax:false,isInvalidPage:false,isDestroyed:false,isDone:false,isPaused:false,container:undefined,pixelsFromNavToBottom:undefined,path:undefined},loadingImg:undefined,loadingMsg:undefined,currDOMChunk:null};$.fn.infinitescroll._debug=function infscr_debug(){if($.infinitescroll.opts.debug){return window.console&&console.log.call(console,arguments)}};$.fn.infinitescroll._shorthand=function infscr_shorthand(){};$.fn.infinitescroll._nearbottom=function infscr_nearbottom(){var opts=$.infinitescroll.opts,debug=$.fn.infinitescroll._debug,hiddenHeight=$.fn.infinitescroll._hiddenheight;if(opts.container.nodeName=="HTML"){var pixelsFromWindowBottomToBottom=0+$(document).height()-($(opts.container).scrollTop()||$(opts.container.ownerDocument.body).scrollTop())-$(window).height()}else{var pixelsFromWindowBottomToBottom=0+hiddenHeight(opts.container)-$(opts.container).scrollTop()-$(opts.container).height()}debug("math:",pixelsFromWindowBottomToBottom,opts.pixelsFromNavToBottom);return(pixelsFromWindowBottomToBottom-opts.bufferPx"):$("
");desturl=($.isFunction(opts.pathParse))?opts.pathParse(path.join("2"),opts.currPage):desturl=path.join(opts.currPage);method=(opts.dataType=="html"||opts.dataType=="json")?opts.dataType:"html+callback";if(opts.appendCallback&&opts.dataType=="html"){method+="+callback"}switch(method){case"html+callback":debug("Using HTML via .load() method");box.load(desturl+" "+opts.itemSelector,null,function(jqXHR,textStatus){loadCallback(box,jqXHR.responseText)});break;case"html":case"json":debug("Using "+(method.toUpperCase())+" via $.ajax() method");$.ajax({url:desturl,dataType:opts.dataType,complete:function _infscrAjax(jqXHR,textStatus){condition=(typeof(jqXHR.isResolved)!=="undefined")?(jqXHR.isResolved()):(textStatus==="success"||textStatus==="notmodified");(condition)?loadCallback(box,jqXHR.responseText):error([404])}});break}})};$.fn.infinitescroll._loadcallback=function infscr_loadcallback(box,data){var props=$.infinitescroll,opts=$.infinitescroll.opts,error=$.fn.infinitescroll._error,showDoneMsg=$.fn.infinitescroll._donemsg,callback=$.fn.infinitescroll._callback,result,frag;result=(opts.isDone)?"done":(!opts.appendCallback)?"no-append":"append";switch(result){case"done":showDoneMsg();return false;break;case"no-append":if(opts.dataType=="html"){data="
"+data+"
";data=$(data).find(opts.itemSelector)}break;case"append":var children=box.children();if(children.length==0||children.hasClass("error404")){return error([404])}frag=document.createDocumentFragment();while(box[0].firstChild){frag.appendChild(box[0].firstChild)}$(opts.contentSelector)[0].appendChild(frag);data=children.get();break}props.loadingMsg.fadeOut("normal");if(opts.animate){var scrollTo=$(window).scrollTop()+$("#infscr-loading").height()+opts.extraScrollPx+"px";$("html,body").animate({scrollTop:scrollTo},800,function(){opts.isDuringAjax=false})}if(!opts.animate){opts.isDuringAjax=false}callback.call($(opts.contentSelector)[0],data)};$.fn.infinitescroll._donemsg=function infscr_donemsg(){var props=$.infinitescroll,opts=$.infinitescroll.opts;props.loadingMsg.find("img").hide().parent().find("div").html(opts.donetext).animate({opacity:1},2000,function(){$(this).parent().fadeOut("normal")});opts.errorCallback()};$.fn.infinitescroll.pause=function infscr_pause(pause){var debug=$.fn.infinitescroll._debug,opts=$.infinitescroll.opts;if(pause!=="pause"&&pause!=="resume"&&pause!=="toggle"&&pause!==null){debug("Invalid argument. Toggling pause value instead")}pause=(pause&&(pause=="pause"||pause=="resume"))?pause:"toggle";switch(pause){case"pause":opts.isPaused=true;break;case"resume":opts.isPaused=false;break;case"toggle":opts.isPaused=!opts.isPaused;break}debug("Paused",opts.isPaused);return false};$.fn.infinitescroll._error=function infscr_error(xhr){var opts=$.infinitescroll.opts,binder=(opts.container.nodeName=="HTML")?$(window):$(opts.container),debug=$.fn.infinitescroll._debug,showDoneMsg=$.fn.infinitescroll._donemsg,error=(!opts.isDone&&xhr==404)?"end":(opts.isDestroyed&&xhr==302)?"destroy":"unknown";switch(error){case"end":debug("Page not found. Self-destructing...");showDoneMsg();opts.isDone=true;opts.currPage=1;opts.isPaused=false;binder.unbind("smartscroll.infscr."+opts.infid);break;case"destroy":debug("Destroyed. Going to next instance...");opts.isDone=true;opts.currPage=1;opts.isPaused=false;binder.unbind("smartscroll.infscr."+opts.infid);break;case"unknown":debug("Unknown Error. WHAT DID YOU DO?!...");showDoneMsg();opts.isDone=true;opts.currPage=1;binder.unbind("smartscroll.infscr."+opts.infid);break}};$.fn.infinitescroll.destroy=function infscr_destroy(){var opts=$.infinitescroll.opts,error=$.fn.infinitescroll._error;opts.isDestroyed=true;return error([302])};$.fn.infinitescroll.binding=function infscr_binding(binding){var opts=$.infinitescroll.opts,setup=$.fn.infinitescroll._setup,error=$.fn.infinitescroll._error,debug=$.fn.infinitescroll._debug;switch(binding){case"bind":opts.binder.bind("smartscroll.infscr."+opts.infid,setup);break;case"unbind":opts.binder.unbind("smartscroll.infscr."+opts.infid);break}debug("Binding",binding);return false};var event=$.event,scrollTimeout;event.special.smartscroll={setup:function(){$(this).bind("scroll",event.special.smartscroll.handler)},teardown:function(){$(this).unbind("scroll",event.special.smartscroll.handler)},handler:function(event,execAsap){var context=this,args=arguments;event.type="smartscroll";if(scrollTimeout){clearTimeout(scrollTimeout)}scrollTimeout=setTimeout(function(){jQuery.event.handle.apply(context,args)},execAsap==="execAsap"?0:100)}};$.fn.smartscroll=function(fn){return fn?this.bind("smartscroll",fn):this.trigger("smartscroll",["execAsap"])}})(jQuery); -------------------------------------------------------------------------------- /peavy/static/peavy/js/jquery-1.5.1.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery JavaScript Library v1.5.1 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: Wed Feb 23 13:55:29 2011 -0500 15 | */ 16 | (function(a,b){function cg(a){return d.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cd(a){if(!bZ[a]){var b=d("<"+a+">").appendTo("body"),c=b.css("display");b.remove();if(c==="none"||c==="")c="block";bZ[a]=c}return bZ[a]}function cc(a,b){var c={};d.each(cb.concat.apply([],cb.slice(0,b)),function(){c[this]=a});return c}function bY(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function bX(){try{return new a.XMLHttpRequest}catch(b){}}function bW(){d(a).unload(function(){for(var a in bU)bU[a](0,1)})}function bQ(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var e=a.dataTypes,f={},g,h,i=e.length,j,k=e[0],l,m,n,o,p;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(r,"`").replace(s,"&")}function E(a){var b,c,e,f,g,h,i,j,k,l,m,n,o,q=[],r=[],s=d._data(this,"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,o=f.handleObj.origHandler.apply(f.elem,arguments);if(o===!1||a.isPropagationStopped()){c=f.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function C(a,c,e){var f=d.extend({},e[0]);f.type=a,f.originalEvent={},f.liveFired=b,d.event.handle.call(c,f),f.isDefaultPrevented()&&e[0].preventDefault()}function w(){return!0}function v(){return!1}function g(a){for(var b in a)if(b!=="toJSON")return!1;return!0}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.1",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.head||c.getElementsByTagName("head")[0]||c.documentElement,e=c.createElement("script");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){var f=E.call(arguments,0),g=b,h=function(a){return function(b){f[a]=arguments.length>1?E.call(arguments,0):b,--g||c.resolveWith(e,f)}};while(b--)a=f[b],a&&d.isFunction(a.promise)?a.promise().then(h(b),c.reject):--g;g||c.resolveWith(e,f)}else c!==a&&c.resolve(a);return e},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 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")),i=b.getElementsByTagName("input")[0];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:i.value==="on",optSelected:h.selected,deleteExpando:!0,optDisabled:!1,checkClone:!1,noCloneEvent:!0,noCloneChecked:!0,boxModel:null,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableHiddenOffsets:!0},i.checked=!0,d.support.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,d.support.optDisabled=!h.disabled;var j=null;d.support.scriptEval=function(){if(j===null){var b=c.documentElement,e=c.createElement("script"),f="script"+d.now();try{e.appendChild(c.createTextNode("window."+f+"=1;"))}catch(g){}b.insertBefore(e,b.firstChild),a[f]?(j=!0,delete a[f]):j=!1,b.removeChild(e),b=e=f=null}return j};try{delete b.test}catch(k){d.support.deleteExpando=!1}!b.addEventListener&&b.attachEvent&&b.fireEvent&&(b.attachEvent("onclick",function l(){d.support.noCloneEvent=!1,b.detachEvent("onclick",l)}),b.cloneNode(!0).fireEvent("onclick")),b=c.createElement("div"),b.innerHTML="";var m=c.createDocumentFragment();m.appendChild(b.firstChild),d.support.checkClone=m.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 n=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=n("submit"),d.support.changeBubbles=n("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&&!g(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]={},j||(k[l].toJSON=d.noop));if(typeof c==="object"||typeof c==="function")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,h=b.nodeType,i=h?d.cache:b,j=h?b[d.expando]:d.expando;if(!i[j])return;if(c){var k=e?i[j][f]:i[j];if(k){delete k[c];if(!g(k))return}}if(e){delete i[j][f];if(!g(i[j]))return}var l=i[j][f];d.support.deleteExpando||i!=a?delete i[j]:i[j]=null,l?(i[j]={},h||(i[j].toJSON=d.noop),i[j][f]=l):h&&(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,i=c.type==="select-one";if(f<0)return null;for(var k=i?f:0,l=i?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=k.test(c);if(c==="selected"&&!d.support.optSelected){var j=a.parentNode;j&&(j.selectedIndex,j.parentNode&&j.parentNode.selectedIndex)}if((c in a||a[c]!==b)&&g&&!i){h&&(c==="type"&&l.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:m.test(a.nodeName)||n.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 p=/\.(.*)$/,q=/^(?:textarea|input|select)$/i,r=/\./g,s=/ /g,t=/[^\w\s.|`]/g,u=function(a){return a.replace(t,"\\$&")};d.event={add:function(c,e,f,g){if(c.nodeType!==3&&c.nodeType!==8){try{d.isWindow(c)&&(c!==a&&!c.frameElement)&&(c=a)}catch(h){}if(f===!1)f=v;else if(!f)return;var i,j;f.handler&&(i=f,f=i.handler),f.guid||(f.guid=d.guid++);var k=d._data(c);if(!k)return;var l=k.events,m=k.handle;l||(k.events=l={}),m||(k.handle=m=function(){return typeof d!=="undefined"&&!d.event.triggered?d.event.handle.apply(m.elem,arguments):b}),m.elem=c,e=e.split(" ");var n,o=0,p;while(n=e[o++]){j=i?d.extend({},i):{handler:f,data:g},n.indexOf(".")>-1?(p=n.split("."),n=p.shift(),j.namespace=p.slice(0).sort().join(".")):(p=[],j.namespace=""),j.type=n,j.guid||(j.guid=f.guid);var q=l[n],r=d.event.special[n]||{};if(!q){q=l[n]=[];if(!r.setup||r.setup.call(c,g,p,m)===!1)c.addEventListener?c.addEventListener(n,m,!1):c.attachEvent&&c.attachEvent("on"+n,m)}r.add&&(r.add.call(c,j),j.handler.guid||(j.handler.guid=f.guid)),q.push(j),d.event.global[n]=!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),t=s&&s.events;if(!s||!t)return;c&&c.type&&(e=c.handler,c=c.type);if(!c||typeof c==="string"&&c.charAt(0)==="."){c=c||"";for(h in t)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(),u).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[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=d._data(e,"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(p,""),n=d.nodeName(l,"a")&&m==="click",o=d.event.special[m]||{};if((!o._default||o._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,"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(q.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,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;(c==="radio"||c==="checkbox"||b.nodeName.toLowerCase()==="select")&&B.call(this,a)},keydown:function(a){var b=a.target,c=b.type;(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&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 q.test(this.nodeName)},teardown:function(a){d.event.remove(this,".specialChange");return q.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 u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(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,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=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 i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(f.call(n)==="[object Array]")if(u)if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&e.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&e.push(j[t]);else e.push.apply(e,n);else p(n,e);o&&(k(o,h,e,g),k.uniqueSort(e));return e};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b==="string",e=0,f=a.length;if(d&&!j.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(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.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]&&k.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),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]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.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&&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!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){return"text"===a.getAttribute("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=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=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=l.attrHandle[c]?l.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=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=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(q){p=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)&&(l.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:[]}},l.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&&(l.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")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[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&&(k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(d||!l.match.PSEUDO.test(c)&&!/!=/.test(c))return b.call(a,c)}catch(e){}return k(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;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!=="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.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?!1: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||!d.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!d.isXMLDoc(a)){$(a,e),f=_(a),g=_(e);for(h=0;f[h];++h)$(f[h],g[h])}if(b){Z(a,e);if(c){f=_(a),g=_(e);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 bb=/alpha\([^)]*\)/i,bc=/opacity=([^)]*)/,bd=/-([a-z])/ig,be=/([A-Z])/g,bf=/^-?\d+(?:px)?$/i,bg=/^-?\d/,bh={position:"absolute",visibility:"hidden",display:"block"},bi=["Left","Right"],bj=["Top","Bottom"],bk,bl,bm,bn=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=bk(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(bk)return bk(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(bd,bn)}}),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=bo(a,b,e):d.swap(a,bh,function(){f=bo(a,b,e)});if(f<=0){f=bk(a,b,b),f==="0px"&&bm&&(f=bm(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(!bf.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),d.support.opacity||(d.cssHooks.opacity={get:function(a,b){return bc.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=bb.test(f)?f.replace(bb,e):c.filter+" "+e}}),c.defaultView&&c.defaultView.getComputedStyle&&(bl=function(a,c,e){var f,g,h;e=e.replace(be,"-$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&&(bm=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bf.test(d)&&bg.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}),bk=bl||bm,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 bp=/%20/g,bq=/\[\]$/,br=/\r?\n/g,bs=/#.*$/,bt=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bu=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bv=/(?:^file|^widget|\-extension):$/,bw=/^(?:GET|HEAD)$/,bx=/^\/\//,by=/\?/,bz=/)<[^<]*)*<\/script>/gi,bA=/^(?:select|textarea)/i,bB=/\s+/,bC=/([?&])_=[^&]*/,bD=/(^|\-)([a-z])/g,bE=function(a,b,c){return b+c.toUpperCase()},bF=/^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,bG=d.fn.load,bH={},bI={},bJ,bK;try{bJ=c.location.href}catch(bL){bJ=c.createElement("a"),bJ.href="",bJ=bJ.href}bK=bF.exec(bJ.toLowerCase()),d.fn.extend({load:function(a,c,e){if(typeof a!=="string"&&bG)return bG.apply(this,arguments);if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var g=a.slice(f,a.length);a=a.slice(0,f)}var h="GET";c&&(d.isFunction(c)?(e=c,c=b):typeof c==="object"&&(c=d.param(c,d.ajaxSettings.traditional),h="POST"));var i=this;d.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?d("
").append(c.replace(bz,"")).find(g):c)),e&&i.each(e,[c,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||bA.test(this.nodeName)||bu.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(br,"\r\n")}}):{name:b.name,value:c.replace(br,"\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,c){d[c]=function(a,e,f,g){d.isFunction(e)&&(g=g||f,f=e,e=b);return d.ajax({type:c,url:a,data:e,success:f,dataType:g})}}),d.extend({getScript:function(a,c){return d.get(a,b,c,"script")},getJSON:function(a,b,c){return d.get(a,b,c,"json")},ajaxSetup:function(a,b){b?d.extend(!0,a,d.ajaxSettings,b):(b=a,a=d.extend(!0,d.ajaxSettings,b));for(var c in {context:1,url:1})c in b?a[c]=b[c]:c in d.ajaxSettings&&(a[c]=d.ajaxSettings[c]);return a},ajaxSettings:{url:bJ,isLocal:bv.test(bK[1]),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:bM(bH),ajaxTransport:bM(bI),ajax:function(a,c){function v(a,c,l,n){if(r!==2){r=2,p&&clearTimeout(p),o=b,m=n||"",u.readyState=a?4:0;var q,t,v,w=l?bP(e,u,l):b,x,y;if(a>=200&&a<300||a===304){if(e.ifModified){if(x=u.getResponseHeader("Last-Modified"))d.lastModified[k]=x;if(y=u.getResponseHeader("Etag"))d.etag[k]=y}if(a===304)c="notmodified",q=!0;else try{t=bQ(e,w),c="success",q=!0}catch(z){c="parsererror",v=z}}else{v=c;if(!c||a)c="error",a<0&&(a=0)}u.status=a,u.statusText=c,q?h.resolveWith(f,[t,c,u]):h.rejectWith(f,[u,c,v]),u.statusCode(j),j=b,s&&g.trigger("ajax"+(q?"Success":"Error"),[u,e,q?t:v]),i.resolveWith(f,[u,c]),s&&(g.trigger("ajaxComplete",[u,e]),--d.active||d.event.trigger("ajaxStop"))}}typeof a==="object"&&(c=a,a=b),c=c||{};var e=d.ajaxSetup({},c),f=e.context||e,g=f!==e&&(f.nodeType||f instanceof d)?d(f):d.event,h=d.Deferred(),i=d._Deferred(),j=e.statusCode||{},k,l={},m,n,o,p,q,r=0,s,t,u={readyState:0,setRequestHeader:function(a,b){r||(l[a.toLowerCase().replace(bD,bE)]=b);return this},getAllResponseHeaders:function(){return r===2?m:null},getResponseHeader:function(a){var c;if(r===2){if(!n){n={};while(c=bt.exec(m))n[c[1].toLowerCase()]=c[2]}c=n[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){r||(e.mimeType=a);return this},abort:function(a){a=a||"abort",o&&o.abort(a),v(0,a);return this}};h.promise(u),u.success=u.done,u.error=u.fail,u.complete=i.done,u.statusCode=function(a){if(a){var b;if(r<2)for(b in a)j[b]=[j[b],a[b]];else b=a[u.status],u.then(b,b)}return this},e.url=((a||e.url)+"").replace(bs,"").replace(bx,bK[1]+"//"),e.dataTypes=d.trim(e.dataType||"*").toLowerCase().split(bB),e.crossDomain||(q=bF.exec(e.url.toLowerCase()),e.crossDomain=q&&(q[1]!=bK[1]||q[2]!=bK[2]||(q[3]||(q[1]==="http:"?80:443))!=(bK[3]||(bK[1]==="http:"?80:443)))),e.data&&e.processData&&typeof e.data!=="string"&&(e.data=d.param(e.data,e.traditional)),bN(bH,e,c,u);if(r===2)return!1;s=e.global,e.type=e.type.toUpperCase(),e.hasContent=!bw.test(e.type),s&&d.active++===0&&d.event.trigger("ajaxStart");if(!e.hasContent){e.data&&(e.url+=(by.test(e.url)?"&":"?")+e.data),k=e.url;if(e.cache===!1){var w=d.now(),x=e.url.replace(bC,"$1_="+w);e.url=x+(x===e.url?(by.test(e.url)?"&":"?")+"_="+w:"")}}if(e.data&&e.hasContent&&e.contentType!==!1||c.contentType)l["Content-Type"]=e.contentType;e.ifModified&&(k=k||e.url,d.lastModified[k]&&(l["If-Modified-Since"]=d.lastModified[k]),d.etag[k]&&(l["If-None-Match"]=d.etag[k])),l.Accept=e.dataTypes[0]&&e.accepts[e.dataTypes[0]]?e.accepts[e.dataTypes[0]]+(e.dataTypes[0]!=="*"?", */*; q=0.01":""):e.accepts["*"];for(t in e.headers)u.setRequestHeader(t,e.headers[t]);if(e.beforeSend&&(e.beforeSend.call(f,u,e)===!1||r===2)){u.abort();return!1}for(t in {success:1,error:1,complete:1})u[t](e[t]);o=bN(bI,e,c,u);if(o){u.readyState=1,s&&g.trigger("ajaxSend",[u,e]),e.async&&e.timeout>0&&(p=setTimeout(function(){u.abort("timeout")},e.timeout));try{r=1,o.send(l,v)}catch(y){status<2?v(-1,y):d.error(y)}}else v(-1,"No Transport");return u},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.isPlainObject(a))d.each(a,function(){f(this.name,this.value)});else for(var g in a)bO(g,a[g],c,f);return e.join("&").replace(bp,"+")}}),d.extend({active:0,lastModified:{},etag:{}});var bR=d.now(),bS=/(\=)\?(&|$)|()\?\?()/i;d.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return d.expando+"_"+bR++}}),d.ajaxPrefilter("json jsonp",function(b,c,e){var f=typeof b.data==="string";if(b.dataTypes[0]==="jsonp"||c.jsonpCallback||c.jsonp!=null||b.jsonp!==!1&&(bS.test(b.url)||f&&bS.test(b.data))){var g,h=b.jsonpCallback=d.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2",m=function(){a[h]=i,g&&d.isFunction(i)&&a[h](g[0])};b.jsonp!==!1&&(j=j.replace(bS,l),b.url===j&&(f&&(k=k.replace(bS,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},e.then(m,m),b.converters["script json"]=function(){g||d.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),d.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},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.head||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 bT=d.now(),bU,bV;d.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&bX()||bY()}:bX,bV=d.ajaxSettings.xhr(),d.support.ajax=!!bV,d.support.cors=bV&&"withCredentials"in bV,bV=b,d.support.ajax&&d.ajaxTransport(function(a){if(!a.crossDomain||d.support.cors){var c;return{send:function(e,f){var g=a.xhr(),h,i;a.username?g.open(a.type,a.url,a.async,a.username,a.password):g.open(a.type,a.url,a.async);if(a.xhrFields)for(i in a.xhrFields)g[i]=a.xhrFields[i];a.mimeType&&g.overrideMimeType&&g.overrideMimeType(a.mimeType),(!a.crossDomain||a.hasContent)&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(i in e)g.setRequestHeader(i,e[i])}catch(j){}g.send(a.hasContent&&a.data||null),c=function(e,i){var j,k,l,m,n;try{if(c&&(i||g.readyState===4)){c=b,h&&(g.onreadystatechange=d.noop,delete bU[h]);if(i)g.readyState!==4&&g.abort();else{j=g.status,l=g.getAllResponseHeaders(),m={},n=g.responseXML,n&&n.documentElement&&(m.xml=n),m.text=g.responseText;try{k=g.statusText}catch(o){k=""}j||!a.isLocal||a.crossDomain?j===1223&&(j=204):j=m.text?200:404}}}catch(p){i||f(-1,p)}m&&f(j,k,m,l)},a.async&&g.readyState!==4?(bU||(bU={},bW()),h=bT++,g.onreadystatechange=bU[h]=c):c()},abort:function(){c&&c(0,1)}}}});var bZ={},b$=/^(?:toggle|show|hide)$/,b_=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,ca,cb=[["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(cc("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:cc("show",1),slideUp:cc("hide",1),slideToggle:cc("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,b=d.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},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||(d.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,g.elem=this.elem,g()&&d.timers.push(g)&&!ca&&(ca=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=cf.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&&(!cf.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=cg(this),g?g.scrollTo(a?d(g).scrollLeft():c,a?c:d(g).scrollTop()):this[e]=c});g=cg(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")}}),a.jQuery=a.$=d})(window); --------------------------------------------------------------------------------