diff --git a/README.md b/README.md index 117e70a..3b74f75 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Mozilla’s Sync Server for Yunohost -The Sync Server provides a replacement for Firefox’s default server (hosted at Mozilla). Its code is available on [the Sync-1.5 Server documentation](https://docs.services.mozilla.com/howtos/run-sync-1.5.html). +The Sync Server provides a replacement for Firefox’s default server (hosted at Mozilla). Its code is available on [the Sync-1.5 Server documentation](https://docs.services.mozilla.com/howtos/run-sync-1.5.html) (no official documentation yet for the 1.6.x as it is really the bleeding edge version). By default, a server set up will defer authentication to the Mozilla-hosted accounts server at [https://accounts.firefox.com](https://accounts.firefox.com). So you will still have to authenticate at Mozilla, but _the storage of your information will be done on your host_. -**Shipped version:** 1.5 +**Shipped version:** 1.6.2 ## Configuring diff --git a/patch/sources/requirements.txt b/patch/sources/requirements.txt new file mode 100644 index 0000000..ba2d46b --- /dev/null +++ b/patch/sources/requirements.txt @@ -0,0 +1,14 @@ +pyramid_chameleon==0.3 +cornice==0.16.2 +gunicorn==19.6 +pyramid==1.5 +WebOb==1.4.1 +requests==2.13 +simplejson==3.10 +SQLAlchemy==1.1.5 +unittest2==1.1 +zope.component==4.2.1 +configparser==3.5 +mozsvc==0.9 +https://github.com/mozilla-services/tokenserver/archive/1.2.23.zip +https://github.com/mozilla-services/server-syncstorage/archive/1.6.2.zip diff --git a/patch/sources/syncserver/__init__.py b/patch/sources/syncserver/__init__.py new file mode 100644 index 0000000..dc44b48 --- /dev/null +++ b/patch/sources/syncserver/__init__.py @@ -0,0 +1,193 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this file, +# You can obtain one at http://mozilla.org/MPL/2.0/. + +import os +import logging +from urlparse import urlparse, urlunparse + +from pyramid.events import NewRequest, subscriber +from pyramid.static import static_view +from pyramid.view import view_config +from pyramid.renderers import render, render_to_response +from pyramid.response import Response + +try: + import requests.packages.urllib3.contrib.pyopenssl + HAS_PYOPENSSL = True +except ImportError: + HAS_PYOPENSSL = False + +import mozsvc.config + +from tokenserver.util import _JSONError + +logger = logging.getLogger("syncserver") + + +def includeme(config): + """Install SyncServer application into the given Pyramid configurator.""" + # Set the umask so that files are created with secure permissions. + # Necessary for e.g. created-on-demand sqlite database files. + os.umask(0077) + + # If PyOpenSSL is available, configure requests to use it. + # This helps improve security on older python versions. + if HAS_PYOPENSSL: + requests.packages.urllib3.contrib.pyopenssl.inject_into_urllib3() + + # Sanity-check the deployment settings and provide sensible defaults. + settings = config.registry.settings + public_url = settings.get("syncserver.public_url") + if public_url is None: + raise RuntimeError("you must configure syncserver.public_url") + public_url = public_url.rstrip("/") + settings["syncserver.public_url"] = public_url + + secret = settings.get("syncserver.secret") + if secret is None: + secret = os.urandom(32).encode("hex") + sqluri = settings.get("syncserver.sqluri") + if sqluri is None: + rootdir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) + sqluri = "sqlite:///" + os.path.join(rootdir, "syncserver.db") + + # Configure app-specific defaults based on top-level configuration. + settings.pop("config", None) + if "tokenserver.backend" not in settings: + # Default to our simple static node-assignment backend + settings["tokenserver.backend"] =\ + "syncserver.staticnode.StaticNodeAssignment" + settings["tokenserver.sqluri"] = sqluri + settings["tokenserver.node_url"] = public_url + settings["endpoints.sync-1.5"] = "{node}/storage/1.5/{uid}" + if "tokenserver.monkey_patch_gevent" not in settings: + # Default to no gevent monkey-patching + settings["tokenserver.monkey_patch_gevent"] = False + if "tokenserver.applications" not in settings: + # Default to just the sync-1.5 application + settings["tokenserver.applications"] = "sync-1.5" + if "tokenserver.secrets.backend" not in settings: + # Default to a single fixed signing secret + settings["tokenserver.secrets.backend"] = "mozsvc.secrets.FixedSecrets" + settings["tokenserver.secrets.secrets"] = [secret] + if "tokenserver.allow_new_users" not in settings: + allow_new_users = settings.get("syncserver.allow_new_users") + if allow_new_users is not None: + settings["tokenserver.allow_new_users"] = allow_new_users + if "hawkauth.secrets.backend" not in settings: + # Default to the same secrets backend as the tokenserver + for key in settings.keys(): + if key.startswith("tokenserver.secrets."): + newkey = "hawkauth" + key[len("tokenserver"):] + settings[newkey] = settings[key] + if "storage.backend" not in settings: + # Default to sql syncstorage backend + settings["storage.backend"] = "syncstorage.storage.sql.SQLStorage" + settings["storage.sqluri"] = sqluri + settings["storage.create_tables"] = True + if "storage.batch_upload_enabled" not in settings: + # Default the new batch-upload API to on + settings["storage.batch_upload_enabled"] = True + if "browserid.backend" not in settings: + # Default to remote verifier, with base of public_url as only audience + audience = urlunparse(urlparse(public_url)._replace(path="")) + settings["browserid.backend"] = "tokenserver.verifiers.RemoteVerifier" + settings["browserid.audiences"] = audience + if "loggers" not in settings: + # Default to basic logging config. + root_logger = logging.getLogger("") + if not root_logger.handlers: + logging.basicConfig(level=logging.WARN) + if "fxa.metrics_uid_secret_key" not in settings: + # Default to a randomly-generated secret. + # This setting isn't useful in a self-hosted setup + # and setting a default avoids scary-sounding warnings. + settings["fxa.metrics_uid_secret_key"] = os.urandom(16).encode("hex") + + # Include the relevant sub-packages. + config.scan("syncserver") + config.include("syncstorage", route_prefix="/storage") + config.include("tokenserver", route_prefix="/token") + config.include('pyramid_chameleon') + + # Add a top-level explaination view. + # First view, available at http://localhost:6543/ + def page(request): + result = render('page/index.pt', + {'public_url':public_url}, + request=request) + response = Response(result) + return response + config.add_route('page', '/') + config.add_view(page, route_name='page') + + www = static_view( + os.path.realpath(os.path.dirname(__file__)+"/page/"), + use_subpath=True + ) + # Documentation for Hybrid routing can be found here + # http://docs.pylonsproject.org/projects/pyramid/en/1.0-branch/narr/hybrid.html#using-subpath-in-a-route-pattern + config.add_route('index', '/*subpath', 'www') # subpath is a reserved word + config.add_view(www, route_name='index') + + +@subscriber(NewRequest) +def reconcile_wsgi_environ_with_public_url(event): + """Event-listener that checks and tweaks WSGI environ based on public_url. + + This is a simple trick to help ensure that the configured public_url + matches the actual deployed address. It fixes fixes parts of the WSGI + environ where it makes sense (e.g. SCRIPT_NAME) and warns about any parts + that seem obviously mis-configured (e.g. http:// versus https://). + + It's very important to get public_url and WSGI environ matching exactly, + since they're used for browserid audience checking and HAWK signature + validation, so mismatches can easily cause strange and cryptic errors. + """ + request = event.request + public_url = request.registry.settings["syncserver.public_url"] + p_public_url = urlparse(public_url) + # If we don't have a SCRIPT_NAME, take it from the public_url. + # This is often the case if we're behind e.g. an nginx proxy that + # is serving us at some sub-path. + if not request.script_name: + request.script_name = p_public_url.path.rstrip("/") + # If the environ does not match public_url, requests are almost certainly + # going to fail due to auth errors. We can either bail out early, or we + # can forcibly clobber the WSGI environ with the values from public_url. + # This is a security risk if you've e.g. mis-configured the server, so + # it's not enabled by default. + application_url = request.application_url + if public_url != application_url: + if not request.registry.settings.get("syncserver.force_wsgi_environ"): + msg = "\n".join(( + "The public_url setting doesn't match the application url.", + "This will almost certainly cause authentication failures!", + " public_url setting is: %s" % (public_url,), + " application url is: %s" % (application_url,), + "You can disable this check by setting the force_wsgi_environ", + "option in your config file, but do so at your own risk.", + )) + logger.error(msg) + raise _JSONError([msg], status_code=500) + request.scheme = p_public_url.scheme + request.host = p_public_url.netloc + request.script_name = p_public_url.path.rstrip("/") + + +def get_configurator(global_config, **settings): + """Load a SyncStorge configurator object from deployment settings.""" + config = mozsvc.config.get_configurator(global_config, **settings) + config.begin() + try: + config.include(includeme) + finally: + config.end() + return config + + +def main(global_config, **settings): + """Load a SyncStorage WSGI app from deployment settings.""" + config = get_configurator(global_config, **settings) + return config.make_wsgi_app() diff --git a/patch/sources/syncserver/page/index.pt b/patch/sources/syncserver/page/index.pt new file mode 100644 index 0000000..8a91299 --- /dev/null +++ b/patch/sources/syncserver/page/index.pt @@ -0,0 +1,663 @@ + + + + + + + + + + + + + + Firefox Sync Server — Keep Synced on your own + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + +
+
+ + +
+ +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+
+
+ + +
+
+
+ + +
+

+ It looks like you’re running an older version of Firefox. +

+
+ +
+

+ The new version of Sync only works with the latest version of Firefox +

+
+ +
+

+ + Sync is just one of the great features you’ll only get with Firefox. + +

+
+ + + +
+ + +
+ + + +
+ + + +
+ + + +
+ +
+ +
+

+ + Download Firefox + — English (US) +

+ +
+ +
+ + +
+

Your system may not meet the requirements for Firefox, but you can try one of these versions:

+ +
+

+ + Download Firefox + — English (US) +

+ +
+ +
+

+ Your system doesn't meet the requirements to run Firefox. +

+

+ Your system doesn't meet the requirements to run Firefox. +

+

+ Please follow these instructions to install Firefox. +

+ + + + Firefox Privacy + +
+
+
+ + + +
+

Get started with Sync in four easy steps:

+
+
    +
  1. Open the menu in the top right of Firefox and select “Sign in to Sync.
  2. + +
  3. Click “Get started” in the tab that opens.
  4. +
  5. Enter an email address and password to “Create a Firefox Account.
  6. +
  7. Click “Next” to get a verification sent to your email.
  8. +
+

After you check your email and click the verification link, you’ll be all set! Firefox will automatically sync in the background from then on.

+
+ +
+ + + + +
+

How to set up Sync in five easy steps:

+
+
    + +
  1. Tap the Menu button (either below the screen or at the top right corner of the browser).
  2. +
  3. Select Settings (you may need to tap More first).
  4. +
  5. Tap Sync and then Get Started.
  6. +
  7. The Create a Firefox Account page will open in a new tab.
  8. +
  9. Fill out the form and click Next.
  10. +
+

After you check your email and click the verification link, you’ll be ready to go! Don’t forget to connect all your other devices to get the most of Sync.

+
+ +
+ +
+
+
+ + + +
+
+
+
+

How to sync your Firefox with this server instead of Mozilla’s?

+

+ You can safely use the Mozilla-hosted Firefox Accounts server in combination with a self-hosted sync storage server. The authentication and encryption protocols are designed so that the account server does not know the user’s plaintext password, and therefore cannot access their stored sync data. +

+ Alternatively, you can also Run your own Firefox Accounts Server to control all aspects of the system. The process for doing so is currently very experimental and not well documented. +

+

+ To configure Firefox to talk to your new Sync server, go to "about:config", + search for "identity.sync.tokenserver.uri" and change its value to the URL of your server + with a path of "token/1.0/sync/1.5": +

+
+ identity.sync.tokenserver.uri: ${public_url}/token/1.0/sync/1.5 + +

+ Since Firefox 33, Firefox for Android has supported custom sync servers, + should be a breeze. +

+

Solving problems with Android

+

The sure-fire way to know what Sync on Android is really doing is to + observe the Android device log using adb logcat. You’ll want to bump + your log-level: +


+ adb shell setprop log.tag.FxAccounts VERBOSE +
+

+ Then, you can observe the log using: +

+
+ adb logcat | grep FxAccounts +
+

+ It’s best to observe the log while you force a sync from the Android Settings App. You should see output like: +

+
+D FxAccounts(...) fennec :: BaseResource :: HTTP GET https://token.stage.mozaws.net/1.0/sync/1.5
+...
+D FxAccounts(...) fennec :: BaseResource :: HTTP GET https://sync-4-us-east-1.stage.mozaws.net/

+See how to file a good Android Sync bug for details. + +

+
+ +
+
+
+ +
+
+
+
+

Change the Sync server on each installation

+ +
+ +
+
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + diff --git a/patch/sources/syncserver/page/media/fonts/opensans-bold.5cf854f3d1c0.woff2 b/patch/sources/syncserver/page/media/fonts/opensans-bold.5cf854f3d1c0.woff2 new file mode 100644 index 0000000..4ed695b Binary files /dev/null and b/patch/sources/syncserver/page/media/fonts/opensans-bold.5cf854f3d1c0.woff2 differ diff --git a/patch/sources/syncserver/page/media/fonts/opensans-italic.c86748d08341.woff2 b/patch/sources/syncserver/page/media/fonts/opensans-italic.c86748d08341.woff2 new file mode 100644 index 0000000..2bd1366 Binary files /dev/null and b/patch/sources/syncserver/page/media/fonts/opensans-italic.c86748d08341.woff2 differ diff --git a/patch/sources/syncserver/page/media/fonts/opensans-light.2120033991a4.woff2 b/patch/sources/syncserver/page/media/fonts/opensans-light.2120033991a4.woff2 new file mode 100644 index 0000000..21b4222 Binary files /dev/null and b/patch/sources/syncserver/page/media/fonts/opensans-light.2120033991a4.woff2 differ diff --git a/patch/sources/syncserver/page/media/fonts/opensans-lightitalic.580ce2d5ac1d.woff2 b/patch/sources/syncserver/page/media/fonts/opensans-lightitalic.580ce2d5ac1d.woff2 new file mode 100644 index 0000000..c2f5521 Binary files /dev/null and b/patch/sources/syncserver/page/media/fonts/opensans-lightitalic.580ce2d5ac1d.woff2 differ diff --git a/patch/sources/syncserver/page/media/fonts/opensans-regular.668362de763a.woff2 b/patch/sources/syncserver/page/media/fonts/opensans-regular.668362de763a.woff2 new file mode 100644 index 0000000..845dc73 Binary files /dev/null and b/patch/sources/syncserver/page/media/fonts/opensans-regular.668362de763a.woff2 differ diff --git a/patch/sources/syncserver/page/media/img/firefox/family/nav-sprite.56fbf5a8d218.png b/patch/sources/syncserver/page/media/img/firefox/family/nav-sprite.56fbf5a8d218.png new file mode 100644 index 0000000..ed3264c Binary files /dev/null and b/patch/sources/syncserver/page/media/img/firefox/family/nav-sprite.56fbf5a8d218.png differ diff --git a/patch/sources/syncserver/page/media/img/firefox/sync/device-lineup.a60618c7dacb.png b/patch/sources/syncserver/page/media/img/firefox/sync/device-lineup.a60618c7dacb.png new file mode 100644 index 0000000..f0ab7c9 Binary files /dev/null and b/patch/sources/syncserver/page/media/img/firefox/sync/device-lineup.a60618c7dacb.png differ diff --git a/patch/sources/syncserver/page/media/img/firefox/sync/icons.b80c6430793b.png b/patch/sources/syncserver/page/media/img/firefox/sync/icons.b80c6430793b.png new file mode 100644 index 0000000..b65f592 Binary files /dev/null and b/patch/sources/syncserver/page/media/img/firefox/sync/icons.b80c6430793b.png differ diff --git a/patch/sources/syncserver/page/media/img/sandstone/bg-gradient-sky.7ea325995978.png b/patch/sources/syncserver/page/media/img/sandstone/bg-gradient-sky.7ea325995978.png new file mode 100644 index 0000000..cf82e53 Binary files /dev/null and b/patch/sources/syncserver/page/media/img/sandstone/bg-gradient-sky.7ea325995978.png differ diff --git a/patch/sources/syncserver/page/media/img/sandstone/footer-mozilla.fafef0912042.png b/patch/sources/syncserver/page/media/img/sandstone/footer-mozilla.fafef0912042.png new file mode 100644 index 0000000..9f874d0 Binary files /dev/null and b/patch/sources/syncserver/page/media/img/sandstone/footer-mozilla.fafef0912042.png differ diff --git a/patch/sources/syncserver/page/media/img/sandstone/grain.855f29e0c686.png b/patch/sources/syncserver/page/media/img/sandstone/grain.855f29e0c686.png new file mode 100644 index 0000000..dd4b1e6 Binary files /dev/null and b/patch/sources/syncserver/page/media/img/sandstone/grain.855f29e0c686.png differ diff --git a/patch/sources/syncserver/page/media/img/tabzilla/tabzilla-static.953a65a1f4a4.png b/patch/sources/syncserver/page/media/img/tabzilla/tabzilla-static.953a65a1f4a4.png new file mode 100644 index 0000000..67861f5 Binary files /dev/null and b/patch/sources/syncserver/page/media/img/tabzilla/tabzilla-static.953a65a1f4a4.png differ diff --git a/patch/sources/syncserver/page/sync_files/btn-app-store.svg b/patch/sources/syncserver/page/sync_files/btn-app-store.svg new file mode 100644 index 0000000..d8c6294 --- /dev/null +++ b/patch/sources/syncserver/page/sync_files/btn-app-store.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/patch/sources/syncserver/page/sync_files/btn-google-play.png b/patch/sources/syncserver/page/sync_files/btn-google-play.png new file mode 100644 index 0000000..1bce4de Binary files /dev/null and b/patch/sources/syncserver/page/sync_files/btn-google-play.png differ diff --git a/patch/sources/syncserver/page/sync_files/common-bundle.js b/patch/sources/syncserver/page/sync_files/common-bundle.js new file mode 100644 index 0000000..024ed67 --- /dev/null +++ b/patch/sources/syncserver/page/sync_files/common-bundle.js @@ -0,0 +1,21 @@ +/*! jQuery v1.11.3 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */ +;function triggerIEDownload(e,t){"use strict";var n=t!==undefined?t:navigator.userAgent;e&&window.site.platform==="windows"&&/MSIE\s[1-8]\./.test(n)&&(window.open(e,"download_window","toolbar=0,location=no,directories=0,status=0,scrollbars=0,resizeable=0,width=1,height=1,top=0,left=0"),window.focus())}function initDownloadLinks(){$(".download-link").each(function(){var e=$(this);e.click(function(){triggerIEDownload(e.data("direct-link"))})}),$(".download-list").attr("role","presentation")}function initMobileDownloadLinks(){site.platform==="android"&&$('a[href^="https://play.google.com/store/apps/"]').each(function(){$(this).attr("href",$(this).attr("href").replace("https://play.google.com/store/apps/","market://"))}),site.platform==="ios"&&$('a[href^="https://itunes.apple.com/"]').each(function(){$(this).attr("href",$(this).attr("href").replace("https://","itms-apps://"))})}function maybeSwitchToDistDownloadLinks(e){if(!e.distribution||e.distribution==="default")return;var t=e.distribution.toLowerCase();$("a[data-"+t+"-link]").each(function(){$(this).attr("href",$(this).data(t+"Link"))})}function initLangSwitcher(){var e=$("#page-language-select"),t=e.val();e.change(function(){window.dataLayer.push({event:"change-language",languageSelected:e.val(),previousLanguage:t}),$("#lang_form").attr("action",window.location.hash||"#"),$("#lang_form").submit()})}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function g(e){var t="length"in e&&e.length,n=h.type(e);return"function"===n||h.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function S(e,t,n){if(h.isFunction(t))return h.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return h.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(E.test(t))return h.filter(t,e,n);t=h.filter(t,e)}return h.grep(e,function(e){return h.inArray(e,t)>=0!==n})}function A(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function _(e){var t=M[e]={};return h.each(e.match(O)||[],function(e,n){t[n]=!0}),t}function P(){T.addEventListener?(T.removeEventListener("DOMContentLoaded",H,!1),e.removeEventListener("load",H,!1)):(T.detachEvent("onreadystatechange",H),e.detachEvent("onload",H))}function H(){(T.addEventListener||"load"===event.type||"complete"===T.readyState)&&(P(),h.ready())}function q(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace(I,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:F.test(n)?h.parseJSON(n):n}catch(i){}h.data(e,t,n)}else n=void 0}return n}function R(e){var t;for(t in e)if(("data"!==t||!h.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function U(e,t,r,i){if(h.acceptData(e)){var s,o,u=h.expando,a=e.nodeType,f=a?h.cache:e,l=a?e[u]:e[u]&&u;if(l&&f[l]&&(i||f[l].data)||void 0!==r||"string"!=typeof t)return l||(l=a?e[u]=n.pop()||h.guid++:u),f[l]||(f[l]=a?{}:{toJSON:h.noop}),("object"==typeof t||"function"==typeof t)&&(i?f[l]=h.extend(f[l],t):f[l].data=h.extend(f[l].data,t)),o=f[l],i||(o.data||(o.data={}),o=o.data),void 0!==r&&(o[h.camelCase(t)]=r),"string"==typeof t?(s=o[t],null==s&&(s=o[h.camelCase(t)])):s=o,s}}function z(e,t,n){if(h.acceptData(e)){var r,i,s=e.nodeType,o=s?h.cache:e,u=s?e[h.expando]:h.expando;if(o[u]){if(t&&(r=n?o[u]:o[u].data)){h.isArray(t)?t=t.concat(h.map(t,h.camelCase)):t in r?t=[t]:(t=h.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!R(r):!h.isEmptyObject(r))return}(n||(delete o[u].data,R(o[u])))&&(s?h.cleanData([e],!0):l.deleteExpando||o!=o.window?delete o[u]:o[u]=null)}}}function et(){return!0}function tt(){return!1}function nt(){try{return T.activeElement}catch(e){}}function rt(e){var t=it.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}function wt(e,t){var n,r,i=0,s=typeof e.getElementsByTagName!==B?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==B?e.querySelectorAll(t||"*"):void 0;if(!s)for(s=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||h.nodeName(r,t)?s.push(r):h.merge(s,wt(r,t));return void 0===t||t&&h.nodeName(e,t)?h.merge([e],s):s}function Et(e){J.test(e.type)&&(e.defaultChecked=e.checked)}function St(e,t){return h.nodeName(e,"table")&&h.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function xt(e){return e.type=(null!==h.find.attr(e,"type"))+"/"+e.type,e}function Tt(e){var t=vt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function Nt(e,t){for(var n,r=0;null!=(n=e[r]);r++)h._data(n,"globalEval",!t||h._data(t[r],"globalEval"))}function Ct(e,t){if(1===t.nodeType&&h.hasData(e)){var n,r,i,s=h._data(e),o=h._data(t,s),u=s.events;if(u){delete o.handle,o.events={};for(n in u)for(r=0,i=u[n].length;i>r;r++)h.event.add(t,n,u[n][r])}o.data&&(o.data=h.extend({},o.data))}}function kt(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!l.noCloneEvent&&t[h.expando]){i=h._data(t);for(r in i.events)h.removeEvent(t,r,i.handle);t.removeAttribute(h.expando)}"script"===n&&t.text!==e.text?(xt(t).text=e.text,Tt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),l.html5Clone&&e.innerHTML&&!h.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&J.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function Ot(t,n){var r,i=h(n.createElement(t)).appendTo(n.body),s=e.getDefaultComputedStyle&&(r=e.getDefaultComputedStyle(i[0]))?r.display:h.css(i[0],"display");return i.detach(),s}function Mt(e){var t=T,n=At[e];return n||(n=Ot(e,t),"none"!==n&&n||(Lt=(Lt|| +h("