Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into onelab
authorJavier García <javier.garcial.external@atos.net>
Mon, 1 Dec 2014 12:09:54 +0000 (13:09 +0100)
committerJavier García <javier.garcial.external@atos.net>
Mon, 1 Dec 2014 12:09:54 +0000 (13:09 +0100)
255 files changed:
README
activity/__init__.py [new file with mode: 0644]
activity/institution.py [new file with mode: 0644]
activity/slice.py [new file with mode: 0644]
activity/user.py [new file with mode: 0644]
auth/views.py
debian/deb-cheat-sheet
manifoldapi/manifoldproxy.py
manifoldapi/static/css/manifold.css
manifoldapi/static/js/manifold.js
manifoldapi/static/js/plugin.js
myslice/monitor.ini.dist [new file with mode: 0644]
myslice/myslice.ini.localhost
myslice/theme.py
myslice/urls.py
plugins/apply/static/js/apply.js
plugins/apply/templates/apply.html
plugins/columns_editor/templates/columns_editor.html
plugins/filter_status/static/js/filter_status.js
plugins/filter_status/templates/filter_status.html
plugins/googlemap/__init__.py
plugins/googlemap/static/js/googlemap.js
plugins/querytable/__init__.py
plugins/querytable/static/js/querytable.js
plugins/querytable/templates/querytable.html
plugins/scheduler2/static/css/scheduler2.css
plugins/scheduler2/static/img/forbidden.png [new file with mode: 0644]
plugins/scheduler2/static/js/scheduler2.js
plugins/scheduler2/templates/scheduler.html
plugins/testbeds/__init__.py
plugins/testbeds/static/js/testbeds.js
plugins/testbeds/templates/testbeds.html
plugins/univbris/__init__.py
plugins/univbris/static/js/univbris.js
plugins/univbris/templates/univbris.html
plugins/univbris/templates/univbris_welcome.html [new file with mode: 0644]
plugins/univbrisfoam/__init__.py
plugins/univbrisfoam/static/js/univbrisfoam.js
plugins/univbrisfoam/templates/generated1.htm
plugins/univbrisfoam/templates/univbrisfoam.html
plugins/univbrisfv/__init__.py
plugins/univbrisfv/__init__1.py [deleted file]
plugins/univbrisfv/static/js/univbrisfv.js
plugins/univbrisfv/templates/univbrisfv.html
plugins/univbrisfvf/static/js/univbrisfvf.js
plugins/univbrisfvf/templates/univbrisfv.html
plugins/univbrisfvf/templates/univbrisfvf.html
plugins/univbrisfvfo/__init__.py [new file with mode: 0644]
plugins/univbrisfvfo/static/css/univbrisfvfo.css [new file with mode: 0644]
plugins/univbrisfvfo/static/img/README [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-bullet1.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-bullet2.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-col-alt.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-gradient.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-header-down.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-header-sortable.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-header-up.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-header.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/tablesort-td-alt.png [new file with mode: 0644]
plugins/univbrisfvfo/static/img/toggle-hidden.png [new file with mode: 0755]
plugins/univbrisfvfo/static/img/toggle-visible.png [new file with mode: 0755]
plugins/univbrisfvfo/static/js/univbrisfvfo.js [moved from plugins/univbrisfv/static/js/univbrisfv1.js with 52% similarity]
plugins/univbrisfvfo/templates/jquery-1.11.0.js [new file with mode: 0644]
plugins/univbrisfvfo/templates/univbrisfvfo.html [new file with mode: 0644]
plugins/univbristopo/__init__.py [new file with mode: 0644]
plugins/univbristopo/static/css/slice.css [new file with mode: 0644]
plugins/univbristopo/static/css/slice.topology.css [new file with mode: 0644]
plugins/univbristopo/static/css/tooltip.css [new file with mode: 0644]
plugins/univbristopo/static/css/tooltip.topology.css [new file with mode: 0644]
plugins/univbristopo/static/css/univbristopo.css [moved from portal/templates/institution-tab-info.html with 100% similarity]
plugins/univbristopo/static/img/genilogo.png [new file with mode: 0644]
plugins/univbristopo/static/img/groupin.png [new file with mode: 0644]
plugins/univbristopo/static/img/host-tiny.png [new file with mode: 0644]
plugins/univbristopo/static/img/oswitch-tiny.png [new file with mode: 0644]
plugins/univbristopo/static/img/server-tiny.png [new file with mode: 0644]
plugins/univbristopo/static/img/switch-tiny.png [new file with mode: 0644]
plugins/univbristopo/static/img/switch-tiny2.png [new file with mode: 0644]
plugins/univbristopo/static/img/zoom.png [new file with mode: 0644]
plugins/univbristopo/static/img/zoomin.png [new file with mode: 0644]
plugins/univbristopo/static/img/zoomout.png [new file with mode: 0644]
plugins/univbristopo/static/js/d3.v2.min.js [new file with mode: 0644]
plugins/univbristopo/static/js/tooltip.topology.js [new file with mode: 0644]
plugins/univbristopo/static/js/univbristopo.js [new file with mode: 0644]
plugins/univbristopo/templates/spillout [new file with mode: 0644]
plugins/univbristopo/templates/univbris_topology.html [new file with mode: 0644]
plugins/univbrisvtam/__init__.py [new file with mode: 0644]
plugins/univbrisvtam/static/css/univbrisvtam.css [new file with mode: 0644]
plugins/univbrisvtam/static/img/README [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-bullet1.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-bullet2.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-col-alt.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-gradient.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header-down.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header-sortable.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header-up.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-header.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/tablesort-td-alt.png [new file with mode: 0644]
plugins/univbrisvtam/static/img/toggle-hidden.png [new file with mode: 0755]
plugins/univbrisvtam/static/img/toggle-visible.png [new file with mode: 0755]
plugins/univbrisvtam/static/js/univbrisvtam.js [moved from plugins/univbrisfv/static/js/univbrisfv2.js with 65% similarity]
plugins/univbrisvtam/templates/univbrisvtamplugin.html [new file with mode: 0644]
plugins/univbrisvtamform/__init__.py [new file with mode: 0644]
plugins/univbrisvtamform/static/css/univbrisvtamform.css [new file with mode: 0644]
plugins/univbrisvtamform/static/img/README [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-bullet1.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-bullet2.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-col-alt.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-gradient.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header-down.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header-sortable.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header-up.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-header.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/tablesort-td-alt.png [new file with mode: 0644]
plugins/univbrisvtamform/static/img/toggle-hidden.png [new file with mode: 0755]
plugins/univbrisvtamform/static/img/toggle-visible.png [new file with mode: 0755]
plugins/univbrisvtamform/static/js/univbrisvtamform.js [new file with mode: 0644]
plugins/univbrisvtamform/templates/univbrisvtamform.html [new file with mode: 0644]
portal/account.py [new file with mode: 0644]
portal/accountview.py
portal/actions.py
portal/contactview.py
portal/emailactivationview.py
portal/forms.py
portal/homeview.py
portal/joinview.py
portal/managementtababout.py [new file with mode: 0644]
portal/managementtabrequests.py
portal/manageuserview.py
portal/manualdelegationview.py [new file with mode: 0644]
portal/migrations/0009_initial.py [new file with mode: 0644]
portal/platform.py [new file with mode: 0644]
portal/registrationview.py
portal/reputationview.py [new file with mode: 0644]
portal/slicerequestview.py
portal/sliceresourceview.py
portal/slicetabexperiment.py
portal/static/css/account_view.css
portal/static/css/fantaastic.css
portal/static/css/onelab.css
portal/static/icons/ko.png [new file with mode: 0644]
portal/static/icons/ok.png [new file with mode: 0644]
portal/static/img/fantaastic.png [new file with mode: 0644]
portal/static/reputation_static/css/delete.gif [new file with mode: 0644]
portal/static/reputation_static/css/images/star-off.png [new file with mode: 0644]
portal/static/reputation_static/css/images/star-on.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_flat_0_aaaaaa_40x100.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_flat_75_ffffff_40x100.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_glass_55_fbf9ee_1x400.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_glass_65_ffffff_1x400.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_glass_75_dadada_1x400.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_glass_75_e6e6e6_1x400.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_glass_95_fef1ec_1x400.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-icons_222222_256x240.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-icons_2e83ff_256x240.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-icons_454545_256x240.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-icons_888888_256x240.png [new file with mode: 0644]
portal/static/reputation_static/css/images/ui-icons_cd0a0a_256x240.png [new file with mode: 0644]
portal/static/reputation_static/css/jquery-ui-1.9.2.custom.min.css [new file with mode: 0644]
portal/static/reputation_static/css/jquery.rating.css [new file with mode: 0644]
portal/static/reputation_static/css/main.css [new file with mode: 0644]
portal/static/reputation_static/img/star-off.png [new file with mode: 0644]
portal/static/reputation_static/img/star-on.png [new file with mode: 0644]
portal/static/reputation_static/img/star.gif [new file with mode: 0644]
portal/static/reputation_static/js/jquery-1.9.0.min.js [new file with mode: 0644]
portal/static/reputation_static/js/jquery.raty.min.js [new file with mode: 0644]
portal/static/reputation_static/js/ui/jquery-ui-1.9.2.custom.min.js [new file with mode: 0644]
portal/templates/_footer.html [new file with mode: 0644]
portal/templates/_widget-monitor.html [new file with mode: 0644]
portal/templates/_widget-stats-top-slices.html [new file with mode: 0644]
portal/templates/about.html
portal/templates/account-view.html
portal/templates/activate_user.html
portal/templates/activate_user.txt
portal/templates/authority_request_denied.html [new file with mode: 0644]
portal/templates/authority_request_denied.txt [new file with mode: 0644]
portal/templates/authority_request_email.html
portal/templates/authority_request_email.txt
portal/templates/base.html
portal/templates/contact.html
portal/templates/contact_support_email.html
portal/templates/email_activation.html
portal/templates/email_default_recipients.txt
portal/templates/email_default_sender.txt
portal/templates/fantaastic/fantaastic_account-view.html [new file with mode: 0644]
portal/templates/fantaastic/fantaastic_footer.html [new file with mode: 0644]
portal/templates/fantaastic/fantaastic_home-view.html [new file with mode: 0644]
portal/templates/fantaastic/fantaastic_institution.html [new file with mode: 0644]
portal/templates/fantaastic/fantaastic_management-tab-requests.html [new file with mode: 0644]
portal/templates/fantaastic/fantaastic_slicerequest_view.html [new file with mode: 0644]
portal/templates/fantaastic/fantaastic_widget-login-user.html [new file with mode: 0644]
portal/templates/fantaastic/fantaastic_widget-topmenu.html
portal/templates/fed4fire/fed4fire_about.html
portal/templates/fed4fire/fed4fire_account-view.html
portal/templates/fed4fire/fed4fire_base.html [deleted file]
portal/templates/fed4fire/fed4fire_footer.html [new file with mode: 0644]
portal/templates/fed4fire/fed4fire_home-view.html
portal/templates/fed4fire/fed4fire_institution.html [new file with mode: 0644]
portal/templates/fed4fire/fed4fire_management-tab-about.html [new file with mode: 0644]
portal/templates/fed4fire/fed4fire_management-tab-requests.html [new file with mode: 0644]
portal/templates/fed4fire/fed4fire_slice-resource-view.html [new file with mode: 0644]
portal/templates/fed4fire/fed4fire_slice-view.html [new file with mode: 0644]
portal/templates/fed4fire/fed4fire_slicerequest_view.html [new file with mode: 0644]
portal/templates/fed4fire/fed4fire_widget-slice-sections.html
portal/templates/fed4fire/fed4fire_widget-topmenu.html
portal/templates/fibre/fibre_slice-resource-view.html [new file with mode: 0644]
portal/templates/join_view.html
portal/templates/management-tab-requests.html
portal/templates/manual-delegation.html [new file with mode: 0644]
portal/templates/onelab/onelab_about.html
portal/templates/onelab/onelab_account-view.html
portal/templates/onelab/onelab_contact.html
portal/templates/onelab/onelab_home-view.html
portal/templates/onelab/onelab_institution.html
portal/templates/onelab/onelab_management-tab-about.html [new file with mode: 0644]
portal/templates/onelab/onelab_management-tab-requests.html
portal/templates/onelab/onelab_news.html
portal/templates/onelab/onelab_registration_view.html
portal/templates/onelab/onelab_slice-resource-view.html [new file with mode: 0644]
portal/templates/onelab/onelab_slice-view.html
portal/templates/onelab/onelab_slicerequest_view.html
portal/templates/onelab/onelab_supportview.html
portal/templates/onelab/onelab_user_request_email.html [new file with mode: 0644]
portal/templates/onelab/onelab_user_request_email.txt [new file with mode: 0644]
portal/templates/onelab/onelab_widget-login-user.html
portal/templates/onelab/onelab_widget-slice-sections.html
portal/templates/onelab/onelab_widget-topmenu.html
portal/templates/password_reset_confirm.html
portal/templates/registration_view.html
portal/templates/reputation.html [new file with mode: 0644]
portal/templates/slice-request-done-view.html
portal/templates/slice-resource-view.html
portal/templates/slice-tab-experiment.html
portal/templates/slice-tab-users-view.html
portal/templates/slice_request_denied.html [new file with mode: 0644]
portal/templates/slice_request_denied.txt [new file with mode: 0644]
portal/templates/slice_request_email.html
portal/templates/slice_request_email.txt
portal/templates/slice_request_validated.html [new file with mode: 0644]
portal/templates/slice_request_validated.txt [new file with mode: 0644]
portal/templates/univbris.html
portal/templates/univbrisvtam.html [new file with mode: 0644]
portal/templates/user_register_complete.html
portal/templates/user_request_denied.html [new file with mode: 0644]
portal/templates/user_request_denied.txt [new file with mode: 0644]
portal/templates/user_request_email.html
portal/templates/user_request_validated.html [new file with mode: 0644]
portal/templates/user_request_validated.txt [new file with mode: 0644]
portal/templatetags/portal_filters.py
portal/univbrisview.py
portal/univbrisvtam.py [new file with mode: 0644]
portal/urls.py
rest/credentials.py [new file with mode: 0644]
rest/monitor.py [new file with mode: 0644]
ui/topmenu.py

diff --git a/README b/README
index 4e0b471..b1f201d 100644 (file)
--- a/README
+++ b/README
@@ -11,7 +11,7 @@ See the devel/ subdir for more devel-oriented doc.
 ** see devel/django-install.txt in case of trouble
 $ apt-get install python-django
 $ apt-get install python-django-south
-$ apt-get install python-pip
+$ apt-get install python-pip or sudo easy_install pip==1.4.1
 $ pip install requests
 $ pip install djangorestframework
 * git clone git://git.onelab.eu/myslice.git
diff --git a/activity/__init__.py b/activity/__init__.py
new file mode 100644 (file)
index 0000000..4719a61
--- /dev/null
@@ -0,0 +1,96 @@
+#
+# Activity monitor
+#
+# Client is authenticated with an API key and a secret
+# The API key is a 64 chars string (digits and letters) that is passed to the request
+# The secret is a 64 chars string that is used to sign the request
+# The generated signature is a SHA256 hes digest
+
+import urllib, urllib2
+import threading
+import hmac
+import hashlib
+import base64
+import time
+import datetime
+from myslice.configengine import ConfigEngine
+
+config = ConfigEngine()
+if config.activity and config.activity.apikey :
+    apikey = config.activity.apikey
+else :
+    # apikey will be necessary
+    apikey = None
+
+if config.activity and config.activity.secret :
+    secret = config.activity.secret
+else :
+    # secret will be necessary
+    secret = None
+
+if config.activity and config.activity.server :
+    server = config.activity.server
+else :
+    # default log server
+    server = "http://athos.ipv6.lip6.fr/activity/push/log"
+
+def logWrite(request, action, message, objects = None):
+    
+    if not apikey :
+        print "===============>> activity: no apikey"
+        return
+    if not secret :
+        print "===============>> activity: no secret"
+        return
+    
+    timestamp = time.mktime(datetime.datetime.today().timetuple())
+    ip = getClientIp(request)
+    log = {
+        "timestamp" : timestamp,
+        "client_ip" : ip,
+        "host"      : request.get_host(),
+        "referrer"  : request.META.get('HTTP_REFERER'),
+        "user"      : request.user,
+        "action"    : action,
+        "message"   : message,
+        "apikey"    : apikey,
+        "signature" : sign(secret, "%s%s%s%s" % (timestamp, ip, request.user, action)),
+        "slice"     : None,
+        "resource"  : None,
+        "resource_type"     : None,
+        "facility"      : None,
+        "testbed"       : None,
+    }
+    
+    if objects is not None:
+        for o in objects :
+            if (o in log) :
+                log[o] = objects[o]
+    
+    try :
+        result = urllib2.urlopen(server, urllib.urlencode(log))
+        print "===============>> activity: %s <%s> %s" % (action, request.user,message)
+        content = result.read()
+    except urllib2.URLError as e:
+        print "===============>> activity: connection to " + server + " impossible, could not log action"
+        print e.strerror
+        print ""
+
+def log(request, action, message, objects = None):
+    # Create a new thread in Daemon mode to send the log entry
+    t = threading.Thread(target=logWrite, args=(request, action, message, objects))
+    t.setDaemon(True)
+    t.start()
+
+def getClientIp(request):
+    x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
+    if x_forwarded_for:
+        ip = x_forwarded_for.split(',')[0]
+    else:
+        ip = request.META.get('REMOTE_ADDR')
+    return ip
+
+#
+# sign the request with the secret key
+def sign(secret, message):
+    return hmac.new(secret, msg=message, digestmod=hashlib.sha256).hexdigest()
\ No newline at end of file
diff --git a/activity/institution.py b/activity/institution.py
new file mode 100644 (file)
index 0000000..73a2369
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# log functions for institution activity
+#
+
+import activity
+
+def joined(request):
+    activity.log(request, "institution.join", "Institution joined")
+
+def join(request):
+    activity.log(request, "institution.join.view", "Institution view join form")
\ No newline at end of file
diff --git a/activity/slice.py b/activity/slice.py
new file mode 100644 (file)
index 0000000..f7f1eff
--- /dev/null
@@ -0,0 +1,11 @@
+#
+# log functions for slice
+#
+
+import activity
+
+def validate(request, o):
+    activity.log(request, "slice.validate", "Slice validation", o)
+    
+def resource(request, o):
+    activity.log(request, "slice.resource", "Resource reservation", o)
\ No newline at end of file
diff --git a/activity/user.py b/activity/user.py
new file mode 100644 (file)
index 0000000..a2790e8
--- /dev/null
@@ -0,0 +1,29 @@
+#
+# log functions for user activity
+#
+
+import activity
+
+def login(request, state=None):
+    if state is not None :
+        activity.log(request, "user.login." + state, "User log in")
+    else :
+        activity.log(request, "user.login", "User log in")
+    
+def logout(request):
+    activity.log(request, "user.logout", "User log out")
+
+def signup(request):
+    activity.log(request, "user.signup.view", "User sign up")
+
+def registered(request):
+    activity.log(request, "user.signup", "User registered")
+
+def contact(request):
+    activity.log(request, "user.contact", "User sent a contact request")
+    
+def slice(request):
+    activity.log(request, "user.slice", "User requested a slice")
+
+def resource(request):
+    activity.log(request, "user.resource", "User added a resource to a slice")
\ No newline at end of file
index 104d11c..b959e73 100644 (file)
@@ -1,12 +1,18 @@
 from django.contrib.auth import logout
 from django.http import HttpResponseRedirect
 
+import activity.user
+
 # hard question : where should we redirect requests to logout if user is not logged in ?
 def logout_user (request):
     # check that we're indeed logged in
     if not request.user.is_authenticated():
         return HttpResponseRedirect ('/')
     print "LOGGING OUT"
+    
+    # log user activity
+    activity.user.logout(request)
+    
     logout(request)
     return HttpResponseRedirect ('/')
         
index 182c3d3..3d3f1bc 100644 (file)
@@ -21,3 +21,7 @@ dpkg -i foo.deb
 - or, if this has deps that need to be pulled through apt-get:
 gdebi foo.deb
 (install with apt-get install -y gdebi-core)
+
+--- find which package a file belongs to
+apt-file search /path/to/file
+(can be installed with : sudo apt-get install apt-file)
index 99959ae..9897b50 100644 (file)
@@ -13,6 +13,9 @@ from manifoldresult             import ManifoldException
 from manifold.util.log          import Log
 from myslice.configengine       import ConfigEngine
 
+# register activity
+import activity.slice
+
 debug=False
 #debug=True
 
@@ -55,9 +58,12 @@ with the query passed using POST"""
             admin_user, admin_password = ConfigEngine().manifold_admin_user_password()
             manifold_api_session_auth = {'AuthMethod': 'password', 'Username': admin_user, 'AuthString': admin_password}
         else:
-            print request.session['manifold']
-            manifold_api_session_auth = request.session['manifold']['auth']
-
+            if 'manifold' in request.session:
+                manifold_api_session_auth = request.session['manifold']['auth']
+            else:
+                json_answer=json.dumps({'code':0,'value':[]})
+                return HttpResponse (json_answer, mimetype="application/json")
+                
         if debug_empty and manifold_query.action.lower()=='get':
             json_answer=json.dumps({'code':0,'value':[]})
             print "By-passing : debug_empty & 'get' request : returning a fake empty list"
@@ -75,7 +81,26 @@ with the query passed using POST"""
         if 'description' in result and result['description'] \
                 and isinstance(result['description'], (tuple, list, set, frozenset)):
             result [ 'description' ] = [ ResultValue.to_html (x) for x in result['description'] ]
-
+        
+        print "=> MANIFOLD PROXY executing: " + manifold_query.action.lower() 
+        #
+        # register activity
+        #
+        # resource reservation
+        if (manifold_query.action.lower() == 'update') :
+            print result['value'][0]
+            if 'resource' in result['value'][0] :
+                for resource in result['value'][0]['resource'] :
+                    activity.slice.resource(request, 
+                            { 
+                                'slice' :           result['value'][0]['slice_hrn'], 
+                                'resource' :        resource['hostname'], 
+                                'resource_type' :   resource['type'],
+                                'facility' :        resource['facility_name'],
+                                'testbed' :         resource['testbed_name']
+                            }
+                    )
+        
         json_answer=json.dumps(result)
 
         return HttpResponse (json_answer, mimetype="application/json")
index 42c034d..dfb4ab5 100644 (file)
@@ -2,3 +2,22 @@
        visibility: hidden;
        position: absolute;
 }
+
+.loading {
+    background-color:white;
+    color:black;
+    position:fixed;
+    top:160px;
+    left:50%;
+    width:30%;
+    margin: 0 0 0 -15%;
+    padding:25px 50px;
+    box-shadow: 4px 4px 5px #888;
+    border:1pt solid #30196D;
+    display:none;
+    z-index:100;
+}
+.loading img {
+    vertical-align:middle;
+    margin-right:15px;
+}
index e261efe..ca111de 100644 (file)
@@ -17,6 +17,32 @@ function debug_query (msg, query) {
     else messages.debug ("debug_query: " + msg + " query= " + query);
 }
 
+// http://stackoverflow.com/questions/7837456/comparing-two-arrays-in-javascript
+// attach the .equals method to Array's prototype to call it on any array
+Array.prototype.equals = function (array) {
+    // if the other array is a falsy value, return
+    if (!array)
+        return false;
+
+    // compare lengths - can save a lot of time 
+    if (this.length != array.length)
+        return false;
+
+    for (var i = 0, l=this.length; i < l; i++) {
+        // Check if we have nested arrays
+        if (this[i] instanceof Array && array[i] instanceof Array) {
+            // recurse into the nested arrays
+            if (!this[i].equals(array[i]))
+                return false;
+        }
+        else if (this[i] != array[i]) {
+            // Warning - two different object instances will never be equal: {x:20} != {x:20}
+            return false;
+        }
+    }
+    return true;
+}
+
 // http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
 Object.toType = (function toType(global) {
   return function(obj) {
@@ -318,12 +344,20 @@ function QueryStore() {
         default_set = (default_set === undefined) ? STATE_SET_OUT : default_set;
 
         var self = this;
-        var query_ext = this.find_analyzed_query_ext(query_uuid);
-        var record_key = manifold.metadata.get_key(query_ext.query.object);
+        var key, object, query_ext, record_key;
+
+        query_ext = this.find_analyzed_query_ext(query_uuid);
+        object = query_ext.query.object;
+        if (object.indexOf(':') != -1) {
+            object = object.split(':')[1];
+        }
+        record_key = manifold.metadata.get_key(object);
+
+        // ["start_time", "resource", "end_time"]
+        // ["urn"]
+        
         $.each(records, function(i, record) {
-            var key = manifold.metadata.get_key(query_ext.query.object);
-            // ["start_time", "resource", "end_time"]
-            // ["urn"]
+            //var key = manifold.metadata.get_key(query_ext.query.object);
             
             var record_key_value = manifold.record_get_value(record, record_key);
             query_ext.records.put(record_key_value, record);
@@ -345,6 +379,18 @@ function QueryStore() {
         return query_ext.records.get(record_key);
     }
 
+    this.del_record = function(query_uuid, record_key)
+    {
+        var query_ext = this.find_analyzed_query_ext(query_uuid);
+        return query_ext.records.remove(record_key);
+    }
+
+    this.del_state = function(query_uuid, record_key)
+    {
+        var query_ext = this.find_analyzed_query_ext(query_uuid);
+        return query_ext.state.remove(record_key);
+    }
+
     this.add_record = function(query_uuid, record, new_state)
     {
         var query_ext, key, record_key;
@@ -375,8 +421,15 @@ function QueryStore() {
         } else {
             record_key = record;
         }
-
-        manifold.query_store.set_record_state(query_uuid, record_key, STATE_SET, new_state);
+        
+        if ((query_ext.query.object == 'lease') && (new_state == STATE_SET_OUT)) {
+            // Leases that are marked out are in fact leases from other slices
+            // We need to _remove_ leases that we mark as OUT
+            manifold.query_store.del_record(query_uuid, record_key);
+            manifold.query_store.del_state(query_uuid, record_key);
+        } else {
+            manifold.query_store.set_record_state(query_uuid, record_key, STATE_SET, new_state);
+        }
     }
 
     this.iter_records = function(query_uuid, callback)
@@ -443,7 +496,7 @@ function QueryStore() {
     {
         var query_ext = this.find_analyzed_query_ext(query_uuid);
         query_ext.filters = $.grep(query_ext.filters, function(x) {
-            return x == filter;
+            return !(x.equals(filter));
         });
 
         this.apply_filters(query_uuid);
@@ -507,6 +560,8 @@ function QueryStore() {
 
         this.iter_records(query_uuid, function(record_key, record) {
             var is_reserved, is_pending, in_set,  is_unconfigured;
+
+            /* By default, a record is visible unless a filter says the opposite */
             var visible = true;
 
             var record_state = manifold.query_store.get_record_state(query_uuid, record_key, STATE_SET);
@@ -576,13 +631,16 @@ function QueryStore() {
                 if (op == '=' || op == '==') {
                     if ( col_value != value || col_value==null || col_value=="" || col_value=="n/a")
                         visible = false;
+
                 }else if (op == 'included') {
+                    /* By default, the filter returns false unless the record
+                     * field match at least one value of the included statement
+                     */
+                    visible = false;
                     $.each(value, function(i,x) {
                       if(x == col_value){
                           visible = true;
                           return false; // ~ break
-                      }else{
-                          visible = false;
                       }
                     });
                 }else if (op == '!=') {
@@ -613,7 +671,7 @@ function QueryStore() {
         });
 
         var end = new Date().getTime();
-        console.log("APPLY FILTERS took", end - start, "ms");
+        console.log("APPLY FILTERS [", filters, "] took", end - start, "ms");
 
     }
 
@@ -704,7 +762,7 @@ var manifold = {
     {
         return function() {
             ret = "";
-            for (i=0; i < key_fields.length; i++)
+            for (var i=0; i < key_fields.length; i++)
                 ret += "@@" + this[key_fields[i]];
             return ret;
         };
@@ -712,7 +770,10 @@ var manifold = {
 
     _record_equals: function(self, other, key_fields)
     {
-        for (i=0; i < key_fields.length; i++) {
+        if ((typeof self === "string") && (typeof other === "string")) {
+            return self == other;
+        }
+        for (var i=0; i < key_fields.length; i++) {
             var this_value  = self[key_fields[i]];
             var other_value = other[key_fields[i]];
 
@@ -724,6 +785,7 @@ var manifold = {
             switch (this_type) {
                 case TYPE_VALUE:
                 case TYPE_LIST_OF_VALUES:
+                case TYPE_LIST_OF_RECORDS:
                     if (this_value != other_value)
                         return false;
                     break;
@@ -731,13 +793,17 @@ var manifold = {
                     if (!(_record_equals(this_value, other_value, key_fields)))
                         return false;
                     break;
+                /*
+                XXX WARNING = disabled for OpenFlow plugin !!!
+
                 case TYPE_LIST_OF_RECORDS:
                     if (this_value.length != other_value.length)
                         return false;
-                    for (i = 0; i < this_value.length; i++)
-                        if (!(_record_equals(this_value, other_value, key_fields)))
+                    for (var j = 0; j < this_value.length; j++)
+                        if (!(_record_equals(this_value[j], other_value[j], key_fields)))
                             return false;
                     break;
+                */
             }
         }
         return true;
@@ -753,7 +819,7 @@ var manifold = {
     _in_array: function(element, array, key_fields)
     {
         if (key_fields.length > 1) {
-            for (i = 0; i < array.length; i++) {
+            for (var i = 0; i < array.length; i++) {
                 if (manifold._record_equals(element, array[i], key_fields))
                     return true;
             }
@@ -1018,7 +1084,7 @@ var manifold = {
         if (query_ext.set_query_ext) {
             // We have a domain query
             // The results are stored in the corresponding set_query
-            manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records)
+            manifold.query_store.set_records(query_ext.set_query_ext.query.query_uuid, records);
             
         } else if (query_ext.domain_query_ext) {
             // We have a set query, it is only used to determine which objects are in the set, we should only retrieve the key
@@ -1153,9 +1219,22 @@ var manifold = {
     make_record: function(object, record)
     {
         // To make an object a record, we just add the hash function
-        var key = manifold.metadata.get_key(object);
-        record.hashCode = manifold.record_hashcode(record, key.sort());
-        record.equals   = manifold.record_equals(record, key);
+        var key, new_object;
+
+        if (object.indexOf(':') != -1) {
+            new_object = object.split(':')[1];
+        } else {
+            new_object = object;
+        }
+
+        key = manifold.metadata.get_key(new_object);
+        if (!key){
+            console.log("object type: " + new_object + " has no key");
+            console.log(record);
+            return;
+        }
+        record.hashCode = manifold.record_hashcode(key.sort());
+        record.equals   = manifold.record_equals(key);
 
         // Looking after subrecords
         for (var field in record) {
@@ -1283,7 +1362,7 @@ case TYPE_LIST_OF_VALUES:
                 */
                 case TYPE_LIST_OF_VALUES: // XXX Until fixed
                 case TYPE_LIST_OF_RECORDS:
-                    var new_state,cur_query_uuid;
+                    var key, new_state, cur_query_uuid;
 
                     cur_query_uuid = query.analyzed_query.subqueries[field].query_uuid;
 
@@ -1291,7 +1370,15 @@ case TYPE_LIST_OF_VALUES:
                     //  - update_query_orig.params.resource = resources in slice before update
                     //  - update_query.params.resource = resource requested in slice
                     //  - keys from field = resources obtained
-                    var key = manifold.metadata.get_key(field);
+                
+                    if (field == 'lease') {
+                         // lease_id has been added to be repeated when
+                         // constructing request rspec. We don't want it for
+                         // comparisons
+                        key = ['start_time', 'end_time', 'resource'];
+                    } else {
+                        key = manifold.metadata.get_key(field);
+                    }
                     if (!key)
                         continue;
                     /*
@@ -1326,6 +1413,14 @@ case TYPE_LIST_OF_VALUES:
 
                         data = { state: STATE_SET, key  : field, op   : new_state, value: added_key }
                         manifold.raise_record_event(query_uuid, FIELD_STATE_CHANGED, data);
+
+                        // Inform subquery also
+                        data.key = '';
+                        manifold.raise_record_event(cur_query_uuid, FIELD_STATE_CHANGED, data);
+                        // XXX Passing no parameters so that they can redraw everything would
+                        // be more efficient but is currently not supported
+                        // XXX We could also need to inform plugins about nodes IN (not pending) that are no more, etc.
+                        // XXX refactor all this when suppressing update_queries, and relying on state instead !
                     });
                     $.each(removed_keys, function(i, removed_key) {
                         new_state = (manifold._in_array(removed_key, result_keys, key)) ? STATE_SET_OUT_FAILURE : STATE_SET_OUT_SUCCESS;
@@ -1338,6 +1433,10 @@ case TYPE_LIST_OF_VALUES:
 
                         data = { state: STATE_SET, key  : field, op   : new_state, value: removed_key }
                         manifold.raise_record_event(query_uuid, FIELD_STATE_CHANGED, data);
+
+                        // Inform subquery also
+                        data.key = '';
+                        manifold.raise_record_event(cur_query_uuid, FIELD_STATE_CHANGED, data);
                     });
 
                     break;
@@ -1350,6 +1449,7 @@ case TYPE_LIST_OF_VALUES:
         var query_ext = manifold.query_store.find_query_ext(query.query_uuid);
         query_ext.query_state = QUERY_STATE_DONE;
 
+
         // Send DONE message to plugins
         query.iter_subqueries(function(sq, data, parent_query) {
             manifold.raise_record_event(sq.query_uuid, DONE);
@@ -1540,7 +1640,7 @@ case TYPE_LIST_OF_VALUES:
         }
     },
 
-    _enforce_constraints: function(query_ext, record, resource_key, event_type)
+    _enforce_constraints: function(query_ext, record, record_key, event_type)
     {
         var query, data;
 
@@ -1555,14 +1655,14 @@ case TYPE_LIST_OF_VALUES:
                 // XXX Not always a resource
                 var is_reservable = (record.exclusive == true);
                 if (is_reservable) {
-                    var warnings = manifold.query_store.get_record_state(query.query_uuid, resource_key, STATE_WARNINGS);
+                    var warnings = manifold.query_store.get_record_state(query.query_uuid, record_key, STATE_WARNINGS);
 
                     if (event_type == STATE_SET_ADD) {
                         // We should have a lease_query associated
                         var lease_query = query_ext.parent_query_ext.query.subqueries['lease']; // in  options
                         var lease_query_ext = manifold.query_store.find_analyzed_query_ext(lease_query.query_uuid);
                         // Do we have lease records (in) with this resource
-                        var lease_records = $.grep(lease_query_ext.records.entries(), this._grep_active_lease_callback(lease_query, resource_key));
+                        var lease_records = $.grep(lease_query_ext.records.entries(), this._grep_active_lease_callback(lease_query, record_key));
                         if (lease_records.length == 0) {
                             // Sets a warning
                             // XXX Need for a better function to manage warnings
@@ -1577,7 +1677,7 @@ case TYPE_LIST_OF_VALUES:
                         delete warnings[CONSTRAINT_RESERVABLE_LEASE];
                     }
 
-                    manifold.query_store.set_record_state(query.query_uuid, resource_key, STATE_WARNINGS, warnings);
+                    manifold.query_store.set_record_state(query.query_uuid, record_key, STATE_WARNINGS, warnings);
                 }
 
                 /* This was redundant */
@@ -1586,7 +1686,7 @@ case TYPE_LIST_OF_VALUES:
                 // Signal the change to plugins (even if the constraint does not apply, so that the plugin can display a checkmark)
                 data = {
                     state:  STATE_WARNINGS,
-                    key   : resource_key,
+                    key   : record_key,
                     op    : null,
                     value : warnings
                 }
@@ -1594,7 +1694,7 @@ case TYPE_LIST_OF_VALUES:
                 break;
 
             case 'lease':
-                var resource_key = record.resource;
+                var resource_key = record_key.resource;
                 var resource_query = query_ext.parent_query_ext.query.subqueries['resource'];
                 var warnings = manifold.query_store.get_record_state(resource_query.query_uuid, resource_key, STATE_WARNINGS);
 
@@ -1792,6 +1892,7 @@ case TYPE_LIST_OF_VALUES:
             // FILTERS
 
             case FILTER_ADDED: 
+                console.log("FILTER ADDED", data);
                 /* Update internal record state */
                 manifold.query_store.add_filter(query_uuid, data);
 
@@ -1801,6 +1902,7 @@ case TYPE_LIST_OF_VALUES:
                 break;
 
             case FILTER_REMOVED:
+                console.log("FILTER REMOVED", data);
                 /* Update internal record state */
                 manifold.query_store.remove_filter(query_uuid, data);
 
index 76e1cb5..82a3cd0 100644 (file)
@@ -19,6 +19,108 @@ ManifoldApp.filter('offset', function() {
   };
 });
 
+// http://stackoverflow.com/questions/19992090/angularjs-group-by-directive
+ManifoldApp.filter('groupBy', ['$parse', function ($parse) {
+    return function (list, group_by) {
+
+        var filtered = [];
+        var prev_item = null;
+        var group_changed = false;
+        // this is a new field which is added to each item where we append "_CHANGED"
+        // to indicate a field change in the list
+        //was var new_field = group_by + '_CHANGED'; - JB 12/17/2013
+        var new_field = 'group_by_CHANGED';
+
+        // loop through each item in the list
+        angular.forEach(list, function (item) {
+
+            group_changed = false;
+
+            // if not the first item
+            if (prev_item !== null) {
+
+                // check if any of the group by field changed
+
+                //force group_by into Array
+                group_by = angular.isArray(group_by) ? group_by : [group_by];
+
+                //check each group by parameter
+                for (var i = 0, len = group_by.length; i < len; i++) {
+                    if ($parse(group_by[i])(prev_item) !== $parse(group_by[i])(item)) {
+                        group_changed = true;
+                    }
+                }
+
+
+            }// otherwise we have the first item in the list which is new
+            else {
+                group_changed = true;
+            }
+
+            // if the group changed, then add a new field to the item
+            // to indicate this
+            if (group_changed) {
+                item[new_field] = true;
+            } else {
+                item[new_field] = false;
+            }
+
+            filtered.push(item);
+            prev_item = item;
+
+        });
+
+        return filtered;
+    };
+}]);
+
+// https://github.com/angular-ui/angular-ui-OLDREPO/blob/master/modules/filters/unique/unique.js
+/**
+ * Filters out all duplicate items from an array by checking the specified key
+ * @param [key] {string} the name of the attribute of each object to compare for uniqueness
+ if the key is empty, the entire object will be compared
+ if the key === false then no filtering will be performed
+ * @return {array}
+ */
+ManifoldApp.filter('unique', function () {
+
+  return function (items, filterOn) {
+
+    if (filterOn === false) {
+      return items;
+    }
+
+    if ((filterOn || angular.isUndefined(filterOn)) && angular.isArray(items)) {
+      var hashCheck = {}, newItems = [];
+
+      var extractValueToCompare = function (item) {
+        if (angular.isObject(item) && angular.isString(filterOn)) {
+          return item[filterOn];
+        } else {
+          return item;
+        }
+      };
+
+      angular.forEach(items, function (item) {
+        var valueToCheck, isDuplicate = false;
+
+        for (var i = 0; i < newItems.length; i++) {
+          if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) {
+            isDuplicate = true;
+            break;
+          }
+        }
+        if (!isDuplicate) {
+          newItems.push(item);
+        }
+
+      });
+      items = newItems;
+    }
+    return items;
+  };
+});
+
 // INHERITANCE
 // http://alexsexton.com/blog/2010/02/using-inheritance-patterns-to-organize-large-jquery-applications/
 // We will use John Resig's proposal
@@ -316,15 +418,18 @@ var Plugin = Class.extend({
     // use spin() to get our default spin settings (called presets)
     // use spin(true) to get spin's builtin defaults
     // you can also call spin_presets() yourself and tweak what you need to, like topmenuvalidation does
-    spin: function (presets) {
-       var presets = ( presets === undefined ) ? spin_presets() : presets;
-       try { this.$element.spin(presets); }
-       catch (err) { messages.debug("Cannot turn on spin " + err); }
+    spin: function (message) {
+       if (!message) {
+               message = 'Please be patient, this operation can take a minute or two.';
+       }
+       $('div.loading').fadeIn('fast');
+       $('div.loading').find('.message').text(message);
+
     },
 
     unspin: function() {
-       try { this.$element.spin(false); }
-       catch (err) { messages.debug("Cannot turn off spin " + err); }
+       $('div.loading').fadeOut('fast');
+
     },
 
     /* TEMPLATE */
diff --git a/myslice/monitor.ini.dist b/myslice/monitor.ini.dist
new file mode 100644 (file)
index 0000000..4613e1a
--- /dev/null
@@ -0,0 +1,33 @@
+[monitor]
+cert = myslice/sfa.cert
+pkey = myslice/sfa.pkey
+
+[onelab]
+name = OneLab
+url = http://portal.onelab.eu:12345
+type = registry
+
+[ple]
+name=PlanetLab Europe
+url = http://sfa3.planet-lab.eu:12346
+type = am
+
+[nitos] 
+name = NITOS
+url = https://nitlab.inf.uth.gr:8001/RPC2
+type = am
+
+[iotlab]
+name = FIT IoT-Lab
+url = http://194.199.16.169:52347
+type = am
+
+#[virtualwall] 
+#name = VirtualWall
+#url = http://www.wall2.ilabt.iminds.be:12369/protogeni/xmlrpc/am/3.0
+#type = am
+
+#[w-ilab.t]
+#name = w-ilab.t
+#url = http://www.wilab2.ilabt.iminds.be:12369/protogeni/xmlrpc/am/3.0
+#type = am
index 0467c0b..524e7be 100644 (file)
@@ -2,3 +2,6 @@
 url = https://localhost:7080
 admin_user = admin
 admin_password = admin
+
+[myslice]
+theme = onelab
index d44b854..e16326b 100644 (file)
@@ -14,12 +14,12 @@ class ThemeView (object):
     def template(self):
         # Load a template from the theme directory if it exists
         # else load it from the common templates dir
-        print "THEME = ",self.theme
-        print "TEMPLATE = ",self.template_name
-        print "TEMPLATE_DIRS = ",TEMPLATE_DIRS
+        #print "THEME = ",self.theme
+        #print "TEMPLATE = ",self.template_name
+        #print "TEMPLATE_DIRS = ",TEMPLATE_DIRS
         filename = self.theme + '_' + self.template_name
-        print any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
-        print (os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
+        #print any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
+        #print (os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
         if any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS):
             return filename
         else:
index 68ec521..91511b7 100644 (file)
@@ -16,7 +16,17 @@ import portal.platformsview
 import portal.dashboardview
 import portal.homeview
 import portal.newsview
+
+from portal.about                   import AboutView
 from portal.registrationview        import RegistrationView
+from portal.accountview             import AccountView, account_process
+from portal.institution             import InstitutionView
+
+from portal.supportview             import SupportView
+from portal.contactview             import ContactView
+
+from portal.termsview               import TermsView
+
 home_view=portal.homeview.HomeView.as_view()
 dashboard_view=portal.dashboardview.DashboardView.as_view()
 platforms_view=portal.platformsview.PlatformsView.as_view()
@@ -31,6 +41,7 @@ import portal.slicetabtestbeds
 import portal.slicetabusers
 import portal.slicetabmeasurements 
 
+import portal.managementtababout
 import portal.managementtabrequests
 
 #### high level choices
@@ -76,7 +87,10 @@ urls = [
     (r'^update/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.update.dispatch'),
     (r'^create/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.create.dispatch'),
     (r'^delete/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.delete.dispatch'),
+    (r'^credentials/(?P<action>[^/]+)/?$', 'rest.credentials.dispatch'),
     #
+    # REST monitoring
+    (r'^monitor/services/?$', 'rest.monitor.servicesStatus'),
     #
     #(r'^view/?', include('view.urls')),
     #(r'^list/slices', 'view.list.slices')
@@ -92,10 +106,20 @@ urls = [
     (r'^testbeds/(?P<slicename>[^/]+)/?$', portal.slicetabtestbeds.SliceTabTestbeds.as_view()),
     (r'^measurements/(?P<slicename>[^/]+)/?$', portal.slicetabmeasurements.SliceTabMeasurements.as_view()),
     (r'^experiment/(?P<slicename>[^/]+)/?$', portal.slicetabexperiment.ExperimentView.as_view()),
-    #
+    
+    url(r'^about/?$', AboutView.as_view(), name='about'),
+    
+    url(r'^institution/?$', InstitutionView.as_view(), name='institution'),
     (r'^management/requests/?$', portal.managementtabrequests.ManagementRequestsView.as_view()),
+    (r'^management/about/?$', portal.managementtababout.ManagementAboutView.as_view()),
+    #
+    url(r'^register/?$', RegistrationView.as_view(), name='registration'),
+    url(r'^account/?$', AccountView.as_view(), name='account'),
+    url(r'^account/account_process/?$', account_process),
+    url(r'^contact/?$', ContactView.as_view(), name='contact'),
+    url(r'^terms/?$', TermsView.as_view(), name='terms'),
+    url(r'^support/?$', SupportView.as_view(), name='support'),
     #
-    url(r'^register/?$', RegistrationView.as_view(), name='registration'),     
     url(r'^portal/', include('portal.urls')),
 
     # SLA
index efc9345..236deaf 100644 (file)
                        bAutoWidth: true,
             });
             
-            //this.elmt('update').click(this, this.do_ok);
-            //this.elmt('refresh').click(this, this.do_cancel);
+            this.elmt('close').click(this, this.do_close);
+            //this.elmt('apply_cancel').click(this, this.do_cancel);
 
-            this.elmt('apply').on('shown.bs.modal', function() {
+            this.elmt('apply__window').on('shown.bs.modal', function() {
                 self.do_update();
             })
 
@@ -80,7 +80,6 @@
 
         clear: function()
         {
-
         },
 
         find_row: function(value)
@@ -98,7 +97,7 @@
 
                 if (cur_value[0] == '{') {
                     cur_value = JSON.parse(cur_value);
-                    return manifold._record_equals(cur_value, value, object_key);_
+                    return manifold._record_equals(cur_value, value, object_key);
                 } else {
                     return (cur_value == value);
                 }
 
             var username = this.options.username;
 
-            this.spin();
             console.log("do_update in progress");
 
             manifold.raise_event(this.options.query_uuid, RUN_UPDATE);
 
         },
 
-        do_ok: function(e)
+        do_close: function(e)
         {
-            throw 'queryupdater.do_reset Not implemented';
+            var self = e.data;
+            self.table.fnClearTable();
         },
 
+        // Not used today
         do_cancel: function(e)
         {
             throw 'queryupdater.do_clear_annotations Not implemented';
 
         on_query_in_progress: function()
         {
-            this.spin();
         },
 
         on_query_done: function()
         {
             this.populate_table();
-            this.unspin();
         },
 
         // D : Data present
 
         on_clear_records: function()
         {
+                $('#applyloading').hide();
             this.clear();
         },
 
         on_query_done: function()
         {
-            this.unspin();
+            $('#applyloading').hide();
         },
 
         // PC : Pending changes
             // XXX how do we handle status reset ?
 
             // Jordan : I don't understand this. I added this test otherwise we have string = ""..."" double quoted twice.
-            if (typeof(data.value) !== "string")
-                data.value = JSON.stringify(data.value);
             data.selected_resources = this.selected_resources;
             row = this.find_row(data.value);
-            newline = [action, data.key, data.value, msg, button];
+            if (typeof(data.value) !== "string")
+                newline = [action, data.key, JSON.stringify(data.value), msg, button];
+            else
+                newline = [action, data.key, data.value, msg, button];
             if (!row) {
                 // XXX second parameter refresh = false can improve performance. todo in querytable also
                 this.table.fnAddData(newline);
index 6507012..f05af49 100644 (file)
@@ -1,11 +1,17 @@
 <div id={{ domid }}>
   <!-- Modal - columns selector -->
-  <div class="modal fade" id="{{domid}}__apply" tabindex="-1" role="dialog" aria-labelledby="{{domid}}__apply__label" aria-hidden="true">
+  <div class="modal fade" id="{{domid}}__apply__window" tabindex="-1" role="dialog" aria-labelledby="{{domid}}__apply__label" aria-hidden="true">
     <div class="modal-dialog modal-dialog-large">
       <div class="modal-content">
         <div class="modal-header">
           <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
-            <h4 class="modal-title" id="{{domid}}__apply__label">Applying pending changes...</h4>
+            <h4 class="modal-title" id="{{domid}}__apply__label">
+                Applying pending changes...                    
+            </h4>
+            <div>
+               <img id="applyloading" src="/static/img/loading.gif" /> &nbsp;&nbsp;
+               Please be patient, this operation can take a minute or two.
+            </div>
         </div>
         <div class="modal-body">
 <div class='resources-selected-spacer'>
@@ -28,7 +34,7 @@
 -->
         </div>
         <div class="modal-footer">
-          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+          <button id="{{domid}}__close" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
         </div>
       </div>
     </div>
@@ -36,6 +42,6 @@
 
   
   <!-- Button toolbar -->
-  <button class="btn btn-onelab btn-sm" data-toggle="modal" data-target="#{{domid}}__apply">Apply</button>
-  <button class="btn btn-default btn-sm" data-toggle="modal" data-target="#{{domid}}__cancel">Cancel</button>
+  <button class="btn btn-onelab btn-apply"  id="{{domid}}__apply" data-toggle="modal" data-target="#{{domid}}__apply__window">Apply</button>
+  <!-- <button class="btn btn-default btn-sm" id="{{domid}}__cancel">Cancel</button> -->
 </div> 
index 1d66e98..57a7831 100644 (file)
@@ -10,7 +10,7 @@ EOF; -->
   <table id='{{domid}}__table' class='query-editor'>
     <thead>
       <tr>
-        <th class='center'>Info</th>
+        <!--<th class='center'>Info</th> -->
         <th class='center'>Field</th>
         <!--
         <th class='center'>Resource</th>
@@ -26,7 +26,7 @@ EOF; -->
     {% for field in fields %}
 
       <tr>
-        <td class='center'><span class='glyphicon glyphicon-chevron-right' style='cursor:pointer'></span></td>
+        <!--<td class='center'><span class='glyphicon glyphicon-chevron-right' style='cursor:pointer'></span></td> -->
         <td class='center'>{{ field.name }}</td>
         <!--
         <td class='center'>{{ field.resource_type }}</td>
index 3bcd15c..9c1c244 100644 (file)
 
             // ... and communicate the appropriate filters to the manager
             // NOTE: we use the manifold namespace for internal filters 
-            if (self.prev_filter_status)
-                manifold.raise_event(self.options.query_uuid, FILTER_REMOVED, self.prev_filter_status);
-
+            if (self.prev_filter_status) {
+                var filter = ['manifold:status', '==', self.prev_filter_status];
+                manifold.raise_event(self.options.query_uuid, FILTER_REMOVED, filter);
+            }
             // XXX The datatables will be refreshed twice !
             if (filter_status != 'all') {
                 // No filter for 'all'
index 498c149..8350eb1 100644 (file)
@@ -1,9 +1,9 @@
 <div id={{ domid }}>
-  <span class="list-group-item-heading sl-resources">View:</span>
+  <span class="list-group-item-heading sl-resources" style='font-size:inherit;'>View:</span>
   
   <a href="#" 
      class="list-group-item sl-resources active" 
-     style='display: inline-block !important;' 
+     style='display: inline-block !important; font-size: inherit;
      id="{{ domid }}__all" 
      data-status="all"
         title="View resources that are available to be reserved."
@@ -13,7 +13,7 @@
   
   <a href="#"
      class="list-group-item sl-resources" 
-     style='display: inline-block !important;' 
+     style='display: inline-block !important; font-size: inherit;
      id="{{ domid }}__reserved" 
      data-status="reserved"
      title="View resources that you have previously reserved for the slice."
@@ -22,7 +22,7 @@
   </a>
   
   <a href="#" class="list-group-item sl-resources"
-     style='display: inline-block !important;' 
+     style='display: inline-block !important; font-size: inherit; width:130px;
      id="{{ domid }}__unconfigured" 
      data-status="unconfigured"
      title="View resources that you have selected to add to your slice, that require configuration before they can be reserved. Hover you mouse over the symbol next to the checkbox for more details."
@@ -32,7 +32,7 @@
   </a>
   
   <a href="#" class="list-group-item sl-resources" 
-     style='display: inline-block !important;' 
+     style='display: inline-block !important; font-size: inherit;
      id="{{ domid }}__pending" 
      data-status="pending"
      title="View pending changes to your slice: resources that you have selected to add, and resources that you have selected to remove. Click on the Apply button to apply those changes, or on the Cancel button to cancel them."
index 08f2a7b..8005de2 100644 (file)
@@ -8,7 +8,7 @@ class GoogleMap (Plugin):
     # googlemap_key :   mandatory googlemap API v3 key
     # latitude,longitude, zoom : the starting point
     # apparently at some point there has been support for a boolean 'checkboxes' input arg but seems dropped
-    def __init__ (self, query, googlemap_api_key=None, latitude=43., longitude=7., zoom=4, **settings):
+    def __init__ (self, query, googlemap_api_key=None, latitude=50., longitude=50, zoom=3, **settings):
         Plugin.__init__ (self, **settings)
         self.query=query
         self.googlemap_api_key=googlemap_api_key
index 5a15a3d..a3d9ba2 100644 (file)
@@ -83,8 +83,11 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2;
 
         on_show: function(e) {
                if (debug) messages.debug("googlemap.on_show");
-            var googlemap = e.data;
-            google.maps.event.trigger(googlemap.map, 'resize');
+            var self = e.data;
+            var center = new google.maps.LatLng(self.options.latitude, self.options.longitude);
+
+            google.maps.event.trigger(self.map, 'resize');
+            self.map.setCenter(center);
         }, 
 
         /**************************************************************************
@@ -173,7 +176,7 @@ GOOGLEMAP_BGCOLOR_REMOVED = 2;
                 data = {
                     state: STATE_SET,
                     key  : null,
-                    op   : this.checked ? SET_ADD : SET_REMOVED,
+                    op   : this.checked ? STATE_SET_ADD : STATE_SET_REMOVE,
                     value: id
                 }
                 manifold.raise_event(self.options.query_uuid, FIELD_STATE_CHANGED, data);
index 2182e70..995e935 100644 (file)
@@ -34,7 +34,8 @@ Current implementation makes the following assumptions
 """
 
     MAP = {
-        'network_hrn'   :   'Testbed',
+        'facility_name' :   'Facility',
+        'testbed_name'  :   'Testbed',
         'hostname'      :   'Resource name',
         'type'          :   'Type',
     }
index 4b9e546..3c1aab2 100644 (file)
@@ -12,7 +12,8 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
 
     
     var QUERYTABLE_MAP = {
-        'Testbed': 'network_hrn',
+        'Facility': 'facility_name',
+        'Testbed': 'testbed_name',
         'Resource name': 'hostname',
         'Type': 'type',
     };
@@ -162,6 +163,62 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
             });
             $(".dataTables_filter").append("<div style='display:inline-block;height:27px;width:27px;padding-left:6px;padding-top:4px;'><span class='glyphicon glyphicon-search'></span></div>");
             $(".dataTables_filter input").css("width","100%");
+            
+            // resource info
+            var sTable = this.table;
+            $('table.dataTable').delegate('a.resource-info','click',function() {
+                var aPos = sTable.fnGetPosition( this.parentNode );
+                var aData = sTable.fnGetData( aPos[0] );
+                //console.log(aData);
+                
+                var network_hrn = aData[18];
+                var resourceData = {
+                    'hostname' : strip(aData[2]),
+                    'urn' : aData[6],
+                    'type' : aData[3],
+                    'status' : aData[10],
+                    'testbed' : aData[4],
+                    'facility' : aData[5],
+                };
+                
+                
+                console.log(network_hrn);
+                //Greece: 37.6687092,22.2282404
+                if (network_hrn == 'omf.nitos') {
+                    var logo = 'nitos';
+                    var resourceLocation = {
+                        'longitude' : '22.2282404',
+                        'latitude' : '37.6687092',
+                    };
+                    var coordinates = resourceLocation['latitude']+','+resourceLocation['longitude'];
+                } else if (network_hrn == 'iotlab') {
+                    var logo = network_hrn;
+                    var s = resourceData['hostname'].split(".");
+                    var n = s[0].split("-");
+                    resourceData['type'] = 'node ( Hardware: <a target="_blank" href="https://www.iot-lab.info/hardware/'+n[0]+'/">'+n[0]+'</a> )';
+                    var coordinates = resourceData['testbed'];
+                } else {
+                    var logo = network_hrn;
+                    var resourceLocation = {
+                        'longitude' : aData[13],
+                        'latitude' : aData[23],
+                    };
+                    var coordinates = resourceLocation['latitude']+','+resourceLocation['longitude'];
+                }
+                
+                var modal = $('#resource-info-modal');
+                modal.find('.modal-title').text(resourceData['testbed'] + ': ' +resourceData['hostname']);
+                table = modal.find('.modal-resource-info');
+                table.html('<tr><td colspan="2"><img class="img-responsive" src="/static/img/testbeds/'+logo+'.png" alt="'+resourceData['facility']+' - '+resourceData['testbed']+'" /></td></tr>');
+                for (var j in resourceData) {
+                    table.append('<tr><td>' + j + '</td><td>' + resourceData[j] + '</td></tr>');
+                }
+                if (coordinates != '') {
+                    table.append('<tr><td colspan="2"><img src="http://maps.google.com/maps/api/staticmap?center='+coordinates+'&zoom=6&size=400x400&sensor=false&markers=color:red%7C'+coordinates+'" style="width:400px; height:400px;" /></td></tr>');
+                }
+                modal.modal();
+            });
+            
         }, // initialize_table
 
         /**
@@ -231,7 +288,8 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
                         //TODO: we need to add source/destination for links
                         line.push('');
                     else
-                        line.push(record['hostname']);
+                        //line.push(record['hostname']);
+                        line.push('<a class="resource-info" data-network_hrn="'+record['network_hrn']+'">' + record['hostname'] + '</a>');
 
                 } else if (colnames[j] == this.init_key && typeof(record) != 'undefined') {
                     obj = this.object
@@ -336,7 +394,7 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
                 }
             } else {
                 msg = '<ul class="nav nav-pills">';
-                msg += '<li class="dropdown">'
+                msg += '<li class="dropdown">';
                 msg += '<a href="#" data-toggle="dropdown" class="dropdown-toggle nopadding"><b>&#9888</b></a>';
                 msg += '  <ul class="dropdown-menu dropdown-menu-right" id="menu1">';
                 $.each(warnings, function(i,warning) {
@@ -563,7 +621,7 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
                 key  : null,
                 op   : this.checked ? STATE_SET_ADD : STATE_SET_REMOVE,
                 value: this.id
-            }
+            };
             manifold.raise_event(self.options.query_uuid, FIELD_STATE_CHANGED, data);
             //return false; // prevent checkbox to be checked, waiting response from manifold plugin api
             
@@ -588,7 +646,6 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
                 });
             }
         },
-
     });
 
     $.plugin('QueryTable', QueryTable);
@@ -603,6 +660,14 @@ QUERYTABLE_BGCOLOR_REMOVED = 2;
             return result=$('td:eq('+iColumn+') input', tr).prop('checked') ? '1' : '0';
         });
     };
+    
+    
 
 })(jQuery);
 
+function strip(html)
+{
+   var tmp = document.createElement("DIV");
+   tmp.innerHTML = html;
+   return tmp.textContent || tmp.innerText || "";
+}
index c843926..b215e1a 100644 (file)
@@ -2,7 +2,7 @@
   <table class="table dataTable" id="{{domid}}__table" width="100%">
     <thead>
       <tr>
-       {% if checkboxes %}<th class="checkbox"><input type="checkbox" disabled/></th>{% endif %}
+       {% if checkboxes %}<th><input type="checkbox" disabled/></th>{% endif %}
         <th>&#9888;</th>
         {% for column, field in columns.items %} <th>{{ column }}</th> {% endfor %} 
         {% for column, field in hidden_columns.items %} <th>{{ column }}</th> {% endfor %}
     </tfoot> 
   </table>
 </div>
+<div class="modal fade" id="resource-info-modal">
+  <div class="modal-dialog modal-md">
+    <div class="modal-content">
+      <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
+        <h4 class="modal-title"></h4>
+      </div>
+      <table class="table modal-resource-info"></table>
+      <div class="modal-footer">
+        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+      </div>
+    </div>
+  </div>
+</div>
index ffbe4f1..9d0cda1 100755 (executable)
     cursor: not-allowed;\r
 }\r
 \r
+#scheduler-reservation-table tbody tr td.disabled {\r
+    background: url("../img/forbidden.png") no-repeat scroll 50% 50%; /* #DD4444;*/\r
+    cursor: not-allowed;\r
+}\r
+\r
+#scheduler-reservation-table tbody tr td.success:after {\r
+       content: "✓";\r
+}\r
+#scheduler-reservation-table tbody tr td.failure:after {\r
+       content: "✗";\r
+}\r
+\r
 #scheduler-reservation-table tbody tr td.maintenance {\r
     background: url("../img/tools-15.png") no-repeat scroll 50% 50% #EDA428;\r
 }\r
 }\r
 \r
 #scheduler-reservation-table tbody tr td.free:hover ,#scheduler-reservation-table tbody tr td.selected, #scheduler-reservation-table tbody tr td.selected_tmp {\r
-    background: #25BA25;\r
+    background: #26c9e2;\r
 }\r
 \r
 td.no-image {\r
@@ -257,10 +269,11 @@ td.no-image {
     filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a6c9e2', endColorstr='#e0e0e0',GradientType=1 ); /* IE6-9 */\r
 \r
     padding: 3px 0 3px 30px;\r
-    width: 150px;\r
+    width: 250px;\r
 }\r
 \r
 .legend ol li.free{\r
+       background: #FFFFFF;\r
 \r
 }\r
 .legend ol li.pendingin{\r
@@ -283,6 +296,10 @@ background: #E8E8E8;
     background: #25BA25;\r
 }\r
 \r
+.legend ol li.disabled {\r
+       background: url("../img/forbidden.png") no-repeat scroll 2px 50% #FFFFFF;\r
+}\r
+\r
 /* latest stuff */\r
 .sliderContainer {\r
        margin-left: -15px;\r
diff --git a/plugins/scheduler2/static/img/forbidden.png b/plugins/scheduler2/static/img/forbidden.png
new file mode 100644 (file)
index 0000000..fba5664
Binary files /dev/null and b/plugins/scheduler2/static/img/forbidden.png differ
index 0b5339f..6b55b92 100755 (executable)
@@ -232,13 +232,15 @@ var SCHEDULER_COLWIDTH = 50;
 \r
         $scope.select = function(index, model_lease, model_resource)\r
         {\r
-            var data;\r
+            var data, resource_granularity;\r
+\r
+            //resource_granularity = model_resource.granularity === undefined ? RESOURCE_DEFAULT_GRANULARITY : model_resource.granularity;\r
 \r
             console.log("Selected", index, model_lease, model_resource);\r
 \r
             var day_timestamp = SchedulerDateSelected.getTime() / 1000;\r
-            var start_time = day_timestamp + index       * model_resource.granularity;\r
-            var end_time   = day_timestamp + (index + 1) * model_resource.granularity;\r
+            var start_time = day_timestamp + index       * model_resource.granularity; // XXX resource_granularity\r
+            var end_time   = day_timestamp + (index + 1) * model_resource.granularity; //\r
             var start_date = new Date(start_time * 1000);\r
             var end_date   = new Date(end_time   * 1000);\r
 \r
@@ -313,7 +315,7 @@ var SCHEDULER_COLWIDTH = 50;
                     }\r
         \r
                     $scope._create_new_lease(model_resource.urn, start_time, end_time);\r
-                    model_lease.status = 'pendingin'; \r
+                    model_lease.status = (model_lease.status == 'free') ? 'pendingin' : 'selected';\r
                     // unless the exact same lease already existed (pending_out status for the lease, not the cell !!)\r
 \r
                     break;\r
@@ -351,7 +353,7 @@ var SCHEDULER_COLWIDTH = 50;
                     }\r
                 \r
                     // cf comment in previous switch case\r
-                    model_lease.status = 'pendingout'; \r
+                    model_lease.status = (model_lease.status == 'selected') ? 'pendingout' : 'free';\r
 \r
                     break;\r
 \r
@@ -478,10 +480,6 @@ var SCHEDULER_COLWIDTH = 50;
                  * be updated when resources arrive.  Should be the pgcd in fact XXX */\r
                 this._granularity = DEFAULT_GRANULARITY;\r
                 scope.granularity = this._granularity;\r
-                this._all_slots = this._generate_all_slots();\r
-\r
-                // A list of {id, time} dictionaries representing the slots for the given day\r
-                scope.slots = this._all_slots;\r
                 this.scope_resources_by_key = {};\r
 \r
                 this.do_resize();\r
@@ -495,6 +493,16 @@ var SCHEDULER_COLWIDTH = 50;
             do_resize: function()\r
             {\r
                 var scope = this._get_scope();\r
+                var num_hidden_cells, new_max, lcm;\r
+\r
+                // do_resize has to be called when the window is resized, or one parameter changes\r
+                // e.g. when new resources have been received\r
+                //\r
+                this.resource_granularities = [3600, 1800]; //, 2400]; /* s */\r
+\r
+                /* Compute the slot length to accommodate all resources. This\r
+                 * is the GCD of all resource granularities. */\r
+                this._slot_length = this._gcdn(this.resource_granularities);\r
 \r
                 $('#' + schedulerTblId + ' thead tr th:eq(0)').css("width", SCHEDULER_FIRST_COLWIDTH);\r
                 //self get width might need fix depending on the template \r
@@ -502,20 +510,33 @@ var SCHEDULER_COLWIDTH = 50;
 \r
                 /* Number of visible cells...*/\r
                 this._num_visible_cells = parseInt((tblwidth - SCHEDULER_FIRST_COLWIDTH) / SCHEDULER_COLWIDTH);\r
+\r
                 /* ...should be a multiple of the lcm of all encountered granularities. */\r
-                // XXX Should be updated everytime a new resource is added\r
-                this._lcm_colspan = this._lcm(this._granularity, RESOURCE_DEFAULT_GRANULARITY) / this._granularity;\r
-                this._num_visible_cells = this._num_visible_cells - this._num_visible_cells % this._lcm_colspan;\r
+                lcm = this._lcmn(this.resource_granularities) / this._slot_length;\r
+                this._num_visible_cells = this._num_visible_cells - this._num_visible_cells % lcm;\r
+\r
+                // A list of {id, time} dictionaries representing the slots for the given day\r
+                this._all_slots = this._generate_all_slots();\r
+\r
                 /* scope also needs this value */\r
+                scope.slots = this._all_slots;\r
+                scope.slot_length = this._slot_length;\r
                 scope.num_visible_cells = this._num_visible_cells;\r
-                scope.lcm_colspan = this._lcm_colspan;\r
+                scope.lcm_colspan = this._lcmn(this.resource_granularities); // XXX WHY ?\r
 \r
-                // Slider max value\r
+                /* Redraw... */\r
+                this._scope_clear_leases();\r
+                this._set_all_lease_slots();\r
 \r
+                // Slider max value\r
                 if ($('#tblSlider').data('slider') != undefined) {\r
-                    var new_max = (this._all_slots.length - this._num_visible_cells) / this._lcm_colspan;\r
-                    $('#tblSlider').slider('setAttribute', 'max', new_max);\r
+                    num_hidden_cells = this._all_slots.length - this._num_visible_cells;\r
+\r
+                    $('#tblSlider').slider('setAttribute', 'max', num_hidden_cells);\r
+                    $('#tblSlider').slider('setValue', scope.from, true);\r
                 }\r
+                this._get_scope().$apply();\r
+\r
 \r
             },\r
 \r
@@ -557,7 +578,9 @@ var SCHEDULER_COLWIDTH = 50;
                     var resource = jQuery.extend(true, {}, record);\r
 \r
                     // Fix granularity\r
-                    resource.granularity = typeof(resource.granularity) == "number" ? resource.granularity : RESOURCE_DEFAULT_GRANULARITY;\r
+                    //resource_granularity = ((resource.granularity === undefined) || (typeof(resource.granularity) != "number")) ? RESOURCE_DEFAULT_GRANULARITY : resource.granularity;\r
+                    if (typeof(resource.granularity) != "number")\r
+                        resource.granularity = RESOURCE_DEFAULT_GRANULARITY;\r
                     resource.leases = []; // a list of occupied timeslots\r
 \r
                     self.scope_resources_by_key[resource['urn']] = resource;\r
@@ -567,18 +590,23 @@ var SCHEDULER_COLWIDTH = 50;
 \r
             _scope_clear_leases: function()\r
             {\r
+                var time, now;\r
                 var self = this;\r
                 var scope = this._get_scope();\r
 \r
+                now = new Date().getTime();\r
+\r
                 // Setup leases with a default free status...\r
                 $.each(this.scope_resources_by_key, function(resource_key, resource) {\r
                     resource.leases = [];\r
-                    var colspan_lease = resource.granularity / self._granularity; //eg. 3600 / 1800 => 2 cells\r
+                    var colspan_lease = resource.granularity / self._slot_length; //eg. 3600 / 1800 => 2 cells\r
+                    time = SchedulerDateSelected.getTime();\r
                     for (i=0; i < self._all_slots.length / colspan_lease; i++) { // divide by granularity\r
                         resource.leases.push({\r
                             id:     'coucou',\r
-                            status: 'free', // 'selected', 'reserved', 'maintenance' XXX pending ??\r
+                            status: (time < now) ? 'disabled':  'free', // 'selected', 'reserved', 'maintenance' XXX pending ??\r
                         });\r
+                        time += resource.granularity * 1000;\r
                     }\r
                 });\r
 \r
@@ -586,45 +614,35 @@ var SCHEDULER_COLWIDTH = 50;
 \r
             _scope_set_leases: function()\r
             {\r
+                    var status;\r
                 var self = this;\r
                 var scope = this._get_scope();\r
             \r
-                var leases = manifold.query_store.get_records(this.options.query_lease_uuid);\r
-                $.each(leases, function(i, lease) {\r
-\r
-                    console.log("SET LEASES", new Date(lease.start_time* 1000));\r
-                    console.log("          ", new Date(lease.end_time* 1000));\r
+                manifold.query_store.iter_records(this.options.query_lease_uuid, function(lease_key, lease) {\r
+                    console.log("SET LEASES", lease.resource, new Date(lease.start_time* 1000), new Date(lease.end_time* 1000));\r
                     // XXX We should ensure leases are correctly merged, otherwise our algorithm won't work\r
 \r
                     // Populate leases by resource array: this will help us merging leases later\r
+\r
+                    // let's only put _our_ leases\r
+                    lease_status = manifold.query_store.get_record_state(self.options.query_lease_uuid, lease_key, STATE_SET);\r
+                    if (lease_status != STATE_SET_IN)\r
+                        return true; // ~continue\r
                     if (!(lease.resource in scope._leases_by_resource))\r
                         scope._leases_by_resource[lease.resource] = [];\r
                     scope._leases_by_resource[lease.resource].push(lease);\r
 \r
-                    var resource = self.scope_resources_by_key[lease.resource];\r
-                    var day_timestamp = SchedulerDateSelected.getTime() / 1000;\r
+                });\r
 \r
-                    var id_start = (lease.start_time - day_timestamp) / resource.granularity;\r
-                    if (id_start < 0) {\r
-                        /* Some leases might be in the past */\r
-                        id_start = 0;\r
-                    }\r
-    \r
-                    var id_end   = (lease.end_time   - day_timestamp) / resource.granularity - 1;\r
-                    var colspan_lease = resource.granularity / self._granularity; //eg. 3600 / 1800 => 2 cells\r
-                    if (id_end >= self._all_slots.length / colspan_lease) {\r
-                        /* Limit the display to the current day */\r
-                        id_end = self._all_slots.length / colspan_lease\r
-                    }\r
+                this._set_all_lease_slots();\r
+            },\r
 \r
-                    for (i = id_start; i <= id_end; i++)\r
-                        // the same slots might be affected multiple times.\r
-                        // PENDING_IN + PENDING_OUT => IN \r
-                        //\r
-                        // RESERVED vs SELECTED !\r
-                        //\r
-                        // PENDING !!\r
-                        resource.leases[i].status = 'selected'; \r
+            _set_all_lease_slots: function()\r
+            {\r
+                var self = this;\r
+            \r
+                manifold.query_store.iter_records(this.options.query_lease_uuid, function(lease_key, lease) {\r
+                    self._set_lease_slots(lease_key, lease);\r
                 });\r
             },\r
 \r
@@ -658,8 +676,121 @@ var SCHEDULER_COLWIDTH = 50;
             on_leases_filter_removed:    function(filter) { this._get_scope().$apply(); },\r
             on_leases_filter_clear:      function()       { this._get_scope().$apply(); },\r
 \r
+            on_field_state_changed: function(data)\r
+            {\r
+                /*\r
+                this._set_lease_slots(lease_key, lease);\r
+\r
+                switch(data.state) {\r
+                    case STATE_SET:\r
+                        switch(data.op) {\r
+                            case STATE_SET_IN:\r
+                            case STATE_SET_IN_SUCCESS:\r
+                            case STATE_SET_OUT_FAILURE:\r
+                                this.set_checkbox_from_data(data.value, true);\r
+                                this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_RESET);\r
+                                break;  \r
+                            case STATE_SET_OUT:\r
+                            case STATE_SET_OUT_SUCCESS:\r
+                            case STATE_SET_IN_FAILURE:\r
+                                this.set_checkbox_from_data(data.value, false);\r
+                                this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_RESET);\r
+                                break;\r
+                            case STATE_SET_IN_PENDING:\r
+                                this.set_checkbox_from_data(data.key, true);\r
+                                this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_ADDED);\r
+                                break;  \r
+                            case STATE_SET_OUT_PENDING:\r
+                                this.set_checkbox_from_data(data.key, false);\r
+                                this.set_bgcolor(data.value, QUERYTABLE_BGCOLOR_REMOVED);\r
+                                break;\r
+                        }\r
+                        break;\r
+\r
+                    case STATE_WARNINGS:\r
+                        this.change_status(data.key, data.value);\r
+                        break;\r
+                }\r
+                */\r
+            },\r
+\r
+\r
             /* INTERNAL FUNCTIONS */\r
 \r
+            _set_lease_slots: function(lease_key, lease)\r
+            {\r
+                var resource, lease_status, lease_class;\r
+                var day_timestamp, id_start, id_end, colspan_lease;\r
+\r
+                resource = this.scope_resources_by_key[lease.resource];\r
+                day_timestamp = SchedulerDateSelected.getTime() / 1000;\r
+                id_start = Math.floor((lease.start_time - day_timestamp) / resource.granularity);\r
+\r
+                /* Some leases might be in the past */\r
+                if (id_start < 0)\r
+                    id_start = 0;\r
+                /* Leases in the future: ignore */\r
+                if (id_start >= this._all_slots.length)\r
+                    return true; // ~ continue\r
+\r
+                id_end   = Math.ceil((lease.end_time   - day_timestamp) / resource.granularity);\r
+                colspan_lease = resource.granularity / this._slot_length; //eg. 3600 / 1800 => 2 cells\r
+                if (id_end >= this._all_slots.length / colspan_lease) {\r
+                    /* Limit the display to the current day */\r
+                    id_end = this._all_slots.length / colspan_lease\r
+                }\r
+                lease_status = manifold.query_store.get_record_state(this.options.query_lease_uuid, lease_key, STATE_SET);\r
+                // the same slots might be affected multiple times.\r
+                // PENDING_IN + PENDING_OUT => IN \r
+                //\r
+                // RESERVED vs SELECTED !\r
+                //\r
+                // PENDING !!\r
+                switch(lease_status) {\r
+                    case STATE_SET_IN:\r
+                        lease_class = 'selected'; // my leases\r
+                        lease_success = '';\r
+                        break;\r
+                    case STATE_SET_IN_SUCCESS:\r
+                        lease_class = 'selected'; // my leases\r
+                        lease_success = 'success';\r
+                    case STATE_SET_OUT_FAILURE:\r
+                        lease_class = 'selected'; // my leases\r
+                        lease_success = 'failure';\r
+                        break;\r
+                    case STATE_SET_OUT:\r
+                        lease_class = 'reserved'; // other leases\r
+                        lease_success = '';\r
+                        break;\r
+                    case STATE_SET_OUT_SUCCESS:\r
+                        lease_class = 'free'; // other leases\r
+                        lease_success = 'success';\r
+                        break;\r
+                    case STATE_SET_IN_FAILURE:\r
+                        lease_class = 'free'; // other leases\r
+                        lease_success = 'failure';\r
+                        break;\r
+                    case STATE_SET_IN_PENDING:\r
+                        lease_class = 'pendingin';\r
+                        lease_success = '';\r
+                        break;\r
+                    case STATE_SET_OUT_PENDING:\r
+                        // pending_in & pending_out == IN == replacement\r
+                        if (resource.leases[i].status == 'pendingin')\r
+                            lease_class = 'pendingin'\r
+                        else\r
+                            lease_class = 'pendingout';\r
+                        lease_success = '';\r
+                        break;\r
+                \r
+                }\r
+\r
+                for (i = id_start; i < id_end; i++) {\r
+                    resource.leases[i].status = lease_class;\r
+                    resource.leases[i].success = lease_success;\r
+                }\r
+            },\r
+\r
 /* XXX IN TEMPLATE XXX\r
                 if (SchedulerDataViewData.length == 0) {\r
                     $("#plugin-scheduler").hide();\r
@@ -679,8 +810,12 @@ var SCHEDULER_COLWIDTH = 50;
             _initUI: function() \r
             {\r
                 var self = this;\r
+                var scope = self._get_scope();\r
+\r
+                var num_hidden_cells;\r
 \r
                 $("#DateToRes").datepicker({\r
+                       dateFormat: "D, d M yy",\r
                     onRender: function(date) {\r
                         return date.valueOf() < now.valueOf() ? 'disabled' : '';\r
                     }\r
@@ -688,24 +823,31 @@ var SCHEDULER_COLWIDTH = 50;
                     SchedulerDateSelected = new Date(ev.date);\r
                     SchedulerDateSelected.setHours(0,0,0,0);\r
                     // Set slider to origin\r
-                    $('#tblSlider').slider('setValue', 0); // XXX\r
+                    //$('#tblSlider').slider('setValue', 0); // XXX\r
                     // Refresh leases\r
                     self._scope_clear_leases();\r
-                    self._scope_set_leases();\r
+                    self._set_all_lease_slots();\r
                     // Refresh display\r
                     self._get_scope().$apply();\r
                 }).datepicker('setValue', SchedulerDateSelected); //.data('datepicker');\r
 \r
                 //init Slider\r
+                num_hidden_cells = self._all_slots.length - self._num_visible_cells;\r
+                init_cell = (new Date().getHours() - 1) * 3600 / self._granularity;\r
+                if (init_cell > num_hidden_cells)\r
+                    init_cell = num_hidden_cells;\r
+\r
                 $('#tblSlider').slider({\r
                     min: 0,\r
-                    max: (self._all_slots.length - self._num_visible_cells) / self._lcm_colspan,\r
-                    value: 0,\r
+                    max: num_hidden_cells,\r
+                    value: init_cell,\r
                 }).on('slide', function(ev) {\r
                     var scope = self._get_scope();\r
-                    scope.from = ev.value * self._lcm_colspan;\r
+                    scope.from = ev.value;\r
                     scope.$apply();\r
                 });\r
+                scope.from = init_cell;\r
+                scope.$apply();\r
 \r
                 $("#plugin-scheduler-loader").hide();\r
                 $("#plugin-scheduler").show();\r
@@ -721,6 +863,12 @@ var SCHEDULER_COLWIDTH = 50;
             return (y==0) ? x : this._gcd(y, x % y);\r
         },\r
 \r
+        _gcdn : function(array)\r
+        {\r
+            var self = this;\r
+            return array.reduce(function(prev, cur, idx, arr) { return self._gcd(prev, cur); });\r
+        },\r
+\r
         /**\r
          * Least common multiple\r
          */\r
@@ -728,6 +876,12 @@ var SCHEDULER_COLWIDTH = 50;
         {\r
             return x * y / this._gcd(x, y);\r
         },\r
+\r
+        _lcmn : function(array)\r
+        {\r
+            var self = this;\r
+            return array.reduce(function(prev, cur, idx, arr) { return self._lcm(prev, cur); });\r
+        },\r
     \r
         _pad_str : function(i)\r
         {\r
@@ -754,7 +908,7 @@ var SCHEDULER_COLWIDTH = 50;
                 /// ...and add the slot to the list of results\r
                 slots.push({ id: i, time: tmpTime });\r
                 // Increment the date with the granularity\r
-                d = new Date(d.getTime() + this._granularity * 1000);\r
+                d = new Date(d.getTime() + this._slot_length * 1000);\r
                 i++;\r
             }\r
             return slots;\r
index 6edc88e..259723b 100755 (executable)
@@ -8,22 +8,28 @@
 </div>\r
 <div id="plugin-{{ domid }}" class="">\r
     <div class="row m-b">\r
-        <div class="col-md-2">\r
-            <label for="inputEmail3" class="col-sm-2 control-label">Day:</label>\r
-        </div>\r
-        <div class="col-md-10">\r
-            <label for="inputEmail3" class="col-sm-2 control-label">Time of day:</label>\r
-        </div>\r
-    </div>\r
-    <div class="row m-b">\r
-               <div class="col-md-2">\r
-               <input id="DateToRes" type="text" placeholder="Reservation Date">\r
-               <!-- <input id="DateToRes" type="text" class="form-control" placeholder="Reservation Date"> -->\r
-               <span class="glyphicon glyphicon-calendar"></span>\r
+        <div class="col-md-4">\r
+               <div class="row">\r
+                       <div class="col-md-1">\r
+                       <label for="inputEmail3" class="control-label">Date:</label>\r
+                       </div>\r
+                               <div class="col-md-11">\r
+                                       <input id="DateToRes" type="text" placeholder="Reservation Date">\r
+                                       <span class="glyphicon glyphicon-calendar" style="position:absolute;margin-left:-20px;margin-top:4px;"></span>\r
+                                       <!-- <input id="DateToRes" type="text" class="form-control" placeholder="Reservation Date"> -->\r
+                               </div>\r
+                       </div>\r
                </div>\r
-               <div class="col-md-10">\r
-                       <div class="sliderContainer">\r
-                               <div id="tblSlider"></div>\r
+        <div class="col-md-8">\r
+               <div class="row">\r
+                       <div class="col-md-2">\r
+                       <label for="inputEmail3" class="control-label">Time of day:</label>\r
+                       </div>\r
+                       <div class="col-md-10">\r
+                                       <div class="sliderContainer">\r
+                                               <div id="tblSlider"></div>\r
+                                       </div>\r
+                               </div>\r
                        </div>\r
                </div>\r
     </div>\r
                                                        style="word-wrap: break-word; word-break: break-all; ">\r
                                                        {[{ resource.hostname }]}\r
                                                </th>\r
-                        <td ng-repeat="lease in resource.leases | offset: from / lcm_colspan  | limitTo: num_visible_cells / lcm_colspan"\r
+                        <td ng-repeat="lease in resource.leases | offset: from / (resource.granularity / slot_length)  | limitTo: num_visible_cells / (resource.granularity / slot_length)"\r
                                                        data-slotid="{[{ lease.id }]}" \r
                                                        data-groupid="{[{ lease.groupid }]}" \r
                                                        ng-class="{{ 'lease.status' }}"\r
-                                                       colspan="{[{resource.granularity / granularity}]}"\r
+                                                       ng-class="{{ 'lease.success' }}"\r
+                                                       colspan="{[{resource.granularity / slot_length}]}"\r
                                                        ng-click="select(from+$index, lease, $parent.resource)">\r
                                                </td>\r
                     </tr>\r
             <div class="legend">\r
                 <ol>\r
                     <li class="free">Free</li>\r
-                    <li class="pendingin">Pending selected</li>\r
-                    <li class="pendingout">Pending deselected</li>\r
-                    <li class="selected">Selected</li>\r
-                    <li class="closed">Reserved</li>\r
+                    <li class="selected">Reserved</li>\r
+                    <li class="pendingin">Reservation pending</li>\r
+                    <li class="pendingout">Reservation cancellation pending</li>\r
+                    <li class="closed">Unavailable</li>\r
+                                       <li class="disabled">Forbidden</li>\r
                     <li class="maintenance">Maintenance</li>\r
                 </ol>\r
             </div>\r
index c72f667..436dc0e 100644 (file)
@@ -2,13 +2,11 @@ from unfold.plugin import Plugin
 
 class TestbedsPlugin(Plugin):
     
-    def __init__ (self, query=None, query_networks=None, **settings):
+    def __init__ (self, query=None, **settings):
         Plugin.__init__ (self, **settings)
 
         # Until we have a proper way to access queries in Python
         self.query              = query
-        self.query_networks          = query_networks
-        self.query_networks_uuid     = query_networks.query_uuid if query_networks else None
 
     def template_file (self):
         return "testbeds.html"
@@ -28,7 +26,7 @@ class TestbedsPlugin(Plugin):
         # query_uuid will pass self.query results to the javascript
         # and will be available as "record" in :
         # on_new_record: function(record)
-        return ['plugin_uuid', 'domid', 'query_uuid', 'query_networks_uuid']
+        return ['plugin_uuid', 'domid', 'query_uuid']
 
     def export_json_settings (self):
         return True
index 623bc91..e628a67 100644 (file)
         /* Plugin instance */
         $scope.instance = null;
 
+        $scope.facility_names = Array();
+        $scope.testbed_names = new Object();
+
         /* Models */
-        $scope.testbeds = Array();
+        //$scope.testbeds = Array();
+        $scope._facility_active = new Object();
+        $scope._testbed_active  = new Object();
+
+        $scope.is_facility_active = function(facility)
+        {
+            return (($scope._facility_active[facility] === undefined) || $scope._facility_active[facility]);
+        };
+
+        $scope.is_testbed_active = function(facility, testbed)
+        {
+            return (($scope._testbed_active[facility] === undefined) || 
+                    ($scope._testbed_active[facility][testbed] === undefined) || 
+                    ($scope._testbed_active[facility][testbed]));
+        };
 
+        $scope.set_facility_active = function(facility, value)
+        {
+            $scope._facility_active[facility] = value;
+        };
+
+        $scope.set_testbed_active = function(facility, testbed, value)
+        {
+            if ($scope._testbed_active[facility] === undefined)
+                $scope._testbed_active[facility] = new Object();
+            $scope._testbed_active[facility][testbed] = value;
+        };
+    
         /* Click event */
-        $scope.select = function(testbed)
+
+        $scope.select_facility = function(facility)
         {
             var selected, prev_selected, num, num_selected, num_prev_selected, filter;
 
-            prev_selected = $.map($scope.testbeds, function(x, i) {
-                return x.active ? x.network_hrn : null;
+            prev_selected = $.map($scope.facility_names, function(x, i) {
+                return $scope.is_facility_active(x) ? x : null;
             });
 
-            testbed.active = !testbed.active;
+            $scope.set_facility_active(facility, ! $scope.is_facility_active(facility));
 
-            selected = $.map($scope.testbeds, function(x, i) {
-                return x.active ? x.network_hrn : null;
+            selected = $.map($scope.facility_names, function(x, i) {
+                return $scope.is_facility_active(x) ? x : null;
             });
 
-            num = $scope.testbeds.length;
+            num = $scope.facility_names.length;
+            prev_num_selected = prev_selected.length;
+            num_selected = selected.length;
+
+            if ((prev_num_selected != 0) && (prev_num_selected != num)) {
+                // Remove previous filter
+                filter = ['facility_name', 'included', prev_selected];
+                manifold.raise_event($scope.instance.options.query_uuid, FILTER_REMOVED, filter);
+            }
+
+            if (num_selected != num) {
+                filter = ['facility_name', 'included', selected];
+                manifold.raise_event($scope.instance.options.query_uuid, FILTER_ADDED, filter);
+            }
+        };
+
+        $scope.select_testbed = function(facility, testbed)
+        {
+            var selected, prev_selected, num, num_selected, num_prev_selected, filter;
+
+            prev_selected = Array();
+            $.each($scope.facility_names, function(i, facility_name) {
+                $.each($scope.testbed_names[facility_name], function(j, testbed_name) {
+                    if ($scope.is_testbed_active(facility_name, testbed_name)) {
+                        // XXX We should have a joint facility/testbed filter
+                        prev_selected.push(testbed_name);
+                    }
+                });
+
+            });
+
+            $scope.set_testbed_active(facility, testbed, ! $scope.is_testbed_active(facility, testbed));
+
+            selected = Array();
+            $.each($scope.facility_names, function(i, facility_name) {
+                $.each($scope.testbed_names[facility_name], function(j, testbed_name) {
+                    if ($scope.is_testbed_active(facility_name, testbed_name)) {
+                        // XXX We should have a joint facility/testbed filter
+                        selected.push(testbed_name);
+                    }
+                });
+
+            });
+
+            num = 0;
+            $.each($scope.facility_names, function(i, facility_name) {
+                num += $scope.testbed_names[facility_name].length;
+            });
             prev_num_selected = prev_selected.length;
             num_selected = selected.length;
 
-            
             if ((prev_num_selected != 0) && (prev_num_selected != num)) {
                 // Remove previous filter
-                filter = ['network_hrn', 'included', prev_selected];
+                // XXX We should have a joint facility/testbed filter
+                filter = ['testbed_name', 'included', prev_selected];
                 manifold.raise_event($scope.instance.options.query_uuid, FILTER_REMOVED, filter);
             }
 
-            if ((num_selected != 0) && (num_selected != num)) {
-                filter = ['network_hrn', 'included', selected];
+            if (num_selected != num) {
+                // XXX We should have a joint facility/testbed filter
+                filter = ['testbed_name', 'included', selected];
                 manifold.raise_event($scope.instance.options.query_uuid, FILTER_ADDED, filter);
             }
         };
             this._super(options, element);
 
             /* Member variables */
-            this.filters = Array();
             this.testbeds = Array();
 
             this._get_scope().instance = this;
         /* HANDLERS */
 
         /* When a filter is added/removed, update the list of filters local to the plugin */
+        /*
         on_filter_added: function(filter)
         {
             this.filters.push(filter);
                 }
             }
         },
-
+        */
         // ... be sure to list all events here
 
-        on_networks_query_done: function()
+        on_query_done: function()
         {
-             this.set_networks();
-        },
-
-/*
-            var self = this;
-            console.log('query network DONE');
-            $("[id^='testbeds-filter_']").on('click',function(e) {
-                $(this).toggleClass("active");
-
-                // avoid multiple calls when an event is raised to manifold.js
-                e.stopPropagation();
-
-                value = this.dataset['platform'];
-                // handle the hrn that include . in their name (has to be in sync with the data from SFA)
-                //value = value.replace(/\./g,"\\.");
-                key = "network_hrn";
-                op = "included";
-                return $(this).hasClass('active') ? self._addFilter(key, op, value) : self._removeFilter(key, op, value);
+            var scope, query_ext, resources;
+            scope = this._get_scope();
+            query_ext = manifold.query_store.find_analyzed_query_ext(this.options.query_uuid);
+            resources = query_ext.records.values();
+
+            $.each(resources, function(i, resource) {
+                if ($.inArray(resource.facility_name, scope.facility_names) == -1)
+                    scope.facility_names.push(resource.facility_name);
+                if (scope.testbed_names[resource.facility_name] === undefined)
+                    scope.testbed_names[resource.facility_name] = Array();
+                if ($.inArray(resource.testbed_name, scope.testbed_names[resource.facility_name]) == -1)
+                    scope.testbed_names[resource.facility_name].push(resource.testbed_name);
             });
-           
-        },*/
 
-        /* INTERNAL FUNCTIONS */
+            scope.$apply();
+        },
 
-        set_networks: function()
+        /*
+        on_networks_query_done: function()
         {
             var scope = this._get_scope();
             var query_ext = manifold.query_store.find_analyzed_query_ext(this.options.query_networks_uuid);
             $.each(scope.testbeds, function(i, testbed) { testbed.active = true });
             scope.$apply();
         },
+*/
+
+        /* INTERNAL FUNCTIONS */
 
         _get_scope : function()
         {
             return angular.element('[ng-controller=TestbedsCtrl]').scope()
         },
 
+/*
         _addFilter: function(key, op, value)
         {
             values = Array();
             // Update the filter with the new list of values, ex: [ple,nitos,wilab]
             manifold.raise_event(this.options.query_uuid, FILTER_ADDED, [key, op, values]);
         },
+
         _removeFilter: function(key, op, value)
         {
             console.log("remove "+value);
                 manifold.raise_event(this.options.query_uuid, FILTER_ADDED, [key, op, values]);
             }
         }
-
+*/
     });
 
     /* Plugin registration */
index 289a556..296e5ef 100644 (file)
@@ -1,16 +1,34 @@
 <div id={{ domid }} ng-controller="TestbedsCtrl">
 
-<div class="list-group-item sl-platform"><span class="list-group-item-heading">Testbeds</span></div>
+<div class="list-group-item sl-platform"><span class="list-group-item-heading">Facilities</span></div>
 
-<div ng-repeat="testbed in testbeds"
-     ng-click="select(testbed)">
+<div ng-repeat="facility_name in facility_names">
        <a href="#" 
           class="list-group-item sl-platform"
-       ng-class="{active: testbed.active}"
-          id="testbeds-filter_{[{ testbed.network_hrn }]}"
-          data-platform="{[{ testbed.network_hrn }]}">
-       <span class="list-group-item-heading">{[{ testbed.platform }]}</span>
-       <p class="list-group-item-heading">{[{ testbed.network_hrn }]}</p></a>
+          ng-class="{active: is_facility_active(facility_name)}"
+          id="facility-filter_{[{ facility_name }]}"
+          ng-click="select_facility(facility_name)"
+          data-platform="{[{ facility_name }]}">
+       <span class="list-group-item-heading">{[{ facility_name }]}</span>
+       </a>
+       <div ng-repeat="testbed_name in testbed_names[facility_name]">
+               <a href="#" 
+                  class="list-group-item sl-platform"
+                  ng-class="{active: is_testbed_active(facility_name, testbed_name)}"
+                  id="testbeds-filter_{[{ testbed_name }]}"
+                ng-click="select_testbed(facility_name, testbed_name)"
+                  data-platform="{[{ testbed_name }]}">
+               <span class="list-group-item-heading">&nbsp;&nbsp;{[{testbed_name}]}</span>
+               </a>
+       </div>
 </div>
 
+<!--
+<style>
+a.sl-platform  {
+    text-transform: uppercase;
+}
+
+</style>
+-->
 </div>
index ca96b6f..89b3ec5 100644 (file)
@@ -5,14 +5,21 @@ class Univbris(Plugin):
     def __init__ (self, query=None, **settings):
         Plugin.__init__ (self, **settings)
         self.query=query
+       self.query_uuid = query.query_uuid if query else None
+       print "called univbris plugin"
 
     def template_file (self):
-        return "univbris.html"
+        try:
+            return "univbris_welcome.html"
+        except Exception:
+                   print "error template"
 
     def requirements (self):
         reqs = {
-            'js_files' : [
-                'js/univbris.js'
+            'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js",
+                           "js/manifold.js", "js/manifold-query.js",
+                           "js/unfold-helper.js",
+                'js/univbris.js',
             ],
             'css_files': [
                 'css/univbris.css',
@@ -24,7 +31,7 @@ class Univbris(Plugin):
         # query_uuid will pass self.query results to the javascript
         # and will be available as "record" in :
         # on_new_record: function(record)
-        return ['plugin_uuid', 'domid', 'query_uuid']
+        return ['plugin_uuid', 'domid', 'query_uuid','init_key',]
 
     def export_json_settings (self):
         return True
index 4c84a90..a22201e 100644 (file)
@@ -1,6 +1,6 @@
 /**
- * univbris:    test plugin for Bristol University
- * Version:     0.1
+ * univbris:    test ofam plugin for Bristol University
+ * Version:     0.2
  * Description: just testing plugin in myslice
  * Requires:    js/plugin.js
  * URL:         http://www.myslice.info
 
     var Univbris = Plugin.extend({
 
-        /** XXX to check
-         * @brief Plugin constructor
-         * @param options : an associative array of setting values
-         * @param element : 
-         * @return : a jQuery collection of objects on which the plugin is
-         *     applied, which allows to maintain chainability of calls
-         */
         init: function(options, element) {
-            // Call the parent constructor, see FAQ when forgotten
             this._super(options, element);
-
-            /* Member variables */
-
-            /* Plugin events */
-
-            /* Setup query and record handlers */
-
-            // Explain this will allow query events to be handled
-            // What happens when we don't define some events ?
-            // Some can be less efficient
             this.listen_query(options.query_uuid);
-            this.listen_query(options.query_uuid, 'all');
-
-            /* GUI setup and event binding */
-            // call function
-
-           alert("univbris plugin 2");
 
         },
 
-        /* PLUGIN EVENTS */
-        // on_show like in querytable
-
-
-        /* GUI EVENTS */
-
-        // a function to bind events here: click change
-        // how to raise manifold events
-
-
-        /* GUI MANIPULATION */
-
-        // We advise you to write function to change behaviour of the GUI
-        // Will use naming helpers to access content _inside_ the plugin
-        // always refer to these functions in the remaining of the code
-
-        show_hide_button: function() 
-        {
-            // this.id, this.el, this.cl, this.elts
-            // same output as a jquery selector with some guarantees
-        },
+       on_query_done: function()
+       {
+         $("#univbris_welcome").hide();
+         jQuery("#univbris_flowspace_selection").show();
+       },
 
-        /* TEMPLATES */
-
-        // see in the html template
-        // How to load a template, use of mustache
-
-        /* QUERY HANDLERS */
-
-        // How to make sure the plugin is not desynchronized
-        // He should manifest its interest in filters, fields or records
-        // functions triggered only if the proper listen is done
-
-        // no prefix
-
-        on_filter_added: function(filter)
-        {
-
-        },
-
-        // ... be sure to list all events here
-
-        /* RECORD HANDLERS */
-        on_all_new_record: function(record)
-        {
-            //
-        },
-
-        /* INTERNAL FUNCTIONS */
-        _dummy: function() {
-            // only convention, not strictly enforced at the moment
-        },
 
     });
 
-    /* Plugin registration */
     $.plugin('Univbris', Univbris);
 
-    // TODO Here use cases for instanciating plugins in different ways like in the pastie.
-
 })(jQuery);
index f8aec26..64e50d1 100644 (file)
@@ -1,4 +1,2 @@
-<div id={{ domid }}>
-<h1><p>Bristol University Island Infrastructure Monitoring</p></h1>
-<p>information to follow</p>
-</div>
+<div id = "univbris_welcome"><center><h2><p>gathering information from testbeds</p></h2></center></div>
+
diff --git a/plugins/univbris/templates/univbris_welcome.html b/plugins/univbris/templates/univbris_welcome.html
new file mode 100644 (file)
index 0000000..09cc7b7
--- /dev/null
@@ -0,0 +1,2 @@
+<center><h2><p>...gathering information from testbeds...</p></h2></center>
+
index b732618..254fda2 100644 (file)
@@ -40,7 +40,7 @@ Current implementation makes the following assumptions
   as we use 'aoColumnDefs' instead.
 """
 
-    def __init__ (self, query=None, query_all=None, 
+    def __init__ (self, query=None, query_all=None, sync_query=None,
                   checkboxes=False, columns=None, 
                   init_key=None,
                   datatables_options={}, **settings):
@@ -49,6 +49,7 @@ Current implementation makes the following assumptions
         # Until we have a proper way to access queries in Python
         self.query_all      = query_all
         self.query_all_uuid = query_all.query_uuid if query_all else None
+       self.sync_query_uuid = sync_query.query_uuid if sync_query else None
         self.checkboxes     = checkboxes
         # XXX We need to have some hidden columns until we properly handle dynamic queries
         if columns is not None:
@@ -115,6 +116,6 @@ Current implementation makes the following assumptions
     # the list of things passed to the js plugin
     def json_settings_list (self):
         return ['plugin_uuid', 'domid', 
-                'query_uuid', 'query_all_uuid', 
+                'query_uuid', 'query_all_uuid', 'sync_query_uuid',
                 'checkboxes', 'datatables_options', 
                 'hidden_columns', 'init_key',]
index 22ba431..cbf72ae 100644 (file)
@@ -7,8 +7,12 @@
 (function($){
 
     var debug=false;
+    window.query_itr2=0;
+    table_links=[];
     //debug=true
 
+    regex_filter="((packet)|(compute))";
+
     var UnivbrisFoam = Plugin.extend({
 
         init: function(options, element) {
             /* Setup query and record handlers */
             this.listen_query(options.query_uuid);
             this.listen_query(options.query_all_uuid, 'all');
+           this.listen_query(options.sync_query_uuid,'sync');
 
             /* GUI setup and event binding */
             this.initialize_table();
+
+           jQuery( "#univbris_foam_ports_selection" ).hide();
            
         },
 
                 // Customize the position of Datatables elements (length,filter,button,...)
                 // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
                 //sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
-               sDom: "<'row'<'col-xs-2'l><'col-xs-9'r><'col-xs-2'f>>t<'row'<'col-xs-5'i><'col-xs-5'p>><'next'>",
+               sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-5'p>>",
                // XXX as of sept. 2013, I cannot locate a bootstrap3-friendly mode for now
                // hopefully this would come with dataTables v1.10 ?
                // in any case, search for 'sPaginationType' all over the code for more comments
                //self.hide_column(field);
             });
 
-           $('<button id="next" type="button" style="height: 50px; width: 300px" onclick="fnButnext()">select flowspace</button>').appendTo('div.next');
+           //$('<button id="next" type="button" style="height: 50px; width: 300px" onclick="fnButnext()">select flowspace</button>').appendTo('div.next');
 
            //type="submit"
 
                jQuery( "#univbris_flowspace_selection" ).show();
                //$("#multi_flowpspace_ports_selected").append('<label><input type="checkbox" name="option[]" value="1" />chocolate</label>');
 
-               $("form#uob_form :input[type=checkbox]").each(function(){
-                       var input = $(this); // This is the jquery object of the input, do what you will
-                       //alert("id: "+ input.attr('id') + " checked: "+ input.is(':checked'));
-                       if(input.is(':checked')==true){
-                               //alert("got true");
-                               $("#multi_flowpspace_ports_selected").append('<label><input type="checkbox" name="'+input.attr('id')+'" />'+input.attr('id')+'</label>');
-                       }
-               });
+               //$("form#uob_form :input[type=checkbox]").each(function(){
+               //      var input = $(this); // This is the jquery object of the input, do what you will
+               //      //alert("id: "+ input.attr('id') + " checked: "+ input.is(':checked'));
+               //      if(input.is(':checked')==true){
+               //              //alert("got true");
+               //              $("#multi_flowpspace_ports_selected").append('<label><input type="checkbox" name="'+input.attr('id')+'" />'+input.attr('id')+'</label>');
+               //      }
+               //});
 
                jQuery( "#univbris_foam_ports_selection" ).hide();
                //jQuery( "#univbris_flowspace_selection" ).hide();
             return result;
         }, 
 
+       fnLinkClick:function(link){
+               //console.log("link has been clicked: ");
+               //console.log(link.target.id);
+
+               var svg_links = svg.selectAll(".link");
+               for(var i=0;i<svg_links[0].length;i++){
+                       //console.log(svg_links[0][i].__data__.value);
+                       if(svg_links[0][i].__data__.value==link.target.id){
+                               //console.log("got clicked link in svg");
+                               //console.log(link);
+                               if(link.target.checked==true){
+                                       svg_links[0][i].style.stroke= 'black';
+                                       svg_links[0][i].style.strokeWidth= '5px';
+                               }
+                               else{
+                                       svg_links[0][i].style.stroke= '#ccc';
+                                       svg_links[0][i].style.strokeWidth= '4px';
+                               }
+                               //svg.transition();
+                               break;
+                       }
+       
+               }
+               //console.log(svg_links);
+       },
+
         fake_checkbox_html : function (record) {
            //alert("fake fun called");
             var result="";
         // set id - for retrieving from an id, or for posting events upon user's clicks
            result += " id='"+ record +"'";
            result += " name='"+ record +"'";
+           result += " class='checkboxlink'";
+           //result += " onclick=fnLinkClick(this)";
         // set init_id
            result += " init_id='" + record + "'";
         // wrap up
 
         new_record: function(record)
         {
-           
-        // this models a line in dataTables, each element in the line describes a cell
-            line = new Array();
-     
-            // go through table headers to get column names we want
-            // in order (we have temporarily hack some adjustments in names)
-            var cols = this.table.fnSettings().aoColumns;
-            var colnames = cols.map(function(x) {return x.sTitle})
-            var nb_col = cols.length;
-            /* if we've requested checkboxes, then forget about the checkbox column for now */
-            if (this.options.checkboxes) nb_col -= 1;
-
 
            var urn = record['urn'];
-           //alert(urn);
             var pos = urn.search('link');
-           //filter records to add links only  
            if (pos!=-1){
-                   //alert(urn);
                    var link = urn.substring(pos+5);
                    pos = link.search("_");
                    var head_node=link.substring(0,pos);
                    pos = link.search("_");
                    var tail_node=link.substring(0,pos);
                    link=link.substring(pos+1);
-                   //pos = link.search("_");
                    var tail_port=link;
                 
-                   
-                   //var head_node=urn.substring(pos+5,pos+28);
-                    //var head_port=urn.substring(pos+29,pos+31);
-                   //var tail_node=urn.substring(pos+32,pos+55);
-                   //var tail_port=urn.substring(pos+56,pos+58);
-                   
-                   //link type int 0-packet, 1-optical, 2-compute
-                   var link_type=0;
-                   if (urn.search('circuit')!=-1){
-                       link_type=1;
+                  
+                   var link_type="packet";
+
+                   if (urn.search('opticalpacket')!=-1){
+                       link_type='opticalpacket';
+                   }
+                   else if (urn.search('optical')!=-1){
+                       link_type='optical';
                    }
                    else if (urn.search('compute')!=-1){
-                       link_type=2;
+                       link_type='compute';
                    }
-
+                   else if (urn.search('federation')!=-1){
+                       link_type='federation';
+                   }
+                   
                    //get island name
                    pos = urn.search('ofam');
                    var testbed=urn.substring(pos+5);
                    testbed=testbed.substring(0, testbed.search('link')-1);
+           
+                   var found=false;
+                   for(i=0;i<table_links.length;i++){
+                               if((table_links[i].head_node==head_node && table_links[i].tail_node==tail_node && table_links[i].head_port==head_port && table_links[i].tail_port==tail_port) || 
+                                  (table_links[i].head_node==tail_node && table_links[i].tail_node==head_node && table_links[i].head_port==tail_port && table_links[i].tail_port==head_port)){
+                                       found=true;
+                                       break;
+                               }
+                   }
 
-                   //alert(urn);
+                   if (found == false){
+                               var tmp_link={};
+                               tmp_link['head_node']=head_node;
+                               tmp_link['tail_node']=tail_node;
+                               tmp_link['head_port']=head_port;
+                               tmp_link['tail_port']=tail_port;
+                               tmp_link['testbed']=testbed;
+                               tmp_link['link_type']=link_type;
+                               tmp_link['urn']=urn;
+                               table_links.push(tmp_link);
+                   }
+                          
+               }
 
-                   //alert("h: "+head_node+"/"+head_port);   
-                   //alert("t: "+tail_node+"/"+tail_port);
+       },
 
 
-                   //alert(colnames);
-                   /*replace production*/
-                   /* fill in stuff depending on the column name */
-                   for (var j = 0; j < nb_col; j++) {
+       process_records: function(link){
+
+        // this models a line in dataTables, each element in the line describes a cell
+            line = new Array();
+     
+            // go through table headers to get column names we want
+            // in order (we have temporarily hack some adjustments in names)
+            var cols = this.table.fnSettings().aoColumns;
+            var colnames = cols.map(function(x) {return x.sTitle})
+            var nb_col = cols.length;
+            /* if we've requested checkboxes, then forget about the checkbox column for now */
+            if (this.options.checkboxes) nb_col -= 1;
+           
+           for (var j = 0; j < nb_col; j++) {
                        if (typeof colnames[j] == 'undefined') {
                            line.push('...');
                        } else if (colnames[j] == 'testbed') {
-                          line.push(testbed);
+                          line.push(link.testbed);
                        } else if (colnames[j] == 'head node id/port') {
-                           line.push(head_node+"/"+head_port);
+                           line.push(link.head_node+"/"+link.head_port);
                        }
                          else if (colnames[j] == 'tail node id/port'){
-                           line.push(tail_node+"/"+tail_port);
+                           line.push(link.tail_node+"/"+link.tail_port);
                        }
                          else if (colnames[j] == 'link type'){
-                           switch (link_type){
-                               case 0:
-                                       line.push("packet");
-                                       break;
-
-                               case 1:
-                                       line.push("optical");
-                                       break;
-       
-                               case 2:
-                                       line.push("compute");
-                                       break;
-                           }
+                           line.push(link.link_type);
                        }
                          else if (colnames[j] == 'selected'){
                            
-                           line.push(this.fake_checkbox_html(urn));
+                           line.push(this.fake_checkbox_html(link.urn));
                        }
 
-                   }
-                  
-           
-                   // catch up with the last column if checkboxes were requested 
-                   if (this.options.checkboxes) {
+            }
+
+              // catch up with the last column if checkboxes were requested 
+           if (this.options.checkboxes) {
                        // Use a key instead of hostname (hard coded...)
                        line.push(this.checkbox_html(record));
-                       }
+           }
            
                    // adding an array in one call is *much* more efficient
                        // this.table.fnAddData(line);
-                       this.buffered_lines.push(line);
-
-           }
+           this.buffered_lines.push(line);
         },
 
         clear_table: function()
             alert('UnivbrisFoam::clear_fields() not implemented');
         },
 
+
+       /* sync query handler*/
+
+       on_sync_filter_added:function(filter)
+       {
+               //alert("sync query filter called");
+               this.filter=[];
+               this.on_filter_added(filter);
+       },
+
+        on_sync_filter_clear: function()
+        {
+            // XXX
+           this.filters=Array();
+            this.redraw_table();
+        },
+
+
+
+
         /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
         /*************************** ALL QUERY HANDLER ****************************/
 
         }, // on_all_query_in_progress
 
         on_all_query_done: function()
-        {
+        { 
            if (debug) messages.debug("1-shot initializing dataTables content with " + this.buffered_lines.length + " lines");
+           this.buffered_lines=[];     
+           for(var i=0;i<table_links.length;i++){
+               this.process_records(table_links[i]);
+           }
            this.table.fnAddData (this.buffered_lines);
            this.buffered_lines=[];
+           //alert(regex_filter)
+           /*try{
+               //this.table.column(3).search("packet",True,True).draw();
+               this.table.fnFilter(regex_filter,3,true);
+           }
+           catch (err){
+               alert(err);
+           }*/
            
             var self = this;
            // if we've already received the slice query, we have not been able to set 
              * Handle clicks on checkboxes: reassociate checkbox click every time
              * the table is redrawn 
              */
+           //alert(options);
             this.elts('querytable-checkbox').unbind('click').click(this, this._check_click);
-           this.elts("next").unbind('click').click(this, this.fnButnext);
-           
+          // this.elts("next").unbind('click').click(this, this.fnButnext);
+           $(".checkboxlink").unbind('click').click(this,this.fnLinkClick);
 
             if (!this.table)
                 return;
        } );
     }
 
+     /*function fnLinkClick(link){
+               console.log("link has been clicked: ");
+               console.log(link);
+       }*/
+
 })(jQuery);
 
index 81f2388..cbd01c8 100644 (file)
@@ -20,7 +20,7 @@
 <link rel='stylesheet' href='/static/css/bootstrap.css' type='text/css' />
 <link rel='stylesheet' href='/static/css/topmenu.css' type='text/css' />
 <script type='text/javascript' src='/static/js/logout.js'></script>
-<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script>
+<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script>
 <!-- <script type="text/javascript">/static/js/ui.widget.js</script> -->
 <script src="/static/js/jquery.notify.js" type="text/javascript"></script>
 <link rel='stylesheet' href='/static/css/ui.notify.css' type='text/css' />
index 7749397..89a65db 100644 (file)
@@ -19,4 +19,5 @@
     </tfoot> 
   </table>
  </form>
+  <div id="fvf_table_button" name="fvf_table_button"> </div>
 </div>
index a44a0ab..6c9aef2 100644 (file)
@@ -118,6 +118,6 @@ Current implementation makes the following assumptions
     # the list of things passed to the js plugin
     def json_settings_list (self):
         return ['plugin_uuid', 'domid', 
-                'query_uuid', 'query_all_uuid', 
+                'query_uuid', 'query_all_uuid',
                 'checkboxes', 'datatables_options', 
                 'hidden_columns', 'init_key',]
diff --git a/plugins/univbrisfv/__init__1.py b/plugins/univbrisfv/__init__1.py
deleted file mode 100644 (file)
index 73cd552..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-from unfold.plugin import Plugin
-
-class UnivbrisFv (Plugin):
-    """
-    ////////////////////////////////////////
-    modified querytable for univbris foam
-    ///////////////////////////////////////
-    """
-
-    def __init__ (self, init_key=None,datatables_options={}, **settings):
-        Plugin.__init__ (self, **settings)
-        self.columns = list (['switch dpid','port no<->peer dpid/port no.','selected'])
-        self.init_key=init_key
-        self.datatables_options=datatables_options
-
-    def template_file (self):
-        return "univbrisfv.html"
-
-    def template_env (self, request):
-        env={}
-        env.update(self.__dict__)
-        env['columns']=self.columns
-        return env
-
-    def requirements (self):
-        reqs = {
-            'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js", 
-                           "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
-                           "js/manifold.js", "js/manifold-query.js", 
-                           "js/unfold-helper.js",
-                           "js/univbrisfv.js", 
-                           ] ,
-            'css_files': [ "css/dataTables.bootstrap.css",
-                           "css/dataTables.full_numbers.css",
-                           "css/univbrisfv.css" , 
-                           ],}
-       return reqs
-
-    # the list of things passed to the js plugin
-    def json_settings_list (self):
-        return ['plugin_uuid', 'domid', 'datatables_options', 'init_key',]
index 82581ab..672a674 100644 (file)
 
     pk_flowspace_index=0;
     opt_flowspace_index=0;
+    pk_mode=0;
     fvf_add=1;
     fvf_nrow=0;
+    
 
     var UnivbrisFv = Plugin.extend({
 
 
         initialize_table: function() 
         {
+
+           
             /* Transforms the table into DataTable, and keep a pointer to it */
             var self = this;
+           //alert(self.options);
             var actual_options = {
                 // Customize the position of Datatables elements (length,filter,button,...)
                 // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
            $('<td><button id="submit_flowspace" type="button" style="height: 25px; width: 400px" onclick="fnButsubmit()">Define controller location</button></td></tr></table>').appendTo('div.buttons');**/
        
           
-           jQuery( "#univbris_flowspace_selection" ).hide();
+           //jQuery( "#univbris_flowspace_selection" ).hide();
 
              //$('<a href="http://localhost:8000/login/" id="next_link">next link</a>').appendTo('div.submit');
 
                //this.new_record("t");
                //this.new_record("t");
                this._querytable_draw_callback();
-       
+               jQuery("#univbris_flowspace_selection").hide(); 
                
 
         }, // initialize_table
 
 
        fnButsubmit:function(e){
-                alert("submitting"); 
-                var rows = $("#univbris_flowspace_selection__table").dataTable().fnGetNodes();
-                var cells=[];
-                for(var i=0;i<rows.length;i++){
-                       var htmlStr=$(rows[i]).find("td:eq(0)").html();
-                       var parser=new DOMParser();
-                       var htmlDoc=parser.parseFromString(htmlStr, "text/html");
-                       var para=htmlDoc.getElementsByTagName('p');
-                       if(typeof para.item(0).id != 'undefined'){
-                               cells.push(para.item(0).id);
+               console.log("verifying before submitting");
+
+               query_uuid=e.data.options.query_uuid;
+               try{
+
+                        var controller= $('#controller_loc').val();
+
+                        //validating controller field
+                        //alert (controller.length);
+                        if (controller.length>=7){
+                               //alert(controller.substring(0,4))
+                               if(controller.substring(0,4)=="tcp:" | controller.substring(0,4)=="ssl:"){
+                                       var controller_ip=controller.substring(4,controller.length);
+                                       //alert(controller_ip)
+                                       var index=controller_ip.indexOf(":")
+                                       if (index!=-1){
+                                               var controller_ip1=controller_ip.substring(0,index);
+                                               //alert(controller_ip1);
+                                               var ip_validator= /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; 
+                                               if (!controller_ip1.match(ip_validator)){
+                                                 throw "Incorrect IP format";
+                                               }
+                                               //else{
+                                               //  throw "incorrect ip";
+                                               //}
+
+                                               var controller_port=controller_ip.substring(index+1,controller_ip.length);
+                                               if(!isNaN(controller_port)){
+                                                       controller_port=parseInt(controller_port,10);
+                                                       if (!((controller_port >0) & (controller_port <65536))){
+                                                       //if(controller_port >0){
+                                                               throw "Incorrect controller port";
+                                                       }
+                                                       //else{
+                                                       //      throw "correct port";
+                                                       //}
+                                               }
+                                               else{
+                                                       throw "Incorrect controller port";
+                                               }
+                                       }
+                                       else{
+                                               throw "Incorrect controller specified";
+                                       } 
+                               }
+                               else{
+                                       throw "Controller must start with tcp: or ssl:";
+                               }
+
+                        }
+                        else{
+                           throw "Incorrect controller specified";
+                        }
+                        //end of validation of controller field
+        
+                        var rows = $("#univbris_flowspace_selection__table").dataTable().fnGetNodes();
+                        var cells=[];
+                        
+                        var json_rspec={};
+                        json_rspec["controller"]=controller;
+                        var groups_rspec=[];
+                        var matches_rspec=[];
+
+                        if (rows.length <=0) {
+                               throw "No Flowspace defined"
+                        }
+
+
+                        var queryStringToJSON = function (url) {
+                if (url === '') return '';
+                var pairs = (url || location.search).slice(1).split('&');
+                var result = {};
+                for (var idx in pairs) {
+                    if ($.isNumeric(idx)) {
+                           var pair = pairs[idx].split('=');
+                           if (!!pair[0]){
+                                       result[pair[0].toLowerCase()] = decodeURIComponent(pair[1].replace(/\+/g, " ") || '');
+                        }
+                    }
+                }
+                return result;
                        }
-                }
 
-               var controller= $('#controller_loc').val();
+                        for(var i=0;i<rows.length;i++){
+                               var htmlStr=$(rows[i]).find("td:eq(0)").html();
+                               var parser=new DOMParser();
+                               var htmlDoc=parser.parseFromString(htmlStr, "text/html");
+                               var para=htmlDoc.getElementsByTagName('p');
+                               if(typeof para.item(0).id != 'undefined'){
+                                       cells.push(para.item(0).id);
+                                       var m_form=para.item(0).id.split(",");
+                                       var result=queryStringToJSON("?"+m_form[0]);
+                                       matches_rspec.push(result);
+                                       //console.log(m_form[1]);
+                                       var result2=queryStringToJSON("?"+m_form[1]);
+                                       result2["flowspace_name"]=result["flowspace_name"];
+                                       groups_rspec.push(result2);
+                               }
+                        }
+
+                       json_rspec["groups"]=groups_rspec;
+                       json_rspec["matches"]=matches_rspec;    
+
+                       //console.log(JSON.stringify(json_rspec));
+
 
-               cells.push("controller="+controller);
+                       //var controller= $('#controller_loc').val();
 
-               var str="";             
+                       //cells.push("controller="+controller);
 
-               //Just for show: built output string 
-               for(var i=0;i<cells.length;i++){
-                       str+=cells[i]+"\n";
+                       
+                       
+
+                       //var str="";           
+
+                       //Just for show: built output string 
+                       //for(var i=0;i<cells.length;i++){
+                       //      str+=cells[i]+"\n";
+
+                       //}
+                   //alert(str);
+            data = {
+                state: STATE_SET,
+                key  : null,
+                op   : STATE_SET_ADD,
+                value: json_rspec 
+            }
+            manifold.raise_event(query_uuid, FIELD_STATE_CHANGED, data);
+
+                   //alert("sending to manifold backend to build rspec");
 
                }
-               alert(str);
-               alert("send to manifold backend to build rspec");               
+               catch(err){
+                       alert(err)
+               }
+               
+                               
        },
 
+
+
        fnAddflowspace:function(e){
+               query_uuid=e.data.options.query_uuid;
+               pk_mode=1;
+               hideFvfError();
+               var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+               var nodes = $('input',port_table.fnGetNodes());
+               for(var i=0;i<nodes.length;i++){
+                       nodes[i].checked=false;
+                       nodes[i].disabled=false;
+               }
+
                fvf_add=1;
                $("#uob_fv_table_form").trigger("reset");
-               this.table = $("#univbris_flowspace_selection__table").dataTable();
+               var port_table = $("#univbris_flowspace_selection__table").DataTable();
                //alert("table length" + this.table.fnGetNodes().length);       
                $("#flowspace_name").val("pk_flowspace_"+ pk_flowspace_index);
                //pk_flowspace_index=1+pk_flowspace_index;
-
                $("[id='addflowspaceform']").show();
                $("#uob_fv_table_form :input").prop("disabled", false);
-               $("[name='flowspace_name']").prop("disabled", true)
+               $("[name='flowspace_name']").prop("disabled", true);
                $("[id='cancel_addflowspaceform']").text('cancel');
-               $("[id='addflowspaceform'").text('add flowspace');
-               jQuery( "#univbris_flowspace_selection" ).hide();
-               jQuery("#uob_fv_table_form").show();            
+               $("[id='addflowspaceform']").text('add flowspace');
+               
+               try{
+                       manifold.raise_event(e.data.options.query_uuid,CLEAR_FILTERS);
+                       var filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("optical");
+                       manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter);
+               }
+               catch(err){
+                       alert("raise error:"+err);
+               }
+
+               var svg_links = svg.selectAll(".link");
+               for(var i=0;i<svg_links[0].length;i++){
+                       svg_links[0][i].style.stroke= '#ccc';
+                       svg_links[0][i].style.strokeWidth= '4px';
+               };
+
+
+               jQuery("#univbris_flowspace_selection").hide(); 
+               jQuery("#uob_fv_table_form").show();
+               jQuery( "#univbris_foam_ports_selection" ).show();
+               
+               
+               topoviewer_state={mode:"edit",link_type:"non-optical"};
+
+               jQuery('#topo_plugin').show();
+               
        },
 
        fnAddcflowspace:function(e){
-               this.table = $("#univbris_flowspace_selection__table").dataTable();
-               //alert("table length" + this.table.fnGetNodes().length);       
-               $("#flowspace_name").val("opt_flowspace_"+ opt_flowspace_index);
-               opt_flowspace_index=1+pk_flowspace_index;
+               pk_mode=0;
+               query_uuid=e.data.options.query_uuid;
+               hideFvfError();
+               var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+               var nodes = $('input',port_table.fnGetNodes());
+               for(var i=0;i<nodes.length;i++){
+                       nodes[i].checked=false;
+                       nodes[i].disabled=false;
+               }
+
+               $("#uob_ofv_table_form").trigger("reset");
+               $("#oflowspace_name").val("opt_flowspace_"+ opt_flowspace_index);
+               fvf_add=1;
+               $("[id='addflowspaceform']").show();
+               $("#uob_ofv_table_form :input").prop("disabled", false);
+               $("[name='oflowspace_name']").prop("disabled", true);
+               $("[id='cancel_addflowspaceform']").text('cancel');
+               $("[id='addflowspaceform']").text('add flowspace');
+
+               try{
+                       manifold.raise_event(e.data.options.query_uuid,CLEAR_FILTERS);
+                       var filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("packet");
+                       manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter);
+                       filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("compute");
+                       manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter);
+                       filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("federation");
+                       manifold.raise_event(e.data.options.query_uuid,FILTER_ADDED,filter);
+               }
+               catch(err){
+                       alert("raise error:"+err);
+               }
+
+               var svg_links = svg.selectAll(".link");
+               for(var i=0;i<svg_links[0].length;i++){
+                       svg_links[0][i].style.stroke= '#ccc';
+                       svg_links[0][i].style.strokeWidth= '4px';
+               };
+
                jQuery( "#univbris_flowspace_selection" ).hide();
-               jQuery("#uob_fv_table_form").show();            
+               jQuery("#uob_ofv_table_form").show();
+               jQuery( "#univbris_foam_ports_selection" ).show();
+
+
+
+               topoviewer_state={mode:"edit",link_type:"optical"};
+
+               jQuery("#topo_plugin").show();          
        },
 
        
 
        fnDelete:function(e){
                        e.preventDefault();
+                       //alert("delwete");
                        var nRow = $(this).parents('tr')[0];
                        this.table = $("#univbris_flowspace_selection__table").dataTable();
                        this.table.fnDeleteRow( nRow );
        },
 
-       fnEdit:function(e){
+       fnEdit:function(e){     
                        e.preventDefault();
                        fvf_add=0;
+                       hideFvfError();
                        
-                       var nRow = $(this).parents('tr')[0];
-                       fvf_nrow=nRow;
-                       var row= $("#univbris_flowspace_selection__table").dataTable().fnGetData(nRow);
-                       var parser=new DOMParser();
-                       var htmlDoc=parser.parseFromString(row[0], "text/html");
-                       //alert("html_doc"+htmlDoc);
-                       var para=htmlDoc.getElementsByTagName('p');
-
-                       //alert("test:"+ para.item(0).id);
+                       try{
+                               var nRow = $(this).parents('tr')[0];
+                               fvf_nrow=nRow;
+                               var row= $("#univbris_flowspace_selection__table").dataTable().fnGetData(nRow);
+                               var parser=new DOMParser();
+                               var htmlDoc=parser.parseFromString(row[0], "text/html");
+                               //alert("html_doc"+htmlDoc);
+                               var para=htmlDoc.getElementsByTagName('p');
+                       }
+                       catch(err){
+                               alert("error:"+err);
+
+                       }
+                       //alert("p id:"+ para.item(0).id);
+                       var m_form=para.item(0).id.split(",");
+                       //console.log(htmlDoc.getElementsByTagName('a'));
                        $("#uob_fv_table_form").trigger("reset");
                        $("#uob_fv_table_form :input").prop("disabled", false);
-                       //$("[name='flowspace_name']").prop("disabled", false);
-                       $("#uob_fv_table_form").deserialize(para.item(0).id);
+                       $("[name='flowspace_name']").prop("disabled", false);
+                       $("#uob_fv_table_form").deserialize(m_form[0]);
+
+                       try{
+                               deserializeDT(m_form[1]);
+                       }
+                       catch (err){
+                               alert("error:"+err);
+                       }
+
+                        var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                        var nodes = $('input',port_table.fnGetNodes());
+                        var svg_links = svg.selectAll(".link");
+
+                        for(n=0;n<nodes.length;n++){
+                               for(var i=0;i<svg_links[0].length;i++){
+                                       if(svg_links[0][i].__data__.value==nodes[n].id){
+                                               if(nodes[n].checked==true){
+                                                       svg_links[0][i].style.stroke= 'black';
+                                                       svg_links[0][i].style.strokeWidth= '5px';
+                                               }
+                                               else{
+                                                       svg_links[0][i].style.stroke= '#ccc';
+                                                       svg_links[0][i].style.strokeWidth= '4px';
+                                               }
+                                               break;
+                                       }
+                               }
+                               nodes[n].disabled=false;
+                       };
+                       
+                       //alert($("#flowspace_name").val());
+
+                       if  ($("#flowspace_name").val().search("pk")==0){
+                               topoviewer_state={mode:"edit",link_type:"non-optical"};
+                       }
+                       else{
+                               topoviewer_state={mode:"edit",link_type:"optical"};
+                       }
+
+                       
+                       
                        $("[name='flowspace_name']").prop("disabled", true);
                        $("[id='cancel_addflowspaceform']").prop("disabled", false);
                        $("[id='addflowspaceform']").prop("disabled", false);
-                       $("[id='addflowspaceform'").text('modify');
-                       $("[id='addflowspaceform'").show();
-                       jQuery("#univbris_flowspace_selection").hide();
+                       $("[id='addflowspaceform']").text('modify');
+                       $("[id='addflowspaceform']").show();                    
+                       jQuery( "#univbris_foam_ports_selection" ).show();                              
                        jQuery("#uob_fv_table_form").show();
+                       jQuery("#univbris_flowspace_selection").hide();
+                       jQuery('#topo_plugin').show();
+                       
        },
 
 
-       fnModflowspace:function(e){
-               alert("modify");
-               //pk_flowspace_index=1+pk_flowspace_index;
-               jQuery("#uob_fv_table_form").hide();
-               var sData=$("#uob_fv_table_form").find("input").serialize();
-               var form =serializeAnything("#uob_fv_table_form");
-               this.table = $("#univbris_flowspace_selection__table").dataTable();
-               flowspace=sData;
-               alert(form+"\n"+sData);
-               
-               var string = "<p id='"+form+"'> <a onclick=\'fnPopTable(\""+form+"\");'>"+$("#flowspace_name").val()+"</a></p>";
-               this.table.fnDeleteRow(fvf_nrow);       
-               this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
-               jQuery( "#univbris_flowspace_selection" ).show();
-               //onclick=\'fnEdit("test");\'
-               //alert("myserialise: "+form);          
-               //alert("added flowspace:" + sData);    
-       },
 
        
 
         on_all_query_done: function()
         {
            if (debug) messages.debug("1-shot initializing dataTables content with " + this.buffered_lines.length + " lines");
+
+
            this.table.fnAddData (this.buffered_lines);
            this.buffered_lines=[];
            
index 44d51af..8ddb249 100644 (file)
@@ -21,7 +21,7 @@
        <tr>
                <td align="center"><button id="add_flowspace" type="button" style="height: 25px; width: 300px;" onclick="fnAddflowspace()">Define another packet  flowspace</button></td>
 
-               <td align="center"><button id="add_opt_flowspace" type="button" style="height: 25px; width: 300px" onclick="fnAddcflowspace()" disabled>Define another optical  flowspace</button></td>'
+               <td align="center"><button id="add_opt_flowspace" type="button" style="height: 25px; width: 300px" onclick="fnAddcflowspace()">Define another optical  flowspace1111</button></td>'
 
        </tr>
 
index a21e524..0422bd7 100644 (file)
@@ -7,7 +7,9 @@
 (function($){
 
     var debug=false;
-    debug=true
+    debug=true;
+    sync_query_uuid="";
+
 
     var UnivbrisFvf = Plugin.extend({
 
        fnCancel:function(e){
                //var sData=$("#uob_fv_table_form").find("input").serialize();
                //alert("add flowspace:" + sData);
+               //alert("cancel"); 
+               jQuery("#uob_ofv_table_form").hide();
                jQuery("#uob_fv_table_form").hide();
+               jQuery( "#univbris_foam_ports_selection" ).hide();
                jQuery( "#univbris_flowspace_selection" ).show();
+               jQuery('#topo_plugin').hide();
+               /*var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+               var nodes = $('input',port_table.fnGetNodes());
+               for(var i=0;i<nodes.length;i++){
+                       nodes[i].checked=false;
+                       console.log(nodes[i].id);
+               }*/
+
        },
 
+
        fnAddflowspace:function(e){
-               if(fvf_add==1){
-                       pk_flowspace_index=1+pk_flowspace_index;
+               
+               e.stopPropagation();
+               //if(fvf_add==1){       
+                       jQuery("#uob_ofv_table_form").hide();
                        jQuery("#uob_fv_table_form").hide();
-                       var sData=$("#uob_fv_table_form").find("input").serialize();
-                       var form =serializeAnything("#uob_fv_table_form");
-                       this.table = $("#univbris_flowspace_selection__table").dataTable();
-                       flowspace=sData;
+
+                       if(pk_mode==1){
+                                                       
+                               var sData=$("#uob_fv_table_form").find("input").serialize();
+                               var form =serializeAnything("#uob_fv_table_form");
+                               var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                               var form2=$('input',port_table.fnGetNodes()).serialize();
+                               var nodes = $('input',port_table.fnGetNodes());
                
-                       var string = "<p id='"+form+"'> <a onclick=\'fnPopTable(\""+form+"\");'>"+$("#flowspace_name").val()+"</a></p>";        
+                               this.table = $("#univbris_flowspace_selection__table").dataTable();
+                               var val_status=validateFvfForm();
+                               if (val_status == true){
+                                       pk_flowspace_index=1+pk_flowspace_index;
+                                       flowspace=sData;
+                                       var m_form=form+","+form2;
+                                       var string = "<p id='"+m_form+"'> <a onclick=\'fnPopTable(\""+form+"\",\""+form2+"\");'>"+$("#flowspace_name").val()+"</a></p>";        
+                                       if(fvf_add==1){
+                                               this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
+                                       }
+                                       else{
+                                               this.table.fnDeleteRow(fvf_nrow);       
                        this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
-                       jQuery( "#univbris_flowspace_selection" ).show();
-               }
+                                       }
+                                       jQuery( "#univbris_foam_ports_selection" ).hide();
+                                       jQuery( "#univbris_flowspace_selection" ).show();
+                                       jQuery('#topo_plugin').hide();
+                               }
+                               else{
+                                       alert("validation failed");
+                                       jQuery("#uob_fv_table_form").show();
+                                       jQuery("#uob_ofv_table_form").hide();
+                                       jQuery( "#univbris_foam_ports_selection" ).show();
+                               }
+                       }
+                       else{
+                                                       
+                               var sData=$("#uob_ofv_table_form").find("input").serialize();
+                               var form =serializeAnything("#uob_ofv_table_form");
+                               var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                               var form2=$('input',port_table.fnGetNodes()).serialize();
+                               var nodes = $('input',port_table.fnGetNodes());
+               
+                               this.table = $("#univbris_flowspace_selection__table").dataTable();
+                               
+                               var val_status=validateoFvfForm();
+                               if (val_status == true){
+                                       opt_flowspace_index=1+opt_flowspace_index;
+                                       flowspace=sData;
+                                       var m_form=form+","+form2;
+                                       var string = "<p id='"+m_form+"'> <a onclick=\'fnPopTable(\""+form+"\",\""+form2+"\");'>"+$("#oflowspace_name").val()+"</a></p>";       
+                                       if(fvf_add==1){
+                                               this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
+                                       }
+                                       else{
+                                               this.table.fnDeleteRow(fvf_nrow);       
+                       this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
+                                       }
+                                       jQuery( "#univbris_foam_ports_selection" ).hide();
+                                       jQuery( "#univbris_flowspace_selection" ).show();
+                                       jQuery('#topo_plugin').hide();
+                               }
+                               else{
+                                       alert("validation failed");
+                                       jQuery("#uob_ofv_table_form").show();
+                                       jQuery("#uob_fv_table_form").hide();
+                                       jQuery( "#univbris_foam_ports_selection" ).show();
+                               }
+
+                       }
+               /*}
                else{
                        jQuery("#uob_fv_table_form").hide();
+                       jQuery("#uob_ofv_table_form").hide();
                        var sData=$("#uob_fv_table_form").find("input").serialize();
                        var form =serializeAnything("#uob_fv_table_form");
+                       //var form2=serializeAnything("#uob_form");
+
+                       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                       var form2=$('input',port_table.fnGetNodes()).serialize();
                        this.table = $("#univbris_flowspace_selection__table").dataTable();
                        flowspace=sData;
-                       
-                       var string = "<p id='"+form+"'> <a onclick=\'fnPopTable(\""+form+"\");'>"+$("#flowspace_name").val()+"</a></p>";
+                       var m_form=form+","+form2;
+                       var string = "<p id='"+m_form+"'> <a onclick=\'fnPopTable(\""+form+"\",\""+form2+"\");'>"+$("#flowspace_name").val()+"</a></p>";
                        this.table.fnDeleteRow(fvf_nrow);       
                        this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
+                       
+                       jQuery( "#univbris_foam_ports_selection" ).hide();
                        jQuery( "#univbris_flowspace_selection" ).show();
+                       jQuery('#topo_plugin').hide();
                
-               }
+               }*/
        },
 
 
-       fnModflowspace:function(e){
-               //alert("modify");
-
-               jQuery("#uob_fv_table_form").hide();
-               var sData=$("#uob_fv_table_form").find("input").serialize();
-               var form =serializeAnything("#uob_fv_table_form");
-               this.table = $("#univbris_flowspace_selection__table").dataTable();
-               flowspace=sData;
-               alert(form+"\n"+sData);
-               
-               var string = "<p id='"+form+"'> <a onclick=\'fnPopTable(\""+form+"\");'>"+$("#flowspace_name").val()+"</a></p>";
-               this.table.fnDeleteRow(fvf_nrow);       
-               this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
-               jQuery( "#univbris_flowspace_selection" ).show();
-       },
-
         /**
          * @brief Determine index of key in the table columns 
          * @param key
                     line.push("first");
                }
                
-
-               /*if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'hostname') {
-                    if (record['type'] == 'resource,link')
-                        //TODO: we need to add source/destination for links
-                        line.push('');
-                    else
-                        line.push(record['hostname']);
-
-                } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
-                    line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record['hrn']);
-                } else {
-                    if (record[colnames[j]])
-                        line.push(record[colnames[j]]);
-                    else
-                        line.push('');
-                }*/
             }
     
             // catch up with the last column if checkboxes were requested 
                $("#addflowspaceform").unbind('click').click(this, this.fnAddflowspace);
            }
            else{
-               $("[id='addflowspaceform'").unbind('click').click(this, this.fnModflowspace);
+               $("[id='addflowspaceform']").unbind('click').click(this, this.fnModflowspace);
            }
-           $("#cancel_addflowspaceform").unbind('click').click(this,this.fnCancel);
+           $("#cancel_addflowspaceform").unbind('click').click(this,this.fnCancel); 
 
             if (!this.table)
                 return;
 })(jQuery);
 
 
+function deserializeDT(d){
 
-function fnPopTable(e){
-               //alert("e: "+e);
-               //this.table = $("#univbris_flowspace_selection__table").dataTable();
-               //alert(this.table);
-                /**var rows = $("#univbris_flowspace_selection__table").dataTable().fnGetNodes();
-               for(var i=0;i<rows.length;i++)
-               {
-                       alert($(rows[i]).find("td:eq(0)").html()); 
-               }
-               **/
+       try{
+           var data = d,
+                currentDom,
+                $current = null,
+                $currentSavedValue = null,
+                $self = this,
+                i = 0,
+                keyValPairString = [],
+                keyValPairObject = {},
+                tmp = null,
+                defaults = null;
 
+            if (data.constructor === String) {
 
-               //var anSelected = fnGetSelected( this.table );
-               //var iRow = oTable.fnGetPosition( anSelected[0] );
-               //alert(iRow);
 
-               //var rowIndex = this.table.fnGetPosition( $(this).closest('tr')[0]);
-               //alert(rowIndex);
-                $("[id='addflowspaceform']").hide();
-               $("#uob_fv_table_form :input").prop("disabled", false);
-               $("#uob_fv_table_form").deserialize(e);
-                $("[name='flowspace_name']").prop("disabled", true)
-               $("#uob_fv_table_form :input").prop("disabled", true);
-               $("[id='cancel_addflowspaceform']").prop("disabled", false);
-               $("[id='cancel_addflowspaceform']").text('close');
-               //$("[id='addflowspaceform'").hide();
+                data = decodeURIComponent(data.replace(/\+/g, " "));
+
+                keyValPairString = data.split('&');
+
+                for (i = 0; i < keyValPairString.length; i++) {
+                    tmp = keyValPairString[i].split('=');
+                    keyValPairObject[tmp[0]] = tmp[1];
+
+                }
+            }
+
+         var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+         var nodes = $('input',port_table.fnGetNodes());
+
+
+         for(i=0;i<nodes.length;i++){
+                       $currentSavedValue = keyValPairObject[nodes[i].id];
+                       if ($currentSavedValue === undefined){
+                               nodes[i].checked=false;
+                       }
+                       else{
+                               nodes[i].checked=true;
+                       }
+         };
+
+       }
+       catch(err){
+               alert(err);
+       }
+
+          
+};
+
+
+function fnPopTable(form1,form2){
+               hideFvfError();
                jQuery("#univbris_flowspace_selection").hide();
-               jQuery("#uob_fv_table_form").show();
+                $("[id='addflowspaceform']").hide();
+               
+               deserializeDT(form2);
+
+
+                //$("[name='flowspace_name']").prop("disabled", true);
+               //$("#uob_fv_table_form :input").prop("disabled", true);
+               //$("[id='cancel_addflowspaceform']").prop("disabled", false);
+               //$("[id='cancel_addflowspaceform']").text('close');
+
+               var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+               var nodes = $('input',port_table.fnGetNodes());
+               for(var i=0;i<nodes.length;i++){
+                       nodes[i].disabled=true;
+               }
+
+               if (form1.search('pk_flowspace')!=-1){
+                       pk_mode=1;
+               }
+               else{
+                       pk_mode=0;
+               }
+               
+
+               if  (pk_mode==1){
+                       try{
+                               manifold.raise_event(sync_query_uuid,CLEAR_FILTERS);
+                               var filter=[];
+                               filter.push("link type");
+                               filter.push("!=");
+                               filter.push("optical");
+                               manifold.raise_event(sync_query_uuid,FILTER_ADDED,filter);
+                       }
+                       catch(err){
+                               alert("raise error:"+err);
+                       }
+                       $("#uob_fv_table_form :input").prop("disabled", false);
+                       $("#uob_fv_table_form").deserialize(form1);
+                       $("[name='flowspace_name']").prop("disabled", true);
+                       $("#uob_fv_table_form :input").prop("disabled", true);
+                       $("[id='cancel_addflowspaceform']").prop("disabled", false);
+                       $("[id='cancel_addflowspaceform']").text('close');
+                       topoviewer_state={mode:"read",link_type:"non-optical"};
+                       jQuery("#uob_fv_table_form").show();
+               }
+               else{
+
+                       try{
+                               manifold.raise_event(sync_query_uuid,CLEAR_FILTERS);
+                               var filter=[];
+                               filter.push("link type");
+                               filter.push("!=");
+                               filter.push("packet");
+                               manifold.raise_event(sync_query_uuid,FILTER_ADDED,filter);
+                               filter=[];
+                               filter.push("link type");
+                               filter.push("!=");
+                               filter.push("compute");
+                               manifold.raise_event(sync_query_uuid,FILTER_ADDED,filter);
+                               filter=[];
+                               filter.push("link type");
+                               filter.push("!=");
+                               filter.push("federation");
+                               manifold.raise_event(sync_query_uuid,FILTER_ADDED,filter);
+                       }
+                       catch(err){
+                               alert("raise error:"+err);
+                       }
+                       $("#uob_ofv_table_form :input").prop("disabled", false);
+                       $("#uob_ofv_table_form").deserialize(form1);
+                       $("[name='oflowspace_name']").prop("disabled", true);
+                       $("#uob_ofv_table_form :input").prop("disabled", true);
+                       $("[id='cancel_addflowspaceform']").prop("disabled", false);
+                       $("[id='cancel_addflowspaceform']").text('close');
+                       topoviewer_state={mode:"read",link_type:"optical"};
+                       jQuery("#uob_ofv_table_form").show();
+               }
+
+               var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+               var nodes = $('input',port_table.fnGetNodes());
+               var svg_links = svg.selectAll(".link");
+
+               for(n=0;n<nodes.length;n++){
+                               for(var i=0;i<svg_links[0].length;i++){
+                                       if(svg_links[0][i].__data__.value==nodes[n].id){
+                                               if(nodes[n].checked==true){
+                                                       svg_links[0][i].style.stroke= 'black';
+                                                       svg_links[0][i].style.strokeWidth= '5px';
+                                               }
+                                               else{
+                                                       svg_links[0][i].style.stroke= '#ccc';
+                                                       svg_links[0][i].style.strokeWidth= '4px';
+                                               }
+                                               break;
+                                       }
+                               }
+                               nodes[n].disabled=false;
+               };
+
+
+               jQuery( "#univbris_foam_ports_selection" ).show();
+               jQuery('#topo_plugin').show();
+};
+
+function macValidator (mac_str){
+       if (mac_str != ""){
+               var mac_validator=/(^(([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2}))$)|(^(([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})))$/;
+               var result =mac_str.match(mac_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else{
+               return true;
+       }
+};
+
+function ethertypeValidator (eth_str){
+       if (eth_str != ""){
+               var ethertype_validator=/^0x[0-9a-fA-F]{4}$/;
+               var result = eth_str.match(ethertype_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else{
+               return true;
+       }
+};
+
+
+function vlanValidator (vlan_str){
+       if (vlan_str != ""){
+               var vlan_validator=/(^[1-9][0-9]{0,2}|[1-3][0-9]{3}|40[0-8][0-9]|409[0-5]$)/;
+               var result = vlan_str.match(vlan_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }
+};
+
+function ipValidator(ip_str){
+       if (ip_str != ""){
+               var ip_validator=/(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$)/;
+               var result = ip_str.match(ip_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }
 };
 
 
+function portValidator (port_str){
+       if (port_str != ""){
+               var port_validator=/^([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/;
+               var result = port_str.match(port_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }       
+}
+
+function ipProtoValidator (ipproto_str){
+       if (ipproto_str != ""){
+               var ipproto_validator=/(^[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]$)/;
+               var result = ipproto_str.match(ipproto_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }       
+}
+
+function wavelengthValidator (wavelength_str){
+               var wavelength_validator=/^\d+.?\d*$/;
+               var result = wavelength_str.match(wavelength_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+}
+
+
+
+
+
+
+
+
+function validateFvfForm(){
+       var status = false;
+       var checked =0;
+
+       //row 1 validation
+       if (macValidator ($("#uob_fv_table_dl_src_start").val())==false){
+               $("#uob_fv_table_dl_src_start").addClass('error');
+               $("#uob_fv_table_dl_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (macValidator ($("#uob_fv_table_dl_src_end").val())==false){
+               $("#uob_fv_table_dl_src_end").addClass('error');
+               $("#uob_fv_table_dl_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 2 validation
+
+       if (macValidator ($("#uob_fv_table_dl_dst_start").val())==false){
+               $("#uob_fv_table_dl_dst_start").addClass('error');
+               $("#uob_fv_table_dl_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (macValidator ($("#uob_fv_table_dl_dst_end").val())==false){
+               $("#uob_fv_table_dl_dst_end").addClass('error');
+               $("#uob_fv_table_dl_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 3 validation
+       
+       if (ethertypeValidator ($("#uob_fv_table_dl_type_start").val())==false){
+               $("#uob_fv_table_dl_type_start").addClass('error');
+               $("#uob_fv_table_dl_type_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ethertypeValidator ($("#uob_fv_table_dl_type_end").val())==false){
+               $("#uob_fv_table_dl_type_end").addClass('error');
+               $("#uob_fv_table_dl_type_error").show();
+       }
+       else {
+               checked++;
+       }
+
+
+       //row 4 validation
+       if (vlanValidator ($("#uob_fv_table_vlan_id_start").val())==false){
+               $("#uob_fv_table_vlan_id_start").addClass('error');
+               $("#uob_fv_table_vlan_id_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (vlanValidator ($("#uob_fv_table_vlan_id_end").val())==false){
+               $("#uob_fv_table_vlan_id_end").addClass('error');
+               $("#uob_fv_table_vlan_id_error").show();
+       }
+       else {
+               checked++;
+       }
+       //row 5 validation
+       if (ipValidator ($("#uob_fv_table_nw_src_start").val())==false){
+               $("#uob_fv_table_nw_src_start").addClass('error');
+               $("#uob_fv_table_nw_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ipValidator ($("#uob_fv_table_nw_src_end").val())==false){
+               $("#uob_fv_table_nw_src_end").addClass('error');
+               $("#uob_fv_table_nw_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 6 validation
+       if (ipValidator ($("#uob_fv_table_nw_dst_start").val())==false){
+               $("#uob_fv_table_nw_dst_start").addClass('error');
+               $("#uob_fv_table_nw_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ipValidator ($("#uob_fv_table_nw_dst_end").val())==false){
+               $("#uob_fv_table_nw_dst_end").addClass('error');
+               $("#uob_fv_table_nw_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+
+
+       //row 7 validation
+
+       if (ipProtoValidator ($("#uob_fv_table_nw_proto_start").val())==false){
+               $("#uob_fv_table_nw_proto_start").addClass('error');
+               $("#uob_fv_table_nw_proto_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ipProtoValidator ($("#uob_fv_table_nw_proto_end").val())==false){
+               $("#uob_fv_table_nw_proto_end").addClass('error');
+               $("#uob_fv_table_nw_proto_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 8 validation
+       if (portValidator ($("#uob_fv_table_tp_src_start").val())==false){
+               $("#uob_fv_table_tp_src_start").addClass('error');
+               $("#uob_fv_table_tp_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (portValidator ($("#uob_fv_table_tp_src_end").val())==false){
+               $("#uob_fv_table_tp_src_end").addClass('error');
+               $("#uob_fv_table_tp_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 9 validation
+       if (portValidator ($("#uob_fv_table_tp_dst_start").val())==false){
+               $("#uob_fv_table_tp_dst_start").addClass('error');
+               $("#uob_fv_table_tp_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (portValidator ($("#uob_fv_table_tp_dst_end").val())==false){
+               $("#uob_fv_table_tp_dst_end").addClass('error');
+               $("#uob_fv_table_tp_dst_error").show();
+       }
+       else {
+               checked++;
+       }/**/
+
+       //validate that at least one port is selected
+       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+       var nodes = $('input',port_table.fnGetNodes());
+
+       var port_selected=false;
+       for(var i=0;i<nodes.length;i++){
+               if(nodes[i].checked==true){
+                       checked++;
+                       port_selected=true;
+                       break;
+               }                       
+       }
+
+       if (checked >= 19) {
+               status=true;
+       }
+
+       if (port_selected==false & checked == 18){
+               alert("you need to select at least one port");
+       }
+       else if (port_selected==false & checked <= 18){
+               alert("you need to select at least one port and correct other flowspace parameter errors");
+       }
+       else if (port_selected==true & checked <= 18){
+               alert("you need to correct other flowspace parameter errors");
+       }
+       
+       //alert("validator status:"+status+" checked:"+checked);
+       return status;
+}
+
+function validateoFvfForm(){
+       var status = false;
+       var checked =0;
+
+       //row 1 validation
+       if (wavelengthValidator($('#uob_ofv_table_wavelength').val())==false){
+               $("#uob_ofv_table_wavelength").addClass('error');
+               $("#uob_ofv_table_wavelength_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       
+
+       //validate that at least one port is selected
+       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+       var nodes = $('input',port_table.fnGetNodes());
+
+       var port_selected=false;
+       for(var i=0;i<nodes.length;i++){
+               if(nodes[i].checked==true){
+                       checked++;
+                       port_selected=true;
+                       break;
+               }                       
+       }
+
+       if (checked >= 2) {
+               status=true;
+       }
+
+       if (port_selected==false & checked == 1){
+               alert("you need to select at least one port");
+       }
+       else if (port_selected==false & checked <= 1){
+               alert("you need to select at least one port and correct other flowspace parameter errors");
+       }
+       else if (port_selected==true & checked <= 1){
+               alert("you need to correct other flowspace parameter errors");
+       }
+       
+       //alert("validator status:"+status+" checked:"+checked);
+       return status;
+}
+
+
 
 function fnGetSelected( oTableLocal )
 {
@@ -777,7 +1311,28 @@ function serializeAnything (form){
                });
 
                return toReturn.join("&").replace(/%20/g, "+");
+}
+
+function hideFvfError(){
+       $("[id*=_error]").hide();
+       console
+       $("#uob_fv_table_form :input").each(function(){
+               try{
+                       $(this).removeClass('error');
+               }
+               catch (err){
+               }
+
+       });
+
+       $("#uob_ofv_table_form :input").each(function(){
+               try{
+                       $(this).removeClass('error');
+               }
+               catch (err){
+               }
 
+       });
 }
 
 
index 44d51af..d6900f6 100644 (file)
@@ -21,7 +21,7 @@
        <tr>
                <td align="center"><button id="add_flowspace" type="button" style="height: 25px; width: 300px;" onclick="fnAddflowspace()">Define another packet  flowspace</button></td>
 
-               <td align="center"><button id="add_opt_flowspace" type="button" style="height: 25px; width: 300px" onclick="fnAddcflowspace()" disabled>Define another optical  flowspace</button></td>'
+               <td align="center"><button id="add_opt_flowspace" type="button" style="height: 25px; width: 300px" onclick="fnAddcflowspace()">Define another optical  flowspace</button></td>'
 
        </tr>
 
index 63973cb..bb531c5 100644 (file)
@@ -9,22 +9,37 @@
 .multiselect label {
     display:block;
 }
- l
 .multiselect-on {
     color:#ffffff;
     background-color:#000099;
 }
+
+.error{
+border:2px solid red;
+}
+
 </style>
 
 <form id="uob_fv_table_form">
   <table id='uob_fv_table'>
                        <tr>
                                <th><strong>Flowspace Name</strong></th>
-                               <td COLSPAN="2">
-                                       <input id="flowspace_name" type="text" name="flowspace_name" maxlength="20" title="Flowspace name" disabled="disabled" />
+                               <td colspan="2">
+                                       <input id="flowspace_name" type="text" style="width:100%;" name="flowspace_name" maxlength="20" title="Flowspace name" disabled="disabled" />
                                        
                                </td>
                           </tr>
+                          </p>
+                          <tr>
+                               <th></th>
+                               <td>
+                                       <center>from</center>
+                               </td>
+                               <td>
+                                       <center>to</center>
+                               </td>
+                           </tr>
                            <tr>
                                <th><strong>MAC Source</strong></th>
                                <td>
                                        <label for="uob_fv_table_dl_src_end"></label>
                                        <input id="uob_fv_table_dl_src_end" type="text" name="uob_fv_table_dl_src_end" maxlength="17" title="Link layer source address range end"/>
                                </td>
+
+                               <td>
+                                       <p id="uob_fv_table_dl_src_error" > mac format should be ff:ff:ff:ff:ff:ff </p> 
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>MAC Destination</strong></th>
                                        <input id="uob_fv_table_dl_dst_start" type="text" name="uob_fv_table_dl_dst_start" maxlength="17" title="Link layer destination address range start"/>
                                </td>
                                <td>
-                                       
                                        <label for="uob_fv_table_dl_dst_end"></label>
                                        <input id="uob_fv_table_dl_dst_end" type="text" name="uob_fv_table_dl_dst_end" maxlength="17" title="Link layer destination address range end"/>
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_dl_dst_error" > mac format should be ff:ff:ff:ff:ff:ff </p> 
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>Ethernet Type</strong></th>
@@ -63,6 +84,9 @@
                                        <label for="uob_fv_table_dl_type_end"></label>
                                        <input type="text" name="uob_fv_table_dl_type_end" id="uob_fv_table_dl_type_end" title="Link layer type range end"/>
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_dl_type_error" > dl type format should be hex format: 0xffff</p>    
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>VLAN ID</strong></th>
                                        <label for="uob_fv_table_vlan_id_end"></label>
                                        <input type="text" name="uob_fv_table_vlan_id_end" value="25" id="uob_fv_table_vlan_id_end" title="VLAN ID range end" />
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_vlan_id_error" > vlan value should be integer between 1 and 4095 </p>       
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>IP Source</strong></th>
                                        <label for="uob_fv_table_nw_src_end"></label>
                                        <input type="text" name="uob_fv_table_nw_src_end" id="uob_fv_table_nw_src_end" title="Network source address range end"/>
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_nw_src_error" > ip format should be xxx.xxx.xxx.xxx </p>    
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>IP Destination</strong></th>
                                        <label for="uob_fv_table_nw_dst_end"></label>
                                        <input type="text" name="uob_fv_table_nw_dst_end" value="192.168.1.31" id="uob_fv_table_nw_dst_end" title="Network destination address range end"/>
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_nw_dst_error" > ip format should be xxx.xxx.xxx.xxx </p>    
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>IP Protocol</strong></th>
                                        <label for="uob_fv_table_nw_proto_end"></label>
                                        <input type="text" name="uob_fv_table_nw_proto_end" id="uob_fv_table_nw_proto_end" title="Network protocol range end"/>
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_nw_proto_error" > ip protocol should be integer between 0 and 255 </p>      
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>TCP/UDP Source</strong></th>
                                        <label for="uob_fv_table_tp_src_end"></label>
                                        <input type="text" name="uob_fv_table_tp_src_end" id="uob_fv_table_tp_src_end" title="Transport source port range end" />
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_tp_src_error" > tcp value should be integer between 0 and 65535 </p>        
+                               </td>
                            </tr>
                            <tr>
                                <th><strong>TCP/UDP Destination</strong></th>
                                        <label for="uob_fv_table_tp_dst_end"></label>
                                        <input type="text" name="uob_fv_table_tp_dst_end" id="uob_fv_table_tp_dst_end" title="Transport destination port range end"/>
                                </td>
+                               <td>
+                                       <p id="uob_fv_table_tp_dst_error" > tcp value should be integer between 0 and 65535 </p>        
+                               </td>
                            </tr>
                            <tr>
                            </tr>
-                           <tr>
-                               <th><strong>Ports</strong></th>
-                               <td COLSPAN="2">
-                                       
-                                       <label for="uob_fv_table_slivers"></label>
-                                       <div class="multiselect" id="multi_flowpspace_ports_selected">
-                                       </div>
-                               </td>
-                           </tr>
+
   </table>
-  <div id="fvf_table_button" name="fvf_table_button"> </div>
  </form>
 
diff --git a/plugins/univbrisfvfo/__init__.py b/plugins/univbrisfvfo/__init__.py
new file mode 100644 (file)
index 0000000..b774fae
--- /dev/null
@@ -0,0 +1,87 @@
+from unfold.plugin import Plugin
+
+class UnivbrisFvfo (Plugin):
+
+    """
+
+////////////////////////////////////////
+
+modified querytable for univbris foam
+///////////////////////////////////////
+
+A plugin for displaying a query as a list
+
+More accurately, we consider a subject entity (say, a slice) 
+that can be linked to any number of related entities (say, resources, or users)
+The 'query' argument will correspond to the subject, while
+'query_all' will fetch the complete list of 
+possible candidates for the relationship.
+
+Current implementation makes the following assumptions
+* query will only retrieve for the related items a list of fields
+  that corresponds to the initial set of fields displayed in the table
+* query_all on the contrary is expected to return the complete set of 
+  available attributes that may be of interest, so that using a QueryEditor
+  one can easily extend this table without having to query the backend
+* checkboxes is a boolean flag, set to true if a rightmost column
+  with checkboxes is desired
+* optionally pass columns as the initial set of columns
+  if None then this is taken from the query's fields
+* init_key is the name of a column that should appear in both queries
+  and used internally in the plugin for checkboxes initialization. 
+  If not specified, metadata will be used to find out a primary key.
+  However in the case of nodes & slice for example, the default key
+  as returned by the metadata would be 'urn', but 'urn' could only 
+  be used for this purpose if it gets displayed initially, which is
+  not necessarily a good idea.
+  This is why a slice view would use 'hrn' here instead.
+* datatables_options are passed to dataTables as-is; 
+  however please refrain from passing an 'aoColumns' 
+  as we use 'aoColumnDefs' instead.
+"""
+
+    def __init__ (self, query=None, query_all=None, 
+                  checkboxes=False, columns=None, 
+                  init_key=None,
+                  datatables_options={}, **settings):
+        Plugin.__init__ (self, **settings)
+        self.query          = query
+        # Until we have a proper way to access queries in Python
+        self.query_all      = query_all
+        self.query_all_uuid = query_all.query_uuid if query_all else None
+
+
+    def template_file (self):
+        return "univbrisfvfo.html"
+
+    def template_env (self, request):
+        env={}
+        env.update(self.__dict__)
+        #env['columns']=self.columns
+        return env
+
+    def requirements (self):
+        reqs = {
+            'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js", 
+                           "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
+                           "js/manifold.js", "js/manifold-query.js", 
+                           "js/unfold-helper.js",
+                          # querytable.js needs to be loaded after dataTables.js as it extends 
+                          # dataTableExt.afnSortData
+                           "js/univbrisfvfo.js",
+                           ] ,
+            'css_files': [ "css/dataTables.bootstrap.css",
+                           # hopefully temporary, when/if datatables supports sPaginationType=bootstrap3
+                           # for now we use full_numbers, with our own ad hoc css 
+                           "css/dataTables.full_numbers.css",
+                           "css/univbrisfvfo.css",
+                           ],
+            }
+        return reqs
+
+    # the list of things passed to the js plugin
+    def json_settings_list (self):
+        return ['plugin_uuid', 'domid', 
+                'query_uuid', 'query_all_uuid', 
+                'checkboxes', 'datatables_options', 
+                'hidden_columns', 'init_key',]
diff --git a/plugins/univbrisfvfo/static/css/univbrisfvfo.css b/plugins/univbrisfvfo/static/css/univbrisfvfo.css
new file mode 100644 (file)
index 0000000..4b518d3
--- /dev/null
@@ -0,0 +1,65 @@
+
+/* the bottom of the datatable needs more space */
+div.univbrisfvf-spacer { padding: 8px 4px 15px 4px; }
+
+div.UnivbrisFv table.dataTable th {
+    font: bold 12px/22px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+    color: #4f6b72;
+    border-right: 1px solid #C1DAD7;
+    border-bottom: 1px solid #C1DAD7;
+    border-top: 1px solid #C1DAD7;
+    letter-spacing: 1px;
+    text-transform: uppercase;
+    text-align: left;
+    padding: 8px 12px 4px 20px;
+    vertical-align:middle;
+/*    background: #CAE8EA url(../img/tablesort-header.jpg) no-repeat; */
+}
+
+div.UnivbrisFv table.dataTable th.checkbox {
+    padding-left: 14px;
+}
+
+div.UnivbrisFv table.dataTable td, div.UnivbrisFv table.dataTable textarea, div.UnivbrisFv table.dataTable input [type="text"] {
+    font: bold 12px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+    color: #660099;
+    border-right: 1px solid #C1DAD7;
+    border-bottom: 1px solid #C1DAD7;
+}
+div.UnivbrisFv table.dataTable td {
+    padding: 4px 8px 4px 8px;
+    /* this applies on even rows only, odd ones have a setting in bootstrap of rbg 249.249.249 */
+    background-color: #f4f4f4;
+    color: #660099;
+}
+div.UnivbrisFv table.dataTable td a {
+    font-weight:normal;
+}
+/* these come from bootstrap */
+div.UnivbrisFv div.dataTables_info {
+    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+/* one could think or using repeat-x here but that's not working because of the arrows
+ * we might need to make these wider some day 
+ * and/or to add background-color: #caebea
+ * which would look less conspicuous in case of overflow
+*/
+
+div.UnivbrisFv table.dataTable thead .sorting { background: url('../img/tablesort-header-sortable.png') no-repeat; }
+div.UnivbrisFv table.dataTable thead .sorting_asc { background: url('../img/tablesort-header-up.png') no-repeat; }
+div.UnivbrisFv table.dataTable thead .sorting_desc { background: url('../img/tablesort-header-down.png') no-repeat; }
+/* this icons set does not have that exact equivalent - using an approximation for now */
+div.UnivbrisFv table.dataTable thead .sorting_asc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+div.UnivbrisFv table.dataTable thead .sorting_desc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+
+/* the footers are not active */
+div.UnivbrisFv table.dataTable tfoot { 
+    background: url('../img/tablesort-header.png') repeat-x;
+    background-color: #caebea;
+}
+/* and when sorting is turned off it's useful to set this on header too */
+div.UnivbrisFv table.dataTable thead { 
+    background: url('../img/tablesort-header.png') repeat-x;
+    background-color: #caebea;
+}
diff --git a/plugins/univbrisfvfo/static/img/README b/plugins/univbrisfvfo/static/img/README
new file mode 100644 (file)
index 0000000..5df2d69
--- /dev/null
@@ -0,0 +1,2 @@
+these styling elements come from plekit with a simple transition to png
+they're currently not all used in myslice
diff --git a/plugins/univbrisfvfo/static/img/tablesort-bullet1.png b/plugins/univbrisfvfo/static/img/tablesort-bullet1.png
new file mode 100644 (file)
index 0000000..4304f36
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-bullet1.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-bullet2.png b/plugins/univbrisfvfo/static/img/tablesort-bullet2.png
new file mode 100644 (file)
index 0000000..4f181e1
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-bullet2.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-col-alt.png b/plugins/univbrisfvfo/static/img/tablesort-col-alt.png
new file mode 100644 (file)
index 0000000..8179f83
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-col-alt.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-gradient.png b/plugins/univbrisfvfo/static/img/tablesort-gradient.png
new file mode 100644 (file)
index 0000000..26558a4
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-gradient.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-header-down.png b/plugins/univbrisfvfo/static/img/tablesort-header-down.png
new file mode 100644 (file)
index 0000000..c8ed657
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-header-down.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-header-sortable.png b/plugins/univbrisfvfo/static/img/tablesort-header-sortable.png
new file mode 100644 (file)
index 0000000..0c16904
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-header-sortable.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-header-up.png b/plugins/univbrisfvfo/static/img/tablesort-header-up.png
new file mode 100644 (file)
index 0000000..d12fe2a
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-header-up.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-header.png b/plugins/univbrisfvfo/static/img/tablesort-header.png
new file mode 100644 (file)
index 0000000..cff526f
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-header.png differ
diff --git a/plugins/univbrisfvfo/static/img/tablesort-td-alt.png b/plugins/univbrisfvfo/static/img/tablesort-td-alt.png
new file mode 100644 (file)
index 0000000..ef5ab35
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/tablesort-td-alt.png differ
diff --git a/plugins/univbrisfvfo/static/img/toggle-hidden.png b/plugins/univbrisfvfo/static/img/toggle-hidden.png
new file mode 100755 (executable)
index 0000000..023f22a
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/toggle-hidden.png differ
diff --git a/plugins/univbrisfvfo/static/img/toggle-visible.png b/plugins/univbrisfvfo/static/img/toggle-visible.png
new file mode 100755 (executable)
index 0000000..baf6c28
Binary files /dev/null and b/plugins/univbrisfvfo/static/img/toggle-visible.png differ
similarity index 52%
rename from plugins/univbrisfv/static/js/univbrisfv1.js
rename to plugins/univbrisfvfo/static/js/univbrisfvfo.js
index 90ca0e8..7d502a8 100644 (file)
@@ -2,18 +2,19 @@
  * Description: display a query result in a datatables-powered <table>
  * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA
  * License: GPLv3
- */
+ */ 
 
 (function($){
 
     var debug=false;
-    //debug=true
+    debug=true;
 
-    var UnivbrisFv = Plugin.extend({
+
+    var UnivbrisFvfo = Plugin.extend({
 
         init: function(options, element) {
-           //alert("fv init called");
-           this.classname="univbrisfv";
+           //alert("foam init called");
+           this.classname="univbrisfvfo";
             this._super(options, element);
                
            //alert(this.options.hidden_columns);
            // query_uuid refers to a single object (typically a slice)
            // query_all_uuid refers to a list (typically resources or users)
            // these can return in any order so we keep track of which has been received yet
-            //this.received_all_query = True;
-            //this.received_query = True;
+            //this.received_all_query = false;
+            //this.received_query = false;
 
             // We need to remember the active filter for datatables filtering
-           // this.filters = Array(); 
-               alert("after super");
+            this.filters = Array(); 
+
             // an internal buffer for records that are 'in' and thus need to be checked 
             this.buffered_records_to_check = [];
            // an internal buffer for keeping lines and display them in one call to fnAddData
            //   (i.e. records returned by both queries) must have (typically: hrn or hostname)
            //   in general query_all will return well populated records, but query
            //   returns records with only the fields displayed on startup
-           //var keys = manifold.metadata.get_key(this.object);
-           //this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
-           //alert("after super");
+           var keys = manifold.metadata.get_key(this.object);
+           this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
+           // 
            this.init_key = this.options.init_key;
            // have init_key default to canonical_key
            this.init_key = this.init_key || this.canonical_key;
            // sanity check
-           if ( ! this.init_key ) messages.warning ("UnivbrisFv : cannot find init_key");
-           if ( ! this.canonical_key ) messages.warning ("UnivbrisFv : cannot find canonical_key");
-           if (debug) messages.debug("UnivbrisFv: canonical_key="+this.canonical_key+" init_key="+this.init_key);
+           if ( ! this.init_key ) messages.warning ("UnivbrisFvfo : cannot find init_key");
+           if ( ! this.canonical_key ) messages.warning ("UnivbrisFvfo : cannot find canonical_key");
+           if (debug) messages.debug("UnivbrisFvfo: canonical_key="+this.canonical_key+" init_key="+this.init_key);
 
             /* Setup query and record handlers */
             //this.listen_query(options.query_uuid);
             //this.listen_query(options.query_all_uuid, 'all');
 
             /* GUI setup and event binding */
-           //alert("fv init called");
-            this.initialize_table();
-           
+            //this.initialize_table();
+           //alert("init fvf");
+           jQuery("#uob_ofv_table_form").hide();
+       
+           //$('<button id="cancel_addflowspaceform" type="button" style="height: 25px; width: 200px" onclick="fnCancel()">Cancel</button>').appendTo('#fvf_table_button');
+
+           //$('<button id="addflowspaceform" type="button" style="height: 25px; width: 200px" onclick="fnAddflowspace()">Add flowspace</button>').appendTo('#fvf_table_button');
+               
+           this._querytable_draw_callback();
         },
 
         /* PLUGIN EVENTS */
 
         on_show: function(e) {
-           if (debug) messages.debug("univbrisfv.on_show");
+           if (debug) messages.debug("univbrisfvfo.on_show");
             var self = e.data;
             self.table.fnAdjustColumnSizing();
        },        
 
         on_resize: function(e) {
-           if (debug) messages.debug("univbrisfv.on_resize");
+           if (debug) messages.debug("univbrisfvfo.on_resize");
             var self = e.data;
             self.table.fnAdjustColumnSizing();
        },        
 
         initialize_table: function() 
         {
-            alert("init table fnc");
-          /* Transforms the table into DataTable, and keep a pointer to it */
+            /* Transforms the table into DataTable, and keep a pointer to it */
             var self = this;
             var actual_options = {
                 // Customize the position of Datatables elements (length,filter,button,...)
                 // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
                 //sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
-               sDom: "<'row'<'col-xs-9'r>t<'next'>",
+               //sDom: "<'row'<'col-xs-2'l><'col-xs-9'r><'col-xs-2'f>>t<'row'<'col-xs-5'i><'col-xs-5'p>><'next'>",
+               sDom: "<'row'<'col-xs-9'r>t<'buttons'>",
                // XXX as of sept. 2013, I cannot locate a bootstrap3-friendly mode for now
                // hopefully this would come with dataTables v1.10 ?
                // in any case, search for 'sPaginationType' all over the code for more comments
                 aoColumnDefs: [{sDefaultContent: '',aTargets: [ '_all' ]}],
                 // WARNING: this one causes tables in a 'tabs' that are not exposed at the time this is run to show up empty
                 // sScrollX: '100%',       /* Horizontal scrolling */
-                bProcessing: true,      /* Loading */
+                bProcessing: false,      /* Loading */
                 fnDrawCallback: function() { self._querytable_draw_callback.call(self);}
-               //fnFooterCallback: function() {self._univbrisfv_footer_callback.call(self,nFoot, aData, iStart, iEnd, aiDisplay)};}
+               //fnFooterCallback: function() {self._univbrisfvf_footer_callback.call(self,nFoot, aData, iStart, iEnd, aiDisplay)};}
                 // XXX use $.proxy here !
             };
             // the intention here is that options.datatables_options as coming from the python object take precedence
            // check your datatables_options tag instead 
            // however, we have to accumulate in aoColumnDefs from here (above) 
            // and from the python wrapper (checkboxes management, plus any user-provided aoColumnDefs)
-           /*if ( 'aoColumnDefs' in this.options.datatables_options) {
+           if ( 'aoColumnDefs' in this.options.datatables_options) {
                actual_options['aoColumnDefs']=this.options.datatables_options['aoColumnDefs'].concat(actual_options['aoColumnDefs']);
                delete this.options.datatables_options['aoColumnDefs'];
-           }*/
-           //this.redraw_table();
-            //this.show();
-           alert("before 1");
+           }
            $.extend(actual_options, this.options.datatables_options );
-            this.table = $('#univbris_flowspace_selection__table').dataTable(actual_options);
-            alert("after 1");
-           alert(this.table);
+            this.table = $("#univbris_flowspace_form__table").dataTable(actual_options);
+
+           //alert(this.table);
 
             /* Setup the SelectAll button in the dataTable header */
             /* xxx not sure this is still working */
              * Note: we use closure to get access to the 'options'
              */
             $.fn.dataTableExt.afnFiltering.push(function( oSettings, aData, iDataIndex ) { 
-               /* No filtering if the table does not match */
-               if (oSettings.nTable.id != self.options.plugin_uuid + '__table')
-                  return true;
+                /* No filtering if the table does not match */
+                if (oSettings.nTable.id != self.options.plugin_uuid + '__table')
+                    return true;
                 return self._querytable_filter.call(self, oSettings, aData, iDataIndex);
             });
 
                //self.hide_column(field);
             });
 
-           $('<button id="next" type="submit" style="height: 50px; width: 300px" onclick="fnButnext()">select flowspace</button>').appendTo('div.next');
+        }, // initialize_table
 
-             $('<a href="http://localhost:8000/login/" id="next_link">next link</a>').appendTo('div.next');
-               alert("before record");
-               //this.redraw_table();
-               this.new_record("test");
-               this._querytable_draw_callback();
-               //this.show(e);
-               alert("after record");
-               //this.show_column()
-               
+
+       fnCancel:function(e){
+               //var sData=$("#uob_fv_table_form").find("input").serialize();
+               //alert("add flowspace:" + sData);
+               //alert("cancel"); 
                
-        }, // initialize_table
+               jQuery("#uob_ofv_table_form").hide();
+               jQuery( "#univbris_foam_ports_selection" ).hide();
+               jQuery( "#univbris_flowspace_selection" ).show();
+               jQuery('#topo_plugin').hide();
+               /*var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+               var nodes = $('input',port_table.fnGetNodes());
+               for(var i=0;i<nodes.length;i++){
+                       nodes[i].checked=false;
+                       console.log(nodes[i].id);
+               }*/
 
+       },
 
-       fnButnext:function(e){
+
+       fnAddflowspace:function(e){
                e.stopPropagation();
-               //var sData = this.table.$('input').serialize();
-               //var sData = $(this).closest('checkboxes__table').find('input').serialize();
-               //var sData = $("form").find('input').serialize();
-               //var element=this.table.$("id="'NEC A/80<->NEC B/1080'"");
-               //var element=this.table.$("[id='"+"NEC A/80<->NEC B/1080"+"']");
-               //var x = element.checked;
-               //var uuid=this.id.split("-");
-               //var oTable=$('checkboxes__table').dataTable();
-               //var oTable=$.fn.dataTable();
-               //this.elts("table").unbind('click').click(this, this.fnButnext);
-               //var sData = $('input', oTable.fnGetNodes()).serialize();
-               //$.fn.dataTable()
-               //sData="test";
-               ///var self = e.data;
-               //self=self.options.query_uuid;
-               //var oTable=$("#querytable-"+self).dataTable();
-               //var sData = $('input', oTable.fnGetNodes()).serialize();
-               //e.stopPropagation();
-               //var oTable=$('#myTable').dataTable();
-               //var sData = $('input', $("#uob_form")).serialize();
-               var sData=$("#uob_form").find("input").serialize();
-               //alert("clicked: "+sData);
-
-               //var url = "http://localhost:8000/login/";    
-               //$(location).attr('href',url);
-               //window.location.href = "http://localhost:8000/login/"
-               //window.location.replace("http://localhost:8000/login/");
-               //UnivbrisFv(options,elements);
-
-                       //$("#next_link").click();
+               if(fvf_add==1){         
+                       pk_flowspace_index=1+pk_flowspace_index;
+                       jQuery("#uob_fv_table_form").hide();
+                       var sData=$("#uob_fv_table_form").find("input").serialize();
+                       var form =serializeAnything("#uob_fv_table_form");
+                       //alert(form);
+                       //var form2=serializeAnything("#uob_form");
+                       //alert(form2);
+                       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                       var form2=$('input',port_table.fnGetNodes()).serialize();
+                       //console.log(form2);
+                       //alert($('input',port_table.fnGetNodes()).serialize());
+                       var nodes = $('input',port_table.fnGetNodes());
+                       //console.log(nodes[1]);
+                       //console.log(nodes);
+                       //alert($("#uob_form").serialize());
+                       //var pos = form.search("&urn");
+                       //form2=form2.substring(pos+1);
+                       //alert(form2[1]);
+                       //console.log(form2);
+                       this.table = $("#univbris_flowspace_selection__table").dataTable();
                        
-               },
+                       var val_status=validateFvfForm();
+                       //val_status=true;
+                       if (val_status == true){
+                               flowspace=sData;
+                               var m_form=form+","+form2;
+                               var string = "<p id='"+m_form+"'> <a onclick=\'fnPopTable(\""+form+"\",\""+form2+"\");'>"+$("#flowspace_name").val()+"</a></p>";        
+                               this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
+                               jQuery( "#univbris_foam_ports_selection" ).hide();
+                               jQuery( "#univbris_flowspace_selection" ).show();
+                               jQuery('#topo_plugin').hide();
+                       }
+                       else{
+                               alert("validation failed");
+                               jQuery("#uob_ofv_table_form").show();
+                               jQuery( "#univbris_foam_ports_selection" ).show();
+                       }
+               }
+               else{
+                       jQuery("#uob_fv_table_form").hide();
+                       var sData=$("#uob_fv_table_form").find("input").serialize();
+                       var form =serializeAnything("#uob_fv_table_form");
+                       //var form2=serializeAnything("#uob_form");
+
+                       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                       var form2=$('input',port_table.fnGetNodes()).serialize();
+                       this.table = $("#univbris_flowspace_selection__table").dataTable();
+                       flowspace=sData;
+                       var m_form=form+","+form2;
+                       var string = "<p id='"+m_form+"'> <a onclick=\'fnPopTable(\""+form+"\",\""+form2+"\");'>"+$("#flowspace_name").val()+"</a></p>";
+                       this.table.fnDeleteRow(fvf_nrow);       
+                       this.table.fnAddData([string, '<a class="edit">Edit</a>', '<a class="delete" href="">Delete</a>']);
+                       
+                       jQuery( "#univbris_foam_ports_selection" ).hide();
+                       jQuery( "#univbris_flowspace_selection" ).show();
+                       jQuery('#topo_plugin').hide();
+               
+               }
+       },
 
-       
 
         /**
          * @brief Determine index of key in the table columns 
             var result="";
             // Prefix id with plugin_uuid
             result += "<input";
-            result += " class='univbrisfv-checkbox'";
+            result += " class='univbrisfvfo-checkbox'";
         // compute id from canonical_key
            var id = record[this.canonical_key]
         // compute init_id form init_key
             var result="";
             // Prefix id with plugin_uuid
             result += "<input";
-            //result += " class='univbrisfv-checkbox'";
+            //result += " class='univbrisfvfo-checkbox'";
         // set id - for retrieving from an id, or for posting events upon user's clicks
            result += " id='"+ record +"'";
            result += " name='"+ record +"'";
         {
            
         // this models a line in dataTables, each element in the line describes a cell
-          // alert("nb_col: ");
             line = new Array();
      
             // go through table headers to get column names we want
             // in order (we have temporarily hack some adjustments in names)
-          
             var cols = this.table.fnSettings().aoColumns;
-           alert("col "+cols);
             var colnames = cols.map(function(x) {return x.sTitle})
             var nb_col = cols.length;
-                       alert("nb_col: "+ nb_col);
             /* if we've requested checkboxes, then forget about the checkbox column for now */
             if (this.options.checkboxes) nb_col -= 1;
-                       alert("nb_col: "+ nb_col);
+           
+           //alert(colnames);
+           /*replace production*/
+            /* fill in stuff depending on the column name */
+             var cols = this.table.fnSettings().aoColumns;
+           //alert("col "+cols);
+            var colnames = cols.map(function(x) {return x.sTitle})
+            var nb_col = cols.length;
+                       //alert("nb_col: "+ nb_col);
+            /* if we've requested checkboxes, then forget about the checkbox column for now */
+            if (this.options.checkboxes) nb_col -= 1;
+                       //alert("nb_col: "+ nb_col);
            //alert(colnames);
            /*replace production*/
             /* fill in stuff depending on the column name */
                 if (typeof colnames[j] == 'undefined') {
                     line.push('...');
                 } else if (colnames[j] == 'Flowspace Selector') {
-                   alert("added");
-                    line.push("first form");
+                   //alert("added");
+                    line.push("first");
                }
-       
                
-
-               /*if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'hostname') {
-                    if (record['type'] == 'resource,link')
-                        //TODO: we need to add source/destination for links
-                        line.push('');
-                    else
-                        line.push(record['hostname']);
-
-                } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
-                    line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record['hrn']);
-                } else {
-                    if (record[colnames[j]])
-                        line.push(record[colnames[j]]);
-                    else
-                        line.push('');
-                }*/
             }
     
             // catch up with the last column if checkboxes were requested 
                }
     
            // adding an array in one call is *much* more efficient
-               alert("sending to table");
-               $('#univbris_flowspace_selection__table').dataTable().fnAddData(['test']);
-               //$('#univbris_flowspace_selection__table').dataTable().fnDraw();
-               this._querytable_draw_callback();
-               alert("sent to table");
-               //this.buffered_lines.push(line);
+               // this.table.fnAddData(line);
+               this.buffered_lines.push(line);
+               this.table.fnAddData(this.buffered_lines);
+               //this.table.redraw();
+               //this._querytable_draw_callback();
         },
 
         clear_table: function()
        set_checkbox_from_record: function (record, checked) {
             if (checked === undefined) checked = true;
            var init_id = record[this.init_key];
-           if (debug) messages.debug("univbrisfv.set_checkbox_from_record, init_id="+init_id);
+           if (debug) messages.debug("univbrisfvfo.set_checkbox_from_record, init_id="+init_id);
            // using table.$ to search inside elements that are not visible
            var element = this.table.$('[init_id="'+init_id+'"]');
            element.attr('checked',checked);
        // id relates to canonical_key
        set_checkbox_from_data: function (id, checked) {
             if (checked === undefined) checked = true;
-           if (debug) messages.debug("univbrisfv.set_checkbox_from_data, id="+id);
+           if (debug) messages.debug("univbrisfvfo.set_checkbox_from_data, id="+id);
            // using table.$ to search inside elements that are not visible
            var element = this.table.$("[id='"+id+"']");
            element.attr('checked',checked);
 
         on_field_clear: function()
         {
-            alert('UnivbrisFv::clear_fields() not implemented');
+            alert('UnivbrisFvfo::clear_fields() not implemented');
         },
 
         /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
 
         on_all_field_clear: function()
         {
-            alert('UnivbrisFv::clear_fields() not implemented');
+            alert('UnivbrisFvfo::clear_fields() not implemented');
         },
 
 
         {
             /* 
              * Handle clicks on checkboxes: reassociate checkbox click every time
-             * the table is redrawn 
+             * the table is redrawn    
              */
             this.elts('querytable-checkbox').unbind('click').click(this, this._check_click);
-           this.elts("next").unbind('click').click(this, this.fnButnext);
-           
+           //alert("fvf_add: "+fvf_add);
+           if(fvf_add==1){
+               $("#addflowspaceform").unbind('click').click(this, this.fnAddflowspace);
+           }
+           else{
+               $("[id='addflowspaceform']").unbind('click').click(this, this.fnModflowspace);
+           }
+           $("#cancel_addflowspaceform").unbind('click').click(this,this.fnCancel); 
 
             if (!this.table)
                 return;
 
             // this.id = key of object to be added... what about multiple keys ?
            if (debug) messages.debug("querytable._check_click key="+this.canonical_key+"->"+id+" checked="+this.checked);
-            manifold.raise_event(self.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, id);
+            //manifold.raise_event(self.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, id);
             //return false; // prevent checkbox to be checked, waiting response from manifold plugin api
             
         },
 
     });
 
-    $.plugin('UnivbrisFv', UnivbrisFv);
+    $.plugin('UnivbrisFvfo', UnivbrisFvfo);
 
   /* define the 'dom-checkbox' type for sorting in datatables 
      http://datatables.net/examples/plug-ins/dom_sort.html
        return $.map( oSettings.oApi._fnGetTrNodes(oSettings), function (tr, i) {
            return result=$('td:eq('+iColumn+') input', tr).prop('checked') ? '1' : '0';
        } );
-    }
+
+};
 
 })(jQuery);
 
+
+function deserializeDT(d){
+
+       try{
+           var data = d,
+                currentDom,
+                $current = null,
+                $currentSavedValue = null,
+                $self = this,
+                i = 0,
+                keyValPairString = [],
+                keyValPairObject = {},
+                tmp = null,
+                defaults = null;
+
+            if (data.constructor === String) {
+
+
+                data = decodeURIComponent(data.replace(/\+/g, " "));
+
+                keyValPairString = data.split('&');
+
+                for (i = 0; i < keyValPairString.length; i++) {
+                    tmp = keyValPairString[i].split('=');
+                    keyValPairObject[tmp[0]] = tmp[1];
+
+                }
+            }
+
+         var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+         var nodes = $('input',port_table.fnGetNodes());
+
+
+         for(i=0;i<nodes.length;i++){
+                       $currentSavedValue = keyValPairObject[nodes[i].id];
+                       if ($currentSavedValue === undefined){
+                               nodes[i].checked=false;
+                       }
+                       else{
+                               nodes[i].checked=true;
+                       }
+         };
+
+       }
+       catch(err){
+               alert(err);
+       }
+
+          
+};
+
+
+function fnPopTable(form1,form2){
+               hideFvfError();
+                $("[id='addflowspaceform']").hide();
+               $("#uob_fv_table_form :input").prop("disabled", false);
+               $("#uob_fv_table_form").deserialize(form1);
+               deserializeDT(form2);
+
+
+                $("[name='flowspace_name']").prop("disabled", true);
+               $("#uob_fv_table_form :input").prop("disabled", true);
+               $("[id='cancel_addflowspaceform']").prop("disabled", false);
+               $("[id='cancel_addflowspaceform']").text('close');
+
+               var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+               var nodes = $('input',port_table.fnGetNodes());
+               for(var i=0;i<nodes.length;i++){
+                       nodes[i].disabled=true;
+               }
+
+               jQuery("#univbris_flowspace_selection").hide();
+               jQuery("#uob_fv_table_form").show();
+               jQuery( "#univbris_foam_ports_selection" ).show();
+
+               if  ($("#flowspace_name").val().search("pk")==0){
+                       topoviewer_state={mode:"read",link_type:"non-optical"};
+               }
+               else{
+                       topoviewer_state={mode:"read",link_type:"optical"};
+               }
+               
+               jQuery('#topo_plugin').show();
+};
+
+function macValidator (mac_str){
+       if (mac_str != ""){
+               var mac_validator=/(^(([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2}))$)|(^(([0-9a-fA-F]{2}[:-]){5}([0-9a-fA-F]{2})))$/;
+               var result =mac_str.match(mac_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else{
+               return true;
+       }
+};
+
+function ethertypeValidator (eth_str){
+       if (eth_str != ""){
+               var ethertype_validator=/^0x[0-9a-fA-F]{4}$/;
+               var result = eth_str.match(ethertype_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else{
+               return true;
+       }
+};
+
+
+function vlanValidator (vlan_str){
+       if (vlan_str != ""){
+               var vlan_validator=/(^[1-9][0-9]{0,2}|[1-3][0-9]{3}|40[0-8][0-9]|409[0-5]$)/;
+               var result = vlan_str.match(vlan_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }
+};
+
+function ipValidator(ip_str){
+       if (ip_str != ""){
+               var ip_validator=/(^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$)/;
+               var result = ip_str.match(ip_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }
+};
+
+
+function portValidator (port_str){
+       if (port_str != ""){
+               var port_validator=/^([1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/;
+               var result = port_str.match(port_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }       
+}
+
+function ipProtoValidator (ipproto_str){
+       if (ipproto_str != ""){
+               var ipproto_validator=/(^[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]$)/;
+               var result = ipproto_str.match(ipproto_validator);
+               if (result==null){
+                       return false;
+               }
+               else{
+                       return true;
+               }
+       }
+       else {
+               return true;
+       }       
+}
+
+
+
+
+
+
+
+function validateFvfForm(){
+       var status = false;
+       var checked =0;
+
+       //row 1 validation
+       if (macValidator ($("#uob_fv_table_dl_src_start").val())==false){
+               $("#uob_fv_table_dl_src_start").addClass('error');
+               $("#uob_fv_table_dl_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (macValidator ($("#uob_fv_table_dl_src_end").val())==false){
+               $("#uob_fv_table_dl_src_end").addClass('error');
+               $("#uob_fv_table_dl_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 2 validation
+
+       if (macValidator ($("#uob_fv_table_dl_dst_start").val())==false){
+               $("#uob_fv_table_dl_dst_start").addClass('error');
+               $("#uob_fv_table_dl_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (macValidator ($("#uob_fv_table_dl_dst_end").val())==false){
+               $("#uob_fv_table_dl_dst_end").addClass('error');
+               $("#uob_fv_table_dl_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 3 validation
+       
+       if (ethertypeValidator ($("#uob_fv_table_dl_type_start").val())==false){
+               $("#uob_fv_table_dl_type_start").addClass('error');
+               $("#uob_fv_table_dl_type_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ethertypeValidator ($("#uob_fv_table_dl_type_end").val())==false){
+               $("#uob_fv_table_dl_type_end").addClass('error');
+               $("#uob_fv_table_dl_type_error").show();
+       }
+       else {
+               checked++;
+       }
+
+
+       //row 4 validation
+       if (vlanValidator ($("#uob_fv_table_vlan_id_start").val())==false){
+               $("#uob_fv_table_vlan_id_start").addClass('error');
+               $("#uob_fv_table_vlan_id_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (vlanValidator ($("#uob_fv_table_vlan_id_end").val())==false){
+               $("#uob_fv_table_vlan_id_end").addClass('error');
+               $("#uob_fv_table_vlan_id_error").show();
+       }
+       else {
+               checked++;
+       }
+       //row 5 validation
+       if (ipValidator ($("#uob_fv_table_nw_src_start").val())==false){
+               $("#uob_fv_table_nw_src_start").addClass('error');
+               $("#uob_fv_table_nw_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ipValidator ($("#uob_fv_table_nw_src_end").val())==false){
+               $("#uob_fv_table_nw_src_end").addClass('error');
+               $("#uob_fv_table_nw_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 6 validation
+       if (ipValidator ($("#uob_fv_table_nw_dst_start").val())==false){
+               $("#uob_fv_table_nw_dst_start").addClass('error');
+               $("#uob_fv_table_nw_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ipValidator ($("#uob_fv_table_nw_dst_end").val())==false){
+               $("#uob_fv_table_nw_dst_end").addClass('error');
+               $("#uob_fv_table_nw_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+
+
+       //row 7 validation
+
+       if (ipProtoValidator ($("#uob_fv_table_nw_proto_start").val())==false){
+               $("#uob_fv_table_nw_proto_start").addClass('error');
+               $("#uob_fv_table_nw_proto_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (ipProtoValidator ($("#uob_fv_table_nw_proto_end").val())==false){
+               $("#uob_fv_table_nw_proto_end").addClass('error');
+               $("#uob_fv_table_nw_proto_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 8 validation
+       if (portValidator ($("#uob_fv_table_tp_src_start").val())==false){
+               $("#uob_fv_table_tp_src_start").addClass('error');
+               $("#uob_fv_table_tp_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (portValidator ($("#uob_fv_table_tp_src_end").val())==false){
+               $("#uob_fv_table_tp_src_end").addClass('error');
+               $("#uob_fv_table_tp_src_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       //row 9 validation
+       if (portValidator ($("#uob_fv_table_tp_dst_start").val())==false){
+               $("#uob_fv_table_tp_dst_start").addClass('error');
+               $("#uob_fv_table_tp_dst_error").show();
+       }
+       else {
+               checked++;
+       }
+
+       if (portValidator ($("#uob_fv_table_tp_dst_end").val())==false){
+               $("#uob_fv_table_tp_dst_end").addClass('error');
+               $("#uob_fv_table_tp_dst_error").show();
+       }
+       else {
+               checked++;
+       }/**/
+
+       //validate that at least one port is selected
+       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+       var nodes = $('input',port_table.fnGetNodes());
+
+       var port_selected=false;
+       for(var i=0;i<nodes.length;i++){
+               if(nodes[i].checked==true){
+                       checked++;
+                       port_selected=true;
+                       break;
+               }                       
+       }
+
+       if (checked >= 19) {
+               status=true;
+       }
+
+       if (port_selected==false & checked == 18){
+               alert("you need to select at least one port");
+       }
+       else if (port_selected==false & checked <= 18){
+               alert("you need to select at least one port and correct other flowspace parameter errors");
+       }
+       else if (port_selected==true & checked <= 18){
+               alert("you need to correct other flowspace parameter errors");
+       }
+       
+       //alert("validator status:"+status+" checked:"+checked);
+       return status;
+}
+
+
+
+function fnGetSelected( oTableLocal )
+{
+       var aReturn = new Array();
+       var aTrs = oTableLocal.fnGetNodes();
+       
+       for ( var i=0 ; i<aTrs.length ; i++ )
+       {
+               if ( $(aTrs[i]).hasClass('row_selected') )
+               {
+                       aReturn.push( aTrs[i] );
+               }
+       }
+       return aReturn;
+}
+
+function serializeAnything (form){
+       var toReturn    = [];
+       var els         = $(form).find(':input').get();
+
+       $.each(els, function() {                        
+               if (this.name && (this.checked || /select|textarea/i.test(this.nodeName) || /text|hidden|password/i.test(this.type))) {
+                               var val = $(this).val();
+                               toReturn.push( encodeURIComponent(this.name) + "=" + encodeURIComponent( val ) );
+                       }
+               });
+
+               return toReturn.join("&").replace(/%20/g, "+");
+}
+
+function hideFvfError(){
+       $("[id*=_error]").hide();
+       console
+       $("#uob_fv_table_form :input").each(function(){
+               try{
+                       $(this).removeClass('error');
+               }
+               catch (err){
+               }
+
+       });
+}
+
+
+(function ($) {
+    $.fn.extend({
+        deserialize : function (d, config) {
+            var data = d,
+                currentDom,
+                $current = null,
+                $currentSavedValue = null,
+                $self = this,
+                i = 0,
+                keyValPairString = [],
+                keyValPairObject = {},
+                tmp = null,
+                defaults = null;
+
+            if (d === undefined || !$self.is('form')) {
+                return $self;
+            }
+
+            defaults = {
+                overwrite : true
+            };
+
+            config = $.extend(defaults, config);
+
+            if (d.constructor === String) {
+
+
+                d = decodeURIComponent(d.replace(/\+/g, " "));
+
+                keyValPairString = d.split('&');
+
+                for (i = 0; i < keyValPairString.length; i++) {
+                    tmp = keyValPairString[i].split('=');
+                    keyValPairObject[tmp[0]] = tmp[1];
+
+                }
+            }
+
+            $('input, select, textarea', $self).each(function (i) {
+
+                $current = $(this);
+                currentDom = $current.get(0);
+                $currentSavedValue = keyValPairObject[$current.attr('name')];
+
+                if (currentDom.disabled === true) {
+                   //current.val($currentSavedValue);
+                    return true;
+                }
+
+                if ($current.is('textarea')) {
+                    if ($currentSavedValue === undefined) {
+                        $current.val('');
+                    } else {
+                        $current.val($currentSavedValue);
+                    }
+                    return true;
+                }
+
+                if ($current.is('select')) {
+                    if ($currentSavedValue === undefined) {
+                        return true;
+                    } else {
+                        currentDom.selectedIndex = $currentSavedValue;
+                    }
+                    return true;
+                }
+
+                if ($current.is('input:radio')) {
+                    if ($currentSavedValue !== undefined) {
+
+                        $current.each(function () {
+                            if ($(this).val() === $currentSavedValue) {
+                                $(this).get(0).checked = true;
+                            }
+                        });
+                    }
+
+                    return true;
+                }
+
+                if ($current.is('input:checkbox')) {
+                    currentDom.checked = ($current.val() === $currentSavedValue);
+                    return true;
+                }
+
+                if ($current.is('input:text, input:hidden')) {
+                    if ($currentSavedValue === undefined) {
+                        $current.val('');
+                    } else {
+                        $current.val($currentSavedValue);
+                        return true;
+                    }
+
+                }
+
+            });
+
+            return $self;
+        }
+
+    });
+
+
+}(jQuery));
+
+
diff --git a/plugins/univbrisfvfo/templates/jquery-1.11.0.js b/plugins/univbrisfvfo/templates/jquery-1.11.0.js
new file mode 100644 (file)
index 0000000..3c88fa8
--- /dev/null
@@ -0,0 +1,10337 @@
+/*!
+ * jQuery JavaScript Library v1.11.0
+ * http://jquery.com/
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ *
+ * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2014-01-23T21:02Z
+ */
+
+(function( global, factory ) {
+
+       if ( typeof module === "object" && typeof module.exports === "object" ) {
+               // For CommonJS and CommonJS-like environments where a proper window is present,
+               // execute the factory and get jQuery
+               // For environments that do not inherently posses a window with a document
+               // (such as Node.js), expose a jQuery-making factory as module.exports
+               // This accentuates the need for the creation of a real window
+               // e.g. var jQuery = require("jquery")(window);
+               // See ticket #14549 for more info
+               module.exports = global.document ?
+                       factory( global, true ) :
+                       function( w ) {
+                               if ( !w.document ) {
+                                       throw new Error( "jQuery requires a window with a document" );
+                               }
+                               return factory( w );
+                       };
+       } else {
+               factory( global );
+       }
+
+// Pass this if window is not defined yet
+}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
+
+// Can't do this because several apps including ASP.NET trace
+// the stack via arguments.caller.callee and Firefox dies if
+// you try to trace through "use strict" call chains. (#13335)
+// Support: Firefox 18+
+//
+
+var deletedIds = [];
+
+var slice = deletedIds.slice;
+
+var concat = deletedIds.concat;
+
+var push = deletedIds.push;
+
+var indexOf = deletedIds.indexOf;
+
+var class2type = {};
+
+var toString = class2type.toString;
+
+var hasOwn = class2type.hasOwnProperty;
+
+var trim = "".trim;
+
+var support = {};
+
+
+
+var
+       version = "1.11.0",
+
+       // Define a local copy of jQuery
+       jQuery = function( selector, context ) {
+               // The jQuery object is actually just the init constructor 'enhanced'
+               // Need init if jQuery is called (just allow error to be thrown if not included)
+               return new jQuery.fn.init( selector, context );
+       },
+
+       // Make sure we trim BOM and NBSP (here's looking at you, Safari 5.0 and IE)
+       rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
+
+       // Matches dashed string for camelizing
+       rmsPrefix = /^-ms-/,
+       rdashAlpha = /-([\da-z])/gi,
+
+       // Used by jQuery.camelCase as callback to replace()
+       fcamelCase = function( all, letter ) {
+               return letter.toUpperCase();
+       };
+
+jQuery.fn = jQuery.prototype = {
+       // The current version of jQuery being used
+       jquery: version,
+
+       constructor: jQuery,
+
+       // Start with an empty selector
+       selector: "",
+
+       // The default length of a jQuery object is 0
+       length: 0,
+
+       toArray: function() {
+               return slice.call( this );
+       },
+
+       // Get the Nth element in the matched element set OR
+       // Get the whole matched element set as a clean array
+       get: function( num ) {
+               return num != null ?
+
+                       // Return a 'clean' array
+                       ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
+
+                       // Return just the object
+                       slice.call( this );
+       },
+
+       // Take an array of elements and push it onto the stack
+       // (returning the new matched element set)
+       pushStack: function( elems ) {
+
+               // Build a new jQuery matched element set
+               var ret = jQuery.merge( this.constructor(), elems );
+
+               // Add the old object onto the stack (as a reference)
+               ret.prevObject = this;
+               ret.context = this.context;
+
+               // Return the newly-formed element set
+               return ret;
+       },
+
+       // Execute a callback for every element in the matched set.
+       // (You can seed the arguments with an array of args, but this is
+       // only used internally.)
+       each: function( callback, args ) {
+               return jQuery.each( this, callback, args );
+       },
+
+       map: function( callback ) {
+               return this.pushStack( jQuery.map(this, function( elem, i ) {
+                       return callback.call( elem, i, elem );
+               }));
+       },
+
+       slice: function() {
+               return this.pushStack( slice.apply( this, arguments ) );
+       },
+
+       first: function() {
+               return this.eq( 0 );
+       },
+
+       last: function() {
+               return this.eq( -1 );
+       },
+
+       eq: function( i ) {
+               var len = this.length,
+                       j = +i + ( i < 0 ? len : 0 );
+               return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
+       },
+
+       end: function() {
+               return this.prevObject || this.constructor(null);
+       },
+
+       // For internal use only.
+       // Behaves like an Array's method, not like a jQuery method.
+       push: push,
+       sort: deletedIds.sort,
+       splice: deletedIds.splice
+};
+
+jQuery.extend = jQuery.fn.extend = function() {
+       var src, copyIsArray, copy, name, options, clone,
+               target = arguments[0] || {},
+               i = 1,
+               length = arguments.length,
+               deep = false;
+
+       // Handle a deep copy situation
+       if ( typeof target === "boolean" ) {
+               deep = target;
+
+               // skip the boolean and the target
+               target = arguments[ i ] || {};
+               i++;
+       }
+
+       // Handle case when target is a string or something (possible in deep copy)
+       if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+               target = {};
+       }
+
+       // extend jQuery itself if only one argument is passed
+       if ( i === length ) {
+               target = this;
+               i--;
+       }
+
+       for ( ; i < length; i++ ) {
+               // Only deal with non-null/undefined values
+               if ( (options = arguments[ i ]) != null ) {
+                       // Extend the base object
+                       for ( name in options ) {
+                               src = target[ name ];
+                               copy = options[ name ];
+
+                               // Prevent never-ending loop
+                               if ( target === copy ) {
+                                       continue;
+                               }
+
+                               // Recurse if we're merging plain objects or arrays
+                               if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+                                       if ( copyIsArray ) {
+                                               copyIsArray = false;
+                                               clone = src && jQuery.isArray(src) ? src : [];
+
+                                       } else {
+                                               clone = src && jQuery.isPlainObject(src) ? src : {};
+                                       }
+
+                                       // Never move original objects, clone them
+                                       target[ name ] = jQuery.extend( deep, clone, copy );
+
+                               // Don't bring in undefined values
+                               } else if ( copy !== undefined ) {
+                                       target[ name ] = copy;
+                               }
+                       }
+               }
+       }
+
+       // Return the modified object
+       return target;
+};
+
+jQuery.extend({
+       // Unique for each copy of jQuery on the page
+       expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
+
+       // Assume jQuery is ready without the ready module
+       isReady: true,
+
+       error: function( msg ) {
+               throw new Error( msg );
+       },
+
+       noop: function() {},
+
+       // See test/unit/core.js for details concerning isFunction.
+       // Since version 1.3, DOM methods and functions like alert
+       // aren't supported. They return false on IE (#2968).
+       isFunction: function( obj ) {
+               return jQuery.type(obj) === "function";
+       },
+
+       isArray: Array.isArray || function( obj ) {
+               return jQuery.type(obj) === "array";
+       },
+
+       isWindow: function( obj ) {
+               /* jshint eqeqeq: false */
+               return obj != null && obj == obj.window;
+       },
+
+       isNumeric: function( obj ) {
+               // parseFloat NaNs numeric-cast false positives (null|true|false|"")
+               // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
+               // subtraction forces infinities to NaN
+               return obj - parseFloat( obj ) >= 0;
+       },
+
+       isEmptyObject: function( obj ) {
+               var name;
+               for ( name in obj ) {
+                       return false;
+               }
+               return true;
+       },
+
+       isPlainObject: function( obj ) {
+               var key;
+
+               // Must be an Object.
+               // Because of IE, we also have to check the presence of the constructor property.
+               // Make sure that DOM nodes and window objects don't pass through, as well
+               if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+                       return false;
+               }
+
+               try {
+                       // Not own constructor property must be Object
+                       if ( obj.constructor &&
+                               !hasOwn.call(obj, "constructor") &&
+                               !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
+                               return false;
+                       }
+               } catch ( e ) {
+                       // IE8,9 Will throw exceptions on certain host objects #9897
+                       return false;
+               }
+
+               // Support: IE<9
+               // Handle iteration over inherited properties before own properties.
+               if ( support.ownLast ) {
+                       for ( key in obj ) {
+                               return hasOwn.call( obj, key );
+                       }
+               }
+
+               // Own properties are enumerated firstly, so to speed up,
+               // if last one is own, then all properties are own.
+               for ( key in obj ) {}
+
+               return key === undefined || hasOwn.call( obj, key );
+       },
+
+       type: function( obj ) {
+               if ( obj == null ) {
+                       return obj + "";
+               }
+               return typeof obj === "object" || typeof obj === "function" ?
+                       class2type[ toString.call(obj) ] || "object" :
+                       typeof obj;
+       },
+
+       // Evaluates a script in a global context
+       // Workarounds based on findings by Jim Driscoll
+       // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
+       globalEval: function( data ) {
+               if ( data && jQuery.trim( data ) ) {
+                       // We use execScript on Internet Explorer
+                       // We use an anonymous function so that context is window
+                       // rather than jQuery in Firefox
+                       ( window.execScript || function( data ) {
+                               window[ "eval" ].call( window, data );
+                       } )( data );
+               }
+       },
+
+       // Convert dashed to camelCase; used by the css and data modules
+       // Microsoft forgot to hump their vendor prefix (#9572)
+       camelCase: function( string ) {
+               return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+       },
+
+       nodeName: function( elem, name ) {
+               return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
+       },
+
+       // args is for internal usage only
+       each: function( obj, callback, args ) {
+               var value,
+                       i = 0,
+                       length = obj.length,
+                       isArray = isArraylike( obj );
+
+               if ( args ) {
+                       if ( isArray ) {
+                               for ( ; i < length; i++ ) {
+                                       value = callback.apply( obj[ i ], args );
+
+                                       if ( value === false ) {
+                                               break;
+                                       }
+                               }
+                       } else {
+                               for ( i in obj ) {
+                                       value = callback.apply( obj[ i ], args );
+
+                                       if ( value === false ) {
+                                               break;
+                                       }
+                               }
+                       }
+
+               // A special, fast, case for the most common use of each
+               } else {
+                       if ( isArray ) {
+                               for ( ; i < length; i++ ) {
+                                       value = callback.call( obj[ i ], i, obj[ i ] );
+
+                                       if ( value === false ) {
+                                               break;
+                                       }
+                               }
+                       } else {
+                               for ( i in obj ) {
+                                       value = callback.call( obj[ i ], i, obj[ i ] );
+
+                                       if ( value === false ) {
+                                               break;
+                                       }
+                               }
+                       }
+               }
+
+               return obj;
+       },
+
+       // Use native String.trim function wherever possible
+       trim: trim && !trim.call("\uFEFF\xA0") ?
+               function( text ) {
+                       return text == null ?
+                               "" :
+                               trim.call( text );
+               } :
+
+               // Otherwise use our own trimming functionality
+               function( text ) {
+                       return text == null ?
+                               "" :
+                               ( text + "" ).replace( rtrim, "" );
+               },
+
+       // results is for internal usage only
+       makeArray: function( arr, results ) {
+               var ret = results || [];
+
+               if ( arr != null ) {
+                       if ( isArraylike( Object(arr) ) ) {
+                               jQuery.merge( ret,
+                                       typeof arr === "string" ?
+                                       [ arr ] : arr
+                               );
+                       } else {
+                               push.call( ret, arr );
+                       }
+               }
+
+               return ret;
+       },
+
+       inArray: function( elem, arr, i ) {
+               var len;
+
+               if ( arr ) {
+                       if ( indexOf ) {
+                               return indexOf.call( arr, elem, i );
+                       }
+
+                       len = arr.length;
+                       i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
+
+                       for ( ; i < len; i++ ) {
+                               // Skip accessing in sparse arrays
+                               if ( i in arr && arr[ i ] === elem ) {
+                                       return i;
+                               }
+                       }
+               }
+
+               return -1;
+       },
+
+       merge: function( first, second ) {
+               var len = +second.length,
+                       j = 0,
+                       i = first.length;
+
+               while ( j < len ) {
+                       first[ i++ ] = second[ j++ ];
+               }
+
+               // Support: IE<9
+               // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
+               if ( len !== len ) {
+                       while ( second[j] !== undefined ) {
+                               first[ i++ ] = second[ j++ ];
+                       }
+               }
+
+               first.length = i;
+
+               return first;
+       },
+
+       grep: function( elems, callback, invert ) {
+               var callbackInverse,
+                       matches = [],
+                       i = 0,
+                       length = elems.length,
+                       callbackExpect = !invert;
+
+               // Go through the array, only saving the items
+               // that pass the validator function
+               for ( ; i < length; i++ ) {
+                       callbackInverse = !callback( elems[ i ], i );
+                       if ( callbackInverse !== callbackExpect ) {
+                               matches.push( elems[ i ] );
+                       }
+               }
+
+               return matches;
+       },
+
+       // arg is for internal usage only
+       map: function( elems, callback, arg ) {
+               var value,
+                       i = 0,
+                       length = elems.length,
+                       isArray = isArraylike( elems ),
+                       ret = [];
+
+               // Go through the array, translating each of the items to their new values
+               if ( isArray ) {
+                       for ( ; i < length; i++ ) {
+                               value = callback( elems[ i ], i, arg );
+
+                               if ( value != null ) {
+                                       ret.push( value );
+                               }
+                       }
+
+               // Go through every key on the object,
+               } else {
+                       for ( i in elems ) {
+                               value = callback( elems[ i ], i, arg );
+
+                               if ( value != null ) {
+                                       ret.push( value );
+                               }
+                       }
+               }
+
+               // Flatten any nested arrays
+               return concat.apply( [], ret );
+       },
+
+       // A global GUID counter for objects
+       guid: 1,
+
+       // Bind a function to a context, optionally partially applying any
+       // arguments.
+       proxy: function( fn, context ) {
+               var args, proxy, tmp;
+
+               if ( typeof context === "string" ) {
+                       tmp = fn[ context ];
+                       context = fn;
+                       fn = tmp;
+               }
+
+               // Quick check to determine if target is callable, in the spec
+               // this throws a TypeError, but we will just return undefined.
+               if ( !jQuery.isFunction( fn ) ) {
+                       return undefined;
+               }
+
+               // Simulated bind
+               args = slice.call( arguments, 2 );
+               proxy = function() {
+                       return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
+               };
+
+               // Set the guid of unique handler to the same of original handler, so it can be removed
+               proxy.guid = fn.guid = fn.guid || jQuery.guid++;
+
+               return proxy;
+       },
+
+       now: function() {
+               return +( new Date() );
+       },
+
+       // jQuery.support is not used in Core but other projects attach their
+       // properties to it so it needs to exist.
+       support: support
+});
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
+       class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+function isArraylike( obj ) {
+       var length = obj.length,
+               type = jQuery.type( obj );
+
+       if ( type === "function" || jQuery.isWindow( obj ) ) {
+               return false;
+       }
+
+       if ( obj.nodeType === 1 && length ) {
+               return true;
+       }
+
+       return type === "array" || length === 0 ||
+               typeof length === "number" && length > 0 && ( length - 1 ) in obj;
+}
+var Sizzle =
+/*!
+ * Sizzle CSS Selector Engine v1.10.16
+ * http://sizzlejs.com/
+ *
+ * Copyright 2013 jQuery Foundation, Inc. and other contributors
+ * Released under the MIT license
+ * http://jquery.org/license
+ *
+ * Date: 2014-01-13
+ */
+(function( window ) {
+
+var i,
+       support,
+       Expr,
+       getText,
+       isXML,
+       compile,
+       outermostContext,
+       sortInput,
+       hasDuplicate,
+
+       // Local document vars
+       setDocument,
+       document,
+       docElem,
+       documentIsHTML,
+       rbuggyQSA,
+       rbuggyMatches,
+       matches,
+       contains,
+
+       // Instance-specific data
+       expando = "sizzle" + -(new Date()),
+       preferredDoc = window.document,
+       dirruns = 0,
+       done = 0,
+       classCache = createCache(),
+       tokenCache = createCache(),
+       compilerCache = createCache(),
+       sortOrder = function( a, b ) {
+               if ( a === b ) {
+                       hasDuplicate = true;
+               }
+               return 0;
+       },
+
+       // General-purpose constants
+       strundefined = typeof undefined,
+       MAX_NEGATIVE = 1 << 31,
+
+       // Instance methods
+       hasOwn = ({}).hasOwnProperty,
+       arr = [],
+       pop = arr.pop,
+       push_native = arr.push,
+       push = arr.push,
+       slice = arr.slice,
+       // Use a stripped-down indexOf if we can't use a native one
+       indexOf = arr.indexOf || function( elem ) {
+               var i = 0,
+                       len = this.length;
+               for ( ; i < len; i++ ) {
+                       if ( this[i] === elem ) {
+                               return i;
+                       }
+               }
+               return -1;
+       },
+
+       booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
+
+       // Regular expressions
+
+       // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
+       whitespace = "[\\x20\\t\\r\\n\\f]",
+       // http://www.w3.org/TR/css3-syntax/#characters
+       characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
+
+       // Loosely modeled on CSS identifier characters
+       // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
+       // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
+       identifier = characterEncoding.replace( "w", "w#" ),
+
+       // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
+       attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
+               "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
+
+       // Prefer arguments quoted,
+       //   then not containing pseudos/brackets,
+       //   then attribute selectors/non-parenthetical expressions,
+       //   then anything else
+       // These preferences are here to reduce the number of selectors
+       //   needing tokenize in the PSEUDO preFilter
+       pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
+
+       // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
+       rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
+
+       rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
+       rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
+
+       rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
+
+       rpseudo = new RegExp( pseudos ),
+       ridentifier = new RegExp( "^" + identifier + "$" ),
+
+       matchExpr = {
+               "ID": new RegExp( "^#(" + characterEncoding + ")" ),
+               "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
+               "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
+               "ATTR": new RegExp( "^" + attributes ),
+               "PSEUDO": new RegExp( "^" + pseudos ),
+               "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
+                       "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
+                       "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
+               "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
+               // For use in libraries implementing .is()
+               // We use this for POS matching in `select`
+               "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
+                       whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
+       },
+
+       rinputs = /^(?:input|select|textarea|button)$/i,
+       rheader = /^h\d$/i,
+
+       rnative = /^[^{]+\{\s*\[native \w/,
+
+       // Easily-parseable/retrievable ID or TAG or CLASS selectors
+       rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
+
+       rsibling = /[+~]/,
+       rescape = /'|\\/g,
+
+       // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
+       runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
+       funescape = function( _, escaped, escapedWhitespace ) {
+               var high = "0x" + escaped - 0x10000;
+               // NaN means non-codepoint
+               // Support: Firefox
+               // Workaround erroneous numeric interpretation of +"0x"
+               return high !== high || escapedWhitespace ?
+                       escaped :
+                       high < 0 ?
+                               // BMP codepoint
+                               String.fromCharCode( high + 0x10000 ) :
+                               // Supplemental Plane codepoint (surrogate pair)
+                               String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
+       };
+
+// Optimize for push.apply( _, NodeList )
+try {
+       push.apply(
+               (arr = slice.call( preferredDoc.childNodes )),
+               preferredDoc.childNodes
+       );
+       // Support: Android<4.0
+       // Detect silently failing push.apply
+       arr[ preferredDoc.childNodes.length ].nodeType;
+} catch ( e ) {
+       push = { apply: arr.length ?
+
+               // Leverage slice if possible
+               function( target, els ) {
+                       push_native.apply( target, slice.call(els) );
+               } :
+
+               // Support: IE<9
+               // Otherwise append directly
+               function( target, els ) {
+                       var j = target.length,
+                               i = 0;
+                       // Can't trust NodeList.length
+                       while ( (target[j++] = els[i++]) ) {}
+                       target.length = j - 1;
+               }
+       };
+}
+
+function Sizzle( selector, context, results, seed ) {
+       var match, elem, m, nodeType,
+               // QSA vars
+               i, groups, old, nid, newContext, newSelector;
+
+       if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
+               setDocument( context );
+       }
+
+       context = context || document;
+       results = results || [];
+
+       if ( !selector || typeof selector !== "string" ) {
+               return results;
+       }
+
+       if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
+               return [];
+       }
+
+       if ( documentIsHTML && !seed ) {
+
+               // Shortcuts
+               if ( (match = rquickExpr.exec( selector )) ) {
+                       // Speed-up: Sizzle("#ID")
+                       if ( (m = match[1]) ) {
+                               if ( nodeType === 9 ) {
+                                       elem = context.getElementById( m );
+                                       // Check parentNode to catch when Blackberry 4.6 returns
+                                       // nodes that are no longer in the document (jQuery #6963)
+                                       if ( elem && elem.parentNode ) {
+                                               // Handle the case where IE, Opera, and Webkit return items
+                                               // by name instead of ID
+                                               if ( elem.id === m ) {
+                                                       results.push( elem );
+                                                       return results;
+                                               }
+                                       } else {
+                                               return results;
+                                       }
+                               } else {
+                                       // Context is not a document
+                                       if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
+                                               contains( context, elem ) && elem.id === m ) {
+                                               results.push( elem );
+                                               return results;
+                                       }
+                               }
+
+                       // Speed-up: Sizzle("TAG")
+                       } else if ( match[2] ) {
+                               push.apply( results, context.getElementsByTagName( selector ) );
+                               return results;
+
+                       // Speed-up: Sizzle(".CLASS")
+                       } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
+                               push.apply( results, context.getElementsByClassName( m ) );
+                               return results;
+                       }
+               }
+
+               // QSA path
+               if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
+                       nid = old = expando;
+                       newContext = context;
+                       newSelector = nodeType === 9 && selector;
+
+                       // qSA works strangely on Element-rooted queries
+                       // We can work around this by specifying an extra ID on the root
+                       // and working up from there (Thanks to Andrew Dupont for the technique)
+                       // IE 8 doesn't work on object elements
+                       if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+                               groups = tokenize( selector );
+
+                               if ( (old = context.getAttribute("id")) ) {
+                                       nid = old.replace( rescape, "\\$&" );
+                               } else {
+                                       context.setAttribute( "id", nid );
+                               }
+                               nid = "[id='" + nid + "'] ";
+
+                               i = groups.length;
+                               while ( i-- ) {
+                                       groups[i] = nid + toSelector( groups[i] );
+                               }
+                               newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
+                               newSelector = groups.join(",");
+                       }
+
+                       if ( newSelector ) {
+                               try {
+                                       push.apply( results,
+                                               newContext.querySelectorAll( newSelector )
+                                       );
+                                       return results;
+                               } catch(qsaError) {
+                               } finally {
+                                       if ( !old ) {
+                                               context.removeAttribute("id");
+                                       }
+                               }
+                       }
+               }
+       }
+
+       // All others
+       return select( selector.replace( rtrim, "$1" ), context, results, seed );
+}
+
+/**
+ * Create key-value caches of limited size
+ * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
+ *     property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
+ *     deleting the oldest entry
+ */
+function createCache() {
+       var keys = [];
+
+       function cache( key, value ) {
+               // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
+               if ( keys.push( key + " " ) > Expr.cacheLength ) {
+                       // Only keep the most recent entries
+                       delete cache[ keys.shift() ];
+               }
+               return (cache[ key + " " ] = value);
+       }
+       return cache;
+}
+
+/**
+ * Mark a function for special use by Sizzle
+ * @param {Function} fn The function to mark
+ */
+function markFunction( fn ) {
+       fn[ expando ] = true;
+       return fn;
+}
+
+/**
+ * Support testing using an element
+ * @param {Function} fn Passed the created div and expects a boolean result
+ */
+function assert( fn ) {
+       var div = document.createElement("div");
+
+       try {
+               return !!fn( div );
+       } catch (e) {
+               return false;
+       } finally {
+               // Remove from its parent by default
+               if ( div.parentNode ) {
+                       div.parentNode.removeChild( div );
+               }
+               // release memory in IE
+               div = null;
+       }
+}
+
+/**
+ * Adds the same handler for all of the specified attrs
+ * @param {String} attrs Pipe-separated list of attributes
+ * @param {Function} handler The method that will be applied
+ */
+function addHandle( attrs, handler ) {
+       var arr = attrs.split("|"),
+               i = attrs.length;
+
+       while ( i-- ) {
+               Expr.attrHandle[ arr[i] ] = handler;
+       }
+}
+
+/**
+ * Checks document order of two siblings
+ * @param {Element} a
+ * @param {Element} b
+ * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
+ */
+function siblingCheck( a, b ) {
+       var cur = b && a,
+               diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
+                       ( ~b.sourceIndex || MAX_NEGATIVE ) -
+                       ( ~a.sourceIndex || MAX_NEGATIVE );
+
+       // Use IE sourceIndex if available on both nodes
+       if ( diff ) {
+               return diff;
+       }
+
+       // Check if b follows a
+       if ( cur ) {
+               while ( (cur = cur.nextSibling) ) {
+                       if ( cur === b ) {
+                               return -1;
+                       }
+               }
+       }
+
+       return a ? 1 : -1;
+}
+
+/**
+ * Returns a function to use in pseudos for input types
+ * @param {String} type
+ */
+function createInputPseudo( type ) {
+       return function( elem ) {
+               var name = elem.nodeName.toLowerCase();
+               return name === "input" && elem.type === type;
+       };
+}
+
+/**
+ * Returns a function to use in pseudos for buttons
+ * @param {String} type
+ */
+function createButtonPseudo( type ) {
+       return function( elem ) {
+               var name = elem.nodeName.toLowerCase();
+               return (name === "input" || name === "button") && elem.type === type;
+       };
+}
+
+/**
+ * Returns a function to use in pseudos for positionals
+ * @param {Function} fn
+ */
+function createPositionalPseudo( fn ) {
+       return markFunction(function( argument ) {
+               argument = +argument;
+               return markFunction(function( seed, matches ) {
+                       var j,
+                               matchIndexes = fn( [], seed.length, argument ),
+                               i = matchIndexes.length;
+
+                       // Match elements found at the specified indexes
+                       while ( i-- ) {
+                               if ( seed[ (j = matchIndexes[i]) ] ) {
+                                       seed[j] = !(matches[j] = seed[j]);
+                               }
+                       }
+               });
+       });
+}
+
+/**
+ * Checks a node for validity as a Sizzle context
+ * @param {Element|Object=} context
+ * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
+ */
+function testContext( context ) {
+       return context && typeof context.getElementsByTagName !== strundefined && context;
+}
+
+// Expose support vars for convenience
+support = Sizzle.support = {};
+
+/**
+ * Detects XML nodes
+ * @param {Element|Object} elem An element or a document
+ * @returns {Boolean} True iff elem is a non-HTML XML node
+ */
+isXML = Sizzle.isXML = function( elem ) {
+       // documentElement is verified for cases where it doesn't yet exist
+       // (such as loading iframes in IE - #4833)
+       var documentElement = elem && (elem.ownerDocument || elem).documentElement;
+       return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+/**
+ * Sets document-related variables once based on the current document
+ * @param {Element|Object} [doc] An element or document object to use to set the document
+ * @returns {Object} Returns the current document
+ */
+setDocument = Sizzle.setDocument = function( node ) {
+       var hasCompare,
+               doc = node ? node.ownerDocument || node : preferredDoc,
+               parent = doc.defaultView;
+
+       // If no document and documentElement is available, return
+       if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
+               return document;
+       }
+
+       // Set our document
+       document = doc;
+       docElem = doc.documentElement;
+
+       // Support tests
+       documentIsHTML = !isXML( doc );
+
+       // Support: IE>8
+       // If iframe document is assigned to "document" variable and if iframe has been reloaded,
+       // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
+       // IE6-8 do not support the defaultView property so parent will be undefined
+       if ( parent && parent !== parent.top ) {
+               // IE11 does not have attachEvent, so all must suffer
+               if ( parent.addEventListener ) {
+                       parent.addEventListener( "unload", function() {
+                               setDocument();
+                       }, false );
+               } else if ( parent.attachEvent ) {
+                       parent.attachEvent( "onunload", function() {
+                               setDocument();
+                       });
+               }
+       }
+
+       /* Attributes
+       ---------------------------------------------------------------------- */
+
+       // Support: IE<8
+       // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
+       support.attributes = assert(function( div ) {
+               div.className = "i";
+               return !div.getAttribute("className");
+       });
+
+       /* getElement(s)By*
+       ---------------------------------------------------------------------- */
+
+       // Check if getElementsByTagName("*") returns only elements
+       support.getElementsByTagName = assert(function( div ) {
+               div.appendChild( doc.createComment("") );
+               return !div.getElementsByTagName("*").length;
+       });
+
+       // Check if getElementsByClassName can be trusted
+       support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
+               div.innerHTML = "<div class='a'></div><div class='a i'></div>";
+
+               // Support: Safari<4
+               // Catch class over-caching
+               div.firstChild.className = "i";
+               // Support: Opera<10
+               // Catch gEBCN failure to find non-leading classes
+               return div.getElementsByClassName("i").length === 2;
+       });
+
+       // Support: IE<10
+       // Check if getElementById returns elements by name
+       // The broken getElementById methods don't pick up programatically-set names,
+       // so use a roundabout getElementsByName test
+       support.getById = assert(function( div ) {
+               docElem.appendChild( div ).id = expando;
+               return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
+       });
+
+       // ID find and filter
+       if ( support.getById ) {
+               Expr.find["ID"] = function( id, context ) {
+                       if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
+                               var m = context.getElementById( id );
+                               // Check parentNode to catch when Blackberry 4.6 returns
+                               // nodes that are no longer in the document #6963
+                               return m && m.parentNode ? [m] : [];
+                       }
+               };
+               Expr.filter["ID"] = function( id ) {
+                       var attrId = id.replace( runescape, funescape );
+                       return function( elem ) {
+                               return elem.getAttribute("id") === attrId;
+                       };
+               };
+       } else {
+               // Support: IE6/7
+               // getElementById is not reliable as a find shortcut
+               delete Expr.find["ID"];
+
+               Expr.filter["ID"] =  function( id ) {
+                       var attrId = id.replace( runescape, funescape );
+                       return function( elem ) {
+                               var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
+                               return node && node.value === attrId;
+                       };
+               };
+       }
+
+       // Tag
+       Expr.find["TAG"] = support.getElementsByTagName ?
+               function( tag, context ) {
+                       if ( typeof context.getElementsByTagName !== strundefined ) {
+                               return context.getElementsByTagName( tag );
+                       }
+               } :
+               function( tag, context ) {
+                       var elem,
+                               tmp = [],
+                               i = 0,
+                               results = context.getElementsByTagName( tag );
+
+                       // Filter out possible comments
+                       if ( tag === "*" ) {
+                               while ( (elem = results[i++]) ) {
+                                       if ( elem.nodeType === 1 ) {
+                                               tmp.push( elem );
+                                       }
+                               }
+
+                               return tmp;
+                       }
+                       return results;
+               };
+
+       // Class
+       Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
+               if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
+                       return context.getElementsByClassName( className );
+               }
+       };
+
+       /* QSA/matchesSelector
+       ---------------------------------------------------------------------- */
+
+       // QSA and matchesSelector support
+
+       // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
+       rbuggyMatches = [];
+
+       // qSa(:focus) reports false when true (Chrome 21)
+       // We allow this because of a bug in IE8/9 that throws an error
+       // whenever `document.activeElement` is accessed on an iframe
+       // So, we allow :focus to pass through QSA all the time to avoid the IE error
+       // See http://bugs.jquery.com/ticket/13378
+       rbuggyQSA = [];
+
+       if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
+               // Build QSA regex
+               // Regex strategy adopted from Diego Perini
+               assert(function( div ) {
+                       // Select is set to empty string on purpose
+                       // This is to test IE's treatment of not explicitly
+                       // setting a boolean content attribute,
+                       // since its presence should be enough
+                       // http://bugs.jquery.com/ticket/12359
+                       div.innerHTML = "<select t=''><option selected=''></option></select>";
+
+                       // Support: IE8, Opera 10-12
+                       // Nothing should be selected when empty strings follow ^= or $= or *=
+                       if ( div.querySelectorAll("[t^='']").length ) {
+                               rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
+                       }
+
+                       // Support: IE8
+                       // Boolean attributes and "value" are not treated correctly
+                       if ( !div.querySelectorAll("[selected]").length ) {
+                               rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
+                       }
+
+                       // Webkit/Opera - :checked should return selected option elements
+                       // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+                       // IE8 throws error here and will not see later tests
+                       if ( !div.querySelectorAll(":checked").length ) {
+                               rbuggyQSA.push(":checked");
+                       }
+               });
+
+               assert(function( div ) {
+                       // Support: Windows 8 Native Apps
+                       // The type and name attributes are restricted during .innerHTML assignment
+                       var input = doc.createElement("input");
+                       input.setAttribute( "type", "hidden" );
+                       div.appendChild( input ).setAttribute( "name", "D" );
+
+                       // Support: IE8
+                       // Enforce case-sensitivity of name attribute
+                       if ( div.querySelectorAll("[name=d]").length ) {
+                               rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
+                       }
+
+                       // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
+                       // IE8 throws error here and will not see later tests
+                       if ( !div.querySelectorAll(":enabled").length ) {
+                               rbuggyQSA.push( ":enabled", ":disabled" );
+                       }
+
+                       // Opera 10-11 does not throw on post-comma invalid pseudos
+                       div.querySelectorAll("*,:x");
+                       rbuggyQSA.push(",.*:");
+               });
+       }
+
+       if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
+               docElem.mozMatchesSelector ||
+               docElem.oMatchesSelector ||
+               docElem.msMatchesSelector) )) ) {
+
+               assert(function( div ) {
+                       // Check to see if it's possible to do matchesSelector
+                       // on a disconnected node (IE 9)
+                       support.disconnectedMatch = matches.call( div, "div" );
+
+                       // This should fail with an exception
+                       // Gecko does not error, returns false instead
+                       matches.call( div, "[s!='']:x" );
+                       rbuggyMatches.push( "!=", pseudos );
+               });
+       }
+
+       rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
+       rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
+
+       /* Contains
+       ---------------------------------------------------------------------- */
+       hasCompare = rnative.test( docElem.compareDocumentPosition );
+
+       // Element contains another
+       // Purposefully does not implement inclusive descendent
+       // As in, an element does not contain itself
+       contains = hasCompare || rnative.test( docElem.contains ) ?
+               function( a, b ) {
+                       var adown = a.nodeType === 9 ? a.documentElement : a,
+                               bup = b && b.parentNode;
+                       return a === bup || !!( bup && bup.nodeType === 1 && (
+                               adown.contains ?
+                                       adown.contains( bup ) :
+                                       a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
+                       ));
+               } :
+               function( a, b ) {
+                       if ( b ) {
+                               while ( (b = b.parentNode) ) {
+                                       if ( b === a ) {
+                                               return true;
+                                       }
+                               }
+                       }
+                       return false;
+               };
+
+       /* Sorting
+       ---------------------------------------------------------------------- */
+
+       // Document order sorting
+       sortOrder = hasCompare ?
+       function( a, b ) {
+
+               // Flag for duplicate removal
+               if ( a === b ) {
+                       hasDuplicate = true;
+                       return 0;
+               }
+
+               // Sort on method existence if only one input has compareDocumentPosition
+               var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
+               if ( compare ) {
+                       return compare;
+               }
+
+               // Calculate position if both inputs belong to the same document
+               compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
+                       a.compareDocumentPosition( b ) :
+
+                       // Otherwise we know they are disconnected
+                       1;
+
+               // Disconnected nodes
+               if ( compare & 1 ||
+                       (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
+
+                       // Choose the first element that is related to our preferred document
+                       if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
+                               return -1;
+                       }
+                       if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
+                               return 1;
+                       }
+
+                       // Maintain original order
+                       return sortInput ?
+                               ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
+                               0;
+               }
+
+               return compare & 4 ? -1 : 1;
+       } :
+       function( a, b ) {
+               // Exit early if the nodes are identical
+               if ( a === b ) {
+                       hasDuplicate = true;
+                       return 0;
+               }
+
+               var cur,
+                       i = 0,
+                       aup = a.parentNode,
+                       bup = b.parentNode,
+                       ap = [ a ],
+                       bp = [ b ];
+
+               // Parentless nodes are either documents or disconnected
+               if ( !aup || !bup ) {
+                       return a === doc ? -1 :
+                               b === doc ? 1 :
+                               aup ? -1 :
+                               bup ? 1 :
+                               sortInput ?
+                               ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
+                               0;
+
+               // If the nodes are siblings, we can do a quick check
+               } else if ( aup === bup ) {
+                       return siblingCheck( a, b );
+               }
+
+               // Otherwise we need full lists of their ancestors for comparison
+               cur = a;
+               while ( (cur = cur.parentNode) ) {
+                       ap.unshift( cur );
+               }
+               cur = b;
+               while ( (cur = cur.parentNode) ) {
+                       bp.unshift( cur );
+               }
+
+               // Walk down the tree looking for a discrepancy
+               while ( ap[i] === bp[i] ) {
+                       i++;
+               }
+
+               return i ?
+                       // Do a sibling check if the nodes have a common ancestor
+                       siblingCheck( ap[i], bp[i] ) :
+
+                       // Otherwise nodes in our document sort first
+                       ap[i] === preferredDoc ? -1 :
+                       bp[i] === preferredDoc ? 1 :
+                       0;
+       };
+
+       return doc;
+};
+
+Sizzle.matches = function( expr, elements ) {
+       return Sizzle( expr, null, null, elements );
+};
+
+Sizzle.matchesSelector = function( elem, expr ) {
+       // Set document vars if needed
+       if ( ( elem.ownerDocument || elem ) !== document ) {
+               setDocument( elem );
+       }
+
+       // Make sure that attribute selectors are quoted
+       expr = expr.replace( rattributeQuotes, "='$1']" );
+
+       if ( support.matchesSelector && documentIsHTML &&
+               ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
+               ( !rbuggyQSA     || !rbuggyQSA.test( expr ) ) ) {
+
+               try {
+                       var ret = matches.call( elem, expr );
+
+                       // IE 9's matchesSelector returns false on disconnected nodes
+                       if ( ret || support.disconnectedMatch ||
+                                       // As well, disconnected nodes are said to be in a document
+                                       // fragment in IE 9
+                                       elem.document && elem.document.nodeType !== 11 ) {
+                               return ret;
+                       }
+               } catch(e) {}
+       }
+
+       return Sizzle( expr, document, null, [elem] ).length > 0;
+};
+
+Sizzle.contains = function( context, elem ) {
+       // Set document vars if needed
+       if ( ( context.ownerDocument || context ) !== document ) {
+               setDocument( context );
+       }
+       return contains( context, elem );
+};
+
+Sizzle.attr = function( elem, name ) {
+       // Set document vars if needed
+       if ( ( elem.ownerDocument || elem ) !== document ) {
+               setDocument( elem );
+       }
+
+       var fn = Expr.attrHandle[ name.toLowerCase() ],
+               // Don't get fooled by Object.prototype properties (jQuery #13807)
+               val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
+                       fn( elem, name, !documentIsHTML ) :
+                       undefined;
+
+       return val !== undefined ?
+               val :
+               support.attributes || !documentIsHTML ?
+                       elem.getAttribute( name ) :
+                       (val = elem.getAttributeNode(name)) && val.specified ?
+                               val.value :
+                               null;
+};
+
+Sizzle.error = function( msg ) {
+       throw new Error( "Syntax error, unrecognized expression: " + msg );
+};
+
+/**
+ * Document sorting and removing duplicates
+ * @param {ArrayLike} results
+ */
+Sizzle.uniqueSort = function( results ) {
+       var elem,
+               duplicates = [],
+               j = 0,
+               i = 0;
+
+       // Unless we *know* we can detect duplicates, assume their presence
+       hasDuplicate = !support.detectDuplicates;
+       sortInput = !support.sortStable && results.slice( 0 );
+       results.sort( sortOrder );
+
+       if ( hasDuplicate ) {
+               while ( (elem = results[i++]) ) {
+                       if ( elem === results[ i ] ) {
+                               j = duplicates.push( i );
+                       }
+               }
+               while ( j-- ) {
+                       results.splice( duplicates[ j ], 1 );
+               }
+       }
+
+       // Clear input after sorting to release objects
+       // See https://github.com/jquery/sizzle/pull/225
+       sortInput = null;
+
+       return results;
+};
+
+/**
+ * Utility function for retrieving the text value of an array of DOM nodes
+ * @param {Array|Element} elem
+ */
+getText = Sizzle.getText = function( elem ) {
+       var node,
+               ret = "",
+               i = 0,
+               nodeType = elem.nodeType;
+
+       if ( !nodeType ) {
+               // If no nodeType, this is expected to be an array
+               while ( (node = elem[i++]) ) {
+                       // Do not traverse comment nodes
+                       ret += getText( node );
+               }
+       } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
+               // Use textContent for elements
+               // innerText usage removed for consistency of new lines (jQuery #11153)
+               if ( typeof elem.textContent === "string" ) {
+                       return elem.textContent;
+               } else {
+                       // Traverse its children
+                       for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+                               ret += getText( elem );
+                       }
+               }
+       } else if ( nodeType === 3 || nodeType === 4 ) {
+               return elem.nodeValue;
+       }
+       // Do not include comment or processing instruction nodes
+
+       return ret;
+};
+
+Expr = Sizzle.selectors = {
+
+       // Can be adjusted by the user
+       cacheLength: 50,
+
+       createPseudo: markFunction,
+
+       match: matchExpr,
+
+       attrHandle: {},
+
+       find: {},
+
+       relative: {
+               ">": { dir: "parentNode", first: true },
+               " ": { dir: "parentNode" },
+               "+": { dir: "previousSibling", first: true },
+               "~": { dir: "previousSibling" }
+       },
+
+       preFilter: {
+               "ATTR": function( match ) {
+                       match[1] = match[1].replace( runescape, funescape );
+
+                       // Move the given value to match[3] whether quoted or unquoted
+                       match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
+
+                       if ( match[2] === "~=" ) {
+                               match[3] = " " + match[3] + " ";
+                       }
+
+                       return match.slice( 0, 4 );
+               },
+
+               "CHILD": function( match ) {
+                       /* matches from matchExpr["CHILD"]
+                               1 type (only|nth|...)
+                               2 what (child|of-type)
+                               3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
+                               4 xn-component of xn+y argument ([+-]?\d*n|)
+                               5 sign of xn-component
+                               6 x of xn-component
+                               7 sign of y-component
+                               8 y of y-component
+                       */
+                       match[1] = match[1].toLowerCase();
+
+                       if ( match[1].slice( 0, 3 ) === "nth" ) {
+                               // nth-* requires argument
+                               if ( !match[3] ) {
+                                       Sizzle.error( match[0] );
+                               }
+
+                               // numeric x and y parameters for Expr.filter.CHILD
+                               // remember that false/true cast respectively to 0/1
+                               match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
+                               match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
+
+                       // other types prohibit arguments
+                       } else if ( match[3] ) {
+                               Sizzle.error( match[0] );
+                       }
+
+                       return match;
+               },
+
+               "PSEUDO": function( match ) {
+                       var excess,
+                               unquoted = !match[5] && match[2];
+
+                       if ( matchExpr["CHILD"].test( match[0] ) ) {
+                               return null;
+                       }
+
+                       // Accept quoted arguments as-is
+                       if ( match[3] && match[4] !== undefined ) {
+                               match[2] = match[4];
+
+                       // Strip excess characters from unquoted arguments
+                       } else if ( unquoted && rpseudo.test( unquoted ) &&
+                               // Get excess from tokenize (recursively)
+                               (excess = tokenize( unquoted, true )) &&
+                               // advance to the next closing parenthesis
+                               (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
+
+                               // excess is a negative index
+                               match[0] = match[0].slice( 0, excess );
+                               match[2] = unquoted.slice( 0, excess );
+                       }
+
+                       // Return only captures needed by the pseudo filter method (type and argument)
+                       return match.slice( 0, 3 );
+               }
+       },
+
+       filter: {
+
+               "TAG": function( nodeNameSelector ) {
+                       var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
+                       return nodeNameSelector === "*" ?
+                               function() { return true; } :
+                               function( elem ) {
+                                       return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
+                               };
+               },
+
+               "CLASS": function( className ) {
+                       var pattern = classCache[ className + " " ];
+
+                       return pattern ||
+                               (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
+                               classCache( className, function( elem ) {
+                                       return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
+                               });
+               },
+
+               "ATTR": function( name, operator, check ) {
+                       return function( elem ) {
+                               var result = Sizzle.attr( elem, name );
+
+                               if ( result == null ) {
+                                       return operator === "!=";
+                               }
+                               if ( !operator ) {
+                                       return true;
+                               }
+
+                               result += "";
+
+                               return operator === "=" ? result === check :
+                                       operator === "!=" ? result !== check :
+                                       operator === "^=" ? check && result.indexOf( check ) === 0 :
+                                       operator === "*=" ? check && result.indexOf( check ) > -1 :
+                                       operator === "$=" ? check && result.slice( -check.length ) === check :
+                                       operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
+                                       operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
+                                       false;
+                       };
+               },
+
+               "CHILD": function( type, what, argument, first, last ) {
+                       var simple = type.slice( 0, 3 ) !== "nth",
+                               forward = type.slice( -4 ) !== "last",
+                               ofType = what === "of-type";
+
+                       return first === 1 && last === 0 ?
+
+                               // Shortcut for :nth-*(n)
+                               function( elem ) {
+                                       return !!elem.parentNode;
+                               } :
+
+                               function( elem, context, xml ) {
+                                       var cache, outerCache, node, diff, nodeIndex, start,
+                                               dir = simple !== forward ? "nextSibling" : "previousSibling",
+                                               parent = elem.parentNode,
+                                               name = ofType && elem.nodeName.toLowerCase(),
+                                               useCache = !xml && !ofType;
+
+                                       if ( parent ) {
+
+                                               // :(first|last|only)-(child|of-type)
+                                               if ( simple ) {
+                                                       while ( dir ) {
+                                                               node = elem;
+                                                               while ( (node = node[ dir ]) ) {
+                                                                       if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
+                                                                               return false;
+                                                                       }
+                                                               }
+                                                               // Reverse direction for :only-* (if we haven't yet done so)
+                                                               start = dir = type === "only" && !start && "nextSibling";
+                                                       }
+                                                       return true;
+                                               }
+
+                                               start = [ forward ? parent.firstChild : parent.lastChild ];
+
+                                               // non-xml :nth-child(...) stores cache data on `parent`
+                                               if ( forward && useCache ) {
+                                                       // Seek `elem` from a previously-cached index
+                                                       outerCache = parent[ expando ] || (parent[ expando ] = {});
+                                                       cache = outerCache[ type ] || [];
+                                                       nodeIndex = cache[0] === dirruns && cache[1];
+                                                       diff = cache[0] === dirruns && cache[2];
+                                                       node = nodeIndex && parent.childNodes[ nodeIndex ];
+
+                                                       while ( (node = ++nodeIndex && node && node[ dir ] ||
+
+                                                               // Fallback to seeking `elem` from the start
+                                                               (diff = nodeIndex = 0) || start.pop()) ) {
+
+                                                               // When found, cache indexes on `parent` and break
+                                                               if ( node.nodeType === 1 && ++diff && node === elem ) {
+                                                                       outerCache[ type ] = [ dirruns, nodeIndex, diff ];
+                                                                       break;
+                                                               }
+                                                       }
+
+                                               // Use previously-cached element index if available
+                                               } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
+                                                       diff = cache[1];
+
+                                               // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
+                                               } else {
+                                                       // Use the same loop as above to seek `elem` from the start
+                                                       while ( (node = ++nodeIndex && node && node[ dir ] ||
+                                                               (diff = nodeIndex = 0) || start.pop()) ) {
+
+                                                               if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
+                                                                       // Cache the index of each encountered element
+                                                                       if ( useCache ) {
+                                                                               (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
+                                                                       }
+
+                                                                       if ( node === elem ) {
+                                                                               break;
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+
+                                               // Incorporate the offset, then check against cycle size
+                                               diff -= last;
+                                               return diff === first || ( diff % first === 0 && diff / first >= 0 );
+                                       }
+                               };
+               },
+
+               "PSEUDO": function( pseudo, argument ) {
+                       // pseudo-class names are case-insensitive
+                       // http://www.w3.org/TR/selectors/#pseudo-classes
+                       // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+                       // Remember that setFilters inherits from pseudos
+                       var args,
+                               fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+                                       Sizzle.error( "unsupported pseudo: " + pseudo );
+
+                       // The user may use createPseudo to indicate that
+                       // arguments are needed to create the filter function
+                       // just as Sizzle does
+                       if ( fn[ expando ] ) {
+                               return fn( argument );
+                       }
+
+                       // But maintain support for old signatures
+                       if ( fn.length > 1 ) {
+                               args = [ pseudo, pseudo, "", argument ];
+                               return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
+                                       markFunction(function( seed, matches ) {
+                                               var idx,
+                                                       matched = fn( seed, argument ),
+                                                       i = matched.length;
+                                               while ( i-- ) {
+                                                       idx = indexOf.call( seed, matched[i] );
+                                                       seed[ idx ] = !( matches[ idx ] = matched[i] );
+                                               }
+                                       }) :
+                                       function( elem ) {
+                                               return fn( elem, 0, args );
+                                       };
+                       }
+
+                       return fn;
+               }
+       },
+
+       pseudos: {
+               // Potentially complex pseudos
+               "not": markFunction(function( selector ) {
+                       // Trim the selector passed to compile
+                       // to avoid treating leading and trailing
+                       // spaces as combinators
+                       var input = [],
+                               results = [],
+                               matcher = compile( selector.replace( rtrim, "$1" ) );
+
+                       return matcher[ expando ] ?
+                               markFunction(function( seed, matches, context, xml ) {
+                                       var elem,
+                                               unmatched = matcher( seed, null, xml, [] ),
+                                               i = seed.length;
+
+                                       // Match elements unmatched by `matcher`
+                                       while ( i-- ) {
+                                               if ( (elem = unmatched[i]) ) {
+                                                       seed[i] = !(matches[i] = elem);
+                                               }
+                                       }
+                               }) :
+                               function( elem, context, xml ) {
+                                       input[0] = elem;
+                                       matcher( input, null, xml, results );
+                                       return !results.pop();
+                               };
+               }),
+
+               "has": markFunction(function( selector ) {
+                       return function( elem ) {
+                               return Sizzle( selector, elem ).length > 0;
+                       };
+               }),
+
+               "contains": markFunction(function( text ) {
+                       return function( elem ) {
+                               return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
+                       };
+               }),
+
+               // "Whether an element is represented by a :lang() selector
+               // is based solely on the element's language value
+               // being equal to the identifier C,
+               // or beginning with the identifier C immediately followed by "-".
+               // The matching of C against the element's language value is performed case-insensitively.
+               // The identifier C does not have to be a valid language name."
+               // http://www.w3.org/TR/selectors/#lang-pseudo
+               "lang": markFunction( function( lang ) {
+                       // lang value must be a valid identifier
+                       if ( !ridentifier.test(lang || "") ) {
+                               Sizzle.error( "unsupported lang: " + lang );
+                       }
+                       lang = lang.replace( runescape, funescape ).toLowerCase();
+                       return function( elem ) {
+                               var elemLang;
+                               do {
+                                       if ( (elemLang = documentIsHTML ?
+                                               elem.lang :
+                                               elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
+
+                                               elemLang = elemLang.toLowerCase();
+                                               return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
+                                       }
+                               } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
+                               return false;
+                       };
+               }),
+
+               // Miscellaneous
+               "target": function( elem ) {
+                       var hash = window.location && window.location.hash;
+                       return hash && hash.slice( 1 ) === elem.id;
+               },
+
+               "root": function( elem ) {
+                       return elem === docElem;
+               },
+
+               "focus": function( elem ) {
+                       return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
+               },
+
+               // Boolean properties
+               "enabled": function( elem ) {
+                       return elem.disabled === false;
+               },
+
+               "disabled": function( elem ) {
+                       return elem.disabled === true;
+               },
+
+               "checked": function( elem ) {
+                       // In CSS3, :checked should return both checked and selected elements
+                       // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
+                       var nodeName = elem.nodeName.toLowerCase();
+                       return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
+               },
+
+               "selected": function( elem ) {
+                       // Accessing this property makes selected-by-default
+                       // options in Safari work properly
+                       if ( elem.parentNode ) {
+                               elem.parentNode.selectedIndex;
+                       }
+
+                       return elem.selected === true;
+               },
+
+               // Contents
+               "empty": function( elem ) {
+                       // http://www.w3.org/TR/selectors/#empty-pseudo
+                       // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
+                       //   but not by others (comment: 8; processing instruction: 7; etc.)
+                       // nodeType < 6 works because attributes (2) do not appear as children
+                       for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
+                               if ( elem.nodeType < 6 ) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               },
+
+               "parent": function( elem ) {
+                       return !Expr.pseudos["empty"]( elem );
+               },
+
+               // Element/input types
+               "header": function( elem ) {
+                       return rheader.test( elem.nodeName );
+               },
+
+               "input": function( elem ) {
+                       return rinputs.test( elem.nodeName );
+               },
+
+               "button": function( elem ) {
+                       var name = elem.nodeName.toLowerCase();
+                       return name === "input" && elem.type === "button" || name === "button";
+               },
+
+               "text": function( elem ) {
+                       var attr;
+                       return elem.nodeName.toLowerCase() === "input" &&
+                               elem.type === "text" &&
+
+                               // Support: IE<8
+                               // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
+                               ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
+               },
+
+               // Position-in-collection
+               "first": createPositionalPseudo(function() {
+                       return [ 0 ];
+               }),
+
+               "last": createPositionalPseudo(function( matchIndexes, length ) {
+                       return [ length - 1 ];
+               }),
+
+               "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
+                       return [ argument < 0 ? argument + length : argument ];
+               }),
+
+               "even": createPositionalPseudo(function( matchIndexes, length ) {
+                       var i = 0;
+                       for ( ; i < length; i += 2 ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               }),
+
+               "odd": createPositionalPseudo(function( matchIndexes, length ) {
+                       var i = 1;
+                       for ( ; i < length; i += 2 ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               }),
+
+               "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+                       var i = argument < 0 ? argument + length : argument;
+                       for ( ; --i >= 0; ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               }),
+
+               "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+                       var i = argument < 0 ? argument + length : argument;
+                       for ( ; ++i < length; ) {
+                               matchIndexes.push( i );
+                       }
+                       return matchIndexes;
+               })
+       }
+};
+
+Expr.pseudos["nth"] = Expr.pseudos["eq"];
+
+// Add button/input type pseudos
+for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
+       Expr.pseudos[ i ] = createInputPseudo( i );
+}
+for ( i in { submit: true, reset: true } ) {
+       Expr.pseudos[ i ] = createButtonPseudo( i );
+}
+
+// Easy API for creating new setFilters
+function setFilters() {}
+setFilters.prototype = Expr.filters = Expr.pseudos;
+Expr.setFilters = new setFilters();
+
+function tokenize( selector, parseOnly ) {
+       var matched, match, tokens, type,
+               soFar, groups, preFilters,
+               cached = tokenCache[ selector + " " ];
+
+       if ( cached ) {
+               return parseOnly ? 0 : cached.slice( 0 );
+       }
+
+       soFar = selector;
+       groups = [];
+       preFilters = Expr.preFilter;
+
+       while ( soFar ) {
+
+               // Comma and first run
+               if ( !matched || (match = rcomma.exec( soFar )) ) {
+                       if ( match ) {
+                               // Don't consume trailing commas as valid
+                               soFar = soFar.slice( match[0].length ) || soFar;
+                       }
+                       groups.push( (tokens = []) );
+               }
+
+               matched = false;
+
+               // Combinators
+               if ( (match = rcombinators.exec( soFar )) ) {
+                       matched = match.shift();
+                       tokens.push({
+                               value: matched,
+                               // Cast descendant combinators to space
+                               type: match[0].replace( rtrim, " " )
+                       });
+                       soFar = soFar.slice( matched.length );
+               }
+
+               // Filters
+               for ( type in Expr.filter ) {
+                       if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
+                               (match = preFilters[ type ]( match ))) ) {
+                               matched = match.shift();
+                               tokens.push({
+                                       value: matched,
+                                       type: type,
+                                       matches: match
+                               });
+                               soFar = soFar.slice( matched.length );
+                       }
+               }
+
+               if ( !matched ) {
+                       break;
+               }
+       }
+
+       // Return the length of the invalid excess
+       // if we're just parsing
+       // Otherwise, throw an error or return tokens
+       return parseOnly ?
+               soFar.length :
+               soFar ?
+                       Sizzle.error( selector ) :
+                       // Cache the tokens
+                       tokenCache( selector, groups ).slice( 0 );
+}
+
+function toSelector( tokens ) {
+       var i = 0,
+               len = tokens.length,
+               selector = "";
+       for ( ; i < len; i++ ) {
+               selector += tokens[i].value;
+       }
+       return selector;
+}
+
+function addCombinator( matcher, combinator, base ) {
+       var dir = combinator.dir,
+               checkNonElements = base && dir === "parentNode",
+               doneName = done++;
+
+       return combinator.first ?
+               // Check against closest ancestor/preceding element
+               function( elem, context, xml ) {
+                       while ( (elem = elem[ dir ]) ) {
+                               if ( elem.nodeType === 1 || checkNonElements ) {
+                                       return matcher( elem, context, xml );
+                               }
+                       }
+               } :
+
+               // Check against all ancestor/preceding elements
+               function( elem, context, xml ) {
+                       var oldCache, outerCache,
+                               newCache = [ dirruns, doneName ];
+
+                       // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
+                       if ( xml ) {
+                               while ( (elem = elem[ dir ]) ) {
+                                       if ( elem.nodeType === 1 || checkNonElements ) {
+                                               if ( matcher( elem, context, xml ) ) {
+                                                       return true;
+                                               }
+                                       }
+                               }
+                       } else {
+                               while ( (elem = elem[ dir ]) ) {
+                                       if ( elem.nodeType === 1 || checkNonElements ) {
+                                               outerCache = elem[ expando ] || (elem[ expando ] = {});
+                                               if ( (oldCache = outerCache[ dir ]) &&
+                                                       oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
+
+                                                       // Assign to newCache so results back-propagate to previous elements
+                                                       return (newCache[ 2 ] = oldCache[ 2 ]);
+                                               } else {
+                                                       // Reuse newcache so results back-propagate to previous elements
+                                                       outerCache[ dir ] = newCache;
+
+                                                       // A match means we're done; a fail means we have to keep checking
+                                                       if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
+                                                               return true;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               };
+}
+
+function elementMatcher( matchers ) {
+       return matchers.length > 1 ?
+               function( elem, context, xml ) {
+                       var i = matchers.length;
+                       while ( i-- ) {
+                               if ( !matchers[i]( elem, context, xml ) ) {
+                                       return false;
+                               }
+                       }
+                       return true;
+               } :
+               matchers[0];
+}
+
+function condense( unmatched, map, filter, context, xml ) {
+       var elem,
+               newUnmatched = [],
+               i = 0,
+               len = unmatched.length,
+               mapped = map != null;
+
+       for ( ; i < len; i++ ) {
+               if ( (elem = unmatched[i]) ) {
+                       if ( !filter || filter( elem, context, xml ) ) {
+                               newUnmatched.push( elem );
+                               if ( mapped ) {
+                                       map.push( i );
+                               }
+                       }
+               }
+       }
+
+       return newUnmatched;
+}
+
+function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
+       if ( postFilter && !postFilter[ expando ] ) {
+               postFilter = setMatcher( postFilter );
+       }
+       if ( postFinder && !postFinder[ expando ] ) {
+               postFinder = setMatcher( postFinder, postSelector );
+       }
+       return markFunction(function( seed, results, context, xml ) {
+               var temp, i, elem,
+                       preMap = [],
+                       postMap = [],
+                       preexisting = results.length,
+
+                       // Get initial elements from seed or context
+                       elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
+
+                       // Prefilter to get matcher input, preserving a map for seed-results synchronization
+                       matcherIn = preFilter && ( seed || !selector ) ?
+                               condense( elems, preMap, preFilter, context, xml ) :
+                               elems,
+
+                       matcherOut = matcher ?
+                               // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+                               postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+                                       // ...intermediate processing is necessary
+                                       [] :
+
+                                       // ...otherwise use results directly
+                                       results :
+                               matcherIn;
+
+               // Find primary matches
+               if ( matcher ) {
+                       matcher( matcherIn, matcherOut, context, xml );
+               }
+
+               // Apply postFilter
+               if ( postFilter ) {
+                       temp = condense( matcherOut, postMap );
+                       postFilter( temp, [], context, xml );
+
+                       // Un-match failing elements by moving them back to matcherIn
+                       i = temp.length;
+                       while ( i-- ) {
+                               if ( (elem = temp[i]) ) {
+                                       matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
+                               }
+                       }
+               }
+
+               if ( seed ) {
+                       if ( postFinder || preFilter ) {
+                               if ( postFinder ) {
+                                       // Get the final matcherOut by condensing this intermediate into postFinder contexts
+                                       temp = [];
+                                       i = matcherOut.length;
+                                       while ( i-- ) {
+                                               if ( (elem = matcherOut[i]) ) {
+                                                       // Restore matcherIn since elem is not yet a final match
+                                                       temp.push( (matcherIn[i] = elem) );
+                                               }
+                                       }
+                                       postFinder( null, (matcherOut = []), temp, xml );
+                               }
+
+                               // Move matched elements from seed to results to keep them synchronized
+                               i = matcherOut.length;
+                               while ( i-- ) {
+                                       if ( (elem = matcherOut[i]) &&
+                                               (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
+
+                                               seed[temp] = !(results[temp] = elem);
+                                       }
+                               }
+                       }
+
+               // Add elements to results, through postFinder if defined
+               } else {
+                       matcherOut = condense(
+                               matcherOut === results ?
+                                       matcherOut.splice( preexisting, matcherOut.length ) :
+                                       matcherOut
+                       );
+                       if ( postFinder ) {
+                               postFinder( null, results, matcherOut, xml );
+                       } else {
+                               push.apply( results, matcherOut );
+                       }
+               }
+       });
+}
+
+function matcherFromTokens( tokens ) {
+       var checkContext, matcher, j,
+               len = tokens.length,
+               leadingRelative = Expr.relative[ tokens[0].type ],
+               implicitRelative = leadingRelative || Expr.relative[" "],
+               i = leadingRelative ? 1 : 0,
+
+               // The foundational matcher ensures that elements are reachable from top-level context(s)
+               matchContext = addCombinator( function( elem ) {
+                       return elem === checkContext;
+               }, implicitRelative, true ),
+               matchAnyContext = addCombinator( function( elem ) {
+                       return indexOf.call( checkContext, elem ) > -1;
+               }, implicitRelative, true ),
+               matchers = [ function( elem, context, xml ) {
+                       return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
+                               (checkContext = context).nodeType ?
+                                       matchContext( elem, context, xml ) :
+                                       matchAnyContext( elem, context, xml ) );
+               } ];
+
+       for ( ; i < len; i++ ) {
+               if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
+                       matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
+               } else {
+                       matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
+
+                       // Return special upon seeing a positional matcher
+                       if ( matcher[ expando ] ) {
+                               // Find the next relative operator (if any) for proper handling
+                               j = ++i;
+                               for ( ; j < len; j++ ) {
+                                       if ( Expr.relative[ tokens[j].type ] ) {
+                                               break;
+                                       }
+                               }
+                               return setMatcher(
+                                       i > 1 && elementMatcher( matchers ),
+                                       i > 1 && toSelector(
+                                               // If the preceding token was a descendant combinator, insert an implicit any-element `*`
+                                               tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
+                                       ).replace( rtrim, "$1" ),
+                                       matcher,
+                                       i < j && matcherFromTokens( tokens.slice( i, j ) ),
+                                       j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
+                                       j < len && toSelector( tokens )
+                               );
+                       }
+                       matchers.push( matcher );
+               }
+       }
+
+       return elementMatcher( matchers );
+}
+
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+       var bySet = setMatchers.length > 0,
+               byElement = elementMatchers.length > 0,
+               superMatcher = function( seed, context, xml, results, outermost ) {
+                       var elem, j, matcher,
+                               matchedCount = 0,
+                               i = "0",
+                               unmatched = seed && [],
+                               setMatched = [],
+                               contextBackup = outermostContext,
+                               // We must always have either seed elements or outermost context
+                               elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
+                               // Use integer dirruns iff this is the outermost matcher
+                               dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
+                               len = elems.length;
+
+                       if ( outermost ) {
+                               outermostContext = context !== document && context;
+                       }
+
+                       // Add elements passing elementMatchers directly to results
+                       // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
+                       // Support: IE<9, Safari
+                       // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
+                       for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
+                               if ( byElement && elem ) {
+                                       j = 0;
+                                       while ( (matcher = elementMatchers[j++]) ) {
+                                               if ( matcher( elem, context, xml ) ) {
+                                                       results.push( elem );
+                                                       break;
+                                               }
+                                       }
+                                       if ( outermost ) {
+                                               dirruns = dirrunsUnique;
+                                       }
+                               }
+
+                               // Track unmatched elements for set filters
+                               if ( bySet ) {
+                                       // They will have gone through all possible matchers
+                                       if ( (elem = !matcher && elem) ) {
+                                               matchedCount--;
+                                       }
+
+                                       // Lengthen the array for every element, matched or not
+                                       if ( seed ) {
+                                               unmatched.push( elem );
+                                       }
+                               }
+                       }
+
+                       // Apply set filters to unmatched elements
+                       matchedCount += i;
+                       if ( bySet && i !== matchedCount ) {
+                               j = 0;
+                               while ( (matcher = setMatchers[j++]) ) {
+                                       matcher( unmatched, setMatched, context, xml );
+                               }
+
+                               if ( seed ) {
+                                       // Reintegrate element matches to eliminate the need for sorting
+                                       if ( matchedCount > 0 ) {
+                                               while ( i-- ) {
+                                                       if ( !(unmatched[i] || setMatched[i]) ) {
+                                                               setMatched[i] = pop.call( results );
+                                                       }
+                                               }
+                                       }
+
+                                       // Discard index placeholder values to get only actual matches
+                                       setMatched = condense( setMatched );
+                               }
+
+                               // Add matches to results
+                               push.apply( results, setMatched );
+
+                               // Seedless set matches succeeding multiple successful matchers stipulate sorting
+                               if ( outermost && !seed && setMatched.length > 0 &&
+                                       ( matchedCount + setMatchers.length ) > 1 ) {
+
+                                       Sizzle.uniqueSort( results );
+                               }
+                       }
+
+                       // Override manipulation of globals by nested matchers
+                       if ( outermost ) {
+                               dirruns = dirrunsUnique;
+                               outermostContext = contextBackup;
+                       }
+
+                       return unmatched;
+               };
+
+       return bySet ?
+               markFunction( superMatcher ) :
+               superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
+       var i,
+               setMatchers = [],
+               elementMatchers = [],
+               cached = compilerCache[ selector + " " ];
+
+       if ( !cached ) {
+               // Generate a function of recursive functions that can be used to check each element
+               if ( !group ) {
+                       group = tokenize( selector );
+               }
+               i = group.length;
+               while ( i-- ) {
+                       cached = matcherFromTokens( group[i] );
+                       if ( cached[ expando ] ) {
+                               setMatchers.push( cached );
+                       } else {
+                               elementMatchers.push( cached );
+                       }
+               }
+
+               // Cache the compiled function
+               cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
+       }
+       return cached;
+};
+
+function multipleContexts( selector, contexts, results ) {
+       var i = 0,
+               len = contexts.length;
+       for ( ; i < len; i++ ) {
+               Sizzle( selector, contexts[i], results );
+       }
+       return results;
+}
+
+function select( selector, context, results, seed ) {
+       var i, tokens, token, type, find,
+               match = tokenize( selector );
+
+       if ( !seed ) {
+               // Try to minimize operations if there is only one group
+               if ( match.length === 1 ) {
+
+                       // Take a shortcut and set the context if the root selector is an ID
+                       tokens = match[0] = match[0].slice( 0 );
+                       if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+                                       support.getById && context.nodeType === 9 && documentIsHTML &&
+                                       Expr.relative[ tokens[1].type ] ) {
+
+                               context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
+                               if ( !context ) {
+                                       return results;
+                               }
+                               selector = selector.slice( tokens.shift().value.length );
+                       }
+
+                       // Fetch a seed set for right-to-left matching
+                       i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
+                       while ( i-- ) {
+                               token = tokens[i];
+
+                               // Abort if we hit a combinator
+                               if ( Expr.relative[ (type = token.type) ] ) {
+                                       break;
+                               }
+                               if ( (find = Expr.find[ type ]) ) {
+                                       // Search, expanding context for leading sibling combinators
+                                       if ( (seed = find(
+                                               token.matches[0].replace( runescape, funescape ),
+                                               rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
+                                       )) ) {
+
+                                               // If seed is empty or no tokens remain, we can return early
+                                               tokens.splice( i, 1 );
+                                               selector = seed.length && toSelector( tokens );
+                                               if ( !selector ) {
+                                                       push.apply( results, seed );
+                                                       return results;
+                                               }
+
+                                               break;
+                                       }
+                               }
+                       }
+               }
+       }
+
+       // Compile and execute a filtering function
+       // Provide `match` to avoid retokenization if we modified the selector above
+       compile( selector, match )(
+               seed,
+               context,
+               !documentIsHTML,
+               results,
+               rsibling.test( selector ) && testContext( context.parentNode ) || context
+       );
+       return results;
+}
+
+// One-time assignments
+
+// Sort stability
+support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
+
+// Support: Chrome<14
+// Always assume duplicates if they aren't passed to the comparison function
+support.detectDuplicates = !!hasDuplicate;
+
+// Initialize against the default document
+setDocument();
+
+// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
+// Detached nodes confoundingly follow *each other*
+support.sortDetached = assert(function( div1 ) {
+       // Should return 1, but returns 4 (following)
+       return div1.compareDocumentPosition( document.createElement("div") ) & 1;
+});
+
+// Support: IE<8
+// Prevent attribute/property "interpolation"
+// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
+if ( !assert(function( div ) {
+       div.innerHTML = "<a href='#'></a>";
+       return div.firstChild.getAttribute("href") === "#" ;
+}) ) {
+       addHandle( "type|href|height|width", function( elem, name, isXML ) {
+               if ( !isXML ) {
+                       return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
+               }
+       });
+}
+
+// Support: IE<9
+// Use defaultValue in place of getAttribute("value")
+if ( !support.attributes || !assert(function( div ) {
+       div.innerHTML = "<input/>";
+       div.firstChild.setAttribute( "value", "" );
+       return div.firstChild.getAttribute( "value" ) === "";
+}) ) {
+       addHandle( "value", function( elem, name, isXML ) {
+               if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
+                       return elem.defaultValue;
+               }
+       });
+}
+
+// Support: IE<9
+// Use getAttributeNode to fetch booleans when getAttribute lies
+if ( !assert(function( div ) {
+       return div.getAttribute("disabled") == null;
+}) ) {
+       addHandle( booleans, function( elem, name, isXML ) {
+               var val;
+               if ( !isXML ) {
+                       return elem[ name ] === true ? name.toLowerCase() :
+                                       (val = elem.getAttributeNode( name )) && val.specified ?
+                                       val.value :
+                               null;
+               }
+       });
+}
+
+return Sizzle;
+
+})( window );
+
+
+
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.pseudos;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+
+
+
+var rneedsContext = jQuery.expr.match.needsContext;
+
+var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
+
+
+
+var risSimple = /^.[^:#\[\.,]*$/;
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, not ) {
+       if ( jQuery.isFunction( qualifier ) ) {
+               return jQuery.grep( elements, function( elem, i ) {
+                       /* jshint -W018 */
+                       return !!qualifier.call( elem, i, elem ) !== not;
+               });
+
+       }
+
+       if ( qualifier.nodeType ) {
+               return jQuery.grep( elements, function( elem ) {
+                       return ( elem === qualifier ) !== not;
+               });
+
+       }
+
+       if ( typeof qualifier === "string" ) {
+               if ( risSimple.test( qualifier ) ) {
+                       return jQuery.filter( qualifier, elements, not );
+               }
+
+               qualifier = jQuery.filter( qualifier, elements );
+       }
+
+       return jQuery.grep( elements, function( elem ) {
+               return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
+       });
+}
+
+jQuery.filter = function( expr, elems, not ) {
+       var elem = elems[ 0 ];
+
+       if ( not ) {
+               expr = ":not(" + expr + ")";
+       }
+
+       return elems.length === 1 && elem.nodeType === 1 ?
+               jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
+               jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
+                       return elem.nodeType === 1;
+               }));
+};
+
+jQuery.fn.extend({
+       find: function( selector ) {
+               var i,
+                       ret = [],
+                       self = this,
+                       len = self.length;
+
+               if ( typeof selector !== "string" ) {
+                       return this.pushStack( jQuery( selector ).filter(function() {
+                               for ( i = 0; i < len; i++ ) {
+                                       if ( jQuery.contains( self[ i ], this ) ) {
+                                               return true;
+                                       }
+                               }
+                       }) );
+               }
+
+               for ( i = 0; i < len; i++ ) {
+                       jQuery.find( selector, self[ i ], ret );
+               }
+
+               // Needed because $( selector, context ) becomes $( context ).find( selector )
+               ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
+               ret.selector = this.selector ? this.selector + " " + selector : selector;
+               return ret;
+       },
+       filter: function( selector ) {
+               return this.pushStack( winnow(this, selector || [], false) );
+       },
+       not: function( selector ) {
+               return this.pushStack( winnow(this, selector || [], true) );
+       },
+       is: function( selector ) {
+               return !!winnow(
+                       this,
+
+                       // If this is a positional/relative selector, check membership in the returned set
+                       // so $("p:first").is("p:last") won't return true for a doc with two "p".
+                       typeof selector === "string" && rneedsContext.test( selector ) ?
+                               jQuery( selector ) :
+                               selector || [],
+                       false
+               ).length;
+       }
+});
+
+
+// Initialize a jQuery object
+
+
+// A central reference to the root jQuery(document)
+var rootjQuery,
+
+       // Use the correct document accordingly with window argument (sandbox)
+       document = window.document,
+
+       // A simple way to check for HTML strings
+       // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
+       // Strict HTML recognition (#11290: must start with <)
+       rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
+
+       init = jQuery.fn.init = function( selector, context ) {
+               var match, elem;
+
+               // HANDLE: $(""), $(null), $(undefined), $(false)
+               if ( !selector ) {
+                       return this;
+               }
+
+               // Handle HTML strings
+               if ( typeof selector === "string" ) {
+                       if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
+                               // Assume that strings that start and end with <> are HTML and skip the regex check
+                               match = [ null, selector, null ];
+
+                       } else {
+                               match = rquickExpr.exec( selector );
+                       }
+
+                       // Match html or make sure no context is specified for #id
+                       if ( match && (match[1] || !context) ) {
+
+                               // HANDLE: $(html) -> $(array)
+                               if ( match[1] ) {
+                                       context = context instanceof jQuery ? context[0] : context;
+
+                                       // scripts is true for back-compat
+                                       // Intentionally let the error be thrown if parseHTML is not present
+                                       jQuery.merge( this, jQuery.parseHTML(
+                                               match[1],
+                                               context && context.nodeType ? context.ownerDocument || context : document,
+                                               true
+                                       ) );
+
+                                       // HANDLE: $(html, props)
+                                       if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
+                                               for ( match in context ) {
+                                                       // Properties of context are called as methods if possible
+                                                       if ( jQuery.isFunction( this[ match ] ) ) {
+                                                               this[ match ]( context[ match ] );
+
+                                                       // ...and otherwise set as attributes
+                                                       } else {
+                                                               this.attr( match, context[ match ] );
+                                                       }
+                                               }
+                                       }
+
+                                       return this;
+
+                               // HANDLE: $(#id)
+                               } else {
+                                       elem = document.getElementById( match[2] );
+
+                                       // Check parentNode to catch when Blackberry 4.6 returns
+                                       // nodes that are no longer in the document #6963
+                                       if ( elem && elem.parentNode ) {
+                                               // Handle the case where IE and Opera return items
+                                               // by name instead of ID
+                                               if ( elem.id !== match[2] ) {
+                                                       return rootjQuery.find( selector );
+                                               }
+
+                                               // Otherwise, we inject the element directly into the jQuery object
+                                               this.length = 1;
+                                               this[0] = elem;
+                                       }
+
+                                       this.context = document;
+                                       this.selector = selector;
+                                       return this;
+                               }
+
+                       // HANDLE: $(expr, $(...))
+                       } else if ( !context || context.jquery ) {
+                               return ( context || rootjQuery ).find( selector );
+
+                       // HANDLE: $(expr, context)
+                       // (which is just equivalent to: $(context).find(expr)
+                       } else {
+                               return this.constructor( context ).find( selector );
+                       }
+
+               // HANDLE: $(DOMElement)
+               } else if ( selector.nodeType ) {
+                       this.context = this[0] = selector;
+                       this.length = 1;
+                       return this;
+
+               // HANDLE: $(function)
+               // Shortcut for document ready
+               } else if ( jQuery.isFunction( selector ) ) {
+                       return typeof rootjQuery.ready !== "undefined" ?
+                               rootjQuery.ready( selector ) :
+                               // Execute immediately if ready is not present
+                               selector( jQuery );
+               }
+
+               if ( selector.selector !== undefined ) {
+                       this.selector = selector.selector;
+                       this.context = selector.context;
+               }
+
+               return jQuery.makeArray( selector, this );
+       };
+
+// Give the init function the jQuery prototype for later instantiation
+init.prototype = jQuery.fn;
+
+// Initialize central reference
+rootjQuery = jQuery( document );
+
+
+var rparentsprev = /^(?:parents|prev(?:Until|All))/,
+       // methods guaranteed to produce a unique set when starting from a unique set
+       guaranteedUnique = {
+               children: true,
+               contents: true,
+               next: true,
+               prev: true
+       };
+
+jQuery.extend({
+       dir: function( elem, dir, until ) {
+               var matched = [],
+                       cur = elem[ dir ];
+
+               while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
+                       if ( cur.nodeType === 1 ) {
+                               matched.push( cur );
+                       }
+                       cur = cur[dir];
+               }
+               return matched;
+       },
+
+       sibling: function( n, elem ) {
+               var r = [];
+
+               for ( ; n; n = n.nextSibling ) {
+                       if ( n.nodeType === 1 && n !== elem ) {
+                               r.push( n );
+                       }
+               }
+
+               return r;
+       }
+});
+
+jQuery.fn.extend({
+       has: function( target ) {
+               var i,
+                       targets = jQuery( target, this ),
+                       len = targets.length;
+
+               return this.filter(function() {
+                       for ( i = 0; i < len; i++ ) {
+                               if ( jQuery.contains( this, targets[i] ) ) {
+                                       return true;
+                               }
+                       }
+               });
+       },
+
+       closest: function( selectors, context ) {
+               var cur,
+                       i = 0,
+                       l = this.length,
+                       matched = [],
+                       pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
+                               jQuery( selectors, context || this.context ) :
+                               0;
+
+               for ( ; i < l; i++ ) {
+                       for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
+                               // Always skip document fragments
+                               if ( cur.nodeType < 11 && (pos ?
+                                       pos.index(cur) > -1 :
+
+                                       // Don't pass non-elements to Sizzle
+                                       cur.nodeType === 1 &&
+                                               jQuery.find.matchesSelector(cur, selectors)) ) {
+
+                                       matched.push( cur );
+                                       break;
+                               }
+                       }
+               }
+
+               return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
+       },
+
+       // Determine the position of an element within
+       // the matched set of elements
+       index: function( elem ) {
+
+               // No argument, return index in parent
+               if ( !elem ) {
+                       return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
+               }
+
+               // index in selector
+               if ( typeof elem === "string" ) {
+                       return jQuery.inArray( this[0], jQuery( elem ) );
+               }
+
+               // Locate the position of the desired element
+               return jQuery.inArray(
+                       // If it receives a jQuery object, the first element is used
+                       elem.jquery ? elem[0] : elem, this );
+       },
+
+       add: function( selector, context ) {
+               return this.pushStack(
+                       jQuery.unique(
+                               jQuery.merge( this.get(), jQuery( selector, context ) )
+                       )
+               );
+       },
+
+       addBack: function( selector ) {
+               return this.add( selector == null ?
+                       this.prevObject : this.prevObject.filter(selector)
+               );
+       }
+});
+
+function sibling( cur, dir ) {
+       do {
+               cur = cur[ dir ];
+       } while ( cur && cur.nodeType !== 1 );
+
+       return cur;
+}
+
+jQuery.each({
+       parent: function( elem ) {
+               var parent = elem.parentNode;
+               return parent && parent.nodeType !== 11 ? parent : null;
+       },
+       parents: function( elem ) {
+               return jQuery.dir( elem, "parentNode" );
+       },
+       parentsUntil: function( elem, i, until ) {
+               return jQuery.dir( elem, "parentNode", until );
+       },
+       next: function( elem ) {
+               return sibling( elem, "nextSibling" );
+       },
+       prev: function( elem ) {
+               return sibling( elem, "previousSibling" );
+       },
+       nextAll: function( elem ) {
+               return jQuery.dir( elem, "nextSibling" );
+       },
+       prevAll: function( elem ) {
+               return jQuery.dir( elem, "previousSibling" );
+       },
+       nextUntil: function( elem, i, until ) {
+               return jQuery.dir( elem, "nextSibling", until );
+       },
+       prevUntil: function( elem, i, until ) {
+               return jQuery.dir( elem, "previousSibling", until );
+       },
+       siblings: function( elem ) {
+               return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
+       },
+       children: function( elem ) {
+               return jQuery.sibling( elem.firstChild );
+       },
+       contents: function( elem ) {
+               return jQuery.nodeName( elem, "iframe" ) ?
+                       elem.contentDocument || elem.contentWindow.document :
+                       jQuery.merge( [], elem.childNodes );
+       }
+}, function( name, fn ) {
+       jQuery.fn[ name ] = function( until, selector ) {
+               var ret = jQuery.map( this, fn, until );
+
+               if ( name.slice( -5 ) !== "Until" ) {
+                       selector = until;
+               }
+
+               if ( selector && typeof selector === "string" ) {
+                       ret = jQuery.filter( selector, ret );
+               }
+
+               if ( this.length > 1 ) {
+                       // Remove duplicates
+                       if ( !guaranteedUnique[ name ] ) {
+                               ret = jQuery.unique( ret );
+                       }
+
+                       // Reverse order for parents* and prev-derivatives
+                       if ( rparentsprev.test( name ) ) {
+                               ret = ret.reverse();
+                       }
+               }
+
+               return this.pushStack( ret );
+       };
+});
+var rnotwhite = (/\S+/g);
+
+
+
+// String to Object options format cache
+var optionsCache = {};
+
+// Convert String-formatted options into Object-formatted ones and store in cache
+function createOptions( options ) {
+       var object = optionsCache[ options ] = {};
+       jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
+               object[ flag ] = true;
+       });
+       return object;
+}
+
+/*
+ * Create a callback list using the following parameters:
+ *
+ *     options: an optional list of space-separated options that will change how
+ *                     the callback list behaves or a more traditional option object
+ *
+ * By default a callback list will act like an event callback list and can be
+ * "fired" multiple times.
+ *
+ * Possible options:
+ *
+ *     once:                   will ensure the callback list can only be fired once (like a Deferred)
+ *
+ *     memory:                 will keep track of previous values and will call any callback added
+ *                                     after the list has been fired right away with the latest "memorized"
+ *                                     values (like a Deferred)
+ *
+ *     unique:                 will ensure a callback can only be added once (no duplicate in the list)
+ *
+ *     stopOnFalse:    interrupt callings when a callback returns false
+ *
+ */
+jQuery.Callbacks = function( options ) {
+
+       // Convert options from String-formatted to Object-formatted if needed
+       // (we check in cache first)
+       options = typeof options === "string" ?
+               ( optionsCache[ options ] || createOptions( options ) ) :
+               jQuery.extend( {}, options );
+
+       var // Flag to know if list is currently firing
+               firing,
+               // Last fire value (for non-forgettable lists)
+               memory,
+               // Flag to know if list was already fired
+               fired,
+               // End of the loop when firing
+               firingLength,
+               // Index of currently firing callback (modified by remove if needed)
+               firingIndex,
+               // First callback to fire (used internally by add and fireWith)
+               firingStart,
+               // Actual callback list
+               list = [],
+               // Stack of fire calls for repeatable lists
+               stack = !options.once && [],
+               // Fire callbacks
+               fire = function( data ) {
+                       memory = options.memory && data;
+                       fired = true;
+                       firingIndex = firingStart || 0;
+                       firingStart = 0;
+                       firingLength = list.length;
+                       firing = true;
+                       for ( ; list && firingIndex < firingLength; firingIndex++ ) {
+                               if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
+                                       memory = false; // To prevent further calls using add
+                                       break;
+                               }
+                       }
+                       firing = false;
+                       if ( list ) {
+                               if ( stack ) {
+                                       if ( stack.length ) {
+                                               fire( stack.shift() );
+                                       }
+                               } else if ( memory ) {
+                                       list = [];
+                               } else {
+                                       self.disable();
+                               }
+                       }
+               },
+               // Actual Callbacks object
+               self = {
+                       // Add a callback or a collection of callbacks to the list
+                       add: function() {
+                               if ( list ) {
+                                       // First, we save the current length
+                                       var start = list.length;
+                                       (function add( args ) {
+                                               jQuery.each( args, function( _, arg ) {
+                                                       var type = jQuery.type( arg );
+                                                       if ( type === "function" ) {
+                                                               if ( !options.unique || !self.has( arg ) ) {
+                                                                       list.push( arg );
+                                                               }
+                                                       } else if ( arg && arg.length && type !== "string" ) {
+                                                               // Inspect recursively
+                                                               add( arg );
+                                                       }
+                                               });
+                                       })( arguments );
+                                       // Do we need to add the callbacks to the
+                                       // current firing batch?
+                                       if ( firing ) {
+                                               firingLength = list.length;
+                                       // With memory, if we're not firing then
+                                       // we should call right away
+                                       } else if ( memory ) {
+                                               firingStart = start;
+                                               fire( memory );
+                                       }
+                               }
+                               return this;
+                       },
+                       // Remove a callback from the list
+                       remove: function() {
+                               if ( list ) {
+                                       jQuery.each( arguments, function( _, arg ) {
+                                               var index;
+                                               while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
+                                                       list.splice( index, 1 );
+                                                       // Handle firing indexes
+                                                       if ( firing ) {
+                                                               if ( index <= firingLength ) {
+                                                                       firingLength--;
+                                                               }
+                                                               if ( index <= firingIndex ) {
+                                                                       firingIndex--;
+                                                               }
+                                                       }
+                                               }
+                                       });
+                               }
+                               return this;
+                       },
+                       // Check if a given callback is in the list.
+                       // If no argument is given, return whether or not list has callbacks attached.
+                       has: function( fn ) {
+                               return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
+                       },
+                       // Remove all callbacks from the list
+                       empty: function() {
+                               list = [];
+                               firingLength = 0;
+                               return this;
+                       },
+                       // Have the list do nothing anymore
+                       disable: function() {
+                               list = stack = memory = undefined;
+                               return this;
+                       },
+                       // Is it disabled?
+                       disabled: function() {
+                               return !list;
+                       },
+                       // Lock the list in its current state
+                       lock: function() {
+                               stack = undefined;
+                               if ( !memory ) {
+                                       self.disable();
+                               }
+                               return this;
+                       },
+                       // Is it locked?
+                       locked: function() {
+                               return !stack;
+                       },
+                       // Call all callbacks with the given context and arguments
+                       fireWith: function( context, args ) {
+                               if ( list && ( !fired || stack ) ) {
+                                       args = args || [];
+                                       args = [ context, args.slice ? args.slice() : args ];
+                                       if ( firing ) {
+                                               stack.push( args );
+                                       } else {
+                                               fire( args );
+                                       }
+                               }
+                               return this;
+                       },
+                       // Call all the callbacks with the given arguments
+                       fire: function() {
+                               self.fireWith( this, arguments );
+                               return this;
+                       },
+                       // To know if the callbacks have already been called at least once
+                       fired: function() {
+                               return !!fired;
+                       }
+               };
+
+       return self;
+};
+
+
+jQuery.extend({
+
+       Deferred: function( func ) {
+               var tuples = [
+                               // action, add listener, listener list, final state
+                               [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
+                               [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
+                               [ "notify", "progress", jQuery.Callbacks("memory") ]
+                       ],
+                       state = "pending",
+                       promise = {
+                               state: function() {
+                                       return state;
+                               },
+                               always: function() {
+                                       deferred.done( arguments ).fail( arguments );
+                                       return this;
+                               },
+                               then: function( /* fnDone, fnFail, fnProgress */ ) {
+                                       var fns = arguments;
+                                       return jQuery.Deferred(function( newDefer ) {
+                                               jQuery.each( tuples, function( i, tuple ) {
+                                                       var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
+                                                       // deferred[ done | fail | progress ] for forwarding actions to newDefer
+                                                       deferred[ tuple[1] ](function() {
+                                                               var returned = fn && fn.apply( this, arguments );
+                                                               if ( returned && jQuery.isFunction( returned.promise ) ) {
+                                                                       returned.promise()
+                                                                               .done( newDefer.resolve )
+                                                                               .fail( newDefer.reject )
+                                                                               .progress( newDefer.notify );
+                                                               } else {
+                                                                       newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
+                                                               }
+                                                       });
+                                               });
+                                               fns = null;
+                                       }).promise();
+                               },
+                               // Get a promise for this deferred
+                               // If obj is provided, the promise aspect is added to the object
+                               promise: function( obj ) {
+                                       return obj != null ? jQuery.extend( obj, promise ) : promise;
+                               }
+                       },
+                       deferred = {};
+
+               // Keep pipe for back-compat
+               promise.pipe = promise.then;
+
+               // Add list-specific methods
+               jQuery.each( tuples, function( i, tuple ) {
+                       var list = tuple[ 2 ],
+                               stateString = tuple[ 3 ];
+
+                       // promise[ done | fail | progress ] = list.add
+                       promise[ tuple[1] ] = list.add;
+
+                       // Handle state
+                       if ( stateString ) {
+                               list.add(function() {
+                                       // state = [ resolved | rejected ]
+                                       state = stateString;
+
+                               // [ reject_list | resolve_list ].disable; progress_list.lock
+                               }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
+                       }
+
+                       // deferred[ resolve | reject | notify ]
+                       deferred[ tuple[0] ] = function() {
+                               deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
+                               return this;
+                       };
+                       deferred[ tuple[0] + "With" ] = list.fireWith;
+               });
+
+               // Make the deferred a promise
+               promise.promise( deferred );
+
+               // Call given func if any
+               if ( func ) {
+                       func.call( deferred, deferred );
+               }
+
+               // All done!
+               return deferred;
+       },
+
+       // Deferred helper
+       when: function( subordinate /* , ..., subordinateN */ ) {
+               var i = 0,
+                       resolveValues = slice.call( arguments ),
+                       length = resolveValues.length,
+
+                       // the count of uncompleted subordinates
+                       remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
+
+                       // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
+                       deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
+
+                       // Update function for both resolve and progress values
+                       updateFunc = function( i, contexts, values ) {
+                               return function( value ) {
+                                       contexts[ i ] = this;
+                                       values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
+                                       if ( values === progressValues ) {
+                                               deferred.notifyWith( contexts, values );
+
+                                       } else if ( !(--remaining) ) {
+                                               deferred.resolveWith( contexts, values );
+                                       }
+                               };
+                       },
+
+                       progressValues, progressContexts, resolveContexts;
+
+               // add listeners to Deferred subordinates; treat others as resolved
+               if ( length > 1 ) {
+                       progressValues = new Array( length );
+                       progressContexts = new Array( length );
+                       resolveContexts = new Array( length );
+                       for ( ; i < length; i++ ) {
+                               if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
+                                       resolveValues[ i ].promise()
+                                               .done( updateFunc( i, resolveContexts, resolveValues ) )
+                                               .fail( deferred.reject )
+                                               .progress( updateFunc( i, progressContexts, progressValues ) );
+                               } else {
+                                       --remaining;
+                               }
+                       }
+               }
+
+               // if we're not waiting on anything, resolve the master
+               if ( !remaining ) {
+                       deferred.resolveWith( resolveContexts, resolveValues );
+               }
+
+               return deferred.promise();
+       }
+});
+
+
+// The deferred used on DOM ready
+var readyList;
+
+jQuery.fn.ready = function( fn ) {
+       // Add the callback
+       jQuery.ready.promise().done( fn );
+
+       return this;
+};
+
+jQuery.extend({
+       // Is the DOM ready to be used? Set to true once it occurs.
+       isReady: false,
+
+       // A counter to track how many items to wait for before
+       // the ready event fires. See #6781
+       readyWait: 1,
+
+       // Hold (or release) the ready event
+       holdReady: function( hold ) {
+               if ( hold ) {
+                       jQuery.readyWait++;
+               } else {
+                       jQuery.ready( true );
+               }
+       },
+
+       // Handle when the DOM is ready
+       ready: function( wait ) {
+
+               // Abort if there are pending holds or we're already ready
+               if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
+                       return;
+               }
+
+               // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+               if ( !document.body ) {
+                       return setTimeout( jQuery.ready );
+               }
+
+               // Remember that the DOM is ready
+               jQuery.isReady = true;
+
+               // If a normal DOM Ready event fired, decrement, and wait if need be
+               if ( wait !== true && --jQuery.readyWait > 0 ) {
+                       return;
+               }
+
+               // If there are functions bound, to execute
+               readyList.resolveWith( document, [ jQuery ] );
+
+               // Trigger any bound ready events
+               if ( jQuery.fn.trigger ) {
+                       jQuery( document ).trigger("ready").off("ready");
+               }
+       }
+});
+
+/**
+ * Clean-up method for dom ready events
+ */
+function detach() {
+       if ( document.addEventListener ) {
+               document.removeEventListener( "DOMContentLoaded", completed, false );
+               window.removeEventListener( "load", completed, false );
+
+       } else {
+               document.detachEvent( "onreadystatechange", completed );
+               window.detachEvent( "onload", completed );
+       }
+}
+
+/**
+ * The ready event handler and self cleanup method
+ */
+function completed() {
+       // readyState === "complete" is good enough for us to call the dom ready in oldIE
+       if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
+               detach();
+               jQuery.ready();
+       }
+}
+
+jQuery.ready.promise = function( obj ) {
+       if ( !readyList ) {
+
+               readyList = jQuery.Deferred();
+
+               // Catch cases where $(document).ready() is called after the browser event has already occurred.
+               // we once tried to use readyState "interactive" here, but it caused issues like the one
+               // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
+               if ( document.readyState === "complete" ) {
+                       // Handle it asynchronously to allow scripts the opportunity to delay ready
+                       setTimeout( jQuery.ready );
+
+               // Standards-based browsers support DOMContentLoaded
+               } else if ( document.addEventListener ) {
+                       // Use the handy event callback
+                       document.addEventListener( "DOMContentLoaded", completed, false );
+
+                       // A fallback to window.onload, that will always work
+                       window.addEventListener( "load", completed, false );
+
+               // If IE event model is used
+               } else {
+                       // Ensure firing before onload, maybe late but safe also for iframes
+                       document.attachEvent( "onreadystatechange", completed );
+
+                       // A fallback to window.onload, that will always work
+                       window.attachEvent( "onload", completed );
+
+                       // If IE and not a frame
+                       // continually check to see if the document is ready
+                       var top = false;
+
+                       try {
+                               top = window.frameElement == null && document.documentElement;
+                       } catch(e) {}
+
+                       if ( top && top.doScroll ) {
+                               (function doScrollCheck() {
+                                       if ( !jQuery.isReady ) {
+
+                                               try {
+                                                       // Use the trick by Diego Perini
+                                                       // http://javascript.nwbox.com/IEContentLoaded/
+                                                       top.doScroll("left");
+                                               } catch(e) {
+                                                       return setTimeout( doScrollCheck, 50 );
+                                               }
+
+                                               // detach all dom ready events
+                                               detach();
+
+                                               // and execute any waiting functions
+                                               jQuery.ready();
+                                       }
+                               })();
+                       }
+               }
+       }
+       return readyList.promise( obj );
+};
+
+
+var strundefined = typeof undefined;
+
+
+
+// Support: IE<9
+// Iteration over object's inherited properties before its own
+var i;
+for ( i in jQuery( support ) ) {
+       break;
+}
+support.ownLast = i !== "0";
+
+// Note: most support tests are defined in their respective modules.
+// false until the test is run
+support.inlineBlockNeedsLayout = false;
+
+jQuery(function() {
+       // We need to execute this one support test ASAP because we need to know
+       // if body.style.zoom needs to be set.
+
+       var container, div,
+               body = document.getElementsByTagName("body")[0];
+
+       if ( !body ) {
+               // Return for frameset docs that don't have a body
+               return;
+       }
+
+       // Setup
+       container = document.createElement( "div" );
+       container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px";
+
+       div = document.createElement( "div" );
+       body.appendChild( container ).appendChild( div );
+
+       if ( typeof div.style.zoom !== strundefined ) {
+               // Support: IE<8
+               // Check if natively block-level elements act like inline-block
+               // elements when setting their display to 'inline' and giving
+               // them layout
+               div.style.cssText = "border:0;margin:0;width:1px;padding:1px;display:inline;zoom:1";
+
+               if ( (support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 )) ) {
+                       // Prevent IE 6 from affecting layout for positioned elements #11048
+                       // Prevent IE from shrinking the body in IE 7 mode #12869
+                       // Support: IE<8
+                       body.style.zoom = 1;
+               }
+       }
+
+       body.removeChild( container );
+
+       // Null elements to avoid leaks in IE
+       container = div = null;
+});
+
+
+
+
+(function() {
+       var div = document.createElement( "div" );
+
+       // Execute the test only if not already executed in another module.
+       if (support.deleteExpando == null) {
+               // Support: IE<9
+               support.deleteExpando = true;
+               try {
+                       delete div.test;
+               } catch( e ) {
+                       support.deleteExpando = false;
+               }
+       }
+
+       // Null elements to avoid leaks in IE.
+       div = null;
+})();
+
+
+/**
+ * Determines whether an object can have data
+ */
+jQuery.acceptData = function( elem ) {
+       var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
+               nodeType = +elem.nodeType || 1;
+
+       // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
+       return nodeType !== 1 && nodeType !== 9 ?
+               false :
+
+               // Nodes accept data unless otherwise specified; rejection can be conditional
+               !noData || noData !== true && elem.getAttribute("classid") === noData;
+};
+
+
+var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
+       rmultiDash = /([A-Z])/g;
+
+function dataAttr( elem, key, data ) {
+       // If nothing was found internally, try to fetch any
+       // data from the HTML5 data-* attribute
+       if ( data === undefined && elem.nodeType === 1 ) {
+
+               var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
+
+               data = elem.getAttribute( name );
+
+               if ( typeof data === "string" ) {
+                       try {
+                               data = data === "true" ? true :
+                                       data === "false" ? false :
+                                       data === "null" ? null :
+                                       // Only convert to a number if it doesn't change the string
+                                       +data + "" === data ? +data :
+                                       rbrace.test( data ) ? jQuery.parseJSON( data ) :
+                                       data;
+                       } catch( e ) {}
+
+                       // Make sure we set the data so it isn't changed later
+                       jQuery.data( elem, key, data );
+
+               } else {
+                       data = undefined;
+               }
+       }
+
+       return data;
+}
+
+// checks a cache object for emptiness
+function isEmptyDataObject( obj ) {
+       var name;
+       for ( name in obj ) {
+
+               // if the public data object is empty, the private is still empty
+               if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
+                       continue;
+               }
+               if ( name !== "toJSON" ) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
+       if ( !jQuery.acceptData( elem ) ) {
+               return;
+       }
+
+       var ret, thisCache,
+               internalKey = jQuery.expando,
+
+               // We have to handle DOM nodes and JS objects differently because IE6-7
+               // can't GC object references properly across the DOM-JS boundary
+               isNode = elem.nodeType,
+
+               // Only DOM nodes need the global jQuery cache; JS object data is
+               // attached directly to the object so GC can occur automatically
+               cache = isNode ? jQuery.cache : elem,
+
+               // Only defining an ID for JS objects if its cache already exists allows
+               // the code to shortcut on the same path as a DOM node with no cache
+               id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
+
+       // Avoid doing any more work than we need to when trying to get data on an
+       // object that has no data at all
+       if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
+               return;
+       }
+
+       if ( !id ) {
+               // Only DOM nodes need a new unique ID for each element since their data
+               // ends up in the global cache
+               if ( isNode ) {
+                       id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
+               } else {
+                       id = internalKey;
+               }
+       }
+
+       if ( !cache[ id ] ) {
+               // Avoid exposing jQuery metadata on plain JS objects when the object
+               // is serialized using JSON.stringify
+               cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
+       }
+
+       // An object can be passed to jQuery.data instead of a key/value pair; this gets
+       // shallow copied over onto the existing cache
+       if ( typeof name === "object" || typeof name === "function" ) {
+               if ( pvt ) {
+                       cache[ id ] = jQuery.extend( cache[ id ], name );
+               } else {
+                       cache[ id ].data = jQuery.extend( cache[ id ].data, name );
+               }
+       }
+
+       thisCache = cache[ id ];
+
+       // jQuery data() is stored in a separate object inside the object's internal data
+       // cache in order to avoid key collisions between internal data and user-defined
+       // data.
+       if ( !pvt ) {
+               if ( !thisCache.data ) {
+                       thisCache.data = {};
+               }
+
+               thisCache = thisCache.data;
+       }
+
+       if ( data !== undefined ) {
+               thisCache[ jQuery.camelCase( name ) ] = data;
+       }
+
+       // Check for both converted-to-camel and non-converted data property names
+       // If a data property was specified
+       if ( typeof name === "string" ) {
+
+               // First Try to find as-is property data
+               ret = thisCache[ name ];
+
+               // Test for null|undefined property data
+               if ( ret == null ) {
+
+                       // Try to find the camelCased property
+                       ret = thisCache[ jQuery.camelCase( name ) ];
+               }
+       } else {
+               ret = thisCache;
+       }
+
+       return ret;
+}
+
+function internalRemoveData( elem, name, pvt ) {
+       if ( !jQuery.acceptData( elem ) ) {
+               return;
+       }
+
+       var thisCache, i,
+               isNode = elem.nodeType,
+
+               // See jQuery.data for more information
+               cache = isNode ? jQuery.cache : elem,
+               id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
+
+       // If there is already no cache entry for this object, there is no
+       // purpose in continuing
+       if ( !cache[ id ] ) {
+               return;
+       }
+
+       if ( name ) {
+
+               thisCache = pvt ? cache[ id ] : cache[ id ].data;
+
+               if ( thisCache ) {
+
+                       // Support array or space separated string names for data keys
+                       if ( !jQuery.isArray( name ) ) {
+
+                               // try the string as a key before any manipulation
+                               if ( name in thisCache ) {
+                                       name = [ name ];
+                               } else {
+
+                                       // split the camel cased version by spaces unless a key with the spaces exists
+                                       name = jQuery.camelCase( name );
+                                       if ( name in thisCache ) {
+                                               name = [ name ];
+                                       } else {
+                                               name = name.split(" ");
+                                       }
+                               }
+                       } else {
+                               // If "name" is an array of keys...
+                               // When data is initially created, via ("key", "val") signature,
+                               // keys will be converted to camelCase.
+                               // Since there is no way to tell _how_ a key was added, remove
+                               // both plain key and camelCase key. #12786
+                               // This will only penalize the array argument path.
+                               name = name.concat( jQuery.map( name, jQuery.camelCase ) );
+                       }
+
+                       i = name.length;
+                       while ( i-- ) {
+                               delete thisCache[ name[i] ];
+                       }
+
+                       // If there is no data left in the cache, we want to continue
+                       // and let the cache object itself get destroyed
+                       if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
+                               return;
+                       }
+               }
+       }
+
+       // See jQuery.data for more information
+       if ( !pvt ) {
+               delete cache[ id ].data;
+
+               // Don't destroy the parent cache unless the internal data object
+               // had been the only thing left in it
+               if ( !isEmptyDataObject( cache[ id ] ) ) {
+                       return;
+               }
+       }
+
+       // Destroy the cache
+       if ( isNode ) {
+               jQuery.cleanData( [ elem ], true );
+
+       // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
+       /* jshint eqeqeq: false */
+       } else if ( support.deleteExpando || cache != cache.window ) {
+               /* jshint eqeqeq: true */
+               delete cache[ id ];
+
+       // When all else fails, null
+       } else {
+               cache[ id ] = null;
+       }
+}
+
+jQuery.extend({
+       cache: {},
+
+       // The following elements (space-suffixed to avoid Object.prototype collisions)
+       // throw uncatchable exceptions if you attempt to set expando properties
+       noData: {
+               "applet ": true,
+               "embed ": true,
+               // ...but Flash objects (which have this classid) *can* handle expandos
+               "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+       },
+
+       hasData: function( elem ) {
+               elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
+               return !!elem && !isEmptyDataObject( elem );
+       },
+
+       data: function( elem, name, data ) {
+               return internalData( elem, name, data );
+       },
+
+       removeData: function( elem, name ) {
+               return internalRemoveData( elem, name );
+       },
+
+       // For internal use only.
+       _data: function( elem, name, data ) {
+               return internalData( elem, name, data, true );
+       },
+
+       _removeData: function( elem, name ) {
+               return internalRemoveData( elem, name, true );
+       }
+});
+
+jQuery.fn.extend({
+       data: function( key, value ) {
+               var i, name, data,
+                       elem = this[0],
+                       attrs = elem && elem.attributes;
+
+               // Special expections of .data basically thwart jQuery.access,
+               // so implement the relevant behavior ourselves
+
+               // Gets all values
+               if ( key === undefined ) {
+                       if ( this.length ) {
+                               data = jQuery.data( elem );
+
+                               if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
+                                       i = attrs.length;
+                                       while ( i-- ) {
+                                               name = attrs[i].name;
+
+                                               if ( name.indexOf("data-") === 0 ) {
+                                                       name = jQuery.camelCase( name.slice(5) );
+
+                                                       dataAttr( elem, name, data[ name ] );
+                                               }
+                                       }
+                                       jQuery._data( elem, "parsedAttrs", true );
+                               }
+                       }
+
+                       return data;
+               }
+
+               // Sets multiple values
+               if ( typeof key === "object" ) {
+                       return this.each(function() {
+                               jQuery.data( this, key );
+                       });
+               }
+
+               return arguments.length > 1 ?
+
+                       // Sets one value
+                       this.each(function() {
+                               jQuery.data( this, key, value );
+                       }) :
+
+                       // Gets one value
+                       // Try to fetch any internally stored data first
+                       elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
+       },
+
+       removeData: function( key ) {
+               return this.each(function() {
+                       jQuery.removeData( this, key );
+               });
+       }
+});
+
+
+jQuery.extend({
+       queue: function( elem, type, data ) {
+               var queue;
+
+               if ( elem ) {
+                       type = ( type || "fx" ) + "queue";
+                       queue = jQuery._data( elem, type );
+
+                       // Speed up dequeue by getting out quickly if this is just a lookup
+                       if ( data ) {
+                               if ( !queue || jQuery.isArray(data) ) {
+                                       queue = jQuery._data( elem, type, jQuery.makeArray(data) );
+                               } else {
+                                       queue.push( data );
+                               }
+                       }
+                       return queue || [];
+               }
+       },
+
+       dequeue: function( elem, type ) {
+               type = type || "fx";
+
+               var queue = jQuery.queue( elem, type ),
+                       startLength = queue.length,
+                       fn = queue.shift(),
+                       hooks = jQuery._queueHooks( elem, type ),
+                       next = function() {
+                               jQuery.dequeue( elem, type );
+                       };
+
+               // If the fx queue is dequeued, always remove the progress sentinel
+               if ( fn === "inprogress" ) {
+                       fn = queue.shift();
+                       startLength--;
+               }
+
+               if ( fn ) {
+
+                       // Add a progress sentinel to prevent the fx queue from being
+                       // automatically dequeued
+                       if ( type === "fx" ) {
+                               queue.unshift( "inprogress" );
+                       }
+
+                       // clear up the last queue stop function
+                       delete hooks.stop;
+                       fn.call( elem, next, hooks );
+               }
+
+               if ( !startLength && hooks ) {
+                       hooks.empty.fire();
+               }
+       },
+
+       // not intended for public consumption - generates a queueHooks object, or returns the current one
+       _queueHooks: function( elem, type ) {
+               var key = type + "queueHooks";
+               return jQuery._data( elem, key ) || jQuery._data( elem, key, {
+                       empty: jQuery.Callbacks("once memory").add(function() {
+                               jQuery._removeData( elem, type + "queue" );
+                               jQuery._removeData( elem, key );
+                       })
+               });
+       }
+});
+
+jQuery.fn.extend({
+       queue: function( type, data ) {
+               var setter = 2;
+
+               if ( typeof type !== "string" ) {
+                       data = type;
+                       type = "fx";
+                       setter--;
+               }
+
+               if ( arguments.length < setter ) {
+                       return jQuery.queue( this[0], type );
+               }
+
+               return data === undefined ?
+                       this :
+                       this.each(function() {
+                               var queue = jQuery.queue( this, type, data );
+
+                               // ensure a hooks for this queue
+                               jQuery._queueHooks( this, type );
+
+                               if ( type === "fx" && queue[0] !== "inprogress" ) {
+                                       jQuery.dequeue( this, type );
+                               }
+                       });
+       },
+       dequeue: function( type ) {
+               return this.each(function() {
+                       jQuery.dequeue( this, type );
+               });
+       },
+       clearQueue: function( type ) {
+               return this.queue( type || "fx", [] );
+       },
+       // Get a promise resolved when queues of a certain type
+       // are emptied (fx is the type by default)
+       promise: function( type, obj ) {
+               var tmp,
+                       count = 1,
+                       defer = jQuery.Deferred(),
+                       elements = this,
+                       i = this.length,
+                       resolve = function() {
+                               if ( !( --count ) ) {
+                                       defer.resolveWith( elements, [ elements ] );
+                               }
+                       };
+
+               if ( typeof type !== "string" ) {
+                       obj = type;
+                       type = undefined;
+               }
+               type = type || "fx";
+
+               while ( i-- ) {
+                       tmp = jQuery._data( elements[ i ], type + "queueHooks" );
+                       if ( tmp && tmp.empty ) {
+                               count++;
+                               tmp.empty.add( resolve );
+                       }
+               }
+               resolve();
+               return defer.promise( obj );
+       }
+});
+var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
+
+var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
+
+var isHidden = function( elem, el ) {
+               // isHidden might be called from jQuery#filter function;
+               // in that case, element will be second argument
+               elem = el || elem;
+               return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
+       };
+
+
+
+// Multifunctional method to get and set values of a collection
+// The value/s can optionally be executed if it's a function
+var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
+       var i = 0,
+               length = elems.length,
+               bulk = key == null;
+
+       // Sets many values
+       if ( jQuery.type( key ) === "object" ) {
+               chainable = true;
+               for ( i in key ) {
+                       jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
+               }
+
+       // Sets one value
+       } else if ( value !== undefined ) {
+               chainable = true;
+
+               if ( !jQuery.isFunction( value ) ) {
+                       raw = true;
+               }
+
+               if ( bulk ) {
+                       // Bulk operations run against the entire set
+                       if ( raw ) {
+                               fn.call( elems, value );
+                               fn = null;
+
+                       // ...except when executing function values
+                       } else {
+                               bulk = fn;
+                               fn = function( elem, key, value ) {
+                                       return bulk.call( jQuery( elem ), value );
+                               };
+                       }
+               }
+
+               if ( fn ) {
+                       for ( ; i < length; i++ ) {
+                               fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
+                       }
+               }
+       }
+
+       return chainable ?
+               elems :
+
+               // Gets
+               bulk ?
+                       fn.call( elems ) :
+                       length ? fn( elems[0], key ) : emptyGet;
+};
+var rcheckableType = (/^(?:checkbox|radio)$/i);
+
+
+
+(function() {
+       var fragment = document.createDocumentFragment(),
+               div = document.createElement("div"),
+               input = document.createElement("input");
+
+       // Setup
+       div.setAttribute( "className", "t" );
+       div.innerHTML = "  <link/><table></table><a href='/a'>a</a>";
+
+       // IE strips leading whitespace when .innerHTML is used
+       support.leadingWhitespace = div.firstChild.nodeType === 3;
+
+       // Make sure that tbody elements aren't automatically inserted
+       // IE will insert them into empty tables
+       support.tbody = !div.getElementsByTagName( "tbody" ).length;
+
+       // Make sure that link elements get serialized correctly by innerHTML
+       // This requires a wrapper element in IE
+       support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
+
+       // Makes sure cloning an html5 element does not cause problems
+       // Where outerHTML is undefined, this still works
+       support.html5Clone =
+               document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
+
+       // Check if a disconnected checkbox will retain its checked
+       // value of true after appended to the DOM (IE6/7)
+       input.type = "checkbox";
+       input.checked = true;
+       fragment.appendChild( input );
+       support.appendChecked = input.checked;
+
+       // Make sure textarea (and checkbox) defaultValue is properly cloned
+       // Support: IE6-IE11+
+       div.innerHTML = "<textarea>x</textarea>";
+       support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
+
+       // #11217 - WebKit loses check when the name is after the checked attribute
+       fragment.appendChild( div );
+       div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
+
+       // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
+       // old WebKit doesn't clone checked state correctly in fragments
+       support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+       // Support: IE<9
+       // Opera does not clone events (and typeof div.attachEvent === undefined).
+       // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
+       support.noCloneEvent = true;
+       if ( div.attachEvent ) {
+               div.attachEvent( "onclick", function() {
+                       support.noCloneEvent = false;
+               });
+
+               div.cloneNode( true ).click();
+       }
+
+       // Execute the test only if not already executed in another module.
+       if (support.deleteExpando == null) {
+               // Support: IE<9
+               support.deleteExpando = true;
+               try {
+                       delete div.test;
+               } catch( e ) {
+                       support.deleteExpando = false;
+               }
+       }
+
+       // Null elements to avoid leaks in IE.
+       fragment = div = input = null;
+})();
+
+
+(function() {
+       var i, eventName,
+               div = document.createElement( "div" );
+
+       // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
+       for ( i in { submit: true, change: true, focusin: true }) {
+               eventName = "on" + i;
+
+               if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
+                       // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
+                       div.setAttribute( eventName, "t" );
+                       support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
+               }
+       }
+
+       // Null elements to avoid leaks in IE.
+       div = null;
+})();
+
+
+var rformElems = /^(?:input|select|textarea)$/i,
+       rkeyEvent = /^key/,
+       rmouseEvent = /^(?:mouse|contextmenu)|click/,
+       rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
+       rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
+
+function returnTrue() {
+       return true;
+}
+
+function returnFalse() {
+       return false;
+}
+
+function safeActiveElement() {
+       try {
+               return document.activeElement;
+       } catch ( err ) { }
+}
+
+/*
+ * Helper functions for managing events -- not part of the public interface.
+ * Props to Dean Edwards' addEvent library for many of the ideas.
+ */
+jQuery.event = {
+
+       global: {},
+
+       add: function( elem, types, handler, data, selector ) {
+               var tmp, events, t, handleObjIn,
+                       special, eventHandle, handleObj,
+                       handlers, type, namespaces, origType,
+                       elemData = jQuery._data( elem );
+
+               // Don't attach events to noData or text/comment nodes (but allow plain objects)
+               if ( !elemData ) {
+                       return;
+               }
+
+               // Caller can pass in an object of custom data in lieu of the handler
+               if ( handler.handler ) {
+                       handleObjIn = handler;
+                       handler = handleObjIn.handler;
+                       selector = handleObjIn.selector;
+               }
+
+               // Make sure that the handler has a unique ID, used to find/remove it later
+               if ( !handler.guid ) {
+                       handler.guid = jQuery.guid++;
+               }
+
+               // Init the element's event structure and main handler, if this is the first
+               if ( !(events = elemData.events) ) {
+                       events = elemData.events = {};
+               }
+               if ( !(eventHandle = elemData.handle) ) {
+                       eventHandle = elemData.handle = function( e ) {
+                               // Discard the second event of a jQuery.event.trigger() and
+                               // when an event is called after a page has unloaded
+                               return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
+                                       jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
+                                       undefined;
+                       };
+                       // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
+                       eventHandle.elem = elem;
+               }
+
+               // Handle multiple events separated by a space
+               types = ( types || "" ).match( rnotwhite ) || [ "" ];
+               t = types.length;
+               while ( t-- ) {
+                       tmp = rtypenamespace.exec( types[t] ) || [];
+                       type = origType = tmp[1];
+                       namespaces = ( tmp[2] || "" ).split( "." ).sort();
+
+                       // There *must* be a type, no attaching namespace-only handlers
+                       if ( !type ) {
+                               continue;
+                       }
+
+                       // If event changes its type, use the special event handlers for the changed type
+                       special = jQuery.event.special[ type ] || {};
+
+                       // If selector defined, determine special event api type, otherwise given type
+                       type = ( selector ? special.delegateType : special.bindType ) || type;
+
+                       // Update special based on newly reset type
+                       special = jQuery.event.special[ type ] || {};
+
+                       // handleObj is passed to all event handlers
+                       handleObj = jQuery.extend({
+                               type: type,
+                               origType: origType,
+                               data: data,
+                               handler: handler,
+                               guid: handler.guid,
+                               selector: selector,
+                               needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
+                               namespace: namespaces.join(".")
+                       }, handleObjIn );
+
+                       // Init the event handler queue if we're the first
+                       if ( !(handlers = events[ type ]) ) {
+                               handlers = events[ type ] = [];
+                               handlers.delegateCount = 0;
+
+                               // Only use addEventListener/attachEvent if the special events handler returns false
+                               if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+                                       // Bind the global event handler to the element
+                                       if ( elem.addEventListener ) {
+                                               elem.addEventListener( type, eventHandle, false );
+
+                                       } else if ( elem.attachEvent ) {
+                                               elem.attachEvent( "on" + type, eventHandle );
+                                       }
+                               }
+                       }
+
+                       if ( special.add ) {
+                               special.add.call( elem, handleObj );
+
+                               if ( !handleObj.handler.guid ) {
+                                       handleObj.handler.guid = handler.guid;
+                               }
+                       }
+
+                       // Add to the element's handler list, delegates in front
+                       if ( selector ) {
+                               handlers.splice( handlers.delegateCount++, 0, handleObj );
+                       } else {
+                               handlers.push( handleObj );
+                       }
+
+                       // Keep track of which events have ever been used, for event optimization
+                       jQuery.event.global[ type ] = true;
+               }
+
+               // Nullify elem to prevent memory leaks in IE
+               elem = null;
+       },
+
+       // Detach an event or set of events from an element
+       remove: function( elem, types, handler, selector, mappedTypes ) {
+               var j, handleObj, tmp,
+                       origCount, t, events,
+                       special, handlers, type,
+                       namespaces, origType,
+                       elemData = jQuery.hasData( elem ) && jQuery._data( elem );
+
+               if ( !elemData || !(events = elemData.events) ) {
+                       return;
+               }
+
+               // Once for each type.namespace in types; type may be omitted
+               types = ( types || "" ).match( rnotwhite ) || [ "" ];
+               t = types.length;
+               while ( t-- ) {
+                       tmp = rtypenamespace.exec( types[t] ) || [];
+                       type = origType = tmp[1];
+                       namespaces = ( tmp[2] || "" ).split( "." ).sort();
+
+                       // Unbind all events (on this namespace, if provided) for the element
+                       if ( !type ) {
+                               for ( type in events ) {
+                                       jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
+                               }
+                               continue;
+                       }
+
+                       special = jQuery.event.special[ type ] || {};
+                       type = ( selector ? special.delegateType : special.bindType ) || type;
+                       handlers = events[ type ] || [];
+                       tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
+
+                       // Remove matching events
+                       origCount = j = handlers.length;
+                       while ( j-- ) {
+                               handleObj = handlers[ j ];
+
+                               if ( ( mappedTypes || origType === handleObj.origType ) &&
+                                       ( !handler || handler.guid === handleObj.guid ) &&
+                                       ( !tmp || tmp.test( handleObj.namespace ) ) &&
+                                       ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
+                                       handlers.splice( j, 1 );
+
+                                       if ( handleObj.selector ) {
+                                               handlers.delegateCount--;
+                                       }
+                                       if ( special.remove ) {
+                                               special.remove.call( elem, handleObj );
+                                       }
+                               }
+                       }
+
+                       // Remove generic event handler if we removed something and no more handlers exist
+                       // (avoids potential for endless recursion during removal of special event handlers)
+                       if ( origCount && !handlers.length ) {
+                               if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
+                                       jQuery.removeEvent( elem, type, elemData.handle );
+                               }
+
+                               delete events[ type ];
+                       }
+               }
+
+               // Remove the expando if it's no longer used
+               if ( jQuery.isEmptyObject( events ) ) {
+                       delete elemData.handle;
+
+                       // removeData also checks for emptiness and clears the expando if empty
+                       // so use it instead of delete
+                       jQuery._removeData( elem, "events" );
+               }
+       },
+
+       trigger: function( event, data, elem, onlyHandlers ) {
+               var handle, ontype, cur,
+                       bubbleType, special, tmp, i,
+                       eventPath = [ elem || document ],
+                       type = hasOwn.call( event, "type" ) ? event.type : event,
+                       namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
+
+               cur = tmp = elem = elem || document;
+
+               // Don't do events on text and comment nodes
+               if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+                       return;
+               }
+
+               // focus/blur morphs to focusin/out; ensure we're not firing them right now
+               if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
+                       return;
+               }
+
+               if ( type.indexOf(".") >= 0 ) {
+                       // Namespaced trigger; create a regexp to match event type in handle()
+                       namespaces = type.split(".");
+                       type = namespaces.shift();
+                       namespaces.sort();
+               }
+               ontype = type.indexOf(":") < 0 && "on" + type;
+
+               // Caller can pass in a jQuery.Event object, Object, or just an event type string
+               event = event[ jQuery.expando ] ?
+                       event :
+                       new jQuery.Event( type, typeof event === "object" && event );
+
+               // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
+               event.isTrigger = onlyHandlers ? 2 : 3;
+               event.namespace = namespaces.join(".");
+               event.namespace_re = event.namespace ?
+                       new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
+                       null;
+
+               // Clean up the event in case it is being reused
+               event.result = undefined;
+               if ( !event.target ) {
+                       event.target = elem;
+               }
+
+               // Clone any incoming data and prepend the event, creating the handler arg list
+               data = data == null ?
+                       [ event ] :
+                       jQuery.makeArray( data, [ event ] );
+
+               // Allow special events to draw outside the lines
+               special = jQuery.event.special[ type ] || {};
+               if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
+                       return;
+               }
+
+               // Determine event propagation path in advance, per W3C events spec (#9951)
+               // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
+               if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
+
+                       bubbleType = special.delegateType || type;
+                       if ( !rfocusMorph.test( bubbleType + type ) ) {
+                               cur = cur.parentNode;
+                       }
+                       for ( ; cur; cur = cur.parentNode ) {
+                               eventPath.push( cur );
+                               tmp = cur;
+                       }
+
+                       // Only add window if we got to document (e.g., not plain obj or detached DOM)
+                       if ( tmp === (elem.ownerDocument || document) ) {
+                               eventPath.push( tmp.defaultView || tmp.parentWindow || window );
+                       }
+               }
+
+               // Fire handlers on the event path
+               i = 0;
+               while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
+
+                       event.type = i > 1 ?
+                               bubbleType :
+                               special.bindType || type;
+
+                       // jQuery handler
+                       handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
+                       if ( handle ) {
+                               handle.apply( cur, data );
+                       }
+
+                       // Native handler
+                       handle = ontype && cur[ ontype ];
+                       if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
+                               event.result = handle.apply( cur, data );
+                               if ( event.result === false ) {
+                                       event.preventDefault();
+                               }
+                       }
+               }
+               event.type = type;
+
+               // If nobody prevented the default action, do it now
+               if ( !onlyHandlers && !event.isDefaultPrevented() ) {
+
+                       if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
+                               jQuery.acceptData( elem ) ) {
+
+                               // Call a native DOM method on the target with the same name name as the event.
+                               // Can't use an .isFunction() check here because IE6/7 fails that test.
+                               // Don't do default actions on window, that's where global variables be (#6170)
+                               if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
+
+                                       // Don't re-trigger an onFOO event when we call its FOO() method
+                                       tmp = elem[ ontype ];
+
+                                       if ( tmp ) {
+                                               elem[ ontype ] = null;
+                                       }
+
+                                       // Prevent re-triggering of the same event, since we already bubbled it above
+                                       jQuery.event.triggered = type;
+                                       try {
+                                               elem[ type ]();
+                                       } catch ( e ) {
+                                               // IE<9 dies on focus/blur to hidden element (#1486,#12518)
+                                               // only reproducible on winXP IE8 native, not IE9 in IE8 mode
+                                       }
+                                       jQuery.event.triggered = undefined;
+
+                                       if ( tmp ) {
+                                               elem[ ontype ] = tmp;
+                                       }
+                               }
+                       }
+               }
+
+               return event.result;
+       },
+
+       dispatch: function( event ) {
+
+               // Make a writable jQuery.Event from the native event object
+               event = jQuery.event.fix( event );
+
+               var i, ret, handleObj, matched, j,
+                       handlerQueue = [],
+                       args = slice.call( arguments ),
+                       handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
+                       special = jQuery.event.special[ event.type ] || {};
+
+               // Use the fix-ed jQuery.Event rather than the (read-only) native event
+               args[0] = event;
+               event.delegateTarget = this;
+
+               // Call the preDispatch hook for the mapped type, and let it bail if desired
+               if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
+                       return;
+               }
+
+               // Determine handlers
+               handlerQueue = jQuery.event.handlers.call( this, event, handlers );
+
+               // Run delegates first; they may want to stop propagation beneath us
+               i = 0;
+               while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
+                       event.currentTarget = matched.elem;
+
+                       j = 0;
+                       while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
+
+                               // Triggered event must either 1) have no namespace, or
+                               // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
+                               if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
+
+                                       event.handleObj = handleObj;
+                                       event.data = handleObj.data;
+
+                                       ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
+                                                       .apply( matched.elem, args );
+
+                                       if ( ret !== undefined ) {
+                                               if ( (event.result = ret) === false ) {
+                                                       event.preventDefault();
+                                                       event.stopPropagation();
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               // Call the postDispatch hook for the mapped type
+               if ( special.postDispatch ) {
+                       special.postDispatch.call( this, event );
+               }
+
+               return event.result;
+       },
+
+       handlers: function( event, handlers ) {
+               var sel, handleObj, matches, i,
+                       handlerQueue = [],
+                       delegateCount = handlers.delegateCount,
+                       cur = event.target;
+
+               // Find delegate handlers
+               // Black-hole SVG <use> instance trees (#13180)
+               // Avoid non-left-click bubbling in Firefox (#3861)
+               if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
+
+                       /* jshint eqeqeq: false */
+                       for ( ; cur != this; cur = cur.parentNode || this ) {
+                               /* jshint eqeqeq: true */
+
+                               // Don't check non-elements (#13208)
+                               // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
+                               if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
+                                       matches = [];
+                                       for ( i = 0; i < delegateCount; i++ ) {
+                                               handleObj = handlers[ i ];
+
+                                               // Don't conflict with Object.prototype properties (#13203)
+                                               sel = handleObj.selector + " ";
+
+                                               if ( matches[ sel ] === undefined ) {
+                                                       matches[ sel ] = handleObj.needsContext ?
+                                                               jQuery( sel, this ).index( cur ) >= 0 :
+                                                               jQuery.find( sel, this, null, [ cur ] ).length;
+                                               }
+                                               if ( matches[ sel ] ) {
+                                                       matches.push( handleObj );
+                                               }
+                                       }
+                                       if ( matches.length ) {
+                                               handlerQueue.push({ elem: cur, handlers: matches });
+                                       }
+                               }
+                       }
+               }
+
+               // Add the remaining (directly-bound) handlers
+               if ( delegateCount < handlers.length ) {
+                       handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
+               }
+
+               return handlerQueue;
+       },
+
+       fix: function( event ) {
+               if ( event[ jQuery.expando ] ) {
+                       return event;
+               }
+
+               // Create a writable copy of the event object and normalize some properties
+               var i, prop, copy,
+                       type = event.type,
+                       originalEvent = event,
+                       fixHook = this.fixHooks[ type ];
+
+               if ( !fixHook ) {
+                       this.fixHooks[ type ] = fixHook =
+                               rmouseEvent.test( type ) ? this.mouseHooks :
+                               rkeyEvent.test( type ) ? this.keyHooks :
+                               {};
+               }
+               copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
+
+               event = new jQuery.Event( originalEvent );
+
+               i = copy.length;
+               while ( i-- ) {
+                       prop = copy[ i ];
+                       event[ prop ] = originalEvent[ prop ];
+               }
+
+               // Support: IE<9
+               // Fix target property (#1925)
+               if ( !event.target ) {
+                       event.target = originalEvent.srcElement || document;
+               }
+
+               // Support: Chrome 23+, Safari?
+               // Target should not be a text node (#504, #13143)
+               if ( event.target.nodeType === 3 ) {
+                       event.target = event.target.parentNode;
+               }
+
+               // Support: IE<9
+               // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
+               event.metaKey = !!event.metaKey;
+
+               return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
+       },
+
+       // Includes some event props shared by KeyEvent and MouseEvent
+       props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
+
+       fixHooks: {},
+
+       keyHooks: {
+               props: "char charCode key keyCode".split(" "),
+               filter: function( event, original ) {
+
+                       // Add which for key events
+                       if ( event.which == null ) {
+                               event.which = original.charCode != null ? original.charCode : original.keyCode;
+                       }
+
+                       return event;
+               }
+       },
+
+       mouseHooks: {
+               props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
+               filter: function( event, original ) {
+                       var body, eventDoc, doc,
+                               button = original.button,
+                               fromElement = original.fromElement;
+
+                       // Calculate pageX/Y if missing and clientX/Y available
+                       if ( event.pageX == null && original.clientX != null ) {
+                               eventDoc = event.target.ownerDocument || document;
+                               doc = eventDoc.documentElement;
+                               body = eventDoc.body;
+
+                               event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
+                               event.pageY = original.clientY + ( doc && doc.scrollTop  || body && body.scrollTop  || 0 ) - ( doc && doc.clientTop  || body && body.clientTop  || 0 );
+                       }
+
+                       // Add relatedTarget, if necessary
+                       if ( !event.relatedTarget && fromElement ) {
+                               event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
+                       }
+
+                       // Add which for click: 1 === left; 2 === middle; 3 === right
+                       // Note: button is not normalized, so don't use it
+                       if ( !event.which && button !== undefined ) {
+                               event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
+                       }
+
+                       return event;
+               }
+       },
+
+       special: {
+               load: {
+                       // Prevent triggered image.load events from bubbling to window.load
+                       noBubble: true
+               },
+               focus: {
+                       // Fire native event if possible so blur/focus sequence is correct
+                       trigger: function() {
+                               if ( this !== safeActiveElement() && this.focus ) {
+                                       try {
+                                               this.focus();
+                                               return false;
+                                       } catch ( e ) {
+                                               // Support: IE<9
+                                               // If we error on focus to hidden element (#1486, #12518),
+                                               // let .trigger() run the handlers
+                                       }
+                               }
+                       },
+                       delegateType: "focusin"
+               },
+               blur: {
+                       trigger: function() {
+                               if ( this === safeActiveElement() && this.blur ) {
+                                       this.blur();
+                                       return false;
+                               }
+                       },
+                       delegateType: "focusout"
+               },
+               click: {
+                       // For checkbox, fire native event so checked state will be right
+                       trigger: function() {
+                               if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
+                                       this.click();
+                                       return false;
+                               }
+                       },
+
+                       // For cross-browser consistency, don't fire native .click() on links
+                       _default: function( event ) {
+                               return jQuery.nodeName( event.target, "a" );
+                       }
+               },
+
+               beforeunload: {
+                       postDispatch: function( event ) {
+
+                               // Even when returnValue equals to undefined Firefox will still show alert
+                               if ( event.result !== undefined ) {
+                                       event.originalEvent.returnValue = event.result;
+                               }
+                       }
+               }
+       },
+
+       simulate: function( type, elem, event, bubble ) {
+               // Piggyback on a donor event to simulate a different one.
+               // Fake originalEvent to avoid donor's stopPropagation, but if the
+               // simulated event prevents default then we do the same on the donor.
+               var e = jQuery.extend(
+                       new jQuery.Event(),
+                       event,
+                       {
+                               type: type,
+                               isSimulated: true,
+                               originalEvent: {}
+                       }
+               );
+               if ( bubble ) {
+                       jQuery.event.trigger( e, null, elem );
+               } else {
+                       jQuery.event.dispatch.call( elem, e );
+               }
+               if ( e.isDefaultPrevented() ) {
+                       event.preventDefault();
+               }
+       }
+};
+
+jQuery.removeEvent = document.removeEventListener ?
+       function( elem, type, handle ) {
+               if ( elem.removeEventListener ) {
+                       elem.removeEventListener( type, handle, false );
+               }
+       } :
+       function( elem, type, handle ) {
+               var name = "on" + type;
+
+               if ( elem.detachEvent ) {
+
+                       // #8545, #7054, preventing memory leaks for custom events in IE6-8
+                       // detachEvent needed property on element, by name of that event, to properly expose it to GC
+                       if ( typeof elem[ name ] === strundefined ) {
+                               elem[ name ] = null;
+                       }
+
+                       elem.detachEvent( name, handle );
+               }
+       };
+
+jQuery.Event = function( src, props ) {
+       // Allow instantiation without the 'new' keyword
+       if ( !(this instanceof jQuery.Event) ) {
+               return new jQuery.Event( src, props );
+       }
+
+       // Event object
+       if ( src && src.type ) {
+               this.originalEvent = src;
+               this.type = src.type;
+
+               // Events bubbling up the document may have been marked as prevented
+               // by a handler lower down the tree; reflect the correct value.
+               this.isDefaultPrevented = src.defaultPrevented ||
+                               src.defaultPrevented === undefined && (
+                               // Support: IE < 9
+                               src.returnValue === false ||
+                               // Support: Android < 4.0
+                               src.getPreventDefault && src.getPreventDefault() ) ?
+                       returnTrue :
+                       returnFalse;
+
+       // Event type
+       } else {
+               this.type = src;
+       }
+
+       // Put explicitly provided properties onto the event object
+       if ( props ) {
+               jQuery.extend( this, props );
+       }
+
+       // Create a timestamp if incoming event doesn't have one
+       this.timeStamp = src && src.timeStamp || jQuery.now();
+
+       // Mark it as fixed
+       this[ jQuery.expando ] = true;
+};
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+       isDefaultPrevented: returnFalse,
+       isPropagationStopped: returnFalse,
+       isImmediatePropagationStopped: returnFalse,
+
+       preventDefault: function() {
+               var e = this.originalEvent;
+
+               this.isDefaultPrevented = returnTrue;
+               if ( !e ) {
+                       return;
+               }
+
+               // If preventDefault exists, run it on the original event
+               if ( e.preventDefault ) {
+                       e.preventDefault();
+
+               // Support: IE
+               // Otherwise set the returnValue property of the original event to false
+               } else {
+                       e.returnValue = false;
+               }
+       },
+       stopPropagation: function() {
+               var e = this.originalEvent;
+
+               this.isPropagationStopped = returnTrue;
+               if ( !e ) {
+                       return;
+               }
+               // If stopPropagation exists, run it on the original event
+               if ( e.stopPropagation ) {
+                       e.stopPropagation();
+               }
+
+               // Support: IE
+               // Set the cancelBubble property of the original event to true
+               e.cancelBubble = true;
+       },
+       stopImmediatePropagation: function() {
+               this.isImmediatePropagationStopped = returnTrue;
+               this.stopPropagation();
+       }
+};
+
+// Create mouseenter/leave events using mouseover/out and event-time checks
+jQuery.each({
+       mouseenter: "mouseover",
+       mouseleave: "mouseout"
+}, function( orig, fix ) {
+       jQuery.event.special[ orig ] = {
+               delegateType: fix,
+               bindType: fix,
+
+               handle: function( event ) {
+                       var ret,
+                               target = this,
+                               related = event.relatedTarget,
+                               handleObj = event.handleObj;
+
+                       // For mousenter/leave call the handler if related is outside the target.
+                       // NB: No relatedTarget if the mouse left/entered the browser window
+                       if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
+                               event.type = handleObj.origType;
+                               ret = handleObj.handler.apply( this, arguments );
+                               event.type = fix;
+                       }
+                       return ret;
+               }
+       };
+});
+
+// IE submit delegation
+if ( !support.submitBubbles ) {
+
+       jQuery.event.special.submit = {
+               setup: function() {
+                       // Only need this for delegated form submit events
+                       if ( jQuery.nodeName( this, "form" ) ) {
+                               return false;
+                       }
+
+                       // Lazy-add a submit handler when a descendant form may potentially be submitted
+                       jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
+                               // Node name check avoids a VML-related crash in IE (#9807)
+                               var elem = e.target,
+                                       form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
+                               if ( form && !jQuery._data( form, "submitBubbles" ) ) {
+                                       jQuery.event.add( form, "submit._submit", function( event ) {
+                                               event._submit_bubble = true;
+                                       });
+                                       jQuery._data( form, "submitBubbles", true );
+                               }
+                       });
+                       // return undefined since we don't need an event listener
+               },
+
+               postDispatch: function( event ) {
+                       // If form was submitted by the user, bubble the event up the tree
+                       if ( event._submit_bubble ) {
+                               delete event._submit_bubble;
+                               if ( this.parentNode && !event.isTrigger ) {
+                                       jQuery.event.simulate( "submit", this.parentNode, event, true );
+                               }
+                       }
+               },
+
+               teardown: function() {
+                       // Only need this for delegated form submit events
+                       if ( jQuery.nodeName( this, "form" ) ) {
+                               return false;
+                       }
+
+                       // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
+                       jQuery.event.remove( this, "._submit" );
+               }
+       };
+}
+
+// IE change delegation and checkbox/radio fix
+if ( !support.changeBubbles ) {
+
+       jQuery.event.special.change = {
+
+               setup: function() {
+
+                       if ( rformElems.test( this.nodeName ) ) {
+                               // IE doesn't fire change on a check/radio until blur; trigger it on click
+                               // after a propertychange. Eat the blur-change in special.change.handle.
+                               // This still fires onchange a second time for check/radio after blur.
+                               if ( this.type === "checkbox" || this.type === "radio" ) {
+                                       jQuery.event.add( this, "propertychange._change", function( event ) {
+                                               if ( event.originalEvent.propertyName === "checked" ) {
+                                                       this._just_changed = true;
+                                               }
+                                       });
+                                       jQuery.event.add( this, "click._change", function( event ) {
+                                               if ( this._just_changed && !event.isTrigger ) {
+                                                       this._just_changed = false;
+                                               }
+                                               // Allow triggered, simulated change events (#11500)
+                                               jQuery.event.simulate( "change", this, event, true );
+                                       });
+                               }
+                               return false;
+                       }
+                       // Delegated event; lazy-add a change handler on descendant inputs
+                       jQuery.event.add( this, "beforeactivate._change", function( e ) {
+                               var elem = e.target;
+
+                               if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
+                                       jQuery.event.add( elem, "change._change", function( event ) {
+                                               if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
+                                                       jQuery.event.simulate( "change", this.parentNode, event, true );
+                                               }
+                                       });
+                                       jQuery._data( elem, "changeBubbles", true );
+                               }
+                       });
+               },
+
+               handle: function( event ) {
+                       var elem = event.target;
+
+                       // Swallow native change events from checkbox/radio, we already triggered them above
+                       if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
+                               return event.handleObj.handler.apply( this, arguments );
+                       }
+               },
+
+               teardown: function() {
+                       jQuery.event.remove( this, "._change" );
+
+                       return !rformElems.test( this.nodeName );
+               }
+       };
+}
+
+// Create "bubbling" focus and blur events
+if ( !support.focusinBubbles ) {
+       jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+               // Attach a single capturing handler on the document while someone wants focusin/focusout
+               var handler = function( event ) {
+                               jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
+                       };
+
+               jQuery.event.special[ fix ] = {
+                       setup: function() {
+                               var doc = this.ownerDocument || this,
+                                       attaches = jQuery._data( doc, fix );
+
+                               if ( !attaches ) {
+                                       doc.addEventListener( orig, handler, true );
+                               }
+                               jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
+                       },
+                       teardown: function() {
+                               var doc = this.ownerDocument || this,
+                                       attaches = jQuery._data( doc, fix ) - 1;
+
+                               if ( !attaches ) {
+                                       doc.removeEventListener( orig, handler, true );
+                                       jQuery._removeData( doc, fix );
+                               } else {
+                                       jQuery._data( doc, fix, attaches );
+                               }
+                       }
+               };
+       });
+}
+
+jQuery.fn.extend({
+
+       on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
+               var type, origFn;
+
+               // Types can be a map of types/handlers
+               if ( typeof types === "object" ) {
+                       // ( types-Object, selector, data )
+                       if ( typeof selector !== "string" ) {
+                               // ( types-Object, data )
+                               data = data || selector;
+                               selector = undefined;
+                       }
+                       for ( type in types ) {
+                               this.on( type, selector, data, types[ type ], one );
+                       }
+                       return this;
+               }
+
+               if ( data == null && fn == null ) {
+                       // ( types, fn )
+                       fn = selector;
+                       data = selector = undefined;
+               } else if ( fn == null ) {
+                       if ( typeof selector === "string" ) {
+                               // ( types, selector, fn )
+                               fn = data;
+                               data = undefined;
+                       } else {
+                               // ( types, data, fn )
+                               fn = data;
+                               data = selector;
+                               selector = undefined;
+                       }
+               }
+               if ( fn === false ) {
+                       fn = returnFalse;
+               } else if ( !fn ) {
+                       return this;
+               }
+
+               if ( one === 1 ) {
+                       origFn = fn;
+                       fn = function( event ) {
+                               // Can use an empty set, since event contains the info
+                               jQuery().off( event );
+                               return origFn.apply( this, arguments );
+                       };
+                       // Use same guid so caller can remove using origFn
+                       fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
+               }
+               return this.each( function() {
+                       jQuery.event.add( this, types, fn, data, selector );
+               });
+       },
+       one: function( types, selector, data, fn ) {
+               return this.on( types, selector, data, fn, 1 );
+       },
+       off: function( types, selector, fn ) {
+               var handleObj, type;
+               if ( types && types.preventDefault && types.handleObj ) {
+                       // ( event )  dispatched jQuery.Event
+                       handleObj = types.handleObj;
+                       jQuery( types.delegateTarget ).off(
+                               handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
+                               handleObj.selector,
+                               handleObj.handler
+                       );
+                       return this;
+               }
+               if ( typeof types === "object" ) {
+                       // ( types-object [, selector] )
+                       for ( type in types ) {
+                               this.off( type, selector, types[ type ] );
+                       }
+                       return this;
+               }
+               if ( selector === false || typeof selector === "function" ) {
+                       // ( types [, fn] )
+                       fn = selector;
+                       selector = undefined;
+               }
+               if ( fn === false ) {
+                       fn = returnFalse;
+               }
+               return this.each(function() {
+                       jQuery.event.remove( this, types, fn, selector );
+               });
+       },
+
+       trigger: function( type, data ) {
+               return this.each(function() {
+                       jQuery.event.trigger( type, data, this );
+               });
+       },
+       triggerHandler: function( type, data ) {
+               var elem = this[0];
+               if ( elem ) {
+                       return jQuery.event.trigger( type, data, elem, true );
+               }
+       }
+});
+
+
+function createSafeFragment( document ) {
+       var list = nodeNames.split( "|" ),
+               safeFrag = document.createDocumentFragment();
+
+       if ( safeFrag.createElement ) {
+               while ( list.length ) {
+                       safeFrag.createElement(
+                               list.pop()
+                       );
+               }
+       }
+       return safeFrag;
+}
+
+var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
+               "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
+       rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
+       rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
+       rleadingWhitespace = /^\s+/,
+       rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
+       rtagName = /<([\w:]+)/,
+       rtbody = /<tbody/i,
+       rhtml = /<|&#?\w+;/,
+       rnoInnerhtml = /<(?:script|style|link)/i,
+       // checked="checked" or checked
+       rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
+       rscriptType = /^$|\/(?:java|ecma)script/i,
+       rscriptTypeMasked = /^true\/(.*)/,
+       rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
+
+       // We have to close these tags to support XHTML (#13200)
+       wrapMap = {
+               option: [ 1, "<select multiple='multiple'>", "</select>" ],
+               legend: [ 1, "<fieldset>", "</fieldset>" ],
+               area: [ 1, "<map>", "</map>" ],
+               param: [ 1, "<object>", "</object>" ],
+               thead: [ 1, "<table>", "</table>" ],
+               tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+               col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
+               td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+
+               // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
+               // unless wrapped in a div with non-breaking characters in front of it.
+               _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>"  ]
+       },
+       safeFragment = createSafeFragment( document ),
+       fragmentDiv = safeFragment.appendChild( document.createElement("div") );
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+function getAll( context, tag ) {
+       var elems, elem,
+               i = 0,
+               found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
+                       typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
+                       undefined;
+
+       if ( !found ) {
+               for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
+                       if ( !tag || jQuery.nodeName( elem, tag ) ) {
+                               found.push( elem );
+                       } else {
+                               jQuery.merge( found, getAll( elem, tag ) );
+                       }
+               }
+       }
+
+       return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
+               jQuery.merge( [ context ], found ) :
+               found;
+}
+
+// Used in buildFragment, fixes the defaultChecked property
+function fixDefaultChecked( elem ) {
+       if ( rcheckableType.test( elem.type ) ) {
+               elem.defaultChecked = elem.checked;
+       }
+}
+
+// Support: IE<8
+// Manipulating tables requires a tbody
+function manipulationTarget( elem, content ) {
+       return jQuery.nodeName( elem, "table" ) &&
+               jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
+
+               elem.getElementsByTagName("tbody")[0] ||
+                       elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
+               elem;
+}
+
+// Replace/restore the type attribute of script elements for safe DOM manipulation
+function disableScript( elem ) {
+       elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
+       return elem;
+}
+function restoreScript( elem ) {
+       var match = rscriptTypeMasked.exec( elem.type );
+       if ( match ) {
+               elem.type = match[1];
+       } else {
+               elem.removeAttribute("type");
+       }
+       return elem;
+}
+
+// Mark scripts as having already been evaluated
+function setGlobalEval( elems, refElements ) {
+       var elem,
+               i = 0;
+       for ( ; (elem = elems[i]) != null; i++ ) {
+               jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
+       }
+}
+
+function cloneCopyEvent( src, dest ) {
+
+       if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
+               return;
+       }
+
+       var type, i, l,
+               oldData = jQuery._data( src ),
+               curData = jQuery._data( dest, oldData ),
+               events = oldData.events;
+
+       if ( events ) {
+               delete curData.handle;
+               curData.events = {};
+
+               for ( type in events ) {
+                       for ( i = 0, l = events[ type ].length; i < l; i++ ) {
+                               jQuery.event.add( dest, type, events[ type ][ i ] );
+                       }
+               }
+       }
+
+       // make the cloned public data object a copy from the original
+       if ( curData.data ) {
+               curData.data = jQuery.extend( {}, curData.data );
+       }
+}
+
+function fixCloneNodeIssues( src, dest ) {
+       var nodeName, e, data;
+
+       // We do not need to do anything for non-Elements
+       if ( dest.nodeType !== 1 ) {
+               return;
+       }
+
+       nodeName = dest.nodeName.toLowerCase();
+
+       // IE6-8 copies events bound via attachEvent when using cloneNode.
+       if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
+               data = jQuery._data( dest );
+
+               for ( e in data.events ) {
+                       jQuery.removeEvent( dest, e, data.handle );
+               }
+
+               // Event data gets referenced instead of copied if the expando gets copied too
+               dest.removeAttribute( jQuery.expando );
+       }
+
+       // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
+       if ( nodeName === "script" && dest.text !== src.text ) {
+               disableScript( dest ).text = src.text;
+               restoreScript( dest );
+
+       // IE6-10 improperly clones children of object elements using classid.
+       // IE10 throws NoModificationAllowedError if parent is null, #12132.
+       } else if ( nodeName === "object" ) {
+               if ( dest.parentNode ) {
+                       dest.outerHTML = src.outerHTML;
+               }
+
+               // This path appears unavoidable for IE9. When cloning an object
+               // element in IE9, the outerHTML strategy above is not sufficient.
+               // If the src has innerHTML and the destination does not,
+               // copy the src.innerHTML into the dest.innerHTML. #10324
+               if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
+                       dest.innerHTML = src.innerHTML;
+               }
+
+       } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
+               // IE6-8 fails to persist the checked state of a cloned checkbox
+               // or radio button. Worse, IE6-7 fail to give the cloned element
+               // a checked appearance if the defaultChecked value isn't also set
+
+               dest.defaultChecked = dest.checked = src.checked;
+
+               // IE6-7 get confused and end up setting the value of a cloned
+               // checkbox/radio button to an empty string instead of "on"
+               if ( dest.value !== src.value ) {
+                       dest.value = src.value;
+               }
+
+       // IE6-8 fails to return the selected option to the default selected
+       // state when cloning options
+       } else if ( nodeName === "option" ) {
+               dest.defaultSelected = dest.selected = src.defaultSelected;
+
+       // IE6-8 fails to set the defaultValue to the correct value when
+       // cloning other types of input fields
+       } else if ( nodeName === "input" || nodeName === "textarea" ) {
+               dest.defaultValue = src.defaultValue;
+       }
+}
+
+jQuery.extend({
+       clone: function( elem, dataAndEvents, deepDataAndEvents ) {
+               var destElements, node, clone, i, srcElements,
+                       inPage = jQuery.contains( elem.ownerDocument, elem );
+
+               if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
+                       clone = elem.cloneNode( true );
+
+               // IE<=8 does not properly clone detached, unknown element nodes
+               } else {
+                       fragmentDiv.innerHTML = elem.outerHTML;
+                       fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
+               }
+
+               if ( (!support.noCloneEvent || !support.noCloneChecked) &&
+                               (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
+
+                       // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
+                       destElements = getAll( clone );
+                       srcElements = getAll( elem );
+
+                       // Fix all IE cloning issues
+                       for ( i = 0; (node = srcElements[i]) != null; ++i ) {
+                               // Ensure that the destination node is not null; Fixes #9587
+                               if ( destElements[i] ) {
+                                       fixCloneNodeIssues( node, destElements[i] );
+                               }
+                       }
+               }
+
+               // Copy the events from the original to the clone
+               if ( dataAndEvents ) {
+                       if ( deepDataAndEvents ) {
+                               srcElements = srcElements || getAll( elem );
+                               destElements = destElements || getAll( clone );
+
+                               for ( i = 0; (node = srcElements[i]) != null; i++ ) {
+                                       cloneCopyEvent( node, destElements[i] );
+                               }
+                       } else {
+                               cloneCopyEvent( elem, clone );
+                       }
+               }
+
+               // Preserve script evaluation history
+               destElements = getAll( clone, "script" );
+               if ( destElements.length > 0 ) {
+                       setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
+               }
+
+               destElements = srcElements = node = null;
+
+               // Return the cloned set
+               return clone;
+       },
+
+       buildFragment: function( elems, context, scripts, selection ) {
+               var j, elem, contains,
+                       tmp, tag, tbody, wrap,
+                       l = elems.length,
+
+                       // Ensure a safe fragment
+                       safe = createSafeFragment( context ),
+
+                       nodes = [],
+                       i = 0;
+
+               for ( ; i < l; i++ ) {
+                       elem = elems[ i ];
+
+                       if ( elem || elem === 0 ) {
+
+                               // Add nodes directly
+                               if ( jQuery.type( elem ) === "object" ) {
+                                       jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
+
+                               // Convert non-html into a text node
+                               } else if ( !rhtml.test( elem ) ) {
+                                       nodes.push( context.createTextNode( elem ) );
+
+                               // Convert html into DOM nodes
+                               } else {
+                                       tmp = tmp || safe.appendChild( context.createElement("div") );
+
+                                       // Deserialize a standard representation
+                                       tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
+                                       wrap = wrapMap[ tag ] || wrapMap._default;
+
+                                       tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
+
+                                       // Descend through wrappers to the right content
+                                       j = wrap[0];
+                                       while ( j-- ) {
+                                               tmp = tmp.lastChild;
+                                       }
+
+                                       // Manually add leading whitespace removed by IE
+                                       if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
+                                               nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
+                                       }
+
+                                       // Remove IE's autoinserted <tbody> from table fragments
+                                       if ( !support.tbody ) {
+
+                                               // String was a <table>, *may* have spurious <tbody>
+                                               elem = tag === "table" && !rtbody.test( elem ) ?
+                                                       tmp.firstChild :
+
+                                                       // String was a bare <thead> or <tfoot>
+                                                       wrap[1] === "<table>" && !rtbody.test( elem ) ?
+                                                               tmp :
+                                                               0;
+
+                                               j = elem && elem.childNodes.length;
+                                               while ( j-- ) {
+                                                       if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
+                                                               elem.removeChild( tbody );
+                                                       }
+                                               }
+                                       }
+
+                                       jQuery.merge( nodes, tmp.childNodes );
+
+                                       // Fix #12392 for WebKit and IE > 9
+                                       tmp.textContent = "";
+
+                                       // Fix #12392 for oldIE
+                                       while ( tmp.firstChild ) {
+                                               tmp.removeChild( tmp.firstChild );
+                                       }
+
+                                       // Remember the top-level container for proper cleanup
+                                       tmp = safe.lastChild;
+                               }
+                       }
+               }
+
+               // Fix #11356: Clear elements from fragment
+               if ( tmp ) {
+                       safe.removeChild( tmp );
+               }
+
+               // Reset defaultChecked for any radios and checkboxes
+               // about to be appended to the DOM in IE 6/7 (#8060)
+               if ( !support.appendChecked ) {
+                       jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
+               }
+
+               i = 0;
+               while ( (elem = nodes[ i++ ]) ) {
+
+                       // #4087 - If origin and destination elements are the same, and this is
+                       // that element, do not do anything
+                       if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
+                               continue;
+                       }
+
+                       contains = jQuery.contains( elem.ownerDocument, elem );
+
+                       // Append to fragment
+                       tmp = getAll( safe.appendChild( elem ), "script" );
+
+                       // Preserve script evaluation history
+                       if ( contains ) {
+                               setGlobalEval( tmp );
+                       }
+
+                       // Capture executables
+                       if ( scripts ) {
+                               j = 0;
+                               while ( (elem = tmp[ j++ ]) ) {
+                                       if ( rscriptType.test( elem.type || "" ) ) {
+                                               scripts.push( elem );
+                                       }
+                               }
+                       }
+               }
+
+               tmp = null;
+
+               return safe;
+       },
+
+       cleanData: function( elems, /* internal */ acceptData ) {
+               var elem, type, id, data,
+                       i = 0,
+                       internalKey = jQuery.expando,
+                       cache = jQuery.cache,
+                       deleteExpando = support.deleteExpando,
+                       special = jQuery.event.special;
+
+               for ( ; (elem = elems[i]) != null; i++ ) {
+                       if ( acceptData || jQuery.acceptData( elem ) ) {
+
+                               id = elem[ internalKey ];
+                               data = id && cache[ id ];
+
+                               if ( data ) {
+                                       if ( data.events ) {
+                                               for ( type in data.events ) {
+                                                       if ( special[ type ] ) {
+                                                               jQuery.event.remove( elem, type );
+
+                                                       // This is a shortcut to avoid jQuery.event.remove's overhead
+                                                       } else {
+                                                               jQuery.removeEvent( elem, type, data.handle );
+                                                       }
+                                               }
+                                       }
+
+                                       // Remove cache only if it was not already removed by jQuery.event.remove
+                                       if ( cache[ id ] ) {
+
+                                               delete cache[ id ];
+
+                                               // IE does not allow us to delete expando properties from nodes,
+                                               // nor does it have a removeAttribute function on Document nodes;
+                                               // we must handle all of these cases
+                                               if ( deleteExpando ) {
+                                                       delete elem[ internalKey ];
+
+                                               } else if ( typeof elem.removeAttribute !== strundefined ) {
+                                                       elem.removeAttribute( internalKey );
+
+                                               } else {
+                                                       elem[ internalKey ] = null;
+                                               }
+
+                                               deletedIds.push( id );
+                                       }
+                               }
+                       }
+               }
+       }
+});
+
+jQuery.fn.extend({
+       text: function( value ) {
+               return access( this, function( value ) {
+                       return value === undefined ?
+                               jQuery.text( this ) :
+                               this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
+               }, null, value, arguments.length );
+       },
+
+       append: function() {
+               return this.domManip( arguments, function( elem ) {
+                       if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+                               var target = manipulationTarget( this, elem );
+                               target.appendChild( elem );
+                       }
+               });
+       },
+
+       prepend: function() {
+               return this.domManip( arguments, function( elem ) {
+                       if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
+                               var target = manipulationTarget( this, elem );
+                               target.insertBefore( elem, target.firstChild );
+                       }
+               });
+       },
+
+       before: function() {
+               return this.domManip( arguments, function( elem ) {
+                       if ( this.parentNode ) {
+                               this.parentNode.insertBefore( elem, this );
+                       }
+               });
+       },
+
+       after: function() {
+               return this.domManip( arguments, function( elem ) {
+                       if ( this.parentNode ) {
+                               this.parentNode.insertBefore( elem, this.nextSibling );
+                       }
+               });
+       },
+
+       remove: function( selector, keepData /* Internal Use Only */ ) {
+               var elem,
+                       elems = selector ? jQuery.filter( selector, this ) : this,
+                       i = 0;
+
+               for ( ; (elem = elems[i]) != null; i++ ) {
+
+                       if ( !keepData && elem.nodeType === 1 ) {
+                               jQuery.cleanData( getAll( elem ) );
+                       }
+
+                       if ( elem.parentNode ) {
+                               if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
+                                       setGlobalEval( getAll( elem, "script" ) );
+                               }
+                               elem.parentNode.removeChild( elem );
+                       }
+               }
+
+               return this;
+       },
+
+       empty: function() {
+               var elem,
+                       i = 0;
+
+               for ( ; (elem = this[i]) != null; i++ ) {
+                       // Remove element nodes and prevent memory leaks
+                       if ( elem.nodeType === 1 ) {
+                               jQuery.cleanData( getAll( elem, false ) );
+                       }
+
+                       // Remove any remaining nodes
+                       while ( elem.firstChild ) {
+                               elem.removeChild( elem.firstChild );
+                       }
+
+                       // If this is a select, ensure that it displays empty (#12336)
+                       // Support: IE<9
+                       if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
+                               elem.options.length = 0;
+                       }
+               }
+
+               return this;
+       },
+
+       clone: function( dataAndEvents, deepDataAndEvents ) {
+               dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
+               deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
+
+               return this.map(function() {
+                       return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
+               });
+       },
+
+       html: function( value ) {
+               return access( this, function( value ) {
+                       var elem = this[ 0 ] || {},
+                               i = 0,
+                               l = this.length;
+
+                       if ( value === undefined ) {
+                               return elem.nodeType === 1 ?
+                                       elem.innerHTML.replace( rinlinejQuery, "" ) :
+                                       undefined;
+                       }
+
+                       // See if we can take a shortcut and just use innerHTML
+                       if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
+                               ( support.htmlSerialize || !rnoshimcache.test( value )  ) &&
+                               ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
+                               !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
+
+                               value = value.replace( rxhtmlTag, "<$1></$2>" );
+
+                               try {
+                                       for (; i < l; i++ ) {
+                                               // Remove element nodes and prevent memory leaks
+                                               elem = this[i] || {};
+                                               if ( elem.nodeType === 1 ) {
+                                                       jQuery.cleanData( getAll( elem, false ) );
+                                                       elem.innerHTML = value;
+                                               }
+                                       }
+
+                                       elem = 0;
+
+                               // If using innerHTML throws an exception, use the fallback method
+                               } catch(e) {}
+                       }
+
+                       if ( elem ) {
+                               this.empty().append( value );
+                       }
+               }, null, value, arguments.length );
+       },
+
+       replaceWith: function() {
+               var arg = arguments[ 0 ];
+
+               // Make the changes, replacing each context element with the new content
+               this.domManip( arguments, function( elem ) {
+                       arg = this.parentNode;
+
+                       jQuery.cleanData( getAll( this ) );
+
+                       if ( arg ) {
+                               arg.replaceChild( elem, this );
+                       }
+               });
+
+               // Force removal if there was no new content (e.g., from empty arguments)
+               return arg && (arg.length || arg.nodeType) ? this : this.remove();
+       },
+
+       detach: function( selector ) {
+               return this.remove( selector, true );
+       },
+
+       domManip: function( args, callback ) {
+
+               // Flatten any nested arrays
+               args = concat.apply( [], args );
+
+               var first, node, hasScripts,
+                       scripts, doc, fragment,
+                       i = 0,
+                       l = this.length,
+                       set = this,
+                       iNoClone = l - 1,
+                       value = args[0],
+                       isFunction = jQuery.isFunction( value );
+
+               // We can't cloneNode fragments that contain checked, in WebKit
+               if ( isFunction ||
+                               ( l > 1 && typeof value === "string" &&
+                                       !support.checkClone && rchecked.test( value ) ) ) {
+                       return this.each(function( index ) {
+                               var self = set.eq( index );
+                               if ( isFunction ) {
+                                       args[0] = value.call( this, index, self.html() );
+                               }
+                               self.domManip( args, callback );
+                       });
+               }
+
+               if ( l ) {
+                       fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
+                       first = fragment.firstChild;
+
+                       if ( fragment.childNodes.length === 1 ) {
+                               fragment = first;
+                       }
+
+                       if ( first ) {
+                               scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
+                               hasScripts = scripts.length;
+
+                               // Use the original fragment for the last item instead of the first because it can end up
+                               // being emptied incorrectly in certain situations (#8070).
+                               for ( ; i < l; i++ ) {
+                                       node = fragment;
+
+                                       if ( i !== iNoClone ) {
+                                               node = jQuery.clone( node, true, true );
+
+                                               // Keep references to cloned scripts for later restoration
+                                               if ( hasScripts ) {
+                                                       jQuery.merge( scripts, getAll( node, "script" ) );
+                                               }
+                                       }
+
+                                       callback.call( this[i], node, i );
+                               }
+
+                               if ( hasScripts ) {
+                                       doc = scripts[ scripts.length - 1 ].ownerDocument;
+
+                                       // Reenable scripts
+                                       jQuery.map( scripts, restoreScript );
+
+                                       // Evaluate executable scripts on first document insertion
+                                       for ( i = 0; i < hasScripts; i++ ) {
+                                               node = scripts[ i ];
+                                               if ( rscriptType.test( node.type || "" ) &&
+                                                       !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
+
+                                                       if ( node.src ) {
+                                                               // Optional AJAX dependency, but won't run scripts if not present
+                                                               if ( jQuery._evalUrl ) {
+                                                                       jQuery._evalUrl( node.src );
+                                                               }
+                                                       } else {
+                                                               jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               // Fix #11809: Avoid leaking memory
+                               fragment = first = null;
+                       }
+               }
+
+               return this;
+       }
+});
+
+jQuery.each({
+       appendTo: "append",
+       prependTo: "prepend",
+       insertBefore: "before",
+       insertAfter: "after",
+       replaceAll: "replaceWith"
+}, function( name, original ) {
+       jQuery.fn[ name ] = function( selector ) {
+               var elems,
+                       i = 0,
+                       ret = [],
+                       insert = jQuery( selector ),
+                       last = insert.length - 1;
+
+               for ( ; i <= last; i++ ) {
+                       elems = i === last ? this : this.clone(true);
+                       jQuery( insert[i] )[ original ]( elems );
+
+                       // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
+                       push.apply( ret, elems.get() );
+               }
+
+               return this.pushStack( ret );
+       };
+});
+
+
+var iframe,
+       elemdisplay = {};
+
+/**
+ * Retrieve the actual display of a element
+ * @param {String} name nodeName of the element
+ * @param {Object} doc Document object
+ */
+// Called only from within defaultDisplay
+function actualDisplay( name, doc ) {
+       var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
+
+               // getDefaultComputedStyle might be reliably used only on attached element
+               display = window.getDefaultComputedStyle ?
+
+                       // Use of this method is a temporary fix (more like optmization) until something better comes along,
+                       // since it was removed from specification and supported only in FF
+                       window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
+
+       // We don't have any data stored on the element,
+       // so use "detach" method as fast way to get rid of the element
+       elem.detach();
+
+       return display;
+}
+
+/**
+ * Try to determine the default display value of an element
+ * @param {String} nodeName
+ */
+function defaultDisplay( nodeName ) {
+       var doc = document,
+               display = elemdisplay[ nodeName ];
+
+       if ( !display ) {
+               display = actualDisplay( nodeName, doc );
+
+               // If the simple way fails, read from inside an iframe
+               if ( display === "none" || !display ) {
+
+                       // Use the already-created iframe if possible
+                       iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
+
+                       // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
+                       doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
+
+                       // Support: IE
+                       doc.write();
+                       doc.close();
+
+                       display = actualDisplay( nodeName, doc );
+                       iframe.detach();
+               }
+
+               // Store the correct default display
+               elemdisplay[ nodeName ] = display;
+       }
+
+       return display;
+}
+
+
+(function() {
+       var a, shrinkWrapBlocksVal,
+               div = document.createElement( "div" ),
+               divReset =
+                       "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
+                       "display:block;padding:0;margin:0;border:0";
+
+       // Setup
+       div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+       a = div.getElementsByTagName( "a" )[ 0 ];
+
+       a.style.cssText = "float:left;opacity:.5";
+
+       // Make sure that element opacity exists
+       // (IE uses filter instead)
+       // Use a regex to work around a WebKit issue. See #5145
+       support.opacity = /^0.5/.test( a.style.opacity );
+
+       // Verify style float existence
+       // (IE uses styleFloat instead of cssFloat)
+       support.cssFloat = !!a.style.cssFloat;
+
+       div.style.backgroundClip = "content-box";
+       div.cloneNode( true ).style.backgroundClip = "";
+       support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
+       // Null elements to avoid leaks in IE.
+       a = div = null;
+
+       support.shrinkWrapBlocks = function() {
+               var body, container, div, containerStyles;
+
+               if ( shrinkWrapBlocksVal == null ) {
+                       body = document.getElementsByTagName( "body" )[ 0 ];
+                       if ( !body ) {
+                               // Test fired too early or in an unsupported environment, exit.
+                               return;
+                       }
+
+                       containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px";
+                       container = document.createElement( "div" );
+                       div = document.createElement( "div" );
+
+                       body.appendChild( container ).appendChild( div );
+
+                       // Will be changed later if needed.
+                       shrinkWrapBlocksVal = false;
+
+                       if ( typeof div.style.zoom !== strundefined ) {
+                               // Support: IE6
+                               // Check if elements with layout shrink-wrap their children
+                               div.style.cssText = divReset + ";width:1px;padding:1px;zoom:1";
+                               div.innerHTML = "<div></div>";
+                               div.firstChild.style.width = "5px";
+                               shrinkWrapBlocksVal = div.offsetWidth !== 3;
+                       }
+
+                       body.removeChild( container );
+
+                       // Null elements to avoid leaks in IE.
+                       body = container = div = null;
+               }
+
+               return shrinkWrapBlocksVal;
+       };
+
+})();
+var rmargin = (/^margin/);
+
+var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
+
+
+
+var getStyles, curCSS,
+       rposition = /^(top|right|bottom|left)$/;
+
+if ( window.getComputedStyle ) {
+       getStyles = function( elem ) {
+               return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
+       };
+
+       curCSS = function( elem, name, computed ) {
+               var width, minWidth, maxWidth, ret,
+                       style = elem.style;
+
+               computed = computed || getStyles( elem );
+
+               // getPropertyValue is only needed for .css('filter') in IE9, see #12537
+               ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
+
+               if ( computed ) {
+
+                       if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
+                               ret = jQuery.style( elem, name );
+                       }
+
+                       // A tribute to the "awesome hack by Dean Edwards"
+                       // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
+                       // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
+                       // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
+                       if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
+
+                               // Remember the original values
+                               width = style.width;
+                               minWidth = style.minWidth;
+                               maxWidth = style.maxWidth;
+
+                               // Put in the new values to get a computed value out
+                               style.minWidth = style.maxWidth = style.width = ret;
+                               ret = computed.width;
+
+                               // Revert the changed values
+                               style.width = width;
+                               style.minWidth = minWidth;
+                               style.maxWidth = maxWidth;
+                       }
+               }
+
+               // Support: IE
+               // IE returns zIndex value as an integer.
+               return ret === undefined ?
+                       ret :
+                       ret + "";
+       };
+} else if ( document.documentElement.currentStyle ) {
+       getStyles = function( elem ) {
+               return elem.currentStyle;
+       };
+
+       curCSS = function( elem, name, computed ) {
+               var left, rs, rsLeft, ret,
+                       style = elem.style;
+
+               computed = computed || getStyles( elem );
+               ret = computed ? computed[ name ] : undefined;
+
+               // Avoid setting ret to empty string here
+               // so we don't default to auto
+               if ( ret == null && style && style[ name ] ) {
+                       ret = style[ name ];
+               }
+
+               // From the awesome hack by Dean Edwards
+               // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
+
+               // If we're not dealing with a regular pixel number
+               // but a number that has a weird ending, we need to convert it to pixels
+               // but not position css attributes, as those are proportional to the parent element instead
+               // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
+               if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
+
+                       // Remember the original values
+                       left = style.left;
+                       rs = elem.runtimeStyle;
+                       rsLeft = rs && rs.left;
+
+                       // Put in the new values to get a computed value out
+                       if ( rsLeft ) {
+                               rs.left = elem.currentStyle.left;
+                       }
+                       style.left = name === "fontSize" ? "1em" : ret;
+                       ret = style.pixelLeft + "px";
+
+                       // Revert the changed values
+                       style.left = left;
+                       if ( rsLeft ) {
+                               rs.left = rsLeft;
+                       }
+               }
+
+               // Support: IE
+               // IE returns zIndex value as an integer.
+               return ret === undefined ?
+                       ret :
+                       ret + "" || "auto";
+       };
+}
+
+
+
+
+function addGetHookIf( conditionFn, hookFn ) {
+       // Define the hook, we'll check on the first run if it's really needed.
+       return {
+               get: function() {
+                       var condition = conditionFn();
+
+                       if ( condition == null ) {
+                               // The test was not ready at this point; screw the hook this time
+                               // but check again when needed next time.
+                               return;
+                       }
+
+                       if ( condition ) {
+                               // Hook not needed (or it's not possible to use it due to missing dependency),
+                               // remove it.
+                               // Since there are no other hooks for marginRight, remove the whole object.
+                               delete this.get;
+                               return;
+                       }
+
+                       // Hook needed; redefine it so that the support test is not executed again.
+
+                       return (this.get = hookFn).apply( this, arguments );
+               }
+       };
+}
+
+
+(function() {
+       var a, reliableHiddenOffsetsVal, boxSizingVal, boxSizingReliableVal,
+               pixelPositionVal, reliableMarginRightVal,
+               div = document.createElement( "div" ),
+               containerStyles = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px",
+               divReset =
+                       "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;" +
+                       "display:block;padding:0;margin:0;border:0";
+
+       // Setup
+       div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+       a = div.getElementsByTagName( "a" )[ 0 ];
+
+       a.style.cssText = "float:left;opacity:.5";
+
+       // Make sure that element opacity exists
+       // (IE uses filter instead)
+       // Use a regex to work around a WebKit issue. See #5145
+       support.opacity = /^0.5/.test( a.style.opacity );
+
+       // Verify style float existence
+       // (IE uses styleFloat instead of cssFloat)
+       support.cssFloat = !!a.style.cssFloat;
+
+       div.style.backgroundClip = "content-box";
+       div.cloneNode( true ).style.backgroundClip = "";
+       support.clearCloneStyle = div.style.backgroundClip === "content-box";
+
+       // Null elements to avoid leaks in IE.
+       a = div = null;
+
+       jQuery.extend(support, {
+               reliableHiddenOffsets: function() {
+                       if ( reliableHiddenOffsetsVal != null ) {
+                               return reliableHiddenOffsetsVal;
+                       }
+
+                       var container, tds, isSupported,
+                               div = document.createElement( "div" ),
+                               body = document.getElementsByTagName( "body" )[ 0 ];
+
+                       if ( !body ) {
+                               // Return for frameset docs that don't have a body
+                               return;
+                       }
+
+                       // Setup
+                       div.setAttribute( "className", "t" );
+                       div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+
+                       container = document.createElement( "div" );
+                       container.style.cssText = containerStyles;
+
+                       body.appendChild( container ).appendChild( div );
+
+                       // Support: IE8
+                       // Check if table cells still have offsetWidth/Height when they are set
+                       // to display:none and there are still other visible table cells in a
+                       // table row; if so, offsetWidth/Height are not reliable for use when
+                       // determining if an element has been hidden directly using
+                       // display:none (it is still safe to use offsets if a parent element is
+                       // hidden; don safety goggles and see bug #4512 for more information).
+                       div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
+                       tds = div.getElementsByTagName( "td" );
+                       tds[ 0 ].style.cssText = "padding:0;margin:0;border:0;display:none";
+                       isSupported = ( tds[ 0 ].offsetHeight === 0 );
+
+                       tds[ 0 ].style.display = "";
+                       tds[ 1 ].style.display = "none";
+
+                       // Support: IE8
+                       // Check if empty table cells still have offsetWidth/Height
+                       reliableHiddenOffsetsVal = isSupported && ( tds[ 0 ].offsetHeight === 0 );
+
+                       body.removeChild( container );
+
+                       // Null elements to avoid leaks in IE.
+                       div = body = null;
+
+                       return reliableHiddenOffsetsVal;
+               },
+
+               boxSizing: function() {
+                       if ( boxSizingVal == null ) {
+                               computeStyleTests();
+                       }
+                       return boxSizingVal;
+               },
+
+               boxSizingReliable: function() {
+                       if ( boxSizingReliableVal == null ) {
+                               computeStyleTests();
+                       }
+                       return boxSizingReliableVal;
+               },
+
+               pixelPosition: function() {
+                       if ( pixelPositionVal == null ) {
+                               computeStyleTests();
+                       }
+                       return pixelPositionVal;
+               },
+
+               reliableMarginRight: function() {
+                       var body, container, div, marginDiv;
+
+                       // Use window.getComputedStyle because jsdom on node.js will break without it.
+                       if ( reliableMarginRightVal == null && window.getComputedStyle ) {
+                               body = document.getElementsByTagName( "body" )[ 0 ];
+                               if ( !body ) {
+                                       // Test fired too early or in an unsupported environment, exit.
+                                       return;
+                               }
+
+                               container = document.createElement( "div" );
+                               div = document.createElement( "div" );
+                               container.style.cssText = containerStyles;
+
+                               body.appendChild( container ).appendChild( div );
+
+                               // Check if div with explicit width and no margin-right incorrectly
+                               // gets computed margin-right based on width of container. (#3333)
+                               // Fails in WebKit before Feb 2011 nightlies
+                               // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+                               marginDiv = div.appendChild( document.createElement( "div" ) );
+                               marginDiv.style.cssText = div.style.cssText = divReset;
+                               marginDiv.style.marginRight = marginDiv.style.width = "0";
+                               div.style.width = "1px";
+
+                               reliableMarginRightVal =
+                                       !parseFloat( ( window.getComputedStyle( marginDiv, null ) || {} ).marginRight );
+
+                               body.removeChild( container );
+                       }
+
+                       return reliableMarginRightVal;
+               }
+       });
+
+       function computeStyleTests() {
+               var container, div,
+                       body = document.getElementsByTagName( "body" )[ 0 ];
+
+               if ( !body ) {
+                       // Test fired too early or in an unsupported environment, exit.
+                       return;
+               }
+
+               container = document.createElement( "div" );
+               div = document.createElement( "div" );
+               container.style.cssText = containerStyles;
+
+               body.appendChild( container ).appendChild( div );
+
+               div.style.cssText =
+                       "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;" +
+                               "position:absolute;display:block;padding:1px;border:1px;width:4px;" +
+                               "margin-top:1%;top:1%";
+
+               // Workaround failing boxSizing test due to offsetWidth returning wrong value
+               // with some non-1 values of body zoom, ticket #13543
+               jQuery.swap( body, body.style.zoom != null ? { zoom: 1 } : {}, function() {
+                       boxSizingVal = div.offsetWidth === 4;
+               });
+
+               // Will be changed later if needed.
+               boxSizingReliableVal = true;
+               pixelPositionVal = false;
+               reliableMarginRightVal = true;
+
+               // Use window.getComputedStyle because jsdom on node.js will break without it.
+               if ( window.getComputedStyle ) {
+                       pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
+                       boxSizingReliableVal =
+                               ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
+               }
+
+               body.removeChild( container );
+
+               // Null elements to avoid leaks in IE.
+               div = body = null;
+       }
+
+})();
+
+
+// A method for quickly swapping in/out CSS properties to get correct calculations.
+jQuery.swap = function( elem, options, callback, args ) {
+       var ret, name,
+               old = {};
+
+       // Remember the old values, and insert the new ones
+       for ( name in options ) {
+               old[ name ] = elem.style[ name ];
+               elem.style[ name ] = options[ name ];
+       }
+
+       ret = callback.apply( elem, args || [] );
+
+       // Revert the old values
+       for ( name in options ) {
+               elem.style[ name ] = old[ name ];
+       }
+
+       return ret;
+};
+
+
+var
+               ralpha = /alpha\([^)]*\)/i,
+       ropacity = /opacity\s*=\s*([^)]*)/,
+
+       // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
+       // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
+       rdisplayswap = /^(none|table(?!-c[ea]).+)/,
+       rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
+       rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
+
+       cssShow = { position: "absolute", visibility: "hidden", display: "block" },
+       cssNormalTransform = {
+               letterSpacing: 0,
+               fontWeight: 400
+       },
+
+       cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
+
+
+// return a css property mapped to a potentially vendor prefixed property
+function vendorPropName( style, name ) {
+
+       // shortcut for names that are not vendor prefixed
+       if ( name in style ) {
+               return name;
+       }
+
+       // check for vendor prefixed names
+       var capName = name.charAt(0).toUpperCase() + name.slice(1),
+               origName = name,
+               i = cssPrefixes.length;
+
+       while ( i-- ) {
+               name = cssPrefixes[ i ] + capName;
+               if ( name in style ) {
+                       return name;
+               }
+       }
+
+       return origName;
+}
+
+function showHide( elements, show ) {
+       var display, elem, hidden,
+               values = [],
+               index = 0,
+               length = elements.length;
+
+       for ( ; index < length; index++ ) {
+               elem = elements[ index ];
+               if ( !elem.style ) {
+                       continue;
+               }
+
+               values[ index ] = jQuery._data( elem, "olddisplay" );
+               display = elem.style.display;
+               if ( show ) {
+                       // Reset the inline display of this element to learn if it is
+                       // being hidden by cascaded rules or not
+                       if ( !values[ index ] && display === "none" ) {
+                               elem.style.display = "";
+                       }
+
+                       // Set elements which have been overridden with display: none
+                       // in a stylesheet to whatever the default browser style is
+                       // for such an element
+                       if ( elem.style.display === "" && isHidden( elem ) ) {
+                               values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
+                       }
+               } else {
+
+                       if ( !values[ index ] ) {
+                               hidden = isHidden( elem );
+
+                               if ( display && display !== "none" || !hidden ) {
+                                       jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
+                               }
+                       }
+               }
+       }
+
+       // Set the display of most of the elements in a second loop
+       // to avoid the constant reflow
+       for ( index = 0; index < length; index++ ) {
+               elem = elements[ index ];
+               if ( !elem.style ) {
+                       continue;
+               }
+               if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
+                       elem.style.display = show ? values[ index ] || "" : "none";
+               }
+       }
+
+       return elements;
+}
+
+function setPositiveNumber( elem, value, subtract ) {
+       var matches = rnumsplit.exec( value );
+       return matches ?
+               // Guard against undefined "subtract", e.g., when used as in cssHooks
+               Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
+               value;
+}
+
+function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
+       var i = extra === ( isBorderBox ? "border" : "content" ) ?
+               // If we already have the right measurement, avoid augmentation
+               4 :
+               // Otherwise initialize for horizontal or vertical properties
+               name === "width" ? 1 : 0,
+
+               val = 0;
+
+       for ( ; i < 4; i += 2 ) {
+               // both box models exclude margin, so add it if we want it
+               if ( extra === "margin" ) {
+                       val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
+               }
+
+               if ( isBorderBox ) {
+                       // border-box includes padding, so remove it if we want content
+                       if ( extra === "content" ) {
+                               val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+                       }
+
+                       // at this point, extra isn't border nor margin, so remove border
+                       if ( extra !== "margin" ) {
+                               val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+                       }
+               } else {
+                       // at this point, extra isn't content, so add padding
+                       val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
+
+                       // at this point, extra isn't content nor padding, so add border
+                       if ( extra !== "padding" ) {
+                               val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
+                       }
+               }
+       }
+
+       return val;
+}
+
+function getWidthOrHeight( elem, name, extra ) {
+
+       // Start with offset property, which is equivalent to the border-box value
+       var valueIsBorderBox = true,
+               val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
+               styles = getStyles( elem ),
+               isBorderBox = support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
+
+       // some non-html elements return undefined for offsetWidth, so check for null/undefined
+       // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
+       // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
+       if ( val <= 0 || val == null ) {
+               // Fall back to computed then uncomputed css if necessary
+               val = curCSS( elem, name, styles );
+               if ( val < 0 || val == null ) {
+                       val = elem.style[ name ];
+               }
+
+               // Computed unit is not pixels. Stop here and return.
+               if ( rnumnonpx.test(val) ) {
+                       return val;
+               }
+
+               // we need the check for style in case a browser which returns unreliable values
+               // for getComputedStyle silently falls back to the reliable elem.style
+               valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
+
+               // Normalize "", auto, and prepare for extra
+               val = parseFloat( val ) || 0;
+       }
+
+       // use the active box-sizing model to add/subtract irrelevant styles
+       return ( val +
+               augmentWidthOrHeight(
+                       elem,
+                       name,
+                       extra || ( isBorderBox ? "border" : "content" ),
+                       valueIsBorderBox,
+                       styles
+               )
+       ) + "px";
+}
+
+jQuery.extend({
+       // Add in style property hooks for overriding the default
+       // behavior of getting and setting a style property
+       cssHooks: {
+               opacity: {
+                       get: function( elem, computed ) {
+                               if ( computed ) {
+                                       // We should always get a number back from opacity
+                                       var ret = curCSS( elem, "opacity" );
+                                       return ret === "" ? "1" : ret;
+                               }
+                       }
+               }
+       },
+
+       // Don't automatically add "px" to these possibly-unitless properties
+       cssNumber: {
+               "columnCount": true,
+               "fillOpacity": true,
+               "fontWeight": true,
+               "lineHeight": true,
+               "opacity": true,
+               "order": true,
+               "orphans": true,
+               "widows": true,
+               "zIndex": true,
+               "zoom": true
+       },
+
+       // Add in properties whose names you wish to fix before
+       // setting or getting the value
+       cssProps: {
+               // normalize float css property
+               "float": support.cssFloat ? "cssFloat" : "styleFloat"
+       },
+
+       // Get and set the style property on a DOM Node
+       style: function( elem, name, value, extra ) {
+               // Don't set styles on text and comment nodes
+               if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
+                       return;
+               }
+
+               // Make sure that we're working with the right name
+               var ret, type, hooks,
+                       origName = jQuery.camelCase( name ),
+                       style = elem.style;
+
+               name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
+
+               // gets hook for the prefixed version
+               // followed by the unprefixed version
+               hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+               // Check if we're setting a value
+               if ( value !== undefined ) {
+                       type = typeof value;
+
+                       // convert relative number strings (+= or -=) to relative numbers. #7345
+                       if ( type === "string" && (ret = rrelNum.exec( value )) ) {
+                               value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
+                               // Fixes bug #9237
+                               type = "number";
+                       }
+
+                       // Make sure that null and NaN values aren't set. See: #7116
+                       if ( value == null || value !== value ) {
+                               return;
+                       }
+
+                       // If a number was passed in, add 'px' to the (except for certain CSS properties)
+                       if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
+                               value += "px";
+                       }
+
+                       // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
+                       // but it would mean to define eight (for every problematic property) identical functions
+                       if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
+                               style[ name ] = "inherit";
+                       }
+
+                       // If a hook was provided, use that value, otherwise just set the specified value
+                       if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
+
+                               // Support: IE
+                               // Swallow errors from 'invalid' CSS values (#5509)
+                               try {
+                                       // Support: Chrome, Safari
+                                       // Setting style to blank string required to delete "style: x !important;"
+                                       style[ name ] = "";
+                                       style[ name ] = value;
+                               } catch(e) {}
+                       }
+
+               } else {
+                       // If a hook was provided get the non-computed value from there
+                       if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
+                               return ret;
+                       }
+
+                       // Otherwise just get the value from the style object
+                       return style[ name ];
+               }
+       },
+
+       css: function( elem, name, extra, styles ) {
+               var num, val, hooks,
+                       origName = jQuery.camelCase( name );
+
+               // Make sure that we're working with the right name
+               name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
+
+               // gets hook for the prefixed version
+               // followed by the unprefixed version
+               hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
+
+               // If a hook was provided get the computed value from there
+               if ( hooks && "get" in hooks ) {
+                       val = hooks.get( elem, true, extra );
+               }
+
+               // Otherwise, if a way to get the computed value exists, use that
+               if ( val === undefined ) {
+                       val = curCSS( elem, name, styles );
+               }
+
+               //convert "normal" to computed value
+               if ( val === "normal" && name in cssNormalTransform ) {
+                       val = cssNormalTransform[ name ];
+               }
+
+               // Return, converting to number if forced or a qualifier was provided and val looks numeric
+               if ( extra === "" || extra ) {
+                       num = parseFloat( val );
+                       return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
+               }
+               return val;
+       }
+});
+
+jQuery.each([ "height", "width" ], function( i, name ) {
+       jQuery.cssHooks[ name ] = {
+               get: function( elem, computed, extra ) {
+                       if ( computed ) {
+                               // certain elements can have dimension info if we invisibly show them
+                               // however, it must have a current display style that would benefit from this
+                               return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
+                                       jQuery.swap( elem, cssShow, function() {
+                                               return getWidthOrHeight( elem, name, extra );
+                                       }) :
+                                       getWidthOrHeight( elem, name, extra );
+                       }
+               },
+
+               set: function( elem, value, extra ) {
+                       var styles = extra && getStyles( elem );
+                       return setPositiveNumber( elem, value, extra ?
+                               augmentWidthOrHeight(
+                                       elem,
+                                       name,
+                                       extra,
+                                       support.boxSizing() && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
+                                       styles
+                               ) : 0
+                       );
+               }
+       };
+});
+
+if ( !support.opacity ) {
+       jQuery.cssHooks.opacity = {
+               get: function( elem, computed ) {
+                       // IE uses filters for opacity
+                       return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
+                               ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
+                               computed ? "1" : "";
+               },
+
+               set: function( elem, value ) {
+                       var style = elem.style,
+                               currentStyle = elem.currentStyle,
+                               opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
+                               filter = currentStyle && currentStyle.filter || style.filter || "";
+
+                       // IE has trouble with opacity if it does not have layout
+                       // Force it by setting the zoom level
+                       style.zoom = 1;
+
+                       // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
+                       // if value === "", then remove inline opacity #12685
+                       if ( ( value >= 1 || value === "" ) &&
+                                       jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
+                                       style.removeAttribute ) {
+
+                               // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
+                               // if "filter:" is present at all, clearType is disabled, we want to avoid this
+                               // style.removeAttribute is IE Only, but so apparently is this code path...
+                               style.removeAttribute( "filter" );
+
+                               // if there is no filter style applied in a css rule or unset inline opacity, we are done
+                               if ( value === "" || currentStyle && !currentStyle.filter ) {
+                                       return;
+                               }
+                       }
+
+                       // otherwise, set new filter values
+                       style.filter = ralpha.test( filter ) ?
+                               filter.replace( ralpha, opacity ) :
+                               filter + " " + opacity;
+               }
+       };
+}
+
+jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
+       function( elem, computed ) {
+               if ( computed ) {
+                       // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+                       // Work around by temporarily setting element display to inline-block
+                       return jQuery.swap( elem, { "display": "inline-block" },
+                               curCSS, [ elem, "marginRight" ] );
+               }
+       }
+);
+
+// These hooks are used by animate to expand properties
+jQuery.each({
+       margin: "",
+       padding: "",
+       border: "Width"
+}, function( prefix, suffix ) {
+       jQuery.cssHooks[ prefix + suffix ] = {
+               expand: function( value ) {
+                       var i = 0,
+                               expanded = {},
+
+                               // assumes a single number if not a string
+                               parts = typeof value === "string" ? value.split(" ") : [ value ];
+
+                       for ( ; i < 4; i++ ) {
+                               expanded[ prefix + cssExpand[ i ] + suffix ] =
+                                       parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
+                       }
+
+                       return expanded;
+               }
+       };
+
+       if ( !rmargin.test( prefix ) ) {
+               jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
+       }
+});
+
+jQuery.fn.extend({
+       css: function( name, value ) {
+               return access( this, function( elem, name, value ) {
+                       var styles, len,
+                               map = {},
+                               i = 0;
+
+                       if ( jQuery.isArray( name ) ) {
+                               styles = getStyles( elem );
+                               len = name.length;
+
+                               for ( ; i < len; i++ ) {
+                                       map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
+                               }
+
+                               return map;
+                       }
+
+                       return value !== undefined ?
+                               jQuery.style( elem, name, value ) :
+                               jQuery.css( elem, name );
+               }, name, value, arguments.length > 1 );
+       },
+       show: function() {
+               return showHide( this, true );
+       },
+       hide: function() {
+               return showHide( this );
+       },
+       toggle: function( state ) {
+               if ( typeof state === "boolean" ) {
+                       return state ? this.show() : this.hide();
+               }
+
+               return this.each(function() {
+                       if ( isHidden( this ) ) {
+                               jQuery( this ).show();
+                       } else {
+                               jQuery( this ).hide();
+                       }
+               });
+       }
+});
+
+
+function Tween( elem, options, prop, end, easing ) {
+       return new Tween.prototype.init( elem, options, prop, end, easing );
+}
+jQuery.Tween = Tween;
+
+Tween.prototype = {
+       constructor: Tween,
+       init: function( elem, options, prop, end, easing, unit ) {
+               this.elem = elem;
+               this.prop = prop;
+               this.easing = easing || "swing";
+               this.options = options;
+               this.start = this.now = this.cur();
+               this.end = end;
+               this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
+       },
+       cur: function() {
+               var hooks = Tween.propHooks[ this.prop ];
+
+               return hooks && hooks.get ?
+                       hooks.get( this ) :
+                       Tween.propHooks._default.get( this );
+       },
+       run: function( percent ) {
+               var eased,
+                       hooks = Tween.propHooks[ this.prop ];
+
+               if ( this.options.duration ) {
+                       this.pos = eased = jQuery.easing[ this.easing ](
+                               percent, this.options.duration * percent, 0, 1, this.options.duration
+                       );
+               } else {
+                       this.pos = eased = percent;
+               }
+               this.now = ( this.end - this.start ) * eased + this.start;
+
+               if ( this.options.step ) {
+                       this.options.step.call( this.elem, this.now, this );
+               }
+
+               if ( hooks && hooks.set ) {
+                       hooks.set( this );
+               } else {
+                       Tween.propHooks._default.set( this );
+               }
+               return this;
+       }
+};
+
+Tween.prototype.init.prototype = Tween.prototype;
+
+Tween.propHooks = {
+       _default: {
+               get: function( tween ) {
+                       var result;
+
+                       if ( tween.elem[ tween.prop ] != null &&
+                               (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
+                               return tween.elem[ tween.prop ];
+                       }
+
+                       // passing an empty string as a 3rd parameter to .css will automatically
+                       // attempt a parseFloat and fallback to a string if the parse fails
+                       // so, simple values such as "10px" are parsed to Float.
+                       // complex values such as "rotate(1rad)" are returned as is.
+                       result = jQuery.css( tween.elem, tween.prop, "" );
+                       // Empty strings, null, undefined and "auto" are converted to 0.
+                       return !result || result === "auto" ? 0 : result;
+               },
+               set: function( tween ) {
+                       // use step hook for back compat - use cssHook if its there - use .style if its
+                       // available and use plain properties where available
+                       if ( jQuery.fx.step[ tween.prop ] ) {
+                               jQuery.fx.step[ tween.prop ]( tween );
+                       } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
+                               jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
+                       } else {
+                               tween.elem[ tween.prop ] = tween.now;
+                       }
+               }
+       }
+};
+
+// Support: IE <=9
+// Panic based approach to setting things on disconnected nodes
+
+Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
+       set: function( tween ) {
+               if ( tween.elem.nodeType && tween.elem.parentNode ) {
+                       tween.elem[ tween.prop ] = tween.now;
+               }
+       }
+};
+
+jQuery.easing = {
+       linear: function( p ) {
+               return p;
+       },
+       swing: function( p ) {
+               return 0.5 - Math.cos( p * Math.PI ) / 2;
+       }
+};
+
+jQuery.fx = Tween.prototype.init;
+
+// Back Compat <1.8 extension point
+jQuery.fx.step = {};
+
+
+
+
+var
+       fxNow, timerId,
+       rfxtypes = /^(?:toggle|show|hide)$/,
+       rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
+       rrun = /queueHooks$/,
+       animationPrefilters = [ defaultPrefilter ],
+       tweeners = {
+               "*": [ function( prop, value ) {
+                       var tween = this.createTween( prop, value ),
+                               target = tween.cur(),
+                               parts = rfxnum.exec( value ),
+                               unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
+
+                               // Starting value computation is required for potential unit mismatches
+                               start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
+                                       rfxnum.exec( jQuery.css( tween.elem, prop ) ),
+                               scale = 1,
+                               maxIterations = 20;
+
+                       if ( start && start[ 3 ] !== unit ) {
+                               // Trust units reported by jQuery.css
+                               unit = unit || start[ 3 ];
+
+                               // Make sure we update the tween properties later on
+                               parts = parts || [];
+
+                               // Iteratively approximate from a nonzero starting point
+                               start = +target || 1;
+
+                               do {
+                                       // If previous iteration zeroed out, double until we get *something*
+                                       // Use a string for doubling factor so we don't accidentally see scale as unchanged below
+                                       scale = scale || ".5";
+
+                                       // Adjust and apply
+                                       start = start / scale;
+                                       jQuery.style( tween.elem, prop, start + unit );
+
+                               // Update scale, tolerating zero or NaN from tween.cur()
+                               // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+                               } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
+                       }
+
+                       // Update tween properties
+                       if ( parts ) {
+                               start = tween.start = +start || +target || 0;
+                               tween.unit = unit;
+                               // If a +=/-= token was provided, we're doing a relative animation
+                               tween.end = parts[ 1 ] ?
+                                       start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
+                                       +parts[ 2 ];
+                       }
+
+                       return tween;
+               } ]
+       };
+
+// Animations created synchronously will run synchronously
+function createFxNow() {
+       setTimeout(function() {
+               fxNow = undefined;
+       });
+       return ( fxNow = jQuery.now() );
+}
+
+// Generate parameters to create a standard animation
+function genFx( type, includeWidth ) {
+       var which,
+               attrs = { height: type },
+               i = 0;
+
+       // if we include width, step value is 1 to do all cssExpand values,
+       // if we don't include width, step value is 2 to skip over Left and Right
+       includeWidth = includeWidth ? 1 : 0;
+       for ( ; i < 4 ; i += 2 - includeWidth ) {
+               which = cssExpand[ i ];
+               attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
+       }
+
+       if ( includeWidth ) {
+               attrs.opacity = attrs.width = type;
+       }
+
+       return attrs;
+}
+
+function createTween( value, prop, animation ) {
+       var tween,
+               collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
+               index = 0,
+               length = collection.length;
+       for ( ; index < length; index++ ) {
+               if ( (tween = collection[ index ].call( animation, prop, value )) ) {
+
+                       // we're done with this property
+                       return tween;
+               }
+       }
+}
+
+function defaultPrefilter( elem, props, opts ) {
+       /* jshint validthis: true */
+       var prop, value, toggle, tween, hooks, oldfire, display, dDisplay,
+               anim = this,
+               orig = {},
+               style = elem.style,
+               hidden = elem.nodeType && isHidden( elem ),
+               dataShow = jQuery._data( elem, "fxshow" );
+
+       // handle queue: false promises
+       if ( !opts.queue ) {
+               hooks = jQuery._queueHooks( elem, "fx" );
+               if ( hooks.unqueued == null ) {
+                       hooks.unqueued = 0;
+                       oldfire = hooks.empty.fire;
+                       hooks.empty.fire = function() {
+                               if ( !hooks.unqueued ) {
+                                       oldfire();
+                               }
+                       };
+               }
+               hooks.unqueued++;
+
+               anim.always(function() {
+                       // doing this makes sure that the complete handler will be called
+                       // before this completes
+                       anim.always(function() {
+                               hooks.unqueued--;
+                               if ( !jQuery.queue( elem, "fx" ).length ) {
+                                       hooks.empty.fire();
+                               }
+                       });
+               });
+       }
+
+       // height/width overflow pass
+       if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
+               // Make sure that nothing sneaks out
+               // Record all 3 overflow attributes because IE does not
+               // change the overflow attribute when overflowX and
+               // overflowY are set to the same value
+               opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
+
+               // Set display property to inline-block for height/width
+               // animations on inline elements that are having width/height animated
+               display = jQuery.css( elem, "display" );
+               dDisplay = defaultDisplay( elem.nodeName );
+               if ( display === "none" ) {
+                       display = dDisplay;
+               }
+               if ( display === "inline" &&
+                               jQuery.css( elem, "float" ) === "none" ) {
+
+                       // inline-level elements accept inline-block;
+                       // block-level elements need to be inline with layout
+                       if ( !support.inlineBlockNeedsLayout || dDisplay === "inline" ) {
+                               style.display = "inline-block";
+                       } else {
+                               style.zoom = 1;
+                       }
+               }
+       }
+
+       if ( opts.overflow ) {
+               style.overflow = "hidden";
+               if ( !support.shrinkWrapBlocks() ) {
+                       anim.always(function() {
+                               style.overflow = opts.overflow[ 0 ];
+                               style.overflowX = opts.overflow[ 1 ];
+                               style.overflowY = opts.overflow[ 2 ];
+                       });
+               }
+       }
+
+       // show/hide pass
+       for ( prop in props ) {
+               value = props[ prop ];
+               if ( rfxtypes.exec( value ) ) {
+                       delete props[ prop ];
+                       toggle = toggle || value === "toggle";
+                       if ( value === ( hidden ? "hide" : "show" ) ) {
+
+                               // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
+                               if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
+                                       hidden = true;
+                               } else {
+                                       continue;
+                               }
+                       }
+                       orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
+               }
+       }
+
+       if ( !jQuery.isEmptyObject( orig ) ) {
+               if ( dataShow ) {
+                       if ( "hidden" in dataShow ) {
+                               hidden = dataShow.hidden;
+                       }
+               } else {
+                       dataShow = jQuery._data( elem, "fxshow", {} );
+               }
+
+               // store state if its toggle - enables .stop().toggle() to "reverse"
+               if ( toggle ) {
+                       dataShow.hidden = !hidden;
+               }
+               if ( hidden ) {
+                       jQuery( elem ).show();
+               } else {
+                       anim.done(function() {
+                               jQuery( elem ).hide();
+                       });
+               }
+               anim.done(function() {
+                       var prop;
+                       jQuery._removeData( elem, "fxshow" );
+                       for ( prop in orig ) {
+                               jQuery.style( elem, prop, orig[ prop ] );
+                       }
+               });
+               for ( prop in orig ) {
+                       tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
+
+                       if ( !( prop in dataShow ) ) {
+                               dataShow[ prop ] = tween.start;
+                               if ( hidden ) {
+                                       tween.end = tween.start;
+                                       tween.start = prop === "width" || prop === "height" ? 1 : 0;
+                               }
+                       }
+               }
+       }
+}
+
+function propFilter( props, specialEasing ) {
+       var index, name, easing, value, hooks;
+
+       // camelCase, specialEasing and expand cssHook pass
+       for ( index in props ) {
+               name = jQuery.camelCase( index );
+               easing = specialEasing[ name ];
+               value = props[ index ];
+               if ( jQuery.isArray( value ) ) {
+                       easing = value[ 1 ];
+                       value = props[ index ] = value[ 0 ];
+               }
+
+               if ( index !== name ) {
+                       props[ name ] = value;
+                       delete props[ index ];
+               }
+
+               hooks = jQuery.cssHooks[ name ];
+               if ( hooks && "expand" in hooks ) {
+                       value = hooks.expand( value );
+                       delete props[ name ];
+
+                       // not quite $.extend, this wont overwrite keys already present.
+                       // also - reusing 'index' from above because we have the correct "name"
+                       for ( index in value ) {
+                               if ( !( index in props ) ) {
+                                       props[ index ] = value[ index ];
+                                       specialEasing[ index ] = easing;
+                               }
+                       }
+               } else {
+                       specialEasing[ name ] = easing;
+               }
+       }
+}
+
+function Animation( elem, properties, options ) {
+       var result,
+               stopped,
+               index = 0,
+               length = animationPrefilters.length,
+               deferred = jQuery.Deferred().always( function() {
+                       // don't match elem in the :animated selector
+                       delete tick.elem;
+               }),
+               tick = function() {
+                       if ( stopped ) {
+                               return false;
+                       }
+                       var currentTime = fxNow || createFxNow(),
+                               remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
+                               // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
+                               temp = remaining / animation.duration || 0,
+                               percent = 1 - temp,
+                               index = 0,
+                               length = animation.tweens.length;
+
+                       for ( ; index < length ; index++ ) {
+                               animation.tweens[ index ].run( percent );
+                       }
+
+                       deferred.notifyWith( elem, [ animation, percent, remaining ]);
+
+                       if ( percent < 1 && length ) {
+                               return remaining;
+                       } else {
+                               deferred.resolveWith( elem, [ animation ] );
+                               return false;
+                       }
+               },
+               animation = deferred.promise({
+                       elem: elem,
+                       props: jQuery.extend( {}, properties ),
+                       opts: jQuery.extend( true, { specialEasing: {} }, options ),
+                       originalProperties: properties,
+                       originalOptions: options,
+                       startTime: fxNow || createFxNow(),
+                       duration: options.duration,
+                       tweens: [],
+                       createTween: function( prop, end ) {
+                               var tween = jQuery.Tween( elem, animation.opts, prop, end,
+                                               animation.opts.specialEasing[ prop ] || animation.opts.easing );
+                               animation.tweens.push( tween );
+                               return tween;
+                       },
+                       stop: function( gotoEnd ) {
+                               var index = 0,
+                                       // if we are going to the end, we want to run all the tweens
+                                       // otherwise we skip this part
+                                       length = gotoEnd ? animation.tweens.length : 0;
+                               if ( stopped ) {
+                                       return this;
+                               }
+                               stopped = true;
+                               for ( ; index < length ; index++ ) {
+                                       animation.tweens[ index ].run( 1 );
+                               }
+
+                               // resolve when we played the last frame
+                               // otherwise, reject
+                               if ( gotoEnd ) {
+                                       deferred.resolveWith( elem, [ animation, gotoEnd ] );
+                               } else {
+                                       deferred.rejectWith( elem, [ animation, gotoEnd ] );
+                               }
+                               return this;
+                       }
+               }),
+               props = animation.props;
+
+       propFilter( props, animation.opts.specialEasing );
+
+       for ( ; index < length ; index++ ) {
+               result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
+               if ( result ) {
+                       return result;
+               }
+       }
+
+       jQuery.map( props, createTween, animation );
+
+       if ( jQuery.isFunction( animation.opts.start ) ) {
+               animation.opts.start.call( elem, animation );
+       }
+
+       jQuery.fx.timer(
+               jQuery.extend( tick, {
+                       elem: elem,
+                       anim: animation,
+                       queue: animation.opts.queue
+               })
+       );
+
+       // attach callbacks from options
+       return animation.progress( animation.opts.progress )
+               .done( animation.opts.done, animation.opts.complete )
+               .fail( animation.opts.fail )
+               .always( animation.opts.always );
+}
+
+jQuery.Animation = jQuery.extend( Animation, {
+       tweener: function( props, callback ) {
+               if ( jQuery.isFunction( props ) ) {
+                       callback = props;
+                       props = [ "*" ];
+               } else {
+                       props = props.split(" ");
+               }
+
+               var prop,
+                       index = 0,
+                       length = props.length;
+
+               for ( ; index < length ; index++ ) {
+                       prop = props[ index ];
+                       tweeners[ prop ] = tweeners[ prop ] || [];
+                       tweeners[ prop ].unshift( callback );
+               }
+       },
+
+       prefilter: function( callback, prepend ) {
+               if ( prepend ) {
+                       animationPrefilters.unshift( callback );
+               } else {
+                       animationPrefilters.push( callback );
+               }
+       }
+});
+
+jQuery.speed = function( speed, easing, fn ) {
+       var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
+               complete: fn || !fn && easing ||
+                       jQuery.isFunction( speed ) && speed,
+               duration: speed,
+               easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
+       };
+
+       opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
+               opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
+
+       // normalize opt.queue - true/undefined/null -> "fx"
+       if ( opt.queue == null || opt.queue === true ) {
+               opt.queue = "fx";
+       }
+
+       // Queueing
+       opt.old = opt.complete;
+
+       opt.complete = function() {
+               if ( jQuery.isFunction( opt.old ) ) {
+                       opt.old.call( this );
+               }
+
+               if ( opt.queue ) {
+                       jQuery.dequeue( this, opt.queue );
+               }
+       };
+
+       return opt;
+};
+
+jQuery.fn.extend({
+       fadeTo: function( speed, to, easing, callback ) {
+
+               // show any hidden elements after setting opacity to 0
+               return this.filter( isHidden ).css( "opacity", 0 ).show()
+
+                       // animate to the value specified
+                       .end().animate({ opacity: to }, speed, easing, callback );
+       },
+       animate: function( prop, speed, easing, callback ) {
+               var empty = jQuery.isEmptyObject( prop ),
+                       optall = jQuery.speed( speed, easing, callback ),
+                       doAnimation = function() {
+                               // Operate on a copy of prop so per-property easing won't be lost
+                               var anim = Animation( this, jQuery.extend( {}, prop ), optall );
+
+                               // Empty animations, or finishing resolves immediately
+                               if ( empty || jQuery._data( this, "finish" ) ) {
+                                       anim.stop( true );
+                               }
+                       };
+                       doAnimation.finish = doAnimation;
+
+               return empty || optall.queue === false ?
+                       this.each( doAnimation ) :
+                       this.queue( optall.queue, doAnimation );
+       },
+       stop: function( type, clearQueue, gotoEnd ) {
+               var stopQueue = function( hooks ) {
+                       var stop = hooks.stop;
+                       delete hooks.stop;
+                       stop( gotoEnd );
+               };
+
+               if ( typeof type !== "string" ) {
+                       gotoEnd = clearQueue;
+                       clearQueue = type;
+                       type = undefined;
+               }
+               if ( clearQueue && type !== false ) {
+                       this.queue( type || "fx", [] );
+               }
+
+               return this.each(function() {
+                       var dequeue = true,
+                               index = type != null && type + "queueHooks",
+                               timers = jQuery.timers,
+                               data = jQuery._data( this );
+
+                       if ( index ) {
+                               if ( data[ index ] && data[ index ].stop ) {
+                                       stopQueue( data[ index ] );
+                               }
+                       } else {
+                               for ( index in data ) {
+                                       if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
+                                               stopQueue( data[ index ] );
+                                       }
+                               }
+                       }
+
+                       for ( index = timers.length; index--; ) {
+                               if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
+                                       timers[ index ].anim.stop( gotoEnd );
+                                       dequeue = false;
+                                       timers.splice( index, 1 );
+                               }
+                       }
+
+                       // start the next in the queue if the last step wasn't forced
+                       // timers currently will call their complete callbacks, which will dequeue
+                       // but only if they were gotoEnd
+                       if ( dequeue || !gotoEnd ) {
+                               jQuery.dequeue( this, type );
+                       }
+               });
+       },
+       finish: function( type ) {
+               if ( type !== false ) {
+                       type = type || "fx";
+               }
+               return this.each(function() {
+                       var index,
+                               data = jQuery._data( this ),
+                               queue = data[ type + "queue" ],
+                               hooks = data[ type + "queueHooks" ],
+                               timers = jQuery.timers,
+                               length = queue ? queue.length : 0;
+
+                       // enable finishing flag on private data
+                       data.finish = true;
+
+                       // empty the queue first
+                       jQuery.queue( this, type, [] );
+
+                       if ( hooks && hooks.stop ) {
+                               hooks.stop.call( this, true );
+                       }
+
+                       // look for any active animations, and finish them
+                       for ( index = timers.length; index--; ) {
+                               if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
+                                       timers[ index ].anim.stop( true );
+                                       timers.splice( index, 1 );
+                               }
+                       }
+
+                       // look for any animations in the old queue and finish them
+                       for ( index = 0; index < length; index++ ) {
+                               if ( queue[ index ] && queue[ index ].finish ) {
+                                       queue[ index ].finish.call( this );
+                               }
+                       }
+
+                       // turn off finishing flag
+                       delete data.finish;
+               });
+       }
+});
+
+jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
+       var cssFn = jQuery.fn[ name ];
+       jQuery.fn[ name ] = function( speed, easing, callback ) {
+               return speed == null || typeof speed === "boolean" ?
+                       cssFn.apply( this, arguments ) :
+                       this.animate( genFx( name, true ), speed, easing, callback );
+       };
+});
+
+// Generate shortcuts for custom animations
+jQuery.each({
+       slideDown: genFx("show"),
+       slideUp: genFx("hide"),
+       slideToggle: genFx("toggle"),
+       fadeIn: { opacity: "show" },
+       fadeOut: { opacity: "hide" },
+       fadeToggle: { opacity: "toggle" }
+}, function( name, props ) {
+       jQuery.fn[ name ] = function( speed, easing, callback ) {
+               return this.animate( props, speed, easing, callback );
+       };
+});
+
+jQuery.timers = [];
+jQuery.fx.tick = function() {
+       var timer,
+               timers = jQuery.timers,
+               i = 0;
+
+       fxNow = jQuery.now();
+
+       for ( ; i < timers.length; i++ ) {
+               timer = timers[ i ];
+               // Checks the timer has not already been removed
+               if ( !timer() && timers[ i ] === timer ) {
+                       timers.splice( i--, 1 );
+               }
+       }
+
+       if ( !timers.length ) {
+               jQuery.fx.stop();
+       }
+       fxNow = undefined;
+};
+
+jQuery.fx.timer = function( timer ) {
+       jQuery.timers.push( timer );
+       if ( timer() ) {
+               jQuery.fx.start();
+       } else {
+               jQuery.timers.pop();
+       }
+};
+
+jQuery.fx.interval = 13;
+
+jQuery.fx.start = function() {
+       if ( !timerId ) {
+               timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
+       }
+};
+
+jQuery.fx.stop = function() {
+       clearInterval( timerId );
+       timerId = null;
+};
+
+jQuery.fx.speeds = {
+       slow: 600,
+       fast: 200,
+       // Default speed
+       _default: 400
+};
+
+
+// Based off of the plugin by Clint Helfers, with permission.
+// http://blindsignals.com/index.php/2009/07/jquery-delay/
+jQuery.fn.delay = function( time, type ) {
+       time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
+       type = type || "fx";
+
+       return this.queue( type, function( next, hooks ) {
+               var timeout = setTimeout( next, time );
+               hooks.stop = function() {
+                       clearTimeout( timeout );
+               };
+       });
+};
+
+
+(function() {
+       var a, input, select, opt,
+               div = document.createElement("div" );
+
+       // Setup
+       div.setAttribute( "className", "t" );
+       div.innerHTML = "  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+       a = div.getElementsByTagName("a")[ 0 ];
+
+       // First batch of tests.
+       select = document.createElement("select");
+       opt = select.appendChild( document.createElement("option") );
+       input = div.getElementsByTagName("input")[ 0 ];
+
+       a.style.cssText = "top:1px";
+
+       // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
+       support.getSetAttribute = div.className !== "t";
+
+       // Get the style information from getAttribute
+       // (IE uses .cssText instead)
+       support.style = /top/.test( a.getAttribute("style") );
+
+       // Make sure that URLs aren't manipulated
+       // (IE normalizes it by default)
+       support.hrefNormalized = a.getAttribute("href") === "/a";
+
+       // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
+       support.checkOn = !!input.value;
+
+       // Make sure that a selected-by-default option has a working selected property.
+       // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+       support.optSelected = opt.selected;
+
+       // Tests for enctype support on a form (#6743)
+       support.enctype = !!document.createElement("form").enctype;
+
+       // Make sure that the options inside disabled selects aren't marked as disabled
+       // (WebKit marks them as disabled)
+       select.disabled = true;
+       support.optDisabled = !opt.disabled;
+
+       // Support: IE8 only
+       // Check if we can trust getAttribute("value")
+       input = document.createElement( "input" );
+       input.setAttribute( "value", "" );
+       support.input = input.getAttribute( "value" ) === "";
+
+       // Check if an input maintains its value after becoming a radio
+       input.value = "t";
+       input.setAttribute( "type", "radio" );
+       support.radioValue = input.value === "t";
+
+       // Null elements to avoid leaks in IE.
+       a = input = select = opt = div = null;
+})();
+
+
+var rreturn = /\r/g;
+
+jQuery.fn.extend({
+       val: function( value ) {
+               var hooks, ret, isFunction,
+                       elem = this[0];
+
+               if ( !arguments.length ) {
+                       if ( elem ) {
+                               hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
+
+                               if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
+                                       return ret;
+                               }
+
+                               ret = elem.value;
+
+                               return typeof ret === "string" ?
+                                       // handle most common string cases
+                                       ret.replace(rreturn, "") :
+                                       // handle cases where value is null/undef or number
+                                       ret == null ? "" : ret;
+                       }
+
+                       return;
+               }
+
+               isFunction = jQuery.isFunction( value );
+
+               return this.each(function( i ) {
+                       var val;
+
+                       if ( this.nodeType !== 1 ) {
+                               return;
+                       }
+
+                       if ( isFunction ) {
+                               val = value.call( this, i, jQuery( this ).val() );
+                       } else {
+                               val = value;
+                       }
+
+                       // Treat null/undefined as ""; convert numbers to string
+                       if ( val == null ) {
+                               val = "";
+                       } else if ( typeof val === "number" ) {
+                               val += "";
+                       } else if ( jQuery.isArray( val ) ) {
+                               val = jQuery.map( val, function( value ) {
+                                       return value == null ? "" : value + "";
+                               });
+                       }
+
+                       hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
+
+                       // If set returns undefined, fall back to normal setting
+                       if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
+                               this.value = val;
+                       }
+               });
+       }
+});
+
+jQuery.extend({
+       valHooks: {
+               option: {
+                       get: function( elem ) {
+                               var val = jQuery.find.attr( elem, "value" );
+                               return val != null ?
+                                       val :
+                                       jQuery.text( elem );
+                       }
+               },
+               select: {
+                       get: function( elem ) {
+                               var value, option,
+                                       options = elem.options,
+                                       index = elem.selectedIndex,
+                                       one = elem.type === "select-one" || index < 0,
+                                       values = one ? null : [],
+                                       max = one ? index + 1 : options.length,
+                                       i = index < 0 ?
+                                               max :
+                                               one ? index : 0;
+
+                               // Loop through all the selected options
+                               for ( ; i < max; i++ ) {
+                                       option = options[ i ];
+
+                                       // oldIE doesn't update selected after form reset (#2551)
+                                       if ( ( option.selected || i === index ) &&
+                                                       // Don't return options that are disabled or in a disabled optgroup
+                                                       ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
+                                                       ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
+
+                                               // Get the specific value for the option
+                                               value = jQuery( option ).val();
+
+                                               // We don't need an array for one selects
+                                               if ( one ) {
+                                                       return value;
+                                               }
+
+                                               // Multi-Selects return an array
+                                               values.push( value );
+                                       }
+                               }
+
+                               return values;
+                       },
+
+                       set: function( elem, value ) {
+                               var optionSet, option,
+                                       options = elem.options,
+                                       values = jQuery.makeArray( value ),
+                                       i = options.length;
+
+                               while ( i-- ) {
+                                       option = options[ i ];
+
+                                       if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
+
+                                               // Support: IE6
+                                               // When new option element is added to select box we need to
+                                               // force reflow of newly added node in order to workaround delay
+                                               // of initialization properties
+                                               try {
+                                                       option.selected = optionSet = true;
+
+                                               } catch ( _ ) {
+
+                                                       // Will be executed only in IE6
+                                                       option.scrollHeight;
+                                               }
+
+                                       } else {
+                                               option.selected = false;
+                                       }
+                               }
+
+                               // Force browsers to behave consistently when non-matching value is set
+                               if ( !optionSet ) {
+                                       elem.selectedIndex = -1;
+                               }
+
+                               return options;
+                       }
+               }
+       }
+});
+
+// Radios and checkboxes getter/setter
+jQuery.each([ "radio", "checkbox" ], function() {
+       jQuery.valHooks[ this ] = {
+               set: function( elem, value ) {
+                       if ( jQuery.isArray( value ) ) {
+                               return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
+                       }
+               }
+       };
+       if ( !support.checkOn ) {
+               jQuery.valHooks[ this ].get = function( elem ) {
+                       // Support: Webkit
+                       // "" is returned instead of "on" if a value isn't specified
+                       return elem.getAttribute("value") === null ? "on" : elem.value;
+               };
+       }
+});
+
+
+
+
+var nodeHook, boolHook,
+       attrHandle = jQuery.expr.attrHandle,
+       ruseDefault = /^(?:checked|selected)$/i,
+       getSetAttribute = support.getSetAttribute,
+       getSetInput = support.input;
+
+jQuery.fn.extend({
+       attr: function( name, value ) {
+               return access( this, jQuery.attr, name, value, arguments.length > 1 );
+       },
+
+       removeAttr: function( name ) {
+               return this.each(function() {
+                       jQuery.removeAttr( this, name );
+               });
+       }
+});
+
+jQuery.extend({
+       attr: function( elem, name, value ) {
+               var hooks, ret,
+                       nType = elem.nodeType;
+
+               // don't get/set attributes on text, comment and attribute nodes
+               if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+                       return;
+               }
+
+               // Fallback to prop when attributes are not supported
+               if ( typeof elem.getAttribute === strundefined ) {
+                       return jQuery.prop( elem, name, value );
+               }
+
+               // All attributes are lowercase
+               // Grab necessary hook if one is defined
+               if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
+                       name = name.toLowerCase();
+                       hooks = jQuery.attrHooks[ name ] ||
+                               ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
+               }
+
+               if ( value !== undefined ) {
+
+                       if ( value === null ) {
+                               jQuery.removeAttr( elem, name );
+
+                       } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
+                               return ret;
+
+                       } else {
+                               elem.setAttribute( name, value + "" );
+                               return value;
+                       }
+
+               } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
+                       return ret;
+
+               } else {
+                       ret = jQuery.find.attr( elem, name );
+
+                       // Non-existent attributes return null, we normalize to undefined
+                       return ret == null ?
+                               undefined :
+                               ret;
+               }
+       },
+
+       removeAttr: function( elem, value ) {
+               var name, propName,
+                       i = 0,
+                       attrNames = value && value.match( rnotwhite );
+
+               if ( attrNames && elem.nodeType === 1 ) {
+                       while ( (name = attrNames[i++]) ) {
+                               propName = jQuery.propFix[ name ] || name;
+
+                               // Boolean attributes get special treatment (#10870)
+                               if ( jQuery.expr.match.bool.test( name ) ) {
+                                       // Set corresponding property to false
+                                       if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
+                                               elem[ propName ] = false;
+                                       // Support: IE<9
+                                       // Also clear defaultChecked/defaultSelected (if appropriate)
+                                       } else {
+                                               elem[ jQuery.camelCase( "default-" + name ) ] =
+                                                       elem[ propName ] = false;
+                                       }
+
+                               // See #9699 for explanation of this approach (setting first, then removal)
+                               } else {
+                                       jQuery.attr( elem, name, "" );
+                               }
+
+                               elem.removeAttribute( getSetAttribute ? name : propName );
+                       }
+               }
+       },
+
+       attrHooks: {
+               type: {
+                       set: function( elem, value ) {
+                               if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
+                                       // Setting the type on a radio button after the value resets the value in IE6-9
+                                       // Reset value to default in case type is set after value during creation
+                                       var val = elem.value;
+                                       elem.setAttribute( "type", value );
+                                       if ( val ) {
+                                               elem.value = val;
+                                       }
+                                       return value;
+                               }
+                       }
+               }
+       }
+});
+
+// Hook for boolean attributes
+boolHook = {
+       set: function( elem, value, name ) {
+               if ( value === false ) {
+                       // Remove boolean attributes when set to false
+                       jQuery.removeAttr( elem, name );
+               } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
+                       // IE<8 needs the *property* name
+                       elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
+
+               // Use defaultChecked and defaultSelected for oldIE
+               } else {
+                       elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
+               }
+
+               return name;
+       }
+};
+
+// Retrieve booleans specially
+jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
+
+       var getter = attrHandle[ name ] || jQuery.find.attr;
+
+       attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
+               function( elem, name, isXML ) {
+                       var ret, handle;
+                       if ( !isXML ) {
+                               // Avoid an infinite loop by temporarily removing this function from the getter
+                               handle = attrHandle[ name ];
+                               attrHandle[ name ] = ret;
+                               ret = getter( elem, name, isXML ) != null ?
+                                       name.toLowerCase() :
+                                       null;
+                               attrHandle[ name ] = handle;
+                       }
+                       return ret;
+               } :
+               function( elem, name, isXML ) {
+                       if ( !isXML ) {
+                               return elem[ jQuery.camelCase( "default-" + name ) ] ?
+                                       name.toLowerCase() :
+                                       null;
+                       }
+               };
+});
+
+// fix oldIE attroperties
+if ( !getSetInput || !getSetAttribute ) {
+       jQuery.attrHooks.value = {
+               set: function( elem, value, name ) {
+                       if ( jQuery.nodeName( elem, "input" ) ) {
+                               // Does not return so that setAttribute is also used
+                               elem.defaultValue = value;
+                       } else {
+                               // Use nodeHook if defined (#1954); otherwise setAttribute is fine
+                               return nodeHook && nodeHook.set( elem, value, name );
+                       }
+               }
+       };
+}
+
+// IE6/7 do not support getting/setting some attributes with get/setAttribute
+if ( !getSetAttribute ) {
+
+       // Use this for any attribute in IE6/7
+       // This fixes almost every IE6/7 issue
+       nodeHook = {
+               set: function( elem, value, name ) {
+                       // Set the existing or create a new attribute node
+                       var ret = elem.getAttributeNode( name );
+                       if ( !ret ) {
+                               elem.setAttributeNode(
+                                       (ret = elem.ownerDocument.createAttribute( name ))
+                               );
+                       }
+
+                       ret.value = value += "";
+
+                       // Break association with cloned elements by also using setAttribute (#9646)
+                       if ( name === "value" || value === elem.getAttribute( name ) ) {
+                               return value;
+                       }
+               }
+       };
+
+       // Some attributes are constructed with empty-string values when not defined
+       attrHandle.id = attrHandle.name = attrHandle.coords =
+               function( elem, name, isXML ) {
+                       var ret;
+                       if ( !isXML ) {
+                               return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
+                                       ret.value :
+                                       null;
+                       }
+               };
+
+       // Fixing value retrieval on a button requires this module
+       jQuery.valHooks.button = {
+               get: function( elem, name ) {
+                       var ret = elem.getAttributeNode( name );
+                       if ( ret && ret.specified ) {
+                               return ret.value;
+                       }
+               },
+               set: nodeHook.set
+       };
+
+       // Set contenteditable to false on removals(#10429)
+       // Setting to empty string throws an error as an invalid value
+       jQuery.attrHooks.contenteditable = {
+               set: function( elem, value, name ) {
+                       nodeHook.set( elem, value === "" ? false : value, name );
+               }
+       };
+
+       // Set width and height to auto instead of 0 on empty string( Bug #8150 )
+       // This is for removals
+       jQuery.each([ "width", "height" ], function( i, name ) {
+               jQuery.attrHooks[ name ] = {
+                       set: function( elem, value ) {
+                               if ( value === "" ) {
+                                       elem.setAttribute( name, "auto" );
+                                       return value;
+                               }
+                       }
+               };
+       });
+}
+
+if ( !support.style ) {
+       jQuery.attrHooks.style = {
+               get: function( elem ) {
+                       // Return undefined in the case of empty string
+                       // Note: IE uppercases css property names, but if we were to .toLowerCase()
+                       // .cssText, that would destroy case senstitivity in URL's, like in "background"
+                       return elem.style.cssText || undefined;
+               },
+               set: function( elem, value ) {
+                       return ( elem.style.cssText = value + "" );
+               }
+       };
+}
+
+
+
+
+var rfocusable = /^(?:input|select|textarea|button|object)$/i,
+       rclickable = /^(?:a|area)$/i;
+
+jQuery.fn.extend({
+       prop: function( name, value ) {
+               return access( this, jQuery.prop, name, value, arguments.length > 1 );
+       },
+
+       removeProp: function( name ) {
+               name = jQuery.propFix[ name ] || name;
+               return this.each(function() {
+                       // try/catch handles cases where IE balks (such as removing a property on window)
+                       try {
+                               this[ name ] = undefined;
+                               delete this[ name ];
+                       } catch( e ) {}
+               });
+       }
+});
+
+jQuery.extend({
+       propFix: {
+               "for": "htmlFor",
+               "class": "className"
+       },
+
+       prop: function( elem, name, value ) {
+               var ret, hooks, notxml,
+                       nType = elem.nodeType;
+
+               // don't get/set properties on text, comment and attribute nodes
+               if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+                       return;
+               }
+
+               notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+               if ( notxml ) {
+                       // Fix name and attach hooks
+                       name = jQuery.propFix[ name ] || name;
+                       hooks = jQuery.propHooks[ name ];
+               }
+
+               if ( value !== undefined ) {
+                       return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
+                               ret :
+                               ( elem[ name ] = value );
+
+               } else {
+                       return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
+                               ret :
+                               elem[ name ];
+               }
+       },
+
+       propHooks: {
+               tabIndex: {
+                       get: function( elem ) {
+                               // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+                               // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+                               // Use proper attribute retrieval(#12072)
+                               var tabindex = jQuery.find.attr( elem, "tabindex" );
+
+                               return tabindex ?
+                                       parseInt( tabindex, 10 ) :
+                                       rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+                                               0 :
+                                               -1;
+                       }
+               }
+       }
+});
+
+// Some attributes require a special call on IE
+// http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
+if ( !support.hrefNormalized ) {
+       // href/src property should get the full normalized URL (#10299/#12915)
+       jQuery.each([ "href", "src" ], function( i, name ) {
+               jQuery.propHooks[ name ] = {
+                       get: function( elem ) {
+                               return elem.getAttribute( name, 4 );
+                       }
+               };
+       });
+}
+
+// Support: Safari, IE9+
+// mis-reports the default selected property of an option
+// Accessing the parent's selectedIndex property fixes it
+if ( !support.optSelected ) {
+       jQuery.propHooks.selected = {
+               get: function( elem ) {
+                       var parent = elem.parentNode;
+
+                       if ( parent ) {
+                               parent.selectedIndex;
+
+                               // Make sure that it also works with optgroups, see #5701
+                               if ( parent.parentNode ) {
+                                       parent.parentNode.selectedIndex;
+                               }
+                       }
+                       return null;
+               }
+       };
+}
+
+jQuery.each([
+       "tabIndex",
+       "readOnly",
+       "maxLength",
+       "cellSpacing",
+       "cellPadding",
+       "rowSpan",
+       "colSpan",
+       "useMap",
+       "frameBorder",
+       "contentEditable"
+], function() {
+       jQuery.propFix[ this.toLowerCase() ] = this;
+});
+
+// IE6/7 call enctype encoding
+if ( !support.enctype ) {
+       jQuery.propFix.enctype = "encoding";
+}
+
+
+
+
+var rclass = /[\t\r\n\f]/g;
+
+jQuery.fn.extend({
+       addClass: function( value ) {
+               var classes, elem, cur, clazz, j, finalValue,
+                       i = 0,
+                       len = this.length,
+                       proceed = typeof value === "string" && value;
+
+               if ( jQuery.isFunction( value ) ) {
+                       return this.each(function( j ) {
+                               jQuery( this ).addClass( value.call( this, j, this.className ) );
+                       });
+               }
+
+               if ( proceed ) {
+                       // The disjunction here is for better compressibility (see removeClass)
+                       classes = ( value || "" ).match( rnotwhite ) || [];
+
+                       for ( ; i < len; i++ ) {
+                               elem = this[ i ];
+                               cur = elem.nodeType === 1 && ( elem.className ?
+                                       ( " " + elem.className + " " ).replace( rclass, " " ) :
+                                       " "
+                               );
+
+                               if ( cur ) {
+                                       j = 0;
+                                       while ( (clazz = classes[j++]) ) {
+                                               if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
+                                                       cur += clazz + " ";
+                                               }
+                                       }
+
+                                       // only assign if different to avoid unneeded rendering.
+                                       finalValue = jQuery.trim( cur );
+                                       if ( elem.className !== finalValue ) {
+                                               elem.className = finalValue;
+                                       }
+                               }
+                       }
+               }
+
+               return this;
+       },
+
+       removeClass: function( value ) {
+               var classes, elem, cur, clazz, j, finalValue,
+                       i = 0,
+                       len = this.length,
+                       proceed = arguments.length === 0 || typeof value === "string" && value;
+
+               if ( jQuery.isFunction( value ) ) {
+                       return this.each(function( j ) {
+                               jQuery( this ).removeClass( value.call( this, j, this.className ) );
+                       });
+               }
+               if ( proceed ) {
+                       classes = ( value || "" ).match( rnotwhite ) || [];
+
+                       for ( ; i < len; i++ ) {
+                               elem = this[ i ];
+                               // This expression is here for better compressibility (see addClass)
+                               cur = elem.nodeType === 1 && ( elem.className ?
+                                       ( " " + elem.className + " " ).replace( rclass, " " ) :
+                                       ""
+                               );
+
+                               if ( cur ) {
+                                       j = 0;
+                                       while ( (clazz = classes[j++]) ) {
+                                               // Remove *all* instances
+                                               while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
+                                                       cur = cur.replace( " " + clazz + " ", " " );
+                                               }
+                                       }
+
+                                       // only assign if different to avoid unneeded rendering.
+                                       finalValue = value ? jQuery.trim( cur ) : "";
+                                       if ( elem.className !== finalValue ) {
+                                               elem.className = finalValue;
+                                       }
+                               }
+                       }
+               }
+
+               return this;
+       },
+
+       toggleClass: function( value, stateVal ) {
+               var type = typeof value;
+
+               if ( typeof stateVal === "boolean" && type === "string" ) {
+                       return stateVal ? this.addClass( value ) : this.removeClass( value );
+               }
+
+               if ( jQuery.isFunction( value ) ) {
+                       return this.each(function( i ) {
+                               jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
+                       });
+               }
+
+               return this.each(function() {
+                       if ( type === "string" ) {
+                               // toggle individual class names
+                               var className,
+                                       i = 0,
+                                       self = jQuery( this ),
+                                       classNames = value.match( rnotwhite ) || [];
+
+                               while ( (className = classNames[ i++ ]) ) {
+                                       // check each className given, space separated list
+                                       if ( self.hasClass( className ) ) {
+                                               self.removeClass( className );
+                                       } else {
+                                               self.addClass( className );
+                                       }
+                               }
+
+                       // Toggle whole class name
+                       } else if ( type === strundefined || type === "boolean" ) {
+                               if ( this.className ) {
+                                       // store className if set
+                                       jQuery._data( this, "__className__", this.className );
+                               }
+
+                               // If the element has a class name or if we're passed "false",
+                               // then remove the whole classname (if there was one, the above saved it).
+                               // Otherwise bring back whatever was previously saved (if anything),
+                               // falling back to the empty string if nothing was stored.
+                               this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
+                       }
+               });
+       },
+
+       hasClass: function( selector ) {
+               var className = " " + selector + " ",
+                       i = 0,
+                       l = this.length;
+               for ( ; i < l; i++ ) {
+                       if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
+                               return true;
+                       }
+               }
+
+               return false;
+       }
+});
+
+
+
+
+// Return jQuery for attributes-only inclusion
+
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+       "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+       "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
+
+       // Handle event binding
+       jQuery.fn[ name ] = function( data, fn ) {
+               return arguments.length > 0 ?
+                       this.on( name, null, data, fn ) :
+                       this.trigger( name );
+       };
+});
+
+jQuery.fn.extend({
+       hover: function( fnOver, fnOut ) {
+               return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+       },
+
+       bind: function( types, data, fn ) {
+               return this.on( types, null, data, fn );
+       },
+       unbind: function( types, fn ) {
+               return this.off( types, null, fn );
+       },
+
+       delegate: function( selector, types, data, fn ) {
+               return this.on( types, selector, data, fn );
+       },
+       undelegate: function( selector, types, fn ) {
+               // ( namespace ) or ( selector, types [, fn] )
+               return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
+       }
+});
+
+
+var nonce = jQuery.now();
+
+var rquery = (/\?/);
+
+
+
+var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
+
+jQuery.parseJSON = function( data ) {
+       // Attempt to parse using the native JSON parser first
+       if ( window.JSON && window.JSON.parse ) {
+               // Support: Android 2.3
+               // Workaround failure to string-cast null input
+               return window.JSON.parse( data + "" );
+       }
+
+       var requireNonComma,
+               depth = null,
+               str = jQuery.trim( data + "" );
+
+       // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
+       // after removing valid tokens
+       return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
+
+               // Force termination if we see a misplaced comma
+               if ( requireNonComma && comma ) {
+                       depth = 0;
+               }
+
+               // Perform no more replacements after returning to outermost depth
+               if ( depth === 0 ) {
+                       return token;
+               }
+
+               // Commas must not follow "[", "{", or ","
+               requireNonComma = open || comma;
+
+               // Determine new depth
+               // array/object open ("[" or "{"): depth += true - false (increment)
+               // array/object close ("]" or "}"): depth += false - true (decrement)
+               // other cases ("," or primitive): depth += true - true (numeric cast)
+               depth += !close - !open;
+
+               // Remove this token
+               return "";
+       }) ) ?
+               ( Function( "return " + str ) )() :
+               jQuery.error( "Invalid JSON: " + data );
+};
+
+
+// Cross-browser xml parsing
+jQuery.parseXML = function( data ) {
+       var xml, tmp;
+       if ( !data || typeof data !== "string" ) {
+               return null;
+       }
+       try {
+               if ( window.DOMParser ) { // Standard
+                       tmp = new DOMParser();
+                       xml = tmp.parseFromString( data, "text/xml" );
+               } else { // IE
+                       xml = new ActiveXObject( "Microsoft.XMLDOM" );
+                       xml.async = "false";
+                       xml.loadXML( data );
+               }
+       } catch( e ) {
+               xml = undefined;
+       }
+       if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
+               jQuery.error( "Invalid XML: " + data );
+       }
+       return xml;
+};
+
+
+var
+       // Document location
+       ajaxLocParts,
+       ajaxLocation,
+
+       rhash = /#.*$/,
+       rts = /([?&])_=[^&]*/,
+       rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
+       // #7653, #8125, #8152: local protocol detection
+       rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
+       rnoContent = /^(?:GET|HEAD)$/,
+       rprotocol = /^\/\//,
+       rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
+
+       /* Prefilters
+        * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
+        * 2) These are called:
+        *    - BEFORE asking for a transport
+        *    - AFTER param serialization (s.data is a string if s.processData is true)
+        * 3) key is the dataType
+        * 4) the catchall symbol "*" can be used
+        * 5) execution will start with transport dataType and THEN continue down to "*" if needed
+        */
+       prefilters = {},
+
+       /* Transports bindings
+        * 1) key is the dataType
+        * 2) the catchall symbol "*" can be used
+        * 3) selection will start with transport dataType and THEN go to "*" if needed
+        */
+       transports = {},
+
+       // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
+       allTypes = "*/".concat("*");
+
+// #8138, IE may throw an exception when accessing
+// a field from window.location if document.domain has been set
+try {
+       ajaxLocation = location.href;
+} catch( e ) {
+       // Use the href attribute of an A element
+       // since IE will modify it given document.location
+       ajaxLocation = document.createElement( "a" );
+       ajaxLocation.href = "";
+       ajaxLocation = ajaxLocation.href;
+}
+
+// Segment location into parts
+ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
+
+// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
+function addToPrefiltersOrTransports( structure ) {
+
+       // dataTypeExpression is optional and defaults to "*"
+       return function( dataTypeExpression, func ) {
+
+               if ( typeof dataTypeExpression !== "string" ) {
+                       func = dataTypeExpression;
+                       dataTypeExpression = "*";
+               }
+
+               var dataType,
+                       i = 0,
+                       dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
+
+               if ( jQuery.isFunction( func ) ) {
+                       // For each dataType in the dataTypeExpression
+                       while ( (dataType = dataTypes[i++]) ) {
+                               // Prepend if requested
+                               if ( dataType.charAt( 0 ) === "+" ) {
+                                       dataType = dataType.slice( 1 ) || "*";
+                                       (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
+
+                               // Otherwise append
+                               } else {
+                                       (structure[ dataType ] = structure[ dataType ] || []).push( func );
+                               }
+                       }
+               }
+       };
+}
+
+// Base inspection function for prefilters and transports
+function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
+
+       var inspected = {},
+               seekingTransport = ( structure === transports );
+
+       function inspect( dataType ) {
+               var selected;
+               inspected[ dataType ] = true;
+               jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
+                       var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
+                       if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
+                               options.dataTypes.unshift( dataTypeOrTransport );
+                               inspect( dataTypeOrTransport );
+                               return false;
+                       } else if ( seekingTransport ) {
+                               return !( selected = dataTypeOrTransport );
+                       }
+               });
+               return selected;
+       }
+
+       return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
+}
+
+// A special extend for ajax options
+// that takes "flat" options (not to be deep extended)
+// Fixes #9887
+function ajaxExtend( target, src ) {
+       var deep, key,
+               flatOptions = jQuery.ajaxSettings.flatOptions || {};
+
+       for ( key in src ) {
+               if ( src[ key ] !== undefined ) {
+                       ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
+               }
+       }
+       if ( deep ) {
+               jQuery.extend( true, target, deep );
+       }
+
+       return target;
+}
+
+/* Handles responses to an ajax request:
+ * - finds the right dataType (mediates between content-type and expected dataType)
+ * - returns the corresponding response
+ */
+function ajaxHandleResponses( s, jqXHR, responses ) {
+       var firstDataType, ct, finalDataType, type,
+               contents = s.contents,
+               dataTypes = s.dataTypes;
+
+       // Remove auto dataType and get content-type in the process
+       while ( dataTypes[ 0 ] === "*" ) {
+               dataTypes.shift();
+               if ( ct === undefined ) {
+                       ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
+               }
+       }
+
+       // Check if we're dealing with a known content-type
+       if ( ct ) {
+               for ( type in contents ) {
+                       if ( contents[ type ] && contents[ type ].test( ct ) ) {
+                               dataTypes.unshift( type );
+                               break;
+                       }
+               }
+       }
+
+       // Check to see if we have a response for the expected dataType
+       if ( dataTypes[ 0 ] in responses ) {
+               finalDataType = dataTypes[ 0 ];
+       } else {
+               // Try convertible dataTypes
+               for ( type in responses ) {
+                       if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
+                               finalDataType = type;
+                               break;
+                       }
+                       if ( !firstDataType ) {
+                               firstDataType = type;
+                       }
+               }
+               // Or just use first one
+               finalDataType = finalDataType || firstDataType;
+       }
+
+       // If we found a dataType
+       // We add the dataType to the list if needed
+       // and return the corresponding response
+       if ( finalDataType ) {
+               if ( finalDataType !== dataTypes[ 0 ] ) {
+                       dataTypes.unshift( finalDataType );
+               }
+               return responses[ finalDataType ];
+       }
+}
+
+/* Chain conversions given the request and the original response
+ * Also sets the responseXXX fields on the jqXHR instance
+ */
+function ajaxConvert( s, response, jqXHR, isSuccess ) {
+       var conv2, current, conv, tmp, prev,
+               converters = {},
+               // Work with a copy of dataTypes in case we need to modify it for conversion
+               dataTypes = s.dataTypes.slice();
+
+       // Create converters map with lowercased keys
+       if ( dataTypes[ 1 ] ) {
+               for ( conv in s.converters ) {
+                       converters[ conv.toLowerCase() ] = s.converters[ conv ];
+               }
+       }
+
+       current = dataTypes.shift();
+
+       // Convert to each sequential dataType
+       while ( current ) {
+
+               if ( s.responseFields[ current ] ) {
+                       jqXHR[ s.responseFields[ current ] ] = response;
+               }
+
+               // Apply the dataFilter if provided
+               if ( !prev && isSuccess && s.dataFilter ) {
+                       response = s.dataFilter( response, s.dataType );
+               }
+
+               prev = current;
+               current = dataTypes.shift();
+
+               if ( current ) {
+
+                       // There's only work to do if current dataType is non-auto
+                       if ( current === "*" ) {
+
+                               current = prev;
+
+                       // Convert response if prev dataType is non-auto and differs from current
+                       } else if ( prev !== "*" && prev !== current ) {
+
+                               // Seek a direct converter
+                               conv = converters[ prev + " " + current ] || converters[ "* " + current ];
+
+                               // If none found, seek a pair
+                               if ( !conv ) {
+                                       for ( conv2 in converters ) {
+
+                                               // If conv2 outputs current
+                                               tmp = conv2.split( " " );
+                                               if ( tmp[ 1 ] === current ) {
+
+                                                       // If prev can be converted to accepted input
+                                                       conv = converters[ prev + " " + tmp[ 0 ] ] ||
+                                                               converters[ "* " + tmp[ 0 ] ];
+                                                       if ( conv ) {
+                                                               // Condense equivalence converters
+                                                               if ( conv === true ) {
+                                                                       conv = converters[ conv2 ];
+
+                                                               // Otherwise, insert the intermediate dataType
+                                                               } else if ( converters[ conv2 ] !== true ) {
+                                                                       current = tmp[ 0 ];
+                                                                       dataTypes.unshift( tmp[ 1 ] );
+                                                               }
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                               }
+
+                               // Apply converter (if not an equivalence)
+                               if ( conv !== true ) {
+
+                                       // Unless errors are allowed to bubble, catch and return them
+                                       if ( conv && s[ "throws" ] ) {
+                                               response = conv( response );
+                                       } else {
+                                               try {
+                                                       response = conv( response );
+                                               } catch ( e ) {
+                                                       return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+
+       return { state: "success", data: response };
+}
+
+jQuery.extend({
+
+       // Counter for holding the number of active queries
+       active: 0,
+
+       // Last-Modified header cache for next request
+       lastModified: {},
+       etag: {},
+
+       ajaxSettings: {
+               url: ajaxLocation,
+               type: "GET",
+               isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
+               global: true,
+               processData: true,
+               async: true,
+               contentType: "application/x-www-form-urlencoded; charset=UTF-8",
+               /*
+               timeout: 0,
+               data: null,
+               dataType: null,
+               username: null,
+               password: null,
+               cache: null,
+               throws: false,
+               traditional: false,
+               headers: {},
+               */
+
+               accepts: {
+                       "*": allTypes,
+                       text: "text/plain",
+                       html: "text/html",
+                       xml: "application/xml, text/xml",
+                       json: "application/json, text/javascript"
+               },
+
+               contents: {
+                       xml: /xml/,
+                       html: /html/,
+                       json: /json/
+               },
+
+               responseFields: {
+                       xml: "responseXML",
+                       text: "responseText",
+                       json: "responseJSON"
+               },
+
+               // Data converters
+               // Keys separate source (or catchall "*") and destination types with a single space
+               converters: {
+
+                       // Convert anything to text
+                       "* text": String,
+
+                       // Text to html (true = no transformation)
+                       "text html": true,
+
+                       // Evaluate text as a json expression
+                       "text json": jQuery.parseJSON,
+
+                       // Parse text as xml
+                       "text xml": jQuery.parseXML
+               },
+
+               // For options that shouldn't be deep extended:
+               // you can add your own custom options here if
+               // and when you create one that shouldn't be
+               // deep extended (see ajaxExtend)
+               flatOptions: {
+                       url: true,
+                       context: true
+               }
+       },
+
+       // Creates a full fledged settings object into target
+       // with both ajaxSettings and settings fields.
+       // If target is omitted, writes into ajaxSettings.
+       ajaxSetup: function( target, settings ) {
+               return settings ?
+
+                       // Building a settings object
+                       ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
+
+                       // Extending ajaxSettings
+                       ajaxExtend( jQuery.ajaxSettings, target );
+       },
+
+       ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
+       ajaxTransport: addToPrefiltersOrTransports( transports ),
+
+       // Main method
+       ajax: function( url, options ) {
+
+               // If url is an object, simulate pre-1.5 signature
+               if ( typeof url === "object" ) {
+                       options = url;
+                       url = undefined;
+               }
+
+               // Force options to be an object
+               options = options || {};
+
+               var // Cross-domain detection vars
+                       parts,
+                       // Loop variable
+                       i,
+                       // URL without anti-cache param
+                       cacheURL,
+                       // Response headers as string
+                       responseHeadersString,
+                       // timeout handle
+                       timeoutTimer,
+
+                       // To know if global events are to be dispatched
+                       fireGlobals,
+
+                       transport,
+                       // Response headers
+                       responseHeaders,
+                       // Create the final options object
+                       s = jQuery.ajaxSetup( {}, options ),
+                       // Callbacks context
+                       callbackContext = s.context || s,
+                       // Context for global events is callbackContext if it is a DOM node or jQuery collection
+                       globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
+                               jQuery( callbackContext ) :
+                               jQuery.event,
+                       // Deferreds
+                       deferred = jQuery.Deferred(),
+                       completeDeferred = jQuery.Callbacks("once memory"),
+                       // Status-dependent callbacks
+                       statusCode = s.statusCode || {},
+                       // Headers (they are sent all at once)
+                       requestHeaders = {},
+                       requestHeadersNames = {},
+                       // The jqXHR state
+                       state = 0,
+                       // Default abort message
+                       strAbort = "canceled",
+                       // Fake xhr
+                       jqXHR = {
+                               readyState: 0,
+
+                               // Builds headers hashtable if needed
+                               getResponseHeader: function( key ) {
+                                       var match;
+                                       if ( state === 2 ) {
+                                               if ( !responseHeaders ) {
+                                                       responseHeaders = {};
+                                                       while ( (match = rheaders.exec( responseHeadersString )) ) {
+                                                               responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
+                                                       }
+                                               }
+                                               match = responseHeaders[ key.toLowerCase() ];
+                                       }
+                                       return match == null ? null : match;
+                               },
+
+                               // Raw string
+                               getAllResponseHeaders: function() {
+                                       return state === 2 ? responseHeadersString : null;
+                               },
+
+                               // Caches the header
+                               setRequestHeader: function( name, value ) {
+                                       var lname = name.toLowerCase();
+                                       if ( !state ) {
+                                               name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
+                                               requestHeaders[ name ] = value;
+                                       }
+                                       return this;
+                               },
+
+                               // Overrides response content-type header
+                               overrideMimeType: function( type ) {
+                                       if ( !state ) {
+                                               s.mimeType = type;
+                                       }
+                                       return this;
+                               },
+
+                               // Status-dependent callbacks
+                               statusCode: function( map ) {
+                                       var code;
+                                       if ( map ) {
+                                               if ( state < 2 ) {
+                                                       for ( code in map ) {
+                                                               // Lazy-add the new callback in a way that preserves old ones
+                                                               statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
+                                                       }
+                                               } else {
+                                                       // Execute the appropriate callbacks
+                                                       jqXHR.always( map[ jqXHR.status ] );
+                                               }
+                                       }
+                                       return this;
+                               },
+
+                               // Cancel the request
+                               abort: function( statusText ) {
+                                       var finalText = statusText || strAbort;
+                                       if ( transport ) {
+                                               transport.abort( finalText );
+                                       }
+                                       done( 0, finalText );
+                                       return this;
+                               }
+                       };
+
+               // Attach deferreds
+               deferred.promise( jqXHR ).complete = completeDeferred.add;
+               jqXHR.success = jqXHR.done;
+               jqXHR.error = jqXHR.fail;
+
+               // Remove hash character (#7531: and string promotion)
+               // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
+               // Handle falsy url in the settings object (#10093: consistency with old signature)
+               // We also use the url parameter if available
+               s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
+
+               // Alias method option to type as per ticket #12004
+               s.type = options.method || options.type || s.method || s.type;
+
+               // Extract dataTypes list
+               s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
+
+               // A cross-domain request is in order when we have a protocol:host:port mismatch
+               if ( s.crossDomain == null ) {
+                       parts = rurl.exec( s.url.toLowerCase() );
+                       s.crossDomain = !!( parts &&
+                               ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
+                                       ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
+                                               ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
+                       );
+               }
+
+               // Convert data if not already a string
+               if ( s.data && s.processData && typeof s.data !== "string" ) {
+                       s.data = jQuery.param( s.data, s.traditional );
+               }
+
+               // Apply prefilters
+               inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
+
+               // If request was aborted inside a prefilter, stop there
+               if ( state === 2 ) {
+                       return jqXHR;
+               }
+
+               // We can fire global events as of now if asked to
+               fireGlobals = s.global;
+
+               // Watch for a new set of requests
+               if ( fireGlobals && jQuery.active++ === 0 ) {
+                       jQuery.event.trigger("ajaxStart");
+               }
+
+               // Uppercase the type
+               s.type = s.type.toUpperCase();
+
+               // Determine if request has content
+               s.hasContent = !rnoContent.test( s.type );
+
+               // Save the URL in case we're toying with the If-Modified-Since
+               // and/or If-None-Match header later on
+               cacheURL = s.url;
+
+               // More options handling for requests with no content
+               if ( !s.hasContent ) {
+
+                       // If data is available, append data to url
+                       if ( s.data ) {
+                               cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
+                               // #9682: remove data so that it's not used in an eventual retry
+                               delete s.data;
+                       }
+
+                       // Add anti-cache in url if needed
+                       if ( s.cache === false ) {
+                               s.url = rts.test( cacheURL ) ?
+
+                                       // If there is already a '_' parameter, set its value
+                                       cacheURL.replace( rts, "$1_=" + nonce++ ) :
+
+                                       // Otherwise add one to the end
+                                       cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
+                       }
+               }
+
+               // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+               if ( s.ifModified ) {
+                       if ( jQuery.lastModified[ cacheURL ] ) {
+                               jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
+                       }
+                       if ( jQuery.etag[ cacheURL ] ) {
+                               jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
+                       }
+               }
+
+               // Set the correct header, if data is being sent
+               if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
+                       jqXHR.setRequestHeader( "Content-Type", s.contentType );
+               }
+
+               // Set the Accepts header for the server, depending on the dataType
+               jqXHR.setRequestHeader(
+                       "Accept",
+                       s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
+                               s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
+                               s.accepts[ "*" ]
+               );
+
+               // Check for headers option
+               for ( i in s.headers ) {
+                       jqXHR.setRequestHeader( i, s.headers[ i ] );
+               }
+
+               // Allow custom headers/mimetypes and early abort
+               if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
+                       // Abort if not done already and return
+                       return jqXHR.abort();
+               }
+
+               // aborting is no longer a cancellation
+               strAbort = "abort";
+
+               // Install callbacks on deferreds
+               for ( i in { success: 1, error: 1, complete: 1 } ) {
+                       jqXHR[ i ]( s[ i ] );
+               }
+
+               // Get transport
+               transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
+
+               // If no transport, we auto-abort
+               if ( !transport ) {
+                       done( -1, "No Transport" );
+               } else {
+                       jqXHR.readyState = 1;
+
+                       // Send global event
+                       if ( fireGlobals ) {
+                               globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
+                       }
+                       // Timeout
+                       if ( s.async && s.timeout > 0 ) {
+                               timeoutTimer = setTimeout(function() {
+                                       jqXHR.abort("timeout");
+                               }, s.timeout );
+                       }
+
+                       try {
+                               state = 1;
+                               transport.send( requestHeaders, done );
+                       } catch ( e ) {
+                               // Propagate exception as error if not done
+                               if ( state < 2 ) {
+                                       done( -1, e );
+                               // Simply rethrow otherwise
+                               } else {
+                                       throw e;
+                               }
+                       }
+               }
+
+               // Callback for when everything is done
+               function done( status, nativeStatusText, responses, headers ) {
+                       var isSuccess, success, error, response, modified,
+                               statusText = nativeStatusText;
+
+                       // Called once
+                       if ( state === 2 ) {
+                               return;
+                       }
+
+                       // State is "done" now
+                       state = 2;
+
+                       // Clear timeout if it exists
+                       if ( timeoutTimer ) {
+                               clearTimeout( timeoutTimer );
+                       }
+
+                       // Dereference transport for early garbage collection
+                       // (no matter how long the jqXHR object will be used)
+                       transport = undefined;
+
+                       // Cache response headers
+                       responseHeadersString = headers || "";
+
+                       // Set readyState
+                       jqXHR.readyState = status > 0 ? 4 : 0;
+
+                       // Determine if successful
+                       isSuccess = status >= 200 && status < 300 || status === 304;
+
+                       // Get response data
+                       if ( responses ) {
+                               response = ajaxHandleResponses( s, jqXHR, responses );
+                       }
+
+                       // Convert no matter what (that way responseXXX fields are always set)
+                       response = ajaxConvert( s, response, jqXHR, isSuccess );
+
+                       // If successful, handle type chaining
+                       if ( isSuccess ) {
+
+                               // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
+                               if ( s.ifModified ) {
+                                       modified = jqXHR.getResponseHeader("Last-Modified");
+                                       if ( modified ) {
+                                               jQuery.lastModified[ cacheURL ] = modified;
+                                       }
+                                       modified = jqXHR.getResponseHeader("etag");
+                                       if ( modified ) {
+                                               jQuery.etag[ cacheURL ] = modified;
+                                       }
+                               }
+
+                               // if no content
+                               if ( status === 204 || s.type === "HEAD" ) {
+                                       statusText = "nocontent";
+
+                               // if not modified
+                               } else if ( status === 304 ) {
+                                       statusText = "notmodified";
+
+                               // If we have data, let's convert it
+                               } else {
+                                       statusText = response.state;
+                                       success = response.data;
+                                       error = response.error;
+                                       isSuccess = !error;
+                               }
+                       } else {
+                               // We extract error from statusText
+                               // then normalize statusText and status for non-aborts
+                               error = statusText;
+                               if ( status || !statusText ) {
+                                       statusText = "error";
+                                       if ( status < 0 ) {
+                                               status = 0;
+                                       }
+                               }
+                       }
+
+                       // Set data for the fake xhr object
+                       jqXHR.status = status;
+                       jqXHR.statusText = ( nativeStatusText || statusText ) + "";
+
+                       // Success/Error
+                       if ( isSuccess ) {
+                               deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
+                       } else {
+                               deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
+                       }
+
+                       // Status-dependent callbacks
+                       jqXHR.statusCode( statusCode );
+                       statusCode = undefined;
+
+                       if ( fireGlobals ) {
+                               globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
+                                       [ jqXHR, s, isSuccess ? success : error ] );
+                       }
+
+                       // Complete
+                       completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
+
+                       if ( fireGlobals ) {
+                               globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
+                               // Handle the global AJAX counter
+                               if ( !( --jQuery.active ) ) {
+                                       jQuery.event.trigger("ajaxStop");
+                               }
+                       }
+               }
+
+               return jqXHR;
+       },
+
+       getJSON: function( url, data, callback ) {
+               return jQuery.get( url, data, callback, "json" );
+       },
+
+       getScript: function( url, callback ) {
+               return jQuery.get( url, undefined, callback, "script" );
+       }
+});
+
+jQuery.each( [ "get", "post" ], function( i, method ) {
+       jQuery[ method ] = function( url, data, callback, type ) {
+               // shift arguments if data argument was omitted
+               if ( jQuery.isFunction( data ) ) {
+                       type = type || callback;
+                       callback = data;
+                       data = undefined;
+               }
+
+               return jQuery.ajax({
+                       url: url,
+                       type: method,
+                       dataType: type,
+                       data: data,
+                       success: callback
+               });
+       };
+});
+
+// Attach a bunch of functions for handling common AJAX events
+jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
+       jQuery.fn[ type ] = function( fn ) {
+               return this.on( type, fn );
+       };
+});
+
+
+jQuery._evalUrl = function( url ) {
+       return jQuery.ajax({
+               url: url,
+               type: "GET",
+               dataType: "script",
+               async: false,
+               global: false,
+               "throws": true
+       });
+};
+
+
+jQuery.fn.extend({
+       wrapAll: function( html ) {
+               if ( jQuery.isFunction( html ) ) {
+                       return this.each(function(i) {
+                               jQuery(this).wrapAll( html.call(this, i) );
+                       });
+               }
+
+               if ( this[0] ) {
+                       // The elements to wrap the target around
+                       var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
+
+                       if ( this[0].parentNode ) {
+                               wrap.insertBefore( this[0] );
+                       }
+
+                       wrap.map(function() {
+                               var elem = this;
+
+                               while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
+                                       elem = elem.firstChild;
+                               }
+
+                               return elem;
+                       }).append( this );
+               }
+
+               return this;
+       },
+
+       wrapInner: function( html ) {
+               if ( jQuery.isFunction( html ) ) {
+                       return this.each(function(i) {
+                               jQuery(this).wrapInner( html.call(this, i) );
+                       });
+               }
+
+               return this.each(function() {
+                       var self = jQuery( this ),
+                               contents = self.contents();
+
+                       if ( contents.length ) {
+                               contents.wrapAll( html );
+
+                       } else {
+                               self.append( html );
+                       }
+               });
+       },
+
+       wrap: function( html ) {
+               var isFunction = jQuery.isFunction( html );
+
+               return this.each(function(i) {
+                       jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
+               });
+       },
+
+       unwrap: function() {
+               return this.parent().each(function() {
+                       if ( !jQuery.nodeName( this, "body" ) ) {
+                               jQuery( this ).replaceWith( this.childNodes );
+                       }
+               }).end();
+       }
+});
+
+
+jQuery.expr.filters.hidden = function( elem ) {
+       // Support: Opera <= 12.12
+       // Opera reports offsetWidths and offsetHeights less than zero on some elements
+       return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
+               (!support.reliableHiddenOffsets() &&
+                       ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
+};
+
+jQuery.expr.filters.visible = function( elem ) {
+       return !jQuery.expr.filters.hidden( elem );
+};
+
+
+
+
+var r20 = /%20/g,
+       rbracket = /\[\]$/,
+       rCRLF = /\r?\n/g,
+       rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
+       rsubmittable = /^(?:input|select|textarea|keygen)/i;
+
+function buildParams( prefix, obj, traditional, add ) {
+       var name;
+
+       if ( jQuery.isArray( obj ) ) {
+               // Serialize array item.
+               jQuery.each( obj, function( i, v ) {
+                       if ( traditional || rbracket.test( prefix ) ) {
+                               // Treat each array item as a scalar.
+                               add( prefix, v );
+
+                       } else {
+                               // Item is non-scalar (array or object), encode its numeric index.
+                               buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
+                       }
+               });
+
+       } else if ( !traditional && jQuery.type( obj ) === "object" ) {
+               // Serialize object item.
+               for ( name in obj ) {
+                       buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
+               }
+
+       } else {
+               // Serialize scalar item.
+               add( prefix, obj );
+       }
+}
+
+// Serialize an array of form elements or a set of
+// key/values into a query string
+jQuery.param = function( a, traditional ) {
+       var prefix,
+               s = [],
+               add = function( key, value ) {
+                       // If value is a function, invoke it and return its value
+                       value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
+                       s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
+               };
+
+       // Set traditional to true for jQuery <= 1.3.2 behavior.
+       if ( traditional === undefined ) {
+               traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
+       }
+
+       // If an array was passed in, assume that it is an array of form elements.
+       if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
+               // Serialize the form elements
+               jQuery.each( a, function() {
+                       add( this.name, this.value );
+               });
+
+       } else {
+               // If traditional, encode the "old" way (the way 1.3.2 or older
+               // did it), otherwise encode params recursively.
+               for ( prefix in a ) {
+                       buildParams( prefix, a[ prefix ], traditional, add );
+               }
+       }
+
+       // Return the resulting serialization
+       return s.join( "&" ).replace( r20, "+" );
+};
+
+jQuery.fn.extend({
+       serialize: function() {
+               return jQuery.param( this.serializeArray() );
+       },
+       serializeArray: function() {
+               return this.map(function() {
+                       // Can add propHook for "elements" to filter or add form elements
+                       var elements = jQuery.prop( this, "elements" );
+                       return elements ? jQuery.makeArray( elements ) : this;
+               })
+               .filter(function() {
+                       var type = this.type;
+                       // Use .is(":disabled") so that fieldset[disabled] works
+                       return this.name && !jQuery( this ).is( ":disabled" ) &&
+                               rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
+                               ( this.checked || !rcheckableType.test( type ) );
+               })
+               .map(function( i, elem ) {
+                       var val = jQuery( this ).val();
+
+                       return val == null ?
+                               null :
+                               jQuery.isArray( val ) ?
+                                       jQuery.map( val, function( val ) {
+                                               return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+                                       }) :
+                                       { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
+               }).get();
+       }
+});
+
+
+// Create the request object
+// (This is still attached to ajaxSettings for backward compatibility)
+jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
+       // Support: IE6+
+       function() {
+
+               // XHR cannot access local files, always use ActiveX for that case
+               return !this.isLocal &&
+
+                       // Support: IE7-8
+                       // oldIE XHR does not support non-RFC2616 methods (#13240)
+                       // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
+                       // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
+                       // Although this check for six methods instead of eight
+                       // since IE also does not support "trace" and "connect"
+                       /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
+
+                       createStandardXHR() || createActiveXHR();
+       } :
+       // For all other browsers, use the standard XMLHttpRequest object
+       createStandardXHR;
+
+var xhrId = 0,
+       xhrCallbacks = {},
+       xhrSupported = jQuery.ajaxSettings.xhr();
+
+// Support: IE<10
+// Open requests must be manually aborted on unload (#5280)
+if ( window.ActiveXObject ) {
+       jQuery( window ).on( "unload", function() {
+               for ( var key in xhrCallbacks ) {
+                       xhrCallbacks[ key ]( undefined, true );
+               }
+       });
+}
+
+// Determine support properties
+support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
+xhrSupported = support.ajax = !!xhrSupported;
+
+// Create transport if the browser can provide an xhr
+if ( xhrSupported ) {
+
+       jQuery.ajaxTransport(function( options ) {
+               // Cross domain only allowed if supported through XMLHttpRequest
+               if ( !options.crossDomain || support.cors ) {
+
+                       var callback;
+
+                       return {
+                               send: function( headers, complete ) {
+                                       var i,
+                                               xhr = options.xhr(),
+                                               id = ++xhrId;
+
+                                       // Open the socket
+                                       xhr.open( options.type, options.url, options.async, options.username, options.password );
+
+                                       // Apply custom fields if provided
+                                       if ( options.xhrFields ) {
+                                               for ( i in options.xhrFields ) {
+                                                       xhr[ i ] = options.xhrFields[ i ];
+                                               }
+                                       }
+
+                                       // Override mime type if needed
+                                       if ( options.mimeType && xhr.overrideMimeType ) {
+                                               xhr.overrideMimeType( options.mimeType );
+                                       }
+
+                                       // X-Requested-With header
+                                       // For cross-domain requests, seeing as conditions for a preflight are
+                                       // akin to a jigsaw puzzle, we simply never set it to be sure.
+                                       // (it can always be set on a per-request basis or even using ajaxSetup)
+                                       // For same-domain requests, won't change header if already provided.
+                                       if ( !options.crossDomain && !headers["X-Requested-With"] ) {
+                                               headers["X-Requested-With"] = "XMLHttpRequest";
+                                       }
+
+                                       // Set headers
+                                       for ( i in headers ) {
+                                               // Support: IE<9
+                                               // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
+                                               // request header to a null-value.
+                                               //
+                                               // To keep consistent with other XHR implementations, cast the value
+                                               // to string and ignore `undefined`.
+                                               if ( headers[ i ] !== undefined ) {
+                                                       xhr.setRequestHeader( i, headers[ i ] + "" );
+                                               }
+                                       }
+
+                                       // Do send the request
+                                       // This may raise an exception which is actually
+                                       // handled in jQuery.ajax (so no try/catch here)
+                                       xhr.send( ( options.hasContent && options.data ) || null );
+
+                                       // Listener
+                                       callback = function( _, isAbort ) {
+                                               var status, statusText, responses;
+
+                                               // Was never called and is aborted or complete
+                                               if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
+                                                       // Clean up
+                                                       delete xhrCallbacks[ id ];
+                                                       callback = undefined;
+                                                       xhr.onreadystatechange = jQuery.noop;
+
+                                                       // Abort manually if needed
+                                                       if ( isAbort ) {
+                                                               if ( xhr.readyState !== 4 ) {
+                                                                       xhr.abort();
+                                                               }
+                                                       } else {
+                                                               responses = {};
+                                                               status = xhr.status;
+
+                                                               // Support: IE<10
+                                                               // Accessing binary-data responseText throws an exception
+                                                               // (#11426)
+                                                               if ( typeof xhr.responseText === "string" ) {
+                                                                       responses.text = xhr.responseText;
+                                                               }
+
+                                                               // Firefox throws an exception when accessing
+                                                               // statusText for faulty cross-domain requests
+                                                               try {
+                                                                       statusText = xhr.statusText;
+                                                               } catch( e ) {
+                                                                       // We normalize with Webkit giving an empty statusText
+                                                                       statusText = "";
+                                                               }
+
+                                                               // Filter status for non standard behaviors
+
+                                                               // If the request is local and we have data: assume a success
+                                                               // (success with no data won't get notified, that's the best we
+                                                               // can do given current implementations)
+                                                               if ( !status && options.isLocal && !options.crossDomain ) {
+                                                                       status = responses.text ? 200 : 404;
+                                                               // IE - #1450: sometimes returns 1223 when it should be 204
+                                                               } else if ( status === 1223 ) {
+                                                                       status = 204;
+                                                               }
+                                                       }
+                                               }
+
+                                               // Call complete if needed
+                                               if ( responses ) {
+                                                       complete( status, statusText, responses, xhr.getAllResponseHeaders() );
+                                               }
+                                       };
+
+                                       if ( !options.async ) {
+                                               // if we're in sync mode we fire the callback
+                                               callback();
+                                       } else if ( xhr.readyState === 4 ) {
+                                               // (IE6 & IE7) if it's in cache and has been
+                                               // retrieved directly we need to fire the callback
+                                               setTimeout( callback );
+                                       } else {
+                                               // Add to the list of active xhr callbacks
+                                               xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
+                                       }
+                               },
+
+                               abort: function() {
+                                       if ( callback ) {
+                                               callback( undefined, true );
+                                       }
+                               }
+                       };
+               }
+       });
+}
+
+// Functions to create xhrs
+function createStandardXHR() {
+       try {
+               return new window.XMLHttpRequest();
+       } catch( e ) {}
+}
+
+function createActiveXHR() {
+       try {
+               return new window.ActiveXObject( "Microsoft.XMLHTTP" );
+       } catch( e ) {}
+}
+
+
+
+
+// Install script dataType
+jQuery.ajaxSetup({
+       accepts: {
+               script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
+       },
+       contents: {
+               script: /(?:java|ecma)script/
+       },
+       converters: {
+               "text script": function( text ) {
+                       jQuery.globalEval( text );
+                       return text;
+               }
+       }
+});
+
+// Handle cache's special case and global
+jQuery.ajaxPrefilter( "script", function( s ) {
+       if ( s.cache === undefined ) {
+               s.cache = false;
+       }
+       if ( s.crossDomain ) {
+               s.type = "GET";
+               s.global = false;
+       }
+});
+
+// Bind script tag hack transport
+jQuery.ajaxTransport( "script", function(s) {
+
+       // This transport only deals with cross domain requests
+       if ( s.crossDomain ) {
+
+               var script,
+                       head = document.head || jQuery("head")[0] || document.documentElement;
+
+               return {
+
+                       send: function( _, callback ) {
+
+                               script = document.createElement("script");
+
+                               script.async = true;
+
+                               if ( s.scriptCharset ) {
+                                       script.charset = s.scriptCharset;
+                               }
+
+                               script.src = s.url;
+
+                               // Attach handlers for all browsers
+                               script.onload = script.onreadystatechange = function( _, isAbort ) {
+
+                                       if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
+
+                                               // Handle memory leak in IE
+                                               script.onload = script.onreadystatechange = null;
+
+                                               // Remove the script
+                                               if ( script.parentNode ) {
+                                                       script.parentNode.removeChild( script );
+                                               }
+
+                                               // Dereference the script
+                                               script = null;
+
+                                               // Callback if not abort
+                                               if ( !isAbort ) {
+                                                       callback( 200, "success" );
+                                               }
+                                       }
+                               };
+
+                               // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
+                               // Use native DOM manipulation to avoid our domManip AJAX trickery
+                               head.insertBefore( script, head.firstChild );
+                       },
+
+                       abort: function() {
+                               if ( script ) {
+                                       script.onload( undefined, true );
+                               }
+                       }
+               };
+       }
+});
+
+
+
+
+var oldCallbacks = [],
+       rjsonp = /(=)\?(?=&|$)|\?\?/;
+
+// Default jsonp settings
+jQuery.ajaxSetup({
+       jsonp: "callback",
+       jsonpCallback: function() {
+               var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
+               this[ callback ] = true;
+               return callback;
+       }
+});
+
+// Detect, normalize options and install callbacks for jsonp requests
+jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
+
+       var callbackName, overwritten, responseContainer,
+               jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
+                       "url" :
+                       typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
+               );
+
+       // Handle iff the expected data type is "jsonp" or we have a parameter to set
+       if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
+
+               // Get callback name, remembering preexisting value associated with it
+               callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
+                       s.jsonpCallback() :
+                       s.jsonpCallback;
+
+               // Insert callback into url or form data
+               if ( jsonProp ) {
+                       s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
+               } else if ( s.jsonp !== false ) {
+                       s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
+               }
+
+               // Use data converter to retrieve json after script execution
+               s.converters["script json"] = function() {
+                       if ( !responseContainer ) {
+                               jQuery.error( callbackName + " was not called" );
+                       }
+                       return responseContainer[ 0 ];
+               };
+
+               // force json dataType
+               s.dataTypes[ 0 ] = "json";
+
+               // Install callback
+               overwritten = window[ callbackName ];
+               window[ callbackName ] = function() {
+                       responseContainer = arguments;
+               };
+
+               // Clean-up function (fires after converters)
+               jqXHR.always(function() {
+                       // Restore preexisting value
+                       window[ callbackName ] = overwritten;
+
+                       // Save back as free
+                       if ( s[ callbackName ] ) {
+                               // make sure that re-using the options doesn't screw things around
+                               s.jsonpCallback = originalSettings.jsonpCallback;
+
+                               // save the callback name for future use
+                               oldCallbacks.push( callbackName );
+                       }
+
+                       // Call if it was a function and we have a response
+                       if ( responseContainer && jQuery.isFunction( overwritten ) ) {
+                               overwritten( responseContainer[ 0 ] );
+                       }
+
+                       responseContainer = overwritten = undefined;
+               });
+
+               // Delegate to script
+               return "script";
+       }
+});
+
+
+
+
+// data: string of html
+// context (optional): If specified, the fragment will be created in this context, defaults to document
+// keepScripts (optional): If true, will include scripts passed in the html string
+jQuery.parseHTML = function( data, context, keepScripts ) {
+       if ( !data || typeof data !== "string" ) {
+               return null;
+       }
+       if ( typeof context === "boolean" ) {
+               keepScripts = context;
+               context = false;
+       }
+       context = context || document;
+
+       var parsed = rsingleTag.exec( data ),
+               scripts = !keepScripts && [];
+
+       // Single tag
+       if ( parsed ) {
+               return [ context.createElement( parsed[1] ) ];
+       }
+
+       parsed = jQuery.buildFragment( [ data ], context, scripts );
+
+       if ( scripts && scripts.length ) {
+               jQuery( scripts ).remove();
+       }
+
+       return jQuery.merge( [], parsed.childNodes );
+};
+
+
+// Keep a copy of the old load method
+var _load = jQuery.fn.load;
+
+/**
+ * Load a url into a page
+ */
+jQuery.fn.load = function( url, params, callback ) {
+       if ( typeof url !== "string" && _load ) {
+               return _load.apply( this, arguments );
+       }
+
+       var selector, response, type,
+               self = this,
+               off = url.indexOf(" ");
+
+       if ( off >= 0 ) {
+               selector = url.slice( off, url.length );
+               url = url.slice( 0, off );
+       }
+
+       // If it's a function
+       if ( jQuery.isFunction( params ) ) {
+
+               // We assume that it's the callback
+               callback = params;
+               params = undefined;
+
+       // Otherwise, build a param string
+       } else if ( params && typeof params === "object" ) {
+               type = "POST";
+       }
+
+       // If we have elements to modify, make the request
+       if ( self.length > 0 ) {
+               jQuery.ajax({
+                       url: url,
+
+                       // if "type" variable is undefined, then "GET" method will be used
+                       type: type,
+                       dataType: "html",
+                       data: params
+               }).done(function( responseText ) {
+
+                       // Save response for use in complete callback
+                       response = arguments;
+
+                       self.html( selector ?
+
+                               // If a selector was specified, locate the right elements in a dummy div
+                               // Exclude scripts to avoid IE 'Permission Denied' errors
+                               jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
+
+                               // Otherwise use the full result
+                               responseText );
+
+               }).complete( callback && function( jqXHR, status ) {
+                       self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
+               });
+       }
+
+       return this;
+};
+
+
+
+
+jQuery.expr.filters.animated = function( elem ) {
+       return jQuery.grep(jQuery.timers, function( fn ) {
+               return elem === fn.elem;
+       }).length;
+};
+
+
+
+
+
+var docElem = window.document.documentElement;
+
+/**
+ * Gets a window from an element
+ */
+function getWindow( elem ) {
+       return jQuery.isWindow( elem ) ?
+               elem :
+               elem.nodeType === 9 ?
+                       elem.defaultView || elem.parentWindow :
+                       false;
+}
+
+jQuery.offset = {
+       setOffset: function( elem, options, i ) {
+               var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
+                       position = jQuery.css( elem, "position" ),
+                       curElem = jQuery( elem ),
+                       props = {};
+
+               // set position first, in-case top/left are set even on static elem
+               if ( position === "static" ) {
+                       elem.style.position = "relative";
+               }
+
+               curOffset = curElem.offset();
+               curCSSTop = jQuery.css( elem, "top" );
+               curCSSLeft = jQuery.css( elem, "left" );
+               calculatePosition = ( position === "absolute" || position === "fixed" ) &&
+                       jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
+
+               // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
+               if ( calculatePosition ) {
+                       curPosition = curElem.position();
+                       curTop = curPosition.top;
+                       curLeft = curPosition.left;
+               } else {
+                       curTop = parseFloat( curCSSTop ) || 0;
+                       curLeft = parseFloat( curCSSLeft ) || 0;
+               }
+
+               if ( jQuery.isFunction( options ) ) {
+                       options = options.call( elem, i, curOffset );
+               }
+
+               if ( options.top != null ) {
+                       props.top = ( options.top - curOffset.top ) + curTop;
+               }
+               if ( options.left != null ) {
+                       props.left = ( options.left - curOffset.left ) + curLeft;
+               }
+
+               if ( "using" in options ) {
+                       options.using.call( elem, props );
+               } else {
+                       curElem.css( props );
+               }
+       }
+};
+
+jQuery.fn.extend({
+       offset: function( options ) {
+               if ( arguments.length ) {
+                       return options === undefined ?
+                               this :
+                               this.each(function( i ) {
+                                       jQuery.offset.setOffset( this, options, i );
+                               });
+               }
+
+               var docElem, win,
+                       box = { top: 0, left: 0 },
+                       elem = this[ 0 ],
+                       doc = elem && elem.ownerDocument;
+
+               if ( !doc ) {
+                       return;
+               }
+
+               docElem = doc.documentElement;
+
+               // Make sure it's not a disconnected DOM node
+               if ( !jQuery.contains( docElem, elem ) ) {
+                       return box;
+               }
+
+               // If we don't have gBCR, just use 0,0 rather than error
+               // BlackBerry 5, iOS 3 (original iPhone)
+               if ( typeof elem.getBoundingClientRect !== strundefined ) {
+                       box = elem.getBoundingClientRect();
+               }
+               win = getWindow( doc );
+               return {
+                       top: box.top  + ( win.pageYOffset || docElem.scrollTop )  - ( docElem.clientTop  || 0 ),
+                       left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
+               };
+       },
+
+       position: function() {
+               if ( !this[ 0 ] ) {
+                       return;
+               }
+
+               var offsetParent, offset,
+                       parentOffset = { top: 0, left: 0 },
+                       elem = this[ 0 ];
+
+               // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
+               if ( jQuery.css( elem, "position" ) === "fixed" ) {
+                       // we assume that getBoundingClientRect is available when computed position is fixed
+                       offset = elem.getBoundingClientRect();
+               } else {
+                       // Get *real* offsetParent
+                       offsetParent = this.offsetParent();
+
+                       // Get correct offsets
+                       offset = this.offset();
+                       if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
+                               parentOffset = offsetParent.offset();
+                       }
+
+                       // Add offsetParent borders
+                       parentOffset.top  += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
+                       parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
+               }
+
+               // Subtract parent offsets and element margins
+               // note: when an element has margin: auto the offsetLeft and marginLeft
+               // are the same in Safari causing offset.left to incorrectly be 0
+               return {
+                       top:  offset.top  - parentOffset.top - jQuery.css( elem, "marginTop", true ),
+                       left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
+               };
+       },
+
+       offsetParent: function() {
+               return this.map(function() {
+                       var offsetParent = this.offsetParent || docElem;
+
+                       while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
+                               offsetParent = offsetParent.offsetParent;
+                       }
+                       return offsetParent || docElem;
+               });
+       }
+});
+
+// Create scrollLeft and scrollTop methods
+jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
+       var top = /Y/.test( prop );
+
+       jQuery.fn[ method ] = function( val ) {
+               return access( this, function( elem, method, val ) {
+                       var win = getWindow( elem );
+
+                       if ( val === undefined ) {
+                               return win ? (prop in win) ? win[ prop ] :
+                                       win.document.documentElement[ method ] :
+                                       elem[ method ];
+                       }
+
+                       if ( win ) {
+                               win.scrollTo(
+                                       !top ? val : jQuery( win ).scrollLeft(),
+                                       top ? val : jQuery( win ).scrollTop()
+                               );
+
+                       } else {
+                               elem[ method ] = val;
+                       }
+               }, method, val, arguments.length, null );
+       };
+});
+
+// Add the top/left cssHooks using jQuery.fn.position
+// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
+// getComputedStyle returns percent when specified for top/left/bottom/right
+// rather than make the css module depend on the offset module, we just check for it here
+jQuery.each( [ "top", "left" ], function( i, prop ) {
+       jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
+               function( elem, computed ) {
+                       if ( computed ) {
+                               computed = curCSS( elem, prop );
+                               // if curCSS returns percentage, fallback to offset
+                               return rnumnonpx.test( computed ) ?
+                                       jQuery( elem ).position()[ prop ] + "px" :
+                                       computed;
+                       }
+               }
+       );
+});
+
+
+// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
+jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
+       jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
+               // margin is only for outerHeight, outerWidth
+               jQuery.fn[ funcName ] = function( margin, value ) {
+                       var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
+                               extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
+
+                       return access( this, function( elem, type, value ) {
+                               var doc;
+
+                               if ( jQuery.isWindow( elem ) ) {
+                                       // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
+                                       // isn't a whole lot we can do. See pull request at this URL for discussion:
+                                       // https://github.com/jquery/jquery/pull/764
+                                       return elem.document.documentElement[ "client" + name ];
+                               }
+
+                               // Get document width or height
+                               if ( elem.nodeType === 9 ) {
+                                       doc = elem.documentElement;
+
+                                       // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
+                                       // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
+                                       return Math.max(
+                                               elem.body[ "scroll" + name ], doc[ "scroll" + name ],
+                                               elem.body[ "offset" + name ], doc[ "offset" + name ],
+                                               doc[ "client" + name ]
+                                       );
+                               }
+
+                               return value === undefined ?
+                                       // Get width or height on the element, requesting but not forcing parseFloat
+                                       jQuery.css( elem, type, extra ) :
+
+                                       // Set width or height on the element
+                                       jQuery.style( elem, type, value, extra );
+                       }, type, chainable ? margin : undefined, chainable, null );
+               };
+       });
+});
+
+
+// The number of elements contained in the matched element set
+jQuery.fn.size = function() {
+       return this.length;
+};
+
+jQuery.fn.andSelf = jQuery.fn.addBack;
+
+
+
+
+// Register as a named AMD module, since jQuery can be concatenated with other
+// files that may use define, but not via a proper concatenation script that
+// understands anonymous AMD modules. A named AMD is safest and most robust
+// way to register. Lowercase jquery is used because AMD module names are
+// derived from file names, and jQuery is normally delivered in a lowercase
+// file name. Do this after creating the global so that if an AMD module wants
+// to call noConflict to hide this version of jQuery, it will work.
+if ( typeof define === "function" && define.amd ) {
+       define( "jquery", [], function() {
+               return jQuery;
+       });
+}
+
+
+
+
+var
+       // Map over jQuery in case of overwrite
+       _jQuery = window.jQuery,
+
+       // Map over the $ in case of overwrite
+       _$ = window.$;
+
+jQuery.noConflict = function( deep ) {
+       if ( window.$ === jQuery ) {
+               window.$ = _$;
+       }
+
+       if ( deep && window.jQuery === jQuery ) {
+               window.jQuery = _jQuery;
+       }
+
+       return jQuery;
+};
+
+// Expose jQuery and $ identifiers, even in
+// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
+// and CommonJS for browser emulators (#13566)
+if ( typeof noGlobal === strundefined ) {
+       window.jQuery = window.$ = jQuery;
+}
+
+
+
+
+return jQuery;
+
+}));
diff --git a/plugins/univbrisfvfo/templates/univbrisfvfo.html b/plugins/univbrisfvfo/templates/univbrisfvfo.html
new file mode 100644 (file)
index 0000000..86a4e9a
--- /dev/null
@@ -0,0 +1,47 @@
+<style>
+.multiselect {
+    width:40em;
+    height:5em;
+    border:solid 1px #c0c0c0;
+    overflow:auto;
+}
+.multiselect label {
+    display:block;
+}
+.multiselect-on {
+    color:#ffffff;
+    background-color:#000099;
+}
+
+.error{
+border:2px solid red;
+}
+
+</style>
+
+<form id="uob_ofv_table_form">
+  <table id='uob_ofv_table'>
+                       <tr>
+                               <th><strong>Flowspace Name</strong></th>
+                               <td colspan="2">
+                                       <input id="oflowspace_name" type="text" style="width:100%;" name="oflowspace_name" maxlength="20" title="Flowspace name" disabled="disabled" />
+                                       
+                               </td>
+                          </tr>
+                          </p>
+                           <tr>
+                               <th><strong>Wavelength</strong></th>
+                               <td>
+                                       
+                                       <label for="uob_ofv_table_wavelength"></label>
+                                       <input id="uob_ofv_table_wavelength" type="text" name="uob_ofv_table_wavelength" maxlength="17" title="wavelength for optical port/link" />
+                               </td>
+                               <td>
+                                       <p id="uob_ofv_table_wavelength_error" > wavelength should be number/double (value), e.g. 193.9 </p>    
+                               </td>
+                           </tr>                     
+  </table>
+ </form>
+
diff --git a/plugins/univbristopo/__init__.py b/plugins/univbristopo/__init__.py
new file mode 100644 (file)
index 0000000..c9e92c9
--- /dev/null
@@ -0,0 +1,37 @@
+from unfold.plugin import Plugin
+
+class UnivbrisTopo(Plugin):
+    
+    def __init__ (self, query=None, **settings):
+        Plugin.__init__ (self, **settings)
+        self.query=query
+       self.query_uuid = query.query_uuid if query else None
+       print "called univbris topo plugin"
+
+    def template_file (self):
+       try:
+               return "univbris_topology.html"
+       except:
+               print "error template"
+
+    def requirements (self):
+        reqs = {
+            'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js",
+                           "js/manifold.js", "js/manifold-query.js", 
+                           "js/unfold-helper.js",
+                'js/univbristopo.js', 'js/d3.v2.min.js','js/tooltip.topology.js',
+            ],
+            'css_files': [
+                'css/univbris.css','css/tooltip.topology.css','css/tooltip.css','css/slice.topology.css', 
+            ]
+        }
+        return reqs
+
+    def json_settings_list (self):
+        # query_uuid will pass self.query results to the javascript
+        # and will be available as "record" in :
+        # on_new_record: function(record)
+        return ['plugin_uuid', 'domid', 'query_uuid','init_key',]
+
+    def export_json_settings (self):
+        return True
diff --git a/plugins/univbristopo/static/css/slice.css b/plugins/univbristopo/static/css/slice.css
new file mode 100644 (file)
index 0000000..6b63ad5
--- /dev/null
@@ -0,0 +1,49 @@
+#resources_table {
+    width: 100%;
+}
+#resource_list {
+    width: 100%;
+}
+.table_div td,th {
+    text-align: center;
+}
+
+/* Buttons for management options: start/update/stop slice */
+.slice_action_button {
+       /*text-shadow: #ccc 1px 1px 0px !important;*/
+       text-align: right !important;
+       /*text-shadow: none !important;*/
+       width: 100px;
+}
+
+.start_slice_button {
+       /*background: #4d4 !important;*/
+       /*border: 1px solid #282 !important;
+       box-shadow: inset 0px 1px 0px 0px #5e5 !important;
+       moz-box-shadow: inset 0px 1px 0px 0px #5e5 !important;
+       -webkit-box-shadow: inset 0px 1px 0px 0px #5e5 !important;*/
+}
+.start_slice_button:hover {
+       background-color: #daf6dc !important;
+}
+.update_slice_button {
+       /*background: #ac0 !important;*/
+       /*border: 1px solid #8a0 !important;
+       box-shadow: inset 0px 1px 0px 0px #bd1 !important;
+       moz-box-shadow: inset 0px 1px 0px 0px #bd1 !important;
+       -webkit-box-shadow: inset 0px 1px 0px 0px #bd1 !important;*/
+}
+.update_slice_button:hover {
+       background-color: #cde1c0 !important;
+}
+.stop_slice_button {
+       /*background: #d44 !important;*/
+       /*border: 1px solid #822 !important;
+       box-shadow: inset 0px 1px 0px 0px #e55 !important;
+       moz-box-shadow: inset 0px 1px 0px 0px #e55 !important;
+       -webkit-box-shadow: inset 0px 1px 0px 0px #e55 !important;*/
+}
+.stop_slice_button:hover {
+       background-color: #efbfbf !important;
+}
+
diff --git a/plugins/univbristopo/static/css/slice.topology.css b/plugins/univbristopo/static/css/slice.topology.css
new file mode 100644 (file)
index 0000000..b5da77a
--- /dev/null
@@ -0,0 +1,60 @@
+#topologyContainer {
+       background: #fff !important; /* Overwrites settings from .expandable */
+       border: 1px solid #7e9fc0 !important;
+       margin-bottom: 20px;
+       overflow: hidden;
+       padding: 0px !important;
+       position:relative
+       top:200px
+       left:200px
+       width:450px
+}
+#topologyAddAggregate {
+       left: 25em;
+       position: relative;
+       top: 15em;
+       width: 450px;
+}
+#target svg {
+       width: 100% !important;
+}
+
+/*#target{
+       background: white;
+}*/
+
+/* Buttons within lower menu */
+#topology_options_menu {
+       background-color: #3d5266;
+       margin-top: 2px;
+       padding-top: 2px;
+       text-align: right;
+       width: 100%;
+}
+#link_group img, #link_zoom_out img {
+       height: 16px;
+       text-align: middle;
+}
+#link_zoom_in img, #link_zoom_out img {
+       height:16px;
+}
+
+/* Links and nodes */
+.link {
+       stroke: #ccc;
+       stroke-width:4px;
+}
+.node {
+       stroke-width:2px;
+}
+.node text {
+       pointer-events: none;
+       font: 10px sans-serif;
+}
+
+#selected_node_info {
+       background-color: #ebf5ff;
+       height: 17px;
+       text-shadow: #eee -3px 2px 4px;
+}
+
diff --git a/plugins/univbristopo/static/css/tooltip.css b/plugins/univbristopo/static/css/tooltip.css
new file mode 100644 (file)
index 0000000..61b5922
--- /dev/null
@@ -0,0 +1,49 @@
+.tooltip {
+       background-color: #c5cfd8; /*#b0c4ff;*/
+       border: 1px solid #9fa4a8;
+       border-radius: 6px;
+       /* color: #fff; */
+       display: none;
+       font-size: .9em;
+       max-width: 400px;
+       min-width: 250px;
+       padding: 10px 10px;
+       text-align: left;
+       /*opacity: 0.85;*/
+       /* outline radius for mozilla/firefox only */
+       -moz-box-shadow:0 0 2px #132c60;
+       -webkit-box-shadow:0 0 2px #132c60;
+       -moz-border-radius: 6px;
+       -webkit-border-radius: 6px;
+       /* IE 8 */
+       /*-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=85)";*/
+       /* IE 5-7 */
+       /*filter: alpha(opacity=85);*/
+       /* Netscape */
+       /*-moz-opacity: 0.85;*/
+       /* Safari 1.x */
+       /*-khtml-opacity: 0.85;*/
+}
+.tooltiptable {
+       border: none;
+       border-collapse: collapse;
+}
+.tooltiptable tbody td,
+.tooltipable tbody th {
+       border: none;
+       border-collapse: collapse;
+}
+/* Separate 1st row (th) from 2nd (td) */
+.tooltiptable tbody th {
+       padding-right: 5px;
+}
+
+/* Links*/
+.tooltip a {
+       /*color: #fff;*/
+       text-decoration: underline;
+}
+.tooltip a:hover {
+       text-decoration: none;
+}
+
diff --git a/plugins/univbristopo/static/css/tooltip.topology.css b/plugins/univbristopo/static/css/tooltip.topology.css
new file mode 100644 (file)
index 0000000..a6693ed
--- /dev/null
@@ -0,0 +1,48 @@
+#tt {
+ position:absolute;
+ display:block;
+ //background:url(images/tt_left.gif) top left no-repeat;
+ }
+#tttop {
+ display:block;
+ height:5px;
+ margin-left:5px;
+ //background:url(images/tt_top.gif) top right no-repeat;
+ overflow:hidden;
+ }
+
+
+#ttcont {
+       background-color:#111111;
+       border:0px;
+       padding:10px 10px;
+       width:200px;
+       color:#fff;
+       text-align:left;
+       font-size:10px;
+       /* outline radius for mozilla/firefox only */
+       -moz-box-shadow:0 0 10px #000;
+       -webkit-box-shadow:0 0 2px #000;
+       -moz-border-radius: 15px 15px 15px 0px;
+       -webkit-border-radius: 15px 15px 15px 0px;
+       border-radius:  10px 10px 10px 4px;
+       opacity:0.85;
+       /* IE 8 */
+       -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=85)";
+       /* IE 5-7 */
+       filter: alpha(opacity=85);
+       /* Netscape */
+       -moz-opacity: 0.85;
+       /* Safari 1.x */
+       -khtml-opacity: 0.85;
+
+
+
+}
+#ttbot {
+display:block;
+height:5px;
+margin-left:5px;
+//background:url(images/tt_bottom.gif) top right no-repeat;
+overflow:hidden;
+}
diff --git a/plugins/univbristopo/static/img/genilogo.png b/plugins/univbristopo/static/img/genilogo.png
new file mode 100644 (file)
index 0000000..5a72dc0
Binary files /dev/null and b/plugins/univbristopo/static/img/genilogo.png differ
diff --git a/plugins/univbristopo/static/img/groupin.png b/plugins/univbristopo/static/img/groupin.png
new file mode 100644 (file)
index 0000000..063e41c
Binary files /dev/null and b/plugins/univbristopo/static/img/groupin.png differ
diff --git a/plugins/univbristopo/static/img/host-tiny.png b/plugins/univbristopo/static/img/host-tiny.png
new file mode 100644 (file)
index 0000000..a998b84
Binary files /dev/null and b/plugins/univbristopo/static/img/host-tiny.png differ
diff --git a/plugins/univbristopo/static/img/oswitch-tiny.png b/plugins/univbristopo/static/img/oswitch-tiny.png
new file mode 100644 (file)
index 0000000..9ab8bbe
Binary files /dev/null and b/plugins/univbristopo/static/img/oswitch-tiny.png differ
diff --git a/plugins/univbristopo/static/img/server-tiny.png b/plugins/univbristopo/static/img/server-tiny.png
new file mode 100644 (file)
index 0000000..c70dc97
Binary files /dev/null and b/plugins/univbristopo/static/img/server-tiny.png differ
diff --git a/plugins/univbristopo/static/img/switch-tiny.png b/plugins/univbristopo/static/img/switch-tiny.png
new file mode 100644 (file)
index 0000000..de572f8
Binary files /dev/null and b/plugins/univbristopo/static/img/switch-tiny.png differ
diff --git a/plugins/univbristopo/static/img/switch-tiny2.png b/plugins/univbristopo/static/img/switch-tiny2.png
new file mode 100644 (file)
index 0000000..de572f8
Binary files /dev/null and b/plugins/univbristopo/static/img/switch-tiny2.png differ
diff --git a/plugins/univbristopo/static/img/zoom.png b/plugins/univbristopo/static/img/zoom.png
new file mode 100644 (file)
index 0000000..5a1337c
Binary files /dev/null and b/plugins/univbristopo/static/img/zoom.png differ
diff --git a/plugins/univbristopo/static/img/zoomin.png b/plugins/univbristopo/static/img/zoomin.png
new file mode 100644 (file)
index 0000000..f091f72
Binary files /dev/null and b/plugins/univbristopo/static/img/zoomin.png differ
diff --git a/plugins/univbristopo/static/img/zoomout.png b/plugins/univbristopo/static/img/zoomout.png
new file mode 100644 (file)
index 0000000..6ac1a16
Binary files /dev/null and b/plugins/univbristopo/static/img/zoomout.png differ
diff --git a/plugins/univbristopo/static/js/d3.v2.min.js b/plugins/univbristopo/static/js/d3.v2.min.js
new file mode 100644 (file)
index 0000000..db146de
--- /dev/null
@@ -0,0 +1,4 @@
+(function(){function e(e,t){try{for(var n in t)Object.defineProperty(e.prototype,n,{value:t[n],enumerable:!1})}catch(r){e.prototype=t}}function t(e){var t=-1,n=e.length,r=[];while(++t<n)r.push(e[t]);return r}function n(e){return Array.prototype.slice.call(e)}function r(){}function i(e){return e}function s(){return this}function o(){return!0}function u(e){return typeof e=="function"?e:function(){return e}}function a(e,t,n){return function(){var r=n.apply(t,arguments);return arguments.length?e:r}}function f(e){return e!=null&&!isNaN(e)}function l(e){return e.length}function c(e){return e==null}function h(e){return e.trim().replace(/\s+/g," ")}function p(e){var t=1;while(e*t%1)t*=10;return t}function d(){}function v(e){function t(){var t=n,r=-1,i=t.length,s;while(++r<i)(s=t[r].on)&&s.apply(this,arguments);return e}var n=[],i=new r;return t.on=function(t,r){var s=i.get(t),o;return arguments.length<2?s&&s.on:(s&&(s.on=null,n=n.slice(0,o=n.indexOf(s)).concat(n.slice(o+1)),i.remove(t)),r&&n.push(i.set(t,{on:r})),e)},t}function m(e,t){return t-(e?1+Math.floor(Math.log(e+Math.pow(10,1+Math.floor(Math.log(e)/Math.LN10)-t))/Math.LN10):1)}function g(e){return e+""}function y(e){var t=e.lastIndexOf("."),n=t>=0?e.substring(t):(t=e.length,""),r=[];while(t>0)r.push(e.substring(t-=3,t+3));return r.reverse().join(",")+n}function b(e,t){var n=Math.pow(10,Math.abs(8-t)*3);return{scale:t>8?function(e){return e/n}:function(e){return e*n},symbol:e}}function w(e){return function(t){return t<=0?0:t>=1?1:e(t)}}function E(e){return function(t){return 1-e(1-t)}}function S(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}}function x(e){return e}function T(e){return function(t){return Math.pow(t,e)}}function N(e){return 1-Math.cos(e*Math.PI/2)}function C(e){return Math.pow(2,10*(e-1))}function k(e){return 1-Math.sqrt(1-e*e)}function L(e,t){var n;return arguments.length<2&&(t=.45),arguments.length<1?(e=1,n=t/4):n=t/(2*Math.PI)*Math.asin(1/e),function(r){return 1+e*Math.pow(2,10*-r)*Math.sin((r-n)*2*Math.PI/t)}}function A(e){return e||(e=1.70158),function(t){return t*t*((e+1)*t-e)}}function O(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}function M(){d3.event.stopPropagation(),d3.event.preventDefault()}function _(){var e=d3.event,t;while(t=e.sourceEvent)e=t;return e}function D(e){var t=new d,n=0,r=arguments.length;while(++n<r)t[arguments[n]]=v(t);return t.of=function(n,r){return function(i){try{var s=i.sourceEvent=d3.event;i.target=e,d3.event=i,t[i.type].apply(n,r)}finally{d3.event=s}}},t}function P(e){var t=[e.a,e.b],n=[e.c,e.d],r=B(t),i=H(t,n),s=B(j(n,t,-i))||0;t[0]*n[1]<n[0]*t[1]&&(t[0]*=-1,t[1]*=-1,r*=-1,i*=-1),this.rotate=(r?Math.atan2(t[1],t[0]):Math.atan2(-n[0],n[1]))*fs,this.translate=[e.e,e.f],this.scale=[r,s],this.skew=s?Math.atan2(i,s)*fs:0}function H(e,t){return e[0]*t[0]+e[1]*t[1]}function B(e){var t=Math.sqrt(H(e,e));return t&&(e[0]/=t,e[1]/=t),t}function j(e,t,n){return e[0]+=n*t[0],e[1]+=n*t[1],e}function F(e){return e=="transform"?d3.interpolateTransform:d3.interpolate}function I(e,t){return t=t-(e=+e)?1/(t-e):0,function(n){return(n-e)*t}}function q(e,t){return t=t-(e=+e)?1/(t-e):0,function(n){return Math.max(0,Math.min(1,(n-e)*t))}}function R(e,t,n){return new U(e,t,n)}function U(e,t,n){this.r=e,this.g=t,this.b=n}function z(e){return e<16?"0"+Math.max(0,e).toString(16):Math.min(255,e).toString(16)}function W(e,t,n){var r=0,i=0,s=0,o,u,a;o=/([a-z]+)\((.*)\)/i.exec(e);if(o){u=o[2].split(",");switch(o[1]){case"hsl":return n(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(J(u[0]),J(u[1]),J(u[2]))}}return(a=hs.get(e))?t(a.r,a.g,a.b):(e!=null&&e.charAt(0)==="#"&&(e.length===4?(r=e.charAt(1),r+=r,i=e.charAt(2),i+=i,s=e.charAt(3),s+=s):e.length===7&&(r=e.substring(1,3),i=e.substring(3,5),s=e.substring(5,7)),r=parseInt(r,16),i=parseInt(i,16),s=parseInt(s,16)),t(r,i,s))}function X(e,t,n){var r=Math.min(e/=255,t/=255,n/=255),i=Math.max(e,t,n),s=i-r,o,u,a=(i+r)/2;return s?(u=a<.5?s/(i+r):s/(2-i-r),e==i?o=(t-n)/s+(t<n?6:0):t==i?o=(n-e)/s+2:o=(e-t)/s+4,o*=60):u=o=0,K(o,u,a)}function V(e,t,n){e=$(e),t=$(t),n=$(n);var r=ot((.4124564*e+.3575761*t+.1804375*n)/ds),i=ot((.2126729*e+.7151522*t+.072175*n)/vs),s=ot((.0193339*e+.119192*t+.9503041*n)/ms);return tt(116*i-16,500*(r-i),200*(i-s))}function $(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function J(e){var t=parseFloat(e);return e.charAt(e.length-1)==="%"?Math.round(t*2.55):t}function K(e,t,n){return new Q(e,t,n)}function Q(e,t,n){this.h=e,this.s=t,this.l=n}function G(e,t,n){function r(e){return e>360?e-=360:e<0&&(e+=360),e<60?s+(o-s)*e/60:e<180?o:e<240?s+(o-s)*(240-e)/60:s}function i(e){return Math.round(r(e)*255)}var s,o;return e%=360,e<0&&(e+=360),t=t<0?0:t>1?1:t,n=n<0?0:n>1?1:n,o=n<=.5?n*(1+t):n+t-n*t,s=2*n-o,R(i(e+120),i(e),i(e-120))}function Y(e,t,n){return new Z(e,t,n)}function Z(e,t,n){this.h=e,this.c=t,this.l=n}function et(e,t,n){return tt(n,Math.cos(e*=Math.PI/180)*t,Math.sin(e)*t)}function tt(e,t,n){return new nt(e,t,n)}function nt(e,t,n){this.l=e,this.a=t,this.b=n}function rt(e,t,n){var r=(e+16)/116,i=r+t/500,s=r-n/200;return i=st(i)*ds,r=st(r)*vs,s=st(s)*ms,R(ut(3.2404542*i-1.5371385*r-.4985314*s),ut(-0.969266*i+1.8760108*r+.041556*s),ut(.0556434*i-.2040259*r+1.0572252*s))}function it(e,t,n){return Y(Math.atan2(n,t)/Math.PI*180,Math.sqrt(t*t+n*n),e)}function st(e){return e>.206893034?e*e*e:(e-4/29)/7.787037}function ot(e){return e>.008856?Math.pow(e,1/3):7.787037*e+4/29}function ut(e){return Math.round(255*(e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055))}function at(e){return Ki(e,Ss),e}function ft(e){return function(){return gs(e,this)}}function lt(e){return function(){return ys(e,this)}}function ct(e,t){function n(){this.removeAttribute(e)}function r(){this.removeAttributeNS(e.space,e.local)}function i(){this.setAttribute(e,t)}function s(){this.setAttributeNS(e.space,e.local,t)}function o(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}function u(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}return e=d3.ns.qualify(e),t==null?e.local?r:n:typeof t=="function"?e.local?u:o:e.local?s:i}function ht(e){return new RegExp("(?:^|\\s+)"+d3.requote(e)+"(?:\\s+|$)","g")}function pt(e,t){function n(){var n=-1;while(++n<i)e[n](this,t)}function r(){var n=-1,r=t.apply(this,arguments);while(++n<i)e[n](this,r)}e=e.trim().split(/\s+/).map(dt);var i=e.length;return typeof t=="function"?r:n}function dt(e){var t=ht(e);return function(n,r){if(i=n.classList)return r?i.add(e):i.remove(e);var i=n.className,s=i.baseVal!=null,o=s?i.baseVal:i;r?(t.lastIndex=0,t.test(o)||(o=h(o+" "+e),s?i.baseVal=o:n.className=o)):o&&(o=h(o.replace(t," ")),s?i.baseVal=o:n.className=o)}}function vt(e,t,n){function r(){this.style.removeProperty(e)}function i(){this.style.setProperty(e,t,n)}function s(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}return t==null?r:typeof t=="function"?s:i}function mt(e,t){function n(){delete this[e]}function r(){this[e]=t}function i(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}return t==null?n:typeof t=="function"?i:r}function gt(e){return{__data__:e}}function yt(e){return function(){return Es(this,e)}}function bt(e){return arguments.length||(e=d3.ascending),function(t,n){return e(t&&t.__data__,n&&n.__data__)}}function wt(e,t,n){function r(){var t=this[s];t&&(this.removeEventListener(e,t,t.$),delete this[s])}function i(){function i(e){var n=d3.event;d3.event=e,u[0]=o.__data__;try{t.apply(o,u)}finally{d3.event=n}}var o=this,u=arguments;r.call(this),this.addEventListener(e,this[s]=i,i.$=n),i._=t}var s="__on"+e,o=e.indexOf(".");return o>0&&(e=e.substring(0,o)),t?i:r}function Et(e,t){for(var n=0,r=e.length;n<r;n++)for(var i=e[n],s=0,o=i.length,u;s<o;s++)(u=i[s])&&t(u,s,n);return e}function St(e){return Ki(e,Ts),e}function xt(e,t,n){Ki(e,Ns);var i=new r,s=d3.dispatch("start","end"),o=Ds;return e.id=t,e.time=n,e.tween=function(t,n){return arguments.length<2?i.get(t):(n==null?i.remove(t):i.set(t,n),e)},e.ease=function(t){return arguments.length?(o=typeof t=="function"?t:d3.ease.apply(d3,arguments),e):o},e.each=function(t,n){return arguments.length<2?Tt.call(e,t):(s.on(t,n),e)},d3.timer(function(r){return Et(e,function(e,u,a){function f(r){return v.active>t?c():(v.active=t,i.forEach(function(t,n){(n=n.call(e,m,u))&&h.push(n)}),s.start.call(e,m,u),l(r)||d3.timer(l,0,n),1)}function l(n){if(v.active!==t)return c();var r=(n-p)/d,i=o(r),a=h.length;while(a>0)h[--a].call(e,i);if(r>=1)return c(),ks=t,s.end.call(e,m,u),ks=0,1}function c(){return--v.count||delete e.__transition__,1}var h=[],p=e.delay,d=e.duration,v=(e=e.node).__transition__||(e.__transition__={active:0,count:0}),m=e.__data__;++v.count,p<=r?f(r):d3.timer(f,p,n)})},0,n),e}function Tt(e){var t=ks,n=Ds,r=Ms,i=_s;return ks=this.id,Ds=this.ease(),Et(this,function(t,n,r){Ms=t.delay,_s=t.duration,e.call(t=t.node,t.__data__,n,r)}),ks=t,Ds=n,Ms=r,_s=i,this}function Nt(e,t,n){return n!=""&&Ps}function Ct(e,t){return d3.tween(e,F(t))}function kt(){var e,t=Date.now(),n=Hs;while(n)e=t-n.then,e>=n.delay&&(n.flush=n.callback(e)),n=n.next;var r=Lt()-t;r>24?(isFinite(r)&&(clearTimeout(js),js=setTimeout(kt,r)),Bs=0):(Bs=1,Fs(kt))}function Lt(){var e=null,t=Hs,n=Infinity;while(t)t.flush?t=e?e.next=t.next:Hs=t.next:(n=Math.min(n,t.then+t.delay),t=(e=t).next);return n}function At(e,t){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();if(Is<0&&(window.scrollX||window.scrollY)){n=d3.select(document.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=n[0][0].getScreenCTM();Is=!i.f&&!i.e,n.remove()}return Is?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}function Ot(){}function Mt(e){var t=e[0],n=e[e.length-1];return t<n?[t,n]:[n,t]}function _t(e){return e.rangeExtent?e.rangeExtent():Mt(e.range())}function Dt(e,t){var n=0,r=e.length-1,i=e[n],s=e[r],o;s<i&&(o=n,n=r,r=o,o=i,i=s,s=o);if(t=t(s-i))e[n]=t.floor(i),e[r]=t.ceil(s);return e}function Pt(){return Math}function Ht(e,t,n,r){function i(){var i=Math.min(e.length,t.length)>2?Ut:Rt,a=r?q:I;return o=i(e,t,a,n),u=i(t,e,a,d3.interpolate),s}function s(e){return o(e)}var o,u;return s.invert=function(e){return u(e)},s.domain=function(t){return arguments.length?(e=t.map(Number),i()):e},s.range=function(e){return arguments.length?(t=e,i()):t},s.rangeRound=function(e){return s.range(e).interpolate(d3.interpolateRound)},s.clamp=function(e){return arguments.length?(r=e,i()):r},s.interpolate=function(e){return arguments.length?(n=e,i()):n},s.ticks=function(t){return It(e,t)},s.tickFormat=function(t){return qt(e,t)},s.nice=function(){return Dt(e,jt),i()},s.copy=function(){return Ht(e,t,n,r)},i()}function Bt(e,t){return d3.rebind(e,t,"range","rangeRound","interpolate","clamp")}function jt(e){return e=Math.pow(10,Math.round(Math.log(e)/Math.LN10)-1),e&&{floor:function(t){return Math.floor(t/e)*e},ceil:function(t){return Math.ceil(t/e)*e}}}function Ft(e,t){var n=Mt(e),r=n[1]-n[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),s=t/r*i;return s<=.15?i*=10:s<=.35?i*=5:s<=.75&&(i*=2),n[0]=Math.ceil(n[0]/i)*i,n[1]=Math.floor(n[1]/i)*i+i*.5,n[2]=i,n}function It(e,t){return d3.range.apply(d3,Ft(e,t))}function qt(e,t){return d3.format(",."+Math.max(0,-Math.floor(Math.log(Ft(e,t)[2])/Math.LN10+.01))+"f")}function Rt(e,t,n,r){var i=n(e[0],e[1]),s=r(t[0],t[1]);return function(e){return s(i(e))}}function Ut(e,t,n,r){var i=[],s=[],o=0,u=Math.min(e.length,t.length)-1;e[u]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());while(++o<=u)i.push(n(e[o-1],e[o])),s.push(r(t[o-1],t[o]));return function(t){var n=d3.bisect(e,t,1,u)-1;return s[n](i[n](t))}}function zt(e,t){function n(n){return e(t(n))}var r=t.pow;return n.invert=function(t){return r(e.invert(t))},n.domain=function(i){return arguments.length?(t=i[0]<0?Xt:Wt,r=t.pow,e.domain(i.map(t)),n):e.domain().map(r)},n.nice=function(){return e.domain(Dt(e.domain(),Pt)),n},n.ticks=function(){var n=Mt(e.domain()),i=[];if(n.every(isFinite)){var s=Math.floor(n[0]),o=Math.ceil(n[1]),u=r(n[0]),a=r(n[1]);if(t===Xt){i.push(r(s));for(;s++<o;)for(var f=9;f>0;f--)i.push(r(s)*f)}else{for(;s<o;s++)for(var f=1;f<10;f++)i.push(r(s)*f);i.push(r(s))}for(s=0;i[s]<u;s++);for(o=i.length;i[o-1]>a;o--);i=i.slice(s,o)}return i},n.tickFormat=function(e,i){arguments.length<2&&(i=qs);if(arguments.length<1)return i;var s=Math.max(.1,e/n.ticks().length),o=t===Xt?(u=-1e-12,Math.floor):(u=1e-12,Math.ceil),u;return function(e){return e/r(o(t(e)+u))<=s?i(e):""}},n.copy=function(){return zt(e.copy(),t)},Bt(n,e)}function Wt(e){return Math.log(e<0?0:e)/Math.LN10}function Xt(e){return-Math.log(e>0?0:-e)/Math.LN10}function Vt(e,t){function n(t){return e(r(t))}var r=$t(t),i=$t(1/t);return n.invert=function(t){return i(e.invert(t))},n.domain=function(t){return arguments.length?(e.domain(t.map(r)),n):e.domain().map(i)},n.ticks=function(e){return It(n.domain(),e)},n.tickFormat=function(e){return qt(n.domain(),e)},n.nice=function(){return n.domain(Dt(n.domain(),jt))},n.exponent=function(e){if(!arguments.length)return t;var s=n.domain();return r=$t(t=e),i=$t(1/t),n.domain(s)},n.copy=function(){return Vt(e.copy(),t)},Bt(n,e)}function $t(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function Jt(e,t){function n(t){return o[((s.get(t)||s.set(t,e.push(t)))-1)%o.length]}function i(t,n){return d3.range(e.length).map(function(e){return t+n*e})}var s,o,u;return n.domain=function(i){if(!arguments.length)return e;e=[],s=new r;var o=-1,u=i.length,a;while(++o<u)s.has(a=i[o])||s.set(a,e.push(a));return n[t.t].apply(n,t.a)},n.range=function(e){return arguments.length?(o=e,u=0,t={t:"range",a:arguments},n):o},n.rangePoints=function(r,s){arguments.length<2&&(s=0);var a=r[0],f=r[1],l=(f-a)/(Math.max(1,e.length-1)+s);return o=i(e.length<2?(a+f)/2:a+l*s/2,l),u=0,t={t:"rangePoints",a:arguments},n},n.rangeBands=function(r,s,a){arguments.length<2&&(s=0),arguments.length<3&&(a=s);var f=r[1]<r[0],l=r[f-0],c=r[1-f],h=(c-l)/(e.length-s+2*a);return o=i(l+h*a,h),f&&o.reverse(),u=h*(1-s),t={t:"rangeBands",a:arguments},n},n.rangeRoundBands=function(r,s,a){arguments.length<2&&(s=0),arguments.length<3&&(a=s);var f=r[1]<r[0],l=r[f-0],c=r[1-f],h=Math.floor((c-l)/(e.length-s+2*a)),p=c-l-(e.length-s)*h;return o=i(l+Math.round(p/2),h),f&&o.reverse(),u=Math.round(h*(1-s)),t={t:"rangeRoundBands",a:arguments},n},n.rangeBand=function(){return u},n.rangeExtent=function(){return Mt(t.a[0])},n.copy=function(){return Jt(e,t)},n.domain(e)}function Kt(e,t){function n(){var n=0,s=e.length,o=t.length;i=[];while(++n<o)i[n-1]=d3.quantile(e,n/o);return r}function r(e){return isNaN(e=+e)?NaN:t[d3.bisect(i,e)]}var i;return r.domain=function(t){return arguments.length?(e=t.filter(function(e){return!isNaN(e)}).sort(d3.ascending),n()):e},r.range=function(e){return arguments.length?(t=e,n()):t},r.quantiles=function(){return i},r.copy=function(){return Kt(e,t)},n()}function Qt(e,t,n){function r(t){return n[Math.max(0,Math.min(o,Math.floor(s*(t-e))))]}function i(){return s=n.length/(t-e),o=n.length-1,r}var s,o;return r.domain=function(n){return arguments.length?(e=+n[0],t=+n[n.length-1],i()):[e,t]},r.range=function(e){return arguments.length?(n=e,i()):n},r.copy=function(){return Qt(e,t,n)},i()}function Gt(e,t){function n(n){return t[d3.bisect(e,n)]}return n.domain=function(t){return arguments.length?(e=t,n):e},n.range=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return Gt(e,t)},n}function Yt(e){function t(e){return+e}return t.invert=t,t.domain=t.range=function(n){return arguments.length?(e=n.map(t),t):e},t.ticks=function(t){return It(e,t)},t.tickFormat=function(t){return qt(e,t)},t.copy=function(){return Yt(e)},t}function Zt(e){return e.innerRadius}function en(e){return e.outerRadius}function tn(e){return e.startAngle}function nn(e){return e.endAngle}function rn(e){function t(t){function o(){a.push("M",s(e(l),f))}var a=[],l=[],c=-1,h=t.length,p,d=u(n),v=u(r);while(++c<h)i.call(this,p=t[c],c)?l.push([+d.call(this,p,c),+v.call(this,p,c)]):l.length&&(o(),l=[]);return l.length&&o(),a.length?a.join(""):null}var n=sn,r=on,i=o,s=un,a=s.key,f=.7;return t.x=function(e){return arguments.length?(n=e,t):n},t.y=function(e){return arguments.length?(r=e,t):r},t.defined=function(e){return arguments.length?(i=e,t):i},t.interpolate=function(e){return arguments.length?(typeof e=="function"?a=s=e:a=(s=$s.get(e)||un).key,t):a},t.tension=function(e){return arguments.length?(f=e,t):f},t}function sn(e){return e[0]}function on(e){return e[1]}function un(e){return e.join("L")}function an(e){return un(e)+"Z"}function fn(e){var t=0,n=e.length,r=e[0],i=[r[0],",",r[1]];while(++t<n)i.push("V",(r=e[t])[1],"H",r[0]);return i.join("")}function ln(e){var t=0,n=e.length,r=e[0],i=[r[0],",",r[1]];while(++t<n)i.push("H",(r=e[t])[0],"V",r[1]);return i.join("")}function cn(e,t){return e.length<4?un(e):e[1]+dn(e.slice(1,e.length-1),vn(e,t))}function hn(e,t){return e.length<3?un(e):e[0]+dn((e.push(e[0]),e),vn([e[e.length-2]].concat(e,[e[1]]),t))}function pn(e,t,n){return e.length<3?un(e):e[0]+dn(e,vn(e,t))}function dn(e,t){if(t.length<1||e.length!=t.length&&e.length!=t.length+2)return un(e);var n=e.length!=t.length,r="",i=e[0],s=e[1],o=t[0],u=o,a=1;n&&(r+="Q"+(s[0]-o[0]*2/3)+","+(s[1]-o[1]*2/3)+","+s[0]+","+s[1],i=e[1],a=2);if(t.length>1){u=t[1],s=e[a],a++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(s[0]-u[0])+","+(s[1]-u[1])+","+s[0]+","+s[1];for(var f=2;f<t.length;f++,a++)s=e[a],u=t[f],r+="S"+(s[0]-u[0])+","+(s[1]-u[1])+","+s[0]+","+s[1]}if(n){var l=e[a];r+="Q"+(s[0]+u[0]*2/3)+","+(s[1]+u[1]*2/3)+","+l[0]+","+l[1]}return r}function vn(e,t){var n=[],r=(1-t)/2,i,s=e[0],o=e[1],u=1,a=e.length;while(++u<a)i=s,s=o,o=e[u],n.push([r*(o[0]-i[0]),r*(o[1]-i[1])]);return n}function mn(e){if(e.length<3)return un(e);var t=1,n=e.length,r=e[0],i=r[0],s=r[1],o=[i,i,i,(r=e[1])[0]],u=[s,s,s,r[1]],a=[i,",",s];En(a,o,u);while(++t<n)r=e[t],o.shift(),o.push(r[0]),u.shift(),u.push(r[1]),En(a,o,u);t=-1;while(++t<2)o.shift(),o.push(r[0]),u.shift(),u.push(r[1]),En(a,o,u);return a.join("")}function gn(e){if(e.length<4)return un(e);var t=[],n=-1,r=e.length,i,s=[0],o=[0];while(++n<3)i=e[n],s.push(i[0]),o.push(i[1]);t.push(wn(Qs,s)+","+wn(Qs,o)),--n;while(++n<r)i=e[n],s.shift(),s.push(i[0]),o.shift(),o.push(i[1]),En(t,s,o);return t.join("")}function yn(e){var t,n=-1,r=e.length,i=r+4,s,o=[],u=[];while(++n<4)s=e[n%r],o.push(s[0]),u.push(s[1]);t=[wn(Qs,o),",",wn(Qs,u)],--n;while(++n<i)s=e[n%r],o.shift(),o.push(s[0]),u.shift(),u.push(s[1]),En(t,o,u);return t.join("")}function bn(e,t){var n=e.length-1;if(n){var r=e[0][0],i=e[0][1],s=e[n][0]-r,o=e[n][1]-i,u=-1,a,f;while(++u<=n)a=e[u],f=u/n,a[0]=t*a[0]+(1-t)*(r+f*s),a[1]=t*a[1]+(1-t)*(i+f*o)}return mn(e)}function wn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function En(e,t,n){e.push("C",wn(Js,t),",",wn(Js,n),",",wn(Ks,t),",",wn(Ks,n),",",wn(Qs,t),",",wn(Qs,n))}function Sn(e,t){return(t[1]-e[1])/(t[0]-e[0])}function xn(e){var t=0,n=e.length-1,r=[],i=e[0],s=e[1],o=r[0]=Sn(i,s);while(++t<n)r[t]=(o+(o=Sn(i=s,s=e[t+1])))/2;return r[t]=o,r}function Tn(e){var t=[],n,r,i,s,o=xn(e),u=-1,a=e.length-1;while(++u<a)n=Sn(e[u],e[u+1]),Math.abs(n)<1e-6?o[u]=o[u+1]=0:(r=o[u]/n,i=o[u+1]/n,s=r*r+i*i,s>9&&(s=n*3/Math.sqrt(s),o[u]=s*r,o[u+1]=s*i));u=-1;while(++u<=a)s=(e[Math.min(a,u+1)][0]-e[Math.max(0,u-1)][0])/(6*(1+o[u]*o[u])),t.push([s||0,o[u]*s||0]);return t}function Nn(e){return e.length<3?un(e):e[0]+dn(e,Tn(e))}function Cn(e){var t,n=-1,r=e.length,i,s;while(++n<r)t=e[n],i=t[0],s=t[1]+Xs,t[0]=i*Math.cos(s),t[1]=i*Math.sin(s);return e}function kn(e){function t(t){function o(){l.push("M",f(e(v),p),h,c(e(d.reverse()),p),"Z")}var l=[],d=[],v=[],m=-1,g=t.length,y,b=u(n),w=u(i),E=n===r?function(){return x}:u(r),S=i===s?function(){return T}:u(s),x,T;while(++m<g)a.call(this,y=t[m],m)?(d.push([x=+b.call(this,y,m),T=+w.call(this,y,m)]),v.push([+E.call(this,y,m),+S.call(this,y,m)])):d.length&&(o(),d=[],v=[]);return d.length&&o(),l.length?l.join(""):null}var n=sn,r=sn,i=0,s=on,a=o,f=un,l=f.key,c=f,h="L",p=.7;return t.x=function(e){return arguments.length?(n=r=e,t):r},t.x0=function(e){return arguments.length?(n=e,t):n},t.x1=function(e){return arguments.length?(r=e,t):r},t.y=function(e){return arguments.length?(i=s=e,t):s},t.y0=function(e){return arguments.length?(i=e,t):i},t.y1=function(e){return arguments.length?(s=e,t):s},t.defined=function(e){return arguments.length?(a=e,t):a},t.interpolate=function(e){return arguments.length?(typeof e=="function"?l=f=e:l=(f=$s.get(e)||un).key,c=f.reverse||f,h=f.closed?"M":"L",t):l},t.tension=function(e){return arguments.length?(p=e,t):p},t}function Ln(e){return e.source}function An(e){return e.target}function On(e){return e.radius}function Mn(e){return e.startAngle}function _n(e){return e.endAngle}function Dn(e){return[e.x,e.y]}function Pn(e){return function(){var t=e.apply(this,arguments),n=t[0],r=t[1]+Xs;return[n*Math.cos(r),n*Math.sin(r)]}}function Hn(){return 64}function Bn(){return"circle"}function jn(e){var t=Math.sqrt(e/Math.PI);return"M0,"+t+"A"+t+","+t+" 0 1,1 0,"+ -t+"A"+t+","+t+" 0 1,1 0,"+t+"Z"}function Fn(e,t){e.attr("transform",function(e){return"translate("+t(e)+",0)"})}function In(e,t){e.attr("transform",function(e){return"translate(0,"+t(e)+")"})}function qn(e,t,n){i=[];if(n&&t.length>1){var r=Mt(e.domain()),i,s=-1,o=t.length,u=(t[1]-t[0])/++n,a,f;while(++s<o)for(a=n;--a>0;)(f=+t[s]-a*u)>=r[0]&&i.push(f);for(--s,a=0;++a<n&&(f=+t[s]+a*u)<r[1];)i.push(f)}return i}function Rn(){no||(no=d3.select("body").append("div").style("visibility","hidden").style("top",0).style("height",0).style("width",0).style("overflow-y","scroll").append("div").style("height","2000px").node().parentNode);var e=d3.event,t;try{no.scrollTop=1e3,no.dispatchEvent(e),t=1e3-no.scrollTop}catch(n){t=e.wheelDelta||-e.detail*5}return t}function Un(e){var t=e.source,n=e.target,r=Wn(t,n),i=[t];while(t!==r)t=t.parent,i.push(t);var s=i.length;while(n!==r)i.splice(s,0,n),n=n.parent;return i}function zn(e){var t=[],n=e.parent;while(n!=null)t.push(e),e=n,n=n.parent;return t.push(e),t}function Wn(e,t){if(e===t)return e;var n=zn(e),r=zn(t),i=n.pop(),s=r.pop(),o=null;while(i===s)o=i,i=n.pop(),s=r.pop();return o}function Xn(e){e.fixed|=2}function Vn(e){e.fixed&=1}function $n(e){e.fixed|=4}function Jn(e){e.fixed&=3}function Kn(e,t,n){var r=0,i=0;e.charge=0;if(!e.leaf){var s=e.nodes,o=s.length,u=-1,a;while(++u<o){a=s[u];if(a==null)continue;Kn(a,t,n),e.charge+=a.charge,r+=a.charge*a.cx,i+=a.charge*a.cy}}if(e.point){e.leaf||(e.point.x+=Math.random()-.5,e.point.y+=Math.random()-.5);var f=t*n[e.point.index];e.charge+=e.pointCharge=f,r+=f*e.point.x,i+=f*e.point.y}e.cx=r/e.charge,e.cy=i/e.charge}function Qn(e){return 20}function Gn(e){return 1}function Yn(e){return e.x}function Zn(e){return e.y}function er(e,t,n){e.y0=t,e.y=n}function tr(e){return d3.range(e.length)}function nr(e){var t=-1,n=e[0].length,r=[];while(++t<n)r[t]=0;return r}function rr(e){var t=1,n=0,r=e[0][1],i,s=e.length;for(;t<s;++t)(i=e[t][1])>r&&(n=t,r=i);return n}function ir(e){return e.reduce(sr,0)}function sr(e,t){return e+t[1]}function or(e,t){return ur(e,Math.ceil(Math.log(t.length)/Math.LN2+1))}function ur(e,t){var n=-1,r=+e[0],i=(e[1]-r)/t,s=[];while(++n<=t)s[n]=i*n+r;return s}function ar(e){return[d3.min(e),d3.max(e)]}function fr(e,t){return d3.rebind(e,t,"sort","children","value"),e.links=pr,e.nodes=function(t){return uo=!0,(e.nodes=e)(t)},e}function lr(e){return e.children}function cr(e){return e.value}function hr(e,t){return t.value-e.value}function pr(e){return d3.merge(e.map(function(e){return(e.children||[]).map(function(t){return{source:e,target:t}})}))}function dr(e,t){return e.value-t.value}function vr(e,t){var n=e._pack_next;e._pack_next=t,t._pack_prev=e,t._pack_next=n,n._pack_prev=t}function mr(e,t){e._pack_next=t,t._pack_prev=e}function gr(e,t){var n=t.x-e.x,r=t.y-e.y,i=e.r+t.r;return i*i-n*n-r*r>.001}function yr(e){function t(e){r=Math.min(e.x-e.r,r),i=Math.max(e.x+e.r,i),s=Math.min(e.y-e.r,s),o=Math.max(e.y+e.r,o)}if(!(n=e.children)||!(p=n.length))return;var n,r=Infinity,i=-Infinity,s=Infinity,o=-Infinity,u,a,f,l,c,h,p;n.forEach(br),u=n[0],u.x=-u.r,u.y=0,t(u);if(p>1){a=n[1],a.x=a.r,a.y=0,t(a);if(p>2){f=n[2],Sr(u,a,f),t(f),vr(u,f),u._pack_prev=f,vr(f,a),a=u._pack_next;for(l=3;l<p;l++){Sr(u,a,f=n[l]);var d=0,v=1,m=1;for(c=a._pack_next;c!==a;c=c._pack_next,v++)if(gr(c,f)){d=1;break}if(d==1)for(h=u._pack_prev;h!==c._pack_prev;h=h._pack_prev,m++)if(gr(h,f))break;d?(v<m||v==m&&a.r<u.r?mr(u,a=c):mr(u=h,a),l--):(vr(u,f),a=f,t(f))}}}var g=(r+i)/2,y=(s+o)/2,b=0;for(l=0;l<p;l++)f=n[l],f.x-=g,f.y-=y,b=Math.max(b,f.r+Math.sqrt(f.x*f.x+f.y*f.y));e.r=b,n.forEach(wr)}function br(e){e._pack_next=e._pack_prev=e}function wr(e){delete e._pack_next,delete e._pack_prev}function Er(e,t,n,r){var i=e.children;e.x=t+=r*e.x,e.y=n+=r*e.y,e.r*=r;if(i){var s=-1,o=i.length;while(++s<o)Er(i[s],t,n,r)}}function Sr(e,t,n){var r=e.r+n.r,i=t.x-e.x,s=t.y-e.y;if(r&&(i||s)){var o=t.r+n.r,u=i*i+s*s;o*=o,r*=r;var a=.5+(r-o)/(2*u),f=Math.sqrt(Math.max(0,2*o*(r+u)-(r-=u)*r-o*o))/(2*u);n.x=e.x+a*i+f*s,n.y=e.y+a*s-f*i}else n.x=e.x+r,n.y=e.y}function xr(e){return 1+d3.max(e,function(e){return e.y})}function Tr(e){return e.reduce(function(e,t){return e+t.x},0)/e.length}function Nr(e){var t=e.children;return t&&t.length?Nr(t[0]):e}function Cr(e){var t=e.children,n;return t&&(n=t.length)?Cr(t[n-1]):e}function kr(e,t){return e.parent==t.parent?1:2}function Lr(e){var t=e.children;return t&&t.length?t[0]:e._tree.thread}function Ar(e){var t=e.children,n;return t&&(n=t.length)?t[n-1]:e._tree.thread}function Or(e,t){var n=e.children;if(n&&(i=n.length)){var r,i,s=-1;while(++s<i)t(r=Or(n[s],t),e)>0&&(e=r)}return e}function Mr(e,t){return e.x-t.x}function _r(e,t){return t.x-e.x}function Dr(e,t){return e.depth-t.depth}function Pr(e,t){function n(e,r){var i=e.children;if(i&&(a=i.length)){var s,o=null,u=-1,a;while(++u<a)s=i[u],n(s,o),o=s}t(e,r)}n(e,null)}function Hr(e){var t=0,n=0,r=e.children,i=r.length,s;while(--i>=0)s=r[i]._tree,s.prelim+=t,s.mod+=t,t+=s.shift+(n+=s.change)}function Br(e,t,n){e=e._tree,t=t._tree;var r=n/(t.number-e.number);e.change+=r,t.change-=r,t.shift+=n,t.prelim+=n,t.mod+=n}function jr(e,t,n){return e._tree.ancestor.parent==t.parent?e._tree.ancestor:n}function Fr(e){return{x:e.x,y:e.y,dx:e.dx,dy:e.dy}}function Ir(e,t){var n=e.x+t[3],r=e.y+t[0],i=e.dx-t[1]-t[3],s=e.dy-t[0]-t[2];return i<0&&(n+=i/2,i=0),s<0&&(r+=s/2,s=0),{x:n,y:r,dx:i,dy:s}}function qr(e,t){function n(e,r){d3.text(e,t,function(e){r(e&&n.parse(e))})}function r(t){return t.map(i).join(e)}function i(e){return o.test(e)?'"'+e.replace(/\"/g,'""')+'"':e}var s=new RegExp("\r\n|["+e+"\r\n]","g"),o=new RegExp('["'+e+"\n]"),u=e.charCodeAt(0);return n.parse=function(e){var t;return n.parseRows(e,function(e,n){if(n){var r={},i=-1,s=t.length;while(++i<s)r[t[i]]=e[i];return r}return t=e,null})},n.parseRows=function(e,t){function n(){if(s.lastIndex>=e.length)return i;if(l)return l=!1,r;var t=s.lastIndex;if(e.charCodeAt(t)===34){var n=t;while(n++<e.length)if(e.charCodeAt(n)===34){if(e.charCodeAt(n+1)!==34)break;n++}s.lastIndex=n+2;var o=e.charCodeAt(n+1);return o===13?(l=!0,e.charCodeAt(n+2)===10&&s.lastIndex++):o===10&&(l=!0),e.substring(t+1,n).replace(/""/g,'"')}var a=s.exec(e);return a?(l=a[0].charCodeAt(0)!==u,e.substring(t,a.index)):(s.lastIndex=e.length,e.substring(t))}var r={},i={},o=[],a=0,f,l;s.lastIndex=0;while((f=n())!==i){var c=[];while(f!==r&&f!==i)c.push(f),f=n();if(t&&!(c=t(c,a++)))continue;o.push(c)}return o},n.format=function(e){return e.map(r).join("\n")},n}function Rr(e,t){return function(n){return n&&e.hasOwnProperty(n.type)?e[n.type](n):t}}function Ur(e){return"m0,"+e+"a"+e+","+e+" 0 1,1 0,"+ -2*e+"a"+e+","+e+" 0 1,1 0,"+2*e+"z"}function zr(e,t){fo.hasOwnProperty(e.type)&&fo[e.type](e,t)}function Wr(e,t){zr(e.geometry,t)}function Xr(e,t){for(var n=e.features,r=0,i=n.length;r<i;r++)zr(n[r].geometry,t)}function Vr(e,t){for(var n=e.geometries,r=0,i=n.length;r<i;r++)zr(n[r],t)}function $r(e,t){for(var n=e.coordinates,r=0,i=n.length;r<i;r++)t.apply(null,n[r])}function Jr(e,t){for(var n=e.coordinates,r=0,i=n.length;r<i;r++)for(var s=n[r],o=0,u=s.length;o<u;o++)t.apply(null,s[o])}function Kr(e,t){for(var n=e.coordinates,r=0,i=n.length;r<i;r++)for(var s=n[r][0],o=0,u=s.length;o<u;o++)t.apply(null,s[o])}function Qr(e,t){t.apply(null,e.coordinates)}function Gr(e,t){for(var n=e.coordinates[0],r=0,i=n.length;r<i;r++)t.apply(null,n[r])}function Yr(e){return e.source}function Zr(e){return e.target}function ei(){function e(e){var t=Math.sin(e*=p)*d,n=Math.sin(p-e)*d,r=n*s+t*c,u=n*o+t*h,a=n*i+t*l;return[Math.atan2(u,r)/ao,Math.atan2(a,Math.sqrt(r*r+u*u))/ao]}var t,n,r,i,s,o,u,a,f,l,c,h,p,d;return e.distance=function(){return p==null&&(d=1/Math.sin(p=Math.acos(Math.max(-1,Math.min(1,i*l+r*f*Math.cos(u-t)))))),p},e.source=function(u){var a=Math.cos(t=u[0]*ao),f=Math.sin(t);return r=Math.cos(n=u[1]*ao),i=Math.sin(n),s=r*a,o=r*f,p=null,e},e.target=function(t){var n=Math.cos(u=t[0]*ao),r=Math.sin(u);return f=Math.cos(a=t[1]*ao),l=Math.sin(a),c=f*n,h=f*r,p=null,e},e}function ti(e,t){var n=ei().source(e).target(t);return n.distance(),n}function ni(e){var t=0,n=0;for(;;){if(e(t,n))return[t,n];t===0?(t=n+1,n=0):(t-=1,n+=1)}}function ri(e,t,n,r){var i,s,o,u,a,f,l;return i=r[e],s=i[0],o=i[1],i=r[t],u=i[0],a=i[1],i=r[n],f=i[0],l=i[1],(l-o)*(u-s)-(a-o)*(f-s)>0}function ii(e,t,n){return(n[0]-t[0])*(e[1]-t[1])<(n[1]-t[1])*(e[0]-t[0])}function si(e,t,n,r){var i=e[0],s=t[0],o=n[0],u=r[0],a=e[1],f=t[1],l=n[1],c=r[1],h=i-o,p=s-i,d=u-o,v=a-l,m=f-a,g=c-l,y=(d*v-g*h)/(g*p-d*m);return[i+y*p,a+y*m]}function oi(e,t){var n={list:e.map(function(e,t){return{index:t,x:e[0],y:e[1]}}).sort(function(e,t){return e.y<t.y?-1:e.y>t.y?1:e.x<t.x?-1:e.x>t.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(e,t){return{edge:e,side:t,vertex:null,l:null,r:null}},insert:function(e,t){t.l=e,t.r=e.r,e.r.l=t,e.r=t},leftBound:function(e){var t=r.leftEnd;do t=t.r;while(t!=r.rightEnd&&i.rightOf(t,e));return t=t.l,t},del:function(e){e.l.r=e.r,e.r.l=e.l,e.edge=null},right:function(e){return e.r},left:function(e){return e.l},leftRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[e.side]},rightRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[ho[e.side]]}},i={bisect:function(e,t){var n={region:{l:e,r:t},ep:{l:null,r:null}},r=t.x-e.x,i=t.y-e.y,s=r>0?r:-r,o=i>0?i:-i;return n.c=e.x*r+e.y*i+(r*r+i*i)*.5,s>o?(n.a=1,n.b=i/r,n.c/=r):(n.b=1,n.a=r/i,n.c/=i),n},intersect:function(e,t){var n=e.edge,r=t.edge;if(!n||!r||n.region.r==r.region.r)return null;var i=n.a*r.b-n.b*r.a;if(Math.abs(i)<1e-10)return null;var s=(n.c*r.b-r.c*n.b)/i,o=(r.c*n.a-n.c*r.a)/i,u=n.region.r,a=r.region.r,f,l;u.y<a.y||u.y==a.y&&u.x<a.x?(f=e,l=n):(f=t,l=r);var c=s>=l.region.r.x;return c&&f.side==="l"||!c&&f.side==="r"?null:{x:s,y:o}},rightOf:function(e,t){var n=e.edge,r=n.region.r,i=t.x>r.x;if(i&&e.side==="l")return 1;if(!i&&e.side==="r")return 0;if(n.a===1){var s=t.y-r.y,o=t.x-r.x,u=0,a=0;!i&&n.b<0||i&&n.b>=0?a=u=s>=n.b*o:(a=t.x+t.y*n.b>n.c,n.b<0&&(a=!a),a||(u=1));if(!u){var f=r.x-n.region.l.x;a=n.b*(o*o-s*s)<f*s*(1+2*o/f+n.b*n.b),n.b<0&&(a=!a)}}else{var l=n.c-n.a*t.x,c=t.y-l,h=t.x-r.x,p=l-r.y;a=c*c>h*h+p*p}return e.side==="l"?a:!a},endPoint:function(e,n,r){e.ep[n]=r;if(!e.ep[ho[n]])return;t(e)},distance:function(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}},s={list:[],insert:function(e,t,n){e.vertex=t,e.ystar=t.y+n;for(var r=0,i=s.list,o=i.length;r<o;r++){var u=i[r];if(e.ystar>u.ystar||e.ystar==u.ystar&&t.x>u.vertex.x)continue;break}i.splice(r,0,e)},del:function(e){for(var t=0,n=s.list,r=n.length;t<r&&n[t]!=e;++t);n.splice(t,1)},empty:function(){return s.list.length===0},nextEvent:function(e){for(var t=0,n=s.list,r=n.length;t<r;++t)if(n[t]==e)return n[t+1];return null},min:function(){var e=s.list[0];return{x:e.vertex.x,y:e.ystar}},extractMin:function(){return s.list.shift()}};r.init(),n.bottomSite=n.list.shift();var o=n.list.shift(),u,a,f,l,c,h,p,d,v,m,g,y,b;for(;;){s.empty()||(u=s.min());if(o&&(s.empty()||o.y<u.y||o.y==u.y&&o.x<u.x))a=r.leftBound(o),f=r.right(a),p=r.rightRegion(a),y=i.bisect(p,o),h=r.createHalfEdge(y,"l"),r.insert(a,h),m=i.intersect(a,h),m&&(s.del(a),s.insert(a,m,i.distance(m,o))),a=h,h=r.createHalfEdge(y,"r"
+),r.insert(a,h),m=i.intersect(h,f),m&&s.insert(h,m,i.distance(m,o)),o=n.list.shift();else{if(!!s.empty())break;a=s.extractMin(),l=r.left(a),f=r.right(a),c=r.right(f),p=r.leftRegion(a),d=r.rightRegion(f),g=a.vertex,i.endPoint(a.edge,a.side,g),i.endPoint(f.edge,f.side,g),r.del(a),s.del(f),r.del(f),b="l",p.y>d.y&&(v=p,p=d,d=v,b="r"),y=i.bisect(p,d),h=r.createHalfEdge(y,b),r.insert(l,h),i.endPoint(y,ho[b],g),m=i.intersect(l,h),m&&(s.del(l),s.insert(l,m,i.distance(m,p))),m=i.intersect(h,c),m&&s.insert(h,m,i.distance(m,p))}}for(a=r.right(r.leftEnd);a!=r.rightEnd;a=r.right(a))t(a.edge)}function ui(){return{leaf:!0,nodes:[],point:null}}function ai(e,t,n,r,i,s){if(!e(t,n,r,i,s)){var o=(n+i)*.5,u=(r+s)*.5,a=t.nodes;a[0]&&ai(e,a[0],n,r,o,u),a[1]&&ai(e,a[1],o,r,i,u),a[2]&&ai(e,a[2],n,u,o,s),a[3]&&ai(e,a[3],o,u,i,s)}}function fi(e){return{x:e[0],y:e[1]}}function li(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function ci(e){return e.substring(0,3)}function hi(e,t,n,r){var i,s,o=0,u=t.length,a=n.length;while(o<u){if(r>=a)return-1;i=t.charCodeAt(o++);if(i==37){s=Ho[t.charAt(o++)];if(!s||(r=s(e,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}function pi(e){return new RegExp("^(?:"+e.map(d3.requote).join("|")+")","i")}function di(e){var t=new r,n=-1,i=e.length;while(++n<i)t.set(e[n].toLowerCase(),n);return t}function vi(e,t,n){Ao.lastIndex=0;var r=Ao.exec(t.substring(n));return r?n+=r[0].length:-1}function mi(e,t,n){Lo.lastIndex=0;var r=Lo.exec(t.substring(n));return r?n+=r[0].length:-1}function gi(e,t,n){_o.lastIndex=0;var r=_o.exec(t.substring(n));return r?(e.m=Do.get(r[0].toLowerCase()),n+=r[0].length):-1}function yi(e,t,n){Oo.lastIndex=0;var r=Oo.exec(t.substring(n));return r?(e.m=Mo.get(r[0].toLowerCase()),n+=r[0].length):-1}function bi(e,t,n){return hi(e,Po.c.toString(),t,n)}function wi(e,t,n){return hi(e,Po.x.toString(),t,n)}function Ei(e,t,n){return hi(e,Po.X.toString(),t,n)}function Si(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+4));return r?(e.y=+r[0],n+=r[0].length):-1}function xi(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.y=Ti(+r[0]),n+=r[0].length):-1}function Ti(e){return e+(e>68?1900:2e3)}function Ni(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.m=r[0]-1,n+=r[0].length):-1}function Ci(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.d=+r[0],n+=r[0].length):-1}function ki(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.H=+r[0],n+=r[0].length):-1}function Li(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.M=+r[0],n+=r[0].length):-1}function Ai(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.S=+r[0],n+=r[0].length):-1}function Oi(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+3));return r?(e.L=+r[0],n+=r[0].length):-1}function Mi(e,t,n){var r=jo.get(t.substring(n,n+=2).toLowerCase());return r==null?-1:(e.p=r,n)}function _i(e){var t=e.getTimezoneOffset(),n=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return n+To(r)+To(i)}function Di(e){return e.toISOString()}function Pi(e,t,n){function r(t){var n=e(t),r=s(n,1);return t-n<r-t?n:r}function i(n){return t(n=e(new po(n-1)),1),n}function s(e,n){return t(e=new po(+e),n),e}function o(e,r,s){var o=i(e),u=[];if(s>1)while(o<r)n(o)%s||u.push(new Date(+o)),t(o,1);else while(o<r)u.push(new Date(+o)),t(o,1);return u}function u(e,t,n){try{po=li;var r=new li;return r._=e,o(r,t,n)}finally{po=Date}}e.floor=e,e.round=r,e.ceil=i,e.offset=s,e.range=o;var a=e.utc=Hi(e);return a.floor=a,a.round=Hi(r),a.ceil=Hi(i),a.offset=Hi(s),a.range=u,e}function Hi(e){return function(t,n){try{po=li;var r=new li;return r._=t,e(r,n)._}finally{po=Date}}}function Bi(e,t,n){function r(t){return e(t)}return r.invert=function(t){return Fi(e.invert(t))},r.domain=function(t){return arguments.length?(e.domain(t),r):e.domain().map(Fi)},r.nice=function(e){return r.domain(Dt(r.domain(),function(){return e}))},r.ticks=function(n,i){var s=ji(r.domain());if(typeof n!="function"){var o=s[1]-s[0],u=o/n,a=d3.bisect(Io,u);if(a==Io.length)return t.year(s,n);if(!a)return e.ticks(n).map(Fi);Math.log(u/Io[a-1])<Math.log(Io[a]/u)&&--a,n=t[a],i=n[1],n=n[0].range}return n(s[0],new Date(+s[1]+1),i)},r.tickFormat=function(){return n},r.copy=function(){return Bi(e.copy(),t,n)},d3.rebind(r,e,"range","rangeRound","interpolate","clamp")}function ji(e){var t=e[0],n=e[e.length-1];return t<n?[t,n]:[n,t]}function Fi(e){return new Date(e)}function Ii(e){return function(t){var n=e.length-1,r=e[n];while(!r[1](t))r=e[--n];return r[0](t)}}function qi(e){var t=new Date(e,0,1);return t.setFullYear(e),t}function Ri(e){var t=e.getFullYear(),n=qi(t),r=qi(t+1);return t+(e-n)/(r-n)}function Ui(e){var t=new Date(Date.UTC(e,0,1));return t.setUTCFullYear(e),t}function zi(e){var t=e.getUTCFullYear(),n=Ui(t),r=Ui(t+1);return t+(e-n)/(r-n)}Date.now||(Date.now=function(){return+(new Date)});try{document.createElement("div").style.setProperty("opacity",0,"")}catch(Wi){var Xi=CSSStyleDeclaration.prototype,Vi=Xi.setProperty;Xi.setProperty=function(e,t,n){Vi.call(this,e,t+"",n)}}d3={version:"2.10.1"};var $i=n;try{$i(document.documentElement.childNodes)[0].nodeType}catch(Ji){$i=t}var Ki=[].__proto__?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)e[n]=t[n]};d3.map=function(e){var t=new r;for(var n in e)t.set(n,e[n]);return t},e(r,{has:function(e){return Qi+e in this},get:function(e){return this[Qi+e]},set:function(e,t){return this[Qi+e]=t},remove:function(e){return e=Qi+e,e in this&&delete this[e]},keys:function(){var e=[];return this.forEach(function(t){e.push(t)}),e},values:function(){var e=[];return this.forEach(function(t,n){e.push(n)}),e},entries:function(){var e=[];return this.forEach(function(t,n){e.push({key:t,value:n})}),e},forEach:function(e){for(var t in this)t.charCodeAt(0)===Gi&&e.call(this,t.substring(1),this[t])}});var Qi="\0",Gi=Qi.charCodeAt(0);d3.functor=u,d3.rebind=function(e,t){var n=1,r=arguments.length,i;while(++n<r)e[i=arguments[n]]=a(e,t,t[i]);return e},d3.ascending=function(e,t){return e<t?-1:e>t?1:e>=t?0:NaN},d3.descending=function(e,t){return t<e?-1:t>e?1:t>=e?0:NaN},d3.mean=function(e,t){var n=e.length,r,i=0,s=-1,o=0;if(arguments.length===1)while(++s<n)f(r=e[s])&&(i+=(r-i)/++o);else while(++s<n)f(r=t.call(e,e[s],s))&&(i+=(r-i)/++o);return o?i:undefined},d3.median=function(e,t){return arguments.length>1&&(e=e.map(t)),e=e.filter(f),e.length?d3.quantile(e.sort(d3.ascending),.5):undefined},d3.min=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++n<r&&((i=e[n])==null||i!=i))i=undefined;while(++n<r)(s=e[n])!=null&&i>s&&(i=s)}else{while(++n<r&&((i=t.call(e,e[n],n))==null||i!=i))i=undefined;while(++n<r)(s=t.call(e,e[n],n))!=null&&i>s&&(i=s)}return i},d3.max=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++n<r&&((i=e[n])==null||i!=i))i=undefined;while(++n<r)(s=e[n])!=null&&s>i&&(i=s)}else{while(++n<r&&((i=t.call(e,e[n],n))==null||i!=i))i=undefined;while(++n<r)(s=t.call(e,e[n],n))!=null&&s>i&&(i=s)}return i},d3.extent=function(e,t){var n=-1,r=e.length,i,s,o;if(arguments.length===1){while(++n<r&&((i=o=e[n])==null||i!=i))i=o=undefined;while(++n<r)(s=e[n])!=null&&(i>s&&(i=s),o<s&&(o=s))}else{while(++n<r&&((i=o=t.call(e,e[n],n))==null||i!=i))i=undefined;while(++n<r)(s=t.call(e,e[n],n))!=null&&(i>s&&(i=s),o<s&&(o=s))}return[i,o]},d3.random={normal:function(e,t){var n=arguments.length;return n<2&&(t=1),n<1&&(e=0),function(){var n,r,i;do n=Math.random()*2-1,r=Math.random()*2-1,i=n*n+r*r;while(!i||i>1);return e+t*n*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(e,t){var n=arguments.length;n<2&&(t=1),n<1&&(e=0);var r=d3.random.normal();return function(){return Math.exp(e+t*r())}},irwinHall:function(e){return function(){for(var t=0,n=0;n<e;n++)t+=Math.random();return t/e}}},d3.sum=function(e,t){var n=0,r=e.length,i,s=-1;if(arguments.length===1)while(++s<r)isNaN(i=+e[s])||(n+=i);else while(++s<r)isNaN(i=+t.call(e,e[s],s))||(n+=i);return n},d3.quantile=function(e,t){var n=(e.length-1)*t+1,r=Math.floor(n),i=e[r-1],s=n-r;return s?i+s*(e[r]-i):i},d3.transpose=function(e){return d3.zip.apply(d3,e)},d3.zip=function(){if(!(i=arguments.length))return[];for(var e=-1,t=d3.min(arguments,l),n=new Array(t);++e<t;)for(var r=-1,i,s=n[e]=new Array(i);++r<i;)s[r]=arguments[r][e];return n},d3.bisector=function(e){return{left:function(t,n,r,i){arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);while(r<i){var s=r+i>>>1;e.call(t,t[s],s)<n?r=s+1:i=s}return r},right:function(t,n,r,i){arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);while(r<i){var s=r+i>>>1;n<e.call(t,t[s],s)?i=s:r=s+1}return r}}};var Yi=d3.bisector(function(e){return e});d3.bisectLeft=Yi.left,d3.bisect=d3.bisectRight=Yi.right,d3.first=function(e,t){var n=0,r=e.length,i=e[0],s;arguments.length===1&&(t=d3.ascending);while(++n<r)t.call(e,i,s=e[n])>0&&(i=s);return i},d3.last=function(e,t){var n=0,r=e.length,i=e[0],s;arguments.length===1&&(t=d3.ascending);while(++n<r)t.call(e,i,s=e[n])<=0&&(i=s);return i},d3.nest=function(){function e(t,s){if(s>=i.length)return u?u.call(n,t):o?t.sort(o):t;var a=-1,f=t.length,l=i[s++],c,h,p=new r,d,v={};while(++a<f)(d=p.get(c=l(h=t[a])))?d.push(h):p.set(c,[h]);return p.forEach(function(t,n){v[t]=e(n,s)}),v}function t(e,n){if(n>=i.length)return e;var r=[],o=s[n++],u;for(u in e)r.push({key:u,values:t(e[u],n)});return o&&r.sort(function(e,t){return o(e.key,t.key)}),r}var n={},i=[],s=[],o,u;return n.map=function(t){return e(t,0)},n.entries=function(n){return t(e(n,0),0)},n.key=function(e){return i.push(e),n},n.sortKeys=function(e){return s[i.length-1]=e,n},n.sortValues=function(e){return o=e,n},n.rollup=function(e){return u=e,n},n},d3.keys=function(e){var t=[];for(var n in e)t.push(n);return t},d3.values=function(e){var t=[];for(var n in e)t.push(e[n]);return t},d3.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},d3.permute=function(e,t){var n=[],r=-1,i=t.length;while(++r<i)n[r]=e[t[r]];return n},d3.merge=function(e){return Array.prototype.concat.apply([],e)},d3.split=function(e,t){var n=[],r=[],i,s=-1,o=e.length;arguments.length<2&&(t=c);while(++s<o)t.call(r,i=e[s],s)?r=[]:(r.length||n.push(r),r.push(i));return n},d3.range=function(e,t,n){arguments.length<3&&(n=1,arguments.length<2&&(t=e,e=0));if((t-e)/n===Infinity)throw new Error("infinite range");var r=[],i=p(Math.abs(n)),s=-1,o;e*=i,t*=i,n*=i;if(n<0)while((o=e+n*++s)>t)r.push(o/i);else while((o=e+n*++s)<t)r.push(o/i);return r},d3.requote=function(e){return e.replace(Zi,"\\$&")};var Zi=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;d3.round=function(e,t){return t?Math.round(e*(t=Math.pow(10,t)))/t:Math.round(e)},d3.xhr=function(e,t,n){var r=new XMLHttpRequest;arguments.length<3?(n=t,t=null):t&&r.overrideMimeType&&r.overrideMimeType(t),r.open("GET",e,!0),t&&r.setRequestHeader("Accept",t),r.onreadystatechange=function(){if(r.readyState===4){var e=r.status;n(!e&&r.response||e>=200&&e<300||e===304?r:null)}},r.send(null)},d3.text=function(e,t,n){function r(e){n(e&&e.responseText)}arguments.length<3&&(n=t,t=null),d3.xhr(e,t,r)},d3.json=function(e,t){d3.text(e,"application/json",function(e){t(e?JSON.parse(e):null)})},d3.html=function(e,t){d3.text(e,"text/html",function(e){if(e!=null){var n=document.createRange();n.selectNode(document.body),e=n.createContextualFragment(e)}t(e)})},d3.xml=function(e,t,n){function r(e){n(e&&e.responseXML)}arguments.length<3&&(n=t,t=null),d3.xhr(e,t,r)};var es={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};d3.ns={prefix:es,qualify:function(e){var t=e.indexOf(":"),n=e;return t>=0&&(n=e.substring(0,t),e=e.substring(t+1)),es.hasOwnProperty(n)?{space:es[n],local:e}:e}},d3.dispatch=function(){var e=new d,t=-1,n=arguments.length;while(++t<n)e[arguments[t]]=v(e);return e},d.prototype.on=function(e,t){var n=e.indexOf("."),r="";return n>0&&(r=e.substring(n+1),e=e.substring(0,n)),arguments.length<2?this[e].on(r):this[e].on(r,t)},d3.format=function(e){var t=ts.exec(e),n=t[1]||" ",r=t[3]||"",i=t[5],s=+t[6],o=t[7],u=t[8],a=t[9],f=1,l="",c=!1;u&&(u=+u.substring(1)),i&&(n="0",o&&(s-=Math.floor((s-1)/4)));switch(a){case"n":o=!0,a="g";break;case"%":f=100,l="%",a="f";break;case"p":f=100,l="%",a="r";break;case"d":c=!0,u=0;break;case"s":f=-1,a="r"}return a=="r"&&!u&&(a="g"),a=ns.get(a)||g,function(e){if(c&&e%1)return"";var t=e<0&&(e=-e)?"-":r;if(f<0){var h=d3.formatPrefix(e,u);e=h.scale(e),l=h.symbol}else e*=f;e=a(e,u);if(i){var p=e.length+t.length;p<s&&(e=(new Array(s-p+1)).join(n)+e),o&&(e=y(e)),e=t+e}else{o&&(e=y(e)),e=t+e;var p=e.length;p<s&&(e=(new Array(s-p+1)).join(n)+e)}return e+l}};var ts=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,ns=d3.map({g:function(e,t){return e.toPrecision(t)},e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},r:function(e,t){return d3.round(e,t=m(e,t)).toFixed(Math.max(0,Math.min(20,t)))}}),rs=["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(b);d3.formatPrefix=function(e,t){var n=0;return e&&(e<0&&(e*=-1),t&&(e=d3.round(e,m(e,t))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,Math.floor((n<=0?n+1:n-1)/3)*3))),rs[8+n/3]};var is=T(2),ss=T(3),os=function(){return x},us=d3.map({linear:os,poly:T,quad:function(){return is},cubic:function(){return ss},sin:function(){return N},exp:function(){return C},circle:function(){return k},elastic:L,back:A,bounce:function(){return O}}),as=d3.map({"in":x,out:E,"in-out":S,"out-in":function(e){return S(E(e))}});d3.ease=function(e){var t=e.indexOf("-"),n=t>=0?e.substring(0,t):e,r=t>=0?e.substring(t+1):"in";return n=us.get(n)||os,r=as.get(r)||x,w(r(n.apply(null,Array.prototype.slice.call(arguments,1))))},d3.event=null,d3.transform=function(e){var t=document.createElementNS(d3.ns.prefix.svg,"g");return(d3.transform=function(e){t.setAttribute("transform",e);var n=t.transform.baseVal.consolidate();return new P(n?n.matrix:ls)})(e)},P.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var fs=180/Math.PI,ls={a:1,b:0,c:0,d:1,e:0,f:0};d3.interpolate=function(e,t){var n=d3.interpolators.length,r;while(--n>=0&&!(r=d3.interpolators[n](e,t)));return r},d3.interpolateNumber=function(e,t){return t-=e,function(n){return e+t*n}},d3.interpolateRound=function(e,t){return t-=e,function(n){return Math.round(e+t*n)}},d3.interpolateString=function(e,t){var n,r,i,s=0,o=0,u=[],a=[],f,l;cs.lastIndex=0;for(r=0;n=cs.exec(t);++r)n.index&&u.push(t.substring(s,o=n.index)),a.push({i:u.length,x:n[0]}),u.push(null),s=cs.lastIndex;s<t.length&&u.push(t.substring(s));for(r=0,f=a.length;(n=cs.exec(e))&&r<f;++r){l=a[r];if(l.x==n[0]){if(l.i)if(u[l.i+1]==null){u[l.i-1]+=l.x,u.splice(l.i,1);for(i=r+1;i<f;++i)a[i].i--}else{u[l.i-1]+=l.x+u[l.i+1],u.splice(l.i,2);for(i=r+1;i<f;++i)a[i].i-=2}else if(u[l.i+1]==null)u[l.i]=l.x;else{u[l.i]=l.x+u[l.i+1],u.splice(l.i+1,1);for(i=r+1;i<f;++i)a[i].i--}a.splice(r,1),f--,r--}else l.x=d3.interpolateNumber(parseFloat(n[0]),parseFloat(l.x))}while(r<f)l=a.pop(),u[l.i+1]==null?u[l.i]=l.x:(u[l.i]=l.x+u[l.i+1],u.splice(l.i+1,1)),f--;return u.length===1?u[0]==null?a[0].x:function(){return t}:function(e){for(r=0;r<f;++r)u[(l=a[r]).i]=l.x(e);return u.join("")}},d3.interpolateTransform=function(e,t){var n=[],r=[],i,s=d3.transform(e),o=d3.transform(t),u=s.translate,a=o.translate,f=s.rotate,l=o.rotate,c=s.skew,h=o.skew,p=s.scale,d=o.scale;return u[0]!=a[0]||u[1]!=a[1]?(n.push("translate(",null,",",null,")"),r.push({i:1,x:d3.interpolateNumber(u[0],a[0])},{i:3,x:d3.interpolateNumber(u[1],a[1])})):a[0]||a[1]?n.push("translate("+a+")"):n.push(""),f!=l?(f-l>180?l+=360:l-f>180&&(f+=360),r.push({i:n.push(n.pop()+"rotate(",null,")")-2,x:d3.interpolateNumber(f,l)})):l&&n.push(n.pop()+"rotate("+l+")"),c!=h?r.push({i:n.push(n.pop()+"skewX(",null,")")-2,x:d3.interpolateNumber(c,h)}):h&&n.push(n.pop()+"skewX("+h+")"),p[0]!=d[0]||p[1]!=d[1]?(i=n.push(n.pop()+"scale(",null,",",null,")"),r.push({i:i-4,x:d3.interpolateNumber(p[0],d[0])},{i:i-2,x:d3.interpolateNumber(p[1],d[1])})):(d[0]!=1||d[1]!=1)&&n.push(n.pop()+"scale("+d+")"),i=r.length,function(e){var t=-1,s;while(++t<i)n[(s=r[t]).i]=s.x(e);return n.join("")}},d3.interpolateRgb=function(e,t){e=d3.rgb(e),t=d3.rgb(t);var n=e.r,r=e.g,i=e.b,s=t.r-n,o=t.g-r,u=t.b-i;return function(e){return"#"+z(Math.round(n+s*e))+z(Math.round(r+o*e))+z(Math.round(i+u*e))}},d3.interpolateHsl=function(e,t){e=d3.hsl(e),t=d3.hsl(t);var n=e.h,r=e.s,i=e.l,s=t.h-n,o=t.s-r,u=t.l-i;return s>180?s-=360:s<-180&&(s+=360),function(e){return G(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateLab=function(e,t){e=d3.lab(e),t=d3.lab(t);var n=e.l,r=e.a,i=e.b,s=t.l-n,o=t.a-r,u=t.b-i;return function(e){return rt(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateHcl=function(e,t){e=d3.hcl(e),t=d3.hcl(t);var n=e.h,r=e.c,i=e.l,s=t.h-n,o=t.c-r,u=t.l-i;return s>180?s-=360:s<-180&&(s+=360),function(e){return et(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateArray=function(e,t){var n=[],r=[],i=e.length,s=t.length,o=Math.min(e.length,t.length),u;for(u=0;u<o;++u)n.push(d3.interpolate(e[u],t[u]));for(;u<i;++u)r[u]=e[u];for(;u<s;++u)r[u]=t[u];return function(e){for(u=0;u<o;++u)r[u]=n[u](e);return r}},d3.interpolateObject=function(e,t){var n={},r={},i;for(i in e)i in t?n[i]=F(i)(e[i],t[i]):r[i]=e[i];for(i in t)i in e||(r[i]=t[i]);return function(e){for(i in n)r[i]=n[i](e);return r}};var cs=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;d3.interpolators=[d3.interpolateObject,function(e,t){return t instanceof Array&&d3.interpolateArray(e,t)},function(e,t){return(typeof e=="string"||typeof t=="string")&&d3.interpolateString(e+"",t+"")},function(e,t){return(typeof t=="string"?hs.has(t)||/^(#|rgb\(|hsl\()/.test(t):t instanceof U||t instanceof Q)&&d3.interpolateRgb(e,t)},function(e,t){return!isNaN(e=+e)&&!isNaN(t=+t)&&d3.interpolateNumber(e,t)}],d3.rgb=function(e,t,n){return arguments.length===1?e instanceof U?R(e.r,e.g,e.b):W(""+e,R,G):R(~~e,~~t,~~n)},U.prototype.brighter=function(e){e=Math.pow(.7,arguments.length?e:1);var t=this.r,n=this.g,r=this.b,i=30;return!t&&!n&&!r?R(i,i,i):(t&&t<i&&(t=i),n&&n<i&&(n=i),r&&r<i&&(r=i),R(Math.min(255,Math.floor(t/e)),Math.min(255,Math.floor(n/e)),Math.min(255,Math.floor(r/e))))},U.prototype.darker=function(e){return e=Math.pow(.7,arguments.length?e:1),R(Math.floor(e*this.r),Math.floor(e*this.g),Math.floor(e*this.b))},U.prototype.hsl=function(){return X(this.r,this.g,this.b)},U.prototype.toString=function(){return"#"+z(this.r)+z(this.g)+z(this.b)};var hs=d3.map({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});hs.forEach(function(e,t){hs.set(e,W(t,R,G))}),d3.hsl=function(e,t,n){return arguments.length===1?e instanceof Q?K(e.h,e.s,e.l):W(""+e,X,K):K(+e,+t,+n)},Q.prototype.brighter=function(e){return e=Math.pow(.7,arguments.length?e:1),K(this.h,this.s,this.l/e)},Q.prototype.darker=function(e){return e=Math.pow(.7,arguments.length?e:1),K(this.h,this.s,e*this.l)},Q.prototype.rgb=function(){return G(this.h,this.s,this.l)},Q.prototype.toString=function(){return this.rgb().toString()},d3.hcl=function(e,t,n){return arguments.length===1?e instanceof Z?Y(e.h,e.c,e.l):e instanceof nt?it(e.l,e.a,e.b):it((e=V((e=d3.rgb(e)).r,e.g,e.b)).l,e.a,e.b):Y(+e,+t,+n)},Z.prototype.brighter=function(e){return Y(this.h,this.c,Math.min(100,this.l+ps*(arguments.length?e:1)))},Z.prototype.darker=function(e){return Y(this.h,this.c,Math.max(0,this.l-ps*(arguments.length?e:1)))},Z.prototype.rgb=function(){return et(this.h,this.c,this.l).rgb()},Z.prototype.toString=function(){return this.rgb()+""},d3.lab=function(e,t,n){return arguments.length===1?e instanceof nt?tt(e.l,e.a,e.b):e instanceof Z?et(e.l,e.c,e.h):V((e=d3.rgb(e)).r,e.g,e.b):tt(+e,+t,+n)};var ps=18,ds=.95047,vs=1,ms=1.08883;nt.prototype.brighter=function(e){return tt(Math.min(100,this.l+ps*(arguments.length?e:1)),this.a,this.b)},nt.prototype.darker=function(e){return tt(Math.max(0,this.l-ps*(arguments.length?e:1)),this.a,this.b)},nt.prototype.rgb=function(){return rt(this.l,this.a,this.b)},nt.prototype.toString=function(){return this.rgb()+""};var gs=function(e,t){return t.querySelector(e)},ys=function(e,t){return t.querySelectorAll(e)},bs=document.documentElement,ws=bs.matchesSelector||bs.webkitMatchesSelector||bs.mozMatchesSelector||bs.msMatchesSelector||bs.oMatchesSelector,Es=function(e,t){return ws.call(e,t)};typeof Sizzle=="function"&&(gs=function(e,t){return Sizzle(e,t)[0]||null},ys=function(e,t){return Sizzle.uniqueSort(Sizzle(e,t))},Es=Sizzle.matchesSelector);var Ss=[];d3.selection=function(){return xs},d3.selection.prototype=Ss,Ss.select=function(e){var t=[],n,r,i,s;typeof e!="function"&&(e=ft(e));for(var o=-1,u=this.length;++o<u;){t.push(n=[]),n.parentNode=(i=this[o]).parentNode;for(var a=-1,f=i.length;++a<f;)(s=i[a])?(n.push(r=e.call(s,s.__data__,a)),r&&"__data__"in s&&(r.__data__=s.__data__)):n.push(null)}return at(t)},Ss.selectAll=function(e){var t=[],n,r;typeof e!="function"&&(e=lt(e));for(var i=-1,s=this.length;++i<s;)for(var o=this[i],u=-1,a=o.length;++u<a;)if(r=o[u])t.push(n=$i(e.call(r,r.__data__,u))),n.parentNode=r;return at(t)},Ss.attr=function(e,t){if(arguments.length<2){if(typeof e=="string"){var n=this.node();return e=d3.ns.qualify(e),e.local?n.getAttributeNS(e.space,e.local):n.getAttribute(e)}for(t in e)this.each(ct(t,e[t]));return this}return this.each(ct(e,t))},Ss.classed=function(e,t){if(arguments.length<2){if(typeof e=="string"){var n=this.node(),r=(e=e.trim().split(/^|\s+/g)).length,i=-1;if(t=n.classList){while(++i<r)if(!t.contains(e[i]))return!1}else{t=n.className,t.baseVal!=null&&(t=t.baseVal);while(++i<r)if(!ht(e[i]).test(t))return!1}return!0}for(t in e)this.each(pt(t,e[t]));return this}return this.each(pt(e,t))},Ss.style=function(e,t,n){var r=arguments.length;if(r<3){if(typeof e!="string"){r<2&&(t="");for(n in e)this.each(vt(n,e[n],t));return this}if(r<2)return window.getComputedStyle(this.node(),null).getPropertyValue(e);n=""}return this.each(vt(e,t,n))},Ss.property=function(e,t){if(arguments.length<2){if(typeof e=="string")return this.node()[e];for(t in e)this.each(mt(t,e[t]));return this}return this.each(mt(e,t))},Ss.text=function(e){return arguments.length<1?this.node().textContent:this.each(typeof e=="function"?function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}:e==null?function(){this.textContent=""}:function(){this.textContent=e})},Ss.html=function(e){return arguments.length<1?this.node().innerHTML:this.each(typeof e=="function"?function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}:e==null?function(){this.innerHTML=""}:function(){this.innerHTML=e})},Ss.append=function(e){function t(){return this.appendChild(document.createElementNS(this.namespaceURI,e))}function n(){return this.appendChild(document.createElementNS(e.space,e.local))}return e=d3.ns.qualify(e),this.select(e.local?n:t)},Ss.insert=function(e,t){function n(){return this.insertBefore(document.createElementNS(this.namespaceURI,e),gs(t,this))}function r(){return this.insertBefore(document.createElementNS(e.space,e.local),gs(t,this))}return e=d3.ns.qualify(e),this.select(e.local?r:n)},Ss.remove=function(){return this.each(function(){var e=this.parentNode;e&&e.removeChild(this)})},Ss.data=function(e,t){function n(e,n){var i,s=e.length,o=n.length,u=Math.min(s,o),c=Math.max(s,o),h=[],p=[],d=[],v,m;if(t){var g=new r,y=[],b,w=n.length;for(i=-1;++i<s;)b=t.call(v=e[i],v.__data__,i),g.has(b)?d[w++]=v:g.set(b,v),y.push(b);for(i=-1;++i<o;)b=t.call(n,m=n[i],i),g.has(b)?(h[i]=v=g.get(b),v.__data__=m,p[i]=d[i]=null):(p[i]=gt(m),h[i]=d[i]=null),g.remove(b);for(i=-1;++i<s;)g.has(y[i])&&(d[i]=e[i])}else{for(i=-1;++i<u;)v=e[i],m=n[i],v?(v.__data__=m,h[i]=v,p[i]=d[i]=null):(p[i]=gt(m),h[i]=d[i]=null);for(;i<o;++i)p[i]=gt(n[i]),h[i]=d[i]=null;for(;i<c;++i)d[i]=e[i],p[i]=h[i]=null}p.update=h,p.parentNode=h.parentNode=d.parentNode=e.parentNode,a.push(p),f.push(h),l.push(d)}var i=-1,s=this.length,o,u;if(!arguments.length){e=new Array(s=(o=this[0]).length);while(++i<s)if(u=o[i])e[i]=u.__data__;return e}var a=St([]),f=at([]),l=at([]);if(typeof e=="function")while(++i<s)n(o=this[i],e.call(o,o.parentNode.__data__,i));else while(++i<s)n(o=this[i],e);return f.enter=function(){return a},f.exit=function(){return l},f},Ss.datum=Ss.map=function(e){return arguments.length<1?this.property("__data__"):this.property("__data__",e)},Ss.filter=function(e){var t=[],n,r,i;typeof e!="function"&&(e=yt(e));for(var s=0,o=this.length;s<o;s++){t.push(n=[]),n.parentNode=(r=this[s]).parentNode;for(var u=0,a=r.length;u<a;u++)(i=r[u])&&e.call(i,i.__data__,u)&&n.push(i)}return at(t)},Ss.order=function(){for(var e=-1,t=this.length;++e<t;)for(var n=this[e],r=n.length-1,i=n[r],s;--r>=0;)if(s=n[r])i&&i!==s.nextSibling&&i.parentNode.insertBefore(s,i),i=s;return this},Ss.sort=function(e){e=bt.apply(this,arguments);for(var t=-1,n=this.length;++t<n;)this[t].sort(e);return this.order()},Ss.on=function(e,t,n){var r=arguments.length;if(r<3){if(typeof e!="string"){r<2&&(t=!1);for(n in e)this.each(wt(n,e[n],t));return this}if(r<2)return(r=this.node()["__on"+e])&&r._;n=!1}return this.each(wt(e,t,n))},Ss.each=function(e){return Et(this,function(t,n,r){e.call(t,t.__data__,n,r)})},Ss.call=function(e){return e.apply(this,(arguments[0]=this,arguments)),this},Ss.empty=function(){return!this.node()},Ss.node=function(e){for(var t=0,n=this.length;t<n;t++)for(var r=this[t],i=0,s=r.length;i<s;i++){var o=r[i];if(o)return o}return null},Ss.transition=function(){var e=[],t,n;for(var r=-1,i=this.length;++r<i;){e.push(t=[]);for(var s=this[r],o=-1,u=s.length;++o<u;)t.push((n=s[o])?{node:n,delay:Ms,duration:_s}:null)}return xt(e,ks||++Cs,Date.now())};var xs=at([[document]]);xs[0].parentNode=bs,d3.select=function(e){return typeof e=="string"?xs.select(e):at([[e]])},d3.selectAll=function(e){return typeof e=="string"?xs.selectAll(e):at([$i(e)])};var Ts=[];d3.selection.enter=St,d3.selection.enter.prototype=Ts,Ts.append=Ss.append,Ts.insert=Ss.insert,Ts.empty=Ss.empty,Ts.node=Ss.node,Ts.select=function(e){var t=[],n,r,i,s,o;for(var u=-1,a=this.length;++u<a;){i=(s=this[u]).update,t.push(n=[]),n.parentNode=s.parentNode;for(var f=-1,l=s.length;++f<l;)(o=s[f])?(n.push(i[f]=r=e.call(s.parentNode,o.__data__,f)),r.__data__=o.__data__):n.push(null)}return at(t)};var Ns=[],Cs=0,ks=0,Ls=0,As=250,Os=d3.ease("cubic-in-out"),Ms=Ls,_s=As,Ds=Os;Ns.call=Ss.call,d3.transition=function(e){return arguments.length?ks?e.transition():e:xs.transition()},d3.transition.prototype=Ns,Ns.select=function(e){var t=[],n,r,i;typeof e!="function"&&(e=ft(e));for(var s=-1,o=this.length;++s<o;){t.push(n=[]);for(var u=this[s],a=-1,f=u.length;++a<f;)(i=u[a])&&(r=e.call(i.node,i.node.__data__,a))?("__data__"in i.node&&(r.__data__=i.node.__data__),n.push({node:r,delay:i.delay,duration:i.duration})):n.push(null)}return xt(t,this.id,this.time).ease(this.ease())},Ns.selectAll=function(e){var t=[],n,r,i;typeof e!="function"&&(e=lt(e));for(var s=-1,o=this.length;++s<o;)for(var u=this[s],a=-1,f=u.length;++a<f;)if(i=u[a]){r=e.call(i.node,i.node.__data__,a),t.push(n=[]);for(var l=-1,c=r.length;++l<c;)n.push({node:r[l],delay:i.delay,duration:i.duration})}return xt(t,this.id,this.time).ease(this.ease())},Ns.filter=function(e){var t=[],n,r,i;typeof e!="function"&&(e=yt(e));for(var s=0,o=this.length;s<o;s++){t.push(n=[]);for(var r=this[s],u=0,a=r.length;u<a;u++)(i=r[u])&&e.call(i.node,i.node.__data__,u)&&n.push(i)}return xt(t,this.id,this.time).ease(this.ease())},Ns.attr=function(e,t){if(arguments.length<2){for(t in e)this.attrTween(t,Ct(e[t],t));return this}return this.attrTween(e,Ct(t,e))},Ns.attrTween=function(e,t){function n(e,n){var r=t.call(this,e,n,this.getAttribute(i));return r===Ps?(this.removeAttribute(i),null):r&&function(e){this.setAttribute(i,r(e))}}function r(e,n){var r=t.call(this,e,n,this.getAttributeNS(i.space,i.local));return r===Ps?(this.removeAttributeNS(i.space,i.local),null):r&&function(e){this.setAttributeNS(i.space,i.local,r(e))}}var i=d3.ns.qualify(e);return this.tween("attr."+e,i.local?r:n)},Ns.style=function(e,t,n){var r=arguments.length;if(r<3){if(typeof e!="string"){r<2&&(t="");for(n in e)this.styleTween(n,Ct(e[n],n),t);return this}n=""}return this.styleTween(e,Ct(t,e),n)},Ns.styleTween=function(e,t,n){return arguments.length<3&&(n=""),this.tween("style."+e,function(r,i){var s=t.call(this,r,i,window.getComputedStyle(this,null).getPropertyValue(e));return s===Ps?(this.style.removeProperty(e),null):s&&function(t){this.style.setProperty(e,s(t),n)}})},Ns.text=function(e){return this.tween("text",function(t,n){this.textContent=typeof e=="function"?e.call(this,t,n):e})},Ns.remove=function(){return this.each("end.transition",function(){var e;!this.__transition__&&(e=this.parentNode)&&e.removeChild(this)})},Ns.delay=function(e){return Et(this,typeof e=="function"?function(t,n,r){t.delay=e.call(t=t.node,t.__data__,n,r)|0}:(e|=0,function(t){t.delay=e}))},Ns.duration=function(e){return Et(this,typeof e=="function"?function(t,n,r){t.duration=Math.max(1,e.call(t=t.node,t.__data__,n,r)|0)}:(e=Math.max(1,e|0),function(t){t.duration=e}))},Ns.transition=function(){return this.select(s)},d3.tween=function(e,t){function n(n,r,i){var s=e.call(this,n,r);return s==null?i!=""&&Ps:i!=s&&t(i,s)}function r(n,r,i){return i!=e&&t(i,e)}return typeof e=="function"?n:e==null?Nt:(e+="",r)};var Ps={},Hs=null,Bs,js;d3.timer=function(e,t,n){var r=!1,i,s=Hs;if(arguments.length<3){if(arguments.length<2)t=0;else if(!isFinite(t))return;n=Date.now()}while(s){if(s.callback===e){s.then=n,s.delay=t,r=!0;break}i=s,s=s.next}r||(Hs={callback:e,then:n,delay:t,next:Hs}),Bs||(js=clearTimeout(js),Bs=1,Fs(kt))},d3.timer.flush=function(){var e,t=Date.now(),n=Hs;while(n)e=t-n.then,n.delay||(n.flush=n.callback(e)),n=n.next;Lt()};var Fs=window.requestAnimationFrame||window.webkitRequestAnimationFrame||
+window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,17)};d3.mouse=function(e){return At(e,_())};var Is=/WebKit/.test(navigator.userAgent)?-1:0;d3.touches=function(e,t){return arguments.length<2&&(t=_().touches),t?$i(t).map(function(t){var n=At(e,t);return n.identifier=t.identifier,n}):[]},d3.scale={},d3.scale.linear=function(){return Ht([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return zt(d3.scale.linear(),Wt)};var qs=d3.format(".0e");Wt.pow=function(e){return Math.pow(10,e)},Xt.pow=function(e){return-Math.pow(10,-e)},d3.scale.pow=function(){return Vt(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return Jt([],{t:"range",a:[[]]})},d3.scale.category10=function(){return d3.scale.ordinal().range(Rs)},d3.scale.category20=function(){return d3.scale.ordinal().range(Us)},d3.scale.category20b=function(){return d3.scale.ordinal().range(zs)},d3.scale.category20c=function(){return d3.scale.ordinal().range(Ws)};var Rs=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Us=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],zs=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Ws=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return Kt([],[])},d3.scale.quantize=function(){return Qt(0,1,[0,1])},d3.scale.threshold=function(){return Gt([.5],[0,1])},d3.scale.identity=function(){return Yt([0,1])},d3.svg={},d3.svg.arc=function(){function e(){var e=t.apply(this,arguments),s=n.apply(this,arguments),o=r.apply(this,arguments)+Xs,u=i.apply(this,arguments)+Xs,a=(u<o&&(a=o,o=u,u=a),u-o),f=a<Math.PI?"0":"1",l=Math.cos(o),c=Math.sin(o),h=Math.cos(u),p=Math.sin(u);return a>=Vs?e?"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"M0,"+e+"A"+e+","+e+" 0 1,0 0,"+ -e+"A"+e+","+e+" 0 1,0 0,"+e+"Z":"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"Z":e?"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L"+e*h+","+e*p+"A"+e+","+e+" 0 "+f+",0 "+e*l+","+e*c+"Z":"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L0,0"+"Z"}var t=Zt,n=en,r=tn,i=nn;return e.innerRadius=function(n){return arguments.length?(t=u(n),e):t},e.outerRadius=function(t){return arguments.length?(n=u(t),e):n},e.startAngle=function(t){return arguments.length?(r=u(t),e):r},e.endAngle=function(t){return arguments.length?(i=u(t),e):i},e.centroid=function(){var e=(t.apply(this,arguments)+n.apply(this,arguments))/2,s=(r.apply(this,arguments)+i.apply(this,arguments))/2+Xs;return[Math.cos(s)*e,Math.sin(s)*e]},e};var Xs=-Math.PI/2,Vs=2*Math.PI-1e-6;d3.svg.line=function(){return rn(i)};var $s=d3.map({linear:un,"linear-closed":an,"step-before":fn,"step-after":ln,basis:mn,"basis-open":gn,"basis-closed":yn,bundle:bn,cardinal:pn,"cardinal-open":cn,"cardinal-closed":hn,monotone:Nn});$s.forEach(function(e,t){t.key=e,t.closed=/-closed$/.test(e)});var Js=[0,2/3,1/3,0],Ks=[0,1/3,2/3,0],Qs=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var e=rn(Cn);return e.radius=e.x,delete e.x,e.angle=e.y,delete e.y,e},fn.reverse=ln,ln.reverse=fn,d3.svg.area=function(){return kn(i)},d3.svg.area.radial=function(){var e=kn(Cn);return e.radius=e.x,delete e.x,e.innerRadius=e.x0,delete e.x0,e.outerRadius=e.x1,delete e.x1,e.angle=e.y,delete e.y,e.startAngle=e.y0,delete e.y0,e.endAngle=e.y1,delete e.y1,e},d3.svg.chord=function(){function e(e,u){var a=t(this,s,e,u),f=t(this,o,e,u);return"M"+a.p0+r(a.r,a.p1,a.a1-a.a0)+(n(a,f)?i(a.r,a.p1,a.r,a.p0):i(a.r,a.p1,f.r,f.p0)+r(f.r,f.p1,f.a1-f.a0)+i(f.r,f.p1,a.r,a.p0))+"Z"}function t(e,t,n,r){var i=t.call(e,n,r),s=a.call(e,i,r),o=f.call(e,i,r)+Xs,u=l.call(e,i,r)+Xs;return{r:s,a0:o,a1:u,p0:[s*Math.cos(o),s*Math.sin(o)],p1:[s*Math.cos(u),s*Math.sin(u)]}}function n(e,t){return e.a0==t.a0&&e.a1==t.a1}function r(e,t,n){return"A"+e+","+e+" 0 "+ +(n>Math.PI)+",1 "+t}function i(e,t,n,r){return"Q 0,0 "+r}var s=Ln,o=An,a=On,f=tn,l=nn;return e.radius=function(t){return arguments.length?(a=u(t),e):a},e.source=function(t){return arguments.length?(s=u(t),e):s},e.target=function(t){return arguments.length?(o=u(t),e):o},e.startAngle=function(t){return arguments.length?(f=u(t),e):f},e.endAngle=function(t){return arguments.length?(l=u(t),e):l},e},d3.svg.diagonal=function(){function e(e,i){var s=t.call(this,e,i),o=n.call(this,e,i),u=(s.y+o.y)/2,a=[s,{x:s.x,y:u},{x:o.x,y:u},o];return a=a.map(r),"M"+a[0]+"C"+a[1]+" "+a[2]+" "+a[3]}var t=Ln,n=An,r=Dn;return e.source=function(n){return arguments.length?(t=u(n),e):t},e.target=function(t){return arguments.length?(n=u(t),e):n},e.projection=function(t){return arguments.length?(r=t,e):r},e},d3.svg.diagonal.radial=function(){var e=d3.svg.diagonal(),t=Dn,n=e.projection;return e.projection=function(e){return arguments.length?n(Pn(t=e)):t},e},d3.svg.mouse=d3.mouse,d3.svg.touches=d3.touches,d3.svg.symbol=function(){function e(e,r){return(Gs.get(t.call(this,e,r))||jn)(n.call(this,e,r))}var t=Bn,n=Hn;return e.type=function(n){return arguments.length?(t=u(n),e):t},e.size=function(t){return arguments.length?(n=u(t),e):n},e};var Gs=d3.map({circle:jn,cross:function(e){var t=Math.sqrt(e/5)/2;return"M"+ -3*t+","+ -t+"H"+ -t+"V"+ -3*t+"H"+t+"V"+ -t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+ -t+"V"+t+"H"+ -3*t+"Z"},diamond:function(e){var t=Math.sqrt(e/(2*Zs)),n=t*Zs;return"M0,"+ -t+"L"+n+",0"+" 0,"+t+" "+ -n+",0"+"Z"},square:function(e){var t=Math.sqrt(e)/2;return"M"+ -t+","+ -t+"L"+t+","+ -t+" "+t+","+t+" "+ -t+","+t+"Z"},"triangle-down":function(e){var t=Math.sqrt(e/Ys),n=t*Ys/2;return"M0,"+n+"L"+t+","+ -n+" "+ -t+","+ -n+"Z"},"triangle-up":function(e){var t=Math.sqrt(e/Ys),n=t*Ys/2;return"M0,"+ -n+"L"+t+","+n+" "+ -t+","+n+"Z"}});d3.svg.symbolTypes=Gs.keys();var Ys=Math.sqrt(3),Zs=Math.tan(30*Math.PI/180);d3.svg.axis=function(){function e(e){e.each(function(){var e=d3.select(this),c=a==null?t.ticks?t.ticks.apply(t,u):t.domain():a,h=f==null?t.tickFormat?t.tickFormat.apply(t,u):String:f,p=qn(t,c,l),d=e.selectAll(".minor").data(p,String),v=d.enter().insert("line","g").attr("class","tick minor").style("opacity",1e-6),m=d3.transition(d.exit()).style("opacity",1e-6).remove(),g=d3.transition(d).style("opacity",1),y=e.selectAll("g").data(c,String),b=y.enter().insert("g","path").style("opacity",1e-6),w=d3.transition(y.exit()).style("opacity",1e-6).remove(),E=d3.transition(y).style("opacity",1),S,x=_t(t),T=e.selectAll(".domain").data([0]),N=T.enter().append("path").attr("class","domain"),C=d3.transition(T),k=t.copy(),L=this.__chart__||k;this.__chart__=k,b.append("line").attr("class","tick"),b.append("text");var A=b.select("line"),O=E.select("line"),M=y.select("text").text(h),_=b.select("text"),D=E.select("text");switch(n){case"bottom":S=Fn,v.attr("y2",i),g.attr("x2",0).attr("y2",i),A.attr("y2",r),_.attr("y",Math.max(r,0)+o),O.attr("x2",0).attr("y2",r),D.attr("x",0).attr("y",Math.max(r,0)+o),M.attr("dy",".71em").attr("text-anchor","middle"),C.attr("d","M"+x[0]+","+s+"V0H"+x[1]+"V"+s);break;case"top":S=Fn,v.attr("y2",-i),g.attr("x2",0).attr("y2",-i),A.attr("y2",-r),_.attr("y",-(Math.max(r,0)+o)),O.attr("x2",0).attr("y2",-r),D.attr("x",0).attr("y",-(Math.max(r,0)+o)),M.attr("dy","0em").attr("text-anchor","middle"),C.attr("d","M"+x[0]+","+ -s+"V0H"+x[1]+"V"+ -s);break;case"left":S=In,v.attr("x2",-i),g.attr("x2",-i).attr("y2",0),A.attr("x2",-r),_.attr("x",-(Math.max(r,0)+o)),O.attr("x2",-r).attr("y2",0),D.attr("x",-(Math.max(r,0)+o)).attr("y",0),M.attr("dy",".32em").attr("text-anchor","end"),C.attr("d","M"+ -s+","+x[0]+"H0V"+x[1]+"H"+ -s);break;case"right":S=In,v.attr("x2",i),g.attr("x2",i).attr("y2",0),A.attr("x2",r),_.attr("x",Math.max(r,0)+o),O.attr("x2",r).attr("y2",0),D.attr("x",Math.max(r,0)+o).attr("y",0),M.attr("dy",".32em").attr("text-anchor","start"),C.attr("d","M"+s+","+x[0]+"H0V"+x[1]+"H"+s)}if(t.ticks)b.call(S,L),E.call(S,k),w.call(S,k),v.call(S,L),g.call(S,k),m.call(S,k);else{var P=k.rangeBand()/2,H=function(e){return k(e)+P};b.call(S,H),E.call(S,H)}})}var t=d3.scale.linear(),n="bottom",r=6,i=6,s=6,o=3,u=[10],a=null,f,l=0;return e.scale=function(n){return arguments.length?(t=n,e):t},e.orient=function(t){return arguments.length?(n=t,e):n},e.ticks=function(){return arguments.length?(u=arguments,e):u},e.tickValues=function(t){return arguments.length?(a=t,e):a},e.tickFormat=function(t){return arguments.length?(f=t,e):f},e.tickSize=function(t,n,o){if(!arguments.length)return r;var u=arguments.length-1;return r=+t,i=u>1?+n:r,s=u>0?+arguments[u]:r,e},e.tickPadding=function(t){return arguments.length?(o=+t,e):o},e.tickSubdivide=function(t){return arguments.length?(l=+t,e):l},e},d3.svg.brush=function(){function e(s){s.each(function(){var s=d3.select(this),f=s.selectAll(".background").data([0]),l=s.selectAll(".extent").data([0]),c=s.selectAll(".resize").data(a,String),h;s.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),f.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),l.enter().append("rect").attr("class","extent").style("cursor","move"),c.enter().append("g").attr("class",function(e){return"resize "+e}).style("cursor",function(e){return eo[e]}).append("rect").attr("x",function(e){return/[ew]$/.test(e)?-3:null}).attr("y",function(e){return/^[ns]/.test(e)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),c.style("display",e.empty()?"none":null),c.exit().remove(),o&&(h=_t(o),f.attr("x",h[0]).attr("width",h[1]-h[0]),n(s)),u&&(h=_t(u),f.attr("y",h[0]).attr("height",h[1]-h[0]),r(s)),t(s)})}function t(e){e.selectAll(".resize").attr("transform",function(e){return"translate("+f[+/e$/.test(e)][0]+","+f[+/^s/.test(e)][1]+")"})}function n(e){e.select(".extent").attr("x",f[0][0]),e.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1][0]-f[0][0])}function r(e){e.select(".extent").attr("y",f[0][1]),e.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1][1]-f[0][1])}function i(){function i(){var e=d3.event.changedTouches;return e?d3.touches(v,e)[0]:d3.mouse(v)}function a(){d3.event.keyCode==32&&(S||(x=null,T[0]-=f[1][0],T[1]-=f[1][1],S=2),M())}function c(){d3.event.keyCode==32&&S==2&&(T[0]+=f[1][0],T[1]+=f[1][1],S=0,M())}function h(){var e=i(),s=!1;N&&(e[0]+=N[0],e[1]+=N[1]),S||(d3.event.altKey?(x||(x=[(f[0][0]+f[1][0])/2,(f[0][1]+f[1][1])/2]),T[0]=f[+(e[0]<x[0])][0],T[1]=f[+(e[1]<x[1])][1]):x=null),w&&p(e,o,0)&&(n(y),s=!0),E&&p(e,u,1)&&(r(y),s=!0),s&&(t(y),g({type:"brush",mode:S?"move":"resize"}))}function p(e,t,n){var r=_t(t),i=r[0],s=r[1],o=T[n],u=f[1][n]-f[0][n],a,c;S&&(i-=o,s-=u+o),a=Math.max(i,Math.min(s,e[n])),S?c=(a+=o)+u:(x&&(o=Math.max(i,Math.min(s,2*x[n]-a))),o<a?(c=a,a=o):c=o);if(f[0][n]!==a||f[1][n]!==c)return l=null,f[0][n]=a,f[1][n]=c,!0}function d(){h(),y.style("pointer-events","all").selectAll(".resize").style("display",e.empty()?"none":null),d3.select("body").style("cursor",null),C.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),g({type:"brushend"}),M()}var v=this,m=d3.select(d3.event.target),g=s.of(v,arguments),y=d3.select(v),b=m.datum(),w=!/^(n|s)$/.test(b)&&o,E=!/^(e|w)$/.test(b)&&u,S=m.classed("extent"),x,T=i(),N,C=d3.select(window).on("mousemove.brush",h).on("mouseup.brush",d).on("touchmove.brush",h).on("touchend.brush",d).on("keydown.brush",a).on("keyup.brush",c);if(S)T[0]=f[0][0]-T[0],T[1]=f[0][1]-T[1];else if(b){var k=+/w$/.test(b),L=+/^n/.test(b);N=[f[1-k][0]-T[0],f[1-L][1]-T[1]],T[0]=f[k][0],T[1]=f[L][1]}else d3.event.altKey&&(x=T.slice());y.style("pointer-events","none").selectAll(".resize").style("display",null),d3.select("body").style("cursor",m.style("cursor")),g({type:"brushstart"}),h(),M()}var s=D(e,"brushstart","brush","brushend"),o=null,u=null,a=to[0],f=[[0,0],[0,0]],l;return e.x=function(t){return arguments.length?(o=t,a=to[!o<<1|!u],e):o},e.y=function(t){return arguments.length?(u=t,a=to[!o<<1|!u],e):u},e.extent=function(t){var n,r,i,s,a;return arguments.length?(l=[[0,0],[0,0]],o&&(n=t[0],r=t[1],u&&(n=n[0],r=r[0]),l[0][0]=n,l[1][0]=r,o.invert&&(n=o(n),r=o(r)),r<n&&(a=n,n=r,r=a),f[0][0]=n|0,f[1][0]=r|0),u&&(i=t[0],s=t[1],o&&(i=i[1],s=s[1]),l[0][1]=i,l[1][1]=s,u.invert&&(i=u(i),s=u(s)),s<i&&(a=i,i=s,s=a),f[0][1]=i|0,f[1][1]=s|0),e):(t=l||f,o&&(n=t[0][0],r=t[1][0],l||(n=f[0][0],r=f[1][0],o.invert&&(n=o.invert(n),r=o.invert(r)),r<n&&(a=n,n=r,r=a))),u&&(i=t[0][1],s=t[1][1],l||(i=f[0][1],s=f[1][1],u.invert&&(i=u.invert(i),s=u.invert(s)),s<i&&(a=i,i=s,s=a))),o&&u?[[n,i],[r,s]]:o?[n,r]:u&&[i,s])},e.clear=function(){return l=null,f[0][0]=f[0][1]=f[1][0]=f[1][1]=0,e},e.empty=function(){return o&&f[0][0]===f[1][0]||u&&f[0][1]===f[1][1]},d3.rebind(e,s,"on")};var eo={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},to=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];d3.behavior={},d3.behavior.drag=function(){function e(){this.on("mousedown.drag",t).on("touchstart.drag",t)}function t(){function e(){var e=o.parentNode;return f?d3.touches(e).filter(function(e){return e.identifier===f})[0]:d3.mouse(e)}function t(){if(!o.parentNode)return i();var t=e(),n=t[0]-c[0],r=t[1]-c[1];h|=n|r,c=t,M(),u({type:"drag",x:t[0]+l[0],y:t[1]+l[1],dx:n,dy:r})}function i(){u({type:"dragend"}),h&&(M(),d3.event.target===a&&p.on("click.drag",s,!0)),p.on(f?"touchmove.drag-"+f:"mousemove.drag",null).on(f?"touchend.drag-"+f:"mouseup.drag",null)}function s(){M(),p.on("click.drag",null)}var o=this,u=n.of(o,arguments),a=d3.event.target,f=d3.event.touches&&d3.event.changedTouches[0].identifier,l,c=e(),h=0,p=d3.select(window).on(f?"touchmove.drag-"+f:"mousemove.drag",t).on(f?"touchend.drag-"+f:"mouseup.drag",i,!0);r?(l=r.apply(o,arguments),l=[l.x-c[0],l.y-c[1]]):l=[0,0],f||M(),u({type:"dragstart"})}var n=D(e,"drag","dragstart","dragend"),r=null;return e.origin=function(t){return arguments.length?(r=t,e):r},d3.rebind(e,n,"on")},d3.behavior.zoom=function(){function e(){this.on("mousedown.zoom",o).on("mousewheel.zoom",u).on("mousemove.zoom",a).on("DOMMouseScroll.zoom",u).on("dblclick.zoom",f).on("touchstart.zoom",l).on("touchmove.zoom",c).on("touchend.zoom",l)}function t(e){return[(e[0]-h[0])/d,(e[1]-h[1])/d]}function n(e){return[e[0]*d+h[0],e[1]*d+h[1]]}function r(e){d=Math.max(m[0],Math.min(m[1],e))}function i(e,t){t=n(t),h[0]+=e[0]-t[0],h[1]+=e[1]-t[1]}function s(e){b&&b.domain(y.range().map(function(e){return(e-h[0])/d}).map(y.invert)),E&&E.domain(w.range().map(function(e){return(e-h[1])/d}).map(w.invert)),d3.event.preventDefault(),e({type:"zoom",scale:d,translate:h})}function o(){function e(){f=1,i(d3.mouse(o),c),s(u)}function n(){f&&M(),l.on("mousemove.zoom",null).on("mouseup.zoom",null),f&&d3.event.target===a&&l.on("click.zoom",r,!0)}function r(){M(),l.on("click.zoom",null)}var o=this,u=g.of(o,arguments),a=d3.event.target,f=0,l=d3.select(window).on("mousemove.zoom",e).on("mouseup.zoom",n),c=t(d3.mouse(o));window.focus(),M()}function u(){p||(p=t(d3.mouse(this))),r(Math.pow(2,Rn()*.002)*d),i(d3.mouse(this),p),s(g.of(this,arguments))}function a(){p=null}function f(){var e=d3.mouse(this),n=t(e);r(d3.event.shiftKey?d/2:d*2),i(e,n),s(g.of(this,arguments))}function l(){var e=d3.touches(this),n=Date.now();v=d,p={},e.forEach(function(e){p[e.identifier]=t(e)}),M();if(e.length===1){if(n-S<500){var o=e[0],u=t(e[0]);r(d*2),i(o,u),s(g.of(this,arguments))}S=n}}function c(){var e=d3.touches(this),t=e[0],n=p[t.identifier];if(o=e[1]){var o,u=p[o.identifier];t=[(t[0]+o[0])/2,(t[1]+o[1])/2],n=[(n[0]+u[0])/2,(n[1]+u[1])/2],r(d3.event.scale*v)}i(t,n),S=null,s(g.of(this,arguments))}var h=[0,0],p,d=1,v,m=ro,g=D(e,"zoom"),y,b,w,E,S;return e.translate=function(t){return arguments.length?(h=t.map(Number),e):h},e.scale=function(t){return arguments.length?(d=+t,e):d},e.scaleExtent=function(t){return arguments.length?(m=t==null?ro:t.map(Number),e):m},e.x=function(t){return arguments.length?(b=t,y=t.copy(),e):b},e.y=function(t){return arguments.length?(E=t,w=t.copy(),e):E},d3.rebind(e,g,"on")};var no,ro=[0,Infinity];d3.layout={},d3.layout.bundle=function(){return function(e){var t=[],n=-1,r=e.length;while(++n<r)t.push(Un(e[n]));return t}},d3.layout.chord=function(){function e(){var e={},n=[],c=d3.range(o),h=[],p,d,v,m,g;r=[],i=[],p=0,m=-1;while(++m<o){d=0,g=-1;while(++g<o)d+=s[m][g];n.push(d),h.push(d3.range(o)),p+=d}a&&c.sort(function(e,t){return a(n[e],n[t])}),f&&h.forEach(function(e,t){e.sort(function(e,n){return f(s[t][e],s[t][n])})}),p=(2*Math.PI-u*o)/p,d=0,m=-1;while(++m<o){v=d,g=-1;while(++g<o){var y=c[m],b=h[y][g],w=s[y][b],E=d,S=d+=w*p;e[y+"-"+b]={index:y,subindex:b,startAngle:E,endAngle:S,value:w}}i[y]={index:y,startAngle:v,endAngle:d,value:(d-v)/p},d+=u}m=-1;while(++m<o){g=m-1;while(++g<o){var x=e[m+"-"+g],T=e[g+"-"+m];(x.value||T.value)&&r.push(x.value<T.value?{source:T,target:x}:{source:x,target:T})}}l&&t()}function t(){r.sort(function(e,t){return l((e.source.value+e.target.value)/2,(t.source.value+t.target.value)/2)})}var n={},r,i,s,o,u=0,a,f,l;return n.matrix=function(e){return arguments.length?(o=(s=e)&&s.length,r=i=null,n):s},n.padding=function(e){return arguments.length?(u=e,r=i=null,n):u},n.sortGroups=function(e){return arguments.length?(a=e,r=i=null,n):a},n.sortSubgroups=function(e){return arguments.length?(f=e,r=null,n):f},n.sortChords=function(e){return arguments.length?(l=e,r&&t(),n):l},n.chords=function(){return r||e(),r},n.groups=function(){return i||e(),i},n},d3.layout.force=function(){function e(e){return function(t,n,r,i,s){if(t.point!==e){var o=t.cx-e.x,u=t.cy-e.y,a=1/Math.sqrt(o*o+u*u);if((i-n)*a<d){var f=t.charge*a*a;return e.px-=o*f,e.py-=u*f,!0}if(t.point&&isFinite(a)){var f=t.pointCharge*a*a;e.px-=o*f,e.py-=u*f}}return!t.charge}}function t(e){e.px=d3.event.x,e.py=d3.event.y,n.resume()}var n={},r=d3.dispatch("start","tick","end"),s=[1,1],o,a,f=.9,l=Qn,c=Gn,h=-30,p=.1,d=.8,v,m=[],g=[],y,b,w;return n.tick=function(){if((a*=.99)<.005)return r.end({type:"end",alpha:a=0}),!0;var t=m.length,n=g.length,i,o,u,l,c,d,v,E,S;for(o=0;o<n;++o){u=g[o],l=u.source,c=u.target,E=c.x-l.x,S=c.y-l.y;if(d=E*E+S*S)d=a*b[o]*((d=Math.sqrt(d))-y[o])/d,E*=d,S*=d,c.x-=E*(v=l.weight/(c.weight+l.weight)),c.y-=S*v,l.x+=E*(v=1-v),l.y+=S*v}if(v=a*p){E=s[0]/2,S=s[1]/2,o=-1;if(v)while(++o<t)u=m[o],u.x+=(E-u.x)*v,u.y+=(S-u.y)*v}if(h){Kn(i=d3.geom.quadtree(m),a,w),o=-1;while(++o<t)(u=m[o]).fixed||i.visit(e(u))}o=-1;while(++o<t)u=m[o],u.fixed?(u.x=u.px,u.y=u.py):(u.x-=(u.px-(u.px=u.x))*f,u.y-=(u.py-(u.py=u.y))*f);r.tick({type:"tick",alpha:a})},n.nodes=function(e){return arguments.length?(m=e,n):m},n.links=function(e){return arguments.length?(g=e,n):g},n.size=function(e){return arguments.length?(s=e,n):s},n.linkDistance=function(e){return arguments.length?(l=u(e),n):l},n.distance=n.linkDistance,n.linkStrength=function(e){return arguments.length?(c=u(e),n):c},n.friction=function(e){return arguments.length?(f=e,n):f},n.charge=function(e){return arguments.length?(h=typeof e=="function"?e:+e,n):h},n.gravity=function(e){return arguments.length?(p=e,n):p},n.theta=function(e){return arguments.length?(d=e,n):d},n.alpha=function(e){return arguments.length?(a?e>0?a=e:a=0:e>0&&(r.start({type:"start",alpha:a=e}),d3.timer(n.tick)),n):a},n.start=function(){function e(e,n){var i=t(r),s=-1,o=i.length,u;while(++s<o)if(!isNaN(u=i[s][e]))return u;return Math.random()*n}function t(){if(!p){p=[];for(i=0;i<o;++i)p[i]=[];for(i=0;i<u;++i){var e=g[i];p[e.source.index].push(e.target),p[e.target.index].push(e.source)}}return p[r]}var r,i,o=m.length,u=g.length,a=s[0],f=s[1],p,d;for(r=0;r<o;++r)(d=m[r]).index=r,d.weight=0;y=[],b=[];for(r=0;r<u;++r)d=g[r],typeof d.source=="number"&&(d.source=m[d.source]),typeof d.target=="number"&&(d.target=m[d.target]),y[r]=l.call(this,d,r),b[r]=c.call(this,d,r),++d.source.weight,++d.target.weight;for(r=0;r<o;++r)d=m[r],isNaN(d.x)&&(d.x=e("x",a)),isNaN(d.y)&&(d.y=e("y",f)),isNaN(d.px)&&(d.px=d.x),isNaN(d.py)&&(d.py=d.y);w=[];if(typeof h=="function")for(r=0;r<o;++r)w[r]=+h.call(this,m[r],r);else for(r=0;r<o;++r)w[r]=h;return n.resume()},n.resume=function(){return n.alpha(.1)},n.stop=function(){return n.alpha(0)},n.drag=function(){o||(o=d3.behavior.drag().origin(i).on("dragstart",Xn).on("drag",t).on("dragend",Vn)),this.on("mouseover.force",$n).on("mouseout.force",Jn).call(o)},d3.rebind(n,r,"on")},d3.layout.partition=function(){function e(t,n,r,i){var s=t.children;t.x=n,t.y=t.depth*i,t.dx=r,t.dy=i;if(s&&(u=s.length)){var o=-1,u,a,f;r=t.value?r/t.value:0;while(++o<u)e(a=s[o],n,f=a.value*r,i),n+=f}}function t(e){var n=e.children,r=0;if(n&&(s=n.length)){var i=-1,s;while(++i<s)r=Math.max(r,t(n[i]))}return 1+r}function n(n,s){var o=r.call(this,n,s);return e(o[0],0,i[0],i[1]/t(o[0])),o}var r=d3.layout.hierarchy(),i=[1,1];return n.size=function(e){return arguments.length?(i=e,n):i},fr(n,r)},d3.layout.pie=function(){function e(s,o){var u=s.map(function(n,r){return+t.call(e,n,r)}),a=+(typeof r=="function"?r.apply(this,arguments):r),f=((typeof i=="function"?i.apply(this,arguments):i)-r)/d3.sum(u),l=d3.range(s.length);n!=null&&l.sort(n===io?function(e,t){return u[t]-u[e]}:function(e,t){return n(s[e],s[t])});var c=[];return l.forEach(function(e){var t;c[e]={data:s[e],value:t=u[e],startAngle:a,endAngle:a+=t*f}}),c}var t=Number,n=io,r=0,i=2*Math.PI;return e.value=function(n){return arguments.length?(t=n,e):t},e.sort=function(t){return arguments.length?(n=t,e):n},e.startAngle=function(t){return arguments.length?(r=t,e):r},e.endAngle=function(t){return arguments.length?(i=t,e):i},e};var io={};d3.layout.stack=function(){function e(i,a){var f=i.map(function(n,r){return t.call(e,n,r)}),l=f.map(function(t,n){return t.map(function(t,n){return[o.call(e,t,n),u.call(e,t,n)]})}),c=n.call(e,l,a);f=d3.permute(f,c),l=d3.permute(l,c);var h=r.call(e,l,a),p=f.length,d=f[0].length,v,m,g;for(m=0;m<d;++m){s.call(e,f[0][m],g=h[m],l[0][m][1]);for(v=1;v<p;++v)s.call(e,f[v][m],g+=l[v-1][m][1],l[v][m][1])}return i}var t=i,n=tr,r=nr,s=er,o=Yn,u=Zn;return e.values=function(n){return arguments.length?(t=n,e):t},e.order=function(t){return arguments.length?(n=typeof t=="function"?t:so.get(t)||tr,e):n},e.offset=function(t){return arguments.length?(r=typeof t=="function"?t:oo.get(t)||nr,e):r},e.x=function(t){return arguments.length?(o=t,e):o},e.y=function(t){return arguments.length?(u=t,e):u},e.out=function(t){return arguments.length?(s=t,e):s},e};var so=d3.map({"inside-out":function(e){var t=e.length,n,r,i=e.map(rr),s=e.map(ir),o=d3.range(t).sort(function(e,t){return i[e]-i[t]}),u=0,a=0,f=[],l=[];for(n=0;n<t;++n)r=o[n],u<a?(u+=s[r],f.push(r)):(a+=s[r],l.push(r));return l.reverse().concat(f)},reverse:function(e){return d3.range(e.length).reverse()},"default":tr}),oo=d3.map({silhouette:function(e){var t=e.length,n=e[0].length,r=[],i=0,s,o,u,a=[];for(o=0;o<n;++o){for(s=0,u=0;s<t;s++)u+=e[s][o][1];u>i&&(i=u),r.push(u)}for(o=0;o<n;++o)a[o]=(i-r[o])/2;return a},wiggle:function(e){var t=e.length,n=e[0],r=n.length,i=0,s,o,u,a,f,l,c,h,p,d=[];d[0]=h=p=0;for(o=1;o<r;++o){for(s=0,a=0;s<t;++s)a+=e[s][o][1];for(s=0,f=0,c=n[o][0]-n[o-1][0];s<t;++s){for(u=0,l=(e[s][o][1]-e[s][o-1][1])/(2*c);u<s;++u)l+=(e[u][o][1]-e[u][o-1][1])/c;f+=l*e[s][o][1]}d[o]=h-=a?f/a*c:0,h<p&&(p=h)}for(o=0;o<r;++o)d[o]-=p;return d},expand:function(e){var t=e.length,n=e[0].length,r=1/t,i,s,o,u=[];for(s=0;s<n;++s){for(i=0,o=0;i<t;i++)o+=e[i][s][1];if(o)for(i=0;i<t;i++)e[i][s][1]/=o;else for(i=0;i<t;i++)e[i][s][1]=r}for(s=0;s<n;++s)u[s]=0;return u},zero:nr});d3.layout.histogram=function(){function e(e,s){var o=[],u=e.map(n,this),a=r.call(this,u,s),f=i.call(this,a,u,s),l,s=-1,c=u.length,h=f.length-1,p=t?1:1/c,d;while(++s<h)l=o[s]=[],l.dx=f[s+1]-(l.x=f[s]),l.y=0;if(h>0){s=-1;while(++s<c)d=u[s],d>=a[0]&&d<=a[1]&&(l=o[d3.bisect(f,d,1,h)-1],l.y+=p,l.push(e[s]))}return o}var t=!0,n=Number,r=ar,i=or;return e.value=function(t){return arguments.length?(n=t,e):n},e.range=function(t){return arguments.length?(r=u(t),e):r},e.bins=function(t){return arguments.length?(i=typeof t=="number"?function(e){return ur(e,t)}:u(t),e):i},e.frequency=function(n){return arguments.length?(t=!!n,e):t},e},d3.layout.hierarchy=function(){function e(t,o,u){var a=i.call(n,t,o),f=uo?t:{data:t};f.depth=o,u.push(f);if(a&&(c=a.length)){var l=-1,c,h=f.children=[],p=0,d=o+1,v;while(++l<c)v=e(a[l],d,u),v.parent=f,h.push(v),p+=v.value;r&&h.sort(r),s&&(f.value=p)}else s&&(f.value=+s.call(n,t,o)||0);return f}function t(e,r){var i=e.children,o=0;if(i&&(a=i.length)){var u=-1,a,f=r+1;while(++u<a)o+=t(i[u],f)}else s&&(o=+s.call(n,uo?e:e.data,r)||0);return s&&(e.value=o),o}function n(t){var n=[];return e(t,0,n),n}var r=hr,i=lr,s=cr;return n.sort=function(e){return arguments.length?(r=e,n):r},n.children=function(e){return arguments.length?(i=e,n):i},n.value=function(e){return arguments.length?(s=e,n):s},n.revalue=function(e){return t(e,0),e},n};var uo=!1;d3.layout.pack=function(){function e(e,i){var s=t.call(this,e,i),o=s[0];o.x=0,o.y=0,Pr(o,function(e){e.r=Math.sqrt(e.value)}),Pr(o,yr);var u=r[0],a=r[1],f=Math.max(2*o.r/u,2*o.r/a);if(n>0){var l=n*f/2;Pr(o,function(e){e.r+=l}),Pr(o,yr),Pr(o,function(e){e.r-=l}),f=Math.max(2*o.r/u,2*o.r/a)}return Er(o,u/2,a/2,1/f),s}var t=d3.layout.hierarchy().sort(dr),n=0,r=[1,1];return e.size=function(t){return arguments.length?(r=t,e):r},e.padding=function(t){return arguments.length?(n=+t,e):n},fr(e,t)},d3.layout.cluster=function(){function e(e,i){var s=t.call(this,e,i),o=s[0],u,a=0,f,l;Pr(o,function(e){var t=e.children;t&&t.length?(e.x=Tr(t),e.y=xr(t)):(e.x=u?a+=n(e,u):0,e.y=0,u=e)});var c=Nr(o),h=Cr(o),p=c.x-n(c,h)/2,d=h.x+n(h,c)/2;return Pr(o,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=(1-(o.y?e.y/o.y:1))*r[1]}),s}var t=d3.layout.hierarchy().sort(null).value(null),n=kr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},fr(e,t)},d3.layout.tree=function(){function e(e,i){function s(e,t){var r=e.children,i=e._tree;if(r&&(o=r.length)){var o,a=r[0],f,l=a,c,h=-1;while(++h<o)c=r[h],s(c,f),l=u(c,f,l),f=c;Hr(e);var p=.5*(a._tree.prelim+c._tree.prelim);t?(i.prelim=t._tree.prelim+n(e,t),i.mod=i.prelim-p):i.prelim=p}else t&&(i.prelim=t._tree.prelim+n(e,t))}function o(e,t){e.x=e._tree.prelim+t;var n=e.children;if(n&&(i=n.length)){var r=-1,i;t+=e._tree.mod;while(++r<i)o(n[r],t)}}function u(e,t,r){if(t){var i=e,s=e,o=t,u=e.parent.children[0],a=i._tree.mod,f=s._tree.mod,l=o._tree.mod,c=u._tree.mod,h;while(o=Ar(o),i=Lr(i),o&&i)u=Lr(u),s=Ar(s),s._tree.ancestor=e,h=o._tree.prelim+l-i._tree.prelim-a+n(o,i),h>0&&(Br(jr(o,e,r),e,h),a+=h,f+=h),l+=o._tree.mod,a+=i._tree.mod,c+=u._tree.mod,f+=s._tree.mod;o&&!Ar(s)&&(s._tree.thread=o,s._tree.mod+=l-f),i&&!Lr(u)&&(u._tree.thread=i,u._tree.mod+=a-c,r=e)}return r}var a=t.call(this,e,i),f=a[0];Pr(f,function(e,t){e._tree={ancestor:e,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),s(f),o(f,-f._tree.prelim);var l=Or(f,_r),c=Or(f,Mr),h=Or(f,Dr),p=l.x-n(l,c)/2,d=c.x+n(c,l)/2,v=h.depth||1;return Pr(f,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=e.depth/v*r[1],delete e._tree}),a}var t=d3.layout.hierarchy().sort(null).value(null),n=kr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},fr(e,t)},d3.layout.treemap=function(){function e(e,t){var n=-1,r=e.length,i,s;while(++n<r)s=(i=e[n]).value*(t<0?0:t),i.area=isNaN(s)||s<=0?0:s}function t(n){var s=n.children;if(s&&s.length){var o=l(n),u=[],a=s.slice(),f,c=Infinity,h,p=Math.min(o.dx,o.dy),d;e(a,o.dx*o.dy/n.value),u.area=0;while((d=a.length)>0)u.push(f=a[d-1]),u.area+=f.area,(h=r(u,p))<=c?(a.pop(),c=h):(u.area-=u.pop().area,i(u,p,o,!1),p=Math.min(o.dx,o.dy),u.length=u.area=0,c=Infinity);u.length&&(i(u,p,o,!0),u.length=u.area=0),s.forEach(t)}}function n(t){var r=t.children;if(r&&r.length){var s=l(t),o=r.slice(),u,a=[];e(o,s.dx*s.dy/t.value),a.area=0;while(u=o.pop())a.push(u),a.area+=u.area,u.z!=null&&(i(a,u.z?s.dx:s.dy,s,!o.length),a.length=a.area=0);r.forEach(n)}}function r(e,t){var n=e.area,r,i=0,s=Infinity,o=-1,u=e.length;while(++o<u){if(!(r=e[o].area))continue;r<s&&(s=r),r>i&&(i=r)}return n*=n,t*=t,n?Math.max(t*i*p/n,n/(t*s*p)):Infinity}function i(e,t,n,r){var i=-1,s=e.length,o=n.x,a=n.y,f=t?u(e.area/t):0,l;if(t==n.dx){if(r||f>n.dy)f=n.dy;while(++i<s)l=e[i],l.x=o,l.y=a,l.dy=f,o+=l.dx=Math.min(n.x+n.dx-o,f?u(l.area/f):0);l.z=!0,l.dx+=n.x+n.dx-o,n.y+=f,n.dy-=f}else{if(r||f>n.dx)f=n.dx;while(++i<s)l=e[i],l.x=o,l.y=a,l.dx=f,a+=l.dy=Math.min(n.y+n.dy-a,f?u(l.area/f):0);l.z=!1,l.dy+=n.y+n.dy-a,n.x+=f,n.dx-=f}}function s(r){var i=h||o(r),s=i[0];return s.x=0,s.y=0,s.dx=a[0],s.dy=a[1],h&&o.revalue(s),e([s],s.dx*s.dy/s.value),(h?n:t)(s),c&&(h=i),i}var o=d3.layout.hierarchy(),u=Math.round,a=[1,1],f=null,l=Fr,c=!1,h,p=.5*(1+Math.sqrt(5));return s.size=function(e){return arguments.length?(a=e,s):a},s.padding=function(e){function t(t){var n=e.call(s,t,t.depth);return n==null?Fr(t):Ir(t,typeof n=="number"?[n,n,n,n]:n)}function n(t){return Ir(t,e)}if(!arguments.length)return f;var r;return l=(f=e)==null?Fr:(r=typeof e)==="function"?t:r==="number"?(e=[e,e,e,e],n):n,s},s.round=function(e){return arguments.length?(u=e?Math.round:Number,s):u!=Number},s.sticky=function(e){return arguments.length?(c=e,h=null,s):c},s.ratio=function(e){return arguments.length?(p=e,s):p},fr(s,o)},d3.csv=qr(",","text/csv"),d3.tsv=qr("     ","text/tab-separated-values"),d3.geo={};var ao=Math.PI/180;d3.geo.azimuthal=function(){function e(e){var n=e[0]*ao-s,o=e[1]*ao,f=Math.cos(n),l=Math.sin(n),c=Math.cos(o),h=Math.sin(o),p=t!=="orthographic"?a*h+u*c*f:null,d,v=t==="stereographic"?1/(1+p):t==="gnomonic"?1/p:t==="equidistant"?(d=Math.acos(p),d?d/Math.sin(d):0):t==="equalarea"?Math.sqrt(2/(1+p)):1,m=v*c*l,g=v*(a*c*f-u*h);return[r*m+i[0],r*g+i[1]]}var t="orthographic",n,r=200,i=[480,250],s,o,u,a;return e.invert=function(e){var n=(e[0]-i[0])/r,o=(e[1]-i[1])/r,f=Math.sqrt(n*n+o*o),l=t==="stereographic"?2*Math.atan(f):t==="gnomonic"?Math.atan(f):t==="equidistant"?f:t==="equalarea"?2*Math.asin(.5*f):Math.asin(f),c=Math.sin(l),h=Math.cos(l);return[(s+Math.atan2(n*c,f*u*h+o*a*c))/ao,Math.asin(h*a-(f?o*c*u/f:0))/ao]},e.mode=function(n){return arguments.length?(t=n+"",e):t},e.origin=function(t){return arguments.length?(n=t,s=n[0]*ao,o=n[1]*ao,u=Math.cos(o),a=Math.sin(o),e):n},e.scale=function(t){return arguments.length?(r=+t,e):r},e.translate=function(t){return arguments.length?(i=[+t[0],+t[1]],e):i},e.origin([0,0])},d3.geo.albers=function(){function e(e){var t=u*(ao*e[0]-o),n=Math.sqrt(a-2*u*Math.sin(ao*e[1]))/u;return[i*n*Math.sin(t)+s[0],i*(n*Math.cos(t)-f)+s[1]]}function t(){var t=ao*r[0],i=ao*r[1],s=ao*n[1],l=Math.sin(t),c=Math.cos(t);return o=ao*n[0],u=.5*(l+Math.sin(i)),a=c*c+2*u*l,f=Math.sqrt(a-2*u*Math.sin(s))/u,e}var n=[-98,38],r=[29.5,45.5],i=1e3,s=[480,250],o,u,a,f;return e.invert=function(e){var t=(e[0]-s[0])/i,n=(e[1]-s[1])/i,r=f+n,l=Math.atan2(t,r),c=Math.sqrt(t*t+r*r);return[(o+l/u)/ao,Math.asin((a-c*c*u*u)/(2*u))/ao]},e.origin=function(e){return arguments.length?(n=[+e[0],+e[1]],t()):n},e.parallels=function(e){return arguments.length?(r=[+e[0],+e[1]],t()):r},e.scale=function(t){return arguments.length?(i=+t,e):i},e.translate=function(t){return arguments.length?(s=[+t[0],+t[1]],e):s},t()},d3.geo.albersUsa=function(){function e(e){var s=e[0],o=e[1];return(o>50?n:s<-140?r:o<21?i:t)(e)}var t=d3.geo.albers(),n=d3.geo.albers().origin([-160,60]).parallels([55,65]),r=d3.geo.albers().origin([-160,20]).parallels([8,18]),i=d3.geo.albers().origin([-60,10]).parallels([8,18]);return e.scale=function(s){return arguments.length?(t.scale(s),n.scale(s*.6),r.scale(s),i.scale(s*1.5),e.translate(t.translate())):t.scale()},e.translate=function(s){if(!arguments.length)return t.translate();var o=t.scale()/1e3,u=s[0],a=s[1];return t.translate(s),n.translate([u-400*o,a+170*o]),r.translate([u-190*o,a+200*o]),i.translate([u+580*o,a+430*o]),e},e.scale(t.scale())},d3.geo.bonne=function(){function e(e){var u=e[0]*ao-r,a=e[1]*ao-i;if(s){var f=o+s-a,l=u*Math.cos(a)/f;u=f*Math.sin(l),a=f*Math.cos(l)-o}else u*=Math.cos(a),a*=-1;return[t*u+n[0],t*a+n[1]]}var t=200,n=[480,250],r,i,s,o;return e.invert=function(e){var i=(e[0]-n[0])/t,u=(e[1]-n[1])/t;if(s){var a=o+u,f=Math.sqrt(i*i+a*a);u=o+s-f,i=r+f*Math.atan2(i,a)/Math.cos(u)}else u*=-1,i/=Math.cos(u);return[i/ao,u/ao]},e.parallel=function(t){return arguments.length?(o=1/Math.tan
+(s=t*ao),e):s/ao},e.origin=function(t){return arguments.length?(r=t[0]*ao,i=t[1]*ao,e):[r/ao,i/ao]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e.origin([0,0]).parallel(45)},d3.geo.equirectangular=function(){function e(e){var r=e[0]/360,i=-e[1]/360;return[t*r+n[0],t*i+n[1]]}var t=500,n=[480,250];return e.invert=function(e){var r=(e[0]-n[0])/t,i=(e[1]-n[1])/t;return[360*r,-360*i]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e},d3.geo.mercator=function(){function e(e){var r=e[0]/360,i=-(Math.log(Math.tan(Math.PI/4+e[1]*ao/2))/ao)/360;return[t*r+n[0],t*Math.max(-0.5,Math.min(.5,i))+n[1]]}var t=500,n=[480,250];return e.invert=function(e){var r=(e[0]-n[0])/t,i=(e[1]-n[1])/t;return[360*r,2*Math.atan(Math.exp(-360*i*ao))/ao-90]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e},d3.geo.path=function(){function e(e,t){typeof s=="function"&&(o=Ur(s.apply(this,arguments))),f(e);var n=a.length?a.join(""):null;return a=[],n}function t(e){return u(e).join(",")}function n(e){var t=i(e[0]),n=0,r=e.length;while(++n<r)t-=i(e[n]);return t}function r(e){var t=d3.geom.polygon(e[0].map(u)),n=t.area(),r=t.centroid(n<0?(n*=-1,1):-1),i=r[0],s=r[1],o=n,a=0,f=e.length;while(++a<f)t=d3.geom.polygon(e[a].map(u)),n=t.area(),r=t.centroid(n<0?(n*=-1,1):-1),i-=r[0],s-=r[1],o-=n;return[i,s,6*o]}function i(e){return Math.abs(d3.geom.polygon(e.map(u)).area())}var s=4.5,o=Ur(s),u=d3.geo.albersUsa(),a=[],f=Rr({FeatureCollection:function(e){var t=e.features,n=-1,r=t.length;while(++n<r)a.push(f(t[n].geometry))},Feature:function(e){f(e.geometry)},Point:function(e){a.push("M",t(e.coordinates),o)},MultiPoint:function(e){var n=e.coordinates,r=-1,i=n.length;while(++r<i)a.push("M",t(n[r]),o)},LineString:function(e){var n=e.coordinates,r=-1,i=n.length;a.push("M");while(++r<i)a.push(t(n[r]),"L");a.pop()},MultiLineString:function(e){var n=e.coordinates,r=-1,i=n.length,s,o,u;while(++r<i){s=n[r],o=-1,u=s.length,a.push("M");while(++o<u)a.push(t(s[o]),"L");a.pop()}},Polygon:function(e){var n=e.coordinates,r=-1,i=n.length,s,o,u;while(++r<i){s=n[r],o=-1;if((u=s.length-1)>0){a.push("M");while(++o<u)a.push(t(s[o]),"L");a[a.length-1]="Z"}}},MultiPolygon:function(e){var n=e.coordinates,r=-1,i=n.length,s,o,u,f,l,c;while(++r<i){s=n[r],o=-1,u=s.length;while(++o<u){f=s[o],l=-1;if((c=f.length-1)>0){a.push("M");while(++l<c)a.push(t(f[l]),"L");a[a.length-1]="Z"}}}},GeometryCollection:function(e){var t=e.geometries,n=-1,r=t.length;while(++n<r)a.push(f(t[n]))}}),l=e.area=Rr({FeatureCollection:function(e){var t=0,n=e.features,r=-1,i=n.length;while(++r<i)t+=l(n[r]);return t},Feature:function(e){return l(e.geometry)},Polygon:function(e){return n(e.coordinates)},MultiPolygon:function(e){var t=0,r=e.coordinates,i=-1,s=r.length;while(++i<s)t+=n(r[i]);return t},GeometryCollection:function(e){var t=0,n=e.geometries,r=-1,i=n.length;while(++r<i)t+=l(n[r]);return t}},0),c=e.centroid=Rr({Feature:function(e){return c(e.geometry)},Polygon:function(e){var t=r(e.coordinates);return[t[0]/t[2],t[1]/t[2]]},MultiPolygon:function(e){var t=0,n=e.coordinates,i,s=0,o=0,u=0,a=-1,f=n.length;while(++a<f)i=r(n[a]),s+=i[0],o+=i[1],u+=i[2];return[s/u,o/u]}});return e.projection=function(t){return u=t,e},e.pointRadius=function(t){return typeof t=="function"?s=t:(s=+t,o=Ur(s)),e},e},d3.geo.bounds=function(e){var t=Infinity,n=Infinity,r=-Infinity,i=-Infinity;return zr(e,function(e,s){e<t&&(t=e),e>r&&(r=e),s<n&&(n=s),s>i&&(i=s)}),[[t,n],[r,i]]};var fo={Feature:Wr,FeatureCollection:Xr,GeometryCollection:Vr,LineString:$r,MultiLineString:Jr,MultiPoint:$r,MultiPolygon:Kr,Point:Qr,Polygon:Gr};d3.geo.circle=function(){function e(){}function t(e){return a.distance(e)<u}function n(e){var t=-1,n=e.length,i=[],s,o,f,l,c;while(++t<n)c=a.distance(f=e[t]),c<u?(o&&i.push(ti(o,f)((l-u)/(l-c))),i.push(f),s=o=null):(o=f,!s&&i.length&&(i.push(ti(i[i.length-1],o)((u-l)/(c-l))),s=o)),l=c;return s=e[0],o=i[0],o&&f[0]===s[0]&&f[1]===s[1]&&(f[0]!==o[0]||f[1]!==o[1])&&i.push(o),r(i)}function r(e){var t=0,n=e.length,r,i,s=n?[e[0]]:e,o,u=a.source();while(++t<n){o=a.source(e[t-1])(e[t]).coordinates;for(r=0,i=o.length;++r<i;)s.push(o[r])}return a.source(u),s}var s=[0,0],o=89.99,u=o*ao,a=d3.geo.greatArc().source(s).target(i);e.clip=function(e){return typeof s=="function"&&a.source(s.apply(this,arguments)),f(e)||null};var f=Rr({FeatureCollection:function(e){var t=e.features.map(f).filter(i);return t&&(e=Object.create(e),e.features=t,e)},Feature:function(e){var t=f(e.geometry);return t&&(e=Object.create(e),e.geometry=t,e)},Point:function(e){return t(e.coordinates)&&e},MultiPoint:function(e){var n=e.coordinates.filter(t);return n.length&&{type:e.type,coordinates:n}},LineString:function(e){var t=n(e.coordinates);return t.length&&(e=Object.create(e),e.coordinates=t,e)},MultiLineString:function(e){var t=e.coordinates.map(n).filter(function(e){return e.length});return t.length&&(e=Object.create(e),e.coordinates=t,e)},Polygon:function(e){var t=e.coordinates.map(n);return t[0].length&&(e=Object.create(e),e.coordinates=t,e)},MultiPolygon:function(e){var t=e.coordinates.map(function(e){return e.map(n)}).filter(function(e){return e[0].length});return t.length&&(e=Object.create(e),e.coordinates=t,e)},GeometryCollection:function(e){var t=e.geometries.map(f).filter(i);return t.length&&(e=Object.create(e),e.geometries=t,e)}});return e.origin=function(t){return arguments.length?(s=t,typeof s!="function"&&a.source(s),e):s},e.angle=function(t){return arguments.length?(u=(o=+t)*ao,e):o},d3.rebind(e,a,"precision")},d3.geo.greatArc=function(){function e(){var t=e.distance.apply(this,arguments),r=0,u=s/t,a=[n];while((r+=u)<1)a.push(o(r));return a.push(i),{type:"LineString",coordinates:a}}var t=Yr,n,r=Zr,i,s=6*ao,o=ei();return e.distance=function(){return typeof t=="function"&&o.source(n=t.apply(this,arguments)),typeof r=="function"&&o.target(i=r.apply(this,arguments)),o.distance()},e.source=function(r){return arguments.length?(t=r,typeof t!="function"&&o.source(n=t),e):t},e.target=function(t){return arguments.length?(r=t,typeof r!="function"&&o.target(i=r),e):r},e.precision=function(t){return arguments.length?(s=t*ao,e):s/ao},e},d3.geo.greatCircle=d3.geo.circle,d3.geom={},d3.geom.contour=function(e,t){var n=t||ni(e),r=[],i=n[0],s=n[1],o=0,u=0,a=NaN,f=NaN,l=0;do l=0,e(i-1,s-1)&&(l+=1),e(i,s-1)&&(l+=2),e(i-1,s)&&(l+=4),e(i,s)&&(l+=8),l===6?(o=f===-1?-1:1,u=0):l===9?(o=0,u=a===1?-1:1):(o=lo[l],u=co[l]),o!=a&&u!=f&&(r.push([i,s]),a=o,f=u),i+=o,s+=u;while(n[0]!=i||n[1]!=s);return r};var lo=[1,0,1,1,-1,0,-1,1,0,0,0,0,-1,0,-1,NaN],co=[0,-1,0,0,0,-1,0,0,1,-1,1,1,0,-1,0,NaN];d3.geom.hull=function(e){if(e.length<3)return[];var t=e.length,n=t-1,r=[],i=[],s,o,u=0,a,f,l,c,h,p,d,v;for(s=1;s<t;++s)e[s][1]<e[u][1]?u=s:e[s][1]==e[u][1]&&(u=e[s][0]<e[u][0]?s:u);for(s=0;s<t;++s){if(s===u)continue;f=e[s][1]-e[u][1],a=e[s][0]-e[u][0],r.push({angle:Math.atan2(f,a),index:s})}r.sort(function(e,t){return e.angle-t.angle}),d=r[0].angle,p=r[0].index,h=0;for(s=1;s<n;++s)o=r[s].index,d==r[s].angle?(a=e[p][0]-e[u][0],f=e[p][1]-e[u][1],l=e[o][0]-e[u][0],c=e[o][1]-e[u][1],a*a+f*f>=l*l+c*c?r[s].index=-1:(r[h].index=-1,d=r[s].angle,h=s,p=o)):(d=r[s].angle,h=s,p=o);i.push(u);for(s=0,o=0;s<2;++o)r[o].index!==-1&&(i.push(r[o].index),s++);v=i.length;for(;o<n;++o){if(r[o].index===-1)continue;while(!ri(i[v-2],i[v-1],r[o].index,e))--v;i[v++]=r[o].index}var m=[];for(s=0;s<v;++s)m.push(e[i[s]]);return m},d3.geom.polygon=function(e){return e.area=function(){var t=0,n=e.length,r=e[n-1][0]*e[0][1],i=e[n-1][1]*e[0][0];while(++t<n)r+=e[t-1][0]*e[t][1],i+=e[t-1][1]*e[t][0];return(i-r)*.5},e.centroid=function(t){var n=-1,r=e.length,i=0,s=0,o,u=e[r-1],a;arguments.length||(t=-1/(6*e.area()));while(++n<r)o=u,u=e[n],a=o[0]*u[1]-u[0]*o[1],i+=(o[0]+u[0])*a,s+=(o[1]+u[1])*a;return[i*t,s*t]},e.clip=function(t){var n,r=-1,i=e.length,s,o,u=e[i-1],a,f,l;while(++r<i){n=t.slice(),t.length=0,a=e[r],f=n[(o=n.length)-1],s=-1;while(++s<o)l=n[s],ii(l,u,a)?(ii(f,u,a)||t.push(si(f,l,u,a)),t.push(l)):ii(f,u,a)&&t.push(si(f,l,u,a)),f=l;u=a}return t},e},d3.geom.voronoi=function(e){var t=e.map(function(){return[]});return oi(e,function(e){var n,r,i,s,o,u;e.a===1&&e.b>=0?(n=e.ep.r,r=e.ep.l):(n=e.ep.l,r=e.ep.r),e.a===1?(o=n?n.y:-1e6,i=e.c-e.b*o,u=r?r.y:1e6,s=e.c-e.b*u):(i=n?n.x:-1e6,o=e.c-e.a*i,s=r?r.x:1e6,u=e.c-e.a*s);var a=[i,o],f=[s,u];t[e.region.l.index].push(a,f),t[e.region.r.index].push(a,f)}),t.map(function(t,n){var r=e[n][0],i=e[n][1];return t.forEach(function(e){e.angle=Math.atan2(e[0]-r,e[1]-i)}),t.sort(function(e,t){return e.angle-t.angle}).filter(function(e,n){return!n||e.angle-t[n-1].angle>1e-10})})};var ho={l:"r",r:"l"};d3.geom.delaunay=function(e){var t=e.map(function(){return[]}),n=[];return oi(e,function(n){t[n.region.l.index].push(e[n.region.r.index])}),t.forEach(function(t,r){var i=e[r],s=i[0],o=i[1];t.forEach(function(e){e.angle=Math.atan2(e[0]-s,e[1]-o)}),t.sort(function(e,t){return e.angle-t.angle});for(var u=0,a=t.length-1;u<a;u++)n.push([i,t[u],t[u+1]])}),n},d3.geom.quadtree=function(e,t,n,r,i){function s(e,t,n,r,i,s){if(isNaN(t.x)||isNaN(t.y))return;if(e.leaf){var u=e.point;u?Math.abs(u.x-t.x)+Math.abs(u.y-t.y)<.01?o(e,t,n,r,i,s):(e.point=null,o(e,u,n,r,i,s),o(e,t,n,r,i,s)):e.point=t}else o(e,t,n,r,i,s)}function o(e,t,n,r,i,o){var u=(n+i)*.5,a=(r+o)*.5,f=t.x>=u,l=t.y>=a,c=(l<<1)+f;e.leaf=!1,e=e.nodes[c]||(e.nodes[c]=ui()),f?n=u:i=u,l?r=a:o=a,s(e,t,n,r,i,o)}var u,a=-1,f=e.length;f&&isNaN(e[0].x)&&(e=e.map(fi));if(arguments.length<5)if(arguments.length===3)i=r=n,n=t;else{t=n=Infinity,r=i=-Infinity;while(++a<f)u=e[a],u.x<t&&(t=u.x),u.y<n&&(n=u.y),u.x>r&&(r=u.x),u.y>i&&(i=u.y);var l=r-t,c=i-n;l>c?i=n+l:r=t+c}var h=ui();return h.add=function(e){s(h,e,t,n,r,i)},h.visit=function(e){ai(e,h,t,n,r,i)},e.forEach(h.add),h},d3.time={};var po=Date,vo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];li.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){mo.setUTCDate.apply(this._,arguments)},setDay:function(){mo.setUTCDay.apply(this._,arguments)},setFullYear:function(){mo.setUTCFullYear.apply(this._,arguments)},setHours:function(){mo.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){mo.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){mo.setUTCMinutes.apply(this._,arguments)},setMonth:function(){mo.setUTCMonth.apply(this._,arguments)},setSeconds:function(){mo.setUTCSeconds.apply(this._,arguments)},setTime:function(){mo.setTime.apply(this._,arguments)}};var mo=Date.prototype,go="%a %b %e %H:%M:%S %Y",yo="%m/%d/%y",bo="%H:%M:%S",wo=vo,Eo=wo.map(ci),So=["January","February","March","April","May","June","July","August","September","October","November","December"],xo=So.map(ci);d3.time.format=function(e){function t(t){var r=[],i=-1,s=0,o,u;while(++i<n)e.charCodeAt(i)==37&&(r.push(e.substring(s,i),(u=Po[o=e.charAt(++i)])?u(t):o),s=i+1);return r.push(e.substring(s,i)),r.join("")}var n=e.length;return t.parse=function(t){var n={y:1900,m:0,d:1,H:0,M:0,S:0,L:0},r=hi(n,e,t,0);if(r!=t.length)return null;"p"in n&&(n.H=n.H%12+n.p*12);var i=new po;return i.setFullYear(n.y,n.m,n.d),i.setHours(n.H,n.M,n.S,n.L),i},t.toString=function(){return e},t};var To=d3.format("02d"),No=d3.format("03d"),Co=d3.format("04d"),ko=d3.format("2d"),Lo=pi(wo),Ao=pi(Eo),Oo=pi(So),Mo=di(So),_o=pi(xo),Do=di(xo),Po={a:function(e){return Eo[e.getDay()]},A:function(e){return wo[e.getDay()]},b:function(e){return xo[e.getMonth()]},B:function(e){return So[e.getMonth()]},c:d3.time.format(go),d:function(e){return To(e.getDate())},e:function(e){return ko(e.getDate())},H:function(e){return To(e.getHours())},I:function(e){return To(e.getHours()%12||12)},j:function(e){return No(1+d3.time.dayOfYear(e))},L:function(e){return No(e.getMilliseconds())},m:function(e){return To(e.getMonth()+1)},M:function(e){return To(e.getMinutes())},p:function(e){return e.getHours()>=12?"PM":"AM"},S:function(e){return To(e.getSeconds())},U:function(e){return To(d3.time.sundayOfYear(e))},w:function(e){return e.getDay()},W:function(e){return To(d3.time.mondayOfYear(e))},x:d3.time.format(yo),X:d3.time.format(bo),y:function(e){return To(e.getFullYear()%100)},Y:function(e){return Co(e.getFullYear()%1e4)},Z:_i,"%":function(e){return"%"}},Ho={a:vi,A:mi,b:gi,B:yi,c:bi,d:Ci,e:Ci,H:ki,I:ki,L:Oi,m:Ni,M:Li,p:Mi,S:Ai,x:wi,X:Ei,y:xi,Y:Si},Bo=/^\s*\d+/,jo=d3.map({am:0,pm:1});d3.time.format.utc=function(e){function t(e){try{po=li;var t=new po;return t._=e,n(t)}finally{po=Date}}var n=d3.time.format(e);return t.parse=function(e){try{po=li;var t=n.parse(e);return t&&t._}finally{po=Date}},t.toString=n.toString,t};var Fo=d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");d3.time.format.iso=Date.prototype.toISOString?Di:Fo,Di.parse=function(e){var t=new Date(e);return isNaN(t)?null:t},Di.toString=Fo.toString,d3.time.second=Pi(function(e){return new po(Math.floor(e/1e3)*1e3)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*1e3)},function(e){return e.getSeconds()}),d3.time.seconds=d3.time.second.range,d3.time.seconds.utc=d3.time.second.utc.range,d3.time.minute=Pi(function(e){return new po(Math.floor(e/6e4)*6e4)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*6e4)},function(e){return e.getMinutes()}),d3.time.minutes=d3.time.minute.range,d3.time.minutes.utc=d3.time.minute.utc.range,d3.time.hour=Pi(function(e){var t=e.getTimezoneOffset()/60;return new po((Math.floor(e/36e5-t)+t)*36e5)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*36e5)},function(e){return e.getHours()}),d3.time.hours=d3.time.hour.range,d3.time.hours.utc=d3.time.hour.utc.range,d3.time.day=Pi(function(e){var t=new po(1970,0);return t.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t},function(e,t){e.setDate(e.getDate()+t)},function(e){return e.getDate()-1}),d3.time.days=d3.time.day.range,d3.time.days.utc=d3.time.day.utc.range,d3.time.dayOfYear=function(e){var t=d3.time.year(e);return Math.floor((e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5)},vo.forEach(function(e,t){e=e.toLowerCase(),t=7-t;var n=d3.time[e]=Pi(function(e){return(e=d3.time.day(e)).setDate(e.getDate()-(e.getDay()+t)%7),e},function(e,t){e.setDate(e.getDate()+Math.floor(t)*7)},function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%7)/7)-(n!==t)});d3.time[e+"s"]=n.range,d3.time[e+"s"].utc=n.utc.range,d3.time[e+"OfYear"]=function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%7)/7)}}),d3.time.week=d3.time.sunday,d3.time.weeks=d3.time.sunday.range,d3.time.weeks.utc=d3.time.sunday.utc.range,d3.time.weekOfYear=d3.time.sundayOfYear,d3.time.month=Pi(function(e){return e=d3.time.day(e),e.setDate(1),e},function(e,t){e.setMonth(e.getMonth()+t)},function(e){return e.getMonth()}),d3.time.months=d3.time.month.range,d3.time.months.utc=d3.time.month.utc.range,d3.time.year=Pi(function(e){return e=d3.time.day(e),e.setMonth(0,1),e},function(e,t){e.setFullYear(e.getFullYear()+t)},function(e){return e.getFullYear()}),d3.time.years=d3.time.year.range,d3.time.years.utc=d3.time.year.utc.range;var Io=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],qo=[[d3.time.second,1],[d3.time.second,5],[d3.time.second,15],[d3.time.second,30],[d3.time.minute,1],[d3.time.minute,5],[d3.time.minute,15],[d3.time.minute,30],[d3.time.hour,1],[d3.time.hour,3],[d3.time.hour,6],[d3.time.hour,12],[d3.time.day,1],[d3.time.day,2],[d3.time.week,1],[d3.time.month,1],[d3.time.month,3],[d3.time.year,1]],Ro=[[d3.time.format("%Y"),function(e){return!0}],[d3.time.format("%B"),function(e){return e.getMonth()}],[d3.time.format("%b %d"),function(e){return e.getDate()!=1}],[d3.time.format("%a %d"),function(e){return e.getDay()&&e.getDate()!=1}],[d3.time.format("%I %p"),function(e){return e.getHours()}],[d3.time.format("%I:%M"),function(e){return e.getMinutes()}],[d3.time.format(":%S"),function(e){return e.getSeconds()}],[d3.time.format(".%L"),function(e){return e.getMilliseconds()}]],Uo=d3.scale.linear(),zo=Ii(Ro);qo.year=function(e,t){return Uo.domain(e.map(Ri)).ticks(t).map(qi)},d3.time.scale=function(){return Bi(d3.scale.linear(),qo,zo)};var Wo=qo.map(function(e){return[e[0].utc,e[1]]}),Xo=[[d3.time.format.utc("%Y"),function(e){return!0}],[d3.time.format.utc("%B"),function(e){return e.getUTCMonth()}],[d3.time.format.utc("%b %d"),function(e){return e.getUTCDate()!=1}],[d3.time.format.utc("%a %d"),function(e){return e.getUTCDay()&&e.getUTCDate()!=1}],[d3.time.format.utc("%I %p"),function(e){return e.getUTCHours()}],[d3.time.format.utc("%I:%M"),function(e){return e.getUTCMinutes()}],[d3.time.format.utc(":%S"),function(e){return e.getUTCSeconds()}],[d3.time.format.utc(".%L"),function(e){return e.getUTCMilliseconds()}]],Vo=Ii(Xo);Wo.year=function(e,t){return Uo.domain(e.map(zi)).ticks(t).map(Ui)},d3.time.scale.utc=function(){return Bi(d3.scale.linear(),Wo,Vo)}})();
\ No newline at end of file
diff --git a/plugins/univbristopo/static/js/tooltip.topology.js b/plugins/univbristopo/static/js/tooltip.topology.js
new file mode 100644 (file)
index 0000000..eeac3e9
--- /dev/null
@@ -0,0 +1,118 @@
+var tooltip=function(){
+ var id = 'tt';
+ var top = 800; //3
+ var left = 3; //3
+ var maxw = 300;
+ var speed = 10;
+ var timer = 20;
+ var endalpha = 95;
+ var alpha = 0;
+ var tt,t,c,b,h;
+ var ie = document.all ? true : false;
+ return{
+          show:function(v,w){
+                  //console.log(tt);
+
+                  if(tt == null){
+                           tt = document.createElement('div');
+                           tt.setAttribute('id',id);
+                           //tt.setAttribute('style',"display: table; display: inline-block;");
+                           t = document.createElement('div');
+                           t.setAttribute('id',id + 'top');
+                           c = document.createElement('div');
+                           c.setAttribute('id',id + 'cont');
+                           b = document.createElement('div');
+                           b.setAttribute('id',id + 'bot');
+                           tt.appendChild(t);
+                           tt.appendChild(c);
+                           tt.appendChild(b);
+                         
+                           //document.body.appendChild(tt);
+                           var objTo = document.getElementById('topo_plugin')
+                           objTo.appendChild(tt);
+                           tt.style.position='absolute';
+                          // tt.style.display='inline-block';
+                           tt.style.opacity = 0;
+                           //tt.style.filter = 'alpha(opacity=0)';
+                           objTo.onmousemove = this.pos;
+                  }//end of if tt==null
+
+                  tt.style.display = 'block';
+                  c.innerHTML = v;
+
+                  //console.log("///////////////tooltip/////////",c);
+                  tt.style.width = w ? w + 'px' : 'auto';
+
+                  if(!w && ie){
+                           t.style.display = 'none';
+                           b.style.display = 'none';
+                           tt.style.width = tt.offsetWidth;
+                           t.style.display = 'block';
+                           b.style.display = 'block';
+                  } //end of if(!w && ie)
+
+                 h=0;
+
+                 if(tt.offsetWidth > maxw){
+                       tt.style.width = maxw + 'px';
+                 }
+
+                  h = parseInt(tt.offsetHeight) + top;
+                  clearInterval(tt.timer);
+                  tt.timer = setInterval(function(){tooltip.fade(1)},timer);
+
+               //console.log("//////////////h:",h);
+                  
+                 },
+
+
+                 pos:function(e){
+                          //console.log(ie);
+                          //var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
+                          //var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
+                          var u=e.clientY;
+                          var l=e.clientX;
+
+                         // if ((u-h)<0){
+                       //      tt.style.top =0 + 'px';
+                         // }
+                         // else{
+                       //      tt.style.top =(u-h) + 'px';
+                        //  }
+                          tt.style.top = e.clientY +'px';
+                          //console.log("top:",tt.style.top);
+                         // console.log("clientY:",e.clientY);
+                          tt.style.left = (e.clientX-300) + 'px';
+
+                 },
+
+                 fade:function(d){
+                          var a = alpha;
+                          if((a != endalpha && d == 1) || (a != 0 && d == -1)){
+                                  var i = speed;
+                                  if(endalpha - a < speed && d == 1){
+                                       i = endalpha - a;
+                                  }else if(alpha < speed && d == -1){
+                                    i = a;
+                                  }
+                                  alpha = a + (i * d);
+                                  tt.style.opacity = alpha * .01;
+                                  //tt.style.filter = 'alpha(opacity=' + alpha + ')';
+                         }else{
+                                  clearInterval(tt.timer);
+                                  if(d == -1){
+                                       tt.style.display = 'none'
+                                  }
+                         }
+                  },
+
+
+                hide:function(){
+                  clearInterval(tt.timer);
+                  tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
+                 }
+
+        }; //end of show function
+  }();// end of return
+
+
diff --git a/plugins/univbristopo/static/js/univbristopo.js b/plugins/univbristopo/static/js/univbristopo.js
new file mode 100644 (file)
index 0000000..c229c51
--- /dev/null
@@ -0,0 +1,1183 @@
+/**
+ * univbristopo:    ofelia openflow topology plugin
+ * Version:         3.0
+ * Description:     plugin to view ofelia topology in myslice
+ * Requires:        js/plugin.js
+ * URL:             http://www.myslice.info
+ * Author:          Frederic Francois <f.francois@bristol.ac.uk>
+ * Copyright:       Copyright 2013-2014 Bristol University
+ * License:         GPLv3
+ */
+
+(function($){
+
+    d3_nodes=[];
+    d3_links=[];
+    links_list=[];
+    d=2;
+    window.query_itr=0;
+    topoviewer_state={mode:"edit",link_type:"non-optical"};
+    //svg=d3;
+
+    var UnivbrisTopo = Plugin.extend({
+
+        init: function(options, element) {
+            this._super(options, element);
+            this.listen_query(options.query_uuid);
+           jQuery('#topo_plugin').hide();
+           //console.log("topo init called");
+        },
+
+       new_record: function(record)
+        {
+           var urn = record['urn'];
+            var pos = urn.search('link');
+           
+           if (pos!=-1){
+                   var link = urn.substring(pos+5);
+                   pos = link.search("_");
+                   var head_node=link.substring(0,pos);
+                   link=link.substring(pos+1);
+                   pos = link.search("_");
+                   var head_port=link.substring(0,pos);
+                   link=link.substring(pos+1);
+                   pos = link.search("_");
+                   var tail_node=link.substring(0,pos);
+                   link=link.substring(pos+1);
+                   var tail_port=link;
+
+                   var link_type=0;
+                   if (urn.search('opticalpacket')!=-1){
+                       link_type=4;
+                   }
+                   else if (urn.search('optical')!=-1){
+                       link_type=1;
+                   }
+                   else if (urn.search('compute')!=-1){
+                       link_type=2;
+                   }
+                   else if (urn.search('federation')!=-1){
+                       link_type=3;
+                   }
+                   
+
+                   //get island name
+                   pos = urn.search('ofam');
+                   var testbed=urn.substring(pos+5);
+                   testbed=testbed.substring(0, testbed.search('link')-1);
+
+                   switch (link_type){
+                       case 0:
+                          var src_id=addNode(head_node,testbed,"packet");
+                          var dst_id=addNode(tail_node,testbed,"packet");
+                          //var tmp_link={};
+                          addLink(src_id,dst_id,head_port,tail_port,urn);
+                          /*tmp_link['source']=src_id;
+                          tmp_link['target']=dst_id;
+                           tmp_link['src_port']=head_port;
+                          tmp_link['dst_port']=tail_port;
+                          tmp_link['value']=urn;
+                          d3_links.push(tmp_link);*/
+                          break;
+
+                       case 1:
+                          var src_id=addNode(head_node,testbed,"optical");
+                          var dst_id=addNode(tail_node,testbed,"optical");
+                          //var tmp_link={};
+                          addLink(src_id,dst_id,head_port,tail_port,urn);
+                          /*tmp_link['source']=src_id;
+                          tmp_link['target']=dst_id;
+                          tmp_link['src_port']=head_port;
+                          tmp_link['dst_port']=tail_port;
+                          tmp_link['value']=urn;
+                          d3_links.push(tmp_link);*/
+                          break;
+
+                       case 2:
+                          var src_id=addNode(head_node,testbed,"packet");
+                          var dst_id=addNode(tail_node,testbed,"compute");
+                          //var tmp_link={};
+                          addLink(src_id,dst_id,head_port,tail_port,urn);
+                          /*tmp_link['source']=src_id;
+                          tmp_link['target']=dst_id;
+                          tmp_link['src_port']=head_port;
+                          tmp_link['dst_port']=tail_port;
+                          tmp_link['value']=urn;
+                          d3_links.push(tmp_link);*/
+                          break;
+
+                       case 3:
+                          var src_id=addNode(head_node,testbed,"federation");
+                          var dst_id=addNode(tail_node,testbed,"packet");
+                          //var tmp_link={};
+                          addLink(src_id,dst_id,head_port,tail_port,urn);
+                          /*tmp_link['source']=src_id;
+                          tmp_link['target']=dst_id;
+                          tmp_link['src_port']=head_port;
+                          tmp_link['dst_port']=tail_port;
+                          tmp_link['value']=urn;
+                          d3_links.push(tmp_link);*/
+                          break;
+
+                       case 4:
+                          var src_id=addNode(head_node,testbed,"optical");
+                          var dst_id=addNode(tail_node,testbed,"packet");
+                          //var tmp_link={};
+                          addLink(src_id,dst_id,head_port,tail_port,urn);
+                          /*tmp_link['source']=src_id;
+                          tmp_link['target']=dst_id;
+                          tmp_link['src_port']=head_port;
+                          tmp_link['dst_port']=tail_port;
+                          tmp_link['value']=urn;
+                          d3_links.push(tmp_link);*/
+                          break;
+                   }
+           }
+        },
+
+       on_new_record: function(record)
+        {
+          //if (query_itr=2){
+            this.new_record(record);
+          //}
+        },
+
+
+       on_query_done: function()
+       {
+         query_itr=query_itr+1;
+         if (query_itr==2){
+               return;
+         }
+         //console.log("graph all done called:"+query_itr);
+         describeNodes();
+         calLinkNum();
+          //console.log(d3_links);
+         //if (query_itr=2){
+         //$("#univbris_welcome").hide();
+         //jQuery("#univbris_flowspace_selection").show();
+         //$("#link_zoom_in").click(zoomIn(0.25));
+         /* d3 data */
+
+       
+
+         var nIslands=1, //replace
+             pad = 5,
+              width = parseInt($("#topo_plugin_width").css("width")); //800,//parseInt($("#topologyContainer").css("width")), /* Obtain width from container */
+              if(width==0){width=800;} 
+              height = 400;
+
+         //Islands area generation
+         var p = width/height
+              ny = Math.sqrt(nIslands/p),
+              nx = Math.ceil(p*ny),
+              ny = Math.ceil(ny),
+              foci = [];
+
+         if (nx*ny > nIslands){
+               if (nx > ny && (nx-1)*ny >= nIslands)
+               nx--;
+               else if( nx <= ny && nx*(ny-1) >= nIslands)
+               ny--;
+         }
+
+         var aw = Math.floor((width-(nx+1)*pad)/nx),
+              ah = Math.floor((height-(ny+1)*pad)/ny);
+
+         for (i=0; i<nIslands; i++){
+               tx0 = pad + (pad + aw)*(Math.floor(i%nx));
+               ty0 = pad + (pad + ah)*(Math.floor(i/nx));
+               foci[i] = {x0: tx0, x1: tx0 + aw, y0: ty0, y1: ty0 + ah};
+         }
+
+
+         function randomXToY(minVal,maxVal,floatVal){
+               var randVal = minVal+(Math.random()*(maxVal-minVal));
+               return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
+         };
+
+         function pEllipse(set){
+               function getDistance(p){
+                       return Math.pow((p[0]-cx),2)/Math.pow(rx,2) + Math.pow((p[1]-cy),2)/Math.pow(ry,2);
+               };
+
+               d = 2;
+
+               try {
+                       cx = (set.x1 + set.x0)/2;
+                       rx = ((set.x1 - set.x0)/2 + (set.y1 - set.y0)/2)/2;
+                       cy = (set.y1 + set.y0)/2;
+                       ry = (set.y1 - set.y0)/2;
+       
+                       while (d>1) {
+                               p = [randomXToY(set.x0, set.x1), randomXToY(set.y0, set.y1) ];
+                               d = getDistance(p);     
+                       }
+               } catch(err) {
+                       p = [];
+               }
+
+               return p;
+         };
+
+
+        var epoints= [];
+         for (i=0;i<d3_nodes.length;i++){
+               epoints.push(foci[d3_nodes[i]['group']]);
+
+         };
+          
+          var data = {};
+
+         var nodes=[];
+
+         //console.log("nodes");
+         //console.log(d3_nodes);
+         //console.log("links");
+         //console.log(d3_links);
+
+         for (i=0;i<d3_nodes.length;i++){
+               var node={};
+               node['nodeValue']=d3_nodes[i].nodeValue;
+               node['nodeName']=d3_nodes[i].nodeName;
+               node['image']=d3_nodes[i].image;
+               node['color']= "";
+               node['group']=d3_nodes[i].group;
+               node['location']=d3_nodes[i].location;
+               node['description']= d3_nodes[i].description;
+               node['fixed']= false;
+               node['radius']= 10;
+               if (d3_nodes[i].type == "compute"){
+                       node['type']=d3_nodes[i].type + " server";
+               }
+               else{
+                       node['type']=d3_nodes[i].type + " switch";
+               }
+               node['available']= d3_nodes[i].available;
+               nodes.push(node);
+         };
+
+         data["nodes"]=nodes;
+
+         var links=[];
+         for (i=0;i<d3_links.length;i++){
+               var link={};
+               link['source']= d3_links[i].source;
+               link['target']= d3_links[i].target;
+               link['value']= d3_links[i].value;
+               link['linknum']=d3_links[i].linknum;
+               links.push(link);
+         }
+
+        data["links"]=links;
+
+
+       function getLinkStyle(d, attr){
+               //rsc_ids = d.value.split("-");
+               //console.log('link with: '+d.value+" event"); 
+               //console.log("getlinkstyle attr:",attr);
+               //console.log("topoviewer_state:",topoviewer_state);
+       
+               //console.log(d);
+               if (topoviewer_state.mode!="edit"){
+                       
+                       return  null;
+               }
+
+
+               if(d.value.search("optical")!=-1 && topoviewer_state.link_type=="optical"){ //link is optical
+                       //if(topoviewer_state.link_type=="optical"){
+                               if(attr=="click"){
+                                         var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                                         var nodes = $('input',port_table.fnGetNodes());
+                                         var checked=false;
+
+                                         for(i=0;i<nodes.length;i++){
+                                                       if (nodes[i].id==d.value){
+                                                               nodes[i].checked=!nodes[i].checked;
+                                                               checked=nodes[i].checked;
+                                                               break;
+                                                       }
+                                         };
+
+
+                                         if (checked==true){
+                                               var values = {'stroke': 'black', 'stroke-width': '5px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+                                         else{
+                                               var values = {'stroke': '#ccc', 'stroke-width': '4px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+
+                               }else if(attr=="mouseover"){
+                       
+                                       var values = {'stroke': 'blue', 'stroke-width': '4px' };
+                                       //console.log("in mouseover return"+ JSON.stringify(values));
+                                       return JSON.stringify(values);
+                               }else{
+                       
+                                       /*
+                                       if( ($(":checkbox#"+rsc_ids[0]+":checked").length && rsc_ids[1].indexOf("eth") != -1) ||($(":checkbox#"+rsc_ids[0]+":checked").length && $(":checkbox#"+rsc_ids[1]+":checked").length)){
+                                               if (attr == "stroke")
+                                                       return "#666";
+                                               else
+                                                       return 2;
+                                       }else{
+                                               if (attr == "stroke")
+                                                       return "#ccc";
+                                               else
+                                                       return 2;
+                                       //}
+                                       */
+
+                                       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                                       var nodes = $('input',port_table.fnGetNodes());
+                                       var checked=false;
+
+                                       for(i=0;i<nodes.length;i++){
+                                                       if (nodes[i].id==d.value){
+                                                               //nodes[i].checked=!nodes[i].checked;
+                                                               checked=nodes[i].checked;
+                                                               break;
+                                                       }
+                                       };
+
+                                       if (checked==true){
+                                               var values = {'stroke': 'black', 'stroke-width': '5px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+                                         else{
+                                               var values = {'stroke': '#ccc', 'stroke-width': '4px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+                                       //return {'stroke': '#ccc', 'stroke-width': '2px' };
+                               }
+                       //}
+                       //else{
+                       //      return  d.style;
+                       //}
+
+               }
+               else{//link is not optical
+                       if(topoviewer_state.link_type=="non-optical" && !(d.value.search("opticalpacket")==-1 && d.value.search("optical")!=-1) ){
+                               if(attr=="click"){
+                                         var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                                         var nodes = $('input',port_table.fnGetNodes());
+                                         var checked=false;
+
+                                         for(i=0;i<nodes.length;i++){
+                                                       if (nodes[i].id==d.value){
+                                                               nodes[i].checked=!nodes[i].checked;
+                                                               checked=nodes[i].checked;
+                                                               break;
+                                                       }
+                                         };
+
+
+                                         if (checked==true){
+                                               var values = {'stroke': 'black', 'stroke-width': '5px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+                                         else{
+                                               var values = {'stroke': '#ccc', 'stroke-width': '4px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+
+                               }else if(attr=="mouseover"){
+                       
+                                       var values = {'stroke': 'blue', 'stroke-width': '4px' };
+                                       //console.log("in mouseover return"+ JSON.stringify(values));
+                                       return JSON.stringify(values);
+                               }else{
+                       
+                                       /*
+                                       if( ($(":checkbox#"+rsc_ids[0]+":checked").length && rsc_ids[1].indexOf("eth") != -1) ||($(":checkbox#"+rsc_ids[0]+":checked").length && $(":checkbox#"+rsc_ids[1]+":checked").length)){
+                                               if (attr == "stroke")
+                                                       return "#666";
+                                               else
+                                                       return 2;
+                                       }else{
+                                               if (attr == "stroke")
+                                                       return "#ccc";
+                                               else
+                                                       return 2;
+                                       //}
+                                       */
+
+                                       var port_table=$("#univbris_foam_ports_selection__table").dataTable();
+                                       var nodes = $('input',port_table.fnGetNodes());
+                                       var checked=false;
+
+                                       for(i=0;i<nodes.length;i++){
+                                                       if (nodes[i].id==d.value){
+                                                               //nodes[i].checked=!nodes[i].checked;
+                                                               checked=nodes[i].checked;
+                                                               break;
+                                                       }
+                                       };
+
+                                       if (checked==true){
+                                               var values = {'stroke': 'black', 'stroke-width': '5px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+                                         else{
+                                               var values = {'stroke': '#ccc', 'stroke-width': '4px' };
+                                               //console.log("in mouseover return"+ JSON.stringify(values));
+                                               return JSON.stringify(values);
+                                         }
+                                       //return {'stroke': '#ccc', 'stroke-width': '2px' };
+                               }
+                       }
+                       else{
+                               return  null;
+                       }
+                       
+               }
+       
+       };
+
+       function getBaseNodeColor(d){
+               var group = 0;
+               group = d.group;
+               return d3.rgb(d.color.toString().toString()).darker(.15*group);
+       };
+
+       function getNodeCircleStyle(d, attr){
+               selected_len =0;// $(":checkbox:checked.node_id_"+d.nodeValue).length;
+               all_len = 0;//$(":checkbox:.node_id_"+d.nodeValue).length;
+               //selected_server = $(".server_node_"+d.nodeValue+".connected").length;
+               if(attr == "drag"){
+                       return d3.rgb(d.color.toString()).brighter(5);
+               }else if(attr=="click"){
+                        if(selected_len == all_len) {
+                               $(":checkbox:checked.node_id_"+d.nodeValue).click();
+                               return getBaseNodeColor(d);
+                        }else{
+                               $(":checkbox:not(:checked).node_id_"+d.nodeValue).click();
+                               return d3.rgb(d.color.toString()).darker(5);
+                       }
+               }else if (attr == "dragstop" && selected_len == 0){
+                       return getBaseNodeColor(d);
+               }else{
+                               if (attr == "fill"){
+                                       return getBaseNodeColor(d);
+                               } else{
+                                       if (selected_len != 0){
+                                               return d3.rgb(d.color.toString()).darker(5);
+                                       }else{
+                                               return getBaseNodeColor(d);
+                                       }
+                               }
+               }
+       };
+
+       function getNodesIsland(d){
+               var nNodes = 0;
+               data.nodes.forEach(function(o, i){
+                  if(o.group == d){
+                       nNodes++;
+                  }
+               });
+           return nNodes;
+       };
+
+        cur_zoom = 1;
+        zoom_in_active = false;
+        zoom_out_active = false;
+
+       
+       function zoomIn(zoom){
+           if(zoom_in_active == false && zoom_out_active == false){
+               $("#link_zoom_in img").css("background-color", "#666");
+               cur_zoom = cur_zoom + zoom;
+               zoom_in_active = true;
+           }
+
+           else if(zoom_in_active == true){
+               cur_zoom = cur_zoom - zoom;
+               $("#link_zoom_in img").css("background-color", "");
+               $("#target, svg, g").css("cursor", "move");
+               zoom_in_active = false;
+           }
+
+           else{
+               cur_zoom = cur_zoom + zoom + zoom;
+               $("#link_zoom_out img").css("background-color", "");
+               $("#link_zoom_in img").css("background-color", "#666");
+               zoom_out_active = false;
+               zoom_in_active = true;
+           }
+       };
+
+
+       function zoomOut(zoom){
+           if(zoom_out_active == false && zoom_in_active == false){
+               if((cur_zoom - zoom) >0){
+                   $("#link_zoom_out img").css("background-color", "#666");
+                   cur_zoom = cur_zoom - zoom;
+                   zoom_out_active = true;
+               }
+               else{
+                   $("#target, svg, g").css("cursor", "move");
+               }
+           }   
+           else if(zoom_out_active == true){
+               cur_zoom = cur_zoom + zoom;
+               $("#link_zoom_out img").css("background-color", "");
+               $("#target, svg, g").css("cursor", "move");
+               zoom_out_active = false;
+           }
+
+           else{
+               cur_zoom = cur_zoom - zoom;
+               zoom_out_active = false;
+               $("#link_zoom_in img").css("background-color", "");
+               if((cur_zoom - zoom) > 0){
+                   $("#link_zoom_out img").css("background-color", "#666");
+                   zoom_out_active = true;
+               }
+               else{
+                   $("#target, svg, g").css("cursor", "move");
+               }
+           }
+       };
+
+       function zoomReset(){
+           cur_zoom = 0.99;
+           posx = 0;
+           posy = 0;
+           return redraw();
+       };
+
+       
+
+       function click(){
+           //console.log('into target clicked with zoomin:'+zoom_in_active);
+           
+           if (zoom_in_active == true || zoom_out_active == true){
+               var mouseClick = d3.mouse(this);
+               _x = -mouseClick[0]/2;
+               _y = -mouseClick[1]/2;
+               if(zoom_out_active == true){
+                   _x = -_x/2;
+                   _y = -_y/2;
+               }
+               posx += _x;
+               posy += _y;
+               zoom_in_active = false;
+               zoom_out_active = false;
+               return redraw();
+           }
+       };
+
+       $('#target').click(function(){
+               //console.log('target clicked');
+               click();
+       });
+
+       function redraw() {
+               //  trans=[(Math.round(width/cur_zoom) - width)/2, (Math.round(height/cur_zoom) - height)/2];
+                   trans = [posx, posy];
+                   svg.transition()
+                      .duration(500)
+                      .attr('x', function(d){ return d.x; })
+                      .attr('y', function(d){ return d.y; })
+                      .attr("transform", 
+                           "translate(" + trans +")"
+                           + "scale(" + cur_zoom + ")");
+                  $("#link_zoom_in img").css("background-color","");
+                  $("#link_zoom_out img").css("background-color","");
+                  $("#target, svg, g").css("cursor", "move"); 
+       };
+
+       //Global position of the canvas
+       var posx = 0;
+       var posy = 0;
+
+       /* Translation - bound to drag behavior */
+       dragMap = function(d) {
+       //No drag while zoom option active
+          if(zoom_in_active == false && zoom_out_active == false){
+             posx += d3.event.dx;
+             posy += d3.event.dy;
+             svg.attr('x', function(d) { return d.x; })
+                .attr('y', function(d) { return d.y; })
+                .attr("transform", "translate(" + posx + "," + posy + ") scale (" + cur_zoom + ")");
+          }
+       };
+
+       
+       /* Instantiation General parameters*/
+       var  padding = 6,
+            color = d3.scale.category10().domain(d3.range(nIslands)),
+            radius = d3.scale.sqrt().range([0, 12]);
+
+       svg = d3.select("#target")
+           .on("click", click)
+           .append("svg")
+               .attr("pointer-events", "all")
+               .attr("width", width)
+               .attr("height", height)
+               .datum({x: 0, y: 0})
+               .call(d3.behavior.drag().on("drag", dragMap))
+           .append("svg:g").on("zoom", redraw)
+               .attr("cursor", "move")       
+       
+       // DATA VARIABLES
+       var nodes = data.nodes;
+       // Set color for each node
+       nodes.forEach(function(d) {
+           if (d.available != "False") {
+               d.color = color(d.group%nIslands);
+           } else {
+               d.color = "#CCC";
+           }
+       });
+
+       var links = data.links;
+
+       // Modified version (Carolina)
+       var force = d3.layout.force()
+           .gravity(1/(2*nIslands))
+           .distance(200/nIslands)
+           .friction(0.6)
+           .size([width, height])
+           .nodes(nodes)
+           .links(links)
+           .start();
+
+       
+
+       var EMPTY_ISLAND = "Island with no resources";
+
+       //XXX:Very ugly, needs improvement
+       var islandsLocs = []
+       for (i = 0; i< nIslands; i++){
+               islandsLocs[i] = EMPTY_ISLAND;
+       }
+
+       nodeInitialPos = []
+       for (i = 0; i< nodes.length; i++){
+               nodeInitialPos[i] = [nodes[i].x, nodes[i].y];
+               if (islandsLocs[nodes[i].group] == EMPTY_ISLAND){
+                       islandsLocs[nodes[i].group] = nodes[i].location;
+               }
+       }
+
+       var dataislands = []
+       for (i = 0; i< nIslands; i++){
+               dataislands[i] = {rx: (aw/2 + ah/2)/2, ry: ah/2, cx:(foci[i].x0+foci[i].x1)/2, cy:(foci[i].y0+foci[i].y1)/2, group: i, location: islandsLocs[i]};
+       }
+
+       var islands = svg.selectAll(".island")
+           .data(dataislands)
+         .enter().append("g")
+               .attr("class", "island")
+
+       var iellipses = islands.append("ellipse")
+           .attr("rx", function(d) { return d.rx; })
+           .attr("ry", function(d) { return d.ry; })
+           .attr("cx",function(d) { return d.cx; })
+           .attr("cy", function(d) { return d.cy; })
+           .style("fill", function(d) { return color(d.group%nIslands); })
+           .style("stroke", function(d) { return color(d.group%nIslands);}) 
+           .style("opacity", 0.3)
+           .style("stroke-opacity", 0.7)
+
+       var ilabels = islands.append("text")
+             .attr("text-anchor", "middle")
+             .attr("y", function(d){ return d.cy + d.ry*0.9})
+             .attr("x", function(d){ return d.cx})
+             .attr("font-color", function(d) { return d3.rgb(color(d.group%nIslands)).darker(5); })
+             .style("opacity",1)
+             .style("cursor", "default")
+             .text(function(d) { return d.location });
+
+       //First ellipse animation on startup
+       animate();
+
+       var link = svg.selectAll(".link")
+           .data(links)
+         .enter().append("path")
+           .attr("class", "link").style({'fill': 'black','stroke': "#ccc", 'stroke-width': "4px" });
+
+       link.on("click", function(d) {
+                               d3.select(this).style(JSON.parse(getLinkStyle(d, "click")));
+                       }       
+       );
+
+       link.on("mouseover", function(d) {
+                               //console.log(getLinkStyle(d, "mouseover"));
+                               d3.select(this).style(JSON.parse(getLinkStyle(d, "mouseover")));
+                              // d3.select(this).style({'stroke': "blue", 'stroke-width': "3px" })
+                       }       
+       );
+
+       link.on("mouseout", function(d) {
+                               //console.log("mouseout");
+                               d3.select(this).style(JSON.parse(getLinkStyle(d, "mouseout")));
+                              // d3.select(this).style({'stroke': "#CCC", 'stroke-width': "2px" })
+                       }       
+       );
+
+       var node = svg.selectAll(".node")
+           .data(nodes)
+         .enter().append("g")
+           .attr("class", "node")
+           .call(force.drag)
+           .call(d3.behavior.drag()
+           .on("dragstart", function(d, i, e) {
+                   d.fixed = false;
+                   force.stop();
+           })
+           .on("drag", function(d, i) {
+                   d.px += d3.event.dx;
+                   d.py += d3.event.dy;
+                   d.x += d3.event.dx;
+                   d.y += d3.event.dy;
+                   d3.select(this).selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "drag");}) 
+                   tick();
+           })
+           .on("dragend", function(d, i) {
+                 //  d.fixed = true; // of course set the node to fixed so the force does not include the node in its auto positioning stuff //with the force.stop() it won't autopositioning, allowing to regroup the nodes
+                   d3.select(this).selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "dragstop");})
+                   tick();
+                   force.stop();
+           })
+           );
+
+       
+       node.append("circle")
+           .attr("r", function(d) { return d.radius; })
+           .style("stroke", function(d){return getNodeCircleStyle(d, "stroke");})
+           .style("fill", function(d){return getNodeCircleStyle(d, "fill");});
+
+       node.append("image")
+           .attr("xlink:href", function (d) { return d.image; })
+           .attr("x", -8)
+           .attr("y", -8)
+           .attr("width", 16)
+           .attr("height", 16)
+           .attr("opacity", function(d) { return d.available=="False"?0.8:1; })
+
+       node.append("text")
+           .attr("dx", 12)
+           .attr("dy", ".35em")
+           .text(function(d) { return d.name });
+
+       node.on("mouseover", function (d, i){
+                       //tooltip.show(get_node_info_formated(d));
+                       // Ugly hack to decode HTML
+                       //$('<div/>').html(d.description).text()
+                       tooltip.show(d.description);
+                       $("#selected_node_info").html("Selected " + d.type + ": " + d.nodeName + " at " + d.location);
+                       $("#selected_node_info").css("background-color", d.color );
+                       $("#selected_node_info").css("text-shadow", "-3px 2px 4px #eee");
+                       $("#selected_node_info").show();
+               }
+               )
+               .on("mouseout", function() {
+                               $("#selected_node_info").css("background-color", "#ebf5ff");
+                               //$("#selected_node_info").hide()
+                               tooltip.hide();
+                       })
+               .on("click", function(d) {
+                   /* Only available AMs can be selected */
+                   if (d.available != "False") {
+                       //checkTopologyLoops(d);
+                       d3.select(this).selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "click");});
+                   }
+               })
+
+       //Number of nodes in each Island
+       var qNodes = [];
+       for(i=0; i<nIslands; i++){
+          qNodes[i] = getNodesIsland(i);
+       } 
+       var grav = 0.008 * nx * ny;
+
+       force.on("tick", function(e){
+           var k = grav * e.alpha;
+           var node_groups = {}
+
+           // Adjust K colliding factor
+           $.each(data.nodes, function(i, n){
+               if (node_groups[n.group] == undefined) {
+                   node_groups[n.group] = 1;
+               } else {
+                   node_groups[n.group] += 1;
+               }
+           });
+
+           data.nodes.forEach(function(o, i){
+               var fact = 1;
+               // Dumb hack: limit expansion through #nodes
+               if (node_groups[o.group] >= 10) {
+                   fact = Math.floor(node_groups[o.group]/10);
+               } else {
+                   fact = o.group+1;
+               }
+               // Carolina: when there are few nodes, avoid them to stay too far away from the center
+               // AND when there are so many nodes avoid them to stay too near each others 
+               if(qNodes[o.group] < 5){
+                   fact = fact * 2;
+               } else {
+                   fact = fact/2;
+               }
+               try {
+                   o.y += k * fact * qNodes[o.group] * ((dataislands[o.group].cy) - o.y);
+                   o.x += k * fact * qNodes[o.group] * ((dataislands[o.group].cx) - o.x);
+               } catch (err) {
+               }
+           });
+
+           node.each(collide(.5));
+           node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")";})
+               .attr("cx", function(d) { return d.x; })
+               .attr("cy", function(d) { return d.y; });
+
+           /*link.attr("x1", function(d) { return d.source.x; })
+               .attr("y1", function(d) { return d.source.y; })
+               .attr("x2", function(d) { return d.target.x; })
+               .attr("y2", function(d) { return d.target.y; });
+           */
+           link.attr("d", function(d) {
+               var dx = d.target.x - d.source.x,
+                   dy = d.target.y - d.source.y,
+                   
+                   //dr = 50/d.linknum;  //linknum is defined above
+                   dr = Math.sqrt(dx * dx + dy * dy)/d.linknum;
+                  // console.log("printing d:");
+                  // console.log(d);
+               //return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0,1 " +                        d.target.x + "," + d.target.y;
+                 return "M" + d.source.x + "," + d.source.y + 
+           "A" + dr + "," + dr + " 0 0 1," + d.target.x + "," + d.target.y + 
+           "A" + dr + "," + dr + " 0 0 0," + d.source.x + "," + d.source.y;
+             });
+       });
+
+       function redrawNodes(){
+               node.selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "stroke");});
+               link.style({'fill': 'black','stroke': "#00BFFF", 'stroke-width': "5px" });//"stroke", function(d) {return getLinkStyle(d, "stroke");});
+               //link.style("stroke-width", function(d) {return getLinkStyle(d, "stroke-width");});
+       }
+
+
+
+       function tick() {
+         
+         /*link.attr("x1", function(d) { return d.source.x; })
+             .attr("y1", function(d) { return d.source.y; })
+             .attr("x2", function(d) { return d.target.x; })
+             .attr("y2", function(d) { return d.target.y; });
+         */
+         
+         node.each(collide(.5));
+         node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; })
+             .attr("cx", d.x)
+             .attr("cy", d.y);
+
+         link.attr("d", function(d) {
+               var dx = d.target.x - d.source.x,
+               dy = d.target.y - d.source.y,
+               dr = Math.sqrt(dx * dx + dy * dy)/d.linknum;
+               //dr = 50/d.linknum;  //linknum is defined above
+               //console.log("target:"+d.target.nodeName+" source:" +d.source.nodeName+" link_no:  "+dr);
+               //dr = 75;//Math.sqrt(dx * dx + dy * dy);
+               //return "M" + d.source.x + "," + d.source.y + "A" + dr + "," + dr + " 0 0,1 " +                        d.target.x + "," + d.target.y;
+               return "M" + d.source.x + "," + d.source.y + 
+           "A" + dr + "," + dr + " 0 0 1," + d.target.x + "," + d.target.y + 
+           "A" + dr + "," + dr + " 0 0 0," + d.source.x + "," + d.source.y;
+         });
+
+         
+       };
+
+       
+
+       function animate(){
+
+       iellipses.attr("rx", function(d) { return d.rx; })
+           .style("display","block")
+           .attr("ry", function(d) { return d.ry; })
+           .attr("cx",function(d) { return d.cx; })
+           .attr("cy", function(d) { return d.cy; })
+           .style("fill", function(d) { return color(d.group%nIslands); })
+           .style("stroke", function(d) { return color(d.group%nIslands);}) 
+           .style("opacity", 0.3)
+           .style("stroke-opacity", 0.7)
+
+       ilabels.attr("text-anchor", "middle")
+             .attr("y", function(d){ return d.cy + d.ry*0.9})
+             .attr("x", function(d){ return d.cx})
+             .attr("font-color", function(d) { return d3.rgb(color(d.group%nIslands)).darker(5); })
+             .style("opacity",1)
+             .text(function(d) { return d.location });
+
+       iellipses.transition()
+                       .style("stroke-width",3)
+                       .style("stroke", function(d) { return d3.rgb(color(d.group%nIslands)).brighter(10);})
+                       .duration(1500)
+       iellipses.transition()
+                  .delay(1500)
+                  .style("opacity",0)
+                  .duration(3000)
+       ilabels.transition()
+                  .delay(1500)
+                  .style("opacity",0)
+                  .duration(3000);
+       }
+
+       function regroup(){
+               force.resume();
+               animate();
+       }
+
+       function collide(alpha) {
+         var quadtree = d3.geom.quadtree(nodes);
+         return function(d) {
+           var r = d.radius + radius.domain()[1] + padding,
+               nx1 = d.x - r,
+               nx2 = d.x + r,
+               ny1 = d.y - r,
+               ny2 = d.y + r;
+           quadtree.visit(function(quad, x1, y1, x2, y2) {
+             if (quad.point && (quad.point !== d)) {
+               var x = d.x - quad.point.x,
+                   y = d.y - quad.point.y,
+                   l = Math.sqrt(x * x + y * y),
+                   r = d.radius + quad.point.radius + (d.color !== quad.point.color) * padding;
+               if (l < r) {
+                 l = (l - r) / l * alpha;
+                 d.x -= x *= l;
+                 d.y -= y *= l;
+                 quad.point.x += x;
+                 quad.point.y += y;
+               }
+             }
+             return x1 > nx2
+                 || x2 < nx1
+                 || y1 > ny2
+                 || y2 < ny1;
+           });
+         };
+       };
+
+       //$("#link_zoom_in").onclick(zoomIn(0.25));
+
+       $("#topo_regroup").unbind('click');
+       $("#topo_regroup").click(function(e){
+         e.preventDefault();
+         regroup();
+       });
+
+       $("#link_zoom_reset").unbind('click');
+       $("#link_zoom_reset").click(function(e){
+         e.preventDefault();
+         zoomReset();
+         redraw();
+       });
+
+       $("#link_zoom_in").unbind('click');
+       $("#link_zoom_in").click(function(e){
+         e.preventDefault(); 
+         //console.log("zoom current value:"); 
+         //console.log(cur_zoom);
+         $("#target, svg, g").css("cursor", "url('../../static/img/zoomin.png'),auto");
+         zoomIn(0.25);
+         //console.log(zoom_in_active);
+        // redraw();  
+       });
+
+       $("#link_zoom_out").unbind('click');
+       $("#link_zoom_out").click(function(e){
+         e.preventDefault();
+         $("#target, svg, g").css("cursor", "url('../../static/img/zoomout.png'),auto" );
+         zoomOut(0.25);
+         //redraw();
+       });
+         $("#target, svg, g").css("cursor", "crosshair");
+        //alert("called");
+               //jQuery('#topo_plugin').hide();
+       //};      
+       //} //if query_itr
+       }, //end of function of on all query done
+
+               //jQuery('#complete-univbris_topology').hide();
+
+    });
+
+    $.plugin('UnivbrisTopo', UnivbrisTopo);
+
+    function addNode(node_dpid,location,node_type){
+       var found=false;
+       var i=0;
+       for(i=0;i<d3_nodes.length;i++){
+               //if (i=0){
+               //      console.log("adding node");
+               //      console.log(d3_nodes[i]);
+               //}
+               if(d3_nodes[i].nodeName==node_dpid){
+                       found=true;
+                       break;
+               }
+       }
+
+       if(found==false){
+               var node={};
+               node['nodeValue']=12;
+               node['nodeName']=node_dpid;
+               node['type']=node_type;
+               if (node_type=="compute"){
+                       node['image']='../../static/img/server-tiny.png';
+               }
+               else if (node_type=="optical"){
+                       node['image']='../../static/img/oswitch-tiny.png';
+
+               }else if (node_type=="federation"){
+                       node['image']='../../static/img/switch-tiny2.png';
+
+               }else{
+                       node['image']='../../static/img/switch-tiny.png';
+
+               }
+               node['color']= "";
+               node['group']=0;
+               node['location']=location;
+               node['description']= "";
+               node['fixed']= false;
+               node['radius']= 10;
+               node['available']= true;
+               d3_nodes.push(node);
+               return d3_nodes.length-1;
+       }
+       else{
+               return i;
+       }
+   }; //end of add node function
+
+
+  function addLink(source,target,src_port,dst_port,value){
+
+       var found=false;
+       for(i=0;i<d3_links.length;i++){
+               //if(d3_links[i].source==source && d3_links[i].target==target && d3_links[i].src_port==src_port && d3_links[i].dst_port==dst_port && d3_links[i].value==value){
+               if((d3_links[i].source==source && d3_links[i].target==target && d3_links[i].src_port==src_port && d3_links[i].dst_port==dst_port) || 
+                 (d3_links[i].source==target && d3_links[i].target==source && d3_links[i].src_port==dst_port && d3_links[i].dst_port==src_port)){
+                       found=true;
+                       break;
+               }
+       }
+
+       if (found == false){
+               var tmp_link={};
+               tmp_link['source']=source;
+               tmp_link['target']=target;
+                tmp_link['src_port']=src_port;
+               tmp_link['dst_port']=dst_port;
+               tmp_link['value']=value;
+               tmp_link['linknum']=1;
+               d3_links.push(tmp_link);
+       }
+          
+  };
+
+   function calLinkNum(){
+       /* d3_links.sort(function(a,b) {
+               if (a.source > b.source) {return 1;}
+                       else if (a.source < b.source) {return -1;}
+               else {
+                       if (a.target > b.target) {return 1;}
+                       if (a.target < b.target) {return -1;}
+                       else {return 0;}
+               }
+       });*/
+
+         for (var i=0; i<d3_nodes.length; i++){
+               for (var i1=0; i1<d3_nodes.length; i1++){
+                       if(i!=i1){
+                               var num_link=1;
+                               for (var i2=0; i2<d3_links.length; i2++){
+                                       if ((d3_links[i2].source ==i  &&
+                                               d3_links[i2].target ==i1) || (d3_links[i2].source ==i1  &&
+                                               d3_links[i2].target ==i)){
+                                               d3_links[i2].linknum = num_link;
+                                               num_link++;
+                                       }
+                               }                               
+                       }
+               }       
+        }
+
+       /* for (var i=0; i<d3_links.length; i++) {
+               if (i != 0 &&
+                       d3_links[i].source == d3_links[i-1].source &&
+                       d3_links[i].target == d3_links[i-1].target) {
+                               d3_links[i].linknum = d3_links[i-1].linknum + 1;
+               }
+               else {d3_links[i].linknum = 1;};
+       };*/
+
+   };
+
+  
+
+
+
+   function describeNodes(){
+       for(i=0;i<d3_nodes.length;i++){
+               if(d3_nodes[i].type=="packet" || d3_nodes[i].type=="optical" || d3_nodes[i].type=="federation"){
+                       d3_nodes[i].description="<strong>Switch Datapath ID&#58; <br> "+d3_nodes[i].nodeName+" </strong><br><strong>Connections&#58;</strong><br>"
+                       for(i1=0;i1<d3_links.length;i1++){
+                               if(d3_links[i1].source==i){
+                                       d3_nodes[i].description+="<strong>&#149; Port "+d3_links[i1].src_port+ " </strong>to Switch " + d3_nodes[d3_links[i1].target].nodeName + " at port "+ d3_links[i1].dst_port+"<br>";
+                               }
+                       else if(d3_links[i1].target==i){
+                               d3_nodes[i].description+="<strong>&#149; Port "+ d3_links[i1].dst_port + " </strong>to Switch " + d3_nodes[d3_links[i1].source].nodeName + " at port "+ d3_links[i1].src_port+"<br>";
+                       }
+                       }
+
+
+               }
+               else if (d3_nodes[i].type=="compute"){
+                       d3_nodes[i].description="<strong>Virtualization server name&#58; <br>"+d3_nodes[i].nodeName+"</strong><br><strong>Connections&#58;</strong><br>";
+                       for(i1=0;i1<d3_links.length;i1++){
+                               if(d3_links[i1].source==i){
+                                       d3_nodes[i].description+="<strong>&#149; Port "+d3_links[i1].src_port+ " </strong>to Switch " + d3_nodes[d3_links[i1].target].nodeName + " at port "+ d3_links[i1].dst_port+"<br>";
+                               //console.log(d3_links[i1],d3_nodes[d3_links[i1].target]);
+                               }
+                              if(d3_links[i1].target==i){
+                               d3_nodes[i].description+="<strong>&#149; Port "+ d3_links[i1].dst_port + " </strong>to Switch " + d3_nodes[d3_links[i1].source].nodeName + " at port "+ d3_links[i1].src_port+"<br>";
+                               //console.log(d3_links[i1],d3_nodes[d3_links[i1].source]);
+                       }
+                       }
+               }
+
+               /*try{
+       
+               
+               }
+               catch(err){
+                       console.log(err);
+               }*/
+               
+               //if(d3_nodes[i].nodeName==node_dpid){
+               //      found=true;
+               //      break;
+               //}
+       }
+
+
+   };
+
+       
+
+})(jQuery);
diff --git a/plugins/univbristopo/templates/spillout b/plugins/univbristopo/templates/spillout
new file mode 100644 (file)
index 0000000..8b5e44b
--- /dev/null
@@ -0,0 +1,613 @@
+//$("#univbris_welcome").hide();
+         //jQuery("#univbris_flowspace_selection").show();
+
+         /* d3 data */
+         var nIslands=[], //replace
+             pad = 5,
+              width = parseInt($("#topologyContainer").css("width")), /* Obtain width from container */
+              height = 400;
+
+         //Islands area generation
+         var p = width/height
+              ny = Math.sqrt(nIslands/p),
+              nx = Math.ceil(p*ny),
+              ny = Math.ceil(ny),
+              foci = [];
+
+         if (nx*ny > nIslands){
+               if (nx > ny && (nx-1)*ny >= nIslands)
+               nx--;
+               else if( nx <= ny && nx*(ny-1) >= nIslands)
+               ny--;
+         }
+
+         var aw = Math.floor((width-(nx+1)*pad)/nx),
+              ah = Math.floor((height-(ny+1)*pad)/ny);
+
+         for (i=0; i<nIslands; i++){
+               tx0 = pad + (pad + aw)*(Math.floor(i%nx));
+               ty0 = pad + (pad + ah)*(Math.floor(i/nx));
+               foci[i] = {x0: tx0, x1: tx0 + aw, y0: ty0, y1: ty0 + ah};
+         }
+
+         function randomXToY(minVal,maxVal,floatVal){
+               var randVal = minVal+(Math.random()*(maxVal-minVal));
+               return typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal);
+         };
+
+         
+          function pEllipse(set){
+               function getDistance(p){
+                       return Math.pow((p[0]-cx),2)/Math.pow(rx,2) + Math.pow((p[1]-cy),2)/Math.pow(ry,2);
+               };
+
+               d = 2;
+
+               try {
+                       cx = (set.x1 + set.x0)/2;
+                       rx = ((set.x1 - set.x0)/2 + (set.y1 - set.y0)/2)/2;
+                       cy = (set.y1 + set.y0)/2;
+                       ry = (set.y1 - set.y0)/2;
+       
+                       while (d>1) {
+                               p = [randomXToY(set.x0, set.x1), randomXToY(set.y0, set.y1) ];
+                               d = getDistance(p);     
+                       }
+               } catch(err) {
+                       p = [];
+               }
+
+               return p;
+         };
+
+         var epoints= [];
+         for (i=0;i<d3_nodes.length;i++){
+               epoints.push(d3_nodes[i]['group']);
+
+         };
+          
+          var data = {};
+
+         var nodes=[];
+         
+
+         for (i=0;i<d3_nodes.length;i++){
+               var node={};
+               node['nodeValue']=d3_nodes[i].value;
+               node['nodeName']=d3_nodes[i].name;
+               node['image']=d3_nodes[i].image;
+               node['color']= "";
+               node['group']=d3_nodes[i].group;
+               node['location']=d3_nodes[i].location;
+               node['description']= d3_nodes[i].description;
+               node['fixed']= false;
+               node['radius']= 10;
+               node['available']= d3_nodes[i].available;
+               nodes.push(node);
+         };
+
+         data["nodes"]=nodes;
+
+         var links=[];
+         for (i=0;i<d3_links.length;i++){
+               var link={};
+               link['source']= d3_links[i].source;
+               link['target']= d3_links[i].target;
+               link['value']= d3_links[i].value;
+               links.push(link);
+         }
+
+        data["links"]=links;
+       },
+       
+       function getLinkStyle(d, attr){
+               rsc_ids = d.value.split("-");
+               if(attr=="click"){
+                       id0 = rsc_ids[0];
+                       id1 = rsc_ids[1];
+                       if (id1.indexOf("eth") != -1){
+                            $(":checkbox#"+id0).click();
+                       }
+                       else{           
+                       if((! $(":checkbox#"+id0+":checked").length && ! $(":checkbox#"+id1+":checked").length) || ($(":checkbox#"+id0+":checked").length && $(":checkbox#"+id1+":checked").length)){
+                               $(":checkbox#"+id0).click();
+                               $(":checkbox#"+id1).click();
+                       }
+                       else if ($(":checkbox#"+id0+":checked").length){
+                               $(":checkbox#"+id1).click();
+                       }
+                       else{
+                               $(":checkbox#"+id0).click();    
+                       }
+                       }
+               }else if(attr=="mouseover"){
+                       var values = {stroke: "#00BFFF", strokewidth: "2" };
+                       return values;
+               }else{
+                       if( ($(":checkbox#"+rsc_ids[0]+":checked").length && rsc_ids[1].indexOf("eth") != -1) ||($(":checkbox#"+rsc_ids[0]+":checked").length && $(":checkbox#"+rsc_ids[1]+":checked").length)){
+                               if (attr == "stroke")
+                                       return "#666";
+                               else
+                                       return 2;
+                       }else{
+                               if (attr == "stroke")
+                                       return "#ccc";
+                               else
+                                       return 2;
+                       }
+               }
+       };
+
+       function getBaseNodeColor(d){
+               var group = 0;
+               group = d.group;
+               return d3.rgb(d.color.toString().toString()).darker(.15*group);
+       };
+
+       function getNodeCircleStyle(d, attr){
+               selected_len = $(":checkbox:checked.node_id_"+d.nodeValue).length;
+               all_len = $(":checkbox:.node_id_"+d.nodeValue).length;
+               selected_server = $(".server_node_"+d.nodeValue+".connected").length;
+               if(attr == "drag"){
+                       return d3.rgb(d.color.toString()).brighter(5);
+               }else if(attr=="click"){
+                        if(selected_len == all_len) {
+                               $(":checkbox:checked.node_id_"+d.nodeValue).click();
+                               return getBaseNodeColor(d);
+                        }else{
+                               $(":checkbox:not(:checked).node_id_"+d.nodeValue).click();
+                               return d3.rgb(d.color.toString()).darker(5);
+                       }
+               }else if (attr == "dragstop" && selected_len == 0){
+                       return getBaseNodeColor(d);
+               }else{
+                               if (attr == "fill"){
+                                       return getBaseNodeColor(d);
+                               } else{
+                                       if (selected_len != 0){
+                                               return d3.rgb(d.color.toString()).darker(5);
+                                       }else{
+                                               return getBaseNodeColor(d);
+                                       }
+                               }
+               }
+       };
+
+       function getNodesIsland(d){
+               var nNodes = 0;
+               data.nodes.forEach(function(o, i){
+                  if(o.group == d){
+                       nNodes++;
+                  }
+               });
+           return nNodes;
+       }
+
+       cur_zoom = 1;
+       zoom_in_active = false;
+       zoom_out_active = false;
+
+       
+       function zoomIn(zoom){
+           if(zoom_in_active == false && zoom_out_active == false){
+               $("#link_zoom_in img").css("background-color", "#666");
+               cur_zoom = cur_zoom + zoom;
+               zoom_in_active = true;
+           }
+
+           else if(zoom_in_active == true){
+               cur_zoom = cur_zoom - zoom;
+               $("#link_zoom_in img").css("background-color", "");
+               $("#target, svg, g").css("cursor", "move");
+               zoom_in_active = false;
+           }
+
+           else{
+               cur_zoom = cur_zoom + zoom + zoom;
+               $("#link_zoom_out img").css("background-color", "");
+               $("#link_zoom_in img").css("background-color", "#666");
+               zoom_out_active = false;
+               zoom_in_active = true;
+           }
+       };
+
+       
+       function zoomOut(zoom){
+           if(zoom_out_active == false && zoom_in_active == false){
+               if((cur_zoom - zoom) >0){
+                   $("#link_zoom_out img").css("background-color", "#666");
+                   cur_zoom = cur_zoom - zoom;
+                   zoom_out_active = true;
+               }
+               else{
+                   $("#target, svg, g").css("cursor", "move");
+               }
+           }   
+           else if(zoom_out_active == true){
+               cur_zoom = cur_zoom + zoom;
+               $("#link_zoom_out img").css("background-color", "");
+               $("#target, svg, g").css("cursor", "move");
+               zoom_out_active = false;
+           }
+
+           else{
+               cur_zoom = cur_zoom - zoom;
+               zoom_out_active = false;
+               $("#link_zoom_in img").css("background-color", "");
+               if((cur_zoom - zoom) > 0){
+                   $("#link_zoom_out img").css("background-color", "#666");
+                   zoom_out_active = true;
+               }
+               else{
+                   $("#target, svg, g").css("cursor", "move");
+               }
+           }
+       };
+
+       function zoomReset(){
+           cur_zoom = 0.99;
+           posx = 0;
+           posy = 0;
+           return redraw();
+       };
+
+       function click(){
+           if (zoom_in_active == true || zoom_out_active == true){
+               var mouseClick = d3.mouse(this);
+               _x = -mouseClick[0]/2;
+               _y = -mouseClick[1]/2;
+               if(zoom_out_active == true){
+                   _x = -_x/2;
+                   _y = -_y/2;
+               }
+               posx += _x;
+               posy += _y;
+               zoom_in_active = false;
+               zoom_out_active = false;
+               return redraw();
+           }
+       };
+
+       function redraw() {
+               //  trans=[(Math.round(width/cur_zoom) - width)/2, (Math.round(height/cur_zoom) - height)/2];
+                   trans = [posx, posy];
+                   svg.transition()
+                      .duration(500)
+                      .attr('x', function(d){ return d.x; })
+                      .attr('y', function(d){ return d.y; })
+                      .attr("transform", 
+                           "translate(" + trans +")"
+                           + "scale(" + cur_zoom + ")");
+                  $("#link_zoom_in img").css("background-color","");
+                  $("#link_zoom_out img").css("background-color","");
+                  $("#target, svg, g").css("cursor", "move"); 
+       };
+
+       //Global position of the canvas
+       var posx = 0;
+       var posy = 0;
+
+       /* Translation - bound to drag behavior */
+       dragMap = function(d) {
+       //No drag while zoom option active
+          if(zoom_in_active == false && zoom_out_active == false){
+             posx += d3.event.dx;
+             posy += d3.event.dy;
+             svg.attr('x', function(d) { return d.x; })
+                .attr('y', function(d) { return d.y; })
+                .attr("transform", "translate(" + posx + "," + posy + ") scale (" + cur_zoom + ")");
+          }
+       };
+
+       
+       /* Instantiation General parameters*/
+       var  padding = 6,
+            color = d3.scale.category10().domain(d3.range(nIslands)),
+            radius = d3.scale.sqrt().range([0, 12]);
+
+       var svg = d3.select("#target")
+           .on("click", click)
+           .append("svg")
+               .attr("pointer-events", "all")
+               .attr("width", width)
+               .attr("height", height)
+               .datum({x: 0, y: 0})
+               .call(d3.behavior.drag().on("drag", dragMap))
+           .append("svg:g").on("zoom", redraw)
+               .attr("cursor", "move")       
+       
+       // DATA VARIABLES
+       var nodes = data.nodes;
+       // Set color for each node
+       nodes.forEach(function(d) {
+           if (d.available != "False") {
+               d.color = color(d.group%nIslands);
+           } else {
+               d.color = "#CCC";
+           }
+       });
+
+       var links = data.links;
+
+       // Modified version (Carolina)
+       var force = d3.layout.force()
+           .gravity(1/(2*nIslands))
+           .distance(200/nIslands)
+           .friction(0.6)
+           .size([width, height])
+           .nodes(nodes)
+           .links(links)
+           .start();
+
+       var EMPTY_ISLAND = "Island with no resources";
+
+       //XXX:Very ugly, needs improvement
+       var islandsLocs = []
+       for (i = 0; i< nIslands; i++){
+               islandsLocs[i] = EMPTY_ISLAND;
+       }
+
+       nodeInitialPos = []
+       for (i = 0; i< nodes.length; i++){
+               nodeInitialPos[i] = [nodes[i].x, nodes[i].y];
+               if (islandsLocs[nodes[i].group] == EMPTY_ISLAND){
+                       islandsLocs[nodes[i].group] = nodes[i].location;
+               }
+       }
+
+       var dataislands = []
+       for (i = 0; i< nIslands; i++){
+               dataislands[i] = {rx: (aw/2 + ah/2)/2, ry: ah/2, cx:(foci[i].x0+foci[i].x1)/2, cy:(foci[i].y0+foci[i].y1)/2, group: i, location: islandsLocs[i]};
+       }
+
+       var islands = svg.selectAll(".island")
+           .data(dataislands)
+         .enter().append("g")
+               .attr("class", "island")
+
+       var iellipses = islands.append("ellipse")
+           .attr("rx", function(d) { return d.rx; })
+           .attr("ry", function(d) { return d.ry; })
+           .attr("cx",function(d) { return d.cx; })
+           .attr("cy", function(d) { return d.cy; })
+           .style("fill", function(d) { return color(d.group%nIslands); })
+           .style("stroke", function(d) { return color(d.group%nIslands);}) 
+           .style("opacity", 0.3)
+           .style("stroke-opacity", 0.7)
+
+       var ilabels = islands.append("text")
+             .attr("text-anchor", "middle")
+             .attr("y", function(d){ return d.cy + d.ry*0.9})
+             .attr("x", function(d){ return d.cx})
+             .attr("font-color", function(d) { return d3.rgb(color(d.group%nIslands)).darker(5); })
+             .style("opacity",1)
+             .style("cursor", "default")
+             .text(function(d) { return d.location });
+
+       //First ellipse animation on startup
+       animate();
+
+       var link = svg.selectAll(".link")
+           .data(links)
+         .enter().append("line")
+           .attr("class", "link");
+
+       link.on("click", function(d) {
+                       d3.select(this).style("stroke", function(d){return getLinkStyle(d, "click");})});
+
+       var node = svg.selectAll(".node")
+           .data(nodes)
+         .enter().append("g")
+           .attr("class", "node")
+           .call(force.drag)
+           .call(d3.behavior.drag()
+           .on("dragstart", function(d, i, e) {
+                   d.fixed = false;
+                   force.stop();
+           })
+           .on("drag", function(d, i) {
+                   d.px += d3.event.dx;
+                   d.py += d3.event.dy;
+                   d.x += d3.event.dx;
+                   d.y += d3.event.dy;
+                   d3.select(this).selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "drag");}) 
+                   tick();
+           })
+           .on("dragend", function(d, i) {
+                 //  d.fixed = true; // of course set the node to fixed so the force does not include the node in its auto positioning stuff //with the force.stop() it won't autopositioning, allowing to regroup the nodes
+                   d3.select(this).selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "dragstop");})
+                   tick();
+                   force.stop();
+           })
+           );
+
+       
+       node.append("circle")
+           .attr("r", function(d) { return d.radius; })
+           .style("stroke", function(d){return getNodeCircleStyle(d, "stroke");})
+           .style("fill", function(d){return getNodeCircleStyle(d, "fill");});
+
+       node.append("image")
+           .attr("xlink:href", function (d) { return d.image; })
+           .attr("x", -8)
+           .attr("y", -8)
+           .attr("width", 16)
+           .attr("height", 16)
+           .attr("opacity", function(d) { return d.available=="False"?0.8:1; })
+
+       node.append("text")
+           .attr("dx", 12)
+           .attr("dy", ".35em")
+           .text(function(d) { return d.name });
+
+       node.on("mouseover", function (d, i){
+                       //tooltip.show(get_node_info_formated(d));
+                       // Ugly hack to decode HTML
+                       tooltip.show($('<div/>').html(d.description).text());
+                       $("#selected_node_info").html("Selected " + d.type + ": " + d.nodeName + " at " + d.location);
+                       $("#selected_node_info").css("background-color", d.color );
+                       $("#selected_node_info").css("text-shadow", "-3px 2px 4px #eee");
+                       $("#selected_node_info").show();
+               }
+               )
+               .on("mouseout", function() {
+                               $("#selected_node_info").css("background-color", "#ebf5ff");
+                               //$("#selected_node_info").hide()
+                               tooltip.hide();
+                       })
+               .on("click", function(d) {
+                   /* Only available AMs can be selected */
+                   if (d.available != "False") {
+                       //checkTopologyLoops(d);
+                       d3.select(this).selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "click");});
+                   }
+               })
+
+       //Number of nodes in each Island
+       var qNodes = [];
+       for(i=0; i<nIslands; i++){
+          qNodes[i] = getNodesIsland(i);
+       } 
+       var grav = 0.008 * nx * ny;
+
+       force.on("tick", function(e){
+           var k = grav * e.alpha;
+           var node_groups = {}
+
+           // Adjust K colliding factor
+           $.each(data.nodes, function(i, n){
+               if (node_groups[n.group] == undefined) {
+                   node_groups[n.group] = 1;
+               } else {
+                   node_groups[n.group] += 1;
+               }
+           });
+
+           data.nodes.forEach(function(o, i){
+               var fact = 1;
+               // Dumb hack: limit expansion through #nodes
+               if (node_groups[o.group] >= 10) {
+                   fact = Math.floor(node_groups[o.group]/10);
+               } else {
+                   fact = o.group+1;
+               }
+               // Carolina: when there are few nodes, avoid them to stay too far away from the center
+               // AND when there are so many nodes avoid them to stay too near each others 
+               if(qNodes[o.group] < 5){
+                   fact = fact * 2;
+               } else {
+                   fact = fact/2;
+               }
+               try {
+                   o.y += k * fact * qNodes[o.group] * ((dataislands[o.group].cy) - o.y);
+                   o.x += k * fact * qNodes[o.group] * ((dataislands[o.group].cx) - o.x);
+               } catch (err) {
+               }
+           });
+
+           node.each(collide(.5));
+           node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")";})
+               .attr("cx", function(d) { return d.x; })
+               .attr("cy", function(d) { return d.y; });
+
+           link.attr("x1", function(d) { return d.source.x; })
+               .attr("y1", function(d) { return d.source.y; })
+               .attr("x2", function(d) { return d.target.x; })
+               .attr("y2", function(d) { return d.target.y; });
+       });
+
+       function redrawNodes(){
+               node.selectAll("circle").style("stroke", function(d){return getNodeCircleStyle(d, "stroke");});
+               link.style("stroke", function(d) {return getLinkStyle(d, "stroke");});
+               link.style("stroke-width", function(d) {return getLinkStyle(d, "stroke-width");});
+       }
+
+       function tick() {
+         
+         link.attr("x1", function(d) { return d.source.x; })
+             .attr("y1", function(d) { return d.source.y; })
+             .attr("x2", function(d) { return d.target.x; })
+             .attr("y2", function(d) { return d.target.y; });
+         
+         node.each(collide(.5));
+         node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; })
+             .attr("cx", d.x)
+             .attr("cy", d.y);
+       };
+
+       function animate(){
+
+       iellipses.attr("rx", function(d) { return d.rx; })
+           .style("display","block")
+           .attr("ry", function(d) { return d.ry; })
+           .attr("cx",function(d) { return d.cx; })
+           .attr("cy", function(d) { return d.cy; })
+           .style("fill", function(d) { return color(d.group%nIslands); })
+           .style("stroke", function(d) { return color(d.group%nIslands);}) 
+           .style("opacity", 0.3)
+           .style("stroke-opacity", 0.7)
+
+       ilabels.attr("text-anchor", "middle")
+             .attr("y", function(d){ return d.cy + d.ry*0.9})
+             .attr("x", function(d){ return d.cx})
+             .attr("font-color", function(d) { return d3.rgb(color(d.group%nIslands)).darker(5); })
+             .style("opacity",1)
+             .text(function(d) { return d.location });
+
+       iellipses.transition()
+                       .style("stroke-width",3)
+                       .style("stroke", function(d) { return d3.rgb(color(d.group%nIslands)).brighter(10);})
+                       .duration(1500)
+       iellipses.transition()
+                  .delay(1500)
+                  .style("opacity",0)
+                  .duration(3000)
+       ilabels.transition()
+                  .delay(1500)
+                  .style("opacity",0)
+                  .duration(3000);
+       }
+
+       function regroup(){
+               force.resume();
+               animate();
+       }
+
+       function collide(alpha) {
+         var quadtree = d3.geom.quadtree(nodes);
+         return function(d) {
+           var r = d.radius + radius.domain()[1] + padding,
+               nx1 = d.x - r,
+               nx2 = d.x + r,
+               ny1 = d.y - r,
+               ny2 = d.y + r;
+           quadtree.visit(function(quad, x1, y1, x2, y2) {
+             if (quad.point && (quad.point !== d)) {
+               var x = d.x - quad.point.x,
+                   y = d.y - quad.point.y,
+                   l = Math.sqrt(x * x + y * y),
+                   r = d.radius + quad.point.radius + (d.color !== quad.point.color) * padding;
+               if (l < r) {
+                 l = (l - r) / l * alpha;
+                 d.x -= x *= l;
+                 d.y -= y *= l;
+                 quad.point.x += x;
+                 quad.point.y += y;
+               }
+             }
+             return x1 > nx2
+                 || x2 < nx1
+                 || y1 > ny2
+                 || y2 < ny1;
+           });
+         };
+       };
+
+       $("#link_zoom_in").click(function(){
+         $("#target, svg, g").css("cursor", "url({%url img_media 'zoomin.png' %}),auto");
+       });
+
+       $("#link_zoom_out").click(function(){
+         $("#target, svg, g").css("cursor", "url({%url img_media 'zoomout.png' %}),auto" );
+       });
+
diff --git a/plugins/univbristopo/templates/univbris_topology.html b/plugins/univbristopo/templates/univbris_topology.html
new file mode 100644 (file)
index 0000000..6dc6310
--- /dev/null
@@ -0,0 +1,66 @@
+<div id="topo_plugin_width" class="expandable">
+
+</div>
+
+
+<div id="topo_plugin">
+
+<h2>Topology</h2>
+<!--
+<link rel="stylesheet" href="tooltip.topology.css" />
+<link rel="stylesheet" href="tooltip.css" />
+-->
+<style>
+  .link {
+    stroke: #ccc;
+    stroke-width:1px;
+  }
+  .node {
+    stroke-width:2px;
+  }
+  .node text {
+    pointer-events: none;
+    font: 10px sans-serif;
+  }
+</style>
+<!--
+<script src="tooltip.topology.js"></script>
+<script src="d3.v2.min.js"></script>
+-->
+
+<div id="topologyContainer" class="expandable">
+  <div id="selected_node_info">
+    Tip: Move cursor over the icons to get extra information...
+  </div>
+  
+  <div id="target" style="background:white;">>
+
+  
+  </div>
+
+
+
+
+<div id="topology_options_menu">
+    
+  <a id="topo_regroup" href="">
+    <img alt="Group" title="Group" src="../../static/img/groupin.png" style="height:16px;text-align:middle" />
+  </a>
+  &nbsp;
+  <a id="link_zoom_in">
+    <img alt="Zoom in" title="Zoom in" src="../../static/img/zoomin.png" style="height:16px;text-align:middle" />
+  </a>
+  &nbsp;
+  <a id="link_zoom_out" href="">
+    <img alt="Zoom out" title="Zoom out" src="../../static/img/zoomout.png" style="height:16px;" />
+  </a>
+  &nbsp;
+  <a id="link_zoom_reset" href="">
+    <img alt="Zoom reset" title="Zoom reset" src="../../static/img/zoom.png" style="height:16px;" />
+  </a>
+  &nbsp;
+</div>
+</div>
+</div>
+
+
diff --git a/plugins/univbrisvtam/__init__.py b/plugins/univbrisvtam/__init__.py
new file mode 100644 (file)
index 0000000..bc2bf9e
--- /dev/null
@@ -0,0 +1,80 @@
+from unfold.plugin import Plugin
+
+class UnivbrisVtam (Plugin):
+    def __init__ (self, query=None, query_all=None, sync_query=None,
+                  checkboxes=False, columns=None, 
+                  init_key=None,
+                  datatables_options={}, **settings):
+        Plugin.__init__ (self, **settings)
+        self.query          = query
+       self.query_uuid     = query.query_uuid if query else None
+        # Until we have a proper way to access queries in Python
+        self.query_all      = query_all
+        self.query_all_uuid = query_all.query_uuid if query_all else None
+       self.sync_query_uuid = sync_query.query_uuid if sync_query else None
+        self.checkboxes     = checkboxes
+        # XXX We need to have some hidden columns until we properly handle dynamic queries
+        if columns is not None:
+            self.columns=columns
+            self.hidden_columns = []
+        elif self.query:
+           self.columns = list (['Testbed', 'Virtualization Server', 'VM name', 'Delete'])
+           #replace production
+            #self.columns = self.query.fields
+            if query_all:
+                #replace production
+               self.hidden_columns = []
+               # We need a list because sets are not JSON-serializable
+                #self.hidden_columns = #list(self.query_all.fields - self.query.fields)
+            else:
+                self.hidden_columns = []
+        else:
+            self.columns = []
+            self.hidden_columns = []
+
+       self.columns = list (['Testbed', 'Virtualization Server', 'VM name', 'Delete'])
+        self.init_key=init_key
+        self.datatables_options=datatables_options
+        # if checkboxes were required, we tell datatables about this column's type
+        # so that sorting can take place on a selected-first basis (or -last of course)
+        # this relies on the template exposing the checkboxes 'th' with class 'checkbox'
+        if self.checkboxes:
+            # we use aoColumnDefs rather than aoColumns -- ignore user-provided aoColumns
+            if 'aoColumns' in self.datatables_options:
+                print 'WARNING: querytable uses aoColumnDefs, your aoColumns spec. is discarded'
+                del self.datatables_options['aoColumns']
+            # set aoColumnDefs in datatables_options - might already have stuff in there
+            aoColumnDefs = self.datatables_options.setdefault ('aoColumnDefs',[])
+            # here 'checkbox' is the class that we give to the <th> dom elem
+            # dom-checkbox is a sorting type that we define in querytable.js
+            aoColumnDefs.append ( {'aTargets': ['checkbox'], 'sSortDataType': 'dom-checkbox' } )
+
+    def template_file (self):
+        return "univbrisvtamplugin.html"
+
+    def template_env (self, request):
+        env={}
+        env.update(self.__dict__)
+        env['columns']=self.columns
+        return env
+
+    def requirements (self):
+        reqs = {
+            'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js",
+ "js/dataTables.js",  "js/dataTables.bootstrap.js", "js/with-datatables.js", "js/jquery.jeditable.js", 
+                           "js/manifold.js", "js/manifold-query.js", 
+                           "js/unfold-helper.js",
+                           "js/univbrisvtam.js",
+                           ] ,
+            'css_files': [ "css/dataTables.bootstrap.css",
+                           "css/dataTables.full_numbers.css",
+                           "css/univbrisvtam.css", 
+                           ],
+            }
+        return reqs
+
+    def json_settings_list (self):
+        return ['plugin_uuid', 'domid', 
+                'query_uuid', 'query_all_uuid', 'sync_query_uuid',
+                'checkboxes', 'datatables_options', 
+                'hidden_columns', 'init_key',]
diff --git a/plugins/univbrisvtam/static/css/univbrisvtam.css b/plugins/univbrisvtam/static/css/univbrisvtam.css
new file mode 100644 (file)
index 0000000..04424af
--- /dev/null
@@ -0,0 +1,84 @@
+
+/* the bottom of the datatable needs more space */
+div.UnivbrisVtam-spacer { padding: 8px 4px 15px 4px; }
+
+div.UnivbrisVtam table.dataTable th {
+    font: bold 12px/22px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+    color: #4f6b72;
+    border-right: 1px solid #C1DAD7;
+    border-bottom: 1px solid #C1DAD7;
+    border-top: 1px solid #C1DAD7;
+    letter-spacing: 1px;
+    text-transform: uppercase;
+    text-align: left;
+    padding: 8px 12px 4px 20px;
+    vertical-align:middle;
+/*    background: #CAE8EA url(../img/tablesort-header.jpg) no-repeat; */
+}
+
+div.UnivbrisVtam table.dataTable th.checkbox {
+    padding-left: 14px;
+}
+
+div.UnivbrisVtam table.dataTable td, div.UnivbrisVtam table.dataTable textarea, div.UnivbrisVtam table.dataTable input [type="text"] {
+    font: bold 12px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+    color: #660099;
+    border-right: 1px solid #C1DAD7;
+    border-bottom: 1px solid #C1DAD7;
+}
+div.UnivbrisVtam table.dataTable td {
+    padding: 4px 8px 4px 8px;
+    /* this applies on even rows only, odd ones have a setting in bootstrap of rbg 249.249.249 */
+    background-color: #f4f4f4;
+    color: #660099;
+}
+div.UnivbrisVtam table.dataTable td a {
+    font-weight:normal;
+}
+/* these come from bootstrap */
+div.UnivbrisVtam div.dataTables_info {
+    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+/* one could think or using repeat-x here but that's not working because of the arrows
+ * we might need to make these wider some day 
+ * and/or to add background-color: #caebea
+ * which would look less conspicuous in case of overflow
+*/
+
+div.UnivbrisVtam table.dataTable thead .sorting { background: url('../img/tablesort-header-sortable.png') no-repeat; }
+div.UnivbrisVtam table.dataTable thead .sorting_asc { background: url('../img/tablesort-header-up.png') no-repeat; }
+div.UnivbrisVtam table.dataTable thead .sorting_desc { background: url('../img/tablesort-header-down.png') no-repeat; }
+/* this icons set does not have that exact equivalent - using an approximation for now */
+div.UnivbrisVtam table.dataTable thead .sorting_asc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+div.UnivbrisVtam table.dataTable thead .sorting_desc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+
+/* the footers are not active */
+div.UnivbrisVtam table.dataTable tfoot { 
+    background: url('../img/tablesort-header.png') repeat-x;
+    background-color: #caebea;
+}
+/* and when sorting is turned off it's useful to set this on header too */
+div.UnivbrisVtam table.dataTable thead { 
+    background: url('../img/tablesort-header.png') repeat-x;
+    background-color: #caebea;
+}
+
+div.UnivbrisVtam table.tbbuttons{
+    background-color:#A9E2F3;
+}
+
+
+div.UnivbrisVtam table.tbbuttons td{
+  padding-top: 7px;
+  /*padding-left: 7px*/
+  /*padding-left: 7px*/
+  padding-bottom: 7px;
+  background-color:#A9E2F3;
+}
+
+div.UnivbrisVtam table.tbbuttons tr{
+  background-color:#A9E2F3;
+}
+
+
diff --git a/plugins/univbrisvtam/static/img/README b/plugins/univbrisvtam/static/img/README
new file mode 100644 (file)
index 0000000..5df2d69
--- /dev/null
@@ -0,0 +1,2 @@
+these styling elements come from plekit with a simple transition to png
+they're currently not all used in myslice
diff --git a/plugins/univbrisvtam/static/img/tablesort-bullet1.png b/plugins/univbrisvtam/static/img/tablesort-bullet1.png
new file mode 100644 (file)
index 0000000..4304f36
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-bullet1.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-bullet2.png b/plugins/univbrisvtam/static/img/tablesort-bullet2.png
new file mode 100644 (file)
index 0000000..4f181e1
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-bullet2.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-col-alt.png b/plugins/univbrisvtam/static/img/tablesort-col-alt.png
new file mode 100644 (file)
index 0000000..8179f83
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-col-alt.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-gradient.png b/plugins/univbrisvtam/static/img/tablesort-gradient.png
new file mode 100644 (file)
index 0000000..26558a4
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-gradient.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-header-down.png b/plugins/univbrisvtam/static/img/tablesort-header-down.png
new file mode 100644 (file)
index 0000000..c8ed657
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header-down.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-header-sortable.png b/plugins/univbrisvtam/static/img/tablesort-header-sortable.png
new file mode 100644 (file)
index 0000000..0c16904
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header-sortable.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-header-up.png b/plugins/univbrisvtam/static/img/tablesort-header-up.png
new file mode 100644 (file)
index 0000000..d12fe2a
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header-up.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-header.png b/plugins/univbrisvtam/static/img/tablesort-header.png
new file mode 100644 (file)
index 0000000..cff526f
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-header.png differ
diff --git a/plugins/univbrisvtam/static/img/tablesort-td-alt.png b/plugins/univbrisvtam/static/img/tablesort-td-alt.png
new file mode 100644 (file)
index 0000000..ef5ab35
Binary files /dev/null and b/plugins/univbrisvtam/static/img/tablesort-td-alt.png differ
diff --git a/plugins/univbrisvtam/static/img/toggle-hidden.png b/plugins/univbrisvtam/static/img/toggle-hidden.png
new file mode 100755 (executable)
index 0000000..023f22a
Binary files /dev/null and b/plugins/univbrisvtam/static/img/toggle-hidden.png differ
diff --git a/plugins/univbrisvtam/static/img/toggle-visible.png b/plugins/univbrisvtam/static/img/toggle-visible.png
new file mode 100755 (executable)
index 0000000..baf6c28
Binary files /dev/null and b/plugins/univbrisvtam/static/img/toggle-visible.png differ
similarity index 65%
rename from plugins/univbrisfv/static/js/univbrisfv2.js
rename to plugins/univbrisvtam/static/js/univbrisvtam.js
index 3048b1e..86341ff 100644 (file)
@@ -2,28 +2,30 @@
  * Description: display a query result in a datatables-powered <table>
  * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA
  * License: GPLv3
- */
+ */ 
 
 (function($){
 
     var debug=false;
     debug=true
 
-    var UnivbrisFv = Plugin.extend({
+    pk_flowspace_index=0;
+    opt_flowspace_index=0;
+    pk_mode=0;
+    fvf_add=1;
+    fvf_nrow=0;
+    
+
+    var UnivbrisVtam = Plugin.extend({
 
+       
         init: function(options, element) {
-           //alert("foam init called");
-           this.classname="univbrisfv";
+           this.classname="univbrisvtam";
             this._super(options, element);
                
-           //alert(this.options.hidden_columns);
-            /* Member variables */
-           // in general we expect 2 queries here
-           // query_uuid refers to a single object (typically a slice)
-           // query_all_uuid refers to a list (typically resources or users)
-           // these can return in any order so we keep track of which has been received yet
-            //this.received_all_query = false;
-            //this.received_query = false;
+               this.elmt().on('show', this, this.on_show);
+            this.elmt().on('shown.bs.tab', this, this.on_show);
+            this.elmt().on('resize', this, this.on_resize);
 
             // We need to remember the active filter for datatables filtering
             this.filters = Array(); 
            // an internal buffer for keeping lines and display them in one call to fnAddData
            this.buffered_lines = [];
 
-            /* Events */
-           // xx somehow non of these triggers at all for now
-            //this.elmt().on('show', this, this.on_show);
-            //this.elmt().on('shown.bs.tab', this, this.on_show);
-            //this.elmt().on('resize', this, this.on_resize);
-
-            //var query = manifold.query_store.find_analyzed_query(this.options.query_uuid);
-            //this.object = query.object;
-
-           //// we need 2 different keys
-           // * canonical_key is the primary key as derived from metadata (typically: urn)
-           //   and is used to communicate about a given record with the other plugins
-           // * init_key is a key that both kinds of records 
-           //   (i.e. records returned by both queries) must have (typically: hrn or hostname)
-           //   in general query_all will return well populated records, but query
-           //   returns records with only the fields displayed on startup
            var keys = manifold.metadata.get_key(this.object);
            this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
-           // 
            this.init_key = this.options.init_key;
            // have init_key default to canonical_key
            this.init_key = this.init_key || this.canonical_key;
            // sanity check
-           if ( ! this.init_key ) messages.warning ("UnivbrisFv : cannot find init_key");
-           if ( ! this.canonical_key ) messages.warning ("UnivbrisFv : cannot find canonical_key");
-           if (debug) messages.debug("UnivbrisFv: canonical_key="+this.canonical_key+" init_key="+this.init_key);
-
-            /* Setup query and record handlers */
-            //this.listen_query(options.query_uuid);
-            //this.listen_query(options.query_all_uuid, 'all');
+           if ( ! this.init_key ) messages.warning ("UnivbrisVtam : cannot find init_key");
+           if ( ! this.canonical_key ) messages.warning ("UnivbrisVtam : cannot find canonical_key");
+           if (debug) messages.debug("UnivbrisVtam: canonical_key="+this.canonical_key+" init_key="+this.init_key);
 
             /* GUI setup and event binding */
             this.initialize_table();
         /* PLUGIN EVENTS */
 
         on_show: function(e) {
-           if (debug) messages.debug("univbrisfv.on_show");
+           if (debug) messages.debug("UnivbrisVtam.on_show");
             var self = e.data;
             self.table.fnAdjustColumnSizing();
        },        
 
         on_resize: function(e) {
-           if (debug) messages.debug("univbrisfv.on_resize");
+           if (debug) messages.debug("UnivbrisVtam.on_resize");
             var self = e.data;
             self.table.fnAdjustColumnSizing();
        },        
 
         initialize_table: function() 
         {
+
+           
             /* Transforms the table into DataTable, and keep a pointer to it */
             var self = this;
+           //alert(self.options);
             var actual_options = {
                 // Customize the position of Datatables elements (length,filter,button,...)
                 // we use a fluid row on top and another on the bottom, making sure we take 12 grid elt's each time
                 //sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>>",
-               sDom: "<'row'<'col-xs-5'l><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>><'buttons'>",
+               sDom: "<'row'<'col-xs-5'l><'col-xs-5'r><'col-xs-1'r><'col-xs-6'f>>t<'row'<'col-xs-5'i><'col-xs-7'p>><'buttons'>",
                //sDom: "<'row'<'col-xs-9'r>t<'buttons'>",
                // XXX as of sept. 2013, I cannot locate a bootstrap3-friendly mode for now
                // hopefully this would come with dataTables v1.10 ?
                 // sScrollX: '100%',       /* Horizontal scrolling */
                 bProcessing: true,      /* Loading */
                 fnDrawCallback: function() { self._querytable_draw_callback.call(self);}
-               //fnFooterCallback: function() {self._univbrisfv_footer_callback.call(self,nFoot, aData, iStart, iEnd, aiDisplay)};}
+               //fnFooterCallback: function() {self._UnivbrisVtam_footer_callback.call(self,nFoot, aData, iStart, iEnd, aiDisplay)};}
                 // XXX use $.proxy here !
             };
             // the intention here is that options.datatables_options as coming from the python object take precedence
                delete this.options.datatables_options['aoColumnDefs'];
            }
            $.extend(actual_options, this.options.datatables_options );
-            this.table = $("#univbris_flowspace_selection__table").dataTable(actual_options);
-           
 
+           
+            this.table = $("#univbris_vtam__table").dataTable(actual_options); 
+           
+           
+           
            //alert(this.table.$("name"));
 
             /* Setup the SelectAll button in the dataTable header */
                 return self._querytable_filter.call(self, oSettings, aData, iDataIndex);
             });
 
-          //alert(this.options.hidden_columns);
-
             /* Processing hidden_columns */
             $.each(this.options.hidden_columns, function(i, field) {
                 //manifold.raise_event(self.options.query_all_uuid, FIELD_REMOVED, field);
                //self.hide_column(field);
             });
 
-           //document.getElementById('buttons').text-align='center';
 
-           /**$('<table><tr><td><button id="add_flowspace" type="button" style="height: 25px; width: 400px; text-align: center" onclick="fnAddflowspace()">Define another packet  flowspace</button></td>').appendTo('div.buttons');
+           this._querytable_draw_callback();   
+
+        }, // initialize_table
 
-           $('<table><tr><td><button id="add_flowspace" type="button" style="height: 25px; width: 400px" onclick="fnAddflowspace()">Define another optical  flowspace</button></td>').appendTo('div.buttons');
 
-           $('<td><button id="submit_flowspace" type="button" style="height: 25px; width: 400px" onclick="fnButsubmit()">Submit flowspaces</button></td></tr></table>').appendTo('div.buttons');
+       fnCreateVms:function(e){
+               console.log("building json to send to backend");
+
+               var vms=[];
+
+               try{
+                        var rows = $("#univbris_vtam__table").dataTable().fnGetNodes();
+                        if (rows.length<=0){
+                               throw("no vm specified");
+                        }
+                        else{
+                               for(var i=0;i<rows.length;i++){
+                    // get the id of the html element in the table
+                    var cell=rows[i].cells[2];
+                    element = cell.getElementsByTagName('p');
+                    server_vm = element.item(0).id;
+                    t_server_vm = JSON.parse(server_vm);
+                    current_server = Object.keys(t_server_vm);
+                    current_vm = t_server_vm[current_server[0]];
+                    if(vms.length>0){
+                        // add the current vm to vms
+                        $.each( vms, function( i, s_vm ) {
+                            // if the server is already listed in vms, add a new vm to the server
+                            s = Object.keys(s_vm);
+                            vm = s_vm[s[0]];
+                           
+                            if(s[0] == current_server[0]){
+                                vm_exists = false;
+                                // XXX We should also loop on the vm names
+                                $.each( vm, function( i, vm_name ) {
+                                    if(vm_name == current_vm[0]){
+                                        vm_exists = true;
+                                        return;
+                                    }
+                                });
+                                if (vm_exists == false){
+                                    vm.push(current_vm[0]);
+                                }
+                            // else add the server with the current vm
+                            }else{
+                                vms.push(t_server_vm);
+                            }
+                        });
+                    }else{
+                        vms.push(t_server_vm);
+                    }
 
-           $('<td><button id="submit_flowspace" type="button" style="height: 25px; width: 400px" onclick="fnButsubmit()">Define controller location</button></td></tr></table>').appendTo('div.buttons');**/
-       
-          
-           jQuery( "#univbris_flowspace_selection" ).hide();
+                               }
 
-             //$('<a href="http://localhost:8000/login/" id="next_link">next link</a>').appendTo('div.submit');
+                               var rspecs = JSON.stringify(vms);
+                               console.log(rspecs);
+                // manifold.raise_event(self.options.query_uuid, ...);
+                       }
 
-               //this.new_record("t");
-               //this.new_record("t");
-               //this.new_record("t");
-               //this.new_record("t");
-               //this.new_record("t");
-               this._querytable_draw_callback();
-       
-               
+               }
+               catch(err){
+                       alert(err)
+               }               
+       },
 
-        }, // initialize_table
 
 
-       fnButsubmit:function(e){
-               alert("submitting flowspaces to AM (TO BE IMPLEMENTED)");
-               
-                       
+       fnAddVm:function(e){
+               //this.hideFvfError(e);
+               $('#uob_vm_name').removeClass('error');
+               $("#uob_vm_name").val("");
+               jQuery('#uob_vm_name_error').hide();
+               jQuery("#univbris_vtam").hide();
+               jQuery("#univbris_vtam_form").show();
        },
 
-       fnAddflowspace:function(e){
-               this.table = $("#univbris_flowspace_selection__table").dataTable();
-               //alert("table length" + this.table.fnGetNodes().length);       
-               $("#flowspace_name").val("flowspace"+(this.table.fnGetNodes().length+1));
-               jQuery( "#univbris_flowspace_selection" ).hide();
-               jQuery("#uob_fv_table_form").show();            
-       },
+       
+
+
+
 
        
 
+       fnDelete:function(e){
+                       e.preventDefault();
+                       var nRow = $(this).parents('tr')[0];
+                       this.table = $("#univbris_vtam__table").dataTable();
+                       this.table.fnDeleteRow( nRow );
+       },
+
+
+
+
        
 
         /**
             return (tabIndex.length > 0) ? tabIndex[0] : -1;
         }, // getColIndex
 
-       // create a checkbox <input> tag
-       // computes 'id' attribute from canonical_key
-       // computes 'init_id' from init_key for initialization phase
-       // no need to used convoluted ids with plugin-uuid or others, since
-       // we search using table.$ which looks only in this table
-        checkbox_html : function (record) {
-            var result="";
-            // Prefix id with plugin_uuid
-            result += "<input";
-            result += " class='univbrisfv-checkbox'";
-        // compute id from canonical_key
-           var id = record[this.canonical_key]
-        // compute init_id form init_key
-           var init_id=record[this.init_key];
-        // set id - for retrieving from an id, or for posting events upon user's clicks
-           result += " id='"+record[this.canonical_key]+"'";
-        // set init_id
-           result += "init_id='" + init_id + "'";
-        // wrap up
-            result += " type='checkbox'";
-            result += " autocomplete='off'";
-            result += "></input>";
-            return result;
-        }, 
-
-        fake_checkbox_html : function (record) {
-           //alert("fake fun called");
-            var result="";
-            // Prefix id with plugin_uuid
-            result += "<input";
-            //result += " class='univbrisfv-checkbox'";
-        // set id - for retrieving from an id, or for posting events upon user's clicks
-           result += " id='"+ record +"'";
-           result += " name='"+ record +"'";
-        // set init_id
-           result += " init_id='" + record + "'";
-        // wrap up
-            result += " type='checkbox'";
-            result += " autocomplete='off'";
-            result += "></input>";
-           ///alert(result);
-            return result;
-        }, 
 
+       
 
         new_record: function(record)
         {
            
-        // this models a line in dataTables, each element in the line describes a cell
-            line = new Array();
-     
-            // go through table headers to get column names we want
-            // in order (we have temporarily hack some adjustments in names)
-            var cols = this.table.fnSettings().aoColumns;
-            var colnames = cols.map(function(x) {return x.sTitle})
-            var nb_col = cols.length;
-            /* if we've requested checkboxes, then forget about the checkbox column for now */
-            if (this.options.checkboxes) nb_col -= 1;
-           
-           //alert(colnames);
-           /*replace production*/
-            /* fill in stuff depending on the column name */
-             var cols = this.table.fnSettings().aoColumns;
-           //alert("col "+cols);
-            var colnames = cols.map(function(x) {return x.sTitle})
-            var nb_col = cols.length;
-                       //alert("nb_col: "+ nb_col);
-            /* if we've requested checkboxes, then forget about the checkbox column for now */
-            if (this.options.checkboxes) nb_col -= 1;
-                       //alert("nb_col: "+ nb_col);
-           //alert(colnames);
-           /*replace production*/
-            /* fill in stuff depending on the column name */
-            for (var j = 0; j < nb_col; j++) {
-                if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'Flowspace Selector') {
-                   //alert("added");
-                    line.push("first");
-               }
-               
-
-               /*if (typeof colnames[j] == 'undefined') {
-                    line.push('...');
-                } else if (colnames[j] == 'hostname') {
-                    if (record['type'] == 'resource,link')
-                        //TODO: we need to add source/destination for links
-                        line.push('');
-                    else
-                        line.push(record['hostname']);
-
-                } else if (colnames[j] == 'hrn' && typeof(record) != 'undefined') {
-                    line.push('<a href="../resource/'+record['urn']+'"><span class="glyphicon glyphicon-search"></span></a> '+record['hrn']);
-                } else {
-                    if (record[colnames[j]])
-                        line.push(record[colnames[j]]);
-                    else
-                        line.push('');
-                }*/
-            }
-    
-            // catch up with the last column if checkboxes were requested 
-            if (this.options.checkboxes) {
-                // Use a key instead of hostname (hard coded...)
-                line.push(this.checkbox_html(record));
-               }
-    
-           // adding an array in one call is *much* more efficient
-               // this.table.fnAddData(line);
-               this.buffered_lines.push(line);
-               this.table.fnAddData(this.buffered_lines);
-               //this.table.redraw();
-               //this._querytable_draw_callback();
         },
 
         clear_table: function()
        set_checkbox_from_record: function (record, checked) {
             if (checked === undefined) checked = true;
            var init_id = record[this.init_key];
-           if (debug) messages.debug("univbrisfv.set_checkbox_from_record, init_id="+init_id);
+           if (debug) messages.debug("UnivbrisVtam.set_checkbox_from_record, init_id="+init_id);
            // using table.$ to search inside elements that are not visible
            var element = this.table.$('[init_id="'+init_id+'"]');
            element.attr('checked',checked);
        // id relates to canonical_key
        set_checkbox_from_data: function (id, checked) {
             if (checked === undefined) checked = true;
-           if (debug) messages.debug("univbrisfv.set_checkbox_from_data, id="+id);
+           if (debug) messages.debug("UnivbrisVtam.set_checkbox_from_data, id="+id);
            // using table.$ to search inside elements that are not visible
            var element = this.table.$("[id='"+id+"']");
            element.attr('checked',checked);
 
         on_field_clear: function()
         {
-            alert('UnivbrisFv::clear_fields() not implemented');
+            alert('UnivbrisVtam::clear_fields() not implemented');
         },
 
         /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
 
         on_all_field_clear: function()
         {
-            alert('UnivbrisFv::clear_fields() not implemented');
+            alert('UnivbrisVtam::clear_fields() not implemented');
         },
 
 
 
         on_new_record: function(record)
         {
-            if (this.received_all_query) {
-               // if the 'all' query has been dealt with already we may turn on the checkbox
-                this.set_checkbox_from_record(record, true);
-            } else {
-                this.buffered_records_to_check.push(record);
-            }
         },
 
         on_clear_records: function()
         on_all_query_done: function()
         {
            if (debug) messages.debug("1-shot initializing dataTables content with " + this.buffered_lines.length + " lines");
-           this.table.fnAddData (this.buffered_lines);
+
+
+           //this.table.fnAddData (this.buffered_lines);
            this.buffered_lines=[];
            
             var self = this;
              * the table is redrawn    
              */
             this.elts('querytable-checkbox').unbind('click').click(this, this._check_click);
-           $("#submit_flowspace").unbind('click').click(this, this.fnButsubmit);
-           $("#add_flowspace").unbind('click').click(this, this.fnAddflowspace);
-
+           $("#add_vm").unbind('click').click(this, this.fnAddVm);
+           $("#submit_vms").unbind('click').click(this, this.fnCreateVms);
+           $('#univbris_vtam__table .delete').unbind('click').click(this, this.fnDelete);
+           /*var edits=this.elts.all.find('.edit');
+           edits.each(function(){
+               this.unbind('click').click(this,this.fnEdit);
+            }
+           */
             if (!this.table)
                 return;
 
                 $('.querytable_length', wrapper).css('visibility', 'visible');
             }
 
+           
+
+
         },
 
 
 
     });
 
-    $.plugin('UnivbrisFv', UnivbrisFv);
+   
+
+    $.plugin('UnivbrisVtam', UnivbrisVtam);
 
   /* define the 'dom-checkbox' type for sorting in datatables 
      http://datatables.net/examples/plug-ins/dom_sort.html
        } );
     }
 
+   
+
 })(jQuery);
 
+
+
diff --git a/plugins/univbrisvtam/templates/univbrisvtamplugin.html b/plugins/univbrisvtam/templates/univbrisvtamplugin.html
new file mode 100644 (file)
index 0000000..bcd7787
--- /dev/null
@@ -0,0 +1,29 @@
+<div id='main-{{ domid }}' class='univbrisvtam-spacer'>
+ <form id="uob_vtam">
+  <table class='table table-striped table-bordered dataTable' id='{{domid}}__table'>
+    <thead>
+      <tr>
+        {% for column in columns %} <th>{{ column }}</th> {% endfor %} 
+        {% for column in hidden_columns %} <th>{{ column }}</th> {% endfor %}
+      </tr>
+    </thead> 
+    <tbody>
+    </tbody> 
+    <tfoot> 
+      <tr>
+        {% for column in columns %} <th>{{ column }}</th> {% endfor %} 
+        {% for column in hidden_columns %} <th>{{ column }}</th> {% endfor %} 
+      </tr>
+    </tfoot> 
+  </table>
+  <table class = 'table tbbuttons' align="center" id='uob_fv_form_buttons'>
+       <tr>
+               <td align="center"><button id="add_vm" type="button" style="height: 25px; width: 300px;" onclick="fnAddVm()">add another VM to request</button></td>
+       <tr>
+
+       </tr>
+               <td align="center"><button id="submit_vms" type="button" style="height: 25px; width: 300px" onclick="fnCreateVms()">Create VMs (submit to AM)</button></td>
+       </tr>
+</table>
+ </form>
+</div>
diff --git a/plugins/univbrisvtamform/__init__.py b/plugins/univbrisvtamform/__init__.py
new file mode 100644 (file)
index 0000000..5f6c0d2
--- /dev/null
@@ -0,0 +1,43 @@
+from unfold.plugin import Plugin
+
+class UnivbrisVtamForm (Plugin):
+
+    def __init__ (self, query=None, query_all=None, 
+                  checkboxes=False, columns=None, 
+                  init_key=None,
+                  datatables_options={}, **settings):
+        Plugin.__init__(self, **settings)
+        self.query          = query
+       self.query.uuid     = query.query_uuid if query else None
+        self.query_all      = query_all
+        self.query_all_uuid = query_all.query_uuid if query_all else None
+
+
+    def template_file (self):
+        return "univbrisvtamform.html"
+
+    def template_env (self, request):
+        env={}
+        env.update(self.__dict__)
+        return env
+
+    def requirements (self):
+        reqs = {
+            'js_files' : [ "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js", 
+                           "js/dataTables.js", "js/dataTables.bootstrap.js", "js/with-datatables.js",
+                           "js/manifold.js", "js/manifold-query.js", 
+                           "js/unfold-helper.js",
+                           "js/univbrisvtamform.js",
+                           ] ,
+            'css_files': [ "css/dataTables.bootstrap.css",
+                           "css/dataTables.full_numbers.css",
+                           "css/univbrisvtamform.css",
+                           ],
+            }
+        return reqs
+
+    def json_settings_list (self):
+        return ['plugin_uuid', 'domid', 
+                'query_uuid', 'query_all_uuid', 
+                'checkboxes', 'datatables_options', 
+                'hidden_columns', 'init_key',]
diff --git a/plugins/univbrisvtamform/static/css/univbrisvtamform.css b/plugins/univbrisvtamform/static/css/univbrisvtamform.css
new file mode 100644 (file)
index 0000000..cd227cf
--- /dev/null
@@ -0,0 +1,65 @@
+
+/* the bottom of the datatable needs more space */
+div.univbrisvtamform-spacer { padding: 8px 4px 15px 4px; }
+
+div.UnivbrisVtamForm table.dataTable th {
+    font: bold 12px/22px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+    color: #4f6b72;
+    border-right: 1px solid #C1DAD7;
+    border-bottom: 1px solid #C1DAD7;
+    border-top: 1px solid #C1DAD7;
+    letter-spacing: 1px;
+    text-transform: uppercase;
+    text-align: left;
+    padding: 8px 12px 4px 20px;
+    vertical-align:middle;
+/*    background: #CAE8EA url(../img/tablesort-header.jpg) no-repeat; */
+}
+
+div.UnivbrisVtamForm table.dataTable th.checkbox {
+    padding-left: 14px;
+}
+
+div.UnivbrisVtamForm table.dataTable td, div.UnivbrisVtamForm table.dataTable textarea, div.UnivbrisVtamForm table.dataTable input [type="text"] {
+    font: bold 12px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+    color: #660099;
+    border-right: 1px solid #C1DAD7;
+    border-bottom: 1px solid #C1DAD7;
+}
+div.UnivbrisVtamForm table.dataTable td {
+    padding: 4px 8px 4px 8px;
+    /* this applies on even rows only, odd ones have a setting in bootstrap of rbg 249.249.249 */
+    background-color: #f4f4f4;
+    color: #660099;
+}
+div.UnivbrisVtamForm table.dataTable td a {
+    font-weight:normal;
+}
+/* these come from bootstrap */
+div.UnivbrisVtamForm div.dataTables_info {
+    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+}
+
+/* one could think or using repeat-x here but that's not working because of the arrows
+ * we might need to make these wider some day 
+ * and/or to add background-color: #caebea
+ * which would look less conspicuous in case of overflow
+*/
+
+div.UnivbrisVtamForm table.dataTable thead .sorting { background: url('../img/tablesort-header-sortable.png') no-repeat; }
+div.UnivbrisVtamForm table.dataTable thead .sorting_asc { background: url('../img/tablesort-header-up.png') no-repeat; }
+div.UnivbrisVtamForm table.dataTable thead .sorting_desc { background: url('../img/tablesort-header-down.png') no-repeat; }
+/* this icons set does not have that exact equivalent - using an approximation for now */
+div.UnivbrisVtamForm table.dataTable thead .sorting_asc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+div.UnivbrisVtamForm table.dataTable thead .sorting_desc_disabled { background: url('../img/tablesort-header.png') repeat-x; }
+
+/* the footers are not active */
+div.UnivbrisVtamForm table.dataTable tfoot { 
+    background: url('../img/tablesort-header.png') repeat-x;
+    background-color: #caebea;
+}
+/* and when sorting is turned off it's useful to set this on header too */
+div.UnivbrisVtamForm table.dataTable thead { 
+    background: url('../img/tablesort-header.png') repeat-x;
+    background-color: #caebea;
+}
diff --git a/plugins/univbrisvtamform/static/img/README b/plugins/univbrisvtamform/static/img/README
new file mode 100644 (file)
index 0000000..5df2d69
--- /dev/null
@@ -0,0 +1,2 @@
+these styling elements come from plekit with a simple transition to png
+they're currently not all used in myslice
diff --git a/plugins/univbrisvtamform/static/img/tablesort-bullet1.png b/plugins/univbrisvtamform/static/img/tablesort-bullet1.png
new file mode 100644 (file)
index 0000000..4304f36
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-bullet1.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-bullet2.png b/plugins/univbrisvtamform/static/img/tablesort-bullet2.png
new file mode 100644 (file)
index 0000000..4f181e1
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-bullet2.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-col-alt.png b/plugins/univbrisvtamform/static/img/tablesort-col-alt.png
new file mode 100644 (file)
index 0000000..8179f83
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-col-alt.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-gradient.png b/plugins/univbrisvtamform/static/img/tablesort-gradient.png
new file mode 100644 (file)
index 0000000..26558a4
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-gradient.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-header-down.png b/plugins/univbrisvtamform/static/img/tablesort-header-down.png
new file mode 100644 (file)
index 0000000..c8ed657
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header-down.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-header-sortable.png b/plugins/univbrisvtamform/static/img/tablesort-header-sortable.png
new file mode 100644 (file)
index 0000000..0c16904
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header-sortable.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-header-up.png b/plugins/univbrisvtamform/static/img/tablesort-header-up.png
new file mode 100644 (file)
index 0000000..d12fe2a
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header-up.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-header.png b/plugins/univbrisvtamform/static/img/tablesort-header.png
new file mode 100644 (file)
index 0000000..cff526f
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-header.png differ
diff --git a/plugins/univbrisvtamform/static/img/tablesort-td-alt.png b/plugins/univbrisvtamform/static/img/tablesort-td-alt.png
new file mode 100644 (file)
index 0000000..ef5ab35
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/tablesort-td-alt.png differ
diff --git a/plugins/univbrisvtamform/static/img/toggle-hidden.png b/plugins/univbrisvtamform/static/img/toggle-hidden.png
new file mode 100755 (executable)
index 0000000..023f22a
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/toggle-hidden.png differ
diff --git a/plugins/univbrisvtamform/static/img/toggle-visible.png b/plugins/univbrisvtamform/static/img/toggle-visible.png
new file mode 100755 (executable)
index 0000000..baf6c28
Binary files /dev/null and b/plugins/univbrisvtamform/static/img/toggle-visible.png differ
diff --git a/plugins/univbrisvtamform/static/js/univbrisvtamform.js b/plugins/univbrisvtamform/static/js/univbrisvtamform.js
new file mode 100644 (file)
index 0000000..ac0df1a
--- /dev/null
@@ -0,0 +1,326 @@
+/**
+ * Description: display a query result in a datatables-powered <table>
+ * Copyright (c) 2012-2013 UPMC Sorbonne Universite - INRIA
+ * License: GPLv3
+ */ 
+
+(function($){
+
+    vt_servers_list=[];
+    testbeds_list=[];
+
+    var UnivbrisVtamForm = Plugin.extend({
+
+        init: function(options, element) {
+           //console.log("hello....................");
+            this._super(options, element);
+            this.filters = Array(); 
+
+            // an internal buffer for records that are 'in' and thus need to be checked 
+            this.buffered_records_to_check = [];
+           // an internal buffer for keeping lines and display them in one call to fnAddData
+           this.buffered_lines = [];
+
+           
+
+            
+           //var keys = manifold.metadata.get_key(this.object);
+           //this.canonical_key = (keys && keys.length == 1) ? keys[0] : undefined;
+           // 
+           //this.init_key = this.options.init_key;
+           // have init_key default to canonical_key
+           //this.init_key = this.init_key || this.canonical_key;
+           // sanity check
+           //if ( ! this.init_key ) messages.warning ("UnivbrisVtamForm : cannot find init_key");
+           //if ( ! this.canonical_key ) messages.warning ("UnivbrisVtamForm : cannot find canonical_key");
+           //if (debug) messages.debug("UnivbrisVtamForm: canonical_key="+this.canonical_key+" init_key="+this.init_key);
+
+            /* Setup query and record handlers */
+            this.listen_query(options.query_uuid);
+           // this.listen_query(options.query_all_uuid, 'all');
+
+            /* GUI setup and event binding */
+
+
+           $('<button id="cancelvtamform" type="button" style="height: 25px; width: 200px" onclick="fnCancelVtamForm()">Cancel</button>').appendTo('#vtam_form_buttons');
+           $("#cancelvtamform").unbind('click').click(this, this.fnCancelVtamForm);
+
+           $('<button id="addvtamform" type="button" style="height: 25px; width: 200px" onclick="fnAddVtamForm()">Add VM</button>').appendTo('#vtam_form_buttons');
+           $("#addvtamform").unbind('click').click(this, this.fnAddVtamForm);
+
+          jQuery("#univbris_vtam_form").hide();
+
+          $('#uob_testbed_name').on("change", this.testbedChanged);
+
+          //this.on_new_record("urn:publicid:IDN+i2cat:vtam+node+Rodoreda");
+          //this.on_new_record("urn:publicid:IDN+bristol:vtam+node+March");
+          //this.on_new_record("urn:publicid:IDN+brazil:vtam+node+Verdaguer");
+          //this.on_query_done();
+          
+          // console.log("after");
+        },
+
+       testbedChanged: function(e){
+               console.log($('#uob_testbed_name option:selected').text());
+
+               $('#uob_virtualization_server')
+                       .find('option')
+                       .remove()
+                       .end();
+
+               for(var i=0;i<vt_servers_list.length;i++){
+                   if(vt_servers_list[i].testbed==$('#uob_testbed_name option:selected').text()){
+                               $('#uob_virtualization_server')
+                                       .append($("<option></option>")
+                                       .attr("value",vt_servers_list[i].urn)
+                                       .text(vt_servers_list[i].name)); 
+                   }
+               }
+       },
+
+
+       fnCancelVtamForm:function(e){
+               jQuery("#univbris_vtam_form").hide();
+               jQuery("#univbris_vtam").show();
+               console.log("cancel vtam form");
+       },
+
+       fnAddVtamForm:function(e){
+               console.log("add vtam form");
+               var vmNameVal = /^[a-zA-Z0-9]+$/;
+               //console.log($("#uob_vm_name").val());
+               if (vmNameVal.test($("#uob_vm_name").val())){
+                       //build form string
+            //{"urn:publicid:IDN+vtam.univbris+node+uclalien":[{"name":"toto"}]}
+            var vtam='{"'+$('#uob_virtualization_server option:selected').val()+'":';
+            vtam+='[{"name":"'+$('#uob_vm_name').val()+'"}]}';
+                       //var vtam="testbed="+$('#uob_testbed_name option:selected').text();
+            // Use the URN instead of the hostname of the server
+                       //vtam +=",vt_server="+$('#uob_virtualization_server option:selected').val();
+                       //vtam +=",vm_name="+$("#uob_vm_name").val();
+                       var vm_name="<p id='"+vtam+"'>"+$("#uob_vm_name").val()+"</p>";
+                       var vtamtable = $("#univbris_vtam__table").dataTable();
+                       vtamtable.fnAddData([$('#uob_testbed_name option:selected').text(),$('#uob_virtualization_server option:selected').text(), vm_name,'<a class="delete" href="">Delete</a>']);
+                       jQuery("#univbris_vtam_form").hide();
+                       jQuery("#univbris_vtam").show();
+               }
+               else{
+                       $('#uob_vm_name').addClass('error');
+                       jQuery('#uob_vm_name_error').show();
+               }
+       },
+
+        /* PLUGIN EVENTS */
+
+        on_show: function(e) {
+       },        
+
+        on_resize: function(e) {
+       },        
+
+        /* GUI EVENTS */
+
+        /* GUI MANIPULATION */
+
+        new_record: function(record)
+        {
+            var urn = record['urn'];
+            var pos = urn.search('vtam');
+            if (pos!=-1){
+                ///line =new Array();
+                var vt_server={};
+                var com_ay=urn.split("+");
+                vt_server['name']=com_ay[com_ay.length-1];
+                var testbed_ay=com_ay[1].split(":");
+                vt_server['testbed']=testbed_ay[0];
+                vt_server['urn']=urn;
+                this.add_new_vt_server(vt_server);
+                this.add_new_testbed(testbed_ay[0]);
+                //this.vt_servers_list.push(vt_server);
+            }
+        },
+
+        clear_table: function()
+        {
+        },
+
+        redraw_table: function()
+        {
+        },
+
+
+       add_new_vt_server:function(vt_server){
+               var found=false;
+               for(var i=0;i<vt_servers_list.length;i++){
+                       if(vt_servers_list[i].name==vt_server.name && vt_servers_list[i].testbed==vt_server.testbed){
+                               found=true;
+                               break;
+                       }
+               }
+
+               //console.log(found);
+
+               if (found==false){
+                        vt_servers_list.push(vt_server);
+               }
+       },
+
+       add_new_testbed:function(testbed){
+               var found=false;
+               for(var i=0;i<testbeds_list.length;i++){
+                       if(testbeds_list[i]==testbed){
+                               found=true;
+                               break;
+                       }
+               }
+
+               //console.log(found);
+
+               if (found==false){
+                        testbeds_list.push(testbed);
+               }
+       },
+
+
+
+       
+
+        /*************************** QUERY HANDLER ****************************/
+
+        on_filter_added: function(filter)
+        {
+        },
+
+        on_filter_removed: function(filter)
+        {
+        },
+        
+        on_filter_clear: function()
+        {
+            this.redraw_table();
+        },
+
+        on_field_added: function(field)
+        {
+            this.show_column(field);
+        },
+
+        on_field_removed: function(field)
+        {
+            this.hide_column(field);
+        },
+
+        on_field_clear: function()
+        {
+        },
+
+
+        /*************************** ALL QUERY HANDLER ****************************/
+
+        on_all_filter_added: function(filter)
+        {
+        },
+
+        on_all_filter_removed: function(filter)
+        {
+
+        },
+        
+        on_all_filter_clear: function()
+        {
+        },
+
+        on_all_field_added: function(field)
+        {
+        },
+
+        on_all_field_removed: function(field)
+        {
+        },
+
+        on_all_field_clear: function()
+        {
+        },
+
+
+        /*************************** RECORD HANDLER ***************************/
+
+        on_new_record: function(record)
+        {
+           //alert("record:")
+           console.log(record.hostname);
+            if (this.received_all_query) {
+                
+            } else {
+                this.buffered_records_to_check.push(record);
+            }
+        },
+
+        on_clear_records: function()
+        {
+        },
+
+        // Could be the default in parent
+        on_query_in_progress: function()
+        {
+            this.spin();
+        },
+
+        on_query_done: function()
+        {
+            this.received_query = true;
+           for(var i=0;i<this.buffered_records_to_check.length;i++){
+               this.new_record(this.buffered_records_to_check[i]);
+           }
+
+       
+           /*$.each(vt_servers_list, function(key, value) {   
+                       $('#uob_testbed_name')
+                               .append($("<option></option>")
+                               .attr("value",key)
+                               .text(value.testbed)); 
+           });*/
+
+            $('#uob_testbed_name')
+                       .find('option')
+                       .remove()
+                       .end()
+
+           for(var t=0;t<testbeds_list.length;t++){
+               $('#uob_testbed_name')
+                               .append($("<option></option>")
+                               .attr("value",testbeds_list[t])
+                               .text(testbeds_list[t])); 
+           }
+
+           $('#uob_virtualization_server')
+                       .find('option')
+                       .remove()
+                       .end()
+
+           for(var i=0;i<vt_servers_list.length;i++){
+                   if(vt_servers_list[i].testbed==$('#uob_testbed_name option:selected').text()){
+                               $('#uob_virtualization_server')
+                                       .append($("<option></option>")
+                                       .attr("value",vt_servers_list[i].urn)
+                                       .text(vt_servers_list[i].name)); 
+                   }
+           }
+        
+            this.unspin();
+        },
+        
+        on_field_state_changed: function(data)
+        {
+
+        },
+
+    }); //close plugin extend
+
+    $.plugin('UnivbrisVtamForm', UnivbrisVtamForm);
+
+})(jQuery);
+
+
+
+
diff --git a/plugins/univbrisvtamform/templates/univbrisvtamform.html b/plugins/univbrisvtamform/templates/univbrisvtamform.html
new file mode 100644 (file)
index 0000000..b9f7c50
--- /dev/null
@@ -0,0 +1,62 @@
+<style>
+.multiselect {
+    width:40em;
+    height:5em;
+    border:solid 1px #c0c0c0;
+    overflow:auto;
+}
+.multiselect label {
+    display:block;
+}
+.multiselect-on {
+    color:#ffffff;
+    background-color:#000099;
+}
+
+.error{
+border:2px solid red;
+}
+
+</style>
+
+<form id="uob_vtam_form">
+  <table id='uob_vtam_table'>
+                       <tr>
+                               <th><strong>Testbed</strong></th>
+                               <td>
+                                       <select id="uob_testbed_name" name="uob_testbed_name" maxlength="20" title="Testbed Name"/>
+                               </td>
+                               <td>
+                               </td>
+                        </tr>
+
+                       <tr>
+                               <th><strong>Virtualization Server</strong></th>
+                               <td>
+                                       
+                                       <label for="uob_virtualization_server"></label>
+                                       <select id="uob_virtualization_server" name="uob_virtualization_server" maxlength="20" title="Virtualization Server of VM" />
+                               </td>
+                               <td>
+                               </td>
+                        </tr>                
+
+
+                        <tr>
+                               <th><strong>VM Name</strong></th>
+                               <td>
+                                       
+                                       <label for="uob_vm_name"></label>
+                                       <input id="uob_vm_name" type="text" name="uob_vm_name" maxlength="20" title="Name of VM" />
+                               </td>
+                               <td>
+                                       <p id="uob_vm_name_error" >name of VM should be alphanumeric</p>        
+                               </td>
+                        </tr>  
+                             
+  </table>
+ </form>
+<div id="vtam_form_buttons"></div>
+
diff --git a/portal/account.py b/portal/account.py
new file mode 100644 (file)
index 0000000..7d08e1c
--- /dev/null
@@ -0,0 +1,45 @@
+from manifold.core.query                import Query
+from manifoldapi.manifoldapi            import execute_query
+
+from datetime import datetime
+import time
+import dateutil.parser
+import calendar
+
+import json, os, re, itertools
+
+class Account:
+    def __init__ (self, platform_id, user_id):
+        account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config').filter_by('platform_id', '==', platform_id).filter_by('user_id', '==', user_id)
+        account_details = execute_query(self.request, account_query)
+        self.user_id     = account_details['user_id']
+        self.platform_id = account_details['platform_id']
+        self.auth_type   = account_details['auth_type']
+        self.config      = account_details['config']
+        account_config = json.loads(account_details['config'])
+
+        self.usr_hrn = account_config.get('user_hrn',None)
+        self.pub_key = account_config.get('user_public_key',None)
+        self.reference = account_config.get ('reference_platform',None)
+
+        self.user_cred = account_config.get('delegated_user_credential',None)
+        self.user_cred_expiration = get_expiration(self.user_cred)
+        
+        slice_creds = account_config.get('delegated_slice_credentials',None)
+        for slice_name, slice_cred in slice_creds.iteritems():
+            self.slice_cred_expiration = get_expiration(self.slice_cred)
+
+        self.auth_cred = account_config.get('delegated_authority_credentials',None)
+        self.auth_cred_expiration = get_expiration(self.auth_cred)
+
+def get_expiration (credential, format = 'UTC'):
+    exp_date = re.search('<expires>(.*)</expires>', credential)
+    if exp_date:
+        exp_date = exp_date.group(1)
+        if format == 'timestamp':
+            exp_date = calendar.timegm(dateutil.parser.parse(exp_date).utctimetuple())
+    else:
+        exp_date = None
+    return exp_date
+
index 734485b..4d25c61 100644 (file)
@@ -5,7 +5,7 @@ from sfa.trust.certificate              import Keypair
 #
 from manifold.core.query                import Query
 from manifoldapi.manifoldapi            import execute_query
-from portal.actions                     import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, sfa_get_user
+from portal.actions                     import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, sfa_get_user, clear_user_creds
 #
 from unfold.page                        import Page    
 from ui.topmenu                         import topmenu_items_live, the_user
@@ -14,10 +14,12 @@ from django.http                        import HttpResponse, HttpResponseRedirec
 from django.contrib                     import messages
 from django.contrib.auth.decorators     import login_required
 
+from myslice.configengine           import ConfigEngine
 from myslice.theme import ThemeView
 
+from portal.account                     import Account, get_expiration
 #
-import json, os, re, itertools
+import json, os, re, itertools, time
 from OpenSSL import crypto
 from Crypto.PublicKey import RSA
 
@@ -31,9 +33,15 @@ class AccountView(LoginRequiredAutoLogoutView, ThemeView):
     def get_context_data(self, **kwargs):
         self.template_name = self.template
         page = Page(self.request)
+        metadata = page.get_metadata()
+        page.expose_js_metadata()
+
         page.add_js_files  ( [ "js/jquery.validate.js", "js/my_account.register.js", "js/my_account.edit_profile.js","js/jquery-ui.js" ] )
         page.add_css_files ( [ "css/onelab.css", "css/account_view.css","css/plugin.css" ] )
 
+        # Execute a Query to delegate credentials if necessary
+        sfa_user_query  = Query().get('myslice:user').select('user_hrn').filter_by('user_hrn','==','$user_hrn')
+        sfa_user_result = execute_query(self.request, sfa_user_query)
 
         user_query  = Query().get('local:user').select('config','email','status')
         user_details = execute_query(self.request, user_query)
@@ -187,29 +195,40 @@ class AccountView(LoginRequiredAutoLogoutView, ThemeView):
 
 
         ## check user is pi or not
-        platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
-        account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
-        platform_details = execute_query(self.request, platform_query)
-        account_details = execute_query(self.request, account_query)
-        for platform_detail in platform_details:
-            for account_detail in account_details:
-                if platform_detail['platform_id'] == account_detail['platform_id']:
-                    if 'config' in account_detail and account_detail['config'] is not '':
-                        account_config = json.loads(account_detail['config'])
-                        if 'myslice' in platform_detail['platform']:
-                            acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+      #  platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
+      #  account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
+      #  platform_details = execute_query(self.request, platform_query)
+      #  account_details = execute_query(self.request, account_query)
+      #  for platform_detail in platform_details:
+      #      for account_detail in account_details:
+      #          if platform_detail['platform_id'] == account_detail['platform_id']:
+      #              if 'config' in account_detail and account_detail['config'] is not '':
+      #                  account_config = json.loads(account_detail['config'])
+      #                  if 'myslice' in platform_detail['platform']:
+      #                      acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
         # assigning values
         if acc_auth_cred == {} or acc_auth_cred == 'N/A':
             pi = "is_not_pi"
         else:
             pi = "is_pi"
 
+        # check if the user has creds or not
+        if acc_user_cred == {} or acc_user_cred == 'N/A':
+            user_cred = 'no_creds'
+        else:
+            exp_date = get_expiration(acc_user_cred, 'timestamp')
+            if exp_date < time.time():
+                user_cred = 'creds_expired'
+            else:
+                user_cred = 'has_creds'
+
         context = super(AccountView, self).get_context_data(**kwargs)
         context['principal_acc'] = principal_acc_list
         context['ref_acc'] = ref_acc_list
         context['platform_list'] = platform_list
         context['my_users'] = my_users
         context['pi'] = pi
+        context['user_cred'] = user_cred
         context['my_slices'] = my_slices
         context['my_auths'] = my_auths
         context['user_status'] = user_status
@@ -234,6 +253,20 @@ class AccountView(LoginRequiredAutoLogoutView, ThemeView):
         context.update(prelude_env)
         return context
 
+@login_required
+def get_myslice_platform(request):
+    platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled','config').filter_by('platform','==','myslice')
+    platform_details = execute_query(request, platform_query)
+    for platform_detail in platform_details:
+        return platform_detail
+
+@login_required
+def get_myslice_account(request):
+    platform_myslice = get_myslice_platform(request)
+    account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config').filter_by('platform_id','==',platform_myslice['platform_id'])
+    account_details = execute_query(request, account_query)
+    for account_detail in account_details:
+        return account_detail
 
 @login_required
 #my_acc form value processing
@@ -247,9 +280,19 @@ def account_process(request):
     platform_query  = Query().get('local:platform').select('platform_id','platform')
     platform_details = execute_query(request, platform_query)
     
-    # getting the user_id from the session
-    for user_detail in user_details:
-            user_id = user_detail['user_id']
+    # getting the user_id from the session                                            
+    for user_detail in user_details:                                                  
+        user_id = user_detail['user_id']                                              
+        user_email = user_detail['email']                                             
+        try:
+            if user_email == request.user.email:                                          
+                authorize_query = True                                                    
+            else:                                                                         
+                print "SECURITY: %s tried to update %s" % (user_email, request.user.email)
+                messages.error(request, 'You are not authorized to modify another user.') 
+                return HttpResponseRedirect("/portal/account/")                               
+        except Exception,e:
+            print "Exception = %s" % e
 
     for account_detail in account_details:
         for platform_detail in platform_details:
@@ -346,6 +389,8 @@ def account_process(request):
         return HttpResponseRedirect("/portal/account/")
 
 # XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/joinview.py
 
     elif 'generate' in request.POST:
         for account_detail in account_details:
@@ -368,7 +413,7 @@ def account_process(request):
                         # updating sfa
                         public_key = public_key.replace('"', '');
                         user_pub_key = {'keys': public_key}
-                        #sfa_update_user(request, user_hrn, user_pub_key)
+
                         sfa_update_user(request, user_hrn, user_pub_key)
                         result_sfa_user = sfa_get_user(request, user_hrn, public_key)
                         try:
@@ -383,6 +428,7 @@ def account_process(request):
                                 raise Exception,"Keys are not matching"
                         except Exception,e:
                             messages.error(request, 'Error: An error occured during the update of your public key at the Registry, or your public key is not matching the one stored.')
+                            print "Exception in accountview ", e
                         return HttpResponseRedirect("/portal/account/")
         else:
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
@@ -503,30 +549,52 @@ def account_process(request):
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
             return HttpResponseRedirect("/portal/account/")
 
+    # Download sfi_config
+    elif 'dl_sfi_config' in request.POST:
+        platform_detail = get_myslice_platform(request)
+        platform_config = json.loads(platform_detail['config'])
+        account_detail = get_myslice_account(request)
+        account_config = json.loads(account_detail['config'])
+
+        user_hrn = account_config.get('user_hrn','N/A')
+        t_user_hrn = user_hrn.split('.')
+        authority_hrn = t_user_hrn[0] + '.' + t_user_hrn[1]
+        import socket
+        hostname = socket.gethostbyaddr(socket.gethostname())[0]
+        registry = platform_config.get('registry','N/A')
+        admin_user = platform_config.get('user','N/A')
+        if 'localhost' in registry:
+            port = registry.split(':')[-1:][0]
+            registry = "http://" + hostname +':'+ port
+        manifold_host = ConfigEngine().manifold_url()
+        if 'localhost' in manifold_host:
+            manifold_host = manifold_host.replace('localhost',hostname)
+        sfi_config  = '[sfi]\n'
+        sfi_config += 'auth = '+ authority_hrn +'\n'
+        sfi_config += 'user = '+ user_hrn +'\n'
+        sfi_config += 'registry = '+ registry +'\n'
+        sfi_config += 'sm = http://sfa3.planet-lab.eu:12346/\n\n'
+        sfi_config += '[myslice]\n'
+        sfi_config += 'backend = '+ manifold_host +'\n'
+        sfi_config += 'delegate  = '+ admin_user +'\n'
+        sfi_config += 'platform  = myslice\n'
+        sfi_config += 'username  = '+ user_email +'\n'
+        response = HttpResponse(sfi_config, content_type='text/plain')
+        response['Content-Disposition'] = 'attachment; filename="sfi_config"'
+        return response
+
     #clear all creds
     elif 'clear_cred' in request.POST:
-        for account_detail in account_details:
-            for platform_detail in platform_details:
-                if platform_detail['platform_id'] == account_detail['platform_id']:
-                    if 'myslice' in platform_detail['platform']:
-                        account_config = json.loads(account_detail['config'])
-                        user_cred = account_config.get('delegated_user_credential','N/A')
-                        if 'N/A' not in user_cred:
-                            user_hrn = account_config.get('user_hrn','N/A')
-                            user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
-                            user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
-                            updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
-                            user_params = { 'config': updated_config}
-                            manifold_update_account(request,user_id, user_params)
-                            messages.success(request, 'All Credentials cleared')
-                            return HttpResponseRedirect("/portal/account/")
-                        else:
-                            messages.error(request, 'Delete error: Credentials are not stored in the server')
-                            return HttpResponseRedirect("/portal/account/")
-        else:
+        try:
+            result = clear_user_creds(request, user_email)
+            if result is not None: 
+                messages.success(request, 'All Credentials cleared')
+            else:
+                messages.error(request, 'Delete error: Credentials are not stored in the server')
+        except Exception,e:
+            print "Exception in accountview.py in clear_user_creds %s" % e
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
-            return HttpResponseRedirect("/portal/account/")
-
+        return HttpResponseRedirect("/portal/account/")
 
     # Download delegated_user_cred
     elif 'dl_user_cred' in request.POST:
index baf4cca..d934671 100644 (file)
@@ -4,7 +4,9 @@ from manifoldapi.manifoldapi    import execute_query,execute_admin_query
 from portal.models              import PendingUser, PendingSlice, PendingAuthority
 import json
 
-from django.contrib.auth.models import User
+from django.contrib.auth.models  import User
+from django.contrib.sites.models import Site
+from django.contrib.auth        import get_user_model
 from django.template.loader     import render_to_string
 from django.core.mail           import EmailMultiAlternatives, send_mail
 
@@ -12,6 +14,8 @@ from myslice.theme              import ThemeView
 
 theme = ThemeView()
 
+import activity.slice
+
 # Thierry: moving this right into the code so 
 # most people can use myslice without having to install sfa
 # XXX tmp sfa dependency, should be moved to SFA gateway
@@ -42,13 +46,52 @@ def authority_get_pi_emails(request, authority_hrn):
         #default_email = default_email.replace('\n', '')
         #return default_email
         # the above doesn't work
-        return ['support@myslice.info']
+        return ['support@onelab.eu']
     else:
         pi_user_hrns = [ hrn for x in pi_users for hrn in x['pi_users'] ]
         query = Query.get('user').filter_by('user_hrn', 'included', pi_user_hrns).select('user_email')
         results = execute_admin_query(request, query)
         return [result['user_email'] for result in results]
 
+#clear user credentials
+def clear_user_creds(request, user_email):
+    try:
+        user_query  = Query().get('local:user').filter_by('email', '==', user_email).select('user_id','email','password','config')
+        user_details = execute_admin_query(request, user_query)
+    
+        # getting the user_id from the session
+        for user_detail in user_details:
+            user_id = user_detail['user_id']
+            user_email = user_detail['email']
+    
+        account_query  = Query().get('local:account').filter_by('user_id', '==', user_id).select('user_id','platform_id','auth_type','config')
+        account_details = execute_admin_query(request, account_query)
+    
+        platform_query  = Query().get('local:platform').select('platform_id','platform')
+        platform_details = execute_admin_query(request, platform_query)
+    
+        for account_detail in account_details:
+            for platform_detail in platform_details:
+                if platform_detail['platform_id'] == account_detail['platform_id']:
+                    if 'myslice' in platform_detail['platform']:
+                        account_config = json.loads(account_detail['config'])
+                        #user_cred = account_config.get('delegated_user_credential','N/A')
+                        user_cred = account_config.get('user_credential','N/A')
+                        if 'N/A' not in user_cred:
+                            user_hrn = account_config.get('user_hrn','N/A')
+                            user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
+                            user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
+                            updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
+                            user_params = { 'config': updated_config}
+                            manifold_update_account(request, user_id,user_params)
+                            return user_email
+                        else:
+                            return None
+
+    except Exception,e:
+        print "Exception in actions.py in clear_user_creds %s" % e
+        return None
+
 def is_pi(wsgi_request, user_hrn, authority_hrn):
     # XXX could be done in a single query !
 
@@ -66,7 +109,7 @@ def is_pi(wsgi_request, user_hrn, authority_hrn):
 
 def sfa_get_user(request, user_hrn, pub):
     query_sfa_user = Query.get('user').filter_by('user_hrn', '==', user_hrn)
-    result_sfa_user = execute_query(request, query_sfa_user)
+    result_sfa_user = execute_admin_query(request, query_sfa_user)
     return result_sfa_user                        
 
 def sfa_update_user(request, user_hrn, user_params):
@@ -74,7 +117,7 @@ def sfa_update_user(request, user_hrn, user_params):
     if 'email' in user_params:
         user_params['user_email'] = user_params['email']
     query = Query.update('user').filter_by('user_hrn', '==', user_hrn).set(user_params).select('user_hrn')
-    results = execute_query(request,query)
+    results = execute_admin_query(request,query)
     return results
 
 def sfa_add_authority(request, authority_params):
@@ -162,6 +205,11 @@ def manifold_delete_account(request, platform_id, user_id, account_params):
     results = execute_admin_query(request,query)
     return results
 
+def manifold_delete_user(request, user_id, user_params):
+    query = Query.delete('local:user').filter_by('user_id', '==', user_id).set(user_params).select('user_id')
+    results = execute_admin_query(request,query)
+    return results
+
 
 #not tested
 def manifold_add_platform(request, platform_params):
@@ -252,7 +300,7 @@ def get_request_by_id(ids):
 def get_requests(authority_hrns=None):
     print "get_request_by_authority auth_hrns = ", authority_hrns
     if not authority_hrns:
-        ## get those pending users who have validated their emails
+        ## get those pending users who have confirmed their emails
         pending_users  = PendingUser.objects.filter(status__iexact = 'True')
         pending_slices = PendingSlice.objects.all()
         pending_authorities = PendingAuthority.objects.all()
@@ -321,13 +369,14 @@ def portal_validate_request(wsgi_request, request_ids):
                 # XXX tmp sfa dependency
                 from sfa.util.xrn import Xrn 
                 urn = Xrn(hrn, request['type']).get_urn()
-
+                
+                # Only hrn is required for Manifold Query 
                 sfa_authority_params = {
-                    'hrn'        : hrn,
-                    'urn'        : urn,
-                    'type'       : request['type'],
+                    'authority_hrn'        : hrn,
+                    #'authority_urn'        : urn,
+                    #'type'       : request['type'],
                     #'pi'        : None,
-                    'enabled'    : True
+                    #'enabled'    : True
                 }
                 print "ADD Authority"
                 sfa_add_authority(wsgi_request, sfa_authority_params)
@@ -343,13 +392,177 @@ def portal_validate_request(wsgi_request, request_ids):
 
     return status
 
-
 def validate_action(request, **kwargs):
     ids = filter(None, kwargs['id'].split('/'))
     status = portal_validate_request(request, ids)
     json_answer = json.dumps(status)
     return HttpResponse (json_answer, mimetype="application/json")
 
+
+def reject_action(request, **kwargs):
+    ids = filter(None, kwargs['id'].split('/'))
+    status = portal_reject_request(request, ids)
+    json_answer = json.dumps(status)
+    return HttpResponse (json_answer, mimetype="application/json")
+
+
+def portal_reject_request(wsgi_request, request_ids):
+    status = {}
+    # get the domain url    
+    current_site = Site.objects.get_current()
+    current_site = current_site.domain
+
+
+    if not isinstance(request_ids, list):
+        request_ids = [request_ids]
+
+    requests = get_request_by_id(request_ids)
+    for request in requests:
+        # type, id, timestamp, details, allowed -- MISSING: authority_hrn
+        # CAREFUL about details
+        # user  : first name, last name, email, password, keypair
+        # slice : number of nodes, type of nodes, purpose
+        
+        request_status = {}
+
+        if request['type'] == 'user':
+            try:
+                request_status['SFA user'] = {'status': True }
+                # getting user email based on id 
+                ## RAW SQL queries on Django DB- https://docs.djangoproject.com/en/dev/topics/db/sql/
+                for user in PendingUser.objects.raw('SELECT * FROM portal_pendinguser WHERE id = %s', [request['id']]):
+                    user_email= user.email
+                    first_name = user.first_name
+                    last_name = user.last_name
+
+                ctx = {
+                    'first_name'    : first_name, 
+                    'last_name'     : last_name, 
+                    'portal_url'    : current_site,
+                    }
+                try:
+                    theme.template_name = 'user_request_denied.txt'
+                    text_content = render_to_string(theme.template, ctx)
+                    theme.template_name = 'user_request_denied.html'
+                    html_content = render_to_string(theme.template, ctx)
+                    theme.template_name = 'email_default_sender.txt'
+                    sender =  render_to_string(theme.template, ctx)
+                    sender = sender.replace('\n', '')
+                               
+                    subject = 'User request denied.'
+
+                    msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+                    msg.attach_alternative(html_content, "text/html")
+                    msg.send()
+                except Exception, e:
+                    print "Failed to send email, please check the mail templates and the SMTP configuration of your server"   
+            
+                # removing from Django auth_user
+                UserModel = get_user_model()
+                UserModel._default_manager.filter(email__iexact = user_email).delete()
+                # removing from Django portal_pendinguser
+                PendingUser.objects.get(id=request['id']).delete()
+                # removing from manifold
+                # removing manifold account
+                user_query = Query().get('local:user') \
+                    .filter_by('email', '==', user_email)           \
+                    .select('user_id')
+                user = execute_admin_query(wsgi_request, user_query)
+                user_id = user[0]['user_id']
+        
+                platform_query = Query().get('local:platform') \
+                    .filter_by('platform', '==', 'myslice')           \
+                    .select('platform_id')
+                platform = execute_admin_query(wsgi_request, platform_query)
+                platform_id = platform[0]['platform_id']
+                account_params = {'user_id':user_id}
+                manifold_delete_account(request, platform_id, user_id, account_params)           
+             
+                # removing manifold user
+                user_params = {'user_id':user_id}
+                manifold_delete_user(request, user_id, user_params)
+            except Exception, e:
+                request_status['SFA authority'] = {'status': False, 'description': str(e)}
+                      
+        elif request['type'] == 'slice':
+            request_status['SFA slice'] = {'status': True } 
+
+            # getting user email based on id 
+            ## RAW SQL queries on Django DB- https://docs.djangoproject.com/en/dev/topics/db/sql/
+            for user in PendingSlice.objects.raw('SELECT * FROM portal_pendingslice WHERE id = %s', [request['id']]):
+                user_email= user.type_of_nodes # XXX type_of_nodes field contains the email [shd be renamed in DB]
+                slice_name = user.slice_name
+                purpose = user.purpose
+                url = user.number_of_nodes
+
+            ctx = {
+                'slice_name': slice_name,
+                'purpose': purpose,
+                'url': url,
+                'portal_url': current_site,
+                }
+            try:
+                theme.template_name = 'slice_request_denied.txt'
+                text_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'slice_request_denied.html'
+                html_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'email_default_sender.txt'
+                sender =  render_to_string(theme.template, ctx)
+                sender = sender.replace('\n', '')
+                               
+                subject = 'Slice request denied.'
+
+                msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+                msg.attach_alternative(html_content, "text/html")
+                msg.send()
+            except Exception, e:
+                print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+                      
+            PendingSlice.objects.get(id=request['id']).delete()
+
+        elif request['type'] == 'authority':
+            request_status['SFA authority'] = {'status': True }
+            
+            # getting user email based on id 
+            ## RAW SQL queries on Django DB- https://docs.djangoproject.com/en/dev/topics/db/sql/
+            for user in PendingAuthority.objects.raw('SELECT * FROM portal_pendingauthority WHERE id = %s', [request['id']]):
+                user_email= user.address_line1 # XXX address_line1 field contains the email [shd be renamed in DB]
+                site_name = user.site_name
+                city = user.address_city
+                country = user.address_country
+                short_name = user.site_abbreviated_name
+                url = user.site_url
+
+            ctx = { 
+                'site_name': site_name,
+                'short_name': short_name,
+                'url': url,
+                'city': city,
+                'country': country,                          
+                'portal_url'    : current_site,
+                }
+                
+            try:
+                theme.template_name = 'authority_request_denied.txt'
+                text_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'authority_request_denied.html'
+                html_content = render_to_string(theme.template, ctx)
+                theme.template_name = 'email_default_sender.txt'
+                sender =  render_to_string(theme.template, ctx)
+                sender = sender.replace('\n', '')
+                subject = 'Authority request denied.'
+                msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+                msg.attach_alternative(html_content, "text/html")
+                msg.send()
+            except Exception, e:
+                print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+
+            PendingAuthority.objects.get(id=request['id']).delete()
+
+        status['%s__%s' % (request['type'], request['id'])] = request_status
+
+    return status
+
 # Django and ajax
 # http://djangosnippets.org/snippets/942/
 
@@ -376,21 +589,55 @@ def create_slice(wsgi_request, request):
     # Add User to Slice if we have the user_hrn in pendingslice table
     user_hrn = request.get('user_hrn', None)
     user_hrns = list([user_hrn]) if user_hrn else list()
+    
+    user_query  = Query().get('user').select('user_hrn','user_email').filter_by('user_hrn','==',user_hrn)
+    user_details_sfa = execute_admin_query(wsgi_request, user_query)
+    if not user_details_sfa:
+        raise Exception, "User %s doesn't exist, validate user before validating slice" % user_hrn
+    for user in user_details_sfa:
+        user_email = user['user_email']
+
+    # XXX LOIC Quick fix because this is totally inconsistent
+    if not 'number_of_nodes' in request:
+        request['number_of_nodes']=""
 
     # XXX We should create a slice with Manifold terminology
     slice_params = {
         'slice_hrn'        : hrn, 
         'slice_urn'        : urn,
         'slice_type'       : request['type'],
+        'url'              : request['number_of_nodes'],
         'users'            : user_hrns,
         'slice_enabled'    : True
     }
     # ignored in request: id, timestamp,  number_of_nodes, type_of_nodes, purpose
 
-    query = Query.create('slice').set(slice_params).select('slice_hrn')
+    query = Query.create('myslice:slice').set(slice_params).select('slice_hrn')
     results = execute_query(wsgi_request, query)
     if not results:
         raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
+    else:
+        clear_user_creds(wsgi_request,user_email)
+        # log user activity
+        activity.slice.validate(request, { "slice" : hrn })
+        try:
+            theme.template_name = 'slice_request_validated.txt'
+            text_content = render_to_string(theme.template, request)
+            theme.template_name = 'slice_request_validated.html'
+            html_content = render_to_string(theme.template, request)
+        
+            theme.template_name = 'email_default_sender.txt'
+            sender =  render_to_string(theme.template, request)
+            sender = sender.replace('\n', '')
+
+            subject = 'Slice request validated'
+
+            msg = EmailMultiAlternatives(subject, text_content, sender, [user_email])
+            msg.attach_alternative(html_content, "text/html")
+            msg.send()
+        except Exception, e:
+            print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+       
     return results
 
 def create_pending_slice(wsgi_request, request, email):
@@ -402,8 +649,9 @@ def create_pending_slice(wsgi_request, request, email):
         slice_name      = request['slice_name'],
         user_hrn        = request['user_hrn'],
         authority_hrn   = request['authority_hrn'],
-        number_of_nodes = request['number_of_nodes'],
+        number_of_nodes = request['url'], # field needs to be renamed
         purpose         = request['purpose'],
+        type_of_nodes   = request['email'] # field needs to be renamed 
     )
     s.save()
 
@@ -474,7 +722,7 @@ def manifold_add_reference_user_accounts(wsgi_request, request):
         }
         manifold_add_account(wsgi_request, manifold_account_params)
 
-def sfa_create_user(wsgi_request, request):
+def sfa_create_user(wsgi_request, request, namespace = None, as_admin = False):
     """
     Arguments:
         wsgi_request (~ WSGIRequest) : 
@@ -501,14 +749,77 @@ def sfa_create_user(wsgi_request, request):
         'user_enabled'      : True
     }
 
-    query = Query.create('user').set(sfa_user_params).select('user_hrn')
-    results = execute_query(wsgi_request, query)
+    if namespace is not None:
+        query = Query.create('%s:user' % namespace).set(sfa_user_params).select('user_hrn')
+    else:
+        query = Query.create('user').set(sfa_user_params).select('user_hrn')
+
+    if as_admin:
+        results = execute_admin_query(wsgi_request, query)
+    else:
+        results = execute_query(wsgi_request, query)
+
     if not results:
         raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
+    else:
+        try:
+            theme.template_name = 'user_request_validated.txt'
+            text_content = render_to_string(theme.template, request)
+            theme.template_name = 'user_request_validated.html'
+            html_content = render_to_string(theme.template, request)
+        
+            theme.template_name = 'email_default_sender.txt'
+            sender =  render_to_string(theme.template, request)
+            sender = sender.replace('\n', '')
+
+
+            subject = 'User validated'
+
+            msg = EmailMultiAlternatives(subject, text_content, sender, [request['email']])
+            msg.attach_alternative(html_content, "text/html")
+            msg.send()
+        except Exception, e:
+            print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+
     return results
 
-def create_user(wsgi_request, request):
+def iotlab_create_user (wsgi_request, request, namespace = None, as_admin=False):
+   
+    import requests
+    import time
+    from requests.auth import HTTPBasicAuth
     
+    URL_REST = 'https://devgrenoble.senslab.info/rest/admin/users'
+    LOGIN_ADMIN = "auge"
+    PASSWORD_ADMIN = "k,mfg1+Q"
+
+    auth = HTTPBasicAuth(LOGIN_ADMIN,PASSWORD_ADMIN)
+    headers = {'content-type': 'application/json'}
+
+    for user in PendingUser.objects.raw('SELECT * FROM portal_pendinguser WHERE email = %s', [request['email']]):
+        password= user.password
+
+
+    iotlab_user_params = {
+        "type"          : "SA",
+        "login"         : request['email'],
+        "password"      : password,
+        "firstName"     : request['first_name'],
+        "lastName"      : request['last_name'],
+        "email"         : request['email'],
+        "structure"     : request['authority_hrn'],
+        "city"          : "N/A",
+        "country"       : "N/A",
+        "sshPublicKey"  : request['public_key'],
+        "motivations"   : "SFA federation",
+    }    
+   
+    iotlab_user_params1 = json.dumps(iotlab_user_params)
+    r=requests.post(url=URL_REST, data=iotlab_user_params1, headers=headers, auth=auth)
+    print 'Create iotlab user : ', r.status_code, r.text
+    return r.text
+
+def create_user(wsgi_request, request, namespace = None, as_admin = False):
     # XXX This has to be stored centrally
     USER_STATUS_ENABLED = 2
 
@@ -516,7 +827,7 @@ def create_user(wsgi_request, request):
     # we would have to perform the steps in create_pending_user too
 
     # Add the user to the SFA registry
-    sfa_create_user(wsgi_request, request)
+    sfa_create_user(wsgi_request, request, namespace, as_admin)
 
     # Update Manifold user status
     manifold_update_user(wsgi_request, request['email'], {'status': USER_STATUS_ENABLED})
@@ -524,6 +835,10 @@ def create_user(wsgi_request, request):
     # Add reference accounts for platforms
     manifold_add_reference_user_accounts(wsgi_request, request)
 
+    # Add the user to iotlab portal if theme is set to onelab
+    if theme.theme == 'onelab':
+        iotlab_create_user (wsgi_request, request)
+
 def create_pending_user(wsgi_request, request, user_detail):
     """
     """
@@ -538,7 +853,7 @@ def create_pending_user(wsgi_request, request, user_detail):
         public_key    = request['public_key'],
         private_key   = request['private_key'],
         user_hrn      = request['user_hrn'],
-        pi            = '',                         # XXX Why not None ?
+        pi            = request['pi'],
         email_hash    = request['email_hash'],
         status        = 'False',
     )
@@ -551,7 +866,6 @@ def create_pending_user(wsgi_request, request, user_detail):
     theme.template_name = 'activate_user_email_subject.txt'
     subject = render_to_string(theme.template, request)
     subject = subject.replace('\n', '')
-    #sender = 'support@myslice.info'
     theme.template_name = 'email_default_sender.txt'
     sender =  render_to_string(theme.template, request)
     sender = sender.replace('\n', '')
index c41ee74..19cc1b9 100644 (file)
@@ -11,6 +11,9 @@ from manifoldapi.manifoldapi            import execute_query
 import json
 
 from myslice.theme import ThemeView
+
+import activity.user
+
 theme = ThemeView()
 
 # splitting the 2 functions done here
@@ -28,17 +31,18 @@ class ContactView (FreeAccessView, ThemeView):
             subject = form.cleaned_data['subject']
             description = form.cleaned_data['description']
             email = form.cleaned_data['email'] # email of the sender
-            cc_myself = form.cleaned_data['cc_myself']
+            #cc_myself = form.cleaned_data['cc_myself']
 
             #try:
                 # Send an email: the support recipients
-            #theme.template_name = 'email_support.txt'
-            #recipients = render_to_string(theme.template, form.cleaned_data)
-            #recipients = subject.replace('\n', '')
-            recipients = ['support@myslice.info']
-            if cc_myself:
-                recipients.append(email)
-            #recipients = ['support@myslice.info']
+            theme.template_name = 'email_default_recipients.txt'
+            recipients = render_to_string(theme.template, form.cleaned_data)
+            recipients = recipients.replace('\n', '')
+            #recipients = ['support@onelab.eu']
+            ## removed it cz recipients is not a list so append doesn't work ###
+            ## we don't need it cz the new ticketing systems sends a confirmation email ###
+            #if cc_myself:
+            #    recipients.append(email)
             theme.template_name = 'contact_support_email.html'
             html_content = render_to_string(theme.template, form.cleaned_data)
         
@@ -56,7 +60,7 @@ class ContactView (FreeAccessView, ThemeView):
             #    else:
             sender = email
         
-            msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
+            msg = EmailMultiAlternatives(subject, text_content, sender, [recipients])
             msg.attach_alternative(html_content, "text/html")
             msg.send()
             #except Exception, e:
@@ -66,6 +70,8 @@ class ContactView (FreeAccessView, ThemeView):
                 username = request.user.email
             else :
                 username = None
+            # log user activity
+            activity.user.contact(self.request)
             return render(request,'contact_sent.html', { 'theme' : self.theme,  'username': username}) # Redirect after POST
         else:
             return self._display (request, form)
index 2a3e617..533cccf 100644 (file)
@@ -2,7 +2,7 @@ from unfold.loginrequired               import FreeAccessView
 #
 from manifold.core.query                import Query
 from manifoldapi.manifoldapi            import execute_query, execute_admin_query
-from portal.actions                     import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, authority_get_pi_emails
+from portal.actions                     import manifold_update_user, manifold_update_account, manifold_add_account, manifold_delete_account, sfa_update_user, authority_get_pi_emails, make_request_user, create_user
 #
 from unfold.page                        import Page    
 from ui.topmenu                         import topmenu_items_live, the_user
@@ -11,20 +11,35 @@ from django.http                        import HttpResponse, HttpResponseRedirec
 from django.contrib                     import messages
 from django.contrib.auth.decorators     import login_required
 from myslice.theme                      import ThemeView
-from portal.models                      import PendingUser
+from portal.models                      import PendingUser, PendingAuthority
 from django.core.mail                   import EmailMultiAlternatives, send_mail
 from django.contrib.sites.models        import Site
 
 #
 import json, os, re, itertools
 
+def ValuesQuerySetToDict(vqs):
+    return [item for item in vqs]
+
 # requires login
 class ActivateEmailView(FreeAccessView, ThemeView):
     template_name = "email_activation.html"
+    def is_ple_enabled(self, pending_user):
+        pending_authorities = PendingAuthority.objects.filter(site_authority__iexact = pending_user.authority_hrn)
+        if pending_authorities:
+            return False                        
+        pending_user_email = pending_user.email
+        query = Query.get('myplcuser').filter_by('email', '==', pending_user_email).select('enabled')
+        results = execute_admin_query(self.request, query)
+        for result in results:
+            # User is enabled in PLE
+            if 'enabled' in result and result['enabled']==True:
+                return True
+        return False
+
     def dispatch(self, *args, **kwargs):
         return super(ActivateEmailView, self).dispatch(*args, **kwargs)
 
-
     def get_context_data(self, **kwargs):
 
         page = Page(self.request)
@@ -35,43 +50,58 @@ class ActivateEmailView(FreeAccessView, ThemeView):
             #print "%s = %s" % (key, value)
             if key == "hash_code":
                 hash_code=value
-       
-        if PendingUser.objects.filter(email_hash__iexact = hash_code):           
-            #get_user = PendingUser.objects.filter(email_hash__iexact = hash_code)
-            #get_user.status= 'True'
-            #get_user.save()
-            #for user in PendingUser.objects.all():
-            #    first_name = user.first_name
-            #    last_name = user.last_name
-            #    authority_hrn = user.authority_hrn
-            #    public_key = user.public_key
-            #    email = user.email
-            #    user_hrn = user.user_hrn
-            PendingUser.objects.filter(email_hash__iexact = hash_code).update(status='True')
+        if PendingUser.objects.filter(email_hash__iexact = hash_code).filter(status__iexact = 'False'):           
             activation = 'success'
-            # sending email after activation success
-            #try:
-                # Send an email: the recipients are the PI of the authority
-                # If No PI is defined for this Authority, send to a default email (different for each theme)
-             #   recipients = authority_get_pi_emails(wsgi_request, authority_hrn)
-             #   theme.template_name = 'user_request_email.html'
-             #   html_content = render_to_string(theme.template, request)
-             #   theme.template_name = 'user_request_email.txt'
-             #   text_content = render_to_string(theme.template, request)
-             #   theme.template_name = 'user_request_email_subject.txt'
-             #   subject = render_to_string(theme.template, request)
-             #   subject = subject.replace('\n', '')
-             #   theme.template_name = 'email_default_sender.txt'
-             #   sender =  render_to_string(theme.template, request)
-             #   sender = sender.replace('\n', '')
-             #   msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
-             #   msg.attach_alternative(html_content, "text/html")
-             #   msg.send()
-           # except Exception, e:
-             #   print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
-             #   import traceback
-             #   traceback.print_exc()
 
+            # AUTO VALIDATION of PLE enabled users (only for OneLab Portal)
+            if self.theme == "onelab":
+                # Auto-Validation of pending user, which is enabled in a trusted SFA Registry (example: PLE)
+                # We could check in the Registry based on email, but it takes too long 
+                # as we currently need to do a Resolve on each user_hrn of the Registry in order to get its email
+                # TODO in SFA XXX We need a Resolve based on email
+                # TODO maybe we can use MyPLC API for PLE
+                pending_users = PendingUser.objects.filter(email_hash__iexact = hash_code)
+
+                # by default user is not in PLE
+                ple_user_enabled = False
+
+                if pending_users:
+                    pending_user = pending_users[0]
+                    
+                    # Auto Validation 
+                    if self.is_ple_enabled(pending_user):
+                        pending_user_request = make_request_user(pending_user)
+                        # Create user in SFA and Update in Manifold
+                        create_user(self.request, pending_user_request, namespace = 'myslice', as_admin = True)
+                        # Delete pending user
+                        PendingUser.objects.filter(email_hash__iexact = hash_code).delete()
+
+                        # template user auto validated
+                        activation = 'validated'
+
+                        # sending email after activation success
+                        #try:
+                        #    # Send an email: the recipient is the user
+                        #    recipients = pending_user_eamil 
+                        #    theme.template_name = 'user_request_email.html'
+                        #    html_content = render_to_string(theme.template, request)
+                        #    theme.template_name = 'user_request_email.txt'
+                        #    text_content = render_to_string(theme.template, request)
+                        #    theme.template_name = 'user_request_email_subject.txt'
+                        #    subject = render_to_string(theme.template, request)
+                        #    subject = subject.replace('\n', '')
+                        #    theme.template_name = 'email_default_sender.txt'
+                        #    sender =  render_to_string(theme.template, request)
+                        #    sender = sender.replace('\n', '')
+                        #    msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
+                        #    msg.attach_alternative(html_content, "text/html")
+                        #    msg.send()
+                        #except Exception, e:
+                        #    print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+                        #    import traceback
+                        #    traceback.print_exc()
+            
+            PendingUser.objects.filter(email_hash__iexact = hash_code).update(status='True')
         else:
             activation = 'failed'
         
index 683cffb..e5087d8 100644 (file)
@@ -85,16 +85,9 @@ class ContactForm(forms.Form):
    #                              label=_("authority"),
    #                              error_messages={'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})
     email = forms.EmailField(widget=forms.TextInput(attrs={'class':'form-control'}))
-    subject = forms.RegexField(widget=forms.TextInput(attrs={'class':'form-control'}),
-                                regex=r'^[\w+\s\w+]+$',
-                                 max_length=100,
-                                 label=_("subject"),
-                                 error_messages={'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})
-    description = forms.RegexField(widget=forms.Textarea(attrs={'class':'form-control'}),
-                                regex=r'^[\w+\s\w+]+$',
-                                 label=_("description"),
-                                 error_messages={'invalid': _("This value may contain only letters, numbers and @/./+/-/_ characters.")})    
-    cc_myself = forms.BooleanField(required=False,widget=forms.CheckboxInput(attrs={'class':'form-control'}))
+    subject = forms.CharField(widget=forms.TextInput(attrs={'class':'form-control'}))
+    description = forms.CharField(widget=forms.Textarea(attrs={'class':'form-control'}))
+    #cc_myself = forms.BooleanField(required=False,widget=forms.CheckboxInput(attrs={'class':'form-control'}))
 
 class PassResetForm(forms.Form):
     email = forms.EmailField(widget=forms.TextInput(attrs={'class':'form-control'}))
index d46ed65..3e9514f 100644 (file)
@@ -1,22 +1,27 @@
 # this somehow is not used anymore - should it not be ?
-from django.core.context_processors import csrf
-from django.http import HttpResponseRedirect
-from django.contrib.auth import authenticate, login, logout
-from django.template import RequestContext
-from django.shortcuts import render_to_response
-from django.shortcuts import render
-import json
+from django.core.context_processors     import csrf
+from django.http                        import HttpResponseRedirect
+from django.contrib.auth                import authenticate, login, logout
+from django.template                    import RequestContext
+from django.shortcuts                   import render_to_response
+from django.shortcuts                   import render
 
-from unfold.loginrequired import FreeAccessView
+
+from unfold.loginrequired               import FreeAccessView
 
 from manifold.core.query                import Query
 from manifoldapi.manifoldapi            import execute_query
 
-from manifoldapi.manifoldresult import ManifoldResult
-from ui.topmenu import topmenu_items, the_user
-from myslice.configengine import ConfigEngine
+from manifoldapi.manifoldresult         import ManifoldResult
+from ui.topmenu                         import topmenu_items, the_user
+from myslice.configengine               import ConfigEngine
+
+from myslice.theme                      import ThemeView
+from portal.account                     import Account, get_expiration
+from portal.models                      import PendingSlice
 
-from myslice.theme import ThemeView
+import json, time
+import activity.user
 
 class HomeView (FreeAccessView, ThemeView):
     template_name = 'home-view.html'
@@ -62,61 +67,118 @@ class HomeView (FreeAccessView, ThemeView):
                     env['person'] = self.request.user
                     env['username'] = self.request.user
                     
+                    # log user activity
+                    activity.user.login(self.request)
+                    
                     ## check user is pi or not
+                    platform_details = {}
+                    account_details = {}
+                    acc_auth_cred = {}
+                    acc_user_cred = {}
                     platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
                     account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
                     platform_details = execute_query(self.request, platform_query)
                     account_details = execute_query(self.request, account_query)
-                    for platform_detail in platform_details:
-                        for account_detail in account_details:
-                            if platform_detail['platform_id'] == account_detail['platform_id']:
-                                if 'config' in account_detail and account_detail['config'] is not '':
-                                    account_config = json.loads(account_detail['config'])
-                                    if 'myslice' in platform_detail['platform']:
-                                        acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+                    if platform_details is not None and platform_details != {}:
+                        for platform_detail in platform_details:
+                            for account_detail in account_details:
+                                if platform_detail['platform_id'] == account_detail['platform_id']:
+                                    if 'config' in account_detail and account_detail['config'] is not '':
+                                        account_config = json.loads(account_detail['config'])
+                                        if 'myslice' in platform_detail['platform']:
+                                            acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+                                            acc_user_cred = account_config.get('delegated_user_credential','N/A')
                     # assigning values
                     if acc_auth_cred=={} or acc_auth_cred=='N/A':
                         pi = "is_not_pi"
                     else:
                         pi = "is_pi"
 
-                    env['pi'] = pi                
+                    # check if the user has creds or not
+                    if acc_user_cred == {} or acc_user_cred == 'N/A':
+                        user_cred = 'no_creds'
+                    else:
+                        exp_date = get_expiration(acc_user_cred, 'timestamp')
+                        if exp_date < time.time():
+                            user_cred = 'creds_expired'
+                        else:
+                            user_cred = 'has_creds'
+
+                    # list the pending slices of this user
+                    pending_slices = []
+                    for slices in PendingSlice.objects.filter(type_of_nodes__iexact=self.request.user).all():
+                        pending_slices.append(slices.slice_name)
+
+                    env['pending_slices'] = pending_slices
+                    env['pi'] = pi
+                    env['user_cred'] = user_cred                
                 else: 
                     env['person'] = None
                 return render_to_response(self.template,env, context_instance=RequestContext(request))
             else:
+                # log user activity
+                activity.user.login(self.request, "notactive")
                 env['state'] = "Your account is not active, please contact the site admin."
                 env['layout_1_or_2']="layout-unfold2.html"
                 
                 return render_to_response(self.template,env, context_instance=RequestContext(request))
         # otherwise
         else:
+            # log user activity
+            activity.user.login(self.request, "error")
             env['state'] = "Your username and/or password were incorrect."
             
             return render_to_response(self.template, env, context_instance=RequestContext(request))
 
     def get (self, request, state=None):
         env = self.default_env()
+        acc_auth_cred={}
         if request.user.is_authenticated():
+           
             ## check user is pi or not
+            platform_details = {}
+            account_details = {}
+            acc_auth_cred = {}
+            acc_user_cred = {}
             platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
             account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
+            # XXX Something like an invalid session seems to make the execute fail sometimes, and thus gives an error on the main page
             platform_details = execute_query(self.request, platform_query)
             account_details = execute_query(self.request, account_query)
-            for platform_detail in platform_details:
-                for account_detail in account_details:
-                    if platform_detail['platform_id'] == account_detail['platform_id']:
-                        if 'config' in account_detail and account_detail['config'] is not '':
-                            account_config = json.loads(account_detail['config'])
-                            if 'myslice' in platform_detail['platform']:
-                                acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+            if platform_details is not None and platform_details != {}:
+                for platform_detail in platform_details:
+                    for account_detail in account_details:
+                        if 'platform_id' in platform_detail:
+                            if platform_detail['platform_id'] == account_detail['platform_id']:
+                                if 'config' in account_detail and account_detail['config'] is not '':
+                                    account_config = json.loads(account_detail['config'])
+                                    if 'myslice' in platform_detail['platform']:
+                                        acc_auth_cred = account_config.get('delegated_authority_credentials','N/A')
+                                        acc_user_cred = account_config.get('delegated_user_credential','N/A')
             # assigning values
             if acc_auth_cred=={} or acc_auth_cred=='N/A':
                 pi = "is_not_pi"
             else:
                 pi = "is_pi"
 
-            env['pi'] = pi     
+            # check if the user has creds or not
+            if acc_user_cred == {} or acc_user_cred == 'N/A':
+                user_cred = 'no_creds'
+            else:
+                exp_date = get_expiration(acc_user_cred, 'timestamp')
+                if exp_date < time.time():
+                    user_cred = 'creds_expired'
+                else:
+                    user_cred = 'has_creds'
+
+            # list the pending slices of this user
+            pending_slices = []
+            for slices in PendingSlice.objects.filter(type_of_nodes__iexact=self.request.user).all():
+                pending_slices.append(slices.slice_name)
+        
+            env['pending_slices'] = pending_slices
+            env['pi'] = pi
+            env['user_cred'] = user_cred                
             env['person'] = self.request.user
         else: 
             env['person'] = None
index 5dd04c2..0282e96 100644 (file)
@@ -2,12 +2,14 @@ import os.path, re
 import json
 from random import randint
 
+from hashlib                    import md5
 from django.core.mail           import EmailMultiAlternatives
 from django.contrib.auth.models import User
 from django.views.generic       import View
 from django.template.loader     import render_to_string
 from django.shortcuts           import render
 from django.contrib.auth        import get_user_model
+from django.contrib.sites.models import Site
 
 from unfold.page                import Page
 from unfold.loginrequired       import FreeAccessView
@@ -17,10 +19,12 @@ from manifoldapi.manifoldapi    import execute_admin_query
 from manifold.core.query        import Query
 
 from portal.models              import PendingUser,PendingAuthority
-from portal.actions             import authority_get_pi_emails, manifold_add_user,manifold_add_account
+from portal.actions             import authority_get_pi_emails, manifold_add_user,manifold_add_account, create_pending_user
 
 from myslice.theme import ThemeView
 
+import activity.institution
+
 # since we inherit from FreeAccessView we cannot redefine 'dispatch'
 # so let's override 'get' and 'post' instead
 #
@@ -59,20 +63,22 @@ class JoinView (FreeAccessView, ThemeView):
 
             reg_site_name = request.POST.get('site_name', '')
             reg_site_authority = request.POST.get('site_authority', '').lower()
-            reg_site_abbreviated_name = request.POST.get('site_abbreviated_name', '')
+            reg_site_abbreviated_name = request.POST.get('site_abbreviated_name', '').lower()
             reg_site_url = request.POST.get('site_url', '')
             reg_site_latitude = request.POST.get('site_latitude', '')
             reg_site_longitude = request.POST.get('site_longitude', '')
 
             reg_fname  = request.POST.get('pi_first_name', '')
             reg_lname  = request.POST.get('pi_last_name', '')
-            reg_auth   = reg_root_authority_hrn + "." + reg_site_authority 
+            reg_auth   = 'onelab.' + reg_site_abbreviated_name   
             reg_email  = request.POST.get('pi_email','').lower()
             reg_phone  = request.POST.get('pi_phone','')
             #prepare user_hrn 
             split_email = reg_email.split("@")[0] 
             split_email = split_email.replace(".", "_")
-            user_hrn = reg_auth + '.' + split_email+ str(randint(1,1000000))
+            # Replace + by _ => more convenient for testing and validate with a real email
+            split_email = split_email.replace("+", "_")
+            user_hrn = reg_auth + '.' + split_email
             
             UserModel = get_user_model()
             
@@ -89,6 +95,16 @@ class JoinView (FreeAccessView, ThemeView):
                 errors.append('First Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
             if (re.search(r'^[\w+\s.@+-]+$', reg_lname) == None):
                 errors.append('Last Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
+            if (re.search(r'^[A-Za-z0-9_ ]*$', reg_site_name) == None):
+                errors.append('Name of organization  may contain only letters, numbers, and underscore.')
+            if (re.search(r'^[A-Za-z ]*$', reg_address_city) == None):
+                errors.append('City may contain only letters.')
+            if (re.search(r'^[A-Za-z ]*$', reg_address_country) == None):
+                errors.append('Country may contain only letters.')
+            if (re.search(r'^[A-Za-z0-9]*$', reg_site_abbreviated_name) == None):
+                errors.append('Shortname  may contain only letters and numbers')
+            if (re.search(r'^[0-9]*$', reg_phone) == None):
+                errors.append('Phone number may contain only numbers.')
             #if (re.search(r'^\w+$', reg_site_authority) == None):
             #    errors.append('Site Authority may contain only letters or numbers.')
             # checking in django_db !!
@@ -106,29 +122,26 @@ class JoinView (FreeAccessView, ThemeView):
                     errors.append('Email already registered in Manifold. Please provide a new email address.')
 
 # XXX TODO: Factorize with portal/accountview.py
+# XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/joinview.py
 #            if 'generate' in request.POST['question']:
             from Crypto.PublicKey import RSA
             private = RSA.generate(1024)
-            private_key = json.dumps(private.exportKey())
-            public  = private.publickey()
-            public_key = json.dumps(public.exportKey(format='OpenSSH'))
-
+            private_key = private.exportKey()
+            public_key = private.publickey().exportKey(format='OpenSSH')
             # Saving to DB
-            account_config = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + ', "user_hrn":"'+ user_hrn + '"}'
             auth_type = 'managed'
-            public_key = public_key.replace('"', '');
-            private_key = private_key.replace('"', '');
 
             if not errors:
                 reg_password = request.POST['pi_password']
                 a = PendingAuthority(
                     site_name             = reg_site_name,             
-                    site_authority        = 'onelab.' + reg_site_abbreviated_name
+                    site_authority        = reg_auth
                     site_abbreviated_name = reg_site_abbreviated_name, 
                     site_url              = reg_site_url,
                     site_latitude         = reg_site_latitude, 
                     site_longitude        = reg_site_longitude,
-                    address_line1         = reg_address_line1,
+                    address_line1         = reg_email, # XXX field name must be renamed. Email needed 4 rejection email.
                     address_line2         = reg_address_line2,
                     address_line3         = reg_address_line3,
                     address_city          = reg_address_city,
@@ -140,23 +153,33 @@ class JoinView (FreeAccessView, ThemeView):
                 a.save()
  
                 reg_password = request.POST['pi_password']
-                b = PendingUser(
-                    first_name    = reg_fname, 
-                    last_name     = reg_lname, 
-                    authority_hrn = reg_auth,
-                    email         = reg_email, 
-                    password      = reg_password,
-                    public_key    = public_key,
-                    private_key   = private_key,
-                    user_hrn      = user_hrn,  
-                    pi            = reg_auth,
-                    email_hash    = '',
-                    status        = 'True',
-                )
-                b.save()
+                salt = randint(1,100000)
+                # get the domain url
+                current_site = Site.objects.get_current()
+                current_site = current_site.domain
 
+                email_hash = md5(str(salt)+reg_email).hexdigest()
+                user_request = {
+                    'first_name'    : reg_fname,
+                    'last_name'     : reg_lname,
+                    'organization'  : reg_site_name,
+                    'authority_hrn' : reg_auth,
+                    'email'         : reg_email,
+                    'password'      : reg_password,
+                    'public_key'    : public_key,
+                    'private_key'   : private_key,
+                    'current_site'  : current_site,
+                    'email_hash'    : email_hash,
+                    'user_hrn'      : user_hrn,
+                    'pi'            : [reg_auth],
+                    'auth_type'     : 'managed',
+                    'validation_link': 'http://' + current_site + '/portal/email_activation/'+ email_hash
+                }
+
+                
+                create_pending_user(request, user_request, user_detail)
                 # saves the user to django auth_user table [needed for password reset]
-                user = User.objects.create_user(reg_email, reg_email, reg_password)
+                #user = User.objects.create_user(reg_email, reg_email, reg_password)
 
                 #creating user to manifold local:user
                 #user_config = '{"first_name":"'+ reg_fname + '", "last_name":"'+ reg_lname + '", "authority_hrn":"'+ reg_auth + '"}'
@@ -174,14 +197,7 @@ class JoinView (FreeAccessView, ThemeView):
                         'authority_hrn'         : reg_root_authority_hrn + '.' + reg_site_authority,
                         'site_abbreviated_name' : reg_site_abbreviated_name, 
                         'site_url'              : reg_site_url,
-                        'site_latitude'         : reg_site_latitude, 
-                        'site_longitude'        : reg_site_longitude,
-                        'address_line1'         : reg_address_line1,
-                        'address_line2'         : reg_address_line2,
-                        'address_line3'         : reg_address_line3,
                         'address_city'          : reg_address_city,
-                        'address_postalcode'    : reg_address_postalcode,
-                        'address_state'         : reg_address_state,
                         'address_country'       : reg_address_country,
                         'first_name'            : reg_fname, 
                         'last_name'             : reg_lname, 
@@ -190,34 +206,36 @@ class JoinView (FreeAccessView, ThemeView):
                         'user_hrn'              : user_hrn,
                         'public_key'            : public_key,
                         }
-                    recipients = authority_get_pi_emails(request,reg_auth)
+
+                    #recipients = authority_get_pi_emails(request,reg_auth)
                     
-                    # We don't need to send this email to user.
-                    # it's for the PI only
-                    #if ctx['cc_myself']:
-                    #    recipients.append(ctx['email'])
-                    theme.template_name = 'authority_request_email.html'
-                    html_content = render_to_string(theme.template, ctx)
+                    self.template_name = 'authority_request_email.html'
+                    html_content = render_to_string(self.template, ctx)
             
-                    theme.template_name = 'authority_request_email.txt'
-                    text_content = render_to_string(theme.template, ctx)
+                    self.template_name = 'authority_request_email.txt'
+                    text_content = render_to_string(self.template, ctx)
             
-                    theme.template_name = 'authority_request_email_subject.txt'
-                    subject = render_to_string(theme.template, ctx)
+                    self.template_name = 'authority_request_email_subject.txt'
+                    subject = render_to_string(self.template, ctx)
                     subject = subject.replace('\n', '')
             
-                    theme.template_name = 'email_default_sender.txt'
-                    sender =  render_to_string(theme.template, ctx)
-                    sender = sender.replace('\n', '')
-            
-                    msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
+                    #theme.template_name = 'email_default_sender.txt'
+                    #sender =  render_to_string(theme.template, ctx)
+                    #sender = sender.replace('\n', '')
+                    sender = reg_email
+                    
+                    msg = EmailMultiAlternatives(subject, text_content, sender, ['support@onelab.eu'])
                     msg.attach_alternative(html_content, "text/html")
                     msg.send()
     
                 except Exception, e:
                     print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
-                
+                    import traceback
+                    traceback.print_exc()
+
                 self.template_name = 'join_complete.html'
+                # log institution activity
+                activity.institution.joined(self.request)
                 return render(request, self.template, {'theme': self.theme})
                 #return render(request, 'user_register_complete.html') 
 
@@ -248,4 +266,6 @@ class JoinView (FreeAccessView, ThemeView):
           'theme': self.theme
           }
         template_env.update(page.prelude_env ())
+        # log institution activity
+        activity.institution.join(self.request)
         return render(request, 'join_view.html',template_env)
diff --git a/portal/managementtababout.py b/portal/managementtababout.py
new file mode 100644 (file)
index 0000000..8bd1cdc
--- /dev/null
@@ -0,0 +1,53 @@
+# this somehow is not used anymore - should it not be ?
+from django.core.context_processors import csrf
+from django.http import HttpResponseRedirect
+from django.contrib.auth import authenticate, login, logout
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from django.shortcuts import render
+
+from unfold.loginrequired import FreeAccessView
+
+from manifold.core.query            import Query
+from manifoldapi.manifoldapi        import execute_query
+from manifoldapi.manifoldresult import ManifoldResult
+from myslice.configengine import ConfigEngine
+
+from myslice.theme import ThemeView
+import json
+
+class ManagementAboutView (FreeAccessView, ThemeView):
+    template_name = 'management-tab-about.html'
+
+    def get (self, request):
+        
+        if request.user.is_authenticated(): 
+            user_query  = Query().get('user').select('user_hrn','parent_authority').filter_by('user_hrn','==','$user_hrn')
+            user_details = execute_query(self.request, user_query)
+            
+            user_local_query  = Query().get('local:user').select('config').filter_by('email','==',str(self.request.user))
+            user_local_details = execute_query(self.request, user_local_query)
+            user_authority = json.loads(user_local_details[0]['config']).get('authority')
+            # XXX Should be done using Metadata
+            # select column.name from local:object where table=='authority'
+            authority_query = Query().get('authority').select('authority_hrn', 'name', 'address', 'enabled','description', 
+                                                              'scientific', 'city', 'name', 'url', 'country', 'enabled', 'longitude', 
+                                                              'tech', 'latitude', 'pi_users', 'parent_authority', 'onelab_membership', 
+                                                              'postcode').filter_by('authority_hrn','==',user_authority)
+            authority_details = execute_query(self.request, authority_query)
+            
+            if authority_details :
+                authority_contacts = {}
+                authority = authority_details[0]
+                if 'scientific' in authority and authority['scientific'] is not None:
+                    authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority['scientific'][1:-1].split(',') ]
+                if 'technical' in authority and authority['technical'] is not None:
+                    authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority['tech'][1:-1].split(',') ]
+                if 'legal' in authority and authority['legal'] is not None:
+                    authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority['legal'][1:-1].split(',') ]
+            else :
+                authority_contacts = None
+                authority = None
+            
+        return render_to_response(self.template, { 'theme' : self.theme, 'authority' : authority, 'authority_contacts' : authority_contacts }, context_instance=RequestContext(request))
+
index 50801e9..31cbb0d 100644 (file)
@@ -7,13 +7,13 @@ from manifoldapi.manifoldapi         import execute_query
 from django.views.generic.base      import TemplateView
 
 from unfold.loginrequired           import LoginRequiredView
-from django.http import HttpResponse
-from django.shortcuts import render
+from django.http                    import HttpResponse
+from django.shortcuts               import render
 
-from manifold.core.query             import Query, AnalyzedQuery
-from manifoldapi.manifoldapi         import execute_query
+from manifold.core.query            import Query, AnalyzedQuery
+from manifoldapi.manifoldapi        import execute_query
 
-from portal.actions             import get_requests
+from portal.actions                 import get_requests
 
 from myslice.theme import ThemeView
 
@@ -133,8 +133,9 @@ class ManagementRequestsView (LoginRequiredView, ThemeView):
                 if auth_hrn in pi_expired_credential_authorities:
                     r['allowed'] = 'expired'
                 if 'allowed' not in r:
-                    r['allowed'] = 'denied'
-
+                    ## TEMP FIX for allowing new authority registration
+                    #r['allowed'] = 'denied'
+                    r['allowed'] = 'allowed'
 
                 if not auth_hrn in dest:
                     dest[auth_hrn] = []
@@ -157,8 +158,8 @@ class ManagementRequestsView (LoginRequiredView, ThemeView):
 #         env['section'] = "Requests"
         
         context = super(ManagementRequestsView, self).get_context_data(**kwargs)
-        print "testing"
-        print ctx_my_authorities
+        
+            
         context['my_authorities']   = ctx_my_authorities
         context['sub_authorities']   = ctx_sub_authorities
         context['delegation_authorities'] = ctx_delegation_authorities
index 7687d34..52a69da 100644 (file)
@@ -24,8 +24,8 @@ class UserView(LoginRequiredAutoLogoutView, ThemeView):
     def get_context_data(self, **kwargs):
 
         page = Page(self.request)
-        page.add_js_files  ( [ "js/jquery.validate.js", "js/my_account.register.js", "js/my_account.edit_profile.js" ] )
-        page.add_css_files ( [ "css/onelab.css", "css/account_view.css","css/plugin.css" ] )
+        page.add_js_files  ( [ "js/jquery.validate.js", "js/my_account.register.js", "js/my_account.edit_profile.js", "js/jquery-ui.js" ] )
+        page.add_css_files ( [ "css/onelab.css", "css/account_view.css","css/plugin.css","css/jquery-ui.css" ] )
 
         for key, value in kwargs.iteritems():
             #print "%s = %s" % (key, value)
@@ -399,7 +399,7 @@ def user_process(request, **kwargs):
                             return HttpResponseRedirect(redirect_url)
         else:
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
-            return HttpResponseRedirect("/portal/account/")
+            return HttpResponseRedirect(redirect_url)
 
     elif 'dl_pubkey' in request.POST:
         for account_detail in account_details:
@@ -433,7 +433,7 @@ def user_process(request, **kwargs):
 
         else:
             messages.error(request, 'Account error: You need an account in myslice platform to perform this action')
-            return HttpResponseRedirect("/portal/account/")
+            return HttpResponseRedirect(redirect_url)
     
 #    elif 'delete' in request.POST:
 #        for account_detail in account_details:
@@ -476,7 +476,7 @@ def user_process(request, **kwargs):
                             user_params = { 'config': updated_config}
                             manifold_update_account(request, user_id,user_params)
                             messages.success(request, 'All Credentials cleared')
-                            return HttpResponseRedirect("/portal/account/")
+                            return HttpResponseRedirect(redirect_url)
                         else:
                             messages.error(request, 'Delete error: Credentials are not stored in the server')
                             return HttpResponseRedirect(redirect_url)
diff --git a/portal/manualdelegationview.py b/portal/manualdelegationview.py
new file mode 100644 (file)
index 0000000..3560a92
--- /dev/null
@@ -0,0 +1,23 @@
+# this somehow is not used anymore - should it not be ?
+from django.core.context_processors import csrf
+from django.http import HttpResponseRedirect
+from django.contrib.auth import authenticate, login, logout
+from django.template import RequestContext
+from django.shortcuts import render_to_response
+from django.shortcuts import render
+
+from unfold.loginrequired import FreeAccessView
+
+from manifoldapi.manifoldresult import ManifoldResult
+from ui.topmenu import topmenu_items, the_user
+from myslice.configengine import ConfigEngine
+
+from myslice.theme import ThemeView
+
+class ManualDelegationView (FreeAccessView, ThemeView):
+    template_name = 'manual-delegation.html'
+
+    def get (self, request, state=None):
+        
+        return render_to_response(self.template, { 'theme' : self.theme }, context_instance=RequestContext(request))
+
diff --git a/portal/migrations/0009_initial.py b/portal/migrations/0009_initial.py
new file mode 100644 (file)
index 0000000..4e7e20a
--- /dev/null
@@ -0,0 +1,141 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Adding model 'Institution'
+        db.create_table(u'portal_institution', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('name', self.gf('django.db.models.fields.TextField')()),
+        ))
+        db.send_create_signal(u'portal', ['Institution'])
+
+        # Adding model 'PendingUser'
+        db.create_table(u'portal_pendinguser', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('first_name', self.gf('django.db.models.fields.TextField')()),
+            ('last_name', self.gf('django.db.models.fields.TextField')()),
+            ('email', self.gf('django.db.models.fields.EmailField')(max_length=75)),
+            ('password', self.gf('django.db.models.fields.TextField')()),
+            ('user_hrn', self.gf('django.db.models.fields.TextField')()),
+            ('public_key', self.gf('django.db.models.fields.TextField')()),
+            ('private_key', self.gf('django.db.models.fields.TextField')()),
+            ('authority_hrn', self.gf('django.db.models.fields.TextField')()),
+            ('login', self.gf('django.db.models.fields.TextField')()),
+            ('pi', self.gf('django.db.models.fields.TextField')()),
+            ('email_hash', self.gf('django.db.models.fields.TextField')()),
+            ('status', self.gf('django.db.models.fields.TextField')()),
+            ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+        ))
+        db.send_create_signal(u'portal', ['PendingUser'])
+
+        # Adding model 'PendingAuthority'
+        db.create_table(u'portal_pendingauthority', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('site_name', self.gf('django.db.models.fields.TextField')()),
+            ('site_authority', self.gf('django.db.models.fields.TextField')()),
+            ('site_abbreviated_name', self.gf('django.db.models.fields.TextField')()),
+            ('site_url', self.gf('django.db.models.fields.TextField')()),
+            ('site_latitude', self.gf('django.db.models.fields.TextField')()),
+            ('site_longitude', self.gf('django.db.models.fields.TextField')()),
+            ('address_line1', self.gf('django.db.models.fields.TextField')()),
+            ('address_line2', self.gf('django.db.models.fields.TextField')()),
+            ('address_line3', self.gf('django.db.models.fields.TextField')()),
+            ('address_city', self.gf('django.db.models.fields.TextField')()),
+            ('address_postalcode', self.gf('django.db.models.fields.TextField')()),
+            ('address_state', self.gf('django.db.models.fields.TextField')()),
+            ('address_country', self.gf('django.db.models.fields.TextField')()),
+            ('authority_hrn', self.gf('django.db.models.fields.TextField')()),
+            ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+        ))
+        db.send_create_signal(u'portal', ['PendingAuthority'])
+
+        # Adding model 'PendingSlice'
+        db.create_table(u'portal_pendingslice', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('slice_name', self.gf('django.db.models.fields.TextField')()),
+            ('user_hrn', self.gf('django.db.models.fields.TextField')()),
+            ('authority_hrn', self.gf('django.db.models.fields.TextField')(null=True)),
+            ('number_of_nodes', self.gf('django.db.models.fields.TextField')(default=0)),
+            ('type_of_nodes', self.gf('django.db.models.fields.TextField')(default='NA')),
+            ('purpose', self.gf('django.db.models.fields.TextField')(default='NA')),
+            ('created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+        ))
+        db.send_create_signal(u'portal', ['PendingSlice'])
+
+
+    def backwards(self, orm):
+        # Deleting model 'Institution'
+        db.delete_table(u'portal_institution')
+
+        # Deleting model 'PendingUser'
+        db.delete_table(u'portal_pendinguser')
+
+        # Deleting model 'PendingAuthority'
+        db.delete_table(u'portal_pendingauthority')
+
+        # Deleting model 'PendingSlice'
+        db.delete_table(u'portal_pendingslice')
+
+
+    models = {
+        u'portal.institution': {
+            'Meta': {'object_name': 'Institution'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.TextField', [], {})
+        },
+        u'portal.pendingauthority': {
+            'Meta': {'object_name': 'PendingAuthority'},
+            'address_city': ('django.db.models.fields.TextField', [], {}),
+            'address_country': ('django.db.models.fields.TextField', [], {}),
+            'address_line1': ('django.db.models.fields.TextField', [], {}),
+            'address_line2': ('django.db.models.fields.TextField', [], {}),
+            'address_line3': ('django.db.models.fields.TextField', [], {}),
+            'address_postalcode': ('django.db.models.fields.TextField', [], {}),
+            'address_state': ('django.db.models.fields.TextField', [], {}),
+            'authority_hrn': ('django.db.models.fields.TextField', [], {}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'site_abbreviated_name': ('django.db.models.fields.TextField', [], {}),
+            'site_authority': ('django.db.models.fields.TextField', [], {}),
+            'site_latitude': ('django.db.models.fields.TextField', [], {}),
+            'site_longitude': ('django.db.models.fields.TextField', [], {}),
+            'site_name': ('django.db.models.fields.TextField', [], {}),
+            'site_url': ('django.db.models.fields.TextField', [], {})
+        },
+        u'portal.pendingslice': {
+            'Meta': {'object_name': 'PendingSlice'},
+            'authority_hrn': ('django.db.models.fields.TextField', [], {'null': 'True'}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'number_of_nodes': ('django.db.models.fields.TextField', [], {'default': '0'}),
+            'purpose': ('django.db.models.fields.TextField', [], {'default': "'NA'"}),
+            'slice_name': ('django.db.models.fields.TextField', [], {}),
+            'type_of_nodes': ('django.db.models.fields.TextField', [], {'default': "'NA'"}),
+            'user_hrn': ('django.db.models.fields.TextField', [], {})
+        },
+        u'portal.pendinguser': {
+            'Meta': {'object_name': 'PendingUser'},
+            'authority_hrn': ('django.db.models.fields.TextField', [], {}),
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75'}),
+            'email_hash': ('django.db.models.fields.TextField', [], {}),
+            'first_name': ('django.db.models.fields.TextField', [], {}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'last_name': ('django.db.models.fields.TextField', [], {}),
+            'login': ('django.db.models.fields.TextField', [], {}),
+            'password': ('django.db.models.fields.TextField', [], {}),
+            'pi': ('django.db.models.fields.TextField', [], {}),
+            'private_key': ('django.db.models.fields.TextField', [], {}),
+            'public_key': ('django.db.models.fields.TextField', [], {}),
+            'status': ('django.db.models.fields.TextField', [], {}),
+            'user_hrn': ('django.db.models.fields.TextField', [], {})
+        }
+    }
+
+    complete_apps = ['portal']
\ No newline at end of file
diff --git a/portal/platform.py b/portal/platform.py
new file mode 100644 (file)
index 0000000..f224056
--- /dev/null
@@ -0,0 +1,21 @@
+from manifold.core.query                import Query
+from manifoldapi.manifoldapi            import execute_query
+
+class Platform:
+    def __init__ (self, id = None, name = None):
+        if id is not None:
+            platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled').filter_by('platform_id', '==', platform_id)
+        if name is not None:
+            platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled').filter_by('platform', '==', platform)
+        self.id       = platform_query['platform_id']
+        self.name     = platform_query['platform']
+        self.type     = platform_query['gateway_type']
+        self.disabled = platform_query['disabled']
+
+#class Platforms:
+#    def __init__ (self):
+#        platforms_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
+#        platforms_details = execute_query(self.request, platform_query)
+#        for platform_detail in platforms_details:
+#            Platform(id = platform_detail['platform_id'])
index 6a8322d..e55e30f 100644 (file)
@@ -5,6 +5,7 @@ from hashlib    import md5
 
 from django.views.generic       import View
 from django.template.loader     import render_to_string
+
 from django.shortcuts           import render
 from django.contrib.auth        import get_user_model
 from django.contrib.sites.models import Site
@@ -21,6 +22,8 @@ from portal.actions             import create_pending_user
 
 from myslice.theme import ThemeView
 
+import activity.user
+
 # since we inherit from FreeAccessView we cannot redefine 'dispatch'
 # so let's override 'get' and 'post' instead
 #
@@ -37,18 +40,19 @@ class RegistrationView (FreeAccessView, ThemeView):
         """
         """
         errors = []
-
+        authority_hrn = None
         authorities_query = Query.get('authority').select('name', 'authority_hrn')
         authorities = execute_admin_query(wsgi_request, authorities_query)
         if authorities is not None:
             authorities = sorted(authorities)
         
+        print "############ BREAKPOINT 1 #################"
         # Page rendering
         page = Page(wsgi_request)
         page.add_js_files  ( [ "js/jquery.validate.js", "js/my_account.register.js", "js/jquery.qtip.min.js","js/jquery-ui.js" ] )
         page.add_css_files ( [ "css/onelab.css", "css/registration.css", "css/jquery.qtip.min.css" ] )
         page.add_css_files ( [ "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" ] )
-
+        print "############ BREAKPOINT 2 #################"
         if method == 'POST':
             reg_form = {}
             # The form has been submitted
@@ -56,14 +60,19 @@ class RegistrationView (FreeAccessView, ThemeView):
             # get the domain url
             current_site = Site.objects.get_current()
             current_site = current_site.domain
-
-            authorities_query = Query.get('authority').select('name', 'authority_hrn')
-            authorities = execute_admin_query(wsgi_request, authorities_query)
-    
+            
+            print "############ BREAKPOINT 3 #################"
+            
             for authority in authorities:
                 if authority['name'] == wsgi_request.POST.get('org_name', ''):
                     authority_hrn = authority['authority_hrn']     
 
+            # Handle the case when the template uses only hrn and not name
+            if authority_hrn is None:
+                authority_hrn = wsgi_request.POST.get('org_name', '')
+            
+            print "############ BREAKPOINT 4 #################"
+            
             post_email = wsgi_request.POST.get('email','').lower()
             salt = randint(1,100000)
             email_hash = md5(str(salt)+post_email).hexdigest()
@@ -77,32 +86,33 @@ class RegistrationView (FreeAccessView, ThemeView):
                 'password'      : wsgi_request.POST.get('password',      ''),
                 'current_site'  : current_site,
                 'email_hash'    : email_hash,
+                'pi'            : '',
                 'validation_link': 'http://' + current_site + '/portal/email_activation/'+ email_hash
             }
-
+            
+            print "############ BREAKPOINT 5 #################"
+            
             # Construct user_hrn from email (XXX Should use common code)
             split_email = user_request['email'].split("@")[0] 
             split_email = split_email.replace(".", "_")
+            # Replace + by _ => more convenient for testing and validate with a real email
+            split_email = split_email.replace("+", "_")
             user_request['user_hrn'] = user_request['authority_hrn'] \
                      + '.' + split_email
             
             # Validate input
             UserModel = get_user_model()
             if (re.search(r'^[\w+\s.@+-]+$', user_request['first_name']) == None):
-                errors.append('First Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
+                errors.append('First name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
             if (re.search(r'^[\w+\s.@+-]+$', user_request['last_name']) == None):
-                errors.append('Last Name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
-            # checking in django_db !!
-            if PendingUser.objects.filter(email__iexact = user_request['email']):
-                errors.append('Email is pending for validation. Please provide a new email address.')
-            if UserModel._default_manager.filter(email__iexact = user_request['email']): 
-                errors.append('This email is not usable. Please contact the administrator or try with another email.')
+                errors.append('Last name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
             # Does the user exist in Manifold?
             user_query  = Query().get('local:user').select('user_id','email')
             user_details = execute_admin_query(wsgi_request, user_query)
             for user_detail in user_details:
                 if user_detail['email'] == user_request['email']:
-                    errors.append('Email already registered in Manifold. Please provide a new email address.')
+                    errors.append('Email already registered. <a href="/">Login</a> with your existing account. <a href="/portal/pass_reset/">Forgot your password?</a>')
+
             # Does the user exist in sfa? [query is very slow!!]
             #user_query  = Query().get('user').select('user_hrn','user_email')
             # XXX Test based on the user_hrn is quick
@@ -111,13 +121,27 @@ class RegistrationView (FreeAccessView, ThemeView):
 
             for user in user_details_sfa:
                 if user['user_email'] == user_request['email']:
-                    errors.append('Email already registered in SFA registry. Please use another email.')
+                    errors.append('Email already registered in OneLab registry. <a href="/contact">Contact OneLab support</a> or use another email.')
                 if user['user_hrn'] == user_request['user_hrn']:
                     # add random number if user_hrn already exists in the registry
                     user_request['user_hrn'] = user_request['authority_hrn'] \
                             + '.' + split_email + str(randint(1,1000000))
-                
+
+            # checking in django unfold db portal application pending users
+            # sqlite3 /var/unfold/unfold.sqlite3
+            # select email from portal_pendinguser;
+            if PendingUser.objects.filter(email__iexact = user_request['email']):
+                errors.append('Account pending for validation. Please wait till your account is validated or contact OneLab support.')
+
+            # checking in django_db !!
+            # sqlite3 /var/unfold/unfold.sqlite3
+            # select email from auth_user;
+            if UserModel._default_manager.filter(email__iexact = user_request['email']): 
+                errors.append('<a href="/contact">Contact OneLab support</a> or try with another email.')
+
             # XXX TODO: Factorize with portal/accountview.py
+            # XXX TODO: Factorize with portal/registrationview.py
+            # XXX TODO: Factorize with portal/joinview.py
             if 'generate' in wsgi_request.POST['question']:
                 user_request['auth_type'] = 'managed'
 
@@ -142,16 +166,19 @@ class RegistrationView (FreeAccessView, ThemeView):
                 ALLOWED_EXTENSIONS =  ['.pub','.txt']
                 if file_extension not in ALLOWED_EXTENSIONS or not re.search(r'ssh-rsa',file_content):
                     errors.append('Please upload a valid RSA public key.')
-
-                user_request['private_key'] = None
+                # user_request['private_key'] can't be Null because all db fields are set as NOT NULL
+                user_request['private_key'] = ""
                 user_request['public_key']  = file_content
                 
             if not errors:
                 create_pending_user(wsgi_request, user_request, user_detail)
                 self.template_name = 'user_register_complete.html'
+                # log user activity
+                activity.user.registered(self.request)
                 return render(wsgi_request, self.template, {'theme': self.theme}) 
 
         else:
+            print "############ BREAKPOINT A #################"
             user_request = {}
             ## this is coming from onelab website onelab.eu
             reg_form = {
@@ -159,6 +186,9 @@ class RegistrationView (FreeAccessView, ThemeView):
                 'last_name': wsgi_request.GET.get('last_name', ''),
                 'email': wsgi_request.GET.get('email', ''),
                 }
+            # log user activity
+            activity.user.signup(self.request)
+            print "############ BREAKPOINT B #################"
 
         template_env = {
           'topmenu_items': topmenu_items_live('Register', page),
@@ -169,4 +199,5 @@ class RegistrationView (FreeAccessView, ThemeView):
         template_env.update(user_request)
         template_env.update(reg_form)
         template_env.update(page.prelude_env ())
+        print "############ BREAKPOINT C #################"
         return render(wsgi_request, self.template,template_env)
diff --git a/portal/reputationview.py b/portal/reputationview.py
new file mode 100644 (file)
index 0000000..40f8506
--- /dev/null
@@ -0,0 +1,300 @@
+from django.contrib.auth        import authenticate, login, logout\r
+from django.template            import RequestContext\r
+from django.shortcuts           import render, render_to_response\r
+\r
+from manifoldapi.manifoldresult import ManifoldResult\r
+from ui.topmenu                 import topmenu_items, the_user\r
+from myslice.configengine       import ConfigEngine\r
+from manifold.core.query        import Query\r
+from unfold.page                import Page\r
+from manifoldapi.manifoldapi    import execute_admin_query, execute_query\r
+from unfold.loginrequired       import LoginRequiredAutoLogoutView\r
+\r
+from myslice.theme import ThemeView\r
+import json\r
+import hashlib\r
+import datetime\r
+import urllib2\r
+import ast\r
+from django.views.decorators.csrf import csrf_exempt\r
+from django.http                  import *\r
+\r
+def response_mimetype(request):\r
+        \r
+    if "application/json" in request.META['HTTP_ACCEPT']:\r
+        return "application/json"\r
+    else:\r
+        return "text/plain"\r
+    \r
+\r
+def json_to_rest(url, data ):\r
+        \r
+    req = urllib2.Request(url)\r
+    req.add_header('Content-Type', 'application/json')\r
+    response = urllib2.urlopen(req, json.dumps(data))\r
+    \r
+    if data == "a":\r
+        mylist = ast.literal_eval(response.read())\r
+    else:\r
+        mylist = response.read().translate(None, '"[]').split(",")\r
+        \r
+    return (mylist)\r
+\r
+\r
+def unix_to_timestamp(timest):\r
+    try:\r
+        return datetime.datetime.fromtimestamp(int(timest)).strftime('%Y-%m-%d %H:%M:%S')\r
+    except:\r
+        return timest\r
+\r
+def timestamp_to_unix(timest):\r
+    try:\r
+        pass\r
+    except:\r
+        pass\r
+    \r
+    \r
+def slice_to_exp(slices_users):\r
+    experiments = {}\r
+    testbeds = {}\r
+    \r
+    \r
+    for slice in slices_users:\r
+        nodes={}\r
+        leases = slice['lease']\r
+        if leases is not None:\r
+            for lease in leases:\r
+                resource = lease['resource']\r
+                start_t = lease['start_time']\r
+                end_t = lease['end_time']\r
+                #node = lease['resource']\r
+                \r
+                testbed_start = resource.index('IDN+')+4\r
+                testbed_end = resource.index('+node+')\r
+                \r
+                testbed = resource[testbed_start:testbed_end]\r
+                node = resource[testbed_end+6:]\r
+                \r
+                if testbed in testbeds:\r
+                    if node not in testbeds[testbed]:\r
+                        testbeds[testbed].append(node)\r
+                else:\r
+                    testbeds[testbed] = [node]\r
+                \r
+                #group nodes in consecutive timeslots\r
+                if not node in nodes:       \r
+                    nodes[node]={str(start_t):{'start_t':start_t, 'nodes':node, 'end_t':end_t}}\r
+                else:\r
+                    if not str(start_t) in nodes[node]:\r
+                        f=0\r
+                        for n in nodes[node]:\r
+                            if n[str(end_t)] == start_t:\r
+                                n[str(end_t)] == end_t\r
+                                f=1\r
+                        if f==0:\r
+                            nodes[node][str(start_t)]={'start_t':start_t, 'nodes':node, 'end_t':end_t}\r
+                        \r
+        #group grouped nodes in experiments\r
+        for n in nodes:\r
+            for exp in nodes[n]:\r
+                key = str(exp) + str(nodes[n][exp]['end_t'])\r
+                \r
+                if key not in experiments:\r
+                    experiments[key]={'slice_hrn':slice['slice_hrn'], \\r
+                                      'start':nodes[n][exp]['start_t'], 'end':nodes[n][exp]['end_t'], 'nodes':[nodes[n][exp]['nodes']]}   \r
+                elif nodes[n][exp]['end_t'] == experiments[key]['end']:\r
+                    experiments[key]['nodes'].append(nodes[n][exp]['nodes'])\r
+                    \r
+    return (experiments,testbeds)\r
+   \r
+class ReputationView (LoginRequiredAutoLogoutView, ThemeView):\r
+    template_name = 'reputation.html'\r
+        \r
+    # expose this so we can mention the backend URL on the welcome page\r
+    def default_env (self):\r
+        return { \r
+                 'MANIFOLD_URL':ConfigEngine().manifold_url(),\r
+                 }\r
+\r
+    def post (self,request):\r
+        env = self.default_env()\r
+        env['theme'] = self.theme\r
+                \r
+        return render_to_response(self.template, env, context_instance=RequestContext(request))\r
+\r
+\r
+    \r
+    \r
+    def get (self, request, state=None):\r
+        env = self.default_env()\r
+                \r
+        #####    *** Reputation Plugin-specific START       ***     ############\r
+        #The following 'if' is a dirty way for bypassing the JS AJAX cross-domain prevention policy...not pretty\r
+        if request.GET.has_key(u'slicedata[user_eval][overall]'):\r
+            dict_to_send = {}\r
+            dict_to_send['eid'] = str(request.GET[u'slicedata[id]'])\r
+            dict_to_send['slice_hrn'] = str(request.GET[u'slicedata[slice_hrn]'])\r
+            dict_to_send['user_hrn'] = str(request.GET[u'slicedata[user_hrn]'])\r
+            dict_to_send['start_tunix'] = str(request.GET[u'slicedata[start_tunix]'])\r
+            dict_to_send['end_tunix'] = str(request.GET[u'slicedata[end_tunix]'])\r
+            dict_to_send['start_t'] = str(request.GET[u'slicedata[start_t]'])\r
+            dict_to_send['end_t'] = str(request.GET[u'slicedata[end_t]'])\r
+            dict_to_send['testbeds'] = ast.literal_eval(str(request.GET[u'testbeds']))\r
+            dict_to_send['user_eval'] = {}\r
+            dict_to_send['user_eval']['reuse'] = str(request.GET[u'slicedata[user_eval][reuse]'])\r
+            dict_to_send['user_eval']['availability'] = str(request.GET[u'slicedata[user_eval][availability]'])\r
+            dict_to_send['user_eval']['pay'] = str(request.GET[u'slicedata[user_eval][pay]'])\r
+            dict_to_send['user_eval']['support'] = str(request.GET[u'slicedata[user_eval][support]'])\r
+            dict_to_send['user_eval']['overall'] = str(request.GET[u'slicedata[user_eval][overall]'])\r
+            dict_to_send['user_eval']['link_quality'] = str(request.GET[u'slicedata[user_eval][link_quality]'])\r
+            dict_to_send['user_eval']['problems'] = str(request.GET[u'slicedata[user_eval][problems]'])\r
+            dict_to_send['user_eval']['quality'] = str(request.GET[u'slicedata[user_eval][quality]'])\r
+            \r
+            slicedata_received = json_to_rest('http://survivor.lab.netmode.ntua.gr:4567/reputation/json', dict_to_send )\r
+                        \r
+            return HttpResponse(json.dumps(slicedata_received), content_type = response_mimetype(self.request))\r
+\r
+                \r
+        slices_users = []\r
+        \r
+        #get slices\r
+        userslice_query = Query().get('slice').select('slice_urn', 'slice_hrn', 'users', 'resource', 'lease')\r
+        slice_details = execute_query(self.request, userslice_query)\r
+        \r
+        #get local users\r
+        local_user_query  = Query().get('local:user').select('email','status','config')\r
+        local_user_details = execute_admin_query(self.request, local_user_query)\r
+        \r
+        #get users - create dict[email]=hrn\r
+        user_query  = Query().get('user').select('user_hrn','user_urn','user_email')\r
+        user_details = execute_admin_query(self.request, user_query)\r
+        users_hrn = {}\r
+        for item in user_details:\r
+            users_hrn[item['user_email']] = item['user_hrn']\r
+        \r
+        #get currenct username (email)\r
+        if request.user.is_authenticated():\r
+            cur_username = request.user.username  \r
+        \r
+        #get a list of all the slices for the logged in user\r
+        testbeds = []\r
+\r
+        for slice in slice_details:\r
+            \r
+            if users_hrn[cur_username] in slice['users']:\r
+                slices_users.append({'slice_hrn':slice['slice_hrn'], 'user':cur_username, 'user_hrn':users_hrn[cur_username] \\r
+                                     , 'resource':slice['resource'], 'lease':slice['lease'] })  \r
+                \r
+                             \r
+        env['slices_users'] = slices_users  ### For logging\r
+       \r
+        #####create slicelist for template & JSON\r
+        experiments,testbeds =  slice_to_exp(slices_users)\r
+    \r
+        all_exp = []\r
+        iddata = []\r
+                          \r
+        for exp in experiments:\r
+            experiment = {}\r
+            experiment['slice_hrn'] = experiments[exp]['slice_hrn']\r
+            experiment['user_hrn'] = users_hrn[cur_username]\r
+            experiment['start_tunix'] = experiments[exp]['start']\r
+            experiment['end_tunix'] = experiments[exp]['end']\r
+            experiment['start_t'] = unix_to_timestamp(experiments[exp]['start'])\r
+            experiment['end_t'] = unix_to_timestamp(experiments[exp]['end'])\r
+            experiment['testbeds'] = {}\r
+            for exp_node in experiments[exp]['nodes']:\r
+                list_testbeds = [ key for key,val in testbeds.items()]\r
+                for tkey in list_testbeds:\r
+                    if exp_node in testbeds[tkey]:\r
+                        if tkey in experiment['testbeds']:\r
+                            if exp_node not in experiment['testbeds'][tkey]:\r
+                                experiment['testbeds'][tkey].append(exp_node)\r
+                        else:\r
+                            experiment['testbeds'][tkey] = [exp_node]\r
+            tempid = hashlib.sha1(str(experiment)).hexdigest()                    \r
+            experiment['id'] = tempid\r
+            \r
+            iddata.append(tempid)\r
+            all_exp.append(experiment)\r
+        \r
+        \r
+        ###### Check which experiments have not been rated yet. Pop from all_exp any experiment that has already been rated\r
+        unrated_exp = json_to_rest('http://survivor.lab.netmode.ntua.gr:4567/reputation/qid', iddata)    \r
+        \r
+        for item in all_exp:\r
+            if item['id'] in unrated_exp:\r
+                pass\r
+            else:\r
+                all_exp.pop(all_exp.index(item))\r
+\r
+\r
+\r
+        ###### Get Reputation values from Reputation DB\r
+        reps = json_to_rest('http://survivor.lab.netmode.ntua.gr:4567/reputation/showrep', "a")\r
+        #env['logging_test'] = reps    \r
+        \r
+        #create a services list and a dict containing the services for each testbed\r
+        serv_per_tb = {}\r
+        services = []\r
+        for item in reps:\r
+            serv_per_tb[item['testbed']]=[]\r
+            for serv in item['services']:\r
+                if serv.keys()[0] not in services:\r
+                    services.append(serv.keys()[0])\r
+                    serv_per_tb[item['testbed']].append(serv.keys()[0])        \r
+        \r
+        #in json, sevices are in the form: 'services':[{'serv1':x}, {'serv2':y}], so we transform it to 'services':[x,y] based on\r
+        # the services dict above. If for a specific service there is no applicable value, we put N/A            \r
+        for testbed in reps:\r
+            d = list(testbed['services'])\r
+            del testbed['services']\r
+            testbed['services'] = []\r
+            for s in services:\r
+                set_v = 0\r
+                for i in d:\r
+                    try:\r
+                        testbed['services'].append(i[s])\r
+                        set_v=1\r
+                    except:\r
+                        pass\r
+                if set_v == 0 :\r
+                    testbed['services'].append('N/A')\r
+                \r
+        ###### Pass variables to template\r
+        env['logging_test'] = json.dumps(all_exp, ensure_ascii=False)\r
+        env['serv_per_tb'] = json.dumps(serv_per_tb, ensure_ascii=False)\r
+        env['reputation'] = reps\r
+        env['rep_serv'] = services\r
+        env['slicelist'] = all_exp\r
+        env['json_data'] = json.dumps(all_exp, ensure_ascii=False)\r
+        \r
+        ######    *** Reputation Plugin-specific END       ***     ############\r
+        \r
+        \r
+        if request.user.is_authenticated(): \r
+            env['person'] = self.request.user\r
+        else: \r
+            env['person'] = None\r
+    \r
+        env['theme'] = self.theme\r
+        #env['user_list']= user_list\r
+\r
+        env['username']=the_user(request)\r
+        env['topmenu_items'] = topmenu_items(None, request)\r
+        if state: env['state'] = state\r
+        elif not env['username']: env['state'] = None\r
+        # use one or two columns for the layout - not logged in users will see the login prompt\r
+        env['layout_1_or_2']="layout-unfold2.html" if not env['username'] else "layout-unfold1.html"        \r
+        \r
+        return render_to_response(self.template, env, context_instance=RequestContext(request))\r
+    \r
+\r
+\r
+    \r
+\r
+                    \r
+                    \r
+                    \r
+                    \r
+            
\ No newline at end of file
index 8cd0af4..e6683bd 100644 (file)
@@ -7,14 +7,16 @@ from unfold.page                import Page
 from manifold.core.query        import Query
 from manifoldapi.manifoldapi    import execute_admin_query, execute_query
 
-from portal.actions             import is_pi, create_slice, create_pending_slice
+from portal.actions             import is_pi, create_slice, create_pending_slice, clear_user_creds
 #from portal.forms               import SliceRequestForm
 from unfold.loginrequired       import LoginRequiredAutoLogoutView
 from ui.topmenu                 import topmenu_items_live, the_user
 
 from myslice.theme import ThemeView
 
-import json, time
+import json, time, re
+
+import activity.user
 
 class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
     template_name = 'slicerequest_view.html'
@@ -31,7 +33,11 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
         """
         """
         errors = []
-
+        slice_name =''
+        purpose=''
+        url=''
+        authority_hrn = None
+        authority_name = None
         # Retrieve the list of authorities
         authorities_query = Query.get('authority').select('name', 'authority_hrn')
         authorities = execute_admin_query(wsgi_request, authorities_query)
@@ -51,6 +57,9 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
             if authority['authority_hrn'] == user_authority:
                 authority_name = authority['name']
 
+        # Handle the case when we use only hrn and not name
+        if authority_name is None:
+            authority_name = user_authority
         #
         account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
         account_details = execute_query(wsgi_request, account_query)
@@ -81,6 +90,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
         page = Page(wsgi_request)
         page.add_js_files  ( [ "js/jquery.validate.js", "js/jquery-ui.js" ] )
         page.add_css_files ( [ "https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" ] )
+        page.expose_js_metadata()
 
         if method == 'POST':
             # The form has been submitted
@@ -89,12 +99,14 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
             current_site = Site.objects.get_current()
             current_site = current_site.domain
             
-            # getting the authority_hrn from the selected organization           
+            # getting the authority_hrn from the selected organization
             for authority in authorities:
                 if authority['name'] == wsgi_request.POST.get('org_name', ''):
                     authority_hrn = authority['authority_hrn']
 
-            
+            # Handle the case when we use only hrn and not name
+            if authority_hrn is None:
+                authority_hrn = wsgi_request.POST.get('org_name', '')
 
             slice_request = {
                 'type'              : 'slice',
@@ -105,34 +117,55 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
                 'authority_hrn'     : authority_hrn,
                 'organization'      : wsgi_request.POST.get('org_name', ''),
                 'slice_name'        : wsgi_request.POST.get('slice_name', ''),
-                'number_of_nodes'   : wsgi_request.POST.get('number_of_nodes', ''),
+                'url'               : wsgi_request.POST.get('url', ''),
                 'purpose'           : wsgi_request.POST.get('purpose', ''),
                 'current_site'      : current_site
             }
             
-            authority_hrn = slice_request['authority_hrn']
-            if (authority_hrn is None or authority_hrn == ''):
-                errors.append('Please, select an authority')
+            # create slice_hrn based on authority_hrn and slice_name
+            slice_name = slice_request['slice_name']
+            req_slice_hrn = authority_hrn + '.' + slice_name
+            # comparing requested slice_hrn with the existing slice_hrn 
+            slice_query  = Query().get('slice').select('slice_hrn','parent_authority').filter_by('parent_authority','==',authority_hrn)
+            slice_details_sfa = execute_admin_query(wsgi_request, slice_query)
+            for _slice in slice_details_sfa:
+                if _slice['slice_hrn'] == req_slice_hrn:
+                    errors.append('Slice already exists. Please use a different slice name.')
+            
 
             # What kind of slice name is valid?
-            slice_name = slice_request['slice_name']
             if (slice_name is None or slice_name == ''):
-                errors.append('Slice Name is mandatory')
+                errors.append('Slice name is mandatory')
+            
+            if (re.search(r'^[A-Za-z0-9_]*$', slice_name) == None):
+                errors.append('Slice name may contain only letters, numbers, and underscore.')
+            
+            organization = slice_request['organization']    
+            if (organization is None or organization == ''):
+                errors.append('Organization is mandatory')
+
+
     
             purpose = slice_request['purpose']
             if (purpose is None or purpose == ''):
-                errors.append('Purpose is mandatory')
+                errors.append('Experiment purpose is mandatory')
+
+            url = slice_request['url']
 
             if not errors:
                 if is_pi(wsgi_request, user_hrn, authority_hrn):
                     # PIs can directly create slices in their own authority...
                     create_slice(wsgi_request, slice_request)
+                    clear_user_creds(wsgi_request, user_email)
                     self.template_name = 'slice-request-done-view.html'
                 else:
                     # Otherwise a wsgi_request is sent to the PI
                     create_pending_slice(wsgi_request, slice_request, user_email)
                     self.template_name = 'slice-request-ack-view.html'
                 
+                # log user activity
+                activity.user.slice(wsgi_request)
+                
                 return render(wsgi_request, self.template, {'theme': self.theme}) # Redirect after POST
         else:
             slice_request = {}
@@ -141,10 +174,14 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
             'username': wsgi_request.user.email,
             'topmenu_items': topmenu_items_live('Request a slice', page),
             'errors': errors,
+            'slice_name': slice_name,
+            'purpose': purpose,
             'email': user_email,
             'user_hrn': user_hrn,
+            'url': url,
             'pi': pi,
             'authority_name': authority_name,        
+            'authority_hrn': user_authority,        
             'cc_myself': True,
             'authorities': authorities,
             'theme': self.theme,
index 8289f9e..75ede2a 100644 (file)
@@ -1,8 +1,8 @@
 from django.template                    import RequestContext
 from django.shortcuts                   import render_to_response
 
-from manifold.core.query             import Query, AnalyzedQuery
-from manifoldapi.manifoldapi         import execute_query
+from manifold.core.query                import Query, AnalyzedQuery
+from manifoldapi.manifoldapi            import execute_query
 import json
 
 from django.views.generic.base          import TemplateView
@@ -22,6 +22,17 @@ from plugins.googlemap                  import GoogleMap
 from plugins.filter_status              import FilterStatusPlugin
 from plugins.testbeds                   import TestbedsPlugin
 from plugins.scheduler2                 import Scheduler2
+
+# Bristol plugin
+from plugins.univbris                   import Univbris
+from plugins.univbrisfoam               import UnivbrisFoam
+from plugins.univbrisfv                 import UnivbrisFv
+from plugins.univbrisfvf                import UnivbrisFvf
+from plugins.univbrisfvfo              import UnivbrisFvfo
+from plugins.univbristopo               import UnivbrisTopo
+from plugins.univbrisvtam                  import UnivbrisVtam as UnivbrisVtamPlugin
+from plugins.univbrisvtamform          import UnivbrisVtamForm
+
 from plugins.columns_editor             import ColumnsEditor
 from plugins.sladialog                  import SlaDialog
 from plugins.lists.simplelist           import SimpleList
@@ -52,14 +63,34 @@ class SliceResourceView (LoginRequiredView, ThemeView):
         # Example: select slice_hrn, resource.urn, lease.resource, lease.start_time, lease.end_time from slice where slice_hrn == "ple.upmc.myslicedemo"
         main_query = Query.get('slice').filter_by('slice_hrn', '=', slicename)
         main_query.select(
-                'slice_urn', # XXX We need the key otherwise the storage of records bugs !
+                # SLICE
                 'slice_hrn',
+                # - The record key is needed otherwise the storage of records
+                #   bugs !
+                'slice_urn',
+                # RESOURCES
+                'resource',
+                'lease',
                 'resource.urn',
                 'resource.hostname', 'resource.type',
-                'resource.network_hrn',
+                # - The facility_name and testbed_name are required for the
+                #   testbeds plugin to properly work.
+                'resource.facility_name', 
+                'resource.testbed_name',
+                # LEASES
                 'lease.resource',
                 'lease.start_time',
                 'lease.end_time',
+                # - The lease_id is important for NITOS identify already existing
+                #   leases
+                'lease.lease_id', 
+
+                # FLOWSPACE
+                #'flowspace',               
+                # VMS
+                #'vms',
+
+
                 #'user.user_hrn',
                 #'application.measurement_point.counter'
         )
@@ -70,16 +101,18 @@ class SliceResourceView (LoginRequiredView, ThemeView):
         page.enqueue_query(main_query, analyzed_query=aq)
         sq_resource    = aq.subquery('resource')
         sq_lease       = aq.subquery('lease')
+        #sq_flowspace   = aq.subquery('flowspace')
+        #sq_vms         = aq.subquery('vms')
 
         query_resource_all = Query.get('resource').select(resource_fields)
-        #page.enqueue_query(query_resource_all)
+        page.enqueue_query(query_resource_all)
 
         # leases query
-        lease_md = metadata.details_by_object('lease')
-        lease_fields = [column['name'] for column in lease_md['column']]
+        #lease_md = metadata.details_by_object('lease')
+        #lease_fields = [column['name'] for column in lease_md['column']]
 
-        query_lease_all = Query.get('lease').select(lease_fields)
-        page.enqueue_query(query_lease_all)
+        #query_lease_all = Query.get('lease').select(lease_fields)
+        #page.enqueue_query(query_lease_all)
 
         # --------------------------------------------------------------------------
         # ALL RESOURCES LIST
@@ -163,10 +196,11 @@ class SliceResourceView (LoginRequiredView, ThemeView):
             # the key to use at init-time
             init_key   = main_query_init_key,
             checkboxes = True,
-            # center on Paris
-            latitude   = 49.,
-            longitude  = 9,
-            zoom       = 8,
+            
+            # To center around Europe : 53,9 / 3
+            latitude   = 53.,
+            longitude  = 9.,
+            zoom       = 3,
         )
 
         # --------------------------------------------------------------------------
@@ -204,22 +238,22 @@ class SliceResourceView (LoginRequiredView, ThemeView):
         network_md = metadata.details_by_object('network')
         network_fields = [column['name'] for column in network_md['column']]
 
-        query_networks = Query.get('network').select(network_fields)
-        page.enqueue_query(query_networks)
+        #query_networks = Query.get('network').select(network_fields)
+        #page.enqueue_query(query_networks)
 
         filter_testbeds = TestbedsPlugin(
             page            = page,
             domid           = 'testbeds-filter',
             title           = 'Filter by testbeds',
             query           = sq_resource,
-            query_networks  = query_networks,
-            init_key        = "network_hrn",
-            checkboxes      = True,
-            datatables_options = {
-                'iDisplayLength': 25,
-                'bLengthChange' : True,
-                'bAutoWidth'    : True,
-                },
+            #query_networks  = query_networks,
+            #init_key        = "network_hrn",
+            #checkboxes      = True,
+            #datatables_options = {
+            #    'iDisplayLength': 25,
+            #    'bLengthChange' : True,
+            #    'bAutoWidth'    : True,
+            #    },
         )
 
         filter_status = FilterStatusPlugin(
@@ -234,27 +268,134 @@ class SliceResourceView (LoginRequiredView, ThemeView):
             username            = request.user,
         )
             
-
         # --------------------------------------------------------------------------
-        # SLA View and accept dialog
-        
-        sla_dialog = SlaDialog(
-            page                = page,
-            title               = 'sla dialog',
-            query               = main_query,
-            togglable           = False,
-            # start turned off, it will open up itself when stuff comes in
-            toggled             = True,
-            domid               = 'sla_dialog',
-            outline_complete    = True,
-            username            = request.user,
-        )
-        
+        # Ofelia OpenFlow Plugin 
+        # Bristol plugin
+
+       # plugin which display a "gathering resources" message 
+        # waiting for all resources to be returned by manifold
+       # univbriswelcome = Univbris(
+       #     page  = page,
+       #     title = 'univbris_welcome',
+       #     domid = 'univbris_welcome',
+       #     query = query_resource_all,
+       # )
+
+       # univbrisfoamlist = UnivbrisFoam(
+       #     page  = page,
+       #     title = 'univbris_foam_ports_selection',
+       #     domid = 'univbris_foam_ports_selection',
+       #     query = query_resource_all,
+       #     query_all = query_resource_all,
+       #     checkboxes = False,
+       #     datatables_options = {
+       #         'iDisplayLength': 10,
+       #         'bLengthChange' : True,
+       #         'bAutoWidth'    : True,
+       #         },
+       # )
+
+       # #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold
+       # univbrisfvlist = UnivbrisFv(
+       #         page  = page,
+       #         title = 'univbris_flowspace_selection',
+       #         domid = 'univbris_flowspace_selection',
+       #         query = sq_flowspace,
+       #         query_all = query_resource_all,
+       #         datatables_options = {
+       #             'iDisplayLength': 5,
+       #             'bLengthChange' : True,
+       #             'bAutoWidth'    : True,
+       #             },
+       # )
+
+       # #plugin which allows the definition of a single flowspace
+       # univbrisfvform = UnivbrisFvf(
+       #         page  = page,
+       #         title = 'univbris_flowspace_form',
+       #         domid = 'univbris_flowspace_form',
+       #         query = query_resource_all,
+       #         query_all = None,
+       #         datatables_options = {
+       #             'iDisplayLength': 3,
+       #             'bLengthChange' : True,
+       #             'bAutoWidth'    : True,
+       #             },
+       # )
+
+          # #plugin which allows the definition the match criteria on a single OPTICAL flowspace
+       # univbrisofvform = UnivbrisFvfo(
+       #     page  = page,
+       #     title = 'univbris_oflowspace_form',
+       #     domid = 'univbris_oflowspace_form',
+          #     query = None,
+       #     query_all = None,
+       #     datatables_options = { 
+       #         'iDisplayLength': 3,
+       #         'bLengthChange' : True,
+       #         'bAutoWidth'    : True,
+       #         },
+       # )
+
+       # #plugin which display the gathered topology
+       # univbristopology = UnivbrisTopo(
+       #     page  = page,
+       #     title = 'univbris_topology',
+       #     domid = 'univbris_topology',
+       #     query = query_resource_all,
+       # )
+
+       # # --------------------------------------------------------------------------
+       # # Ofelia VTAM Plugin 
+       # # Bristol Plugin
+
+       # #plugin which display a table where an experimenter will add VMs to according to his needs
+       # # responsible to send the data to Manifold
+       # univbrisvtamplugin = UnivbrisVtamPlugin(
+       #     page  = page,
+       #     title = 'univbris_vtam',
+       #     domid = 'univbris_vtam',
+       #     query = sq_vms,
+       #     #query = sq_resource,
+       # )
+
+       # #plugin which display a form where an experimenter will specify 
+       # # in which testbed and which physical server to setup the VM
+       # univbrisvtamform = UnivbrisVtamForm(
+       #     page  = page,
+       #     title = 'univbris_vtam_form',
+       #     domid = 'univbris_vtam_form',
+          #     query =  query_resource_all,
+       #     query_all = None,
+       #     datatables_options = { 
+       #         'iDisplayLength': 3,
+       #         'bLengthChange' : True,
+       #         'bAutoWidth'    : True,
+       #         },
+       # )
+
+       # # --------------------------------------------------------------------------
+       # # SLA View and accept dialog
+       # 
+       # sla_dialog = SlaDialog(
+       #     page                = page,
+       #     title               = 'sla dialog',
+       #     query               = main_query,
+       #     togglable           = False,
+       #     # start turned off, it will open up itself when stuff comes in
+       #     toggled             = True,
+       #     domid               = 'sla_dialog',
+       #     outline_complete    = True,
+       #     username            = request.user,
+       # )
+       # 
         ## check user is pi or not
         platform_query  = Query().get('local:platform').select('platform_id','platform','gateway_type','disabled')
         account_query  = Query().get('local:account').select('user_id','platform_id','auth_type','config')
         platform_details = execute_query(self.request, platform_query)
         account_details = execute_query(self.request, account_query)
+
+        # XXX When session has expired, this is None and thus not iterable
         for platform_detail in platform_details:
             for account_detail in account_details:
                 if platform_detail['platform_id'] == account_detail['platform_id']:
@@ -281,8 +422,19 @@ class SliceResourceView (LoginRequiredView, ThemeView):
 
         template_env['map_resources'] = map_resources.render(self.request)
         template_env['scheduler'] = resources_as_scheduler2.render(self.request)
+
+        # Bristol plugin
+       # template_env['welcome'] = univbriswelcome.render(self.request)
+       # template_env['resources'] = univbrisfoamlist.render(self.request)
+       # template_env['flowspaces'] = univbrisfvlist.render(self.request)
+       # template_env['oflowspaces_form'] = univbrisofvform.render(self.request)
+       # template_env['flowspaces_form'] = univbrisfvform.render(self.request)
+       # template_env['topology'] = univbristopology.render(self.request)
+       # template_env['vms_list'] = univbrisvtamplugin.render(self.request)
+       # template_env['vm_form'] = univbrisvtamform.render(self.request)
+
 #        template_env['pending_resources'] = pending_resources.render(self.request)
-        template_env['sla_dialog'] = '' # sla_dialog.render(self.request)
+       # template_env['sla_dialog'] = '' # sla_dialog.render(self.request)
         template_env["theme"] = self.theme
         template_env["username"] = request.user
         template_env["pi"] = pi
index cca8afb..023c206 100644 (file)
@@ -8,6 +8,8 @@ from django.shortcuts import render
 
 from unfold.loginrequired import FreeAccessView
 
+from manifold.core.query        import Query
+from manifoldapi.manifoldapi    import execute_query
 from manifoldapi.manifoldresult import ManifoldResult
 from ui.topmenu import topmenu_items, the_user
 from myslice.configengine import ConfigEngine
@@ -18,6 +20,29 @@ class ExperimentView (FreeAccessView, ThemeView):
     template_name = 'slice-tab-experiment.html'
 
     def get (self, request, slicename, state=None):
+  
+        username = self.request.user    
         
-        return render_to_response(self.template, { 'theme' : self.theme }, context_instance=RequestContext(request))
+        split_slicename = slicename.split('.')
+        ple_slicename = split_slicename[0] + '8' + split_slicename[1] + '_' + split_slicename[2]
+
+        query_current_resources = Query.get('slice').select('resource').filter_by('slice_hrn','==',slicename)
+        current_resources = execute_query(request, query_current_resources)
+
+        formatted_resource_list=[]
+        try:
+            for resources in current_resources:
+                list_res = resources['resource']
+                for res in list_res:
+                    split_list = res.split('+') # split the resource urn
+                    if [s for s in split_list if 'ple' in s]: # search only ple resources
+                        res_hrn = split_list[-1] # last element is resource hrn
+                        formatted_resource_list.append(res_hrn)
+        except Exception,e:
+            print "Exception in slicetabexperiment.py in ple resource search %s" % e
+        
+        print "list of ple resource hrns"
+        print formatted_resource_list
+
+        return render_to_response(self.template, { 'theme' : self.theme,'slicename':slicename, 'ple_slicename':ple_slicename, 'username':username, 'ple_resources':formatted_resource_list }, context_instance=RequestContext(request))
 
index cfdf432..bcb2950 100644 (file)
@@ -56,14 +56,14 @@ table.profile tr td.value {
 }
 
 table.profile button { 
-  width: 80px;
+  width: 100px;
   vertical-align: middle;
   float: right;
   margin-right: 15px;
 }
 
 #delete {
-  width: 80px;
+  width: 100px;
   vertical-align: middle;
   float: right;
   margin-right: 15px;
@@ -71,7 +71,7 @@ table.profile button {
 }
 
 #upload_key {
-  width: 80px;
+  width: 100px;
   vertical-align: middle;
   float: right; 
   margin-right: 15px;
@@ -123,7 +123,7 @@ table.profile form{
 
 #generate_keypair {
   position:relative;
-  width: 175px;
+  width: 215px;
   float: right;
   margin-right: 15px;
 
@@ -143,7 +143,7 @@ table.profile form{
 }
 
 .wide_button {
-  width: 175px;
+  width: 215px;
 }
 
 .api_cell {
index 411234b..190924e 100644 (file)
@@ -1,3 +1,5 @@
+@import url("../fonts/opensans_bold_macroman/stylesheet.css");
+
 html { height: 100% }
 
 body {
@@ -6,15 +8,32 @@ body {
     margin:0;
     padding:0;
     height: 100%;
+    letter-spacing:0.3px;
 }
 a, a:active, a:focus {
     outline: 0;
+    text-decoration:none;
+    color:#760073;
+}
+a:hover {
+    color:#0D0049;
 }
 
+a.current {
+    text-decoration:underline;
+    color:#333333;
+}
+p.command {
+    padding:15px;
+    margin:15px 0;
+    color:#890000;
+    background-color:#E0E0E0; 
+    font-family:Courier, monospace;
+}
 h1 {
     border-bottom:1px solid #DDDDDD;
     padding:0 0 0 0;
-    margin:0 0 0 0;
+    margin:15px 0 15px 0;
     font-size:14pt;
 }
 h1 img {
@@ -24,154 +43,177 @@ h1 img {
 }
 h2 {
     margin:0 0 15px 0;
-    font-size:13pt;
-    color:#0C0045;
+    font-size:14pt;
+    color:#333333;
 }
 h3 {
-    font-size:11pt;
+    margin:0 0 5px 0;
+    font-size:13pt;
     color:#201E62;
 }
-button {
-    font-size:11pt;
-}
-div.wrapper {
-    width:980px;
-    margin:0 auto;
-    position:relative;
+h4 {
+    margin:0 0 5px 0;
+    font-size:12pt;
+    color:#333333;
 }
-div.container {
-    width:980px;
-    margin:25px auto;
+span.subtitle {
+    color:#454545;
+    font-size:9pt;
+    font-weight:normal;
+    text-transform:uppercase;
 }
-div.wide {
-    margin:25px auto;
-    padding:0 25px;
+span.small {
+    font-size:9pt;
 }
-
-span.label {
-    font-size:11pt;
+span.gray {
     color:gray;
+}
+span.type {
+    color:#201E62;
+    font-weight:bold;
+    font-size:9pt;
+}
+span.htitle {
+    color:#454545;
+    font-size:9pt;
     font-weight:normal;
-    padding:0;
 }
-/***** Notifications *****/
-.warning {
-    border: 1px solid red;
-    margin: 20px 60px;
-    padding: 10px 20px;
-    color: red;
-    background-color: #f2dbdb;
-    text-align: center;
+span.version {
+    font-size:8pt;
+    color:#888888;
 }
-/* HEADER */
-div#header {
-    height:100px;
-    background-color:white;
+input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], select, option {
+    min-width:260px;
+    padding:6px;
+    border:1pt solid #22606D;
+    vertical-align:bottom;
+    border-radius:0;
 }
 
-div#secondary {
-    
+textarea {
+    padding:6px;
+    border:1pt solid #22606D !important;
+    border-radius:0 !important;
 }
 
-div#secondary ul {
-    position:absolute;
-    top:20px;
-    right:0;
+span.label {
+    font-size:11pt;
+    color:gray;
+    font-weight:normal;
+    padding:0;
 }
-
-div#secondary li {
+div.el {
+    padding-bottom:15px;
+}
+div.breadcrumbs {
+    margin:15px 0;
+    color:gray;
     font-size:10pt;
-    float:left;
-    list-style:none;
-    margin-right:30px;
 }
-div#secondary li a {
-    color:black;
+div.breadcrumbs a {
+    color:gray;
 }
-div#secondary li a:hover {
-    color:#270A5A;
-    text-decoration:none;
+div.breadcrumbs a:hover {
+    text-decoration:underline;
 }
-div#secondary li:last-child {
-    margin-right:0;
+.tab-pane {
+    padding-top:15px;
 }
-
-div#navigation {
-    background-color:black;
-    width:100%;
-    height:40px;
+/* buttons */
+button.btn, input.btn {
+    padding:6px 10px;
+    border-radius:5px;
+    font-size:10pt;
+    font-weight:normal;
 }
-div#navigation div.wrapper {
-    text-align:center;
+button.btn span.glyphicon {
+    margin-right:6px;
 }
-div#navigation ul {
-    margin:0;
-    padding:0;
-    display: inline-block;
-    list-style-type: none;
-    white-space: nowrap;
+button.btn-default {
+    border-bottom:3px solid #cccccc;
 }
-
-div#navigation li {
-    color:white;
-    font-family:helvetica, sans-serif;
-    font-size:10pt ;
-    font-weight:normal;
-    line-height:0.8em;
-    letter-spacing:0.6pt;
-    list-style:none;
-    float:left;
-    padding:0;
-    margin:15px 50px 0 0;
+button.btn-default:hover {
+    background-color:white;
+    border:1px solid #ADADAD;
+    border-bottom:3px solid #ADADAD;
 }
-div#navigation li a {
+button.btn-default:active {
+    background-color:white;
+    border:1px solid #ADADAD;
+    border-bottom:1px solid #ADADAD;
+    margin-top:2px;
+    box-shadow:none;
+}
+button.btn-primary {
+    border-bottom:3px solid #3071A9;
+}
+button.btn-primary:hover {
+    box-shadow:none;
+    background-color:#428bca;
+    border:1px solid #357ebd;
+    border-bottom:3px solid #3071A9;
+}
+button.btn-primary:active {
+    box-shadow:none;
+    border-bottom:1px solid #3071A9;
+    margin-top:2px;
+}
+button.btn-danger {
+    border-bottom:3px solid #A13F3A;
+}
+button.btn-danger:hover {
+    box-shadow:none;
+    background-color:#d9534f;
+    border:1px solid #d43f3a;
+    border-bottom:3px solid #A13F3A;
+}
+button.btn-danger:active {
+    border:1px solid #d43f3a;
+    box-shadow:none;
+    margin-top:2px;
+}
+button.btn-onelab, input.btn-onelab {
+    border:0;
+    border-bottom:3px solid #760073;
+    background-color:#302562;
     color:white;
 }
-div#navigation li a:hover {
-    text-decoration:none;
-    color:#B8B2FF;
+button.btn-onelab:hover, input.btn-onelab:hover {
+    border:0;
+    border-bottom:3px solid #760073;
+    background-color:#302562;
+    color:white;
 }
-div#navigation li:last-child {
-    margin-right:0;
+button.btn-onelab:active, input.btn-onelab:active {
+    box-shadow:none;
+    border-bottom:1px solid #760073;
+    margin-top:2px;
 }
 
-div#navigation li.active {
-       padding:5px;
-    padding-top: 15px;
-    min-height: 40px;
-    margin-top: 0px;
-       background-color:gray;
-       color:#FF0000;
-}
-div#navigation li.slices {
-    position:relative;
-    cursor:pointer;
+.container-resource button {
+    padding:2px 4px;
+    border-radius:3px;
+    font-size:9pt;
+    font-weight:normal;
 }
-div#navigation .dropdown-menu {
-    color:white;
-    padding:0 15px 15px 15px;
-    margin-top:5px;
-    margin-left:-16px;
-    background-color:black;
+.container-resource select,.container-resource option, .container-resource input {
+    padding:2px 4px;
+    font-size:9pt;
 }
-div#navigation .dropdown-menu a {
-    color:white;
+.badge {
+    font-size:9pt;
+    margin-left:4px;
 }
-
-div#menu-slice-list{
-    display:none;
-    position:absolute;
-    background-color:black;
-    padding:15px;
-    left:-15px;
-    z-index:10;
+/***** Notifications *****/
+.warning {
+    border: 1px solid red;
+    margin: 20px 60px;
+    padding: 10px 20px;
+    color: red;
+    background-color: #f2dbdb;
+    text-align: center;
 }
 
-div#navigation .dropdown-menu li:first-child {
-    border-bottom:1px solid white;
-    padding-bottom:5px;
-     
-}
 /* HOME DASHBOARD */
 div#home-dashboard {
     color:black;
@@ -245,24 +287,6 @@ div#home-dashboard div#home-slice-list li {
     
 }
 
-.login-submit {
-    vertical-align:middle;
-    padding:0;
-}
-.lost-password {
-    font-size:10pt;
-    color:#CCCCCC;
-    text-align:right;
-    padding:0px;
-}
-.lost-password a {
-}
-.login-signup {
-    border-top:1px solid #CCCCCC;
-    text-align:center;
-    margin-top:15px;
-    padding:5px 0 0 0;
-}
 /**/
 
 /**/
@@ -270,15 +294,6 @@ div#home-dashboard div#home-slice-list li {
 div.well {
 }
 /**/
-/* BUTTON */
-.btn.btn-default {
-    font-weight: bold;
-}
-
-.btn.btn-default:hover {
-    font-weight: bold;
-}
-/**/
 /* TABLE */
 table.table {
     margin:0;
@@ -327,26 +342,22 @@ div#ticket-request p {
     margin:20px 0;
 }
 
-ul.nav-tabs {}
+ul.nav-tabs {
+    margin:0 0 15px 0;
+}
 ul.nav-tabs ul {}
 ul.nav-tabs li {}
 
 ul.nav-section li a {
+    color:black;
     border-bottom:0;
 }
 ul.nav-section li:first-child {
     padding:0;
 }
 ul.nav-section li:first-child a {
-    font-weight:bold;
-    padding:6px 15px 4px 15px;
 }
 ul.nav-section li:first-child.active a {
-    padding:6px 15px 3px 15px;
-}
-ul.nav-section li:first-child img {
-    margin:0 4px 1px 0;
-    padding:0;
 }
 
 ul.nav-resources {
@@ -357,42 +368,82 @@ ul.nav-resources a {
 }
 
 /* SLICE VIEW */
-
-
+div.container-resource, div.container-slice {
+    padding-right:15px;
+    padding-left:15px;
+}
+.table th {
+    border-top:0 !important;
+}
 div#slice-view {
     margin:0;
 }
 div.list-group-item {
     border:0;
+    -moz-border-radius: 0;
+    border-radius: 0;
     background-color:white;
     font-weight:bold;
     padding-left:0;
 }
 a.list-group-item {
+    -moz-border-radius: 0;
+    border-radius: 0;
     border:0;
     background-color:white;
-    padding:3px 0 3px 10px;
+    padding:3px 2px 3px 10px;
     border-left:2pt white solid;
 }
-a.list-group-item.active, a.list-group-item.active:hover {
+a.list-group-item.active, a.list-group-item.active:hover, a.list-group-item.active:focus {
+    -moz-border-radius: 0;
+    border-radius: 0;
     font-weight: bold;
     color:black;
-    background-color:transparent;
+    background-color:#F5F5F5;
     border-left:2pt blue solid;
 }
-a.list-group-item.active:hover {
-    background-color:#dddddd;
-}
+
 a.list-group-item:hover {
+    -moz-border-radius: 0;
+    border-radius: 0;
     border-left:2pt blue solid;
 }
 a.list-group-item p.list-group-item-text {
+    -moz-border-radius: 0;
+    border-radius: 0;
     font-size:9pt;
     font-style:italic;
     font-weight: normal;
     color: black !important;
 }
 
+span.sl-resources {
+    font-size:9pt;
+    color:gray;
+}
+a.sl-resources, a.sl-resources:hover {
+    font-size:9pt;
+    border:0;
+    padding:2px 4px;
+    -moz-border-radius: 4px;
+    border-radius: 4px;
+    width:105px;
+    margin-left:4px;
+    margin-bottom:8px;
+    text-align: center;
+}
+a.sl-resources.active, a.sl-resources.active:hover, a.sl-resources.active:focus {
+    border:0;
+    -moz-border-radius: 4px;
+    border-radius: 4px;
+}
+a.sl-resources:first-child {
+    margin-left:12px;
+}
+button.btn-apply {
+    font-size:13px;
+    padding:2px 8px;
+}
 div#slice-info {
     margin-top:25px;
 }
@@ -471,6 +522,8 @@ div#slice-info td {
     padding:3px 5px;
 }
 .slice-pending button.apply {
+    font-size:14px;
+    padding:2px 5px;
 }
 .slice-pending button.clear {
 }
@@ -481,3 +534,287 @@ div.dataTables_filter label{
     float:left;
     width:400px;
 }
+
+/* HEADER */
+
+
+.header {
+  -moz-box-shadow:    0 0 1px rgba(82,82,82,0.6);
+  -webkit-box-shadow: 0 0 1px rgba(82,82,82,0.6);
+  box-shadow:         0 0 1px rgba(82,82,82,0.6);
+  height:61px;
+  background-color:white;
+}
+
+div.navigation {
+    
+}
+div.navigation ul {
+    margin:26px 0 0 0;
+    padding:0;
+    display: inline-block;
+    list-style-type: none;
+    white-space: nowrap;
+}
+
+div.navigation li {
+    color:#0C0047;
+    font-family:open_sansbold, sans-serif;
+    font-size:9pt;
+    font-weight:normal;
+    line-height:0.8em;
+    letter-spacing:0.4pt;
+    list-style:none;
+    float:left;
+    padding:0 15px;
+    margin:0;
+    text-transform:uppercase;
+}
+div.navigation li:hover {
+}
+div.navigation li a {
+    color:#0C0047;
+}
+div.navigation li a:hover, div.navigation li a.current {
+    color:#760073;
+    text-decoration:none;
+}
+
+div.navigation li:last-child {
+    margin-right:0;
+}
+
+
+div.navigation .dropdown-menu {
+    color:black;
+    -moz-box-shadow:    1px 1px 0px 0 rgba(58, 48, 100,0.8);
+    -webkit-box-shadow: 1px 1px 0px 0 rgba(58, 48, 100,0.8);
+    box-shadow:         1px 1px 0px 0 rgba(58, 48, 100,0.8);
+    border-radius:2px;
+    padding:0 5px 5px 5px;
+    margin-top:5px;
+    margin-left:20px;
+}
+div.navigation .dropdown-menu ul {
+    margin:0;
+    padding:15px 5px 5px 5px;
+    display:list-item;
+}
+div.navigation .dropdown-menu li {
+    margin:0 10px 0 0;
+    padding:0 0 8px 0;
+    display:list-item;
+    float:none;
+    text-transform: none;
+}
+
+div.navigation .dropdown-menu a {
+    font-family:Helvetica,sans-serif;
+    font-size:10pt;
+    color:black;
+}
+div.navigation .dropdown-menu li.title {
+    margin-bottom:10px;
+}
+div.navigation .dropdown-menu li.title a {
+    font-family:open_sansbold, sans-serif;
+}
+
+
+div.navigation .dropdown-menu li:first-child {
+    border-bottom:1px solid white;
+    padding-bottom:5px;
+     
+}
+
+div.secondary {
+    text-align:right;
+}
+
+div.secondary ul {
+   margin:6px 0 0 0;
+   padding:0;
+}
+
+div.secondary li {
+    font-size:9pt;
+    display:inline;
+    list-style:none;
+    margin:0px;
+    padding:0;
+    margin-right:15px;
+    color:#747474;
+    letter-spacing:0.4px;
+}
+div.secondary li:last-child {
+    margin-right:0;
+}
+div.secondary li a {
+    color:#747474;
+}
+div.secondary li a:hover {
+    text-decoration:underline;
+}
+div.secondary .button {    
+    width:300px;
+    margin-top:15px;
+}
+div.secondary .account {
+    margin-top:10px;
+    padding:0;
+    font-size:9pt;
+    color:gray;
+    text-align:right;
+}
+div.secondary .account span {
+    font-size:8pt;
+}
+div.secondary .account a {
+    color:black;
+}
+
+
+div.footer {
+    padding-top:15px;
+}
+div.footer div.bottom {
+    position:absolute;
+    bottom:0;
+}
+div.footer ul {
+   margin:6px 0 0 0;
+   padding:0;
+}
+
+div.footer li {
+    font-size:9pt;
+    display:inline;
+    list-style:none;
+    margin:0px;
+    padding:0;
+    margin-right:15px;
+    color:#747474;
+    letter-spacing:0.4px;
+}
+
+div.footer li a {
+    color:#747474;
+}
+div.footer li a:hover {
+    text-decoration:underline;
+}
+div.copy {
+    font-size:8pt;
+    color:gray;
+    padding-top:15px;
+    padding-bottom:15px;
+}
+
+div.home {
+    font-size:11pt;
+    line-height:1.2em;
+    letter-spacing:0.3pt;
+    min-height:500px;
+    //background-image: url('../img/bg-experiment.png');
+    background-repeat:no-repeat;
+    background-size:cover;
+    background-position:center top;
+    background-color:#4FABA3;
+    padding:100px 0;
+}
+div.home h2 {
+    color:white;
+    line-height:1.2em;
+    font-size:18pt;
+}
+div.home h3 {
+    color:white;
+    line-height:1.4em;
+}
+div.dashboard {
+    text-align:center;
+}
+div.dashboard div {
+    margin:25px 0;
+}
+div.dashboard ul {
+    text-align:left;
+    margin-left:24px;
+    list-style:none;
+}
+div.registration-form {
+    padding-top:150px;
+    text-align:center;
+}
+
+.login-form input {
+    width:320px;
+}
+.login-form input[type=submit] {
+    width:108px;
+}
+
+.login-submit {
+    vertical-align:middle;
+    padding:0;
+}
+.lost-password {
+    font-size:10pt;
+    color:black;
+    text-align:right;
+    padding:0px;
+}
+.lost-password a {
+    color:white;
+    text-shadow:0.5px 0.5px black;
+}
+.login-signup {
+    font-size:12pt;
+    color:white;
+    text-shadow:0.5px 0.5px black;
+    margin-top:45px;
+    padding:5px 0 0 4px;
+    
+}
+.login-signup a {
+    color:white;
+    text-shadow:0.5px 0.5px black;
+    padding-bottom:2px;
+    border-bottom:2pt solid white;
+}
+.login-signup a:hover {
+    text-decoration:none;
+}
+.login-signup button {
+    padding:8px;
+    border:0;
+    border-bottom:2px solid #540086;
+    background-color:#302562;
+    color:white;
+    width:100px;
+    border-radius:5px;
+    font-size:12pt;
+}
+div.slogan {
+    text-align:center;
+    color:white;
+    padding-top:60px;
+    text-shadow: 1px 1px #013540;
+}
+
+th {
+    border:0 !important;
+}
+
+div.monitor {
+    padding:40px 0 25px 0;
+}
+div.monitor h1 {
+    margin-bottom:25px;
+}
+div.s-monitor {
+    padding-bottom:25px;
+}
+span#stats-period-txt {
+    text-transform:lowercase;
+}
index 1104c98..0b238d9 100644 (file)
@@ -8,12 +8,28 @@ body {
     margin:0;
     padding:0;
     height: 100%;
+    letter-spacing:0.3px;
 }
 a, a:active, a:focus {
     outline: 0;
     text-decoration:none;
+    color:#760073;
+}
+a:hover {
+    color:#0D0049;
 }
 
+a.current {
+    text-decoration:underline;
+    color:#333333;
+}
+p.command {
+    padding:15px;
+    margin:15px 0;
+    color:#890000;
+    background-color:#E0E0E0; 
+    font-family:Courier, monospace;
+}
 h1 {
     border-bottom:1px solid #DDDDDD;
     padding:0 0 0 0;
@@ -26,13 +42,46 @@ h1 img {
     margin-right:10px;
 }
 h2 {
+    margin:0 0 15px 0;
     font-size:14pt;
     color:#333333;
 }
 h3 {
+    margin:0 0 5px 0;
     font-size:13pt;
     color:#201E62;
 }
+h4 {
+    margin:0 0 5px 0;
+    font-size:12pt;
+    color:#333333;
+}
+span.subtitle {
+    color:#454545;
+    font-size:9pt;
+    font-weight:normal;
+    text-transform:uppercase;
+}
+span.small {
+    font-size:9pt;
+}
+span.gray {
+    color:gray;
+}
+span.type {
+    color:#201E62;
+    font-weight:bold;
+    font-size:9pt;
+}
+span.htitle {
+    color:#454545;
+    font-size:9pt;
+    font-weight:normal;
+}
+span.version {
+    font-size:8pt;
+    color:#888888;
+}
 input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], select, option {
     min-width:260px;
     padding:6px;
@@ -61,6 +110,15 @@ div.breadcrumbs {
     color:gray;
     font-size:10pt;
 }
+div.breadcrumbs a {
+    color:gray;
+}
+div.breadcrumbs a:hover {
+    text-decoration:underline;
+}
+.tab-pane {
+    padding-top:15px;
+}
 /* buttons */
 button.btn, input.btn {
     padding:6px 10px;
@@ -369,13 +427,23 @@ a.sl-resources, a.sl-resources:hover {
     padding:2px 4px;
     -moz-border-radius: 4px;
     border-radius: 4px;
+    width:105px;
+    margin-left:4px;
+    margin-bottom:8px;
+    text-align: center;
 }
 a.sl-resources.active, a.sl-resources.active:hover, a.sl-resources.active:focus {
     border:0;
     -moz-border-radius: 4px;
     border-radius: 4px;
 }
-
+a.sl-resources:first-child {
+    margin-left:12px;
+}
+button.btn-apply {
+    font-size:13px;
+    padding:2px 8px;
+}
 div#slice-info {
     margin-top:25px;
 }
@@ -454,6 +522,8 @@ div#slice-info td {
     padding:3px 5px;
 }
 .slice-pending button.apply {
+    font-size:14px;
+    padding:2px 5px;
 }
 .slice-pending button.clear {
 }
@@ -583,7 +653,7 @@ div.secondary li a {
     color:#747474;
 }
 div.secondary li a:hover {
-    text-decoration:none;
+    text-decoration:underline;
 }
 div.secondary .button {    
     width:300px;
@@ -602,6 +672,44 @@ div.secondary .account span {
 div.secondary .account a {
     color:black;
 }
+
+
+div.footer {
+    padding-top:15px;
+}
+div.footer div.bottom {
+    position:absolute;
+    bottom:0;
+}
+div.footer ul {
+   margin:6px 0 0 0;
+   padding:0;
+}
+
+div.footer li {
+    font-size:9pt;
+    display:inline;
+    list-style:none;
+    margin:0px;
+    padding:0;
+    margin-right:15px;
+    color:#747474;
+    letter-spacing:0.4px;
+}
+
+div.footer li a {
+    color:#747474;
+}
+div.footer li a:hover {
+    text-decoration:underline;
+}
+div.copy {
+    font-size:8pt;
+    color:gray;
+    padding-top:15px;
+    padding-bottom:15px;
+}
+
 div.home {
     font-size:11pt;
     line-height:1.2em;
@@ -692,4 +800,38 @@ div.slogan {
     color:white;
     padding-top:60px;
     text-shadow: 1px 1px #013540;
-}
\ No newline at end of file
+}
+
+th {
+    border:0 !important;
+}
+
+div.monitor {
+    padding:40px 0 25px 0;
+}
+div.monitor h1 {
+    margin-bottom:25px;
+}
+div.s-monitor {
+    padding-bottom:25px;
+}
+span#stats-period-txt {
+    text-transform:lowercase;
+}
+
+// resource info modal
+a.resource-info:hover {
+    cursor:pointer;
+}
+table.modal-resource-info tr td:first-child {
+    font-weight:bold;
+    text-align:right;
+}
+table.modal-resource-info tr:first-child td {
+    border-top:0;
+    text-align:center;
+}
+table.modal-resource-info tr:last-child td {
+    border-bottom:0;
+    text-align:center;
+}
diff --git a/portal/static/icons/ko.png b/portal/static/icons/ko.png
new file mode 100644 (file)
index 0000000..0a39312
Binary files /dev/null and b/portal/static/icons/ko.png differ
diff --git a/portal/static/icons/ok.png b/portal/static/icons/ok.png
new file mode 100644 (file)
index 0000000..becd464
Binary files /dev/null and b/portal/static/icons/ok.png differ
diff --git a/portal/static/img/fantaastic.png b/portal/static/img/fantaastic.png
new file mode 100644 (file)
index 0000000..f4ec9a0
Binary files /dev/null and b/portal/static/img/fantaastic.png differ
diff --git a/portal/static/reputation_static/css/delete.gif b/portal/static/reputation_static/css/delete.gif
new file mode 100644 (file)
index 0000000..43c6ca8
Binary files /dev/null and b/portal/static/reputation_static/css/delete.gif differ
diff --git a/portal/static/reputation_static/css/images/star-off.png b/portal/static/reputation_static/css/images/star-off.png
new file mode 100644 (file)
index 0000000..956fa7c
Binary files /dev/null and b/portal/static/reputation_static/css/images/star-off.png differ
diff --git a/portal/static/reputation_static/css/images/star-on.png b/portal/static/reputation_static/css/images/star-on.png
new file mode 100644 (file)
index 0000000..975fe7f
Binary files /dev/null and b/portal/static/reputation_static/css/images/star-on.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_flat_0_aaaaaa_40x100.png b/portal/static/reputation_static/css/images/ui-bg_flat_0_aaaaaa_40x100.png
new file mode 100644 (file)
index 0000000..5b5dab2
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_flat_0_aaaaaa_40x100.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_flat_75_ffffff_40x100.png b/portal/static/reputation_static/css/images/ui-bg_flat_75_ffffff_40x100.png
new file mode 100644 (file)
index 0000000..ac8b229
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_flat_75_ffffff_40x100.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_glass_55_fbf9ee_1x400.png b/portal/static/reputation_static/css/images/ui-bg_glass_55_fbf9ee_1x400.png
new file mode 100644 (file)
index 0000000..ad3d634
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_glass_55_fbf9ee_1x400.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_glass_65_ffffff_1x400.png b/portal/static/reputation_static/css/images/ui-bg_glass_65_ffffff_1x400.png
new file mode 100644 (file)
index 0000000..42ccba2
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_glass_65_ffffff_1x400.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_glass_75_dadada_1x400.png b/portal/static/reputation_static/css/images/ui-bg_glass_75_dadada_1x400.png
new file mode 100644 (file)
index 0000000..5a46b47
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_glass_75_dadada_1x400.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_glass_75_e6e6e6_1x400.png b/portal/static/reputation_static/css/images/ui-bg_glass_75_e6e6e6_1x400.png
new file mode 100644 (file)
index 0000000..86c2baa
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_glass_75_e6e6e6_1x400.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_glass_95_fef1ec_1x400.png b/portal/static/reputation_static/css/images/ui-bg_glass_95_fef1ec_1x400.png
new file mode 100644 (file)
index 0000000..4443fdc
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_glass_95_fef1ec_1x400.png differ
diff --git a/portal/static/reputation_static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png b/portal/static/reputation_static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png
new file mode 100644 (file)
index 0000000..7c9fa6c
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png differ
diff --git a/portal/static/reputation_static/css/images/ui-icons_222222_256x240.png b/portal/static/reputation_static/css/images/ui-icons_222222_256x240.png
new file mode 100644 (file)
index 0000000..b273ff1
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-icons_222222_256x240.png differ
diff --git a/portal/static/reputation_static/css/images/ui-icons_2e83ff_256x240.png b/portal/static/reputation_static/css/images/ui-icons_2e83ff_256x240.png
new file mode 100644 (file)
index 0000000..09d1cdc
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-icons_2e83ff_256x240.png differ
diff --git a/portal/static/reputation_static/css/images/ui-icons_454545_256x240.png b/portal/static/reputation_static/css/images/ui-icons_454545_256x240.png
new file mode 100644 (file)
index 0000000..59bd45b
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-icons_454545_256x240.png differ
diff --git a/portal/static/reputation_static/css/images/ui-icons_888888_256x240.png b/portal/static/reputation_static/css/images/ui-icons_888888_256x240.png
new file mode 100644 (file)
index 0000000..6d02426
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-icons_888888_256x240.png differ
diff --git a/portal/static/reputation_static/css/images/ui-icons_cd0a0a_256x240.png b/portal/static/reputation_static/css/images/ui-icons_cd0a0a_256x240.png
new file mode 100644 (file)
index 0000000..2ab019b
Binary files /dev/null and b/portal/static/reputation_static/css/images/ui-icons_cd0a0a_256x240.png differ
diff --git a/portal/static/reputation_static/css/jquery-ui-1.9.2.custom.min.css b/portal/static/reputation_static/css/jquery-ui-1.9.2.custom.min.css
new file mode 100644 (file)
index 0000000..5708cbc
--- /dev/null
@@ -0,0 +1,5 @@
+/*! jQuery UI - v1.9.2 - 2013-01-17
+* http://jqueryui.com
+* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.button.css, jquery.ui.dialog.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
+* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=cccccc&bgTextureHeader=03_highlight_soft.png&bgImgOpacityHeader=75&borderColorHeader=aaaaaa&fcHeader=222222&iconColorHeader=222222&bgColorContent=ffffff&bgTextureContent=01_flat.png&bgImgOpacityContent=75&borderColorContent=aaaaaa&fcContent=222222&iconColorContent=222222&bgColorDefault=e6e6e6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=75&borderColorDefault=d3d3d3&fcDefault=555555&iconColorDefault=888888&bgColorHover=dadada&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=999999&fcHover=212121&iconColorHover=454545&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=aaaaaa&fcActive=212121&iconColorActive=454545&bgColorHighlight=fbf9ee&bgTextureHighlight=02_glass.png&bgImgOpacityHighlight=55&borderColorHighlight=fcefa1&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
+* Copyright (c) 2013 jQuery Foundation and other contributors Licensed MIT */.ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{zoom:1}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin-top:2px;padding:.5em .5em .5em .7em;zoom:1}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-noicons{padding-left:.7em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto;zoom:1}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{position:absolute;top:0;left:0;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-tabs-loading a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip{background-image:none}body .ui-tooltip{border-width:2px}.ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #aaa;background:#fff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222}.ui-widget-content a{color:#222}.ui-widget-header{border:1px solid #aaa;background:#ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222;font-weight:bold}.ui-widget-header a{color:#222}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #d3d3d3;background:#e6e6e6 url(images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#555}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#555;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #999;background:#dadada url(images/ui-bg_glass_75_dadada_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited{color:#212121;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #aaa;background:#fff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x;font-weight:normal;color:#212121}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#212121;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #fcefa1;background:#fbf9ee url(images/ui-bg_glass_55_fbf9ee_1x400.png) 50% 50% repeat-x;color:#363636}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #cd0a0a;background:#fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x;color:#cd0a0a}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#cd0a0a}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#cd0a0a}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px;background-image:url(images/ui-icons_222222_256x240.png)}.ui-widget-content .ui-icon{background-image:url(images/ui-icons_222222_256x240.png)}.ui-widget-header .ui-icon{background-image:url(images/ui-icons_222222_256x240.png)}.ui-state-default .ui-icon{background-image:url(images/ui-icons_888888_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}.ui-state-active .ui-icon{background-image:url(images/ui-icons_454545_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(images/ui-icons_2e83ff_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(images/ui-icons_cd0a0a_256x240.png)}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:4px;-webkit-border-top-left-radius:4px;-khtml-border-top-left-radius:4px;border-top-left-radius:4px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{-moz-border-radius-topright:4px;-webkit-border-top-right-radius:4px;-khtml-border-top-right-radius:4px;border-top-right-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{-moz-border-radius-bottomleft:4px;-webkit-border-bottom-left-radius:4px;-khtml-border-bottom-left-radius:4px;border-bottom-left-radius:4px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{-moz-border-radius-bottomright:4px;-webkit-border-bottom-right-radius:4px;-khtml-border-bottom-right-radius:4px;border-bottom-right-radius:4px}.ui-widget-overlay{background:#aaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30)}.ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30);-moz-border-radius:8px;-khtml-border-radius:8px;-webkit-border-radius:8px;border-radius:8px}
\ No newline at end of file
diff --git a/portal/static/reputation_static/css/jquery.rating.css b/portal/static/reputation_static/css/jquery.rating.css
new file mode 100644 (file)
index 0000000..50cf2e2
--- /dev/null
@@ -0,0 +1,12 @@
+/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */\r
+div.rating-cancel,div.star-rating{float:left;width:17px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden}\r
+div.rating-cancel,div.rating-cancel a{background:url(delete.gif) no-repeat 0 -16px}\r
+div.star-rating,div.star-rating a{background:url(star.gif) no-repeat 0 0px}\r
+div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0}\r
+div.star-rating-on a{background-position:0 -16px!important}\r
+div.star-rating-hover a{background-position:0 -32px}\r
+/* Read Only CSS */\r
+div.star-rating-readonly a{cursor:default !important}\r
+/* Partial Star CSS */\r
+div.star-rating{background:transparent!important;overflow:hidden!important}\r
+/* END jQuery.Rating Plugin CSS */
\ No newline at end of file
diff --git a/portal/static/reputation_static/css/main.css b/portal/static/reputation_static/css/main.css
new file mode 100644 (file)
index 0000000..2f9dcbf
--- /dev/null
@@ -0,0 +1,196 @@
+/*\r
+*\r
+*/\r
+\r
+\r
+\r
+*{ margin: 0; padding: 0; }\r
+\r
+:focus,:active { outline: 0; }\r
+body {\r
+       font-family:"Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif;\r
+       font-size:12px;\r
+       color: #111; \r
+       background: #f7f7f7;\r
+}\r
+.registration_form {\r
+       margin:0 auto;\r
+       width:500px;\r
+       padding:14px;\r
+}\r
+label {\r
+       width: 10em;\r
+       float: left;\r
+       margin-right: 0.5em;\r
+       display: block\r
+}\r
+.submit {\r
+       float:right;\r
+}\r
+fieldset {\r
+       background:#EBF4FB none repeat scroll 0 0;\r
+       border:2px solid #B7DDF2;\r
+       width: 500px;\r
+}\r
+legend {\r
+       color: #fff;\r
+       background: #80D3E2;\r
+       border: 1px solid #781351;\r
+       padding: 2px 6px\r
+}\r
+.elements {\r
+       padding:10px;\r
+}\r
+p {\r
+       color:#666666;\r
+       font-size:13px;\r
+       margin-bottom:20px;\r
+       padding-bottom:10px;\r
+}\r
+a{\r
+    color:#0099FF;\r
+font-weight:bold;\r
+}\r
+\r
+/* Box Style */\r
+ .success, .warning, .errormsgbox, .validation {\r
+       border: 1px solid;\r
+       margin: 0 auto;\r
+       padding:10px 5px 10px 60px;\r
+       background-repeat: no-repeat;\r
+       background-position: 10px center;\r
+     font-weight:bold;\r
+     width:450px;\r
+     \r
+}\r
+.success {\r
+   \r
+       color: #4F8A10;\r
+       background-color: #DFF2BF;\r
+       background-image:url('../images/success.png');\r
+}\r
+.warning {\r
+\r
+       color: #9F6000;\r
+       background-color: #FEEFB3;\r
+       background-image: url('../images/warning.png');\r
+}\r
+.errormsgbox {\r
\r
+       color: #D8000C;\r
+       background-color: #FFBABA;\r
+       background-image: url('../images/error.png');\r
+       \r
+}\r
+.validation {\r
\r
+       color: #D63301;\r
+       background-color: #FFCCBA;\r
+       background-image: url('../images/error.png');\r
+}\r
+\r
+a { text-decoration: none; color: #000; }\r
+       a:hover { color: #000; }\r
+.x { clear: both; }\r
+\r
+p { line-height: 22px; margin: 0 0 22px; color:#666; }\r
+img { border: 0; }\r
+\r
+h1 { font-size: 24px; font-weight: normal; margin-bottom: 15px;}\r
+h2 { font-size: 14px; font-weight: normal; margin-bottom: 2px; color: #333; }\r
+h3 { font-size: 14px; font-weight: bolder; margin-bottom: 10px; color: #333; }\r
+h4 { font-size: 18px; font-weight: normal; float: left; margin: 3px 0 10px; width: 460px; }\r
+\r
+#wrapper { margin: 0 auto; width: 980px; background: url(../images/bg.jpg) no-repeat; }\r
+\r
+#logo { padding: 20px 12px 10px; }\r
+       #logo h1 { font: bold 24px Arial; text-shadow: 1px 1px 1px #fff; letter-spacing: 4px; }\r
+               #logo h1 a { color: #333; }\r
+               #logo h1 a span { color: #000; }\r
+#content { background: #fff; width: 980px; }\r
+       \r
+.menu { list-style:none; margin: 14px 25px 0 10px; width: 600px; float: left; }\r
+       .menu li { float: left; margin: 0 4px 0 0; }\r
+       .menu li a { display: block; font-size: 14px; padding: 14px 24px; border: 1px solid #fff; }\r
+       .menu a:hover, .menu li.current a { border: 1px solid #ddd; }\r
+\r
+               .menu li ul { display: block; background: #fff; margin: -1px 0 0; position: absolute; display: none; z-index: 2; border: 1px solid #ddd; }\r
+               .menu li ul li { float: none; display: inline; margin: 0; padding: 0; }\r
+               .menu li ul li a { width: auto; margin: 4px; white-space: nowrap; }\r
+\r
+#search { float: right; width: 275px; margin: 23px 18px; display: inline; }\r
+       #search .text { width: 227px; height: 16px; border: 1px solid #ddd; padding: 5px; float: left; color: #888; }\r
+       #search .submit { float: right; border: 0; background: #000 url(../images/search.gif) no-repeat center 8px; width: 32px; height: 28px; padding-top: 1px; }\r
+\r
+#pitch { margin-bottom: 30px; }\r
+       #pitch .infoline { margin-top: -70px; padding: 25px 0 25px 25px; background: #000; font-size: 18px; width: 955px; height: 18px; opacity:0.70; filter:alpha(opacity=70); color: #fff; }\r
+\r
+       .pitch-gallery { overflow: hidden; width: 980px; position: relative; }\r
+               .pitch-gallery-holder { width: 3920px; position: relative; top: 0; left: 0; }\r
+               .pitch-gallery-div { float: left; }\r
+               \r
+#left { width: 600px; float: left; margin-left: 25px; display: inline; }\r
+       #left img { float: left; margin: 5px 20px 2px 0; padding: 3px; border: 1px solid #ccc; }\r
+       #left form { padding-left: 45px; }\r
+       #left label { float: left; display: block; clear: both; padding: 3px 0; color: #666; font-weight: normal; width: 150px; }\r
+               #left .lcurrent { font-weight: bold; }\r
+       #left label img { vertical-align: middle; }\r
+       #left input.text, textarea, select { float: left; margin: 0 5px 10px 0; padding: 2px; width: 250px; border: 1px solid #ccc; }\r
+       #left textarea { height: 200px; }\r
+       #left select { width: 366px; }\r
+       #left input.radio {  }\r
+               #left input:focus { border-color:#aaa; }\r
+               #left textarea:focus { border-color: #aaa; }    \r
+       .error { font-size: 10px; color: #666; margin: 0 0 10px 150px; display: none; }\r
+       #left .submit { border: 0; background: #000; color: #fff; padding: 5px; float: left; margin-left: 150px; }\r
+       \r
+ul { color: #666; margin: 0 0 10px 10px; line-height: 18px; }\r
+ol { color: #666; margin: 5px 0 5px 30px; line-height: 18px; }\r
+       \r
+       #contact-back { margin: 12px 40px 0 0; float: right; }\r
+\r
+.post { position: relative; margin-bottom: 20px; height: 127px; }\r
+.post-options { position: relative; margin: -37px 0 40px 0; font-size: 10px; color: #666; }\r
+\r
+#right { width: 260px; float: right; border-left: 1px solid #ccc; padding-left: 36px; margin-right: 25px; display: inline; }\r
+       \r
+#feature { margin-left: 25px; padding-bottom: 10px; }\r
+       .small-post { float: left; width: 260px; margin-right: 75px; }\r
+               .small-post img { border: 1px solid #ccc; padding: 3px; margin-bottom: 10px; }\r
+       .last { margin-right: 0; }\r
+       #feature ul { margin-top: -11px; }\r
+       \r
+#footer { color: #666; font-size: 11px; margin: 20px 0 20px 10px; }\r
+\r
+.post-info { font-size: 11px; color: #999; }\r
+.read-more { background: url(../images/link.gif) no-repeat center left; padding-left: 13px; font-size: 10px; }\r
+.break { border-top: 1px solid #ccc; margin: 30px 0; display: block; }\r
+       .no-border { border: 0; }\r
+.space { margin-bottom: 20px; }\r
+\r
+.ui-widget-header {\r
+       background: transparent !important;\r
+       border: none !important;\r
+       border-bottom: 1px solid #AAA !important;\r
+       border-radius: 0px !important;\r
+}\r
+\r
+\r
+#tabs{\r
+       margin-top: 30px !important;\r
+       min-height: 700px;\r
+}\r
+\r
+\r
+#temp_log{\r
+       display: block;\r
+       width:700px;\r
+       height:500px;\r
+       overflow: auto;\r
+       background-color:grey;\r
+       color:white !important;\r
+       padding: 10px 10px 10px 10px;\r
+       margin-left:auto;\r
+       margin-right:auto;\r
+       \r
+}\r
diff --git a/portal/static/reputation_static/img/star-off.png b/portal/static/reputation_static/img/star-off.png
new file mode 100644 (file)
index 0000000..956fa7c
Binary files /dev/null and b/portal/static/reputation_static/img/star-off.png differ
diff --git a/portal/static/reputation_static/img/star-on.png b/portal/static/reputation_static/img/star-on.png
new file mode 100644 (file)
index 0000000..975fe7f
Binary files /dev/null and b/portal/static/reputation_static/img/star-on.png differ
diff --git a/portal/static/reputation_static/img/star.gif b/portal/static/reputation_static/img/star.gif
new file mode 100644 (file)
index 0000000..d0948a7
Binary files /dev/null and b/portal/static/reputation_static/img/star.gif differ
diff --git a/portal/static/reputation_static/js/jquery-1.9.0.min.js b/portal/static/reputation_static/js/jquery-1.9.0.min.js
new file mode 100644 (file)
index 0000000..50d1b22
--- /dev/null
@@ -0,0 +1,4 @@
+/*! jQuery v1.9.0 | (c) 2005, 2012 jQuery Foundation, Inc. | jquery.org/license */(function(e,t){"use strict";function n(e){var t=e.length,n=st.type(e);return st.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}function r(e){var t=Tt[e]={};return st.each(e.match(lt)||[],function(e,n){t[n]=!0}),t}function i(e,n,r,i){if(st.acceptData(e)){var o,a,s=st.expando,u="string"==typeof n,l=e.nodeType,c=l?st.cache:e,f=l?e[s]:e[s]&&s;if(f&&c[f]&&(i||c[f].data)||!u||r!==t)return f||(l?e[s]=f=K.pop()||st.guid++:f=s),c[f]||(c[f]={},l||(c[f].toJSON=st.noop)),("object"==typeof n||"function"==typeof n)&&(i?c[f]=st.extend(c[f],n):c[f].data=st.extend(c[f].data,n)),o=c[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[st.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[st.camelCase(n)])):a=o,a}}function o(e,t,n){if(st.acceptData(e)){var r,i,o,a=e.nodeType,u=a?st.cache:e,l=a?e[st.expando]:st.expando;if(u[l]){if(t&&(r=n?u[l]:u[l].data)){st.isArray(t)?t=t.concat(st.map(t,st.camelCase)):t in r?t=[t]:(t=st.camelCase(t),t=t in r?[t]:t.split(" "));for(i=0,o=t.length;o>i;i++)delete r[t[i]];if(!(n?s:st.isEmptyObject)(r))return}(n||(delete u[l].data,s(u[l])))&&(a?st.cleanData([e],!0):st.support.deleteExpando||u!=u.window?delete u[l]:u[l]=null)}}}function a(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(Nt,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:wt.test(r)?st.parseJSON(r):r}catch(o){}st.data(e,n,r)}else r=t}return r}function s(e){var t;for(t in e)if(("data"!==t||!st.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function u(){return!0}function l(){return!1}function c(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function f(e,t,n){if(t=t||0,st.isFunction(t))return st.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return st.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=st.grep(e,function(e){return 1===e.nodeType});if(Wt.test(t))return st.filter(t,r,!n);t=st.filter(t,r)}return st.grep(e,function(e){return st.inArray(e,t)>=0===n})}function p(e){var t=zt.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function d(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function h(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function g(e){var t=nn.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function m(e,t){for(var n,r=0;null!=(n=e[r]);r++)st._data(n,"globalEval",!t||st._data(t[r],"globalEval"))}function y(e,t){if(1===t.nodeType&&st.hasData(e)){var n,r,i,o=st._data(e),a=st._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)st.event.add(t,n,s[n][r])}a.data&&(a.data=st.extend({},a.data))}}function v(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!st.support.noCloneEvent&&t[st.expando]){r=st._data(t);for(i in r.events)st.removeEvent(t,i,r.handle);t.removeAttribute(st.expando)}"script"===n&&t.text!==e.text?(h(t).text=e.text,g(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),st.support.html5Clone&&e.innerHTML&&!st.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Zt.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 b(e,n){var r,i,o=0,a=e.getElementsByTagName!==t?e.getElementsByTagName(n||"*"):e.querySelectorAll!==t?e.querySelectorAll(n||"*"):t;if(!a)for(a=[],r=e.childNodes||e;null!=(i=r[o]);o++)!n||st.nodeName(i,n)?a.push(i):st.merge(a,b(i,n));return n===t||n&&st.nodeName(e,n)?st.merge([e],a):a}function x(e){Zt.test(e.type)&&(e.defaultChecked=e.checked)}function T(e,t){if(t in e)return t;for(var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=Nn.length;i--;)if(t=Nn[i]+n,t in e)return t;return r}function w(e,t){return e=t||e,"none"===st.css(e,"display")||!st.contains(e.ownerDocument,e)}function N(e,t){for(var n,r=[],i=0,o=e.length;o>i;i++)n=e[i],n.style&&(r[i]=st._data(n,"olddisplay"),t?(r[i]||"none"!==n.style.display||(n.style.display=""),""===n.style.display&&w(n)&&(r[i]=st._data(n,"olddisplay",S(n.nodeName)))):r[i]||w(n)||st._data(n,"olddisplay",st.css(n,"display")));for(i=0;o>i;i++)n=e[i],n.style&&(t&&"none"!==n.style.display&&""!==n.style.display||(n.style.display=t?r[i]||"":"none"));return e}function C(e,t,n){var r=mn.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function k(e,t,n,r,i){for(var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;4>o;o+=2)"margin"===n&&(a+=st.css(e,n+wn[o],!0,i)),r?("content"===n&&(a-=st.css(e,"padding"+wn[o],!0,i)),"margin"!==n&&(a-=st.css(e,"border"+wn[o]+"Width",!0,i))):(a+=st.css(e,"padding"+wn[o],!0,i),"padding"!==n&&(a+=st.css(e,"border"+wn[o]+"Width",!0,i)));return a}function E(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=ln(e),a=st.support.boxSizing&&"border-box"===st.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=un(e,t,o),(0>i||null==i)&&(i=e.style[t]),yn.test(i))return i;r=a&&(st.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+k(e,t,n||(a?"border":"content"),r,o)+"px"}function S(e){var t=V,n=bn[e];return n||(n=A(e,t),"none"!==n&&n||(cn=(cn||st("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(cn[0].contentWindow||cn[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=A(e,t),cn.detach()),bn[e]=n),n}function A(e,t){var n=st(t.createElement(e)).appendTo(t.body),r=st.css(n[0],"display");return n.remove(),r}function j(e,t,n,r){var i;if(st.isArray(t))st.each(t,function(t,i){n||kn.test(e)?r(e,i):j(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==st.type(t))r(e,t);else for(i in t)j(e+"["+i+"]",t[i],n,r)}function D(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(lt)||[];if(st.isFunction(n))for(;r=o[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function L(e,n,r,i){function o(u){var l;return a[u]=!0,st.each(e[u]||[],function(e,u){var c=u(n,r,i);return"string"!=typeof c||s||a[c]?s?!(l=c):t:(n.dataTypes.unshift(c),o(c),!1)}),l}var a={},s=e===$n;return o(n.dataTypes[0])||!a["*"]&&o("*")}function H(e,n){var r,i,o=st.ajaxSettings.flatOptions||{};for(r in n)n[r]!==t&&((o[r]?e:i||(i={}))[r]=n[r]);return i&&st.extend(!0,e,i),e}function M(e,n,r){var i,o,a,s,u=e.contents,l=e.dataTypes,c=e.responseFields;for(o in c)o in r&&(n[c[o]]=r[o]);for(;"*"===l[0];)l.shift(),i===t&&(i=e.mimeType||n.getResponseHeader("Content-Type"));if(i)for(o in u)if(u[o]&&u[o].test(i)){l.unshift(o);break}if(l[0]in r)a=l[0];else{for(o in r){if(!l[0]||e.converters[o+" "+l[0]]){a=o;break}s||(s=o)}a=a||s}return a?(a!==l[0]&&l.unshift(a),r[a]):t}function q(e,t){var n,r,i,o,a={},s=0,u=e.dataTypes.slice(),l=u[0];if(e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u[1])for(n in e.converters)a[n.toLowerCase()]=e.converters[n];for(;i=u[++s];)if("*"!==i){if("*"!==l&&l!==i){if(n=a[l+" "+i]||a["* "+i],!n)for(r in a)if(o=r.split(" "),o[1]===i&&(n=a[l+" "+o[0]]||a["* "+o[0]])){n===!0?n=a[r]:a[r]!==!0&&(i=o[0],u.splice(s--,0,i));break}if(n!==!0)if(n&&e["throws"])t=n(t);else try{t=n(t)}catch(c){return{state:"parsererror",error:n?c:"No conversion from "+l+" to "+i}}}l=i}return{state:"success",data:t}}function _(){try{return new e.XMLHttpRequest}catch(t){}}function F(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}function O(){return setTimeout(function(){Qn=t}),Qn=st.now()}function B(e,t){st.each(t,function(t,n){for(var r=(rr[t]||[]).concat(rr["*"]),i=0,o=r.length;o>i;i++)if(r[i].call(e,t,n))return})}function P(e,t,n){var r,i,o=0,a=nr.length,s=st.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;for(var t=Qn||O(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;u>a;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),1>o&&u?n:(s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:st.extend({},t),opts:st.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Qn||O(),duration:n.duration,tweens:[],createTween:function(t,n){var r=st.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?s.resolveWith(e,[l,t]):s.rejectWith(e,[l,t]),this}}),c=l.props;for(R(c,l.opts.specialEasing);a>o;o++)if(r=nr[o].call(l,e,c,l.opts))return r;return B(l,c),st.isFunction(l.opts.start)&&l.opts.start.call(e,l),st.fx.timer(st.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function R(e,t){var n,r,i,o,a;for(n in e)if(r=st.camelCase(n),i=t[r],o=e[n],st.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=st.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}function W(e,t,n){var r,i,o,a,s,u,l,c,f,p=this,d=e.style,h={},g=[],m=e.nodeType&&w(e);n.queue||(c=st._queueHooks(e,"fx"),null==c.unqueued&&(c.unqueued=0,f=c.empty.fire,c.empty.fire=function(){c.unqueued||f()}),c.unqueued++,p.always(function(){p.always(function(){c.unqueued--,st.queue(e,"fx").length||c.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[d.overflow,d.overflowX,d.overflowY],"inline"===st.css(e,"display")&&"none"===st.css(e,"float")&&(st.support.inlineBlockNeedsLayout&&"inline"!==S(e.nodeName)?d.zoom=1:d.display="inline-block")),n.overflow&&(d.overflow="hidden",st.support.shrinkWrapBlocks||p.done(function(){d.overflow=n.overflow[0],d.overflowX=n.overflow[1],d.overflowY=n.overflow[2]}));for(r in t)if(o=t[r],Zn.exec(o)){if(delete t[r],u=u||"toggle"===o,o===(m?"hide":"show"))continue;g.push(r)}if(a=g.length){s=st._data(e,"fxshow")||st._data(e,"fxshow",{}),"hidden"in s&&(m=s.hidden),u&&(s.hidden=!m),m?st(e).show():p.done(function(){st(e).hide()}),p.done(function(){var t;st._removeData(e,"fxshow");for(t in h)st.style(e,t,h[t])});for(r=0;a>r;r++)i=g[r],l=p.createTween(i,m?s[i]:0),h[i]=s[i]||st.style(e,i),i in s||(s[i]=l.start,m&&(l.end=l.start,l.start="width"===i||"height"===i?1:0))}}function $(e,t,n,r,i){return new $.prototype.init(e,t,n,r,i)}function I(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=wn[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}function z(e){return st.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}var X,U,V=e.document,Y=e.location,J=e.jQuery,G=e.$,Q={},K=[],Z="1.9.0",et=K.concat,tt=K.push,nt=K.slice,rt=K.indexOf,it=Q.toString,ot=Q.hasOwnProperty,at=Z.trim,st=function(e,t){return new st.fn.init(e,t,X)},ut=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,lt=/\S+/g,ct=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,ft=/^(?:(<[\w\W]+>)[^>]*|#([\w-]*))$/,pt=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,dt=/^[\],:{}\s]*$/,ht=/(?:^|:|,)(?:\s*\[)+/g,gt=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,mt=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,yt=/^-ms-/,vt=/-([\da-z])/gi,bt=function(e,t){return t.toUpperCase()},xt=function(){V.addEventListener?(V.removeEventListener("DOMContentLoaded",xt,!1),st.ready()):"complete"===V.readyState&&(V.detachEvent("onreadystatechange",xt),st.ready())};st.fn=st.prototype={jquery:Z,constructor:st,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:ft.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof st?n[0]:n,st.merge(this,st.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:V,!0)),pt.test(i[1])&&st.isPlainObject(n))for(i in n)st.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=V.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=V,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):st.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),st.makeArray(e,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return nt.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=st.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return st.each(this,e,t)},ready:function(e){return st.ready.promise().done(e),this},slice:function(){return this.pushStack(nt.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(st.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:tt,sort:[].sort,splice:[].splice},st.fn.init.prototype=st.fn,st.extend=st.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},u=1,l=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},u=2),"object"==typeof s||st.isFunction(s)||(s={}),l===u&&(s=this,--u);l>u;u++)if(null!=(e=arguments[u]))for(n in e)r=s[n],i=e[n],s!==i&&(c&&i&&(st.isPlainObject(i)||(o=st.isArray(i)))?(o?(o=!1,a=r&&st.isArray(r)?r:[]):a=r&&st.isPlainObject(r)?r:{},s[n]=st.extend(c,a,i)):i!==t&&(s[n]=i));return s},st.extend({noConflict:function(t){return e.$===st&&(e.$=G),t&&e.jQuery===st&&(e.jQuery=J),st},isReady:!1,readyWait:1,holdReady:function(e){e?st.readyWait++:st.ready(!0)},ready:function(e){if(e===!0?!--st.readyWait:!st.isReady){if(!V.body)return setTimeout(st.ready);st.isReady=!0,e!==!0&&--st.readyWait>0||(U.resolveWith(V,[st]),st.fn.trigger&&st(V).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===st.type(e)},isArray:Array.isArray||function(e){return"array"===st.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?Q[it.call(e)]||"object":typeof e},isPlainObject:function(e){if(!e||"object"!==st.type(e)||e.nodeType||st.isWindow(e))return!1;try{if(e.constructor&&!ot.call(e,"constructor")&&!ot.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}var r;for(r in e);return r===t||ot.call(e,r)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||V;var r=pt.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=st.buildFragment([e],t,i),i&&st(i).remove(),st.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=st.trim(n),n&&dt.test(n.replace(gt,"@").replace(mt,"]").replace(ht,"")))?Function("return "+n)():(st.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||st.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&st.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(yt,"ms-").replace(vt,bt)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,r){var i,o=0,a=e.length,s=n(e);if(r){if(s)for(;a>o&&(i=t.apply(e[o],r),i!==!1);o++);else for(o in e)if(i=t.apply(e[o],r),i===!1)break}else if(s)for(;a>o&&(i=t.call(e[o],o,e[o]),i!==!1);o++);else for(o in e)if(i=t.call(e[o],o,e[o]),i===!1)break;return e},trim:at&&!at.call("\ufeff\u00a0")?function(e){return null==e?"":at.call(e)}:function(e){return null==e?"":(e+"").replace(ct,"")},makeArray:function(e,t){var r=t||[];return null!=e&&(n(Object(e))?st.merge(r,"string"==typeof e?[e]:e):tt.call(r,e)),r},inArray:function(e,t,n){var r;if(t){if(rt)return rt.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else for(;n[o]!==t;)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,r){var i,o=0,a=e.length,s=n(e),u=[];if(s)for(;a>o;o++)i=t(e[o],o,r),null!=i&&(u[u.length]=i);else for(o in e)i=t(e[o],o,r),null!=i&&(u[u.length]=i);return et.apply([],u)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(r=e[n],n=e,e=r),st.isFunction(e)?(i=nt.call(arguments,2),o=function(){return e.apply(n||this,i.concat(nt.call(arguments)))},o.guid=e.guid=e.guid||st.guid++,o):t},access:function(e,n,r,i,o,a,s){var u=0,l=e.length,c=null==r;if("object"===st.type(r)){o=!0;for(u in r)st.access(e,n,u,r[u],!0,a,s)}else if(i!==t&&(o=!0,st.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(st(e),n)})),n))for(;l>u;u++)n(e[u],r,s?i:i.call(e[u],u,n(e[u],r)));return o?e:c?n.call(e):l?n(e[0],r):a},now:function(){return(new Date).getTime()}}),st.ready.promise=function(t){if(!U)if(U=st.Deferred(),"complete"===V.readyState)setTimeout(st.ready);else if(V.addEventListener)V.addEventListener("DOMContentLoaded",xt,!1),e.addEventListener("load",st.ready,!1);else{V.attachEvent("onreadystatechange",xt),e.attachEvent("onload",st.ready);var n=!1;try{n=null==e.frameElement&&V.documentElement}catch(r){}n&&n.doScroll&&function i(){if(!st.isReady){try{n.doScroll("left")}catch(e){return setTimeout(i,50)}st.ready()}}()}return U.promise(t)},st.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){Q["[object "+t+"]"]=t.toLowerCase()}),X=st(V);var Tt={};st.Callbacks=function(e){e="string"==typeof e?Tt[e]||r(e):st.extend({},e);var n,i,o,a,s,u,l=[],c=!e.once&&[],f=function(t){for(n=e.memory&&t,i=!0,u=a||0,a=0,s=l.length,o=!0;l&&s>u;u++)if(l[u].apply(t[0],t[1])===!1&&e.stopOnFalse){n=!1;break}o=!1,l&&(c?c.length&&f(c.shift()):n?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function r(t){st.each(t,function(t,n){var i=st.type(n);"function"===i?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==i&&r(n)})})(arguments),o?s=l.length:n&&(a=t,f(n))}return this},remove:function(){return l&&st.each(arguments,function(e,t){for(var n;(n=st.inArray(t,l,n))>-1;)l.splice(n,1),o&&(s>=n&&s--,u>=n&&u--)}),this},has:function(e){return st.inArray(e,l)>-1},empty:function(){return l=[],this},disable:function(){return l=c=n=t,this},disabled:function(){return!l},lock:function(){return c=t,n||p.disable(),this},locked:function(){return!c},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!l||i&&!c||(o?c.push(t):f(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},st.extend({Deferred:function(e){var t=[["resolve","done",st.Callbacks("once memory"),"resolved"],["reject","fail",st.Callbacks("once memory"),"rejected"],["notify","progress",st.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return st.Deferred(function(n){st.each(t,function(t,o){var a=o[0],s=st.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&st.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?st.extend(e,r):r}},i={};return r.pipe=r.then,st.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t,n,r,i=0,o=nt.call(arguments),a=o.length,s=1!==a||e&&st.isFunction(e.promise)?a:0,u=1===s?e:st.Deferred(),l=function(e,n,r){return function(i){n[e]=this,r[e]=arguments.length>1?nt.call(arguments):i,r===t?u.notifyWith(n,r):--s||u.resolveWith(n,r)}};if(a>1)for(t=Array(a),n=Array(a),r=Array(a);a>i;i++)o[i]&&st.isFunction(o[i].promise)?o[i].promise().done(l(i,r,o)).fail(u.reject).progress(l(i,n,t)):--s;return s||u.resolveWith(r,o),u.promise()}}),st.support=function(){var n,r,i,o,a,s,u,l,c,f,p=V.createElement("div");if(p.setAttribute("className","t"),p.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",r=p.getElementsByTagName("*"),i=p.getElementsByTagName("a")[0],!r||!i||!r.length)return{};o=V.createElement("select"),a=o.appendChild(V.createElement("option")),s=p.getElementsByTagName("input")[0],i.style.cssText="top:1px;float:left;opacity:.5",n={getSetAttribute:"t"!==p.className,leadingWhitespace:3===p.firstChild.nodeType,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(i.getAttribute("style")),hrefNormalized:"/a"===i.getAttribute("href"),opacity:/^0.5/.test(i.style.opacity),cssFloat:!!i.style.cssFloat,checkOn:!!s.value,optSelected:a.selected,enctype:!!V.createElement("form").enctype,html5Clone:"<:nav></:nav>"!==V.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===V.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},s.checked=!0,n.noCloneChecked=s.cloneNode(!0).checked,o.disabled=!0,n.optDisabled=!a.disabled;try{delete p.test}catch(d){n.deleteExpando=!1}s=V.createElement("input"),s.setAttribute("value",""),n.input=""===s.getAttribute("value"),s.value="t",s.setAttribute("type","radio"),n.radioValue="t"===s.value,s.setAttribute("checked","t"),s.setAttribute("name","t"),u=V.createDocumentFragment(),u.appendChild(s),n.appendChecked=s.checked,n.checkClone=u.cloneNode(!0).cloneNode(!0).lastChild.checked,p.attachEvent&&(p.attachEvent("onclick",function(){n.noCloneEvent=!1}),p.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})p.setAttribute(l="on"+f,"t"),n[f+"Bubbles"]=l in e||p.attributes[l].expando===!1;return p.style.backgroundClip="content-box",p.cloneNode(!0).style.backgroundClip="",n.clearCloneStyle="content-box"===p.style.backgroundClip,st(function(){var r,i,o,a="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",s=V.getElementsByTagName("body")[0];s&&(r=V.createElement("div"),r.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",s.appendChild(r).appendChild(p),p.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=p.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",c=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",n.reliableHiddenOffsets=c&&0===o[0].offsetHeight,p.innerHTML="",p.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",n.boxSizing=4===p.offsetWidth,n.doesNotIncludeMarginInBodyOffset=1!==s.offsetTop,e.getComputedStyle&&(n.pixelPosition="1%"!==(e.getComputedStyle(p,null)||{}).top,n.boxSizingReliable="4px"===(e.getComputedStyle(p,null)||{width:"4px"}).width,i=p.appendChild(V.createElement("div")),i.style.cssText=p.style.cssText=a,i.style.marginRight=i.style.width="0",p.style.width="1px",n.reliableMarginRight=!parseFloat((e.getComputedStyle(i,null)||{}).marginRight)),p.style.zoom!==t&&(p.innerHTML="",p.style.cssText=a+"width:1px;padding:1px;display:inline;zoom:1",n.inlineBlockNeedsLayout=3===p.offsetWidth,p.style.display="block",p.innerHTML="<div></div>",p.firstChild.style.width="5px",n.shrinkWrapBlocks=3!==p.offsetWidth,s.style.zoom=1),s.removeChild(r),r=p=o=i=null)}),r=o=u=a=i=s=null,n}();var wt=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,Nt=/([A-Z])/g;st.extend({cache:{},expando:"jQuery"+(Z+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(e){return e=e.nodeType?st.cache[e[st.expando]]:e[st.expando],!!e&&!s(e)},data:function(e,t,n){return i(e,t,n,!1)},removeData:function(e,t){return o(e,t,!1)},_data:function(e,t,n){return i(e,t,n,!0)},_removeData:function(e,t){return o(e,t,!0)},acceptData:function(e){var t=e.nodeName&&st.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),st.fn.extend({data:function(e,n){var r,i,o=this[0],s=0,u=null;if(e===t){if(this.length&&(u=st.data(o),1===o.nodeType&&!st._data(o,"parsedAttrs"))){for(r=o.attributes;r.length>s;s++)i=r[s].name,i.indexOf("data-")||(i=st.camelCase(i.substring(5)),a(o,i,u[i]));st._data(o,"parsedAttrs",!0)}return u}return"object"==typeof e?this.each(function(){st.data(this,e)}):st.access(this,function(n){return n===t?o?a(o,e,st.data(o,e)):null:(this.each(function(){st.data(this,e,n)}),t)},null,n,arguments.length>1,null,!0)},removeData:function(e){return this.each(function(){st.removeData(this,e)})}}),st.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=st._data(e,n),r&&(!i||st.isArray(r)?i=st._data(e,n,st.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=st.queue(e,t),r=n.length,i=n.shift(),o=st._queueHooks(e,t),a=function(){st.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),o.cur=i,i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return st._data(e,n)||st._data(e,n,{empty:st.Callbacks("once memory").add(function(){st._removeData(e,t+"queue"),st._removeData(e,n)})})}}),st.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?st.queue(this[0],e):n===t?this:this.each(function(){var t=st.queue(this,e,n);st._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&st.dequeue(this,e)})},dequeue:function(e){return this.each(function(){st.dequeue(this,e)})},delay:function(e,t){return e=st.fx?st.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=st.Deferred(),a=this,s=this.length,u=function(){--i||o.resolveWith(a,[a])};for("string"!=typeof e&&(n=e,e=t),e=e||"fx";s--;)r=st._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(u));return u(),o.promise(n)}});var Ct,kt,Et=/[\t\r\n]/g,St=/\r/g,At=/^(?:input|select|textarea|button|object)$/i,jt=/^(?:a|area)$/i,Dt=/^(?:checked|selected|autofocus|autoplay|async|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped)$/i,Lt=/^(?:checked|selected)$/i,Ht=st.support.getSetAttribute,Mt=st.support.input;st.fn.extend({attr:function(e,t){return st.access(this,st.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){st.removeAttr(this,e)})},prop:function(e,t){return st.access(this,st.prop,e,t,arguments.length>1)},removeProp:function(e){return e=st.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,u="string"==typeof e&&e;if(st.isFunction(e))return this.each(function(t){st(this).addClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(lt)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(Et," "):" ")){for(o=0;i=t[o++];)0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=st.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,u=0===arguments.length||"string"==typeof e&&e;if(st.isFunction(e))return this.each(function(t){st(this).removeClass(e.call(this,t,this.className))});if(u)for(t=(e||"").match(lt)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(Et," "):"")){for(o=0;i=t[o++];)for(;r.indexOf(" "+i+" ")>=0;)r=r.replace(" "+i+" "," ");n.className=e?st.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return st.isFunction(e)?this.each(function(n){st(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n)for(var i,o=0,a=st(this),s=t,u=e.match(lt)||[];i=u[o++];)s=r?s:!a.hasClass(i),a[s?"addClass":"removeClass"](i);else("undefined"===n||"boolean"===n)&&(this.className&&st._data(this,"__className__",this.className),this.className=this.className||e===!1?"":st._data(this,"__className__")||"")})},hasClass:function(e){for(var t=" "+e+" ",n=0,r=this.length;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(Et," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=st.isFunction(e),this.each(function(r){var o,a=st(this);1===this.nodeType&&(o=i?e.call(this,r,a.val()):e,null==o?o="":"number"==typeof o?o+="":st.isArray(o)&&(o=st.map(o,function(e){return null==e?"":e+""})),n=st.valHooks[this.type]||st.valHooks[this.nodeName.toLowerCase()],n&&"set"in n&&n.set(this,o,"value")!==t||(this.value=o))});if(o)return n=st.valHooks[o.type]||st.valHooks[o.nodeName.toLowerCase()],n&&"get"in n&&(r=n.get(o,"value"))!==t?r:(r=o.value,"string"==typeof r?r.replace(St,""):null==r?"":r)}}}),st.extend({valHooks:{option:{get:function(e){var t=e.attributes.value;return!t||t.specified?e.value:e.text}},select:{get:function(e){for(var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,u=0>i?s:o?i:0;s>u;u++)if(n=r[u],!(!n.selected&&u!==i||(st.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&st.nodeName(n.parentNode,"optgroup"))){if(t=st(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n=st.makeArray(t);return st(e).find("option").each(function(){this.selected=st.inArray(st(this).val(),n)>=0}),n.length||(e.selectedIndex=-1),n}}},attr:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return e.getAttribute===t?st.prop(e,n,r):(a=1!==s||!st.isXMLDoc(e),a&&(n=n.toLowerCase(),o=st.attrHooks[n]||(Dt.test(n)?kt:Ct)),r===t?o&&a&&"get"in o&&null!==(i=o.get(e,n))?i:(e.getAttribute!==t&&(i=e.getAttribute(n)),null==i?t:i):null!==r?o&&a&&"set"in o&&(i=o.set(e,r,n))!==t?i:(e.setAttribute(n,r+""),r):(st.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(lt);if(o&&1===e.nodeType)for(;n=o[i++];)r=st.propFix[n]||n,Dt.test(n)?!Ht&&Lt.test(n)?e[st.camelCase("default-"+n)]=e[r]=!1:e[r]=!1:st.attr(e,n,""),e.removeAttribute(Ht?n:r)},attrHooks:{type:{set:function(e,t){if(!st.support.radioValue&&"radio"===t&&st.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!st.isXMLDoc(e),a&&(n=st.propFix[n]||n,o=st.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var n=e.getAttributeNode("tabindex");return n&&n.specified?parseInt(n.value,10):At.test(e.nodeName)||jt.test(e.nodeName)&&e.href?0:t}}}}),kt={get:function(e,n){var r=st.prop(e,n),i="boolean"==typeof r&&e.getAttribute(n),o="boolean"==typeof r?Mt&&Ht?null!=i:Lt.test(n)?e[st.camelCase("default-"+n)]:!!i:e.getAttributeNode(n);return o&&o.value!==!1?n.toLowerCase():t},set:function(e,t,n){return t===!1?st.removeAttr(e,n):Mt&&Ht||!Lt.test(n)?e.setAttribute(!Ht&&st.propFix[n]||n,n):e[st.camelCase("default-"+n)]=e[n]=!0,n}},Mt&&Ht||(st.attrHooks.value={get:function(e,n){var r=e.getAttributeNode(n);return st.nodeName(e,"input")?e.defaultValue:r&&r.specified?r.value:t
+},set:function(e,n,r){return st.nodeName(e,"input")?(e.defaultValue=n,t):Ct&&Ct.set(e,n,r)}}),Ht||(Ct=st.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},st.attrHooks.contenteditable={get:Ct.get,set:function(e,t,n){Ct.set(e,""===t?!1:t,n)}},st.each(["width","height"],function(e,n){st.attrHooks[n]=st.extend(st.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),st.support.hrefNormalized||(st.each(["href","src","width","height"],function(e,n){st.attrHooks[n]=st.extend(st.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),st.each(["href","src"],function(e,t){st.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),st.support.style||(st.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),st.support.optSelected||(st.propHooks.selected=st.extend(st.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),st.support.enctype||(st.propFix.enctype="encoding"),st.support.checkOn||st.each(["radio","checkbox"],function(){st.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),st.each(["radio","checkbox"],function(){st.valHooks[this]=st.extend(st.valHooks[this],{set:function(e,n){return st.isArray(n)?e.checked=st.inArray(st(e).val(),n)>=0:t}})});var qt=/^(?:input|select|textarea)$/i,_t=/^key/,Ft=/^(?:mouse|contextmenu)|click/,Ot=/^(?:focusinfocus|focusoutblur)$/,Bt=/^([^.]*)(?:\.(.+)|)$/;st.event={global:{},add:function(e,n,r,i,o){var a,s,u,l,c,f,p,d,h,g,m,y=3!==e.nodeType&&8!==e.nodeType&&st._data(e);if(y){for(r.handler&&(a=r,r=a.handler,o=a.selector),r.guid||(r.guid=st.guid++),(l=y.events)||(l=y.events={}),(s=y.handle)||(s=y.handle=function(e){return st===t||e&&st.event.triggered===e.type?t:st.event.dispatch.apply(s.elem,arguments)},s.elem=e),n=(n||"").match(lt)||[""],c=n.length;c--;)u=Bt.exec(n[c])||[],h=m=u[1],g=(u[2]||"").split(".").sort(),p=st.event.special[h]||{},h=(o?p.delegateType:p.bindType)||h,p=st.event.special[h]||{},f=st.extend({type:h,origType:m,data:i,handler:r,guid:r.guid,selector:o,needsContext:o&&st.expr.match.needsContext.test(o),namespace:g.join(".")},a),(d=l[h])||(d=l[h]=[],d.delegateCount=0,p.setup&&p.setup.call(e,i,g,s)!==!1||(e.addEventListener?e.addEventListener(h,s,!1):e.attachEvent&&e.attachEvent("on"+h,s))),p.add&&(p.add.call(e,f),f.handler.guid||(f.handler.guid=r.guid)),o?d.splice(d.delegateCount++,0,f):d.push(f),st.event.global[h]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,m=st.hasData(e)&&st._data(e);if(m&&(u=m.events)){for(t=(t||"").match(lt)||[""],l=t.length;l--;)if(s=Bt.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){for(f=st.event.special[d]||{},d=(r?f.delegateType:f.bindType)||d,p=u[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;o--;)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&f.teardown.call(e,h,m.handle)!==!1||st.removeEvent(e,d,m.handle),delete u[d])}else for(d in u)st.event.remove(e,d+t[l],n,r,!0);st.isEmptyObject(u)&&(delete m.handle,st._removeData(e,"events"))}},trigger:function(n,r,i,o){var a,s,u,l,c,f,p,d=[i||V],h=n.type||n,g=n.namespace?n.namespace.split("."):[];if(s=u=i=i||V,3!==i.nodeType&&8!==i.nodeType&&!Ot.test(h+st.event.triggered)&&(h.indexOf(".")>=0&&(g=h.split("."),h=g.shift(),g.sort()),c=0>h.indexOf(":")&&"on"+h,n=n[st.expando]?n:new st.Event(h,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=g.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:st.makeArray(r,[n]),p=st.event.special[h]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!st.isWindow(i)){for(l=p.delegateType||h,Ot.test(l+h)||(s=s.parentNode);s;s=s.parentNode)d.push(s),u=s;u===(i.ownerDocument||V)&&d.push(u.defaultView||u.parentWindow||e)}for(a=0;(s=d[a++])&&!n.isPropagationStopped();)n.type=a>1?l:p.bindType||h,f=(st._data(s,"events")||{})[n.type]&&st._data(s,"handle"),f&&f.apply(s,r),f=c&&s[c],f&&st.acceptData(s)&&f.apply&&f.apply(s,r)===!1&&n.preventDefault();if(n.type=h,!(o||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===h&&st.nodeName(i,"a")||!st.acceptData(i)||!c||!i[h]||st.isWindow(i))){u=i[c],u&&(i[c]=null),st.event.triggered=h;try{i[h]()}catch(m){}st.event.triggered=t,u&&(i[c]=u)}return n.result}},dispatch:function(e){e=st.event.fix(e);var n,r,i,o,a,s=[],u=nt.call(arguments),l=(st._data(this,"events")||{})[e.type]||[],c=st.event.special[e.type]||{};if(u[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){for(s=st.event.handlers.call(this,e,l),n=0;(o=s[n++])&&!e.isPropagationStopped();)for(e.currentTarget=o.elem,r=0;(a=o.handlers[r++])&&!e.isImmediatePropagationStopped();)(!e.namespace_re||e.namespace_re.test(a.namespace))&&(e.handleObj=a,e.data=a.data,i=((st.event.special[a.origType]||{}).handle||a.handler).apply(o.elem,u),i!==t&&(e.result=i)===!1&&(e.preventDefault(),e.stopPropagation()));return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],u=n.delegateCount,l=e.target;if(u&&l.nodeType&&(!e.button||"click"!==e.type))for(;l!=this;l=l.parentNode||this)if(l.disabled!==!0||"click"!==e.type){for(i=[],r=0;u>r;r++)a=n[r],o=a.selector+" ",i[o]===t&&(i[o]=a.needsContext?st(o,this).index(l)>=0:st.find(o,this,null,[l]).length),i[o]&&i.push(a);i.length&&s.push({elem:l,handlers:i})}return n.length>u&&s.push({elem:this,handlers:n.slice(u)}),s},fix:function(e){if(e[st.expando])return e;var t,n,r=e,i=st.event.fixHooks[e.type]||{},o=i.props?this.props.concat(i.props):this.props;for(e=new st.Event(r),t=o.length;t--;)n=o[t],e[n]=r[n];return e.target||(e.target=r.srcElement||V),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,i.filter?i.filter(e,r):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,a=n.button,s=n.fromElement;return null==e.pageX&&null!=n.clientX&&(r=e.target.ownerDocument||V,i=r.documentElement,o=r.body,e.pageX=n.clientX+(i&&i.scrollLeft||o&&o.scrollLeft||0)-(i&&i.clientLeft||o&&o.clientLeft||0),e.pageY=n.clientY+(i&&i.scrollTop||o&&o.scrollTop||0)-(i&&i.clientTop||o&&o.clientTop||0)),!e.relatedTarget&&s&&(e.relatedTarget=s===e.target?n.toElement:s),e.which||a===t||(e.which=1&a?1:2&a?3:4&a?2:0),e}},special:{load:{noBubble:!0},click:{trigger:function(){return st.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t}},focus:{trigger:function(){if(this!==V.activeElement&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===V.activeElement&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=st.extend(new st.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?st.event.trigger(i,null,t):st.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},st.removeEvent=V.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,n,r){var i="on"+n;e.detachEvent&&(e[i]===t&&(e[i]=null),e.detachEvent(i,r))},st.Event=function(e,n){return this instanceof st.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?u:l):this.type=e,n&&st.extend(this,n),this.timeStamp=e&&e.timeStamp||st.now(),this[st.expando]=!0,t):new st.Event(e,n)},st.Event.prototype={isDefaultPrevented:l,isPropagationStopped:l,isImmediatePropagationStopped:l,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=u,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=u,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u,this.stopPropagation()}},st.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){st.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!st.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),st.support.submitBubbles||(st.event.special.submit={setup:function(){return st.nodeName(this,"form")?!1:(st.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=st.nodeName(n,"input")||st.nodeName(n,"button")?n.form:t;r&&!st._data(r,"submitBubbles")&&(st.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),st._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&st.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return st.nodeName(this,"form")?!1:(st.event.remove(this,"._submit"),t)}}),st.support.changeBubbles||(st.event.special.change={setup:function(){return qt.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(st.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),st.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),st.event.simulate("change",this,e,!0)})),!1):(st.event.add(this,"beforeactivate._change",function(e){var t=e.target;qt.test(t.nodeName)&&!st._data(t,"changeBubbles")&&(st.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||st.event.simulate("change",this.parentNode,e,!0)}),st._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return st.event.remove(this,"._change"),!qt.test(this.nodeName)}}),st.support.focusinBubbles||st.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){st.event.simulate(t,e.target,st.event.fix(e),!0)};st.event.special[t]={setup:function(){0===n++&&V.addEventListener(e,r,!0)},teardown:function(){0===--n&&V.removeEventListener(e,r,!0)}}}),st.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(s in e)this.on(s,n,r,e[s],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=l;else if(!i)return this;return 1===o&&(a=i,i=function(e){return st().off(e),a.apply(this,arguments)},i.guid=a.guid||(a.guid=st.guid++)),this.each(function(){st.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,st(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=l),this.each(function(){st.event.remove(this,e,r,n)})},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)},trigger:function(e,t){return this.each(function(){st.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?st.event.trigger(e,n,r,!0):t},hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}}),st.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){st.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)},_t.test(t)&&(st.event.fixHooks[t]=st.event.keyHooks),Ft.test(t)&&(st.event.fixHooks[t]=st.event.mouseHooks)}),function(e,t){function n(e){return ht.test(e+"")}function r(){var e,t=[];return e=function(n,r){return t.push(n+=" ")>C.cacheLength&&delete e[t.shift()],e[n]=r}}function i(e){return e[P]=!0,e}function o(e){var t=L.createElement("div");try{return e(t)}catch(n){return!1}finally{t=null}}function a(e,t,n,r){var i,o,a,s,u,l,c,d,h,g;if((t?t.ownerDocument||t:R)!==L&&D(t),t=t||L,n=n||[],!e||"string"!=typeof e)return n;if(1!==(s=t.nodeType)&&9!==s)return[];if(!M&&!r){if(i=gt.exec(e))if(a=i[1]){if(9===s){if(o=t.getElementById(a),!o||!o.parentNode)return n;if(o.id===a)return n.push(o),n}else if(t.ownerDocument&&(o=t.ownerDocument.getElementById(a))&&O(t,o)&&o.id===a)return n.push(o),n}else{if(i[2])return Q.apply(n,K.call(t.getElementsByTagName(e),0)),n;if((a=i[3])&&W.getByClassName&&t.getElementsByClassName)return Q.apply(n,K.call(t.getElementsByClassName(a),0)),n}if(W.qsa&&!q.test(e)){if(c=!0,d=P,h=t,g=9===s&&e,1===s&&"object"!==t.nodeName.toLowerCase()){for(l=f(e),(c=t.getAttribute("id"))?d=c.replace(vt,"\\$&"):t.setAttribute("id",d),d="[id='"+d+"'] ",u=l.length;u--;)l[u]=d+p(l[u]);h=dt.test(e)&&t.parentNode||t,g=l.join(",")}if(g)try{return Q.apply(n,K.call(h.querySelectorAll(g),0)),n}catch(m){}finally{c||t.removeAttribute("id")}}}return x(e.replace(at,"$1"),t,n,r)}function s(e,t){for(var n=e&&t&&e.nextSibling;n;n=n.nextSibling)if(n===t)return-1;return e?1:-1}function u(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function l(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function c(e){return i(function(t){return t=+t,i(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function f(e,t){var n,r,i,o,s,u,l,c=X[e+" "];if(c)return t?0:c.slice(0);for(s=e,u=[],l=C.preFilter;s;){(!n||(r=ut.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),u.push(i=[])),n=!1,(r=lt.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(at," ")}),s=s.slice(n.length));for(o in C.filter)!(r=pt[o].exec(s))||l[o]&&!(r=l[o](r))||(n=r.shift(),i.push({value:n,type:o,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?a.error(e):X(e,u).slice(0)}function p(e){for(var t=0,n=e.length,r="";n>t;t++)r+=e[t].value;return r}function d(e,t,n){var r=t.dir,i=n&&"parentNode"===t.dir,o=I++;return t.first?function(t,n,o){for(;t=t[r];)if(1===t.nodeType||i)return e(t,n,o)}:function(t,n,a){var s,u,l,c=$+" "+o;if(a){for(;t=t[r];)if((1===t.nodeType||i)&&e(t,n,a))return!0}else for(;t=t[r];)if(1===t.nodeType||i)if(l=t[P]||(t[P]={}),(u=l[r])&&u[0]===c){if((s=u[1])===!0||s===N)return s===!0}else if(u=l[r]=[c],u[1]=e(t,n,a)||N,u[1]===!0)return!0}}function h(e){return e.length>1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function g(e,t,n,r,i){for(var o,a=[],s=0,u=e.length,l=null!=t;u>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),l&&t.push(s));return a}function m(e,t,n,r,o,a){return r&&!r[P]&&(r=m(r)),o&&!o[P]&&(o=m(o,a)),i(function(i,a,s,u){var l,c,f,p=[],d=[],h=a.length,m=i||b(t||"*",s.nodeType?[s]:s,[]),y=!e||!i&&t?m:g(m,p,e,s,u),v=n?o||(i?e:h||r)?[]:a:y;if(n&&n(y,v,s,u),r)for(l=g(v,d),r(l,[],s,u),c=l.length;c--;)(f=l[c])&&(v[d[c]]=!(y[d[c]]=f));if(i){if(o||e){if(o){for(l=[],c=v.length;c--;)(f=v[c])&&l.push(y[c]=f);o(null,v=[],l,u)}for(c=v.length;c--;)(f=v[c])&&(l=o?Z.call(i,f):p[c])>-1&&(i[l]=!(a[l]=f))}}else v=g(v===a?v.splice(h,v.length):v),o?o(null,a,v,u):Q.apply(a,v)})}function y(e){for(var t,n,r,i=e.length,o=C.relative[e[0].type],a=o||C.relative[" "],s=o?1:0,u=d(function(e){return e===t},a,!0),l=d(function(e){return Z.call(t,e)>-1},a,!0),c=[function(e,n,r){return!o&&(r||n!==j)||((t=n).nodeType?u(e,n,r):l(e,n,r))}];i>s;s++)if(n=C.relative[e[s].type])c=[d(h(c),n)];else{if(n=C.filter[e[s].type].apply(null,e[s].matches),n[P]){for(r=++s;i>r&&!C.relative[e[r].type];r++);return m(s>1&&h(c),s>1&&p(e.slice(0,s-1)).replace(at,"$1"),n,r>s&&y(e.slice(s,r)),i>r&&y(e=e.slice(r)),i>r&&p(e))}c.push(n)}return h(c)}function v(e,t){var n=0,r=t.length>0,o=e.length>0,s=function(i,s,u,l,c){var f,p,d,h=[],m=0,y="0",v=i&&[],b=null!=c,x=j,T=i||o&&C.find.TAG("*",c&&s.parentNode||s),w=$+=null==x?1:Math.E;for(b&&(j=s!==L&&s,N=n);null!=(f=T[y]);y++){if(o&&f){for(p=0;d=e[p];p++)if(d(f,s,u)){l.push(f);break}b&&($=w,N=++n)}r&&((f=!d&&f)&&m--,i&&v.push(f))}if(m+=y,r&&y!==m){for(p=0;d=t[p];p++)d(v,h,s,u);if(i){if(m>0)for(;y--;)v[y]||h[y]||(h[y]=G.call(l));h=g(h)}Q.apply(l,h),b&&!i&&h.length>0&&m+t.length>1&&a.uniqueSort(l)}return b&&($=w,j=x),v};return r?i(s):s}function b(e,t,n){for(var r=0,i=t.length;i>r;r++)a(e,t[r],n);return n}function x(e,t,n,r){var i,o,a,s,u,l=f(e);if(!r&&1===l.length){if(o=l[0]=l[0].slice(0),o.length>2&&"ID"===(a=o[0]).type&&9===t.nodeType&&!M&&C.relative[o[1].type]){if(t=C.find.ID(a.matches[0].replace(xt,Tt),t)[0],!t)return n;e=e.slice(o.shift().value.length)}for(i=pt.needsContext.test(e)?-1:o.length-1;i>=0&&(a=o[i],!C.relative[s=a.type]);i--)if((u=C.find[s])&&(r=u(a.matches[0].replace(xt,Tt),dt.test(o[0].type)&&t.parentNode||t))){if(o.splice(i,1),e=r.length&&p(o),!e)return Q.apply(n,K.call(r,0)),n;break}}return S(e,l)(r,t,M,n,dt.test(e)),n}function T(){}var w,N,C,k,E,S,A,j,D,L,H,M,q,_,F,O,B,P="sizzle"+-new Date,R=e.document,W={},$=0,I=0,z=r(),X=r(),U=r(),V=typeof t,Y=1<<31,J=[],G=J.pop,Q=J.push,K=J.slice,Z=J.indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(this[t]===e)return t;return-1},et="[\\x20\\t\\r\\n\\f]",tt="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",nt=tt.replace("w","w#"),rt="([*^$|!~]?=)",it="\\["+et+"*("+tt+")"+et+"*(?:"+rt+et+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+nt+")|)|)"+et+"*\\]",ot=":("+tt+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+it.replace(3,8)+")*)|.*)\\)|)",at=RegExp("^"+et+"+|((?:^|[^\\\\])(?:\\\\.)*)"+et+"+$","g"),ut=RegExp("^"+et+"*,"+et+"*"),lt=RegExp("^"+et+"*([\\x20\\t\\r\\n\\f>+~])"+et+"*"),ct=RegExp(ot),ft=RegExp("^"+nt+"$"),pt={ID:RegExp("^#("+tt+")"),CLASS:RegExp("^\\.("+tt+")"),NAME:RegExp("^\\[name=['\"]?("+tt+")['\"]?\\]"),TAG:RegExp("^("+tt.replace("w","w*")+")"),ATTR:RegExp("^"+it),PSEUDO:RegExp("^"+ot),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+et+"*(even|odd|(([+-]|)(\\d*)n|)"+et+"*(?:([+-]|)"+et+"*(\\d+)|))"+et+"*\\)|)","i"),needsContext:RegExp("^"+et+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+et+"*((?:-\\d)?\\d*)"+et+"*\\)|)(?=[^-]|$)","i")},dt=/[\x20\t\r\n\f]*[+~]/,ht=/\{\s*\[native code\]\s*\}/,gt=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,mt=/^(?:input|select|textarea|button)$/i,yt=/^h\d$/i,vt=/'|\\/g,bt=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,xt=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,Tt=function(e,t){var n="0x"+t-65536;return n!==n?t:0>n?String.fromCharCode(n+65536):String.fromCharCode(55296|n>>10,56320|1023&n)};try{K.call(H.childNodes,0)[0].nodeType}catch(wt){K=function(e){for(var t,n=[];t=this[e];e++)n.push(t);return n}}E=a.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},D=a.setDocument=function(e){var r=e?e.ownerDocument||e:R;return r!==L&&9===r.nodeType&&r.documentElement?(L=r,H=r.documentElement,M=E(r),W.tagNameNoComments=o(function(e){return e.appendChild(r.createComment("")),!e.getElementsByTagName("*").length}),W.attributes=o(function(e){e.innerHTML="<select></select>";var t=typeof e.lastChild.getAttribute("multiple");return"boolean"!==t&&"string"!==t}),W.getByClassName=o(function(e){return e.innerHTML="<div class='hidden e'></div><div class='hidden'></div>",e.getElementsByClassName&&e.getElementsByClassName("e").length?(e.lastChild.className="e",2===e.getElementsByClassName("e").length):!1}),W.getByName=o(function(e){e.id=P+0,e.innerHTML="<a name='"+P+"'></a><div name='"+P+"'></div>",H.insertBefore(e,H.firstChild);var t=r.getElementsByName&&r.getElementsByName(P).length===2+r.getElementsByName(P+0).length;return W.getIdNotName=!r.getElementById(P),H.removeChild(e),t}),C.attrHandle=o(function(e){return e.innerHTML="<a href='#'></a>",e.firstChild&&typeof e.firstChild.getAttribute!==V&&"#"===e.firstChild.getAttribute("href")})?{}:{href:function(e){return e.getAttribute("href",2)},type:function(e){return e.getAttribute("type")}},W.getIdNotName?(C.find.ID=function(e,t){if(typeof t.getElementById!==V&&!M){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},C.filter.ID=function(e){var t=e.replace(xt,Tt);return function(e){return e.getAttribute("id")===t}}):(C.find.ID=function(e,n){if(typeof n.getElementById!==V&&!M){var r=n.getElementById(e);return r?r.id===e||typeof r.getAttributeNode!==V&&r.getAttributeNode("id").value===e?[r]:t:[]}},C.filter.ID=function(e){var t=e.replace(xt,Tt);return function(e){var n=typeof e.getAttributeNode!==V&&e.getAttributeNode("id");return n&&n.value===t}}),C.find.TAG=W.tagNameNoComments?function(e,n){return typeof n.getElementsByTagName!==V?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i];i++)1===n.nodeType&&r.push(n);return r}return o},C.find.NAME=W.getByName&&function(e,n){return typeof n.getElementsByName!==V?n.getElementsByName(name):t},C.find.CLASS=W.getByClassName&&function(e,n){return typeof n.getElementsByClassName===V||M?t:n.getElementsByClassName(e)},_=[],q=[":focus"],(W.qsa=n(r.querySelectorAll))&&(o(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||q.push("\\["+et+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),e.querySelectorAll(":checked").length||q.push(":checked")}),o(function(e){e.innerHTML="<input type='hidden' i=''/>",e.querySelectorAll("[i^='']").length&&q.push("[*^$]="+et+"*(?:\"\"|'')"),e.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),q.push(",.*:")})),(W.matchesSelector=n(F=H.matchesSelector||H.mozMatchesSelector||H.webkitMatchesSelector||H.oMatchesSelector||H.msMatchesSelector))&&o(function(e){W.disconnectedMatch=F.call(e,"div"),F.call(e,"[s!='']:x"),_.push("!=",ot)}),q=RegExp(q.join("|")),_=RegExp(_.join("|")),O=n(H.contains)||H.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},B=H.compareDocumentPosition?function(e,t){var n;return e===t?(A=!0,0):(n=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t))?1&n||e.parentNode&&11===e.parentNode.nodeType?e===r||O(R,e)?-1:t===r||O(R,t)?1:0:4&n?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var n,i=0,o=e.parentNode,a=t.parentNode,u=[e],l=[t];if(e===t)return A=!0,0;if(e.sourceIndex&&t.sourceIndex)return(~t.sourceIndex||Y)-(O(R,e)&&~e.sourceIndex||Y);if(!o||!a)return e===r?-1:t===r?1:o?-1:a?1:0;if(o===a)return s(e,t);for(n=e;n=n.parentNode;)u.unshift(n);for(n=t;n=n.parentNode;)l.unshift(n);for(;u[i]===l[i];)i++;return i?s(u[i],l[i]):u[i]===R?-1:l[i]===R?1:0},A=!1,[0,0].sort(B),W.detectDuplicates=A,L):L},a.matches=function(e,t){return a(e,null,null,t)},a.matchesSelector=function(e,t){if((e.ownerDocument||e)!==L&&D(e),t=t.replace(bt,"='$1']"),!(!W.matchesSelector||M||_&&_.test(t)||q.test(t)))try{var n=F.call(e,t);if(n||W.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(r){}return a(t,L,null,[e]).length>0},a.contains=function(e,t){return(e.ownerDocument||e)!==L&&D(e),O(e,t)},a.attr=function(e,t){var n;return(e.ownerDocument||e)!==L&&D(e),M||(t=t.toLowerCase()),(n=C.attrHandle[t])?n(e):M||W.attributes?e.getAttribute(t):((n=e.getAttributeNode(t))||e.getAttribute(t))&&e[t]===!0?t:n&&n.specified?n.value:null},a.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},a.uniqueSort=function(e){var t,n=[],r=1,i=0;if(A=!W.detectDuplicates,e.sort(B),A){for(;t=e[r];r++)t===e[r-1]&&(i=n.push(r));for(;i--;)e.splice(n[i],1)}return e},k=a.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=k(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=k(t);return n},C=a.selectors={cacheLength:50,createPseudo:i,match:pt,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(xt,Tt),e[3]=(e[4]||e[5]||"").replace(xt,Tt),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||a.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&a.error(e[0]),e},PSEUDO:function(e){var t,n=!e[5]&&e[2];return pt.CHILD.test(e[0])?null:(e[4]?e[2]=e[4]:n&&ct.test(n)&&(t=f(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){return"*"===e?function(){return!0}:(e=e.replace(xt,Tt).toLowerCase(),function(t){return t.nodeName&&t.nodeName.toLowerCase()===e})},CLASS:function(e){var t=z[e+" "];return t||(t=RegExp("(^|"+et+")"+e+"("+et+"|$)"))&&z(e,function(e){return t.test(e.className||typeof e.getAttribute!==V&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=a.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.substr(i.length-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.substr(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,p,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s;if(m){if(o){for(;g;){for(f=t;f=f[g];)if(s?f.nodeName.toLowerCase()===y:1===f.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){for(c=m[P]||(m[P]={}),l=c[e]||[],d=l[0]===$&&l[1],p=l[0]===$&&l[2],f=d&&m.childNodes[d];f=++d&&f&&f[g]||(p=d=0)||h.pop();)if(1===f.nodeType&&++p&&f===t){c[e]=[$,d,p];break}}else if(v&&(l=(t[P]||(t[P]={}))[e])&&l[0]===$)p=l[1];else for(;(f=++d&&f&&f[g]||(p=d=0)||h.pop())&&((s?f.nodeName.toLowerCase()!==y:1!==f.nodeType)||!++p||(v&&((f[P]||(f[P]={}))[e]=[$,p]),f!==t)););return p-=i,p===r||0===p%r&&p/r>=0}}},PSEUDO:function(e,t){var n,r=C.pseudos[e]||C.setFilters[e.toLowerCase()]||a.error("unsupported pseudo: "+e);return r[P]?r(t):r.length>1?(n=[e,e,"",t],C.setFilters.hasOwnProperty(e.toLowerCase())?i(function(e,n){for(var i,o=r(e,t),a=o.length;a--;)i=Z.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:i(function(e){var t=[],n=[],r=S(e.replace(at,"$1"));return r[P]?i(function(e,t,n,i){for(var o,a=r(e,null,i,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:i(function(e){return function(t){return a(e,t).length>0}}),contains:i(function(e){return function(t){return(t.textContent||t.innerText||k(t)).indexOf(e)>-1}}),lang:i(function(e){return ft.test(e||"")||a.error("unsupported lang: "+e),e=e.replace(xt,Tt).toLowerCase(),function(t){var n;do if(n=M?t.getAttribute("xml:lang")||t.getAttribute("lang"):t.lang)return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===H},focus:function(e){return e===L.activeElement&&(!L.hasFocus||L.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!C.pseudos.empty(e)},header:function(e){return yt.test(e.nodeName)},input:function(e){return mt.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:c(function(){return[0]}),last:c(function(e,t){return[t-1]}),eq:c(function(e,t,n){return[0>n?n+t:n]}),even:c(function(e,t){for(var n=0;t>n;n+=2)e.push(n);return e}),odd:c(function(e,t){for(var n=1;t>n;n+=2)e.push(n);return e}),lt:c(function(e,t,n){for(var r=0>n?n+t:n;--r>=0;)e.push(r);return e}),gt:c(function(e,t,n){for(var r=0>n?n+t:n;t>++r;)e.push(r);return e})}};for(w in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})C.pseudos[w]=u(w);for(w in{submit:!0,reset:!0})C.pseudos[w]=l(w);S=a.compile=function(e,t){var n,r=[],i=[],o=U[e+" "];if(!o){for(t||(t=f(e)),n=t.length;n--;)o=y(t[n]),o[P]?r.push(o):i.push(o);o=U(e,v(i,r))}return o},C.pseudos.nth=C.pseudos.eq,C.filters=T.prototype=C.pseudos,C.setFilters=new T,D(),a.attr=st.attr,st.find=a,st.expr=a.selectors,st.expr[":"]=st.expr.pseudos,st.unique=a.uniqueSort,st.text=a.getText,st.isXMLDoc=a.isXML,st.contains=a.contains}(e);var Pt=/Until$/,Rt=/^(?:parents|prev(?:Until|All))/,Wt=/^.[^:#\[\.,]*$/,$t=st.expr.match.needsContext,It={children:!0,contents:!0,next:!0,prev:!0};st.fn.extend({find:function(e){var t,n,r;if("string"!=typeof e)return r=this,this.pushStack(st(e).filter(function(){for(t=0;r.length>t;t++)if(st.contains(r[t],this))return!0}));for(n=[],t=0;this.length>t;t++)st.find(e,this[t],n);return n=this.pushStack(st.unique(n)),n.selector=(this.selector?this.selector+" ":"")+e,n},has:function(e){var t,n=st(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(st.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(f(this,e,!1))},filter:function(e){return this.pushStack(f(this,e,!0))},is:function(e){return!!e&&("string"==typeof e?$t.test(e)?st(e,this.context).index(this[0])>=0:st.filter(e,this).length>0:this.filter(e).length>0)},closest:function(e,t){for(var n,r=0,i=this.length,o=[],a=$t.test(e)||"string"!=typeof e?st(e,t||this.context):0;i>r;r++)for(n=this[r];n&&n.ownerDocument&&n!==t&&11!==n.nodeType;){if(a?a.index(n)>-1:st.find.matchesSelector(n,e)){o.push(n);break}n=n.parentNode}return this.pushStack(o.length>1?st.unique(o):o)},index:function(e){return e?"string"==typeof e?st.inArray(this[0],st(e)):st.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?st(e,t):st.makeArray(e&&e.nodeType?[e]:e),r=st.merge(this.get(),n);return this.pushStack(st.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),st.fn.andSelf=st.fn.addBack,st.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return st.dir(e,"parentNode")},parentsUntil:function(e,t,n){return st.dir(e,"parentNode",n)},next:function(e){return c(e,"nextSibling")},prev:function(e){return c(e,"previousSibling")
+},nextAll:function(e){return st.dir(e,"nextSibling")},prevAll:function(e){return st.dir(e,"previousSibling")},nextUntil:function(e,t,n){return st.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return st.dir(e,"previousSibling",n)},siblings:function(e){return st.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return st.sibling(e.firstChild)},contents:function(e){return st.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:st.merge([],e.childNodes)}},function(e,t){st.fn[e]=function(n,r){var i=st.map(this,t,n);return Pt.test(e)||(r=n),r&&"string"==typeof r&&(i=st.filter(r,i)),i=this.length>1&&!It[e]?st.unique(i):i,this.length>1&&Rt.test(e)&&(i=i.reverse()),this.pushStack(i)}}),st.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?st.find.matchesSelector(t[0],e)?[t[0]]:[]:st.find.matches(e,t)},dir:function(e,n,r){for(var i=[],o=e[n];o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!st(o).is(r));)1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});var zt="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Xt=/ jQuery\d+="(?:null|\d+)"/g,Ut=RegExp("<(?:"+zt+")[\\s/>]","i"),Vt=/^\s+/,Yt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Jt=/<([\w:]+)/,Gt=/<tbody/i,Qt=/<|&#?\w+;/,Kt=/<(?:script|style|link)/i,Zt=/^(?:checkbox|radio)$/i,en=/checked\s*(?:[^=]|=\s*.checked.)/i,tn=/^$|\/(?:java|ecma)script/i,nn=/^true\/(.*)/,rn=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,on={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:st.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},an=p(V),sn=an.appendChild(V.createElement("div"));on.optgroup=on.option,on.tbody=on.tfoot=on.colgroup=on.caption=on.thead,on.th=on.td,st.fn.extend({text:function(e){return st.access(this,function(e){return e===t?st.text(this):this.empty().append((this[0]&&this[0].ownerDocument||V).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(st.isFunction(e))return this.each(function(t){st(this).wrapAll(e.call(this,t))});if(this[0]){var t=st(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstChild&&1===e.firstChild.nodeType;)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return st.isFunction(e)?this.each(function(t){st(this).wrapInner(e.call(this,t))}):this.each(function(){var t=st(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=st.isFunction(e);return this.each(function(n){st(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){st.nodeName(this,"body")||st(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){for(var n,r=0;null!=(n=this[r]);r++)(!e||st.filter(e,[n]).length>0)&&(t||1!==n.nodeType||st.cleanData(b(n)),n.parentNode&&(t&&st.contains(n.ownerDocument,n)&&m(b(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){for(var e,t=0;null!=(e=this[t]);t++){for(1===e.nodeType&&st.cleanData(b(e,!1));e.firstChild;)e.removeChild(e.firstChild);e.options&&st.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return st.clone(this,e,t)})},html:function(e){return st.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(Xt,""):t;if(!("string"!=typeof e||Kt.test(e)||!st.support.htmlSerialize&&Ut.test(e)||!st.support.leadingWhitespace&&Vt.test(e)||on[(Jt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(Yt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(st.cleanData(b(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=st.isFunction(e);return t||"string"==typeof e||(e=st(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;(n&&1===this.nodeType||11===this.nodeType)&&(st(this).remove(),t?t.parentNode.insertBefore(e,t):n.appendChild(e))})},detach:function(e){return this.remove(e,!0)},domManip:function(e,n,r){e=et.apply([],e);var i,o,a,s,u,l,c=0,f=this.length,p=this,m=f-1,y=e[0],v=st.isFunction(y);if(v||!(1>=f||"string"!=typeof y||st.support.checkClone)&&en.test(y))return this.each(function(i){var o=p.eq(i);v&&(e[0]=y.call(this,i,n?o.html():t)),o.domManip(e,n,r)});if(f&&(i=st.buildFragment(e,this[0].ownerDocument,!1,this),o=i.firstChild,1===i.childNodes.length&&(i=o),o)){for(n=n&&st.nodeName(o,"tr"),a=st.map(b(i,"script"),h),s=a.length;f>c;c++)u=i,c!==m&&(u=st.clone(u,!0,!0),s&&st.merge(a,b(u,"script"))),r.call(n&&st.nodeName(this[c],"table")?d(this[c],"tbody"):this[c],u,c);if(s)for(l=a[a.length-1].ownerDocument,st.map(a,g),c=0;s>c;c++)u=a[c],tn.test(u.type||"")&&!st._data(u,"globalEval")&&st.contains(l,u)&&(u.src?st.ajax({url:u.src,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0}):st.globalEval((u.text||u.textContent||u.innerHTML||"").replace(rn,"")));i=o=null}return this}}),st.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){st.fn[e]=function(e){for(var n,r=0,i=[],o=st(e),a=o.length-1;a>=r;r++)n=r===a?this:this.clone(!0),st(o[r])[t](n),tt.apply(i,n.get());return this.pushStack(i)}}),st.extend({clone:function(e,t,n){var r,i,o,a,s,u=st.contains(e.ownerDocument,e);if(st.support.html5Clone||st.isXMLDoc(e)||!Ut.test("<"+e.nodeName+">")?s=e.cloneNode(!0):(sn.innerHTML=e.outerHTML,sn.removeChild(s=sn.firstChild)),!(st.support.noCloneEvent&&st.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||st.isXMLDoc(e)))for(r=b(s),i=b(e),a=0;null!=(o=i[a]);++a)r[a]&&v(o,r[a]);if(t)if(n)for(i=i||b(e),r=r||b(s),a=0;null!=(o=i[a]);a++)y(o,r[a]);else y(e,s);return r=b(s,"script"),r.length>0&&m(r,!u&&b(e,"script")),r=i=o=null,s},buildFragment:function(e,t,n,r){for(var i,o,a,s,u,l,c,f=e.length,d=p(t),h=[],g=0;f>g;g++)if(o=e[g],o||0===o)if("object"===st.type(o))st.merge(h,o.nodeType?[o]:o);else if(Qt.test(o)){for(s=s||d.appendChild(t.createElement("div")),a=(Jt.exec(o)||["",""])[1].toLowerCase(),u=on[a]||on._default,s.innerHTML=u[1]+o.replace(Yt,"<$1></$2>")+u[2],c=u[0];c--;)s=s.lastChild;if(!st.support.leadingWhitespace&&Vt.test(o)&&h.push(t.createTextNode(Vt.exec(o)[0])),!st.support.tbody)for(o="table"!==a||Gt.test(o)?"<table>"!==u[1]||Gt.test(o)?0:s:s.firstChild,c=o&&o.childNodes.length;c--;)st.nodeName(l=o.childNodes[c],"tbody")&&!l.childNodes.length&&o.removeChild(l);for(st.merge(h,s.childNodes),s.textContent="";s.firstChild;)s.removeChild(s.firstChild);s=d.lastChild}else h.push(t.createTextNode(o));for(s&&d.removeChild(s),st.support.appendChecked||st.grep(b(h,"input"),x),g=0;o=h[g++];)if((!r||-1===st.inArray(o,r))&&(i=st.contains(o.ownerDocument,o),s=b(d.appendChild(o),"script"),i&&m(s),n))for(c=0;o=s[c++];)tn.test(o.type||"")&&n.push(o);return s=null,d},cleanData:function(e,n){for(var r,i,o,a,s=0,u=st.expando,l=st.cache,c=st.support.deleteExpando,f=st.event.special;null!=(o=e[s]);s++)if((n||st.acceptData(o))&&(i=o[u],r=i&&l[i])){if(r.events)for(a in r.events)f[a]?st.event.remove(o,a):st.removeEvent(o,a,r.handle);l[i]&&(delete l[i],c?delete o[u]:o.removeAttribute!==t?o.removeAttribute(u):o[u]=null,K.push(i))}}});var un,ln,cn,fn=/alpha\([^)]*\)/i,pn=/opacity\s*=\s*([^)]*)/,dn=/^(top|right|bottom|left)$/,hn=/^(none|table(?!-c[ea]).+)/,gn=/^margin/,mn=RegExp("^("+ut+")(.*)$","i"),yn=RegExp("^("+ut+")(?!px)[a-z%]+$","i"),vn=RegExp("^([+-])=("+ut+")","i"),bn={BODY:"block"},xn={position:"absolute",visibility:"hidden",display:"block"},Tn={letterSpacing:0,fontWeight:400},wn=["Top","Right","Bottom","Left"],Nn=["Webkit","O","Moz","ms"];st.fn.extend({css:function(e,n){return st.access(this,function(e,n,r){var i,o,a={},s=0;if(st.isArray(n)){for(i=ln(e),o=n.length;o>s;s++)a[n[s]]=st.css(e,n[s],!1,i);return a}return r!==t?st.style(e,n,r):st.css(e,n)},e,n,arguments.length>1)},show:function(){return N(this,!0)},hide:function(){return N(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:w(this))?st(this).show():st(this).hide()})}}),st.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=un(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":st.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,u=st.camelCase(n),l=e.style;if(n=st.cssProps[u]||(st.cssProps[u]=T(l,u)),s=st.cssHooks[n]||st.cssHooks[u],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:l[n];if(a=typeof r,"string"===a&&(o=vn.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(st.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||st.cssNumber[u]||(r+="px"),st.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(l[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{l[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,u=st.camelCase(n);return n=st.cssProps[u]||(st.cssProps[u]=T(e.style,u)),s=st.cssHooks[n]||st.cssHooks[u],s&&"get"in s&&(o=s.get(e,!0,r)),o===t&&(o=un(e,n,i)),"normal"===o&&n in Tn&&(o=Tn[n]),r?(a=parseFloat(o),r===!0||st.isNumeric(a)?a||0:o):o},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),e.getComputedStyle?(ln=function(t){return e.getComputedStyle(t,null)},un=function(e,n,r){var i,o,a,s=r||ln(e),u=s?s.getPropertyValue(n)||s[n]:t,l=e.style;return s&&(""!==u||st.contains(e.ownerDocument,e)||(u=st.style(e,n)),yn.test(u)&&gn.test(n)&&(i=l.width,o=l.minWidth,a=l.maxWidth,l.minWidth=l.maxWidth=l.width=u,u=s.width,l.width=i,l.minWidth=o,l.maxWidth=a)),u}):V.documentElement.currentStyle&&(ln=function(e){return e.currentStyle},un=function(e,n,r){var i,o,a,s=r||ln(e),u=s?s[n]:t,l=e.style;return null==u&&l&&l[n]&&(u=l[n]),yn.test(u)&&!dn.test(n)&&(i=l.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),l.left="fontSize"===n?"1em":u,u=l.pixelLeft+"px",l.left=i,a&&(o.left=a)),""===u?"auto":u}),st.each(["height","width"],function(e,n){st.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&hn.test(st.css(e,"display"))?st.swap(e,xn,function(){return E(e,n,i)}):E(e,n,i):t},set:function(e,t,r){var i=r&&ln(e);return C(e,t,r?k(e,n,r,st.support.boxSizing&&"border-box"===st.css(e,"boxSizing",!1,i),i):0)}}}),st.support.opacity||(st.cssHooks.opacity={get:function(e,t){return pn.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=st.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===st.trim(o.replace(fn,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=fn.test(o)?o.replace(fn,i):o+" "+i)}}),st(function(){st.support.reliableMarginRight||(st.cssHooks.marginRight={get:function(e,n){return n?st.swap(e,{display:"inline-block"},un,[e,"marginRight"]):t}}),!st.support.pixelPosition&&st.fn.position&&st.each(["top","left"],function(e,n){st.cssHooks[n]={get:function(e,r){return r?(r=un(e,n),yn.test(r)?st(e).position()[n]+"px":r):t}}})}),st.expr&&st.expr.filters&&(st.expr.filters.hidden=function(e){return 0===e.offsetWidth&&0===e.offsetHeight||!st.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||st.css(e,"display"))},st.expr.filters.visible=function(e){return!st.expr.filters.hidden(e)}),st.each({margin:"",padding:"",border:"Width"},function(e,t){st.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];4>r;r++)i[e+wn[r]+t]=o[r]||o[r-2]||o[0];return i}},gn.test(e)||(st.cssHooks[e+t].set=C)});var Cn=/%20/g,kn=/\[\]$/,En=/\r?\n/g,Sn=/^(?:submit|button|image|reset)$/i,An=/^(?:input|select|textarea|keygen)/i;st.fn.extend({serialize:function(){return st.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=st.prop(this,"elements");return e?st.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!st(this).is(":disabled")&&An.test(this.nodeName)&&!Sn.test(e)&&(this.checked||!Zt.test(e))}).map(function(e,t){var n=st(this).val();return null==n?null:st.isArray(n)?st.map(n,function(e){return{name:t.name,value:e.replace(En,"\r\n")}}):{name:t.name,value:n.replace(En,"\r\n")}}).get()}}),st.param=function(e,n){var r,i=[],o=function(e,t){t=st.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=st.ajaxSettings&&st.ajaxSettings.traditional),st.isArray(e)||e.jquery&&!st.isPlainObject(e))st.each(e,function(){o(this.name,this.value)});else for(r in e)j(r,e[r],n,o);return i.join("&").replace(Cn,"+")};var jn,Dn,Ln=st.now(),Hn=/\?/,Mn=/#.*$/,qn=/([?&])_=[^&]*/,_n=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Fn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,On=/^(?:GET|HEAD)$/,Bn=/^\/\//,Pn=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Rn=st.fn.load,Wn={},$n={},In="*/".concat("*");try{Dn=Y.href}catch(zn){Dn=V.createElement("a"),Dn.href="",Dn=Dn.href}jn=Pn.exec(Dn.toLowerCase())||[],st.fn.load=function(e,n,r){if("string"!=typeof e&&Rn)return Rn.apply(this,arguments);var i,o,a,s=this,u=e.indexOf(" ");return u>=0&&(i=e.slice(u,e.length),e=e.slice(0,u)),st.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(o="POST"),s.length>0&&st.ajax({url:e,type:o,dataType:"html",data:n}).done(function(e){a=arguments,s.html(i?st("<div>").append(st.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,a||[e.responseText,t,e])}),this},st.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){st.fn[t]=function(e){return this.on(t,e)}}),st.each(["get","post"],function(e,n){st[n]=function(e,r,i,o){return st.isFunction(r)&&(o=o||i,i=r,r=t),st.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),st.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Dn,type:"GET",isLocal:Fn.test(jn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":In,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":st.parseJSON,"text xml":st.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?H(H(e,st.ajaxSettings),t):H(st.ajaxSettings,e)},ajaxPrefilter:D(Wn),ajaxTransport:D($n),ajax:function(e,n){function r(e,n,r,s){var l,f,v,b,T,N=n;2!==x&&(x=2,u&&clearTimeout(u),i=t,a=s||"",w.readyState=e>0?4:0,r&&(b=M(p,w,r)),e>=200&&300>e||304===e?(p.ifModified&&(T=w.getResponseHeader("Last-Modified"),T&&(st.lastModified[o]=T),T=w.getResponseHeader("etag"),T&&(st.etag[o]=T)),304===e?(l=!0,N="notmodified"):(l=q(p,b),N=l.state,f=l.data,v=l.error,l=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),w.status=e,w.statusText=(n||N)+"",l?g.resolveWith(d,[f,N,w]):g.rejectWith(d,[w,N,v]),w.statusCode(y),y=t,c&&h.trigger(l?"ajaxSuccess":"ajaxError",[w,p,l?f:v]),m.fireWith(d,[w,N]),c&&(h.trigger("ajaxComplete",[w,p]),--st.active||st.event.trigger("ajaxStop")))}"object"==typeof e&&(n=e,e=t),n=n||{};var i,o,a,s,u,l,c,f,p=st.ajaxSetup({},n),d=p.context||p,h=p.context&&(d.nodeType||d.jquery)?st(d):st.event,g=st.Deferred(),m=st.Callbacks("once memory"),y=p.statusCode||{},v={},b={},x=0,T="canceled",w={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!s)for(s={};t=_n.exec(a);)s[t[1].toLowerCase()]=t[2];t=s[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=b[n]=b[n]||e,v[e]=t),this},overrideMimeType:function(e){return x||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)y[t]=[y[t],e[t]];else w.always(e[w.status]);return this},abort:function(e){var t=e||T;return i&&i.abort(t),r(0,t),this}};if(g.promise(w).complete=m.add,w.success=w.done,w.error=w.fail,p.url=((e||p.url||Dn)+"").replace(Mn,"").replace(Bn,jn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=st.trim(p.dataType||"*").toLowerCase().match(lt)||[""],null==p.crossDomain&&(l=Pn.exec(p.url.toLowerCase()),p.crossDomain=!(!l||l[1]===jn[1]&&l[2]===jn[2]&&(l[3]||("http:"===l[1]?80:443))==(jn[3]||("http:"===jn[1]?80:443)))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=st.param(p.data,p.traditional)),L(Wn,p,n,w),2===x)return w;c=p.global,c&&0===st.active++&&st.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!On.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(Hn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=qn.test(o)?o.replace(qn,"$1_="+Ln++):o+(Hn.test(o)?"&":"?")+"_="+Ln++)),p.ifModified&&(st.lastModified[o]&&w.setRequestHeader("If-Modified-Since",st.lastModified[o]),st.etag[o]&&w.setRequestHeader("If-None-Match",st.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&w.setRequestHeader("Content-Type",p.contentType),w.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+In+"; q=0.01":""):p.accepts["*"]);for(f in p.headers)w.setRequestHeader(f,p.headers[f]);if(p.beforeSend&&(p.beforeSend.call(d,w,p)===!1||2===x))return w.abort();T="abort";for(f in{success:1,error:1,complete:1})w[f](p[f]);if(i=L($n,p,n,w)){w.readyState=1,c&&h.trigger("ajaxSend",[w,p]),p.async&&p.timeout>0&&(u=setTimeout(function(){w.abort("timeout")},p.timeout));try{x=1,i.send(v,r)}catch(N){if(!(2>x))throw N;r(-1,N)}}else r(-1,"No Transport");return w},getScript:function(e,n){return st.get(e,t,n,"script")},getJSON:function(e,t,n){return st.get(e,t,n,"json")}}),st.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return st.globalEval(e),e}}}),st.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),st.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=V.head||st("head")[0]||V.documentElement;return{send:function(t,i){n=V.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Xn=[],Un=/(=)\?(?=&|$)|\?\?/;st.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Xn.pop()||st.expando+"_"+Ln++;return this[e]=!0,e}}),st.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,u=n.jsonp!==!1&&(Un.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Un.test(n.data)&&"data");return u||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=st.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,u?n[u]=n[u].replace(Un,"$1"+o):n.jsonp!==!1&&(n.url+=(Hn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||st.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Xn.push(o)),s&&st.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Vn,Yn,Jn=0,Gn=e.ActiveXObject&&function(){var e;for(e in Vn)Vn[e](t,!0)};st.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&_()||F()}:_,Yn=st.ajaxSettings.xhr(),st.support.cors=!!Yn&&"withCredentials"in Yn,Yn=st.support.ajax=!!Yn,Yn&&st.ajaxTransport(function(n){if(!n.crossDomain||st.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,f,p;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=st.noop,Gn&&delete Vn[a]),i)4!==u.readyState&&u.abort();else{f={},s=u.status,p=u.responseXML,c=u.getAllResponseHeaders(),p&&p.documentElement&&(f.xml=p),"string"==typeof u.responseText&&(f.text=u.responseText);try{l=u.statusText}catch(d){l=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=f.text?200:404}}catch(h){i||o(-1,h)}f&&o(s,l,f,c)},n.async?4===u.readyState?setTimeout(r):(a=++Jn,Gn&&(Vn||(Vn={},st(e).unload(Gn)),Vn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Qn,Kn,Zn=/^(?:toggle|show|hide)$/,er=RegExp("^(?:([+-])=|)("+ut+")([a-z%]*)$","i"),tr=/queueHooks$/,nr=[W],rr={"*":[function(e,t){var n,r,i=this.createTween(e,t),o=er.exec(t),a=i.cur(),s=+a||0,u=1,l=20;if(o){if(n=+o[2],r=o[3]||(st.cssNumber[e]?"":"px"),"px"!==r&&s){s=st.css(i.elem,e,!0)||n||1;do u=u||".5",s/=u,st.style(i.elem,e,s+r);while(u!==(u=i.cur()/a)&&1!==u&&--l)}i.unit=r,i.start=s,i.end=o[1]?s+(o[1]+1)*n:n}return i}]};st.Animation=st.extend(P,{tweener:function(e,t){st.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");for(var n,r=0,i=e.length;i>r;r++)n=e[r],rr[n]=rr[n]||[],rr[n].unshift(t)},prefilter:function(e,t){t?nr.unshift(e):nr.push(e)}}),st.Tween=$,$.prototype={constructor:$,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(st.cssNumber[n]?"":"px")},cur:function(){var e=$.propHooks[this.prop];return e&&e.get?e.get(this):$.propHooks._default.get(this)},run:function(e){var t,n=$.propHooks[this.prop];return this.pos=t=this.options.duration?st.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):$.propHooks._default.set(this),this}},$.prototype.init.prototype=$.prototype,$.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=st.css(e.elem,e.prop,"auto"),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){st.fx.step[e.prop]?st.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[st.cssProps[e.prop]]||st.cssHooks[e.prop])?st.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},$.propHooks.scrollTop=$.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},st.each(["toggle","show","hide"],function(e,t){var n=st.fn[t];st.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(I(t,!0),e,r,i)}}),st.fn.extend({fadeTo:function(e,t,n,r){return this.filter(w).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=st.isEmptyObject(e),o=st.speed(t,n,r),a=function(){var t=P(this,st.extend({},e),o);a.finish=function(){t.stop(!0)},(i||st._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=st.timers,a=st._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&tr.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&st.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=st._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=st.timers,a=r?r.length:0;for(n.finish=!0,st.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}}),st.each({slideDown:I("show"),slideUp:I("hide"),slideToggle:I("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){st.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),st.speed=function(e,t,n){var r=e&&"object"==typeof e?st.extend({},e):{complete:n||!n&&t||st.isFunction(e)&&e,duration:e,easing:n&&t||t&&!st.isFunction(t)&&t};return r.duration=st.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in st.fx.speeds?st.fx.speeds[r.duration]:st.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){st.isFunction(r.old)&&r.old.call(this),r.queue&&st.dequeue(this,r.queue)},r},st.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},st.timers=[],st.fx=$.prototype.init,st.fx.tick=function(){var e,n=st.timers,r=0;for(Qn=st.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||st.fx.stop(),Qn=t},st.fx.timer=function(e){e()&&st.timers.push(e)&&st.fx.start()},st.fx.interval=13,st.fx.start=function(){Kn||(Kn=setInterval(st.fx.tick,st.fx.interval))},st.fx.stop=function(){clearInterval(Kn),Kn=null},st.fx.speeds={slow:600,fast:200,_default:400},st.fx.step={},st.expr&&st.expr.filters&&(st.expr.filters.animated=function(e){return st.grep(st.timers,function(t){return e===t.elem}).length}),st.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){st.offset.setOffset(this,e,t)});var n,r,i={top:0,left:0},o=this[0],a=o&&o.ownerDocument;if(a)return n=a.documentElement,st.contains(n,o)?(o.getBoundingClientRect!==t&&(i=o.getBoundingClientRect()),r=z(a),{top:i.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:i.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):i},st.offset={setOffset:function(e,t,n){var r=st.css(e,"position");"static"===r&&(e.style.position="relative");var i,o,a=st(e),s=a.offset(),u=st.css(e,"top"),l=st.css(e,"left"),c=("absolute"===r||"fixed"===r)&&st.inArray("auto",[u,l])>-1,f={},p={};c?(p=a.position(),i=p.top,o=p.left):(i=parseFloat(u)||0,o=parseFloat(l)||0),st.isFunction(t)&&(t=t.call(e,n,s)),null!=t.top&&(f.top=t.top-s.top+i),null!=t.left&&(f.left=t.left-s.left+o),"using"in t?t.using.call(e,f):a.css(f)}},st.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===st.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),st.nodeName(e[0],"html")||(n=e.offset()),n.top+=st.css(e[0],"borderTopWidth",!0),n.left+=st.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-st.css(r,"marginTop",!0),left:t.left-n.left-st.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var e=this.offsetParent||V.documentElement;e&&!st.nodeName(e,"html")&&"static"===st.css(e,"position");)e=e.offsetParent;return e||V.documentElement})}}),st.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);st.fn[e]=function(i){return st.access(this,function(e,i,o){var a=z(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?st(a).scrollLeft():o,r?o:st(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}}),st.each({Height:"height",Width:"width"},function(e,n){st.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){st.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return st.access(this,function(n,r,i){var o;return st.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?st.css(n,r,s):st.style(n,r,i,s)},n,a?i:t,a,null)}})}),e.jQuery=e.$=st,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return st})})(window);
+//@ sourceMappingURL=jquery.min.map
\ No newline at end of file
diff --git a/portal/static/reputation_static/js/jquery.raty.min.js b/portal/static/reputation_static/js/jquery.raty.min.js
new file mode 100644 (file)
index 0000000..bc73d7e
--- /dev/null
@@ -0,0 +1,12 @@
+/*!
+ * jQuery Raty - A Star Rating Plugin
+ *
+ * Licensed under The MIT License
+ *
+ * @version        2.4.5
+ * @author         Washington Botelho
+ * @documentation  wbotelhos.com/raty
+ * 
+ */
+
+;(function(b){var a={init:function(c){return this.each(function(){var d=this,h=b(d).empty();d.opt=b.extend(true,{},b.fn.raty.defaults,c);h.data("settings",d.opt);d.opt.number=a.between(d.opt.number,0,20);if(d.opt.path.substring(d.opt.path.length-1,d.opt.path.length)!="/"){d.opt.path+="/";}if(typeof d.opt.score=="function"){d.opt.score=d.opt.score.call(d);}if(d.opt.score){d.opt.score=a.between(d.opt.score,0,d.opt.number);}for(var e=1;e<=d.opt.number;e++){b("<img />",{src:d.opt.path+((!d.opt.score||d.opt.score<e)?d.opt.starOff:d.opt.starOn),alt:e,title:(e<=d.opt.hints.length&&d.opt.hints[e-1]!==null)?d.opt.hints[e-1]:e}).appendTo(d);if(d.opt.space){h.append((e<d.opt.number)?"&#160;":"");}}d.stars=h.children('img:not(".raty-cancel")');d.score=b("<input />",{type:"hidden",name:d.opt.scoreName}).appendTo(d);if(d.opt.score&&d.opt.score>0){d.score.val(d.opt.score);a.roundStar.call(d,d.opt.score);}if(d.opt.iconRange){a.fill.call(d,d.opt.score);}a.setTarget.call(d,d.opt.score,d.opt.targetKeep);var g=d.opt.space?4:0,f=d.opt.width||(d.opt.number*d.opt.size+d.opt.number*g);if(d.opt.cancel){d.cancel=b("<img />",{src:d.opt.path+d.opt.cancelOff,alt:"x",title:d.opt.cancelHint,"class":"raty-cancel"});if(d.opt.cancelPlace=="left"){h.prepend("&#160;").prepend(d.cancel);}else{h.append("&#160;").append(d.cancel);}f+=(d.opt.size+g);}if(d.opt.readOnly){a.fixHint.call(d);if(d.cancel){d.cancel.hide();}}else{h.css("cursor","pointer");a.bindAction.call(d);}h.css("width",f);});},between:function(e,d,c){return Math.min(Math.max(parseFloat(e),d),c);},bindAction:function(){var c=this,e=b(c);e.mouseleave(function(){var f=c.score.val()||undefined;a.initialize.call(c,f);a.setTarget.call(c,f,c.opt.targetKeep);if(c.opt.mouseover){c.opt.mouseover.call(c,f);}});var d=c.opt.half?"mousemove":"mouseover";if(c.opt.cancel){c.cancel.mouseenter(function(){b(this).attr("src",c.opt.path+c.opt.cancelOn);c.stars.attr("src",c.opt.path+c.opt.starOff);a.setTarget.call(c,null,true);if(c.opt.mouseover){c.opt.mouseover.call(c,null);}}).mouseleave(function(){b(this).attr("src",c.opt.path+c.opt.cancelOff);if(c.opt.mouseover){c.opt.mouseover.call(c,c.score.val()||null);}}).click(function(f){c.score.removeAttr("value");if(c.opt.click){c.opt.click.call(c,null,f);}});}c.stars.bind(d,function(g){var h=parseInt(this.alt,10);if(c.opt.half){var f=parseFloat((g.pageX-b(this).offset().left)/c.opt.size),i=(f>0.5)?1:0.5;h=parseFloat(this.alt)-1+i;a.fill.call(c,h);if(c.opt.precision){h=h-i+f;}a.showHalf.call(c,h);}else{a.fill.call(c,h);}e.data("score",h);a.setTarget.call(c,h,true);if(c.opt.mouseover){c.opt.mouseover.call(c,h,g);}}).click(function(f){c.score.val((c.opt.half||c.opt.precision)?e.data("score"):this.alt);if(c.opt.click){c.opt.click.call(c,c.score.val(),f);}});},cancel:function(c){return b(this).each(function(){var d=this,e=b(d);if(e.data("readonly")===true){return this;}if(c){a.click.call(d,null);}else{a.score.call(d,null);}d.score.removeAttr("value");});},click:function(c){return b(this).each(function(){if(b(this).data("readonly")===true){return this;}a.initialize.call(this,c);if(this.opt.click){this.opt.click.call(this,c);}else{a.error.call(this,'you must add the "click: function(score, evt) { }" callback.');}a.setTarget.call(this,c,true);});},error:function(c){b(this).html(c);b.error(c);},fill:function(k){var c=this,h=c.stars.length,g=0,d,j,f;for(var e=1;e<=h;e++){d=c.stars.eq(e-1);if(c.opt.iconRange&&c.opt.iconRange.length>g){j=c.opt.iconRange[g];if(c.opt.single){f=(e==k)?(j.on||c.opt.starOn):(j.off||c.opt.starOff);}else{f=(e<=k)?(j.on||c.opt.starOn):(j.off||c.opt.starOff);}if(e<=j.range){d.attr("src",c.opt.path+f);}if(e==j.range){g++;}}else{if(c.opt.single){f=(e==k)?c.opt.starOn:c.opt.starOff;}else{f=(e<=k)?c.opt.starOn:c.opt.starOff;}d.attr("src",c.opt.path+f);}}},fixHint:function(){var c=b(this),e=parseInt(this.score.val(),10),d=this.opt.noRatedMsg;if(!isNaN(e)&&e>0){d=(e<=this.opt.hints.length&&this.opt.hints[e-1]!==null)?this.opt.hints[e-1]:e;}c.data("readonly",true).css("cursor","default").attr("title",d);this.score.attr("readonly","readonly");this.stars.attr("title",d);},getScore:function(){var d=[],c;b(this).each(function(){c=this.score.val();d.push(c?parseFloat(c):undefined);});return(d.length>1)?d:d[0];},readOnly:function(c){return this.each(function(){var d=b(this);if(d.data("readonly")===c){return this;}if(this.cancel){if(c){this.cancel.hide();}else{this.cancel.show();}}if(c){d.unbind();d.children("img").unbind();a.fixHint.call(this);}else{a.bindAction.call(this);a.unfixHint.call(this);}d.data("readonly",c);});},reload:function(){return a.set.call(this,{});},roundStar:function(e){var d=(e-Math.floor(e)).toFixed(2);if(d>this.opt.round.down){var c=this.opt.starOn;if(d<this.opt.round.up&&this.opt.halfShow){c=this.opt.starHalf;}else{if(d<this.opt.round.full){c=this.opt.starOff;}}this.stars.eq(Math.ceil(e)-1).attr("src",this.opt.path+c);}},score:function(){return arguments.length?a.setScore.apply(this,arguments):a.getScore.call(this);},set:function(c){this.each(function(){var d=b(this),f=d.data("settings"),e=d.clone().removeAttr("style").insertBefore(d);d.remove();e.raty(b.extend(f,c));});return b(this.selector);},setScore:function(c){return b(this).each(function(){if(b(this).data("readonly")===true){return this;}a.initialize.call(this,c);a.setTarget.call(this,c,true);});},setTarget:function(e,d){if(this.opt.target){var c=b(this.opt.target);if(c.length==0){a.error.call(this,"target selector invalid or missing!");}var f=e;if(!d||f===undefined){f=this.opt.targetText;}else{if(this.opt.targetType=="hint"){f=(f===null&&this.opt.cancel)?this.opt.cancelHint:this.opt.hints[Math.ceil(f-1)];}else{f=this.opt.precision?parseFloat(f).toFixed(1):parseInt(f,10);}}if(this.opt.targetFormat.indexOf("{score}")<0){a.error.call(this,'template "{score}" missing!');}if(e!==null){f=this.opt.targetFormat.toString().replace("{score}",f);}if(c.is(":input")){c.val(f);}else{c.html(f);}}},showHalf:function(d){var c=(d-Math.floor(d)).toFixed(1);if(c>0&&c<0.6){this.stars.eq(Math.ceil(d)-1).attr("src",this.opt.path+this.opt.starHalf);}},initialize:function(c){c=!c?0:a.between(c,0,this.opt.number);a.fill.call(this,c);if(c>0){if(this.opt.halfShow){a.roundStar.call(this,c);}this.score.val(c);}},unfixHint:function(){for(var c=0;c<this.opt.number;c++){this.stars.eq(c).attr("title",(c<this.opt.hints.length&&this.opt.hints[c]!==null)?this.opt.hints[c]:c);}b(this).data("readonly",false).css("cursor","pointer").removeAttr("title");this.score.attr("readonly","readonly");}};b.fn.raty=function(c){if(a[c]){return a[c].apply(this,Array.prototype.slice.call(arguments,1));}else{if(typeof c==="object"||!c){return a.init.apply(this,arguments);}else{b.error("Method "+c+" does not exist!");}}};b.fn.raty.defaults={cancel:false,cancelHint:"cancel this rating!",cancelOff:"cancel-off.png",cancelOn:"cancel-on.png",cancelPlace:"left",click:undefined,half:false,halfShow:true,hints:["bad","poor","regular","good","gorgeous"],iconRange:undefined,mouseover:undefined,noRatedMsg:"not rated yet",number:5,path:"",precision:false,round:{down:0.25,full:0.6,up:0.76},readOnly:false,score:undefined,scoreName:"score",single:false,size:16,space:true,starHalf:"star-half.png",starOff:"star-off.png",starOn:"star-on.png",target:undefined,targetFormat:"{score}",targetKeep:false,targetText:"",targetType:"hint",width:undefined};})(jQuery);
diff --git a/portal/static/reputation_static/js/ui/jquery-ui-1.9.2.custom.min.js b/portal/static/reputation_static/js/ui/jquery-ui-1.9.2.custom.min.js
new file mode 100644 (file)
index 0000000..d8e985b
--- /dev/null
@@ -0,0 +1,6 @@
+/*! jQuery UI - v1.9.2 - 2013-01-17
+* http://jqueryui.com
+* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.accordion.js, jquery.ui.button.js, jquery.ui.dialog.js, jquery.ui.tabs.js, jquery.ui.tooltip.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-drop.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-slide.js
+* Copyright (c) 2013 jQuery Foundation and other contributors Licensed MIT */
+
+(function(e,t){function i(t,n){var r,i,o,u=t.nodeName.toLowerCase();return"area"===u?(r=t.parentNode,i=r.name,!t.href||!i||r.nodeName.toLowerCase()!=="map"?!1:(o=e("img[usemap=#"+i+"]")[0],!!o&&s(o))):(/input|select|textarea|button|object/.test(u)?!t.disabled:"a"===u?t.href||n:n)&&s(t)}function s(t){return e.expr.filters.visible(t)&&!e(t).parents().andSelf().filter(function(){return e.css(this,"visibility")==="hidden"}).length}var n=0,r=/^ui-id-\d+$/;e.ui=e.ui||{};if(e.ui.version)return;e.extend(e.ui,{version:"1.9.2",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({_focus:e.fn.focus,focus:function(t,n){return typeof t=="number"?this.each(function(){var r=this;setTimeout(function(){e(r).focus(),n&&n.call(r)},t)}):this._focus.apply(this,arguments)},scrollParent:function(){var t;return e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?t=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):t=this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(n){if(n!==t)return this.css("zIndex",n);if(this.length){var r=e(this[0]),i,s;while(r.length&&r[0]!==document){i=r.css("position");if(i==="absolute"||i==="relative"||i==="fixed"){s=parseInt(r.css("zIndex"),10);if(!isNaN(s)&&s!==0)return s}r=r.parent()}}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++n)})},removeUniqueId:function(){return this.each(function(){r.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var n=e.attr(t,"tabindex"),r=isNaN(n);return(r||n>=0)&&i(t,!r)}}),e(function(){var t=document.body,n=t.appendChild(n=document.createElement("div"));n.offsetHeight,e.extend(n.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),e.support.minHeight=n.offsetHeight===100,e.support.selectstart="onselectstart"in n,t.removeChild(n).style.display="none"}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(n,r){function u(t,n,r,s){return e.each(i,function(){n-=parseFloat(e.css(t,"padding"+this))||0,r&&(n-=parseFloat(e.css(t,"border"+this+"Width"))||0),s&&(n-=parseFloat(e.css(t,"margin"+this))||0)}),n}var i=r==="Width"?["Left","Right"]:["Top","Bottom"],s=r.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?o["inner"+r].call(this):this.each(function(){e(this).css(s,u(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return typeof t!="number"?o["outer"+r].call(this,t):this.each(function(){e(this).css(s,u(this,t,!0,n)+"px")})}}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(n){return arguments.length?t.call(this,e.camelCase(n)):t.call(this)}}(e.fn.removeData)),function(){var t=/msie ([\w.]+)/.exec(navigator.userAgent.toLowerCase())||[];e.ui.ie=t.length?!0:!1,e.ui.ie6=parseFloat(t[1],10)===6}(),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,n,r){var i,s=e.ui[t].prototype;for(i in r)s.plugins[i]=s.plugins[i]||[],s.plugins[i].push([n,r[i]])},call:function(e,t,n){var r,i=e.plugins[t];if(!i||!e.element[0].parentNode||e.element[0].parentNode.nodeType===11)return;for(r=0;r<i.length;r++)e.options[i[r][0]]&&i[r][1].apply(e.element,n)}},contains:e.contains,hasScroll:function(t,n){if(e(t).css("overflow")==="hidden")return!1;var r=n&&n==="left"?"scrollLeft":"scrollTop",i=!1;return t[r]>0?!0:(t[r]=1,i=t[r]>0,t[r]=0,i)},isOverAxis:function(e,t,n){return e>t&&e<t+n},isOver:function(t,n,r,i,s,o){return e.ui.isOverAxis(t,r,s)&&e.ui.isOverAxis(n,i,o)}})})(jQuery);(function(e,t){var n=0,r=Array.prototype.slice,i=e.cleanData;e.cleanData=function(t){for(var n=0,r;(r=t[n])!=null;n++)try{e(r).triggerHandler("remove")}catch(s){}i(t)},e.widget=function(t,n,r){var i,s,o,u,a=t.split(".")[0];t=t.split(".")[1],i=a+"-"+t,r||(r=n,n=e.Widget),e.expr[":"][i.toLowerCase()]=function(t){return!!e.data(t,i)},e[a]=e[a]||{},s=e[a][t],o=e[a][t]=function(e,t){if(!this._createWidget)return new o(e,t);arguments.length&&this._createWidget(e,t)},e.extend(o,s,{version:r.version,_proto:e.extend({},r),_childConstructors:[]}),u=new n,u.options=e.widget.extend({},u.options),e.each(r,function(t,i){e.isFunction(i)&&(r[t]=function(){var e=function(){return n.prototype[t].apply(this,arguments)},r=function(e){return n.prototype[t].apply(this,e)};return function(){var t=this._super,n=this._superApply,s;return this._super=e,this._superApply=r,s=i.apply(this,arguments),this._super=t,this._superApply=n,s}}())}),o.prototype=e.widget.extend(u,{widgetEventPrefix:s?u.widgetEventPrefix:t},r,{constructor:o,namespace:a,widgetName:t,widgetBaseClass:i,widgetFullName:i}),s?(e.each(s._childConstructors,function(t,n){var r=n.prototype;e.widget(r.namespace+"."+r.widgetName,o,n._proto)}),delete s._childConstructors):n._childConstructors.push(o),e.widget.bridge(t,o)},e.widget.extend=function(n){var i=r.call(arguments,1),s=0,o=i.length,u,a;for(;s<o;s++)for(u in i[s])a=i[s][u],i[s].hasOwnProperty(u)&&a!==t&&(e.isPlainObject(a)?n[u]=e.isPlainObject(n[u])?e.widget.extend({},n[u],a):e.widget.extend({},a):n[u]=a);return n},e.widget.bridge=function(n,i){var s=i.prototype.widgetFullName||n;e.fn[n]=function(o){var u=typeof o=="string",a=r.call(arguments,1),f=this;return o=!u&&a.length?e.widget.extend.apply(null,[o].concat(a)):o,u?this.each(function(){var r,i=e.data(this,s);if(!i)return e.error("cannot call methods on "+n+" prior to initialization; "+"attempted to call method '"+o+"'");if(!e.isFunction(i[o])||o.charAt(0)==="_")return e.error("no such method '"+o+"' for "+n+" widget instance");r=i[o].apply(i,a);if(r!==i&&r!==t)return f=r&&r.jquery?f.pushStack(r.get()):r,!1}):this.each(function(){var t=e.data(this,s);t?t.option(o||{})._init():e.data(this,s,new i(o,this))}),f}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,r){r=e(r||this.defaultElement||this)[0],this.element=e(r),this.uuid=n++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),r!==this&&(e.data(r,this.widgetName,this),e.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===r&&this.destroy()}}),this.document=e(r.style?r.ownerDocument:r.document||r),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(n,r){var i=n,s,o,u;if(arguments.length===0)return e.widget.extend({},this.options);if(typeof n=="string"){i={},s=n.split("."),n=s.shift();if(s.length){o=i[n]=e.widget.extend({},this.options[n]);for(u=0;u<s.length-1;u++)o[s[u]]=o[s[u]]||{},o=o[s[u]];n=s.pop();if(r===t)return o[n]===t?null:o[n];o[n]=r}else{if(r===t)return this.options[n]===t?null:this.options[n];i[n]=r}}return this._setOptions(i),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,e==="disabled"&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!t).attr("aria-disabled",t),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(t,n,r){var i,s=this;typeof t!="boolean"&&(r=n,n=t,t=!1),r?(n=i=e(n),this.bindings=this.bindings.add(n)):(r=n,n=this.element,i=this.widget()),e.each(r,function(r,o){function u(){if(!t&&(s.options.disabled===!0||e(this).hasClass("ui-state-disabled")))return;return(typeof o=="string"?s[o]:o).apply(s,arguments)}typeof o!="string"&&(u.guid=o.guid=o.guid||u.guid||e.guid++);var a=r.match(/^(\w+)\s*(.*)$/),f=a[1]+s.eventNamespace,l=a[2];l?i.delegate(l,f,u):n.bind(f,u)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function n(){return(typeof e=="string"?r[e]:e).apply(r,arguments)}var r=this;return setTimeout(n,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,n,r){var i,s,o=this.options[t];r=r||{},n=e.Event(n),n.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),n.target=this.element[0],s=n.originalEvent;if(s)for(i in s)i in n||(n[i]=s[i]);return this.element.trigger(n,r),!(e.isFunction(o)&&o.apply(this.element[0],[n].concat(r))===!1||n.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,n){e.Widget.prototype["_"+t]=function(r,i,s){typeof i=="string"&&(i={effect:i});var o,u=i?i===!0||typeof i=="number"?n:i.effect||n:t;i=i||{},typeof i=="number"&&(i={duration:i}),o=!e.isEmptyObject(i),i.complete=s,i.delay&&r.delay(i.delay),o&&e.effects&&(e.effects.effect[u]||e.uiBackCompat!==!1&&e.effects[u])?r[t](i):u!==t&&r[u]?r[u](i.duration,i.easing,s):r.queue(function(n){e(this)[t](),s&&s.call(r[0]),n()})}}),e.uiBackCompat!==!1&&(e.Widget.prototype._getCreateOptions=function(){return e.metadata&&e.metadata.get(this.element[0])[this.widgetName]})})(jQuery);(function(e,t){var n=!1;e(document).mouseup(function(e){n=!1}),e.widget("ui.mouse",{version:"1.9.2",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(n){if(!0===e.data(n.target,t.widgetName+".preventClickEvent"))return e.removeData(n.target,t.widgetName+".preventClickEvent"),n.stopImmediatePropagation(),!1}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(n)return;this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var r=this,i=t.which===1,s=typeof this.options.cancel=="string"&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;if(!i||s||!this._mouseCapture(t))return!0;this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){r.mouseDelayMet=!0},this.options.delay));if(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)){this._mouseStarted=this._mouseStart(t)!==!1;if(!this._mouseStarted)return t.preventDefault(),!0}return!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return r._mouseMove(e)},this._mouseUpDelegate=function(e){return r._mouseUp(e)},e(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),n=!0,!0},_mouseMove:function(t){return!e.ui.ie||document.documentMode>=9||!!t.button?this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted):this._mouseUp(t)},_mouseUp:function(t){return e(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(e){return this.mouseDelayMet},_mouseStart:function(e){},_mouseDrag:function(e){},_mouseStop:function(e){},_mouseCapture:function(e){return!0}})})(jQuery);(function(e,t){function h(e,t,n){return[parseInt(e[0],10)*(l.test(e[0])?t/100:1),parseInt(e[1],10)*(l.test(e[1])?n/100:1)]}function p(t,n){return parseInt(e.css(t,n),10)||0}e.ui=e.ui||{};var n,r=Math.max,i=Math.abs,s=Math.round,o=/left|center|right/,u=/top|center|bottom/,a=/[\+\-]\d+%?/,f=/^\w+/,l=/%$/,c=e.fn.position;e.position={scrollbarWidth:function(){if(n!==t)return n;var r,i,s=e("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),o=s.children()[0];return e("body").append(s),r=o.offsetWidth,s.css("overflow","scroll"),i=o.offsetWidth,r===i&&(i=s[0].clientWidth),s.remove(),n=r-i},getScrollInfo:function(t){var n=t.isWindow?"":t.element.css("overflow-x"),r=t.isWindow?"":t.element.css("overflow-y"),i=n==="scroll"||n==="auto"&&t.width<t.element[0].scrollWidth,s=r==="scroll"||r==="auto"&&t.height<t.element[0].scrollHeight;return{width:i?e.position.scrollbarWidth():0,height:s?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var n=e(t||window),r=e.isWindow(n[0]);return{element:n,isWindow:r,offset:n.offset()||{left:0,top:0},scrollLeft:n.scrollLeft(),scrollTop:n.scrollTop(),width:r?n.width():n.outerWidth(),height:r?n.height():n.outerHeight()}}},e.fn.position=function(t){if(!t||!t.of)return c.apply(this,arguments);t=e.extend({},t);var n,l,d,v,m,g=e(t.of),y=e.position.getWithinInfo(t.within),b=e.position.getScrollInfo(y),w=g[0],E=(t.collision||"flip").split(" "),S={};return w.nodeType===9?(l=g.width(),d=g.height(),v={top:0,left:0}):e.isWindow(w)?(l=g.width(),d=g.height(),v={top:g.scrollTop(),left:g.scrollLeft()}):w.preventDefault?(t.at="left top",l=d=0,v={top:w.pageY,left:w.pageX}):(l=g.outerWidth(),d=g.outerHeight(),v=g.offset()),m=e.extend({},v),e.each(["my","at"],function(){var e=(t[this]||"").split(" "),n,r;e.length===1&&(e=o.test(e[0])?e.concat(["center"]):u.test(e[0])?["center"].concat(e):["center","center"]),e[0]=o.test(e[0])?e[0]:"center",e[1]=u.test(e[1])?e[1]:"center",n=a.exec(e[0]),r=a.exec(e[1]),S[this]=[n?n[0]:0,r?r[0]:0],t[this]=[f.exec(e[0])[0],f.exec(e[1])[0]]}),E.length===1&&(E[1]=E[0]),t.at[0]==="right"?m.left+=l:t.at[0]==="center"&&(m.left+=l/2),t.at[1]==="bottom"?m.top+=d:t.at[1]==="center"&&(m.top+=d/2),n=h(S.at,l,d),m.left+=n[0],m.top+=n[1],this.each(function(){var o,u,a=e(this),f=a.outerWidth(),c=a.outerHeight(),w=p(this,"marginLeft"),x=p(this,"marginTop"),T=f+w+p(this,"marginRight")+b.width,N=c+x+p(this,"marginBottom")+b.height,C=e.extend({},m),k=h(S.my,a.outerWidth(),a.outerHeight());t.my[0]==="right"?C.left-=f:t.my[0]==="center"&&(C.left-=f/2),t.my[1]==="bottom"?C.top-=c:t.my[1]==="center"&&(C.top-=c/2),C.left+=k[0],C.top+=k[1],e.support.offsetFractions||(C.left=s(C.left),C.top=s(C.top)),o={marginLeft:w,marginTop:x},e.each(["left","top"],function(r,i){e.ui.position[E[r]]&&e.ui.position[E[r]][i](C,{targetWidth:l,targetHeight:d,elemWidth:f,elemHeight:c,collisionPosition:o,collisionWidth:T,collisionHeight:N,offset:[n[0]+k[0],n[1]+k[1]],my:t.my,at:t.at,within:y,elem:a})}),e.fn.bgiframe&&a.bgiframe(),t.using&&(u=function(e){var n=v.left-C.left,s=n+l-f,o=v.top-C.top,u=o+d-c,h={target:{element:g,left:v.left,top:v.top,width:l,height:d},element:{element:a,left:C.left,top:C.top,width:f,height:c},horizontal:s<0?"left":n>0?"right":"center",vertical:u<0?"top":o>0?"bottom":"middle"};l<f&&i(n+s)<l&&(h.horizontal="center"),d<c&&i(o+u)<d&&(h.vertical="middle"),r(i(n),i(s))>r(i(o),i(u))?h.important="horizontal":h.important="vertical",t.using.call(this,e,h)}),a.offset(e.extend(C,{using:u}))})},e.ui.position={fit:{left:function(e,t){var n=t.within,i=n.isWindow?n.scrollLeft:n.offset.left,s=n.width,o=e.left-t.collisionPosition.marginLeft,u=i-o,a=o+t.collisionWidth-s-i,f;t.collisionWidth>s?u>0&&a<=0?(f=e.left+u+t.collisionWidth-s-i,e.left+=u-f):a>0&&u<=0?e.left=i:u>a?e.left=i+s-t.collisionWidth:e.left=i:u>0?e.left+=u:a>0?e.left-=a:e.left=r(e.left-o,e.left)},top:function(e,t){var n=t.within,i=n.isWindow?n.scrollTop:n.offset.top,s=t.within.height,o=e.top-t.collisionPosition.marginTop,u=i-o,a=o+t.collisionHeight-s-i,f;t.collisionHeight>s?u>0&&a<=0?(f=e.top+u+t.collisionHeight-s-i,e.top+=u-f):a>0&&u<=0?e.top=i:u>a?e.top=i+s-t.collisionHeight:e.top=i:u>0?e.top+=u:a>0?e.top-=a:e.top=r(e.top-o,e.top)}},flip:{left:function(e,t){var n=t.within,r=n.offset.left+n.scrollLeft,s=n.width,o=n.isWindow?n.scrollLeft:n.offset.left,u=e.left-t.collisionPosition.marginLeft,a=u-o,f=u+t.collisionWidth-s-o,l=t.my[0]==="left"?-t.elemWidth:t.my[0]==="right"?t.elemWidth:0,c=t.at[0]==="left"?t.targetWidth:t.at[0]==="right"?-t.targetWidth:0,h=-2*t.offset[0],p,d;if(a<0){p=e.left+l+c+h+t.collisionWidth-s-r;if(p<0||p<i(a))e.left+=l+c+h}else if(f>0){d=e.left-t.collisionPosition.marginLeft+l+c+h-o;if(d>0||i(d)<f)e.left+=l+c+h}},top:function(e,t){var n=t.within,r=n.offset.top+n.scrollTop,s=n.height,o=n.isWindow?n.scrollTop:n.offset.top,u=e.top-t.collisionPosition.marginTop,a=u-o,f=u+t.collisionHeight-s-o,l=t.my[1]==="top",c=l?-t.elemHeight:t.my[1]==="bottom"?t.elemHeight:0,h=t.at[1]==="top"?t.targetHeight:t.at[1]==="bottom"?-t.targetHeight:0,p=-2*t.offset[1],d,v;a<0?(v=e.top+c+h+p+t.collisionHeight-s-r,e.top+c+h+p>a&&(v<0||v<i(a))&&(e.top+=c+h+p)):f>0&&(d=e.top-t.collisionPosition.marginTop+c+h+p-o,e.top+c+h+p>f&&(d>0||i(d)<f)&&(e.top+=c+h+p))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,n,r,i,s,o=document.getElementsByTagName("body")[0],u=document.createElement("div");t=document.createElement(o?"div":"body"),r={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},o&&e.extend(r,{position:"absolute",left:"-1000px",top:"-1000px"});for(s in r)t.style[s]=r[s];t.appendChild(u),n=o||document.documentElement,n.insertBefore(t,n.firstChild),u.style.cssText="position: absolute; left: 10.7432222px;",i=e(u).offset().left,e.support.offsetFractions=i>10&&i<11,t.innerHTML="",n.removeChild(t)}(),e.uiBackCompat!==!1&&function(e){var n=e.fn.position;e.fn.position=function(r){if(!r||!r.offset)return n.call(this,r);var i=r.offset.split(" "),s=r.at.split(" ");return i.length===1&&(i[1]=i[0]),/^\d/.test(i[0])&&(i[0]="+"+i[0]),/^\d/.test(i[1])&&(i[1]="+"+i[1]),s.length===1&&(/left|center|right/.test(s[0])?s[1]="center":(s[1]=s[0],s[0]="center")),n.call(this,e.extend(r,{at:s[0]+i[0]+" "+s[1]+i[1],offset:t}))}}(jQuery)})(jQuery);(function(e,t){e.widget("ui.draggable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){this.options.helper=="original"&&!/^(?:r|a|f)/.test(this.element.css("position"))&&(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},_destroy:function(){this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy()},_mouseCapture:function(t){var n=this.options;return this.helper||n.disabled||e(t.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(t),this.handle?(e(n.iframeFix===!0?"iframe":n.iframeFix).each(function(){e('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var n=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,n.cursorAt&&this._adjustOffsetFromHelper(n.cursorAt),n.containment&&this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,n){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute");if(!n){var r=this._uiHash();if(this._trigger("drag",t,r)===!1)return this._mouseUp({}),!1;this.position=r.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";return e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var n=!1;e.ui.ddmanager&&!this.options.dropBehaviour&&(n=e.ui.ddmanager.drop(this,t)),this.dropped&&(n=this.dropped,this.dropped=!1);var r=this.element[0],i=!1;while(r&&(r=r.parentNode))r==document&&(i=!0);if(!i&&this.options.helper==="original")return!1;if(this.options.revert=="invalid"&&!n||this.options.revert=="valid"&&n||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,n)){var s=this;e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){s._trigger("stop",t)!==!1&&s._clear()})}else this._trigger("stop",t)!==!1&&this._clear();return!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){var n=!this.options.handle||!e(this.options.handle,this.element).length?!0:!1;return e(this.options.handle,this.element).find("*").andSelf().each(function(){this==t.target&&(n=!0)}),n},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t])):n.helper=="clone"?this.element.clone().removeAttr("id"):this.element;return r.parents("body").length||r.appendTo(n.appendTo=="parent"?this.element[0].parentNode:n.appendTo),r[0]!=this.element[0]&&!/(fixed|absolute)/.test(r.css("position"))&&r.css("position","absolute"),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.element.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[t.containment=="document"?0:e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,t.containment=="document"?0:e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,(t.containment=="document"?0:e(window).scrollLeft())+e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(t.containment=="document"?0:e(window).scrollTop())+(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)&&t.containment.constructor!=Array){var n=e(t.containment),r=n[0];if(!r)return;var i=n.offset(),s=e(r).css("overflow")!="hidden";this.containment=[(parseInt(e(r).css("borderLeftWidth"),10)||0)+(parseInt(e(r).css("paddingLeft"),10)||0),(parseInt(e(r).css("borderTopWidth"),10)||0)+(parseInt(e(r).css("paddingTop"),10)||0),(s?Math.max(r.scrollWidth,r.offsetWidth):r.offsetWidth)-(parseInt(e(r).css("borderLeftWidth"),10)||0)-(parseInt(e(r).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(s?Math.max(r.scrollHeight,r.offsetHeight):r.offsetHeight)-(parseInt(e(r).css("borderTopWidth"),10)||0)-(parseInt(e(r).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=n}else t.containment.constructor==Array&&(this.containment=t.containment)},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName),s=t.pageX,o=t.pageY;if(this.originalPosition){var u;if(this.containment){if(this.relative_container){var a=this.relative_container.offset();u=[this.containment[0]+a.left,this.containment[1]+a.top,this.containment[2]+a.left,this.containment[3]+a.top]}else u=this.containment;t.pageX-this.offset.click.left<u[0]&&(s=u[0]+this.offset.click.left),t.pageY-this.offset.click.top<u[1]&&(o=u[1]+this.offset.click.top),t.pageX-this.offset.click.left>u[2]&&(s=u[2]+this.offset.click.left),t.pageY-this.offset.click.top>u[3]&&(o=u[3]+this.offset.click.top)}if(n.grid){var f=n.grid[1]?this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1]:this.originalPageY;o=u?f-this.offset.click.top<u[1]||f-this.offset.click.top>u[3]?f-this.offset.click.top<u[1]?f+n.grid[1]:f-n.grid[1]:f:f;var l=n.grid[0]?this.originalPageX+Math.round((s-this.originalPageX)/n.grid[0])*n.grid[0]:this.originalPageX;s=u?l-this.offset.click.left<u[0]||l-this.offset.click.left>u[2]?l-this.offset.click.left<u[0]?l+n.grid[0]:l-n.grid[0]:l:l}}return{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():i?0:r.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():i?0:r.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(t,n,r){return r=r||this._uiHash(),e.ui.plugin.call(this,t,[n,r]),t=="drag"&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,n,r)},plugins:{},_uiHash:function(e){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,n){var r=e(this).data("draggable"),i=r.options,s=e.extend({},n,{item:r.element});r.sortables=[],e(i.connectToSortable).each(function(){var n=e.data(this,"sortable");n&&!n.options.disabled&&(r.sortables.push({instance:n,shouldRevert:n.options.revert}),n.refreshPositions(),n._trigger("activate",t,s))})},stop:function(t,n){var r=e(this).data("draggable"),i=e.extend({},n,{item:r.element});e.each(r.sortables,function(){this.instance.isOver?(this.instance.isOver=0,r.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,r.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,i))})},drag:function(t,n){var r=e(this).data("draggable"),i=this,s=function(t){var n=this.offset.click.top,r=this.offset.click.left,i=this.positionAbs.top,s=this.positionAbs.left,o=t.height,u=t.width,a=t.top,f=t.left;return e.ui.isOver(i+n,s+r,a,f,o,u)};e.each(r.sortables,function(s){var o=!1,u=this;this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(o=!0,e.each(r.sortables,function(){return this.instance.positionAbs=r.positionAbs,this.instance.helperProportions=r.helperProportions,this.instance.offset.click=r.offset.click,this!=u&&this.instance._intersectsWith(this.instance.containerCache)&&e.ui.contains(u.instance.element[0],this.instance.element[0])&&(o=!1),o})),o?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(i).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return n.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=r.offset.click.top,this.instance.offset.click.left=r.offset.click.left,this.instance.offset.parent.left-=r.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=r.offset.parent.top-this.instance.offset.parent.top,r._trigger("toSortable",t),r.dropped=this.instance.element,r.currentItem=r.element,this.instance.fromOutside=r),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),r._trigger("fromSortable",t),r.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(t,n){var r=e("body"),i=e(this).data("draggable").options;r.css("cursor")&&(i._cursor=r.css("cursor")),r.css("cursor",i.cursor)},stop:function(t,n){var r=e(this).data("draggable").options;r._cursor&&e("body").css("cursor",r._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,n){var r=e(n.helper),i=e(this).data("draggable").options;r.css("opacity")&&(i._opacity=r.css("opacity")),r.css("opacity",i.opacity)},stop:function(t,n){var r=e(this).data("draggable").options;r._opacity&&e(n.helper).css("opacity",r._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(t,n){var r=e(this).data("draggable");r.scrollParent[0]!=document&&r.scrollParent[0].tagName!="HTML"&&(r.overflowOffset=r.scrollParent.offset())},drag:function(t,n){var r=e(this).data("draggable"),i=r.options,s=!1;if(r.scrollParent[0]!=document&&r.scrollParent[0].tagName!="HTML"){if(!i.axis||i.axis!="x")r.overflowOffset.top+r.scrollParent[0].offsetHeight-t.pageY<i.scrollSensitivity?r.scrollParent[0].scrollTop=s=r.scrollParent[0].scrollTop+i.scrollSpeed:t.pageY-r.overflowOffset.top<i.scrollSensitivity&&(r.scrollParent[0].scrollTop=s=r.scrollParent[0].scrollTop-i.scrollSpeed);if(!i.axis||i.axis!="y")r.overflowOffset.left+r.scrollParent[0].offsetWidth-t.pageX<i.scrollSensitivity?r.scrollParent[0].scrollLeft=s=r.scrollParent[0].scrollLeft+i.scrollSpeed:t.pageX-r.overflowOffset.left<i.scrollSensitivity&&(r.scrollParent[0].scrollLeft=s=r.scrollParent[0].scrollLeft-i.scrollSpeed)}else{if(!i.axis||i.axis!="x")t.pageY-e(document).scrollTop()<i.scrollSensitivity?s=e(document).scrollTop(e(document).scrollTop()-i.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<i.scrollSensitivity&&(s=e(document).scrollTop(e(document).scrollTop()+i.scrollSpeed));if(!i.axis||i.axis!="y")t.pageX-e(document).scrollLeft()<i.scrollSensitivity?s=e(document).scrollLeft(e(document).scrollLeft()-i.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<i.scrollSensitivity&&(s=e(document).scrollLeft(e(document).scrollLeft()+i.scrollSpeed))}s!==!1&&e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(r,t)}}),e.ui.plugin.add("draggable","snap",{start:function(t,n){var r=e(this).data("draggable"),i=r.options;r.snapElements=[],e(i.snap.constructor!=String?i.snap.items||":data(draggable)":i.snap).each(function(){var t=e(this),n=t.offset();this!=r.element[0]&&r.snapElements.push({item:this,width:t.outerWidth(),height:t.outerHeight(),top:n.top,left:n.left})})},drag:function(t,n){var r=e(this).data("draggable"),i=r.options,s=i.snapTolerance,o=n.offset.left,u=o+r.helperProportions.width,a=n.offset.top,f=a+r.helperProportions.height;for(var l=r.snapElements.length-1;l>=0;l--){var c=r.snapElements[l].left,h=c+r.snapElements[l].width,p=r.snapElements[l].top,d=p+r.snapElements[l].height;if(!(c-s<o&&o<h+s&&p-s<a&&a<d+s||c-s<o&&o<h+s&&p-s<f&&f<d+s||c-s<u&&u<h+s&&p-s<a&&a<d+s||c-s<u&&u<h+s&&p-s<f&&f<d+s)){r.snapElements[l].snapping&&r.options.snap.release&&r.options.snap.release.call(r.element,t,e.extend(r._uiHash(),{snapItem:r.snapElements[l].item})),r.snapElements[l].snapping=!1;continue}if(i.snapMode!="inner"){var v=Math.abs(p-f)<=s,m=Math.abs(d-a)<=s,g=Math.abs(c-u)<=s,y=Math.abs(h-o)<=s;v&&(n.position.top=r._convertPositionTo("relative",{top:p-r.helperProportions.height,left:0}).top-r.margins.top),m&&(n.position.top=r._convertPositionTo("relative",{top:d,left:0}).top-r.margins.top),g&&(n.position.left=r._convertPositionTo("relative",{top:0,left:c-r.helperProportions.width}).left-r.margins.left),y&&(n.position.left=r._convertPositionTo("relative",{top:0,left:h}).left-r.margins.left)}var b=v||m||g||y;if(i.snapMode!="outer"){var v=Math.abs(p-a)<=s,m=Math.abs(d-f)<=s,g=Math.abs(c-o)<=s,y=Math.abs(h-u)<=s;v&&(n.position.top=r._convertPositionTo("relative",{top:p,left:0}).top-r.margins.top),m&&(n.position.top=r._convertPositionTo("relative",{top:d-r.helperProportions.height,left:0}).top-r.margins.top),g&&(n.position.left=r._convertPositionTo("relative",{top:0,left:c}).left-r.margins.left),y&&(n.position.left=r._convertPositionTo("relative",{top:0,left:h-r.helperProportions.width}).left-r.margins.left)}!r.snapElements[l].snapping&&(v||m||g||y||b)&&r.options.snap.snap&&r.options.snap.snap.call(r.element,t,e.extend(r._uiHash(),{snapItem:r.snapElements[l].item})),r.snapElements[l].snapping=v||m||g||y||b}}}),e.ui.plugin.add("draggable","stack",{start:function(t,n){var r=e(this).data("draggable").options,i=e.makeArray(e(r.stack)).sort(function(t,n){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(n).css("zIndex"),10)||0)});if(!i.length)return;var s=parseInt(i[0].style.zIndex)||0;e(i).each(function(e){this.style.zIndex=s+e}),this[0].style.zIndex=s+i.length}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,n){var r=e(n.helper),i=e(this).data("draggable").options;r.css("zIndex")&&(i._zIndex=r.css("zIndex")),r.css("zIndex",i.zIndex)},stop:function(t,n){var r=e(this).data("draggable").options;r._zIndex&&e(n.helper).css("zIndex",r._zIndex)}})})(jQuery);(function(e,t){e.widget("ui.droppable",{version:"1.9.2",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect"},_create:function(){var t=this.options,n=t.accept;this.isover=0,this.isout=1,this.accept=e.isFunction(n)?n:function(e){return e.is(n)},this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight},e.ui.ddmanager.droppables[t.scope]=e.ui.ddmanager.droppables[t.scope]||[],e.ui.ddmanager.droppables[t.scope].push(this),t.addClasses&&this.element.addClass("ui-droppable")},_destroy:function(){var t=e.ui.ddmanager.droppables[this.options.scope];for(var n=0;n<t.length;n++)t[n]==this&&t.splice(n,1);this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,n){t=="accept"&&(this.accept=e.isFunction(n)?n:function(e){return e.is(n)}),e.Widget.prototype._setOption.apply(this,arguments)},_activate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),n&&this._trigger("activate",t,this.ui(n))},_deactivate:function(t){var n=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),n&&this._trigger("deactivate",t,this.ui(n))},_over:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]==this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(n)))},_out:function(t){var n=e.ui.ddmanager.current;if(!n||(n.currentItem||n.element)[0]==this.element[0])return;this.accept.call(this.element[0],n.currentItem||n.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(n)))},_drop:function(t,n){var r=n||e.ui.ddmanager.current;if(!r||(r.currentItem||r.element)[0]==this.element[0])return!1;var i=!1;return this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var t=e.data(this,"droppable");if(t.options.greedy&&!t.options.disabled&&t.options.scope==r.options.scope&&t.accept.call(t.element[0],r.currentItem||r.element)&&e.ui.intersect(r,e.extend(t,{offset:t.element.offset()}),t.options.tolerance))return i=!0,!1}),i?!1:this.accept.call(this.element[0],r.currentItem||r.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(r)),this.element):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(t,n,r){if(!n.offset)return!1;var i=(t.positionAbs||t.position.absolute).left,s=i+t.helperProportions.width,o=(t.positionAbs||t.position.absolute).top,u=o+t.helperProportions.height,a=n.offset.left,f=a+n.proportions.width,l=n.offset.top,c=l+n.proportions.height;switch(r){case"fit":return a<=i&&s<=f&&l<=o&&u<=c;case"intersect":return a<i+t.helperProportions.width/2&&s-t.helperProportions.width/2<f&&l<o+t.helperProportions.height/2&&u-t.helperProportions.height/2<c;case"pointer":var h=(t.positionAbs||t.position.absolute).left+(t.clickOffset||t.offset.click).left,p=(t.positionAbs||t.position.absolute).top+(t.clickOffset||t.offset.click).top,d=e.ui.isOver(p,h,l,a,n.proportions.height,n.proportions.width);return d;case"touch":return(o>=l&&o<=c||u>=l&&u<=c||o<l&&u>c)&&(i>=a&&i<=f||s>=a&&s<=f||i<a&&s>f);default:return!1}},e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,n){var r=e.ui.ddmanager.droppables[t.options.scope]||[],i=n?n.type:null,s=(t.currentItem||t.element).find(":data(droppable)").andSelf();e:for(var o=0;o<r.length;o++){if(r[o].options.disabled||t&&!r[o].accept.call(r[o].element[0],t.currentItem||t.element))continue;for(var u=0;u<s.length;u++)if(s[u]==r[o].element[0]){r[o].proportions.height=0;continue e}r[o].visible=r[o].element.css("display")!="none";if(!r[o].visible)continue;i=="mousedown"&&r[o]._activate.call(r[o],n),r[o].offset=r[o].element.offset(),r[o].proportions={width:r[o].element[0].offsetWidth,height:r[o].element[0].offsetHeight}}},drop:function(t,n){var r=!1;return e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options)return;!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance)&&(r=this._drop.call(this,n)||r),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=1,this.isover=0,this._deactivate.call(this,n))}),r},dragStart:function(t,n){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)})},drag:function(t,n){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,n),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(this.options.disabled||this.greedyChild||!this.visible)return;var r=e.ui.intersect(t,this,this.options.tolerance),i=!r&&this.isover==1?"isout":r&&this.isover==0?"isover":null;if(!i)return;var s;if(this.options.greedy){var o=this.options.scope,u=this.element.parents(":data(droppable)").filter(function(){return e.data(this,"droppable").options.scope===o});u.length&&(s=e.data(u[0],"droppable"),s.greedyChild=i=="isover"?1:0)}s&&i=="isover"&&(s.isover=0,s.isout=1,s._out.call(s,n)),this[i]=1,this[i=="isout"?"isover":"isout"]=0,this[i=="isover"?"_over":"_out"].call(this,n),s&&i=="isout"&&(s.isout=0,s.isover=1,s._over.call(s,n))})},dragStop:function(t,n){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,n)}}})(jQuery);(function(e,t){e.widget("ui.resizable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1e3},_create:function(){var t=this,n=this.options;this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!n.aspectRatio,aspectRatio:n.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:n.helper||n.ghost||n.animate?n.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("resizable",this.element.data("resizable")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=n.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se");if(this.handles.constructor==String){this.handles=="all"&&(this.handles="n,e,s,w,se,sw,ne,nw");var r=this.handles.split(",");this.handles={};for(var i=0;i<r.length;i++){var s=e.trim(r[i]),o="ui-resizable-"+s,u=e('<div class="ui-resizable-handle '+o+'"></div>');u.css({zIndex:n.zIndex}),"se"==s&&u.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(u)}}this._renderAxis=function(t){t=t||this.element;for(var n in this.handles){this.handles[n].constructor==String&&(this.handles[n]=e(this.handles[n],this.element).show());if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var r=e(this.handles[n],this.element),i=0;i=/sw|ne|nw|se|n|s/.test(n)?r.outerHeight():r.outerWidth();var s=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");t.css(s,i),this._proportionallyResize()}if(!e(this.handles[n]).length)continue}},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){if(!t.resizing){if(this.className)var e=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);t.axis=e&&e[1]?e[1]:"se"}}),n.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){if(n.disabled)return;e(this).removeClass("ui-resizable-autohide"),t._handles.show()}).mouseleave(function(){if(n.disabled)return;t.resizing||(e(this).addClass("ui-resizable-autohide"),t._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){t(this.element);var n=this.element;this.originalElement.css({position:n.css("position"),width:n.outerWidth(),height:n.outerHeight(),top:n.css("top"),left:n.css("left")}).insertAfter(n),n.remove()}return this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_mouseCapture:function(t){var n=!1;for(var r in this.handles)e(this.handles[r])[0]==t.target&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(t){var r=this.options,i=this.element.position(),s=this.element;this.resizing=!0,this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()},(s.is(".ui-draggable")||/absolute/.test(s.css("position")))&&s.css({position:"absolute",top:i.top,left:i.left}),this._renderProxy();var o=n(this.helper.css("left")),u=n(this.helper.css("top"));r.containment&&(o+=e(r.containment).scrollLeft()||0,u+=e(r.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:o,top:u},this.size=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalSize=this._helper?{width:s.outerWidth(),height:s.outerHeight()}:{width:s.width(),height:s.height()},this.originalPosition={left:o,top:u},this.sizeDiff={width:s.outerWidth()-s.width(),height:s.outerHeight()-s.height()},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio=typeof r.aspectRatio=="number"?r.aspectRatio:this.originalSize.width/this.originalSize.height||1;var a=e(".ui-resizable-"+this.axis).css("cursor");return e("body").css("cursor",a=="auto"?this.axis+"-resize":a),s.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(e){var t=this.helper,n=this.options,r={},i=this,s=this.originalMousePosition,o=this.axis,u=e.pageX-s.left||0,a=e.pageY-s.top||0,f=this._change[o];if(!f)return!1;var l=f.apply(this,[e,u,a]);this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey)l=this._updateRatio(l,e);return l=this._respectSize(l,e),this._propagate("resize",e),t.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"}),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),this._updateCache(l),this._trigger("resize",e,this.ui()),!1},_mouseStop:function(t){this.resizing=!1;var n=this.options,r=this;if(this._helper){var i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),o=s&&e.ui.hasScroll(i[0],"left")?0:r.sizeDiff.height,u=s?0:r.sizeDiff.width,a={width:r.helper.width()-u,height:r.helper.height()-o},f=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,l=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;n.animate||this.element.css(e.extend(a,{top:l,left:f})),r.helper.height(r.size.height),r.helper.width(r.size.width),this._helper&&!n.animate&&this._proportionallyResize()}return e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updateVirtualBoundaries:function(e){var t=this.options,n,i,s,o,u;u={minWidth:r(t.minWidth)?t.minWidth:0,maxWidth:r(t.maxWidth)?t.maxWidth:Infinity,minHeight:r(t.minHeight)?t.minHeight:0,maxHeight:r(t.maxHeight)?t.maxHeight:Infinity};if(this._aspectRatio||e)n=u.minHeight*this.aspectRatio,s=u.minWidth/this.aspectRatio,i=u.maxHeight*this.aspectRatio,o=u.maxWidth/this.aspectRatio,n>u.minWidth&&(u.minWidth=n),s>u.minHeight&&(u.minHeight=s),i<u.maxWidth&&(u.maxWidth=i),o<u.maxHeight&&(u.maxHeight=o);this._vBoundaries=u},_updateCache:function(e){var t=this.options;this.offset=this.helper.offset(),r(e.left)&&(this.position.left=e.left),r(e.top)&&(this.position.top=e.top),r(e.height)&&(this.size.height=e.height),r(e.width)&&(this.size.width=e.width)},_updateRatio:function(e,t){var n=this.options,i=this.position,s=this.size,o=this.axis;return r(e.height)?e.width=e.height*this.aspectRatio:r(e.width)&&(e.height=e.width/this.aspectRatio),o=="sw"&&(e.left=i.left+(s.width-e.width),e.top=null),o=="nw"&&(e.top=i.top+(s.height-e.height),e.left=i.left+(s.width-e.width)),e},_respectSize:function(e,t){var n=this.helper,i=this._vBoundaries,s=this._aspectRatio||t.shiftKey,o=this.axis,u=r(e.width)&&i.maxWidth&&i.maxWidth<e.width,a=r(e.height)&&i.maxHeight&&i.maxHeight<e.height,f=r(e.width)&&i.minWidth&&i.minWidth>e.width,l=r(e.height)&&i.minHeight&&i.minHeight>e.height;f&&(e.width=i.minWidth),l&&(e.height=i.minHeight),u&&(e.width=i.maxWidth),a&&(e.height=i.maxHeight);var c=this.originalPosition.left+this.originalSize.width,h=this.position.top+this.size.height,p=/sw|nw|w/.test(o),d=/nw|ne|n/.test(o);f&&p&&(e.left=c-i.minWidth),u&&p&&(e.left=c-i.maxWidth),l&&d&&(e.top=h-i.minHeight),a&&d&&(e.top=h-i.maxHeight);var v=!e.width&&!e.height;return v&&!e.left&&e.top?e.top=null:v&&!e.top&&e.left&&(e.left=null),e},_proportionallyResize:function(){var t=this.options;if(!this._proportionallyResizeElements.length)return;var n=this.helper||this.element;for(var r=0;r<this._proportionallyResizeElements.length;r++){var i=this._proportionallyResizeElements[r];if(!this.borderDif){var s=[i.css("borderTopWidth"),i.css("borderRightWidth"),i.css("borderBottomWidth"),i.css("borderLeftWidth")],o=[i.css("paddingTop"),i.css("paddingRight"),i.css("paddingBottom"),i.css("paddingLeft")];this.borderDif=e.map(s,function(e,t){var n=parseInt(e,10)||0,r=parseInt(o[t],10)||0;return n+r})}i.css({height:n.height()-this.borderDif[0]-this.borderDif[2]||0,width:n.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var t=this.element,n=this.options;this.elementOffset=t.offset();if(this._helper){this.helper=this.helper||e('<div style="overflow:hidden;"></div>');var r=e.ui.ie6?1:0,i=e.ui.ie6?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+i,height:this.element.outerHeight()+i,position:"absolute",left:this.elementOffset.left-r+"px",top:this.elementOffset.top-r+"px",zIndex:++n.zIndex}),this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(e,t,n){return{width:this.originalSize.width+t}},w:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,n){var r=this.options,i=this.originalSize,s=this.originalPosition;return{top:s.top+n,height:i.height-n}},s:function(e,t,n){return{height:this.originalSize.height+n}},se:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},sw:function(t,n,r){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,n,r]))},ne:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,n,r]))},nw:function(t,n,r){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,n,r]))}},_propagate:function(t,n){e.ui.plugin.call(this,t,[n,this.ui()]),t!="resize"&&this._trigger(t,n,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","alsoResize",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=function(t){e(t).each(function(){var t=e(this);t.data("resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};typeof i.alsoResize=="object"&&!i.alsoResize.parentNode?i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)}):s(i.alsoResize)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.originalSize,o=r.originalPosition,u={height:r.size.height-s.height||0,width:r.size.width-s.width||0,top:r.position.top-o.top||0,left:r.position.left-o.left||0},a=function(t,r){e(t).each(function(){var t=e(this),i=e(this).data("resizable-alsoresize"),s={},o=r&&r.length?r:t.parents(n.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var n=(i[t]||0)+(u[t]||0);n&&n>=0&&(s[t]=n||null)}),t.css(s)})};typeof i.alsoResize=="object"&&!i.alsoResize.nodeType?e.each(i.alsoResize,function(e,t){a(e,t)}):a(i.alsoResize)},stop:function(t,n){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","animate",{stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r._proportionallyResizeElements,o=s.length&&/textarea/i.test(s[0].nodeName),u=o&&e.ui.hasScroll(s[0],"left")?0:r.sizeDiff.height,a=o?0:r.sizeDiff.width,f={width:r.size.width-a,height:r.size.height-u},l=parseInt(r.element.css("left"),10)+(r.position.left-r.originalPosition.left)||null,c=parseInt(r.element.css("top"),10)+(r.position.top-r.originalPosition.top)||null;r.element.animate(e.extend(f,c&&l?{top:c,left:l}:{}),{duration:i.animateDuration,easing:i.animateEasing,step:function(){var n={width:parseInt(r.element.css("width"),10),height:parseInt(r.element.css("height"),10),top:parseInt(r.element.css("top"),10),left:parseInt(r.element.css("left"),10)};s&&s.length&&e(s[0]).css({width:n.width,height:n.height}),r._updateCache(n),r._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(t,r){var i=e(this).data("resizable"),s=i.options,o=i.element,u=s.containment,a=u instanceof e?u.get(0):/parent/.test(u)?o.parent().get(0):u;if(!a)return;i.containerElement=e(a);if(/document/.test(u)||u==document)i.containerOffset={left:0,top:0},i.containerPosition={left:0,top:0},i.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight};else{var f=e(a),l=[];e(["Top","Right","Left","Bottom"]).each(function(e,t){l[e]=n(f.css("padding"+t))}),i.containerOffset=f.offset(),i.containerPosition=f.position(),i.containerSize={height:f.innerHeight()-l[3],width:f.innerWidth()-l[1]};var c=i.containerOffset,h=i.containerSize.height,p=i.containerSize.width,d=e.ui.hasScroll(a,"left")?a.scrollWidth:p,v=e.ui.hasScroll(a)?a.scrollHeight:h;i.parentData={element:a,left:c.left,top:c.top,width:d,height:v}}},resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.containerSize,o=r.containerOffset,u=r.size,a=r.position,f=r._aspectRatio||t.shiftKey,l={top:0,left:0},c=r.containerElement;c[0]!=document&&/static/.test(c.css("position"))&&(l=o),a.left<(r._helper?o.left:0)&&(r.size.width=r.size.width+(r._helper?r.position.left-o.left:r.position.left-l.left),f&&(r.size.height=r.size.width/r.aspectRatio),r.position.left=i.helper?o.left:0),a.top<(r._helper?o.top:0)&&(r.size.height=r.size.height+(r._helper?r.position.top-o.top:r.position.top),f&&(r.size.width=r.size.height*r.aspectRatio),r.position.top=r._helper?o.top:0),r.offset.left=r.parentData.left+r.position.left,r.offset.top=r.parentData.top+r.position.top;var h=Math.abs((r._helper?r.offset.left-l.left:r.offset.left-l.left)+r.sizeDiff.width),p=Math.abs((r._helper?r.offset.top-l.top:r.offset.top-o.top)+r.sizeDiff.height),d=r.containerElement.get(0)==r.element.parent().get(0),v=/relative|absolute/.test(r.containerElement.css("position"));d&&v&&(h-=r.parentData.left),h+r.size.width>=r.parentData.width&&(r.size.width=r.parentData.width-h,f&&(r.size.height=r.size.width/r.aspectRatio)),p+r.size.height>=r.parentData.height&&(r.size.height=r.parentData.height-p,f&&(r.size.width=r.size.height*r.aspectRatio))},stop:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.position,o=r.containerOffset,u=r.containerPosition,a=r.containerElement,f=e(r.helper),l=f.offset(),c=f.outerWidth()-r.sizeDiff.width,h=f.outerHeight()-r.sizeDiff.height;r._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h}),r._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:l.left-u.left-o.left,width:c,height:h})}}),e.ui.plugin.add("resizable","ghost",{start:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size;r.ghost=r.originalElement.clone(),r.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof i.ghost=="string"?i.ghost:""),r.ghost.appendTo(r.helper)},resize:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.ghost.css({position:"relative",height:r.size.height,width:r.size.width})},stop:function(t,n){var r=e(this).data("resizable"),i=r.options;r.ghost&&r.helper&&r.helper.get(0).removeChild(r.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(t,n){var r=e(this).data("resizable"),i=r.options,s=r.size,o=r.originalSize,u=r.originalPosition,a=r.axis,f=i._aspectRatio||t.shiftKey;i.grid=typeof i.grid=="number"?[i.grid,i.grid]:i.grid;var l=Math.round((s.width-o.width)/(i.grid[0]||1))*(i.grid[0]||1),c=Math.round((s.height-o.height)/(i.grid[1]||1))*(i.grid[1]||1);/^(se|s|e)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c):/^(ne)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c):/^(sw)$/.test(a)?(r.size.width=o.width+l,r.size.height=o.height+c,r.position.left=u.left-l):(r.size.width=o.width+l,r.size.height=o.height+c,r.position.top=u.top-c,r.position.left=u.left-l)}});var n=function(e){return parseInt(e,10)||0},r=function(e){return!isNaN(parseInt(e,10))}})(jQuery);(function(e,t){e.widget("ui.selectable",e.ui.mouse,{version:"1.9.2",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch"},_create:function(){var t=this;this.element.addClass("ui-selectable"),this.dragged=!1;var n;this.refresh=function(){n=e(t.options.filter,t.element[0]),n.addClass("ui-selectee"),n.each(function(){var t=e(this),n=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:n.left,top:n.top,right:n.left+t.outerWidth(),bottom:n.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=n.addClass("ui-selectee"),this._mouseInit(),this.helper=e("<div class='ui-selectable-helper'></div>")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var n=this;this.opos=[t.pageX,t.pageY];if(this.options.disabled)return;var r=this.options;this.selectees=e(r.filter,this.element[0]),this._trigger("start",t),e(r.appendTo).append(this.helper),this.helper.css({left:t.clientX,top:t.clientY,width:0,height:0}),r.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var r=e.data(this,"selectable-item");r.startselected=!0,!t.metaKey&&!t.ctrlKey&&(r.$element.removeClass("ui-selected"),r.selected=!1,r.$element.addClass("ui-unselecting"),r.unselecting=!0,n._trigger("unselecting",t,{unselecting:r.element}))}),e(t.target).parents().andSelf().each(function(){var r=e.data(this,"selectable-item");if(r){var i=!t.metaKey&&!t.ctrlKey||!r.$element.hasClass("ui-selected");return r.$element.removeClass(i?"ui-unselecting":"ui-selected").addClass(i?"ui-selecting":"ui-unselecting"),r.unselecting=!i,r.selecting=i,r.selected=i,i?n._trigger("selecting",t,{selecting:r.element}):n._trigger("unselecting",t,{unselecting:r.element}),!1}})},_mouseDrag:function(t){var n=this;this.dragged=!0;if(this.options.disabled)return;var r=this.options,i=this.opos[0],s=this.opos[1],o=t.pageX,u=t.pageY;if(i>o){var a=o;o=i,i=a}if(s>u){var a=u;u=s,s=a}return this.helper.css({left:i,top:s,width:o-i,height:u-s}),this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!a||a.element==n.element[0])return;var f=!1;r.tolerance=="touch"?f=!(a.left>o||a.right<i||a.top>u||a.bottom<s):r.tolerance=="fit"&&(f=a.left>i&&a.right<o&&a.top>s&&a.bottom<u),f?(a.selected&&(a.$element.removeClass("ui-selected"),a.selected=!1),a.unselecting&&(a.$element.removeClass("ui-unselecting"),a.unselecting=!1),a.selecting||(a.$element.addClass("ui-selecting"),a.selecting=!0,n._trigger("selecting",t,{selecting:a.element}))):(a.selecting&&((t.metaKey||t.ctrlKey)&&a.startselected?(a.$element.removeClass("ui-selecting"),a.selecting=!1,a.$element.addClass("ui-selected"),a.selected=!0):(a.$element.removeClass("ui-selecting"),a.selecting=!1,a.startselected&&(a.$element.addClass("ui-unselecting"),a.unselecting=!0),n._trigger("unselecting",t,{unselecting:a.element}))),a.selected&&!t.metaKey&&!t.ctrlKey&&!a.startselected&&(a.$element.removeClass("ui-selected"),a.selected=!1,a.$element.addClass("ui-unselecting"),a.unselecting=!0,n._trigger("unselecting",t,{unselecting:a.element})))}),!1},_mouseStop:function(t){var n=this;this.dragged=!1;var r=this.options;return e(".ui-unselecting",this.element[0]).each(function(){var r=e.data(this,"selectable-item");r.$element.removeClass("ui-unselecting"),r.unselecting=!1,r.startselected=!1,n._trigger("unselected",t,{unselected:r.element})}),e(".ui-selecting",this.element[0]).each(function(){var r=e.data(this,"selectable-item");r.$element.removeClass("ui-selecting").addClass("ui-selected"),r.selecting=!1,r.selected=!0,r.startselected=!0,n._trigger("selected",t,{selected:r.element})}),this._trigger("stop",t),this.helper.remove(),!1}})})(jQuery);(function(e,t){e.widget("ui.sortable",e.ui.mouse,{version:"1.9.2",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?e.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,n){t==="disabled"?(this.options[t]=n,this.widget().toggleClass("ui-sortable-disabled",!!n)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,n){var r=this;if(this.reverting)return!1;if(this.options.disabled||this.options.type=="static")return!1;this._refreshItems(t);var i=null,s=e(t.target).parents().each(function(){if(e.data(this,r.widgetName+"-item")==r)return i=e(this),!1});e.data(t.target,r.widgetName+"-item")==r&&(i=e(t.target));if(!i)return!1;if(this.options.handle&&!n){var o=!1;e(this.options.handle,i).find("*").andSelf().each(function(){this==t.target&&(o=!0)});if(!o)return!1}return this.currentItem=i,this._removeCurrentsFromItems(),!0},_mouseStart:function(t,n,r){var i=this.options;this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),i.containment&&this._setContainment(),i.cursor&&(e("body").css("cursor")&&(this._storedCursor=e("body").css("cursor")),e("body").css("cursor",i.cursor)),i.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",i.opacity)),i.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",i.zIndex)),this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions();if(!r)for(var s=this.containers.length-1;s>=0;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs);if(this.options.scroll){var n=this.options,r=!1;this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<n.scrollSensitivity?this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop+n.scrollSpeed:t.pageY-this.overflowOffset.top<n.scrollSensitivity&&(this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop-n.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<n.scrollSensitivity?this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft+n.scrollSpeed:t.pageX-this.overflowOffset.left<n.scrollSensitivity&&(this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft-n.scrollSpeed)):(t.pageY-e(document).scrollTop()<n.scrollSensitivity?r=e(document).scrollTop(e(document).scrollTop()-n.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<n.scrollSensitivity&&(r=e(document).scrollTop(e(document).scrollTop()+n.scrollSpeed)),t.pageX-e(document).scrollLeft()<n.scrollSensitivity?r=e(document).scrollLeft(e(document).scrollLeft()-n.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<n.scrollSensitivity&&(r=e(document).scrollLeft(e(document).scrollLeft()+n.scrollSpeed))),r!==!1&&e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(var i=this.items.length-1;i>=0;i--){var s=this.items[i],o=s.item[0],u=this._intersectsWithPointer(s);if(!u)continue;if(s.instance!==this.currentContainer)continue;if(o!=this.currentItem[0]&&this.placeholder[u==1?"next":"prev"]()[0]!=o&&!e.contains(this.placeholder[0],o)&&(this.options.type=="semi-dynamic"?!e.contains(this.element[0],o):!0)){this.direction=u==1?"down":"up";if(this.options.tolerance!="pointer"&&!this._intersectsWithSides(s))break;this._rearrange(t,s),this._trigger("change",t,this._uiHash());break}}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,n){if(!t)return;e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t);if(this.options.revert){var r=this,i=this.placeholder.offset();this.reverting=!0,e(this.helper).animate({left:i.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:i.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){r._clear(t)})}else this._clear(t,n);return!1},cancel:function(){if(this.dragging){this._mouseUp({target:null}),this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},e(n).each(function(){var n=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[-=_](.+)/);n&&r.push((t.key||n[1]+"[]")+"="+(t.key&&t.expression?n[1]:n[2]))}),!r.length&&t.key&&r.push(t.key+"="),r.join("&")},toArray:function(t){var n=this._getItemsAsjQuery(t&&t.connected),r=[];return t=t||{},n.each(function(){r.push(e(t.item||this).attr(t.attribute||"id")||"")}),r},_intersectsWith:function(e){var t=this.positionAbs.left,n=t+this.helperProportions.width,r=this.positionAbs.top,i=r+this.helperProportions.height,s=e.left,o=s+e.width,u=e.top,a=u+e.height,f=this.offset.click.top,l=this.offset.click.left,c=r+f>u&&r+f<a&&t+l>s&&t+l<o;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?c:s<t+this.helperProportions.width/2&&n-this.helperProportions.width/2<o&&u<r+this.helperProportions.height/2&&i-this.helperProportions.height/2<a},_intersectsWithPointer:function(t){var n=this.options.axis==="x"||e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top,t.height),r=this.options.axis==="y"||e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left,t.width),i=n&&r,s=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return i?this.floating?o&&o=="right"||s=="down"?2:1:s&&(s=="down"?2:1):!1},_intersectsWithSides:function(t){var n=e.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),r=e.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),i=this._getDragVerticalDirection(),s=this._getDragHorizontalDirection();return this.floating&&s?s=="right"&&r||s=="left"&&!r:i&&(i=="down"&&n||i=="up"&&!n)},_getDragVerticalDirection:function(){var e=this.positionAbs.top-this.lastPositionAbs.top;return e!=0&&(e>0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return e!=0&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor==String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var n=[],r=[],i=this._connectWith();if(i&&t)for(var s=i.length-1;s>=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&r.push([e.isFunction(a.options.items)?a.options.items.call(a.element):e(a.options.items,a.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),a])}}r.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var s=r.length-1;s>=0;s--)r[s][0].each(function(){n.push(this)});return e(n)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var n=0;n<t.length;n++)if(t[n]==e.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var n=this.items,r=[[e.isFunction(this.options.items)?this.options.items.call(this.element[0],t,{item:this.currentItem}):e(this.options.items,this.element),this]],i=this._connectWith();if(i&&this.ready)for(var s=i.length-1;s>=0;s--){var o=e(i[s]);for(var u=o.length-1;u>=0;u--){var a=e.data(o[u],this.widgetName);a&&a!=this&&!a.options.disabled&&(r.push([e.isFunction(a.options.items)?a.options.items.call(a.element[0],t,{item:this.currentItem}):e(a.options.items,a.element),a]),this.containers.push(a))}}for(var s=r.length-1;s>=0;s--){var f=r[s][1],l=r[s][0];for(var u=0,c=l.length;u<c;u++){var h=e(l[u]);h.data(this.widgetName+"-item",f),n.push({item:h,instance:f,width:0,height:0,left:0,top:0})}}},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var n=this.items.length-1;n>=0;n--){var r=this.items[n];if(r.instance!=this.currentContainer&&this.currentContainer&&r.item[0]!=this.currentItem[0])continue;var i=this.options.toleranceElement?e(this.options.toleranceElement,r.item):r.item;t||(r.width=i.outerWidth(),r.height=i.outerHeight());var s=i.offset();r.left=s.left,r.top=s.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var n=this.containers.length-1;n>=0;n--){var s=this.containers[n].element.offset();this.containers[n].containerCache.left=s.left,this.containers[n].containerCache.top=s.top,this.containers[n].containerCache.width=this.containers[n].element.outerWidth(),this.containers[n].containerCache.height=this.containers[n].element.outerHeight()}return this},_createPlaceholder:function(t){t=t||this;var n=t.options;if(!n.placeholder||n.placeholder.constructor==String){var r=n.placeholder;n.placeholder={element:function(){var n=e(document.createElement(t.currentItem[0].nodeName)).addClass(r||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return r||(n.style.visibility="hidden"),n},update:function(e,i){if(r&&!n.forcePlaceholderSize)return;i.height()||i.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),i.width()||i.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10))}}}t.placeholder=e(n.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),n.placeholder.update(t,t.placeholder)},_contactContainers:function(t){var n=null,r=null;for(var i=this.containers.length-1;i>=0;i--){if(e.contains(this.currentItem[0],this.containers[i].element[0]))continue;if(this._intersectsWith(this.containers[i].containerCache)){if(n&&e.contains(this.containers[i].element[0],n.element[0]))continue;n=this.containers[i],r=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",t,this._uiHash(this)),this.containers[i].containerCache.over=0)}if(!n)return;if(this.containers.length===1)this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1;else{var s=1e4,o=null,u=this.containers[r].floating?"left":"top",a=this.containers[r].floating?"width":"height",f=this.positionAbs[u]+this.offset.click[u];for(var l=this.items.length-1;l>=0;l--){if(!e.contains(this.containers[r].element[0],this.items[l].item[0]))continue;if(this.items[l].item[0]==this.currentItem[0])continue;var c=this.items[l].item.offset()[u],h=!1;Math.abs(c-f)>Math.abs(c+this.items[l][a]-f)&&(h=!0,c+=this.items[l][a]),Math.abs(c-f)<s&&(s=Math.abs(c-f),o=this.items[l],this.direction=h?"up":"down")}if(!o&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[r],o?this._rearrange(t,o,null,!0):this._rearrange(t,null,this.containers[r].element,!0),this._trigger("change",t,this._uiHash()),this.containers[r]._trigger("change",t,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[r]._trigger("over",t,this._uiHash(this)),this.containers[r].containerCache.over=1}},_createHelper:function(t){var n=this.options,r=e.isFunction(n.helper)?e(n.helper.apply(this.element[0],[t,this.currentItem])):n.helper=="clone"?this.currentItem.clone():this.currentItem;return r.parents("body").length||e(n.appendTo!="parent"?n.appendTo:this.currentItem[0].parentNode)[0].appendChild(r[0]),r[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(r[0].style.width==""||n.forceHelperSize)&&r.width(this.currentItem.width()),(r[0].style.height==""||n.forceHelperSize)&&r.height(this.currentItem.height()),r},_adjustOffsetFromHelper:function(t){typeof t=="string"&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop());if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&e.ui.ie)t={top:0,left:0};return{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t=this.options;t.containment=="parent"&&(t.containment=this.helper[0].parentNode);if(t.containment=="document"||t.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e(t.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(e(t.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(t.containment)){var n=e(t.containment)[0],r=e(t.containment).offset(),i=e(n).css("overflow")!="hidden";this.containment=[r.left+(parseInt(e(n).css("borderLeftWidth"),10)||0)+(parseInt(e(n).css("paddingLeft"),10)||0)-this.margins.left,r.top+(parseInt(e(n).css("borderTopWidth"),10)||0)+(parseInt(e(n).css("paddingTop"),10)||0)-this.margins.top,r.left+(i?Math.max(n.scrollWidth,n.offsetWidth):n.offsetWidth)-(parseInt(e(n).css("borderLeftWidth"),10)||0)-(parseInt(e(n).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,r.top+(i?Math.max(n.scrollHeight,n.offsetHeight):n.offsetHeight)-(parseInt(e(n).css("borderTopWidth"),10)||0)-(parseInt(e(n).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(t,n){n||(n=this.position);var r=t=="absolute"?1:-1,i=this.options,s=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,o=/(html|body)/i.test(s[0].tagName);return{top:n.top+this.offset.relative.top*r+this.offset.parent.top*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():o?0:s.scrollTop())*r,left:n.left+this.offset.relative.left*r+this.offset.parent.left*r-(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():o?0:s.scrollLeft())*r}},_generatePosition:function(t){var n=this.options,r=this.cssPosition!="absolute"||this.scrollParent[0]!=document&&!!e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,i=/(html|body)/i.test(r[0].tagName);this.cssPosition=="relative"&&(this.scrollParent[0]==document||this.scrollParent[0]==this.offsetParent[0])&&(this.offset.relative=this._getRelativeOffset());var s=t.pageX,o=t.pageY;if(this.originalPosition){this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(s=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top));if(n.grid){var u=this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1];o=this.containment?u-this.offset.click.top<this.containment[1]||u-this.offset.click.top>this.containment[3]?u-this.offset.click.top<this.containment[1]?u+n.grid[1]:u-n.grid[1]:u:u;var a=this.originalPageX+Math.round((s-this.originalPageX)/n.grid[0])*n.grid[0];s=this.containment?a-this.offset.click.left<this.containment[0]||a-this.offset.click.left>this.containment[2]?a-this.offset.click.left<this.containment[0]?a+n.grid[0]:a-n.grid[0]:a:a}}return{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():i?0:r.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():i?0:r.scrollLeft())}},_rearrange:function(e,t,n,r){n?n[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var i=this.counter;this._delay(function(){i==this.counter&&this.refreshPositions(!r)})},_clear:function(t,n){this.reverting=!1;var r=[];!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var i in this._storedCSS)if(this._storedCSS[i]=="auto"||this._storedCSS[i]=="static")this._storedCSS[i]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!n&&r.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),(this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!n&&r.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(n||(r.push(function(e){this._trigger("remove",e,this._uiHash())}),r.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),r.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer))));for(var i=this.containers.length-1;i>=0;i--)n||r.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(r.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);this._storedCursor&&e("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex),this.dragging=!1;if(this.cancelHelperRemoval){if(!n){this._trigger("beforeStop",t,this._uiHash());for(var i=0;i<r.length;i++)r[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}n||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null;if(!n){for(var i=0;i<r.length;i++)r[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){e.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(t){var n=t||this;return{helper:n.helper,placeholder:n.placeholder||e([]),position:n.position,originalPosition:n.originalPosition,offset:n.positionAbs,item:n.currentItem,sender:t?t.element:null}}})})(jQuery);(function(e,t){var n=0,r={},i={};r.height=r.paddingTop=r.paddingBottom=r.borderTopWidth=r.borderBottomWidth="hide",i.height=i.paddingTop=i.paddingBottom=i.borderTopWidth=i.borderBottomWidth="show",e.widget("ui.accordion",{version:"1.9.2",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},_create:function(){var t=this.accordionId="ui-accordion-"+(this.element.attr("id")||++n),r=this.options;this.prevShow=this.prevHide=e(),this.element.addClass("ui-accordion ui-widget ui-helper-reset"),this.headers=this.element.find(r.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all"),this._hoverable(this.headers),this._focusable(this.headers),this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").hide(),!r.collapsible&&(r.active===!1||r.active==null)&&(r.active=0),r.active<0&&(r.active+=this.headers.length),this.active=this._findActive(r.active).addClass("ui-accordion-header-active ui-state-active").toggleClass("ui-corner-all ui-corner-top"),this.active.next().addClass("ui-accordion-content-active").show(),this._createIcons(),this.refresh(),this.element.attr("role","tablist"),this.headers.attr("role","tab").each(function(n){var r=e(this),i=r.attr("id"),s=r.next(),o=s.attr("id");i||(i=t+"-header-"+n,r.attr("id",i)),o||(o=t+"-panel-"+n,s.attr("id",o)),r.attr("aria-controls",o),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false",tabIndex:-1}).next().attr({"aria-expanded":"false","aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true",tabIndex:0}).next().attr({"aria-expanded":"true","aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._on(this.headers,{keydown:"_keydown"}),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._setupEvents(r.event)},_getCreateEventData:function(){return{header:this.active,content:this.active.length?this.active.next():e()}},_createIcons:function(){var t=this.options.icons;t&&(e("<span>").addClass("ui-accordion-header-icon ui-icon "+t.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var e;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this._destroyIcons(),e=this.headers.next().css("display","").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").each(function(){/^ui-accordion/.test(this.id)&&this.removeAttribute("id")}),this.options.heightStyle!=="content"&&e.css("height","")},_setOption:function(e,t){if(e==="active"){this._activate(t);return}e==="event"&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(t)),this._super(e,t),e==="collapsible"&&!t&&this.options.active===!1&&this._activate(0),e==="icons"&&(this._destroyIcons(),t&&this._createIcons()),e==="disabled"&&this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!t)},_keydown:function(t){if(t.altKey||t.ctrlKey)return;var n=e.ui.keyCode,r=this.headers.length,i=this.headers.index(t.target),s=!1;switch(t.keyCode){case n.RIGHT:case n.DOWN:s=this.headers[(i+1)%r];break;case n.LEFT:case n.UP:s=this.headers[(i-1+r)%r];break;case n.SPACE:case n.ENTER:this._eventHandler(t);break;case n.HOME:s=this.headers[0];break;case n.END:s=this.headers[r-1]}s&&(e(t.target).attr("tabIndex",-1),e(s).attr("tabIndex",0),s.focus(),t.preventDefault())},_panelKeyDown:function(t){t.keyCode===e.ui.keyCode.UP&&t.ctrlKey&&e(t.currentTarget).prev().focus()},refresh:function(){var t,n,r=this.options.heightStyle,i=this.element.parent();r==="fill"?(e.support.minHeight||(n=i.css("overflow"),i.css("overflow","hidden")),t=i.height(),this.element.siblings(":visible").each(function(){var n=e(this),r=n.css("position");if(r==="absolute"||r==="fixed")return;t-=n.outerHeight(!0)}),n&&i.css("overflow",n),this.headers.each(function(){t-=e(this).outerHeight(!0)}),this.headers.next().each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):r==="auto"&&(t=0,this.headers.next().each(function(){t=Math.max(t,e(this).css("height","").height())}).height(t))},_activate:function(t){var n=this._findActive(t)[0];if(n===this.active[0])return;n=n||this.active[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return typeof t=="number"?this.headers.eq(t):e()},_setupEvents:function(t){var n={};if(!t)return;e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._on(this.headers,n)},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i[0]===r[0],o=s&&n.collapsible,u=o?e():i.next(),a=r.next(),f={oldHeader:r,oldPanel:a,newHeader:o?e():i,newPanel:u};t.preventDefault();if(s&&!n.collapsible||this._trigger("beforeActivate",t,f)===!1)return;n.active=o?!1:this.headers.index(i),this.active=s?e():i,this._toggle(f),r.removeClass("ui-accordion-header-active ui-state-active"),n.icons&&r.children(".ui-accordion-header-icon").removeClass(n.icons.activeHeader).addClass(n.icons.header),s||(i.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),n.icons&&i.children(".ui-accordion-header-icon").removeClass(n.icons.header).addClass(n.icons.activeHeader),i.next().addClass("ui-accordion-content-active"))},_toggle:function(t){var n=t.newPanel,r=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=n,this.prevHide=r,this.options.animate?this._animate(n,r,t):(r.hide(),n.show(),this._toggleComplete(t)),r.attr({"aria-expanded":"false","aria-hidden":"true"}),r.prev().attr("aria-selected","false"),n.length&&r.length?r.prev().attr("tabIndex",-1):n.length&&this.headers.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),n.attr({"aria-expanded":"true","aria-hidden":"false"}).prev().attr({"aria-selected":"true",tabIndex:0})},_animate:function(e,t,n){var s,o,u,a=this,f=0,l=e.length&&(!t.length||e.index()<t.index()),c=this.options.animate||{},h=l&&c.down||c,p=function(){a._toggleComplete(n)};typeof h=="number"&&(u=h),typeof h=="string"&&(o=h),o=o||h.easing||c.easing,u=u||h.duration||c.duration;if(!t.length)return e.animate(i,u,o,p);if(!e.length)return t.animate(r,u,o,p);s=e.show().outerHeight(),t.animate(r,{duration:u,easing:o,step:function(e,t){t.now=Math.round(e)}}),e.hide().animate(i,{duration:u,easing:o,complete:p,step:function(e,n){n.now=Math.round(e),n.prop!=="height"?f+=n.now:a.options.heightStyle!=="content"&&(n.now=Math.round(s-t.outerHeight()-f),f=0)}})},_toggleComplete:function(e){var t=e.oldPanel;t.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"),t.length&&(t.parent()[0].className=t.parent()[0].className),this._trigger("activate",null,e)}}),e.uiBackCompat!==!1&&(function(e,t){e.extend(t.options,{navigation:!1,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}});var n=t._create;t._create=function(){if(this.options.navigation){var t=this,r=this.element.find(this.options.header),i=r.next(),s=r.add(i).find("a").filter(this.options.navigationFilter)[0];s&&r.add(i).each(function(n){if(e.contains(this,s))return t.options.active=Math.floor(n/2),!1})}n.call(this)}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options,{heightStyle:null,autoHeight:!0,clearStyle:!1,fillSpace:!1});var n=t._create,r=t._setOption;e.extend(t,{_create:function(){this.options.heightStyle=this.options.heightStyle||this._mergeHeightStyle(),n.call(this)},_setOption:function(e){if(e==="autoHeight"||e==="clearStyle"||e==="fillSpace")this.options.heightStyle=this._mergeHeightStyle();r.apply(this,arguments)},_mergeHeightStyle:function(){var e=this.options;if(e.fillSpace)return"fill";if(e.clearStyle)return"content";if(e.autoHeight)return"auto"}})}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options.icons,{activeHeader:null,headerSelected:"ui-icon-triangle-1-s"});var n=t._createIcons;t._createIcons=function(){this.options.icons&&(this.options.icons.activeHeader=this.options.icons.activeHeader||this.options.icons.headerSelected),n.call(this)}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){t.activate=t._activate;var n=t._findActive;t._findActive=function(e){return e===-1&&(e=!1),e&&typeof e!="number"&&(e=this.headers.index(this.headers.filter(e)),e===-1&&(e=!1)),n.call(this,e)}}(jQuery,jQuery.ui.accordion.prototype),jQuery.ui.accordion.prototype.resize=jQuery.ui.accordion.prototype.refresh,function(e,t){e.extend(t.options,{change:null,changestart:null});var n=t._trigger;t._trigger=function(e,t,r){var i=n.apply(this,arguments);return i?(e==="beforeActivate"?i=n.call(this,"changestart",t,{oldHeader:r.oldHeader,oldContent:r.oldPanel,newHeader:r.newHeader,newContent:r.newPanel}):e==="activate"&&(i=n.call(this,"change",t,{oldHeader:r.oldHeader,oldContent:r.oldPanel,newHeader:r.newHeader,newContent:r.newPanel})),i):!1}}(jQuery,jQuery.ui.accordion.prototype),function(e,t){e.extend(t.options,{animate:null,animated:"slide"});var n=t._create;t._create=function(){var e=this.options;e.animate===null&&(e.animated?e.animated==="slide"?e.animate=300:e.animated==="bounceslide"?e.animate={duration:200,down:{easing:"easeOutBounce",duration:1e3}}:e.animate=e.animated:e.animate=!1),n.call(this)}}(jQuery,jQuery.ui.accordion.prototype))})(jQuery);(function(e,t){var n,r,i,s,o="ui-button ui-widget ui-state-default ui-corner-all",u="ui-state-hover ui-state-active ",a="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",f=function(){var t=e(this).find(":ui-button");setTimeout(function(){t.button("refresh")},1)},l=function(t){var n=t.name,r=t.form,i=e([]);return n&&(r?i=e(r).find("[name='"+n+"']"):i=e("[name='"+n+"']",t.ownerDocument).filter(function(){return!this.form})),i};e.widget("ui.button",{version:"1.9.2",defaultElement:"<button>",options:{disabled:null,text:!0,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset"+this.eventNamespace).bind("reset"+this.eventNamespace,f),typeof this.options.disabled!="boolean"?this.options.disabled=!!this.element.prop("disabled"):this.element.prop("disabled",this.options.disabled),this._determineButtonType(),this.hasTitle=!!this.buttonElement.attr("title");var t=this,u=this.options,a=this.type==="checkbox"||this.type==="radio",c=a?"":"ui-state-active",h="ui-state-focus";u.label===null&&(u.label=this.type==="input"?this.buttonElement.val():this.buttonElement.html()),this._hoverable(this.buttonElement),this.buttonElement.addClass(o).attr("role","button").bind("mouseenter"+this.eventNamespace,function(){if(u.disabled)return;this===n&&e(this).addClass("ui-state-active")}).bind("mouseleave"+this.eventNamespace,function(){if(u.disabled)return;e(this).removeClass(c)}).bind("click"+this.eventNamespace,function(e){u.disabled&&(e.preventDefault(),e.stopImmediatePropagation())}),this.element.bind("focus"+this.eventNamespace,function(){t.buttonElement.addClass(h)}).bind("blur"+this.eventNamespace,function(){t.buttonElement.removeClass(h)}),a&&(this.element.bind("change"+this.eventNamespace,function(){if(s)return;t.refresh()}),this.buttonElement.bind("mousedown"+this.eventNamespace,function(e){if(u.disabled)return;s=!1,r=e.pageX,i=e.pageY}).bind("mouseup"+this.eventNamespace,function(e){if(u.disabled)return;if(r!==e.pageX||i!==e.pageY)s=!0})),this.type==="checkbox"?this.buttonElement.bind("click"+this.eventNamespace,function(){if(u.disabled||s)return!1;e(this).toggleClass("ui-state-active"),t.buttonElement.attr("aria-pressed",t.element[0].checked)}):this.type==="radio"?this.buttonElement.bind("click"+this.eventNamespace,function(){if(u.disabled||s)return!1;e(this).addClass("ui-state-active"),t.buttonElement.attr("aria-pressed","true");var n=t.element[0];l(n).not(n).map(function(){return e(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")}):(this.buttonElement.bind("mousedown"+this.eventNamespace,function(){if(u.disabled)return!1;e(this).addClass("ui-state-active"),n=this,t.document.one("mouseup",function(){n=null})}).bind("mouseup"+this.eventNamespace,function(){if(u.disabled)return!1;e(this).removeClass("ui-state-active")}).bind("keydown"+this.eventNamespace,function(t){if(u.disabled)return!1;(t.keyCode===e.ui.keyCode.SPACE||t.keyCode===e.ui.keyCode.ENTER)&&e(this).addClass("ui-state-active")}).bind("keyup"+this.eventNamespace,function(){e(this).removeClass("ui-state-active")}),this.buttonElement.is("a")&&this.buttonElement.keyup(function(t){t.keyCode===e.ui.keyCode.SPACE&&e(this).click()})),this._setOption("disabled",u.disabled),this._resetButton()},_determineButtonType:function(){var e,t,n;this.element.is("[type=checkbox]")?this.type="checkbox":this.element.is("[type=radio]")?this.type="radio":this.element.is("input")?this.type="input":this.type="button",this.type==="checkbox"||this.type==="radio"?(e=this.element.parents().last(),t="label[for='"+this.element.attr("id")+"']",this.buttonElement=e.find(t),this.buttonElement.length||(e=e.length?e.siblings():this.element.siblings(),this.buttonElement=e.filter(t),this.buttonElement.length||(this.buttonElement=e.find(t))),this.element.addClass("ui-helper-hidden-accessible"),n=this.element.is(":checked"),n&&this.buttonElement.addClass("ui-state-active"),this.buttonElement.prop("aria-pressed",n)):this.buttonElement=this.element},widget:function(){return this.buttonElement},_destroy:function(){this.element.removeClass("ui-helper-hidden-accessible"),this.buttonElement.removeClass(o+" "+u+" "+a).removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html()),this.hasTitle||this.buttonElement.removeAttr("title")},_setOption:function(e,t){this._super(e,t);if(e==="disabled"){t?this.element.prop("disabled",!0):this.element.prop("disabled",!1);return}this._resetButton()},refresh:function(){var t=this.element.is("input, button")?this.element.is(":disabled"):this.element.hasClass("ui-button-disabled");t!==this.options.disabled&&this._setOption("disabled",t),this.type==="radio"?l(this.element[0]).each(function(){e(this).is(":checked")?e(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):e(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")}):this.type==="checkbox"&&(this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false"))},_resetButton:function(){if(this.type==="input"){this.options.label&&this.element.val(this.options.label);return}var t=this.buttonElement.removeClass(a),n=e("<span></span>",this.document[0]).addClass("ui-button-text").html(this.options.label).appendTo(t.empty()).text(),r=this.options.icons,i=r.primary&&r.secondary,s=[];r.primary||r.secondary?(this.options.text&&s.push("ui-button-text-icon"+(i?"s":r.primary?"-primary":"-secondary")),r.primary&&t.prepend("<span class='ui-button-icon-primary ui-icon "+r.primary+"'></span>"),r.secondary&&t.append("<span class='ui-button-icon-secondary ui-icon "+r.secondary+"'></span>"),this.options.text||(s.push(i?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||t.attr("title",e.trim(n)))):s.push("ui-button-text-only"),t.addClass(s.join(" "))}}),e.widget("ui.buttonset",{version:"1.9.2",options:{items:"button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(e,t){e==="disabled"&&this.buttons.button("option",e,t),this._super(e,t)},refresh:function(){var t=this.element.css("direction")==="rtl";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(t?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(t?"ui-corner-left":"ui-corner-right").end().end()},_destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy")}})})(jQuery);(function(e,t){var n="ui-dialog ui-widget ui-widget-content ui-corner-all ",r={buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},i={maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0};e.widget("ui.dialog",{version:"1.9.2",options:{autoOpen:!0,buttons:{},closeOnEscape:!0,closeText:"close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:!1,maxWidth:!1,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var n=e(this).css(t).offset().top;n<0&&e(this).css("top",t.top-n)}},resizable:!0,show:null,stack:!0,title:"",width:300,zIndex:1e3},_create:function(){this.originalTitle=this.element.attr("title"),typeof this.originalTitle!="string"&&(this.originalTitle=""),this.oldPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.options.title=this.options.title||this.originalTitle;var t=this,r=this.options,i=r.title||"&#160;",s,o,u,a,f;s=(this.uiDialog=e("<div>")).addClass(n+r.dialogClass).css({display:"none",outline:0,zIndex:r.zIndex}).attr("tabIndex",-1).keydown(function(n){r.closeOnEscape&&!n.isDefaultPrevented()&&n.keyCode&&n.keyCode===e.ui.keyCode.ESCAPE&&(t.close(n),n.preventDefault())}).mousedown(function(e){t.moveToTop(!1,e)}).appendTo("body"),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(s),o=(this.uiDialogTitlebar=e("<div>")).addClass("ui-dialog-titlebar  ui-widget-header  ui-corner-all  ui-helper-clearfix").bind("mousedown",function(){s.focus()}).prependTo(s),u=e("<a href='#'></a>").addClass("ui-dialog-titlebar-close  ui-corner-all").attr("role","button").click(function(e){e.preventDefault(),t.close(e)}).appendTo(o),(this.uiDialogTitlebarCloseText=e("<span>")).addClass("ui-icon ui-icon-closethick").text(r.closeText).appendTo(u),a=e("<span>").uniqueId().addClass("ui-dialog-title").html(i).prependTo(o),f=(this.uiDialogButtonPane=e("<div>")).addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),(this.uiButtonSet=e("<div>")).addClass("ui-dialog-buttonset").appendTo(f),s.attr({role:"dialog","aria-labelledby":a.attr("id")}),o.find("*").add(o).disableSelection(),this._hoverable(u),this._focusable(u),r.draggable&&e.fn.draggable&&this._makeDraggable(),r.resizable&&e.fn.resizable&&this._makeResizable(),this._createButtons(r.buttons),this._isOpen=!1,e.fn.bgiframe&&s.bgiframe(),this._on(s,{keydown:function(t){if(!r.modal||t.keyCode!==e.ui.keyCode.TAB)return;var n=e(":tabbable",s),i=n.filter(":first"),o=n.filter(":last");if(t.target===o[0]&&!t.shiftKey)return i.focus(1),!1;if(t.target===i[0]&&t.shiftKey)return o.focus(1),!1}})},_init:function(){this.options.autoOpen&&this.open()},_destroy:function(){var e,t=this.oldPosition;this.overlay&&this.overlay.destroy(),this.uiDialog.hide(),this.element.removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"),this.uiDialog.remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},close:function(t){var n=this,r,i;if(!this._isOpen)return;if(!1===this._trigger("beforeClose",t))return;return this._isOpen=!1,this.overlay&&this.overlay.destroy(),this.options.hide?this._hide(this.uiDialog,this.options.hide,function(){n._trigger("close",t)}):(this.uiDialog.hide(),this._trigger("close",t)),e.ui.dialog.overlay.resize(),this.options.modal&&(r=0,e(".ui-dialog").each(function(){this!==n.uiDialog[0]&&(i=e(this).css("z-index"),isNaN(i)||(r=Math.max(r,i)))}),e.ui.dialog.maxZ=r),this},isOpen:function(){return this._isOpen},moveToTop:function(t,n){var r=this.options,i;return r.modal&&!t||!r.stack&&!r.modal?this._trigger("focus",n):(r.zIndex>e.ui.dialog.maxZ&&(e.ui.dialog.maxZ=r.zIndex),this.overlay&&(e.ui.dialog.maxZ+=1,e.ui.dialog.overlay.maxZ=e.ui.dialog.maxZ,this.overlay.$el.css("z-index",e.ui.dialog.overlay.maxZ)),i={scrollTop:this.element.scrollTop(),scrollLeft:this.element.scrollLeft()},e.ui.dialog.maxZ+=1,this.uiDialog.css("z-index",e.ui.dialog.maxZ),this.element.attr(i),this._trigger("focus",n),this)},open:function(){if(this._isOpen)return;var t,n=this.options,r=this.uiDialog;return this._size(),this._position(n.position),r.show(n.show),this.overlay=n.modal?new e.ui.dialog.overlay(this):null,this.moveToTop(!0),t=this.element.find(":tabbable"),t.length||(t=this.uiDialogButtonPane.find(":tabbable"),t.length||(t=r)),t.eq(0).focus(),this._isOpen=!0,this._trigger("open"),this},_createButtons:function(t){var n=this,r=!1;this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),typeof t=="object"&&t!==null&&e.each(t,function(){return!(r=!0)}),r?(e.each(t,function(t,r){var i,s;r=e.isFunction(r)?{click:r,text:t}:r,r=e.extend({type:"button"},r),s=r.click,r.click=function(){s.apply(n.element[0],arguments)},i=e("<button></button>",r).appendTo(n.uiButtonSet),e.fn.button&&i.button()}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog)):this.uiDialog.removeClass("ui-dialog-buttons")},_makeDraggable:function(){function r(e){return{position:e.position,offset:e.offset}}var t=this,n=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(n,i){e(this).addClass("ui-dialog-dragging"),t._trigger("dragStart",n,r(i))},drag:function(e,n){t._trigger("drag",e,r(n))},stop:function(i,s){n.position=[s.position.left-t.document.scrollLeft(),s.position.top-t.document.scrollTop()],e(this).removeClass("ui-dialog-dragging"),t._trigger("dragStop",i,r(s)),e.ui.dialog.overlay.resize()}})},_makeResizable:function(n){function u(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}n=n===t?this.options.resizable:n;var r=this,i=this.options,s=this.uiDialog.css("position"),o=typeof n=="string"?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:i.maxWidth,maxHeight:i.maxHeight,minWidth:i.minWidth,minHeight:this._minHeight(),handles:o,start:function(t,n){e(this).addClass("ui-dialog-resizing"),r._trigger("resizeStart",t,u(n))},resize:function(e,t){r._trigger("resize",e,u(t))},stop:function(t,n){e(this).removeClass("ui-dialog-resizing"),i.height=e(this).height(),i.width=e(this).width(),r._trigger("resizeStop",t,u(n)),e.ui.dialog.overlay.resize()}}).css("position",s).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var e=this.options;return e.height==="auto"?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(t){var n=[],r=[0,0],i;if(t){if(typeof t=="string"||typeof t=="object"&&"0"in t)n=t.split?t.split(" "):[t[0],t[1]],n.length===1&&(n[1]=n[0]),e.each(["left","top"],function(e,t){+n[e]===n[e]&&(r[e]=n[e],n[e]=t)}),t={my:n[0]+(r[0]<0?r[0]:"+"+r[0])+" "+n[1]+(r[1]<0?r[1]:"+"+r[1]),at:n.join(" ")};t=e.extend({},e.ui.dialog.prototype.options.position,t)}else t=e.ui.dialog.prototype.options.position;i=this.uiDialog.is(":visible"),i||this.uiDialog.show(),this.uiDialog.position(t),i||this.uiDialog.hide()},_setOptions:function(t){var n=this,s={},o=!1;e.each(t,function(e,t){n._setOption(e,t),e in r&&(o=!0),e in i&&(s[e]=t)}),o&&this._size(),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",s)},_setOption:function(t,r){var i,s,o=this.uiDialog;switch(t){case"buttons":this._createButtons(r);break;case"closeText":this.uiDialogTitlebarCloseText.text(""+r);break;case"dialogClass":o.removeClass(this.options.dialogClass).addClass(n+r);break;case"disabled":r?o.addClass("ui-dialog-disabled"):o.removeClass("ui-dialog-disabled");break;case"draggable":i=o.is(":data(draggable)"),i&&!r&&o.draggable("destroy"),!i&&r&&this._makeDraggable();break;case"position":this._position(r);break;case"resizable":s=o.is(":data(resizable)"),s&&!r&&o.resizable("destroy"),s&&typeof r=="string"&&o.resizable("option","handles",r),!s&&r!==!1&&this._makeResizable(r);break;case"title":e(".ui-dialog-title",this.uiDialogTitlebar).html(""+(r||"&#160;"))}this._super(t,r)},_size:function(){var t,n,r,i=this.options,s=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0}),i.minWidth>i.width&&(i.width=i.minWidth),t=this.uiDialog.css({height:"auto",width:i.width}).outerHeight(),n=Math.max(0,i.minHeight-t),i.height==="auto"?e.support.minHeight?this.element.css({minHeight:n,height:"auto"}):(this.uiDialog.show(),r=this.element.css("height","auto").height(),s||this.uiDialog.hide(),this.element.height(Math.max(r,n))):this.element.height(Math.max(i.height-t,0)),this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}}),e.extend(e.ui.dialog,{uuid:0,maxZ:0,getTitleId:function(e){var t=e.attr("id");return t||(this.uuid+=1,t=this.uuid),"ui-dialog-title-"+t},overlay:function(t){this.$el=e.ui.dialog.overlay.create(t)}}),e.extend(e.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:e.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(e){return e+".dialog-overlay"}).join(" "),create:function(t){this.instances.length===0&&(setTimeout(function(){e.ui.dialog.overlay.instances.length&&e(document).bind(e.ui.dialog.overlay.events,function(t){if(e(t.target).zIndex()<e.ui.dialog.overlay.maxZ)return!1})},1),e(window).bind("resize.dialog-overlay",e.ui.dialog.overlay.resize));var n=this.oldInstances.pop()||e("<div>").addClass("ui-widget-overlay");return e(document).bind("keydown.dialog-overlay",function(r){var i=e.ui.dialog.overlay.instances;i.length!==0&&i[i.length-1]===n&&t.options.closeOnEscape&&!r.isDefaultPrevented()&&r.keyCode&&r.keyCode===e.ui.keyCode.ESCAPE&&(t.close(r),r.preventDefault())}),n.appendTo(document.body).css({width:this.width(),height:this.height()}),e.fn.bgiframe&&n.bgiframe(),this.instances.push(n),n},destroy:function(t){var n=e.inArray(t,this.instances),r=0;n!==-1&&this.oldInstances.push(this.instances.splice(n,1)[0]),this.instances.length===0&&e([document,window]).unbind(".dialog-overlay"),t.height(0).width(0).remove(),e.each(this.instances,function(){r=Math.max(r,this.css("z-index"))}),this.maxZ=r},height:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),n=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight),t<n?e(window).height()+"px":t+"px"):e(document).height()+"px"},width:function(){var t,n;return e.ui.ie?(t=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),n=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth),t<n?e(window).width()+"px":t+"px"):e(document).width()+"px"},resize:function(){var t=e([]);e.each(e.ui.dialog.overlay.instances,function(){t=t.add(this)}),t.css({width:0,height:0}).css({width:e.ui.dialog.overlay.width(),height:e.ui.dialog.overlay.height()})}}),e.extend(e.ui.dialog.overlay.prototype,{destroy:function(){e.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);(function(e,t){function i(){return++n}function s(e){return e.hash.length>1&&e.href.replace(r,"")===location.href.replace(r,"").replace(/\s/g,"%20")}var n=0,r=/#.*$/;e.widget("ui.tabs",{version:"1.9.2",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_create:function(){var t=this,n=this.options,r=n.active,i=location.hash.substring(1);this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",n.collapsible).delegate(".ui-tabs-nav > li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this._processTabs();if(r===null){i&&this.tabs.each(function(t,n){if(e(n).attr("aria-controls")===i)return r=t,!1}),r===null&&(r=this.tabs.index(this.tabs.filter(".ui-tabs-active")));if(r===null||r===-1)r=this.tabs.length?0:!1}r!==!1&&(r=this.tabs.index(this.tabs.eq(r)),r===-1&&(r=n.collapsible?!1:0)),n.active=r,!n.collapsible&&n.active===!1&&this.anchors.length&&(n.active=0),e.isArray(n.disabled)&&(n.disabled=e.unique(n.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.options.active!==!1&&this.anchors.length?this.active=this._findActive(this.options.active):this.active=e(),this._refresh(),this.active.length&&this.load(n.active)},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var n=e(this.document[0].activeElement).closest("li"),r=this.tabs.index(n),i=!0;if(this._handlePageNav(t))return;switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:r++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:i=!1,r--;break;case e.ui.keyCode.END:r=this.anchors.length-1;break;case e.ui.keyCode.HOME:r=0;break;case e.ui.keyCode.SPACE:t.preventDefault(),clearTimeout(this.activating),this._activate(r);return;case e.ui.keyCode.ENTER:t.preventDefault(),clearTimeout(this.activating),this._activate(r===this.options.active?!1:r);return;default:return}t.preventDefault(),clearTimeout(this.activating),r=this._focusNextTab(r,i),t.ctrlKey||(n.attr("aria-selected","false"),this.tabs.eq(r).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",r)},this.delay))},_panelKeydown:function(t){if(this._handlePageNav(t))return;t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP)return this._activate(this._focusNextTab(this.options.active-1,!1)),!0;if(t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN)return this._activate(this._focusNextTab(this.options.active+1,!0)),!0},_findNextTab:function(t,n){function i(){return t>r&&(t=0),t<0&&(t=r),t}var r=this.tabs.length-1;while(e.inArray(i(),this.options.disabled)!==-1)t=n?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,t){if(e==="active"){this._activate(t);return}if(e==="disabled"){this._setupDisabled(t);return}this._super(e,t),e==="collapsible"&&(this.element.toggleClass("ui-tabs-collapsible",t),!t&&this.options.active===!1&&this._activate(0)),e==="event"&&this._setupEvents(t),e==="heightStyle"&&this._setupHeightStyle(t)},_tabId:function(e){return e.attr("aria-controls")||"ui-tabs-"+i()},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,n=this.tablist.children(":has(a[href])");t.disabled=e.map(n.filter(".ui-state-disabled"),function(e){return n.index(e)}),this._processTabs(),t.active===!1||!this.anchors.length?(t.active=!1,this.active=e()):this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-expanded":"false","aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-expanded":"true","aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist"),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]}).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(n,r){var i,o,u,a=e(r).uniqueId().attr("id"),f=e(r).closest("li"),l=f.attr("aria-controls");s(r)?(i=r.hash,o=t.element.find(t._sanitizeSelector(i))):(u=t._tabId(f),i="#"+u,o=t.element.find(i),o.length||(o=t._createPanel(u),o.insertAfter(t.panels[n-1]||t.tablist)),o.attr("aria-live","polite")),o.length&&(t.panels=t.panels.add(o)),l&&f.data("ui-tabs-aria-controls",l),f.attr({"aria-controls":i.substring(1),"aria-labelledby":a}),o.attr("aria-labelledby",a)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("<div>").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var n=0,r;r=this.tabs[n];n++)t===!0||e.inArray(n,t)!==-1?e(r).addClass("ui-state-disabled").attr("aria-disabled","true"):e(r).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var n={click:function(e){e.preventDefault()}};t&&e.each(t.split(" "),function(e,t){n[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(this.anchors,n),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var n,r,i=this.element.parent();t==="fill"?(e.support.minHeight||(r=i.css("overflow"),i.css("overflow","hidden")),n=i.height(),this.element.siblings(":visible").each(function(){var t=e(this),r=t.css("position");if(r==="absolute"||r==="fixed")return;n-=t.outerHeight(!0)}),r&&i.css("overflow",r),this.element.children().not(this.panels).each(function(){n-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,n-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):t==="auto"&&(n=0,this.panels.each(function(){n=Math.max(n,e(this).height("").height())}).height(n))},_eventHandler:function(t){var n=this.options,r=this.active,i=e(t.currentTarget),s=i.closest("li"),o=s[0]===r[0],u=o&&n.collapsible,a=u?e():this._getPanelForTab(s),f=r.length?this._getPanelForTab(r):e(),l={oldTab:r,oldPanel:f,newTab:u?e():s,newPanel:a};t.preventDefault();if(s.hasClass("ui-state-disabled")||s.hasClass("ui-tabs-loading")||this.running||o&&!n.collapsible||this._trigger("beforeActivate",t,l)===!1)return;n.active=u?!1:this.tabs.index(s),this.active=o?e():s,this.xhr&&this.xhr.abort(),!f.length&&!a.length&&e.error("jQuery UI Tabs: Mismatching fragment identifier."),a.length&&this.load(this.tabs.index(s),t),this._toggle(t,l)},_toggle:function(t,n){function o(){r.running=!1,r._trigger("activate",t,n)}function u(){n.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),i.length&&r.options.show?r._show(i,r.options.show,o):(i.show(),o())}var r=this,i=n.newPanel,s=n.oldPanel;this.running=!0,s.length&&this.options.hide?this._hide(s,this.options.hide,function(){n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(n.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),s.hide(),u()),s.attr({"aria-expanded":"false","aria-hidden":"true"}),n.oldTab.attr("aria-selected","false"),i.length&&s.length?n.oldTab.attr("tabIndex",-1):i.length&&this.tabs.filter(function(){return e(this).attr("tabIndex")===0}).attr("tabIndex",-1),i.attr({"aria-expanded":"true","aria-hidden":"false"}),n.newTab.attr({"aria-selected":"true",tabIndex:0})},_activate:function(t){var n,r=this._findActive(t);if(r[0]===this.active[0])return;r.length||(r=this.active),n=r.find(".ui-tabs-anchor")[0],this._eventHandler({target:n,currentTarget:n,preventDefault:e.noop})},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return typeof e=="string"&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeData("href.tabs").removeData("load.tabs").removeUniqueId(),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),n=t.data("ui-tabs-aria-controls");n?t.attr("aria-controls",n):t.removeAttr("aria-controls")}),this.panels.show(),this.options.heightStyle!=="content"&&this.panels.css("height","")},enable:function(n){var r=this.options.disabled;if(r===!1)return;n===t?r=!1:(n=this._getIndex(n),e.isArray(r)?r=e.map(r,function(e){return e!==n?e:null}):r=e.map(this.tabs,function(e,t){return t!==n?t:null})),this._setupDisabled(r)},disable:function(n){var r=this.options.disabled;if(r===!0)return;if(n===t)r=!0;else{n=this._getIndex(n);if(e.inArray(n,r)!==-1)return;e.isArray(r)?r=e.merge([n],r).sort():r=[n]}this._setupDisabled(r)},load:function(t,n){t=this._getIndex(t);var r=this,i=this.tabs.eq(t),o=i.find(".ui-tabs-anchor"),u=this._getPanelForTab(i),a={tab:i,panel:u};if(s(o[0]))return;this.xhr=e.ajax(this._ajaxSettings(o,n,a)),this.xhr&&this.xhr.statusText!=="canceled"&&(i.addClass("ui-tabs-loading"),u.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){u.html(e),r._trigger("load",n,a)},1)}).complete(function(e,t){setTimeout(function(){t==="abort"&&r.panels.stop(!1,!0),i.removeClass("ui-tabs-loading"),u.removeAttr("aria-busy"),e===r.xhr&&delete r.xhr},1)}))},_ajaxSettings:function(t,n,r){var i=this;return{url:t.attr("href"),beforeSend:function(t,s){return i._trigger("beforeLoad",n,e.extend({jqXHR:t,ajaxSettings:s},r))}}},_getPanelForTab:function(t){var n=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+n))}}),e.uiBackCompat!==!1&&(e.ui.tabs.prototype._ui=function(e,t){return{tab:e,panel:t,index:this.anchors.index(e)}},e.widget("ui.tabs",e.ui.tabs,{url:function(e,t){this.anchors.eq(e).attr("href",t)}}),e.widget("ui.tabs",e.ui.tabs,{options:{ajaxOptions:null,cache:!1},_create:function(){this._super();var t=this;this._on({tabsbeforeload:function(n,r){if(e.data(r.tab[0],"cache.tabs")){n.preventDefault();return}r.jqXHR.success(function(){t.options.cache&&e.data(r.tab[0],"cache.tabs",!0)})}})},_ajaxSettings:function(t,n,r){var i=this.options.ajaxOptions;return e.extend({},i,{error:function(e,t){try{i.error(e,t,r.tab.closest("li").index(),r.tab[0])}catch(n){}}},this._superApply(arguments))},_setOption:function(e,t){e==="cache"&&t===!1&&this.anchors.removeData("cache.tabs"),this._super(e,t)},_destroy:function(){this.anchors.removeData("cache.tabs"),this._super()},url:function(e){this.anchors.eq(e).removeData("cache.tabs"),this._superApply(arguments)}}),e.widget("ui.tabs",e.ui.tabs,{abort:function(){this.xhr&&this.xhr.abort()}}),e.widget("ui.tabs",e.ui.tabs,{options:{spinner:"<em>Loading&#8230;</em>"},_create:function(){this._super(),this._on({tabsbeforeload:function(e,t){if(e.target!==this.element[0]||!this.options.spinner)return;var n=t.tab.find("span"),r=n.html();n.html(this.options.spinner),t.jqXHR.complete(function(){n.html(r)})}})}}),e.widget("ui.tabs",e.ui.tabs,{options:{enable:null,disable:null},enable:function(t){var n=this.options,r;if(t&&n.disabled===!0||e.isArray(n.disabled)&&e.inArray(t,n.disabled)!==-1)r=!0;this._superApply(arguments),r&&this._trigger("enable",null,this._ui(this.anchors[t],this.panels[t]))},disable:function(t){var n=this.options,r;if(t&&n.disabled===!1||e.isArray(n.disabled)&&e.inArray(t,n.disabled)===-1)r=!0;this._superApply(arguments),r&&this._trigger("disable",null,this._ui(this.anchors[t],this.panels[t]))}}),e.widget("ui.tabs",e.ui.tabs,{options:{add:null,remove:null,tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},add:function(n,r,i){i===t&&(i=this.anchors.length);var s,o,u=this.options,a=e(u.tabTemplate.replace(/#\{href\}/g,n).replace(/#\{label\}/g,r)),f=n.indexOf("#")?this._tabId(a):n.replace("#","");return a.addClass("ui-state-default ui-corner-top").data("ui-tabs-destroy",!0),a.attr("aria-controls",f),s=i>=this.tabs.length,o=this.element.find("#"+f),o.length||(o=this._createPanel(f),s?i>0?o.insertAfter(this.panels.eq(-1)):o.appendTo(this.element):o.insertBefore(this.panels[i])),o.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").hide(),s?a.appendTo(this.tablist):a.insertBefore(this.tabs[i]),u.disabled=e.map(u.disabled,function(e){return e>=i?++e:e}),this.refresh(),this.tabs.length===1&&u.active===!1&&this.option("active",0),this._trigger("add",null,this._ui(this.anchors[i],this.panels[i])),this},remove:function(t){t=this._getIndex(t);var n=this.options,r=this.tabs.eq(t).remove(),i=this._getPanelForTab(r).remove();return r.hasClass("ui-tabs-active")&&this.anchors.length>2&&this._activate(t+(t+1<this.anchors.length?1:-1)),n.disabled=e.map(e.grep(n.disabled,function(e){return e!==t}),function(e){return e>=t?--e:e}),this.refresh(),this._trigger("remove",null,this._ui(r.find("a")[0],i[0])),this}}),e.widget("ui.tabs",e.ui.tabs,{length:function(){return this.anchors.length}}),e.widget("ui.tabs",e.ui.tabs,{options:{idPrefix:"ui-tabs-"},_tabId:function(t){var n=t.is("li")?t.find("a[href]"):t;return n=n[0],e(n).closest("li").attr("aria-controls")||n.title&&n.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF\-]/g,"")||this.options.idPrefix+i()}}),e.widget("ui.tabs",e.ui.tabs,{options:{panelTemplate:"<div></div>"},_createPanel:function(t){return e(this.options.panelTemplate).attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)}}),e.widget("ui.tabs",e.ui.tabs,{_create:function(){var e=this.options;e.active===null&&e.selected!==t&&(e.active=e.selected===-1?!1:e.selected),this._super(),e.selected=e.active,e.selected===!1&&(e.selected=-1)},_setOption:function(e,t){if(e!=="selected")return this._super(e,t);var n=this.options;this._super("active",t===-1?!1:t),n.selected=n.active,n.selected===!1&&(n.selected=-1)},_eventHandler:function(){this._superApply(arguments),this.options.selected=this.options.active,this.options.selected===!1&&(this.options.selected=-1)}}),e.widget("ui.tabs",e.ui.tabs,{options:{show:null,select:null},_create:function(){this._super(),this.options.active!==!1&&this._trigger("show",null,this._ui(this.active.find(".ui-tabs-anchor")[0],this._getPanelForTab(this.active)[0]))},_trigger:function(e,t,n){var r,i,s=this._superApply(arguments);return s?(e==="beforeActivate"?(r=n.newTab.length?n.newTab:n.oldTab,i=n.newPanel.length?n.newPanel:n.oldPanel,s=this._super("select",t,{tab:r.find(".ui-tabs-anchor")[0],panel:i[0],index:r.closest("li").index()})):e==="activate"&&n.newTab.length&&(s=this._super("show",t,{tab:n.newTab.find(".ui-tabs-anchor")[0],panel:n.newPanel[0],index:n.newTab.closest("li").index()})),s):!1}}),e.widget("ui.tabs",e.ui.tabs,{select:function(e){e=this._getIndex(e);if(e===-1){if(!this.options.collapsible||this.options.selected===-1)return;e=this.options.selected}this.anchors.eq(e).trigger(this.options.event+this.eventNamespace)}}),function(){var t=0;e.widget("ui.tabs",e.ui.tabs,{options:{cookie:null},_create:function(){var e=this.options,t;e.active==null&&e.cookie&&(t=parseInt(this._cookie(),10),t===-1&&(t=!1),e.active=t),this._super()},_cookie:function(n){var r=[this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++t)];return arguments.length&&(r.push(n===!1?-1:n),r.push(this.options.cookie)),e.cookie.apply(null,r)},_refresh:function(){this._super(),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_eventHandler:function(){this._superApply(arguments),this.options.cookie&&this._cookie(this.options.active,this.options.cookie)},_destroy:function(){this._super(),this.options.cookie&&this._cookie(null,this.options.cookie)}})}(),e.widget("ui.tabs",e.ui.tabs,{_trigger:function(t,n,r){var i=e.extend({},r);return t==="load"&&(i.panel=i.panel[0],i.tab=i.tab.find(".ui-tabs-anchor")[0]),this._super(t,n,i)}}),e.widget("ui.tabs",e.ui.tabs,{options:{fx:null},_getFx:function(){var t,n,r=this.options.fx;return r&&(e.isArray(r)?(t=r[0],n=r[1]):t=n=r),r?{show:n,hide:t}:null},_toggle:function(e,t){function o(){n.running=!1,n._trigger("activate",e,t)}function u(){t.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),r.length&&s.show?r.animate(s.show,s.show.duration,function(){o()}):(r.show(),o())}var n=this,r=t.newPanel,i=t.oldPanel,s=this._getFx();if(!s)return this._super(e,t);n.running=!0,i.length&&s.hide?i.animate(s.hide,s.hide.duration,function(){t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),u()}):(t.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),i.hide(),u())}}))})(jQuery);(function(e){function n(t,n){var r=(t.attr("aria-describedby")||"").split(/\s+/);r.push(n),t.data("ui-tooltip-id",n).attr("aria-describedby",e.trim(r.join(" ")))}function r(t){var n=t.data("ui-tooltip-id"),r=(t.attr("aria-describedby")||"").split(/\s+/),i=e.inArray(n,r);i!==-1&&r.splice(i,1),t.removeData("ui-tooltip-id"),r=e.trim(r.join(" ")),r?t.attr("aria-describedby",r):t.removeAttr("aria-describedby")}var t=0;e.widget("ui.tooltip",{version:"1.9.2",options:{content:function(){return e(this).attr("title")},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable()},_setOption:function(t,n){var r=this;if(t==="disabled"){this[n?"_disable":"_enable"](),this.options[t]=n;return}this._super(t,n),t==="content"&&e.each(this.tooltips,function(e,t){r._updateContent(t)})},_disable:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0)}),this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).attr("title","")})},_enable:function(){this.element.find(this.options.items).andSelf().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var n=this,r=e(t?t.target:this.element).closest(this.options.items);if(!r.length||r.data("ui-tooltip-id"))return;r.attr("title")&&r.data("ui-tooltip-title",r.attr("title")),r.data("ui-tooltip-open",!0),t&&t.type==="mouseover"&&r.parents().each(function(){var t=e(this),r;t.data("ui-tooltip-open")&&(r=e.Event("blur"),r.target=r.currentTarget=this,n.close(r,!0)),t.attr("title")&&(t.uniqueId(),n.parents[this.id]={element:this,title:t.attr("title")},t.attr("title",""))}),this._updateContent(r,t)},_updateContent:function(e,t){var n,r=this.options.content,i=this,s=t?t.type:null;if(typeof r=="string")return this._open(t,e,r);n=r.call(e[0],function(n){if(!e.data("ui-tooltip-open"))return;i._delay(function(){t&&(t.type=s),this._open(t,e,n)})}),n&&this._open(t,e,n)},_open:function(t,r,i){function f(e){a.of=e;if(s.is(":hidden"))return;s.position(a)}var s,o,u,a=e.extend({},this.options.position);if(!i)return;s=this._find(r);if(s.length){s.find(".ui-tooltip-content").html(i);return}r.is("[title]")&&(t&&t.type==="mouseover"?r.attr("title",""):r.removeAttr("title")),s=this._tooltip(r),n(r,s.attr("id")),s.find(".ui-tooltip-content").html(i),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:f}),f(t)):s.position(e.extend({of:r},this.options.position)),s.hide(),this._show(s,this.options.show),this.options.show&&this.options.show.delay&&(u=setInterval(function(){s.is(":visible")&&(f(a.of),clearInterval(u))},e.fx.interval)),this._trigger("open",t,{tooltip:s}),o={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var n=e.Event(t);n.currentTarget=r[0],this.close(n,!0)}},remove:function(){this._removeTooltip(s)}};if(!t||t.type==="mouseover")o.mouseleave="close";if(!t||t.type==="focusin")o.focusout="close";this._on(!0,r,o)},close:function(t){var n=this,i=e(t?t.currentTarget:this.element),s=this._find(i);if(this.closing)return;i.data("ui-tooltip-title")&&i.attr("title",i.data("ui-tooltip-title")),r(i),s.stop(!0),this._hide(s,this.options.hide,function(){n._removeTooltip(e(this))}),i.removeData("ui-tooltip-open"),this._off(i,"mouseleave focusout keyup"),i[0]!==this.element[0]&&this._off(i,"remove"),this._off(this.document,"mousemove"),t&&t.type==="mouseleave"&&e.each(this.parents,function(t,r){e(r.element).attr("title",r.title),delete n.parents[t]}),this.closing=!0,this._trigger("close",t,{tooltip:s}),this.closing=!1},_tooltip:function(n){var r="ui-tooltip-"+t++,i=e("<div>").attr({id:r,role:"tooltip"}).addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||""));return e("<div>").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),e.fn.bgiframe&&i.bgiframe(),this.tooltips[r]=n,i},_find:function(t){var n=t.data("ui-tooltip-id");return n?e("#"+n):e()},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(n,r){var i=e.Event("blur");i.target=i.currentTarget=r[0],t.close(i,!0),e("#"+n).remove(),r.data("ui-tooltip-title")&&(r.attr("title",r.data("ui-tooltip-title")),r.removeData("ui-tooltip-title"))})}})})(jQuery);jQuery.effects||function(e,t){var n=e.uiBackCompat!==!1,r="ui-effects-";e.effects={effect:{}},function(t,n){function p(e,t,n){var r=a[t.type]||{};return e==null?n||!t.def?null:t.def:(e=r.floor?~~e:parseFloat(e),isNaN(e)?t.def:r.mod?(e+r.mod)%r.mod:0>e?0:r.max<e?r.max:e)}function d(e){var n=o(),r=n._rgba=[];return e=e.toLowerCase(),h(s,function(t,i){var s,o=i.re.exec(e),a=o&&i.parse(o),f=i.space||"rgba";if(a)return s=n[f](a),n[u[f].cache]=s[u[f].cache],r=n._rgba=s._rgba,!1}),r.length?(r.join()==="0,0,0,0"&&t.extend(r,c.transparent),n):c[e]}function v(e,t,n){return n=(n+1)%1,n*6<1?e+(t-e)*n*6:n*2<1?t:n*3<2?e+(t-e)*(2/3-n)*6:e}var r="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),i=/^([\-+])=\s*(\d+\.?\d*)/,s=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1],e[2],e[3],e[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1]*2.55,e[2]*2.55,e[3]*2.55,e[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(e){return[e[1],e[2]/100,e[3]/100,e[4]]}}],o=t.Color=function(e,n,r,i){return new t.Color.fn.parse(e,n,r,i)},u={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},a={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},f=o.support={},l=t("<p>")[0],c,h=t.each;l.style.cssText="background-color:rgba(1,1,1,.5)",f.rgba=l.style.backgroundColor.indexOf("rgba")>-1,h(u,function(e,t){t.cache="_"+e,t.props.alpha={idx:3,type:"percent",def:1}}),o.fn=t.extend(o.prototype,{parse:function(r,i,s,a){if(r===n)return this._rgba=[null,null,null,null],this;if(r.jquery||r.nodeType)r=t(r).css(i),i=n;var f=this,l=t.type(r),v=this._rgba=[];i!==n&&(r=[r,i,s,a],l="array");if(l==="string")return this.parse(d(r)||c._default);if(l==="array")return h(u.rgba.props,function(e,t){v[t.idx]=p(r[t.idx],t)}),this;if(l==="object")return r instanceof o?h(u,function(e,t){r[t.cache]&&(f[t.cache]=r[t.cache].slice())}):h(u,function(t,n){var i=n.cache;h(n.props,function(e,t){if(!f[i]&&n.to){if(e==="alpha"||r[e]==null)return;f[i]=n.to(f._rgba)}f[i][t.idx]=p(r[e],t,!0)}),f[i]&&e.inArray(null,f[i].slice(0,3))<0&&(f[i][3]=1,n.from&&(f._rgba=n.from(f[i])))}),this},is:function(e){var t=o(e),n=!0,r=this;return h(u,function(e,i){var s,o=t[i.cache];return o&&(s=r[i.cache]||i.to&&i.to(r._rgba)||[],h(i.props,function(e,t){if(o[t.idx]!=null)return n=o[t.idx]===s[t.idx],n})),n}),n},_space:function(){var e=[],t=this;return h(u,function(n,r){t[r.cache]&&e.push(n)}),e.pop()},transition:function(e,t){var n=o(e),r=n._space(),i=u[r],s=this.alpha()===0?o("transparent"):this,f=s[i.cache]||i.to(s._rgba),l=f.slice();return n=n[i.cache],h(i.props,function(e,r){var i=r.idx,s=f[i],o=n[i],u=a[r.type]||{};if(o===null)return;s===null?l[i]=o:(u.mod&&(o-s>u.mod/2?s+=u.mod:s-o>u.mod/2&&(s-=u.mod)),l[i]=p((o-s)*t+s,r))}),this[r](l)},blend:function(e){if(this._rgba[3]===1)return this;var n=this._rgba.slice(),r=n.pop(),i=o(e)._rgba;return o(t.map(n,function(e,t){return(1-r)*i[t]+r*e}))},toRgbaString:function(){var e="rgba(",n=t.map(this._rgba,function(e,t){return e==null?t>2?1:0:e});return n[3]===1&&(n.pop(),e="rgb("),e+n.join()+")"},toHslaString:function(){var e="hsla(",n=t.map(this.hsla(),function(e,t){return e==null&&(e=t>2?1:0),t&&t<3&&(e=Math.round(e*100)+"%"),e});return n[3]===1&&(n.pop(),e="hsl("),e+n.join()+")"},toHexString:function(e){var n=this._rgba.slice(),r=n.pop();return e&&n.push(~~(r*255)),"#"+t.map(n,function(e){return e=(e||0).toString(16),e.length===1?"0"+e:e}).join("")},toString:function(){return this._rgba[3]===0?"transparent":this.toRgbaString()}}),o.fn.parse.prototype=o.fn,u.hsla.to=function(e){if(e[0]==null||e[1]==null||e[2]==null)return[null,null,null,e[3]];var t=e[0]/255,n=e[1]/255,r=e[2]/255,i=e[3],s=Math.max(t,n,r),o=Math.min(t,n,r),u=s-o,a=s+o,f=a*.5,l,c;return o===s?l=0:t===s?l=60*(n-r)/u+360:n===s?l=60*(r-t)/u+120:l=60*(t-n)/u+240,f===0||f===1?c=f:f<=.5?c=u/a:c=u/(2-a),[Math.round(l)%360,c,f,i==null?1:i]},u.hsla.from=function(e){if(e[0]==null||e[1]==null||e[2]==null)return[null,null,null,e[3]];var t=e[0]/360,n=e[1],r=e[2],i=e[3],s=r<=.5?r*(1+n):r+n-r*n,o=2*r-s;return[Math.round(v(o,s,t+1/3)*255),Math.round(v(o,s,t)*255),Math.round(v(o,s,t-1/3)*255),i]},h(u,function(e,r){var s=r.props,u=r.cache,a=r.to,f=r.from;o.fn[e]=function(e){a&&!this[u]&&(this[u]=a(this._rgba));if(e===n)return this[u].slice();var r,i=t.type(e),l=i==="array"||i==="object"?e:arguments,c=this[u].slice();return h(s,function(e,t){var n=l[i==="object"?e:t.idx];n==null&&(n=c[t.idx]),c[t.idx]=p(n,t)}),f?(r=o(f(c)),r[u]=c,r):o(c)},h(s,function(n,r){if(o.fn[n])return;o.fn[n]=function(s){var o=t.type(s),u=n==="alpha"?this._hsla?"hsla":"rgba":e,a=this[u](),f=a[r.idx],l;return o==="undefined"?f:(o==="function"&&(s=s.call(this,f),o=t.type(s)),s==null&&r.empty?this:(o==="string"&&(l=i.exec(s),l&&(s=f+parseFloat(l[2])*(l[1]==="+"?1:-1))),a[r.idx]=s,this[u](a)))}})}),h(r,function(e,n){t.cssHooks[n]={set:function(e,r){var i,s,u="";if(t.type(r)!=="string"||(i=d(r))){r=o(i||r);if(!f.rgba&&r._rgba[3]!==1){s=n==="backgroundColor"?e.parentNode:e;while((u===""||u==="transparent")&&s&&s.style)try{u=t.css(s,"backgroundColor"),s=s.parentNode}catch(a){}r=r.blend(u&&u!=="transparent"?u:"_default")}r=r.toRgbaString()}try{e.style[n]=r}catch(l){}}},t.fx.step[n]=function(e){e.colorInit||(e.start=o(e.elem,n),e.end=o(e.end),e.colorInit=!0),t.cssHooks[n].set(e.elem,e.start.transition(e.end,e.pos))}}),t.cssHooks.borderColor={expand:function(e){var t={};return h(["Top","Right","Bottom","Left"],function(n,r){t["border"+r+"Color"]=e}),t}},c=t.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(jQuery),function(){function i(){var t=this.ownerDocument.defaultView?this.ownerDocument.defaultView.getComputedStyle(this,null):this.currentStyle,n={},r,i;if(t&&t.length&&t[0]&&t[t[0]]){i=t.length;while(i--)r=t[i],typeof t[r]=="string"&&(n[e.camelCase(r)]=t[r])}else for(r in t)typeof t[r]=="string"&&(n[r]=t[r]);return n}function s(t,n){var i={},s,o;for(s in n)o=n[s],t[s]!==o&&!r[s]&&(e.fx.step[s]||!isNaN(parseFloat(o)))&&(i[s]=o);return i}var n=["add","remove","toggle"],r={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};e.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(t,n){e.fx.step[n]=function(e){if(e.end!=="none"&&!e.setAttr||e.pos===1&&!e.setAttr)jQuery.style(e.elem,n,e.end),e.setAttr=!0}}),e.effects.animateClass=function(t,r,o,u){var a=e.speed(r,o,u);return this.queue(function(){var r=e(this),o=r.attr("class")||"",u,f=a.children?r.find("*").andSelf():r;f=f.map(function(){var t=e(this);return{el:t,start:i.call(this)}}),u=function(){e.each(n,function(e,n){t[n]&&r[n+"Class"](t[n])})},u(),f=f.map(function(){return this.end=i.call(this.el[0]),this.diff=s(this.start,this.end),this}),r.attr("class",o),f=f.map(function(){var t=this,n=e.Deferred(),r=jQuery.extend({},a,{queue:!1,complete:function(){n.resolve(t)}});return this.el.animate(this.diff,r),n.promise()}),e.when.apply(e,f.get()).done(function(){u(),e.each(arguments,function(){var t=this.el;e.each(this.diff,function(e){t.css(e,"")})}),a.complete.call(r[0])})})},e.fn.extend({_addClass:e.fn.addClass,addClass:function(t,n,r,i){return n?e.effects.animateClass.call(this,{add:t},n,r,i):this._addClass(t)},_removeClass:e.fn.removeClass,removeClass:function(t,n,r,i){return n?e.effects.animateClass.call(this,{remove:t},n,r,i):this._removeClass(t)},_toggleClass:e.fn.toggleClass,toggleClass:function(n,r,i,s,o){return typeof r=="boolean"||r===t?i?e.effects.animateClass.call(this,r?{add:n}:{remove:n},i,s,o):this._toggleClass(n,r):e.effects.animateClass.call(this,{toggle:n},r,i,s)},switchClass:function(t,n,r,i,s){return e.effects.animateClass.call(this,{add:n,remove:t},r,i,s)}})}(),function(){function i(t,n,r,i){e.isPlainObject(t)&&(n=t,t=t.effect),t={effect:t},n==null&&(n={}),e.isFunction(n)&&(i=n,r=null,n={});if(typeof n=="number"||e.fx.speeds[n])i=r,r=n,n={};return e.isFunction(r)&&(i=r,r=null),n&&e.extend(t,n),r=r||n.duration,t.duration=e.fx.off?0:typeof r=="number"?r:r in e.fx.speeds?e.fx.speeds[r]:e.fx.speeds._default,t.complete=i||n.complete,t}function s(t){return!t||typeof t=="number"||e.fx.speeds[t]?!0:typeof t=="string"&&!e.effects.effect[t]?n&&e.effects[t]?!1:!0:!1}e.extend(e.effects,{version:"1.9.2",save:function(e,t){for(var n=0;n<t.length;n++)t[n]!==null&&e.data(r+t[n],e[0].style[t[n]])},restore:function(e,n){var i,s;for(s=0;s<n.length;s++)n[s]!==null&&(i=e.data(r+n[s]),i===t&&(i=""),e.css(n[s],i))},setMode:function(e,t){return t==="toggle"&&(t=e.is(":hidden")?"show":"hide"),t},getBaseline:function(e,t){var n,r;switch(e[0]){case"top":n=0;break;case"middle":n=.5;break;case"bottom":n=1;break;default:n=e[0]/t.height}switch(e[1]){case"left":r=0;break;case"center":r=.5;break;case"right":r=1;break;default:r=e[1]/t.width}return{x:r,y:n}},createWrapper:function(t){if(t.parent().is(".ui-effects-wrapper"))return t.parent();var n={width:t.outerWidth(!0),height:t.outerHeight(!0),"float":t.css("float")},r=e("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),i={width:t.width(),height:t.height()},s=document.activeElement;try{s.id}catch(o){s=document.body}return t.wrap(r),(t[0]===s||e.contains(t[0],s))&&e(s).focus(),r=t.parent(),t.css("position")==="static"?(r.css({position:"relative"}),t.css({position:"relative"})):(e.extend(n,{position:t.css("position"),zIndex:t.css("z-index")}),e.each(["top","left","bottom","right"],function(e,r){n[r]=t.css(r),isNaN(parseInt(n[r],10))&&(n[r]="auto")}),t.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),t.css(i),r.css(n).show()},removeWrapper:function(t){var n=document.activeElement;return t.parent().is(".ui-effects-wrapper")&&(t.parent().replaceWith(t),(t[0]===n||e.contains(t[0],n))&&e(n).focus()),t},setTransition:function(t,n,r,i){return i=i||{},e.each(n,function(e,n){var s=t.cssUnit(n);s[0]>0&&(i[n]=s[0]*r+s[1])}),i}}),e.fn.extend({effect:function(){function a(n){function u(){e.isFunction(i)&&i.call(r[0]),e.isFunction(n)&&n()}var r=e(this),i=t.complete,s=t.mode;(r.is(":hidden")?s==="hide":s==="show")?u():o.call(r[0],t,u)}var t=i.apply(this,arguments),r=t.mode,s=t.queue,o=e.effects.effect[t.effect],u=!o&&n&&e.effects[t.effect];return e.fx.off||!o&&!u?r?this[r](t.duration,t.complete):this.each(function(){t.complete&&t.complete.call(this)}):o?s===!1?this.each(a):this.queue(s||"fx",a):u.call(this,{options:t,duration:t.duration,callback:t.complete,mode:t.mode})},_show:e.fn.show,show:function(e){if(s(e))return this._show.apply(this,arguments);var t=i.apply(this,arguments);return t.mode="show",this.effect.call(this,t)},_hide:e.fn.hide,hide:function(e){if(s(e))return this._hide.apply(this,arguments);var t=i.apply(this,arguments);return t.mode="hide",this.effect.call(this,t)},__toggle:e.fn.toggle,toggle:function(t){if(s(t)||typeof t=="boolean"||e.isFunction(t))return this.__toggle.apply(this,arguments);var n=i.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)},cssUnit:function(t){var n=this.css(t),r=[];return e.each(["em","px","%","pt"],function(e,t){n.indexOf(t)>0&&(r=[parseFloat(n),t])}),r}})}(),function(){var t={};e.each(["Quad","Cubic","Quart","Quint","Expo"],function(e,n){t[n]=function(t){return Math.pow(t,e+2)}}),e.extend(t,{Sine:function(e){return 1-Math.cos(e*Math.PI/2)},Circ:function(e){return 1-Math.sqrt(1-e*e)},Elastic:function(e){return e===0||e===1?e:-Math.pow(2,8*(e-1))*Math.sin(((e-1)*80-7.5)*Math.PI/15)},Back:function(e){return e*e*(3*e-2)},Bounce:function(e){var t,n=4;while(e<((t=Math.pow(2,--n))-1)/11);return 1/Math.pow(4,3-n)-7.5625*Math.pow((t*3-2)/22-e,2)}}),e.each(t,function(t,n){e.easing["easeIn"+t]=n,e.easing["easeOut"+t]=function(e){return 1-n(1-e)},e.easing["easeInOut"+t]=function(e){return e<.5?n(e*2)/2:1-n(e*-2+2)/2}})}()}(jQuery);(function(e,t){var n=/up|down|vertical/,r=/up|left|vertical|horizontal/;e.effects.effect.blind=function(t,i){var s=e(this),o=["position","top","bottom","left","right","height","width"],u=e.effects.setMode(s,t.mode||"hide"),a=t.direction||"up",f=n.test(a),l=f?"height":"width",c=f?"top":"left",h=r.test(a),p={},d=u==="show",v,m,g;s.parent().is(".ui-effects-wrapper")?e.effects.save(s.parent(),o):e.effects.save(s,o),s.show(),v=e.effects.createWrapper(s).css({overflow:"hidden"}),m=v[l](),g=parseFloat(v.css(c))||0,p[l]=d?m:0,h||(s.css(f?"bottom":"right",0).css(f?"top":"left","auto").css({position:"absolute"}),p[c]=d?g:m+g),d&&(v.css(l,0),h||v.css(c,g+m)),v.animate(p,{duration:t.duration,easing:t.easing,queue:!1,complete:function(){u==="hide"&&s.hide(),e.effects.restore(s,o),e.effects.removeWrapper(s),i()}})}})(jQuery);(function(e,t){e.effects.effect.drop=function(t,n){var r=e(this),i=["position","top","bottom","left","right","opacity","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left"?"pos":"neg",l={opacity:o?1:0},c;e.effects.save(r,i),r.show(),e.effects.createWrapper(r),c=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0)/2,o&&r.css("opacity",0).css(a,f==="pos"?-c:c),l[a]=(o?f==="pos"?"+=":"-=":f==="pos"?"-=":"+=")+c,r.animate(l,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);(function(e,t){e.effects.effect.fade=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"toggle");r.animate({opacity:i},{queue:!1,duration:t.duration,easing:t.easing,complete:n})}})(jQuery);(function(e,t){e.effects.effect.fold=function(t,n){var r=e(this),i=["position","top","bottom","left","right","height","width"],s=e.effects.setMode(r,t.mode||"hide"),o=s==="show",u=s==="hide",a=t.size||15,f=/([0-9]+)%/.exec(a),l=!!t.horizFirst,c=o!==l,h=c?["width","height"]:["height","width"],p=t.duration/2,d,v,m={},g={};e.effects.save(r,i),r.show(),d=e.effects.createWrapper(r).css({overflow:"hidden"}),v=c?[d.width(),d.height()]:[d.height(),d.width()],f&&(a=parseInt(f[1],10)/100*v[u?0:1]),o&&d.css(l?{height:0,width:a}:{height:a,width:0}),m[h[0]]=o?v[0]:a,g[h[1]]=o?v[1]:0,d.animate(m,p,t.easing).animate(g,p,t.easing,function(){u&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()})}})(jQuery);(function(e,t){e.effects.effect.highlight=function(t,n){var r=e(this),i=["backgroundImage","backgroundColor","opacity"],s=e.effects.setMode(r,t.mode||"show"),o={backgroundColor:r.css("backgroundColor")};s==="hide"&&(o.opacity=0),e.effects.save(r,i),r.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(o,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),n()}})}})(jQuery);(function(e,t){e.effects.effect.pulsate=function(t,n){var r=e(this),i=e.effects.setMode(r,t.mode||"show"),s=i==="show",o=i==="hide",u=s||i==="hide",a=(t.times||5)*2+(u?1:0),f=t.duration/a,l=0,c=r.queue(),h=c.length,p;if(s||!r.is(":visible"))r.css("opacity",0).show(),l=1;for(p=1;p<a;p++)r.animate({opacity:l},f,t.easing),l=1-l;r.animate({opacity:l},f,t.easing),r.queue(function(){o&&r.hide(),n()}),h>1&&c.splice.apply(c,[1,0].concat(c.splice(h,a+1))),r.dequeue()}})(jQuery);(function(e,t){e.effects.effect.slide=function(t,n){var r=e(this),i=["position","top","bottom","left","right","width","height"],s=e.effects.setMode(r,t.mode||"show"),o=s==="show",u=t.direction||"left",a=u==="up"||u==="down"?"top":"left",f=u==="up"||u==="left",l,c={};e.effects.save(r,i),r.show(),l=t.distance||r[a==="top"?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(r).css({overflow:"hidden"}),o&&r.css(a,f?isNaN(l)?"-"+l:-l:l),c[a]=(o?f?"+=":"-=":f?"-=":"+=")+l,r.animate(c,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){s==="hide"&&r.hide(),e.effects.restore(r,i),e.effects.removeWrapper(r),n()}})}})(jQuery);
\ No newline at end of file
diff --git a/portal/templates/_footer.html b/portal/templates/_footer.html
new file mode 100644 (file)
index 0000000..ad23176
--- /dev/null
@@ -0,0 +1,16 @@
+<div class="footer">
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+            <ul>
+                <li><a href="/terms">Terms and Conditions</a></li>
+            </ul>
+        </div>
+    </div>
+    <div class="row">
+        <div class="col-md-12 copy">
+            Copyright © UPMC Sorbonne Universités, on behalf of the OneLab consortium
+        </div>
+    </div>
+</div>
+</div>
\ No newline at end of file
diff --git a/portal/templates/_widget-monitor.html b/portal/templates/_widget-monitor.html
new file mode 100644 (file)
index 0000000..cb7af4f
--- /dev/null
@@ -0,0 +1,29 @@
+<div class="monitor">
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+               <h1>Services Status</h1>
+        </div>
+    </div>
+       <div class="row" id="monitor-services">
+       </div>
+</div>
+</div>
+<script>
+       $(document).ready(function() {
+               $.get('/monitor/services', function(result) {
+                       for (var r in result) {
+                               html = '<div class="col-xs-6 col-sm-4 col-md-3 s-monitor"><div class="row">';
+                               html += '<div class="col-md-2"><img src="{{ STATIC_URL }}icons/'+result[r].status+'.png"></div>';
+                               html += '<div class="col-md-8">';
+                               html += '<h4>'+result[r].name+'<h4>';
+                               html += '<span class="subtitle">'+result[r].type+'</span>';
+                               if (typeof(result[r].version) != 'undefined')
+                                       html += ' <span class="version">version '+result[r].version+'</span>';
+                               html += '</div></div></div>';
+                               $('div#monitor-services').append(html);
+                       }
+               });
+       });
+</script>
diff --git a/portal/templates/_widget-stats-top-slices.html b/portal/templates/_widget-stats-top-slices.html
new file mode 100644 (file)
index 0000000..80d9aed
--- /dev/null
@@ -0,0 +1,145 @@
+<script type="text/javascript" src="https://www.google.com/jsapi"></script>
+<script type="text/javascript">
+google.load("visualization", "1.0", {packages:["corechart"]});
+google.setOnLoadCallback(function() {
+       drawChart("experiments","cpu","day");
+       drawChart("resources","cpu","day");
+});
+function drawChart(graph, orderby, period) {
+       var options = { 'height':260,
+               vAxes:[
+                       {title: 'CPU, Memory usage (%)',textStyle:{color: '#302562'}},
+                       {title: 'Bandwidth (Kbps)',textStyle:{color: '#302562'}}
+               ],
+               series: {
+                0: { type: "bar", targetAxisIndex: 0},
+                1: { type: "bar", targetAxisIndex: 0},
+                2: { type: "bar", targetAxisIndex: 1},
+                3: { type: "bar", targetAxisIndex: 1},
+            }
+               };
+       
+       var jsonData = $.ajax({
+            type: 'GET',
+               url: "http://slicestat.onelab.eu/top/" + graph,
+               dataType: "json",
+               async: false,
+               data: { orderby: orderby, period: period },
+            success: function(ret) {
+               var result = [];
+               var data = new google.visualization.DataTable();
+                               data.addColumn('string', graph);
+                               data.addColumn('number', 'CPU (%)');
+                               data.addColumn('number', 'MEM (%)');
+                               data.addColumn('number', 'SND (Kbps)');
+                               data.addColumn('number', 'RCV (Kbps)');
+                               
+                               $.each(ret, function() {
+                                       switch(graph) {
+                                               case "experiments":
+                                                       result.push([this[0] + " | number of resources: " + this[1], this[2], this[3], this[4], this[5]]);
+                                               break;
+                                               case "resources":
+                                                       result.push([this[0] + " | number of experiments: " + this[1], this[2], this[3], this[4], this[5]]);
+                                               break;
+                                       }
+                });
+                data.addRows(result);
+
+                               var chart = new google.visualization.ColumnChart(document.getElementById(graph));
+                               chart.draw(data, options);
+            }
+        }).responseText;
+
+    // var data = google.visualization.arrayToDataTable(obj, false);
+       
+       
+  }
+  $(document).ready(function () {
+       var orderby = "cpu";
+       var period = "day";
+       $('a.stats-orderby').click(function(event) {
+               event.preventDefault();
+                 
+               orderby = $(this).data('orderby');
+               graph = $(this).data('graph');
+
+               $('a.stats-orderby[data-graph='+graph+']').removeClass('current');
+               
+               drawChart(graph, orderby, period);
+               $(this).addClass('current');
+       });
+       
+       $('a.stats-period').click(function(event) {
+               event.preventDefault();
+               period = $(this).data('period');
+               graph = $(this).data('graph');
+               
+               $('a.stats-period[data-graph='+graph+']').removeClass('current');
+               
+               $('#stats-period-'+graph+'-txt').text($(this).text());
+               
+               drawChart(graph, orderby, period);
+               $(this).addClass('current');
+       });
+  });
+</script>
+<style>div#graph {margin:0;padding:0;border:0;}</style>
+<div class="stats">
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+               <h1>Experiment statistics <span class="htitle">top experiments per resource usage in the <span id="stats-period-experiments-txt">last day</span></span></h1>
+        </div>
+    </div>
+       <div class="row">
+               <div class="col-md-7">
+                       Order by: 
+                       <a class="stats-orderby current" data-orderby="cpu" data-graph="experiments" href="#">CPU usage</a> &middot;
+                       <a class="stats-orderby" data-orderby="mem" data-graph="experiments" href="#">Memory usage</a> &middot;
+                       <a class="stats-orderby" data-orderby="snd" data-graph="experiments" href="#">Sending bandwidth</a> &middot;
+                       <a class="stats-orderby" data-orderby="rcv" data-graph="experiments" href="#">Receiving bandwidth</a>
+               </div>
+               <div class="col-md-5">
+                       Period: 
+                       <a class="stats-period current" data-period="day" data-graph="experiments" href="#">Last day</a> &middot;
+                       <a class="stats-period" data-period="week" data-graph="experiments" href="#">Last week</a> &middot;
+                       <a class="stats-period" data-period="month" data-graph="experiments" href="#">Last month</a> &middot;
+                       <a class="stats-period" data-period="3months" data-graph="experiments" href="#">Last three months</a>
+               </div>
+       </div>
+       <div class="row">
+               <div class="col-md-12">
+                       <div id="experiments"></div>
+               </div>
+       </div>
+</div>
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+               <h1>Resource statistics <span class="htitle">top resources per usage in the <span id="stats-period-resources-txt">last day</span></span></h1>
+        </div>
+    </div>
+       <div class="row">
+               <div class="col-md-7">
+                       Order by: 
+                       <a class="stats-orderby current" data-orderby="cpu" data-graph="resources" href="#">CPU usage</a> &middot;
+                       <a class="stats-orderby" data-orderby="mem" data-graph="resources" href="#">Memory usage</a> &middot;
+                       <a class="stats-orderby" data-orderby="snd" data-graph="resources" href="#">Sending bandwidth</a> &middot;
+                       <a class="stats-orderby" data-orderby="rcv" data-graph="resources" href="#">Receiving bandwidth</a>
+               </div>
+               <div class="col-md-5">
+                       Period: 
+                       <a class="stats-period current" data-period="day" data-graph="resources" href="#">Last day</a> &middot;
+                       <a class="stats-period" data-period="week" data-graph="resources" href="#">Last week</a> &middot;
+                       <a class="stats-period" data-period="month" data-graph="resources" href="#">Last month</a> &middot;
+                       <a class="stats-period" data-period="3months" data-graph="resources" href="#">Last three months</a>
+               </div>
+       </div>
+       <div class="row">
+               <div class="col-md-12">
+                       <div id="resources"></div>
+               </div>
+       </div>
+</div>
+</div>
index 1ccc720..ab8be3a 100644 (file)
@@ -68,7 +68,7 @@
                                        <p> More Info: <a href="http://myslice.info/" target="_blank">http://myslice.info/</a></p>
                                        <p> Code: <a href="http://git.onelab.eu/?p=myslice.git;a=summary" target="_blank">Git Repository</a> (read only)</p> 
                                        <p> 
-                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@myslice.info">support@myslice.info</a>.
+                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@onelab.eu">support@onelab.eu</a>.
                                        </p>
 
 
index 2b8a9ca..2b99be1 100644 (file)
                                                        </td>
                                                 {%endif%}              
                                                </tr>
+                                       <tr class="even" id="sfi_config_row">
+                                               <td class="key">sfi_config </td>
+                                               <td class="value">use sfi_config file with sfi.py package (pip install sfa)<a href="#"></a>
+                                                       <button type="submit" name="dl_sfi_config" class="btn btn-default btn-xs" title="Download your privaye key" id="dl_sfi_config">
+                                                                       <span class="glyphicon glyphicon-download"></span> Download 
+                                                               </button>
+                                               </td>
+                        </tr>
                                                <tr class="even">
                                                <td colspan="2">
                                                        <p class="message" id="pkey_del_msg"><b> Tradeoff:</b> Ease-of-use vs Security.<br>
index cbad91c..9f165d0 100644 (file)
@@ -1,4 +1,4 @@
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="https://onelab.eu/static/images/onelab.png">
 <br>
 <p>We have received a user signup request for your email address at {{current_site}}</p>
 <p>You have the following user details:</p>
@@ -10,19 +10,20 @@ Email: {{email}}<br>
 
 <p></p>
 <p>
-You may now log in to the portal using your email address and the password that you provided, but your access will be limited. To gain full access, two steps are required:
+You may now <a href="http://{{current_site}}">log</a> in to the portal using your email address and the password that you provided, but your access will be limited. To gain full access, two steps are required:
 </p>
 
-<ul>
-<li>1. You confirm that you have indeed made this request by clicking on the following link: <br>
+<ul style="list-style-type:decimal;">
+<li>
+You must confirm that you have indeed made this request by clicking on the following link: <br>
        <a href={{validation_link}}>{{validation_link}}</a> 
-               <ul><li>If you did not make this request, we apologise. You may disregard this email or you may advise us the error by replying to this email.</li></ul>
+       <ul><li>If you did not make this request, we apologise. You may disregard this email or you may advise us the error by replying to this email.</li></ul>
 </li>
 <li>
-2. A manager from your organization validates your request. Upon confirmation of your signup request, we will send an email to the managers at your organization with a validation request.
+A manager from your organization must also validate your request. Upon confirmation of your signup request, we will send an email to the managers at your organization with a validation request.
 </li>
 </ul>
 <p>
-We look forward to welcoming you to OneLab. You will find answers to frequently asked questions <a href="http://{{current_site}}/portal/support/">here</a>. 
-Please don't hesitate to <a href="http://{{current_site}}/portal/contact/">contact us</a> with any additional questions that you might have.
+We look forward to welcoming you to OneLab. You will find answers to frequently asked questions <a href="http://{{current_site}}/support/">here</a>. 
+Please don't hesitate to <a href="http://{{current_site}}/contact/">contact us</a> with any additional questions that you might have.
 </p>
index ac31ec2..a68d1ce 100644 (file)
@@ -9,16 +9,16 @@ Email: {{email}}
 
 You may now log in to the portal using your email address and the password that you provided, but your access will be limited. To gain full access, two steps are required:
 
-       1. You confirm that you have indeed made this request by clicking on the following link:
+       1. You must confirm that you have indeed made this request by clicking on the following link:
 
                {{validation_link}}
 
                If you did not make this request, we apologise. You may disregard this email or you may advise us the error by replying to this email.
 
-       2. A manager from your organization validates your request. Upon confirmation of your signup request, we will send an email to the managers at your organization with a validation request.
+       2. A manager from your organization must also validate your request. Upon confirmation of your signup request, we will send an email to the managers at your organization with a validation request.
 
 We look forward to welcoming you to OneLab. 
-Please don't hesitate to contact us at support@myslice.info with any additional questions that you might have.
+Please don't hesitate to contact us at support@onelab.eu with any additional questions that you might have.
 
 
 
diff --git a/portal/templates/authority_request_denied.html b/portal/templates/authority_request_denied.html
new file mode 100644 (file)
index 0000000..a028170
--- /dev/null
@@ -0,0 +1,20 @@
+<p>Dear OneLab user,</p>
+<p></p>
+<p>You have recently requested an addition of the following authority in the OneLab portal ({{portal_url}}):</p> 
+<p></p>
+<b>Name of organization:</b> {{site_name}}<br>
+<b>Short name:</b> {{short_name}}<br>
+<b>Url:</b> {{url}}<br>
+<b>City:</b> {{city}}<br>
+<b>Country:</b> {{country}}<br>
+<p></p>
+</p>After verifying your request, we regret to inform you that, we are unable to validate your request.</p>
+<p>For any queries, contact us by replying to this email.</p>
+<br>
+<p>On behalf of the entire team, I wish you all the best.</p>
+<br>
+<p>Yours sincerely,</p>
+<br>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
diff --git a/portal/templates/authority_request_denied.txt b/portal/templates/authority_request_denied.txt
new file mode 100644 (file)
index 0000000..7708b3f
--- /dev/null
@@ -0,0 +1,21 @@
+Dear OneLab user,
+
+You have recently requested an addition of the following authority in the OneLab portal ({{portal_url}}): 
+
+Name of organization: {{site_name}}
+Short name: {{short_name}}
+Url: {{url}}
+City: {{city}}
+Country: {{country}}
+
+
+After verifying your request, we regret to inform you that, we are unable to validate your request.
+For any queries, contact us by replying to this email.
+
+On behalf of the entire team, I wish you all the best.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
index 51b7c40..64bf981 100644 (file)
@@ -1,27 +1,22 @@
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="https://onelab.eu/static/images/onelab.png">
 <br>
 <h1>NEW AUTHORITY REQUEST</h1>
 <br>
+<p>This email is only for OneLab admins</p>
+<br>
 <h2>{{site_name}}</h2>             
-<b>Authority hrn    :</b> {{authority_hrn}}         
-<b>Abreviated name  :</b> {{site_abbreviated_name}} 
-<b>URL              :</b> {{site_url}}              
-<b>latitude         :</b> {{site_latitude}}         
-<b>longitude        :</b> {{site_longitude}}        
-<b>Address          :</b> {{address_line1}}<br>        
-                          {{address_line2}}<br>     
-                          {{address_line3}}<br>         
-<b>City             :</b> {{address_city}}          
-<b>Postcode         :</b> {{address_postalcode}}    
-<b>State            :</b> {{address_state}}         
-<b>Country          :</b> {{address_country}}  
+<b>Authority hrn    :</b> {{authority_hrn}}<br>         
+<b>Abreviated name  :</b> {{site_abbreviated_name}}<br>
+<b>URL              :</b> {{site_url}}<br>              
+<b>City             :</b> {{address_city}}<br>          
+<b>Country          :</b> {{address_country}}<br>  
 
 <br><br>
 
 <h2>PI for this Authority</h2>     
-<b>First Name   :</b> {{first_name}}
-<b>Last Name    :</b> {{last_name}}
-<b>Authority hrn:</b> {{authority_hrn}}
-<b>Public key   :</b> {{public_key}}
-<b>Email        :</b> {{email}}
-<b>User Hrn     :</b> {{user_hrn}}
+<b>First Name   :</b> {{first_name}}<br>
+<b>Last Name    :</b> {{last_name}}<br>
+<b>Authority hrn:</b> {{authority_hrn}}<br>
+<b>Public key   :</b> {{public_key}}<br>
+<b>Email        :</b> {{email}}<br>
+<b>User Hrn     :</b> {{user_hrn}}<br>
index 25eb21b..9376a65 100644 (file)
@@ -1,3 +1,5 @@
+This email is only for OneLab admins.
+
 NEW AUTHORITY REQUEST
 
 Site             : {{site_name}}             
@@ -6,15 +8,8 @@ Authority hrn    : {{authority_hrn}}
 Abreviated name  : {{site_abbreviated_name}} 
 URL              : {{site_url}}              
 
-latitude         : {{site_latitude}}         
-longitude        : {{site_longitude}}        
 
-Address          : {{address_line1}}
-                   {{address_line2}}     
-                   {{address_line3}}         
 City             : {{address_city}}          
-Postcode         : {{address_postalcode}}    
-State            : {{address_state}}         
 Country          : {{address_country}}  
 
 
index 237cfa6..df8fd9c 100644 (file)
@@ -69,11 +69,27 @@ $(document).ready(function() {
         slices = user.slices;
         drawSlices(slices);
     }
+
+    /*
+        Launch queries to get the resources and leases in Manifold Cache
+    */
+        
+    $.post("/rest/resource/", function( data ) {
+    });
+    $.post("/rest/lease/", function( data ) {
+    });
+
+   
     function drawSlices(slices){
         var items = [];
                
         $.each( slices, function(i, val) {
             items.push( "<li><a href=\"/resources/"+val+"\">" + val + "</a></li>" );
+            /*
+            Launch a Query for each slice to get resources and leases in Manifold Cache
+            */
+            $.post("/rest/slice/", { 'filters': { 'slice_hrn' : val } }, function(data) {
+            });
         });
         $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
         $("ul#dropdown-slice-list").append(items.join( "" ));
@@ -88,9 +104,14 @@ $(document).ready(function() {
        {% block topmenu %}
        {% widget "_widget-topmenu.html" %}
        {% endblock topmenu %}
-       {% include 'messages-transient.html' %}
        {% block base_content %}
        {% endblock %}
 {% endblock container %}
+{% widget "_footer.html" %}
+<div class="loading">
+       <div><img src="{{ STATIC_URL }}/img/loading.gif" /> Loading...</div>
+       <div>&nbsp;</div>
+       <div class="message"></div>
+</div>
 </body>
 </html>
index fdb5d0d..98e2c0b 100644 (file)
@@ -18,7 +18,7 @@
        <p>Please check our <a href="/portal/support/">FAQ</a> section. Most of the basic problems are explained there.</p>
        <p>
        If you haven't find your answes in the FAQ, please contact us by filling the form below.<br />
-       You can also <a href="mailto:support@myslice.info">e-mail</a> us directly.
+       You can also <a href="mailto:support@onelab.eu">e-mail</a> us directly.
        </p>
        </div>
 </div>
index 9774347..9848087 100644 (file)
@@ -1,4 +1,4 @@
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="https://onelab.eu/static/images/onelab.png">
 <br>
 <h1>User details</h1>
 <br>
index 43feab2..d923b9d 100644 (file)
@@ -6,15 +6,19 @@
        <h1><img src="{{ STATIC_URL }}img/icon_user_small.png" alt="User Registration" />User sign-up</h1>
 </div>
 <div class="row">
-       {%if activation_status == 'success'%}
+       {% if activation_status == 'success' %}
                <h3>Signup request confirmed.</h3>
-               <p>You are currently able to log in to the portal using your email address and the password that you provided, but your access is still limited.</p> 
-               <p>You will have full access as soon as your account is validated by a manager at your organization. We have sent an email to the managers with a validation request.</p>
+               <p>You are currently able to log in to the portal using your email address and the password that you have provided; however, your access is still limited.</p> 
+               <p>You will have full access as soon as your account is validated by a manager at your organization. We have sent an email to your organisation's managers with a validation request.</p>
+    {% elif activation_status == 'validated' %}
+               <h3>Account validated.</h3>
+               <p>We have identified you as a valid PLE user. Your OneLab account has automatically been approved.</p>
+        <p>You have a full access to OneLab testbeds.</p>
        {%else%}
                <h3>Signup confirmation failed.</h3>
-               <p>You have probably arrived at this page by clicking a confirmation link in an email that we have sent to you. However, 
-               we have been unable to match the link that you have clicked to a signup request in our database.</p>
-               <p>Please <a href="/portal/contact/">contact support</a> so that we can help you complete the signup process.</p>
+               <p>You have probably arrived at this page by clicking a confirmation link in an email that we have sent to you. 
+               We have been unable to match the link that you have clicked to a signup request in our database.</p>
+               <p>Please <a href="/portal/contact/">contact support</a> so that we may help you complete the signup process.</p>
        {%endif%}
  </div>
 
index fb49ee9..33b2c46 100644 (file)
@@ -1 +1 @@
-support@myslice.info
+OneLab Support <support@onelab.eu>
\ No newline at end of file
index c0f206f..33b2c46 100644 (file)
@@ -1 +1 @@
-support@onelab.eu
+OneLab Support <support@onelab.eu>
\ No newline at end of file
diff --git a/portal/templates/fantaastic/fantaastic_account-view.html b/portal/templates/fantaastic/fantaastic_account-view.html
new file mode 100644 (file)
index 0000000..199444a
--- /dev/null
@@ -0,0 +1,371 @@
+{% extends "layout.html" %}
+{% block content %}
+
+<div class="row">
+       <div class="col-md-12">
+                <div class="breadcrumbs">
+                        Account &nbsp;>&nbsp; <a href="/account">{{ person.email }}</a>
+                </div>
+       </div>
+        {%if 'no_creds'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
+{%endif%}
+
+</div>
+{% if messages %}
+<ul class="messages">
+    {% for message in messages %}
+    <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
+    {% endfor %}
+</ul>
+{% endif %}
+<div class="row">
+       <div class="col-md-12">
+               <ul class="nav nav-tabs nav-section">
+                       <li class="active"><a href="#profile">User Profile</a></li>
+                       <li><a href="#account">Account</a></li>
+                       <li><a href="#access">Testbed Access</a></li>
+               </ul>
+    </div>
+</div>
+<div class="tab-content">
+       <div class="tab-pane active row" id="profile">
+               
+               <div class="col-md-12">
+
+                       <form id="editForm" method="post" action="account_process" enctype="multipart/form-data">
+                               {% csrf_token %}
+                                       <table class="profile">          
+                                       <tr>
+                                               <td colspan="2">
+                                                               <div><h3>Platform: Myslice</h3></div>
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td class="key">Email</td>
+                                               <td class="value">
+                                                               <span id="emailval" class="value" >{{ person.email }}</span>
+                                                               <button class="btn btn-default" type="button" id="edit_email" onclick="editAlert();"  title="To change your affiliation please contact the administrator">
+                                                               <span class="glyphicon glyphicon-question-sign"></span> Edit
+                                                               </button>
+                                                       </td>
+                                       </tr>
+                                       <tr class="odd">
+                                                       <td class="key">Password</td>
+                                                       <td class="value"> 
+                                                               <button class="btn btn-default btn-xs" type="button" title="Password" name="edit_pass" id="edit_pass">
+                                                                       <span class="glyphicon glyphicon-edit"></span> Edit
+                                                               </button>
+                                                               <span id="passval"class="value">******** </span>
+                                                               <span class="hide_this" id="span_pass">
+                                                               <button type="button" class="btn btn-default btn-xs" title="Cancel" id="cancel_pass_change"> Cancel </button>
+                                                               <div style='display:none;' id="pass_form">
+                                                               <input type='hidden'  value='' /></div>
+                                                               <table id="edit_password">
+                                                                       <tr>
+                                                                                       <td>Enter password: </td>
+                                                                                       <td class="field"> <input type="password" name="password" id="password" /> </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>Confirm password: </td>
+                                                                                       <td class="field"> 
+                                                                                               <input type="password" name="confirmpassword" id="confirmpassword" /> 
+                                                                                               <input type="submit" class="btn btn-default btn-xs" name="submit_pass" value="Save"/> 
+                                                                                       </td>
+                                                                       </tr>
+                                                               </table>
+                                                               </span> 
+                                                       </td>
+                                       </tr>
+                                       <tr class="even">
+                                                       <td class="key">Full Name</td>
+                                                       <td class="value">
+                                                               <span id="nameval" class="value" >{{ fullname }} </span>
+                                                               <span class="hide_this" id="span_name">
+                                                               <button type="button" class="btn btn-default btn-xs" title="Cancel" id="cancel_name_change"> Cancel </button> 
+                                                               <div style='display:none;'><input type='hidden'  name='nameform'  /></div>
+                                                               <input id="fname" type="text" name="fname" class="required"  maxlength="200" value="{{firstname}}" />
+                                                               <input id="lname" type="text" name="lname" class="required"  maxlength="200" value="{{lastname}}" />
+                                                               <input type="submit" class="btn btn-default btn-xs" name="submit_name" value="Save"/>
+                                                               </span>
+                                                               <button class="btn btn-default btn-xs" type="button"title="Full Name" id="edit_name">
+                                                                       <span class="glyphicon glyphicon-edit"></span> Edit
+                                                               </button>
+                                                       </td>
+                                       </tr>
+                                       <tr class="odd">
+                                                       <td class="key">Authority</td>
+                                                       <td class="value">
+                                                               <span id="affval" class="value">{{ authority }}</span>
+                                                                <button class="btn btn-default btn-xs" type="button" id="edit_auth" onclick="editAlert()"  title="To change your authority please contact the administrator">
+                                                               <span class="glyphicon glyphicon-question-sign"></span> Edit
+                                                                </button>
+                                                       </td>
+                                               </tr>
+                                               {%if 'Enabled'  in user_status %}
+                                               <tr class="even">
+                                                       <td class="key">Generate Keys</td>
+                                                       <td>
+                                                               <input type="submit" name="generate" class="btn btn-primary" value="Generate a new Key Pair" id="generate_keypair" 
+                                                                          onclick="return confirm('Are you sure? If you do so, your current credentials will be overwritten.');" 
+                                                                          title="It will generate a new key Pair and your current credentials will be overwritten."/>
+                                               </td> 
+                                       </tr>
+                                       <tr class="odd">
+                                               <td class="key">Public Key</td>
+                                               <td class="value">
+                                                               <span id="keyval" class="value">******** </span>
+                                                               <span class="hide_this" id="span_upload">
+                                                                       <button type="button" class="btn btn-default" title="Cancel" id="cancel_upload"> Cancel </button>
+                                                                       <div style='display:none;'>
+                                                                               <input type='hidden'  name='upload'  /></div>
+                                                                               <input type="file" name="pubkey" class="required" id="pubkey"/>  
+                                                                               <input class="btn btn-default btn-xs" name="upload_key" id="upload_key"  type="submit" title="Upload your public key" value="Upload"
+                                                                                  onclick="return confirm('Are you sure? It will overwrite your current credentials and you have delegate it manually.');"/>
+                                                               </span>
+                                                               <div style='display:none;'> <input type='hidden'  name='dload'  /> </div> 
+                                                               <button type="submit" name="dl_pubkey" class="btn btn-default btn-xs" title="Download your public key" id="dl_file">
+                                                                       <span class="glyphicon glyphicon-download"></span> Download
+                                                               </button>
+                                                               <button class="btn btn-default btn-xs" id="upload_file" type="button" title="Upload a public key">
+                                                                       <span class="glyphicon glyphicon-upload"></span> Upload
+                                                               </button>       
+                                               </td>
+                                       </tr>
+                                       <tr class="even" id="pkey_row">
+                                                {%if 'N/A' not in user_private_key%}
+                                               <td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform   -->
+                                               <td class="value">********<a href="#"></a>
+                                                       <button type="submit" name="dl_pkey" class="btn btn-default" title="Download your privaye key" id="dl_pkey">
+                                                                       <span class="glyphicon glyphicon-download"></span> Download     
+                                                               </button>
+                                                       <input class="btn btn-danger btn-xs" id="delete" name="delete" type="submit"  value="Delete" title="Delete your private key"
+                                                                               onclick="return confirm('Are you sure? If you do so, you have to delegate your credentials manually.');"/> 
+                                               </td>
+                                                 {%else%}
+                                                       <td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform   -->
+                                                       <td class="value">********<a href="#"></a>
+                                                       <button type="submit" name="dl_pkey" class="btn btn-default disabled" title="Download your privaye key" id="dl_pkey">
+                                                               <span class="glyphicon glyphicon-download"></span> Download 
+                                                       </button>
+                                                       <input class="btn btn-danger btn-xs disabled" id="delete" name="delete" type="submit" title="Delete your private key" value="Delete" />
+                                                       </td>
+                                                {%endif%}              
+                                               </tr>
+                                               <tr class="even">
+                                               <td colspan="2">
+                                                       <p class="message" id="pkey_del_msg"><b> Tradeoff:</b> Ease-of-use vs Security.<br>
+                                                                       <b>Ease-of-use:</b> Automatic account delegation. Don't delete private key.<br>
+                                                                       <b>Security:</b> Manual account delegation. Download & Delete private key.
+                                                               </p>
+                                               </td>
+                                               </tr>
+                                               {%endif%}
+                                       </table>
+                       
+               </div>
+       </div>
+
+       <div class="tab-pane row" id="account">
+               <div class="col-md-12">
+       
+               <h3>Principal Account <small>Account used for delegating credentials</small></h3>
+               <table class="table"> 
+                       <tr class="odd"> 
+                       <th>Platform</th> 
+                       <th>Account Type</th>
+                               <th>Account Delegation</th>
+                       <th>User hrn</th>
+                               <th>User Status</th>
+                       <!--<th>Pub Key</th> -->
+               </tr>   
+                       {% for row in principal_acc %}         
+                       <tr class="border_bottom">
+                       <td class="odd"> {{ row.platform_name }} </td>
+                       <td class="odd"> {{ row.account_type }} </td>
+                               <td class="odd"> {{ row.delegation_type }} </td>
+                               <td class="odd"> {{ row.usr_hrn }}  </td>
+                               <td class="odd"> {{ row.user_status }}  </td>
+               <!--    <td class="even"> {{ row.usr_pubkey }} </td> -->
+               </tr> 
+                       {%endfor%}               
+               </table>
+       
+               </div>
+       
+
+       {%if 'Enabled'  in user_status %}
+               <div class="col-md-12">
+               <h3>Credentials <small>Delegated to Principal Account</small></h3>
+                       <table class="table">
+                                       <caption><b>Delegated User Credential</b></caption> 
+                           <tr class="odd"> 
+                               <th>Expiration Date</th>
+                                               <th>Download</th>
+                           </tr>
+                                       {% for row in my_users %}         
+                                       <tr class="border_bottom">
+                                       <td class="odd"> {{ row.cred_exp }} </td>
+                                               <td class="odd">
+                                                       <button class="btn btn-default btn-xs" name= "dl_user_cred" type="submit" title="Download User Credential">
+                                                               <span class="glyphicon glyphicon-download"></span> Credential
+                                                       </button>
+                                                       <button class="btn btn-default btn-xs" name= "dl_user_cert" type="submit" title="Download User Certificate">
+                                                               <span class="glyphicon glyphicon-download"></span> Certificate
+                                                       </button>
+                             <button class="btn btn-default btn-xs" name= "dl_user_p12" type="submit" title="Download User PKCS12">
+                                 <span class="glyphicon glyphicon-download"></span> PKCS p12
+                             </button>
+                                               </td>
+                                       </tr>
+                                       {%endfor%}
+                                </table>
+                               <p></p>
+                               <table class="mytable table table-bordered table-hover">
+                                       <caption><b>Delegated Slice Credentials</b></caption>  
+                               <tr class="odd"> 
+                                               <th>Slice Name</th> 
+                                       <th>Expiration Date</th>
+                                               <th>Download</th>
+                               </tr>
+                                       {% for row in my_slices %}     
+                               <tr class="border_bottom">
+                                       <td class="odd"> {{ row.slice_name }} </td>
+                                               <td class="odd"> {{ row.cred_exp }} </td>
+                                               <td class="odd"> 
+                                                       <button class="btn btn-default btn-xs" name= "dl_{{row.slice_name}}" type="submit" title="Download Slice Credentials">
+                                                               <span class="glyphicon glyphicon-download"></span> Download
+                                                       </button> 
+                                               </td>
+                               </tr>
+                               {%endfor%}
+                               </table>
+                               <p></p>
+                               <table class="mytable table table-bordered table-hover">
+                                       <caption><b>Delegated Authority Credentials</b></caption>
+                                       <tr class="odd"> 
+                                       <th>Authority Name</th> 
+                                       <th>Expiration Date</th>
+                                               <th>Download</th>
+                                       </tr>
+                                       {% for row in my_auths %}
+                                       <tr class="border_bottom">
+                                       <td class="odd"> {{ row.auth_name }} </td>
+                                       <td class="odd"> {{ row.cred_exp }} </td>
+                                               <td class="odd">
+                                                       <button class="btn btn-default btn-xs" name= "dl_{{row.auth_name}}" type="submit" title="Download Authority Credentials">
+                                                               <span class="glyphicon glyphicon-download"></span> Download
+                                                       </button>
+                                               </td>
+                                       </tr>
+                                       {%endfor%}
+                               </table>
+                               <p></p>
+                                {%if '' not in my_users%}      
+                               <p><button class="btn btn-danger btn-lg btn-block"   name= "clear_cred" type="submit" title="Clear All Credentials">Clear Credentials</button></p>
+                               {%else%}
+                               <p><button class="btn btn-danger btn-lg btn-block disabled"   name= "clear_cred" type="submit" title="Clear All Credentials">Clear Credentials</button></p>
+                               {%endif%}
+               </div>
+       </div>
+<!-- Modal- No credentials -->
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">No credentials are delegated to the portal</h4>
+                    </div>
+                    <div class="modal-body">
+                                       <p>You may get this message for several reasons.</p>
+                                       <h3>Account Delegation: Automatic</h3>
+                                       <ul>
+                                               <li>If your account is not yet validated</li>
+                                               <li>If you press the "Clear Credentials" button</li>
+                                               <li>If you "Generate a new key pair"</li>
+                                               <li>If a new slice is added to your account</li>
+                                       </ul>
+                                       <p>In all the above mentioned cases, it is sufficient to refresh the page or go back to home page. The portal will regenrate your credentials.
+                                        In some cases it may take more time than usual. If nothing works, then please logout and login again to the portal.</p>
+                                       <h3>Account Delegation: Manual</h3>
+                                               <p>First of all your account needs to be validated by the manager of your organization.</p>
+                                               <p>As you have uploaded your own public key, the portal can no longer generate your credentials automatically.</p>
+                                               <p>In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to
+                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a>
+                                       </p>
+                                       <h5>Contact support</h5>
+                                       <p>If you don't have the above mentioned cases and still have this message, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
+
+
+       <div class="tab-pane row" id="access">
+               <div class="col-md-12">
+       
+               <h3>Testbed Access <small>Reference Accounts in the following testbeds</small></h3>
+        <table class="mytable table table-bordered table-hover"> 
+            <tr class="odd"> 
+                <th>Platform</th> 
+                <th>Account Type</th>
+                               <th>Reference to</th>
+                               <th>Remove Account</th>
+            </tr>   
+            {% for row in ref_acc %}         
+            <tr class="border_bottom">
+                <td class="odd"> {{ row.platform_name }} </td>
+                <td class="odd"> {{ row.account_type }} </td>
+                               <td class="odd"> {{ row.account_reference }} </td>
+                               <td class="odd">
+                               <button class="btn btn-danger" name="delete_{{row.platform_name}}" type="submit" title="Delete account from this platform">
+                                               <span class="glyphicon glyphicon-minus"></span>
+                                       </button>
+                               </td>
+            </tr> 
+            {%endfor%}               
+        </table>               
+               
+               
+               <h3>Add reference account to the following testbeds</h3>
+        <table class="mytable table table-bordered table-hover"> 
+            <tr class="odd"> 
+                <th>Platforms</th> 
+                <th>Add Account</th>
+            </tr>   
+            {% for platform in platform_list %}         
+            <tr class="border_bottom">
+                <td class="odd"> {{ platform.platform_no_access }} </td>
+                <td class="odd">
+                                       <button class="btn btn-success btn-sm" name= "add_{{platform.platform_no_access}}" type="submit" title="Add account to this platform">
+                                               <span class="glyphicon glyphicon-plus"></span>
+                                       </button>
+                               </td>
+            </tr> 
+            {%endfor%}               
+        </table>
+       </div>
+{%endif%} 
+</div>
+</form>
+</div>
+
+<script>
+    $(document).ready(function() {
+       $('.nav-tabs a').click(function (e) {
+                       e.preventDefault();
+                       $(this).tab('show');
+                       id = $(this).attr('href').substr(1);
+               
+               });
+               
+        $('button#createslice').click(function() {
+            window.location="/portal/slice_request/";
+        });
+    });
+</script>
+
+{% endblock %}
diff --git a/portal/templates/fantaastic/fantaastic_footer.html b/portal/templates/fantaastic/fantaastic_footer.html
new file mode 100644 (file)
index 0000000..307f7d3
--- /dev/null
@@ -0,0 +1,16 @@
+<div class="footer">
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+            <ul>
+                <li></li>
+            </ul>
+        </div>
+    </div>
+    <div class="row">
+        <div class="col-md-12 copy">
+            
+        </div>
+    </div>
+</div>
+</div>
\ No newline at end of file
diff --git a/portal/templates/fantaastic/fantaastic_home-view.html b/portal/templates/fantaastic/fantaastic_home-view.html
new file mode 100644 (file)
index 0000000..e8e733e
--- /dev/null
@@ -0,0 +1,188 @@
+{% extends "layout_base.html" %}
+{% load portal_filters %}
+
+{% block content %}
+<!-- <div class="row">
+{% widget '_widget-news.html' %}
+</div> -->
+{% if username %}
+<div class="container dashboard">
+       <div class="row">
+               {%if 'is_pi'  in pi %}
+               <div class="col-md-3">
+                       <h3>
+                               EXPERIMENT
+                       </h3>
+                       <div>
+                               <a href="#"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Slice</button>
+                       </div>
+                       <div>
+                               <p><strong>Your slices </strong>
+                                       <span title="A slice is a set of testbed resources on which you can conduct an experiment. 
+                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'. 
+                                       However, on the OneLab portal, you will only see slices that you have created through OneLab. If you have created slices elsewhere, 
+                                       such as on the PlanetLab Europe portal, those slices will not appear here."
+                                       class="glyphicon glyphicon-info-sign">
+                               </span>
+
+                               </p>
+                       </div>
+                       <div>   
+                               <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+                       </div>
+               </div>
+               <div class="col-md-3">
+                       <h3>MANAGEMENT</h3>
+                       <div>
+                               <a href="/portal/institution"><img src="{{ STATIC_URL }}img/icon_authority_color.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="validaterequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Validate Requests</button>
+                       </div>
+               </div>
+               <div class="col-md-3">
+                       <h3>
+                               SUPPORT
+                       </h3>
+                       <div>
+                               <a href="/portal/support"><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-envelope"></span> Contact</button>
+                       </div>
+               </div>
+               
+               <div class="col-md-3">
+                       <h3>
+                               ACCOUNT
+                       </h3>
+                       <div>
+                               <a href="/portal/account/"><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
+                       </div>
+                       <div>
+                               {% if person.last_name %}
+                                       {{person.first_name}} {{person.last_name}}<br />
+                               {% endif %}
+                       <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
+               </div>
+               </div>
+       </div>
+       {%else%}
+       <div class="row">
+               <div class="col-md-4">
+                       <h3>
+                               EXPERIMENT
+                       </h3>
+                       <div>
+                               <a href="#"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
+                       </div>
+                       <div>
+                               <p><strong>Your slices </strong>
+                               <span title="A slice is a set of testbed resources on which you can conduct an experiment. 
+                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'. 
+                                       However, on the OneLab portal, you will only see slices that you have created through OneLab. If you have created slices elsewhere, 
+                                       such as on the PlanetLab Europe portal, those slices will not appear here."
+                                       class="glyphicon glyphicon-info-sign">
+                               </span>
+                               </p>
+                       </div>
+                       <div>   
+                               <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+                       </div>
+               </div>
+               <div class="col-md-4">
+                       <h3>
+                               SUPPORT
+                       </h3>
+                       <div>
+                               <a href="/portal/support"><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-envelope"></span> Contact</button>
+                       </div>
+               </div>
+               
+               <div class="col-md-4">
+                       <h3>
+                               ACCOUNT
+                       </h3>
+                       <div>
+                               <a href="/portal/account/"><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
+                       </div>
+                       <div>
+                               {% if person.last_name %}
+                                       {{person.first_name}} {{person.last_name}}<br />
+                               {% endif %}
+                       <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
+               </div>
+               </div>
+       </div>
+       {%endif%}
+
+</div>
+{% else %}
+<div class="container-fluid home">
+       <div class="">
+               <div class="col-sm-2"></div>
+               <div class="col-sm-4 slogan">
+                       <h2>
+                               FanTaaStic:
+                       </h2>
+                       <h3>
+                                the one-stop shop for ICT testbeds and support services
+                       </h3>
+               </div>
+               <div class="col-sm-5 col-sm-offset-1">
+                       <div class="row">
+                               {% widget '_widget-login-user.html' %}
+                       </div>
+               </div>
+               <div class="col-sm-1"></div>
+       </div>
+</div>
+{% endif %}
+
+
+<script type="text/javascript">
+       $(document).ready(function() {
+               $('a.home-tab').click(function() {
+                       $('ul.nav-tabs li').removeClass('active');
+                       $(this).parent().addClass('active');
+                       $('div.home-panel').hide();
+                       $('div#'+$(this).data('panel')).show();
+               });
+               $('button#validaterequestbtn').click(function() {
+                       window.location="/portal/institution#requests";
+               });
+               $('button#ticketbtn').click(function() {
+                       window.location="/portal/contact/";
+               });
+               $('button#signupbtn').click(function() {
+                       window.location="/portal/register/";
+               });
+               $('button#slicerequestbtn').click(function() {
+                       window.location="/portal/slice_request/";
+               });
+/*-------
+List of slices has been moved in 
+portal/templates/base.html
+This should go into session
+--------*/
+});
+</script>
+{# widget "_widget-monitor.html" #}
+{# widget "_widget-stats-top-slices.html" #}
+
+{% endblock %}
diff --git a/portal/templates/fantaastic/fantaastic_institution.html b/portal/templates/fantaastic/fantaastic_institution.html
new file mode 100644 (file)
index 0000000..bd361de
--- /dev/null
@@ -0,0 +1,185 @@
+{% extends "layout_wide.html" %}
+
+{% block head %} 
+<script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
+{% endblock head %}
+
+{% block content %}
+<div class="container">
+       <div class="row">
+               <div class="col-md-12">
+                        <div class="breadcrumbs">
+                                Management &nbsp;>&nbsp; Institution: <span id="authority_name"></span>
+                        </div>
+               </div>
+       </div>
+</div>
+<div class="container">
+       <div class="row">
+               <div class="col-md-12">
+                       <ul class="nav nav-tabs nav-section">
+                               <li class="active"><a href="#about">About</a></li>
+                               <li><a href="#users">Users</a></li>
+                               <li><a href="#slices">Slices</a></li>
+                               <li><a href="#requests">Requests</a></li>
+                       </ul>
+           </div>
+       </div>
+</div>
+<div class="container tab-content">
+       <div class="tab-pane active row" id="about">
+       </div>
+       
+       <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
+               <div class="col-md-12 el">
+                       <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+                               <div id="user-tab-loaded" style="display:none;">
+                               <table id="user-tab" class="table">
+                                       <tr>
+                                       <th>+/-</th>
+                                       <th>Email</th>
+                                       <th>User hrn</th>
+                            <!--
+                                       <th>First name</th>
+                                       <th>Last name</th>
+                                       <th>Enabled</th>
+                            -->
+                                       </tr>
+                               </table>
+                               
+                       </div>
+                       {%if 'is_pi'  in pi %}  
+                       <div>
+                               <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
+                       </div>
+                       {% endif %}
+               </div>
+       </div>
+
+       <div class="tab-pane row" id="slices">
+               <div class="col-md-12 el">
+           <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+           <div id="slice-tab-loaded" style="display:none;">
+               <table id="slice-tab" class="table">
+                   <tr>
+                       <th>+/-</th>
+                       <th>Slice hrn</th>
+                       <th>Users</th>
+                       <th>Url</th>
+                       <!-- <th>nodes</th> -->
+                       <th>Creation</th>
+                   </tr>
+               </table>                        
+           </div>
+       {% if 'is_pi'  in pi %}
+        <div>
+               {% if 'is_pi'  in pi %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+                       {% else %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                       {% endif %}
+            <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
+            <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
+        </div>
+               {% endif %} 
+          </div>
+       </div>
+       <div class="tab-pane row" id="requests">
+       </div>
+</div>
+<script>
+$(document).ready(function() {
+    {% if person %}
+    {% if user_details.parent_authority %}
+
+        $.post("/rest/slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+            var list_slices = [];
+            var table_slices = [];
+            /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
+            $.each( data, function( key, val ) {
+                list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
+                if(val.nodes=="undefined" || val.nodes==null){
+                    nodes_length=0;
+                }else{
+                    nodes_length=val.nodes.length;
+                }
+                console.log(val);
+                if(val.users=="undefined" || val.users==null){
+                    users_length=0;
+                }else{
+                    users_length=val.users.length;
+                }
+
+                if(val.url=="undefined" || val.url==null){
+                    slice_url="";
+                }else{
+                    slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
+                }
+                
+                slice_row = "<tr id='"+val.slice_hrn+"'>";
+                slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
+                slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
+                slice_row += "<td>"+users_length+"</td>";
+                slice_row += "<td>"+slice_url+"</td>";
+                //slice_row += "<td>"+nodes_length+"</td>";
+                slice_row += "<td>"+val.slice_date_created+"</td>";
+                slice_row += "</tr>";
+                table_slices.push(slice_row);
+                
+            });
+           
+            /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
+            $("table#slice-tab tr:last").after(table_slices.join( "" ));
+            $("div#slice-tab-loaded").css("display","block");
+            $("div#slice-tab-loading").css("display","none");
+        });
+               
+               
+        $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+            var list_users = [];
+            var table_users = [];
+                   /* Available fields
+                   user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
+                   user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
+                   */
+            $.each( data, function( key, val ) {
+                list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
+                user_row = "<tr id='"+val.user_hrn+"'>";
+                user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
+                user_row += "<td>"+val.user_email+"</td>";
+                user_row += "<td>"+val.user_hrn+"</td>";
+                /*
+                user_row += "<td>"+val.user_first_name+"</td>";
+                user_row += "<td>"+val.user_last_name+"</td>";
+                           user_row += "<td>"+val.user_enabled+"</td>";
+                */
+                user_row += "</tr>";
+                table_users.push(user_row);
+            });
+            $("table#user-tab tr:last").after(table_users.join( "" ));
+            $("div#user-tab-loaded").css("display","block");
+            $("div#user-tab-loading").css("display","none");
+        });
+
+    {% endif %}
+    {% endif %}
+
+}); // End document.ready
+
+$(document).ready(function() {
+       $('.nav-tabs a').click(function (e) {
+               e.preventDefault();
+               $(this).tab('show');
+       var id = $(this).attr('href').substr(1);
+       if ((id == 'requests') || (id == 'about'))
+               $("#" + id).load('/management/' + id);
+       });
+       var hash = window.location.hash;
+       if (hash) {
+               $('.nav-tabs a[href='+hash+']').click();
+       } else {
+               $('.nav-tabs a[href=#about]').click();
+       }
+});
+</script>
+{% endblock %}
diff --git a/portal/templates/fantaastic/fantaastic_management-tab-requests.html b/portal/templates/fantaastic/fantaastic_management-tab-requests.html
new file mode 100644 (file)
index 0000000..e255779
--- /dev/null
@@ -0,0 +1,226 @@
+<script type="text/javascript">
+       $(document).ready(function() {
+               $("li#nav-request").addClass("active");
+       });
+       function on_click_event() {
+               var ids = []; 
+               $('.portal__validate__checkbox').each(function(i, el) {
+                       if ($(el).prop('checked')) {
+                               // portal__validate__checkbox__slice__2
+                               var id_array = $(el).attr('id').split('__');
+                               // push(slice__2)
+                               ids.push(id_array[3] + '__' + id_array[4]);
+                       }
+               });
+               if (ids.length > 0) {
+                       var id_str = ids.join('/');
+                       // XXX spinner
+                       $.getJSON('/portal/validate_action/' + id_str,
+                               function(status) {
+                                       $.each(status, function(request_type__id, request_status) {
+                                               // request_status: NAME -> dict (status, description)
+                                               var status_str = '';
+                                               $.each(request_status, function(name, result) {
+                                                       if (status_str != '')
+                                                               status_str += ' -- ';
+
+                                                       if (result.status) {
+                                                               status_str += '<font color="green">OK</font>';
+                                                               $('#portal__validate__checkbox__' + request_type__id).hide();
+                                                       } else {
+                                                               status_str += '<font color="red">ERROR: ' + result.description + '</font>';
+                                                       }
+                                               });
+                                               $('#portal__status__' + request_type__id).html(status_str);
+
+
+                                       });
+                               }
+                       );
+               }
+       }
+</script>
+
+<div class="col-md-12">
+       <h2>From your authorities</h2>
+</div>
+{% if my_authorities %}
+       
+       {% for authority, requests in my_authorities.items %}
+       
+       <div class="col-md-12">
+               <h2>{{authority}}</h2>
+       </div>
+       
+    <table class="table">
+      <th>
+        <td>Type</td>
+        <td>Id</td>
+        <td>Details</td>
+        <td>Timestamp</td>
+        <td>Status</td>
+      </th>
+    {% for request in requests %}
+
+         <tr>
+               <td>
+               {% if request.allowed == 'allowed' %}
+               <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+               {% else %}
+                       {% if request.allowed == 'expired' %}
+                               expired
+                       {% else %} {# denied #}
+                               denied
+                       {% endif %}
+               {% endif %}
+               </td>
+               <td>{{ request.type }}</td>
+               <td>{{ request.id }}</td>
+               <td>
+        {% if request.type == 'user' %}
+            <b>{{request.first_name}} {{request.last_name}}</b> <a href="mailto:{{request.email}}">{{request.email}}</a>
+        {% else %}
+            {% if request.type == 'slice' %}
+            <b>{{request.slice_name}}</b> -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+            {% else %} {# authority #}
+            <b>{{request.site_name}}</b> ({{request.site_authority}}) -- {{request.address_city}}, {{request.address_country}}
+            {% endif %}
+        {% endif %}
+               </td>
+               <td>{{ request.timestamp }}</td>
+               
+               <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+
+    <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+         </tr>
+
+    {% endfor %}
+       </table>
+       {% endfor %}
+
+{% else %}
+       <div class="col-md-12">
+               <i>There is no pending request waiting for validation.</i>
+       </div>
+{% endif %}
+<div>nnllknjkn<br /><br /></div>
+<div class="col-md-12">
+       <h2>From your sub-authorities</h2>
+</div>
+{% if sub_authorities %}
+       
+       {% for authority, requests in sub_authorities.items %}
+       <div class="col-md-12">
+               <h2>{{authority}}</h2>
+       </div>
+       
+       <table class="table">
+             <th>
+               <td>Type</td>
+               <td>Id</td>
+               <td>Details</td>
+               <td>Timestamp</td>
+               <td>Status</td>
+             </th>
+           {% for request in requests %}
+                 <tr>
+                       <td>
+                       {% if request.allowed == 'allowed' %}
+                       <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+                       {% else %}
+                               {% if request.allowed == 'expired' %}
+                                       expired
+                               {% else %} {# denied #}
+                                       denied
+                               {% endif %}
+                       {% endif %}
+                       </td>
+                       <td>{{ request.type }}</td>
+                       <td>{{ request.id }}</td>
+                       <td>
+               {% if request.type == 'user' %}
+               Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
+               {% else %}
+                   {% if request.type == 'slice' %}
+               Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+                   {% else %} {# authority #}
+               Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+                   {% endif %}
+               {% endif %}
+                       </td>
+                       <td>{{ request.timestamp }}</td>
+                       
+                       <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+       
+           <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+                 </tr>
+           {% endfor %}
+       </table>
+       {% endfor %}
+{% else %}
+<div class="col-md-12">
+       <i>There is no pending request waiting for validation.</i>
+</div>
+{% endif %}
+
+<div class="col-md-12">
+       <h2>From your authorities with delegation</h2>
+</div>
+
+{% if delegation_authorities %}
+       
+       {% for authority, requests in delegation_authorities.items %}
+       <div class="col-md-12">
+               <h3>{{authority}}</h3>
+       </div>
+       <table class="table">
+                     <th>
+                       <td>Type</td>
+                       <td>Id</td>
+                       <td>Details</td>
+                       <td>Timestamp</td>
+                       <td>Status</td>
+                     </th>
+                   {% for request in requests %}
+                         <tr>
+                               <td>
+                               {% if request.allowed == 'allowed' %}
+                               <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+                               {% else %}
+                                       {% if request.allowed == 'expired' %}
+                                               expired
+                                       {% else %} {# denied #}
+                                               denied
+                                       {% endif %}
+                               {% endif %}
+                               </td>
+                               <td>{{ request.type }}</td>
+                               <td>{{ request.id }}</td>
+                               <td>
+                       {% if request.type == 'user' %}
+                       Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
+                       {% else %}
+                           {% if request.type == 'slice' %}
+                       Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+                           {% else %} {# authority #}
+                       Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+                           {% endif %}
+                      {% endif %}
+                               </td>
+                               <td>{{ request.timestamp }}</td>
+                               
+                               <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+               
+                   <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+                         </tr>
+                   {% endfor %}
+       </table>
+               {% endfor %}
+{% else %}
+<div class="col-md-12">
+       <i>There is no pending request waiting for validation.</i>
+</div>
+{% endif %}
+<div class="col-md-12">
+       <button class="btn btn-onelab" type="button" id="portal__validate" onclick="on_click_event();"><span class="glyphicon glyphicon-ok"></span> Validate</button>
+</div>
diff --git a/portal/templates/fantaastic/fantaastic_slicerequest_view.html b/portal/templates/fantaastic/fantaastic_slicerequest_view.html
new file mode 100644 (file)
index 0000000..211f35d
--- /dev/null
@@ -0,0 +1,108 @@
+{% extends "layout.html" %}
+{% load i18n %}
+
+{% block content %}
+       <div class="row">
+               <div class="col-md-12">
+                        <div class="breadcrumbs">
+                                Experiment &nbsp;>&nbsp; Request a new Slice
+                        </div>
+               </div>
+       </div>
+
+       {% if errors %}
+       <div class="row">
+               <div class="col-md-12">
+               <ul class="error">
+                 {% for error in errors %}
+                 <li>{{ error }}</li>
+                 {% endfor %}
+               </ul>
+               </div>
+       </div>
+       {% endif %}
+       
+       <div class="row">
+               <div class="col-md-8 el">
+                       <form role="form" method="post">
+                       {% csrf_token %}
+                         <div class="form-group" style="display:none">
+                           <input type="email" class="form-control" id="email" style="width:300px" value="{{ email }}" readonly="readonly">
+                         </div>
+                         <div class="form-group">
+                           <input type="text" class="form-control" name="slice_name" id="slice_name" style="width:300px" placeholder="Slice name" value="{{slice_name}}" 
+                               title="Please enter a name for your slice"required="required">
+                         </div>
+                         <div class="form-group">
+                               {%if 'is_pi'  in pi %}
+                               <input type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Organization" 
+                               title="An authority responsible for vetting your slice" required="required">
+                               {%else%}
+                           <input type="text" class="form-control" id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;" 
+                               title="An authority responsible for vetting your slice" required="required" readonly>
+                               {%endif%}
+                         </div>
+                         <div class="form-group">
+                           <input type="text" class="form-control" name="url" id="url" style="width:300px" placeholder="Experiment URL (if one exists)"
+                               title="Please provide the url of your experiment if you have one." value="{{url}}">
+                         </div>
+                         <div class="form-group">
+                               <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Experiment purpose" style="width:300px" 
+                               title="Purpose of your experiment (informative)" required="required">{{ purpose }}</textarea>
+                         </div>
+                         {%if 'is_pi'  in pi %}        
+                         <button type="submit" id=submit_pi class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+                         {%else%}
+                         <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                         {%endif%}     
+                       </form>
+       
+               </div>
+       </div>
+               
+<script>
+jQuery(document).ready(function(){
+       
+       /*$("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) {
+               var jsonData = JSON.parse(data);
+        $(this).attr("value", jsonData[0]['parent_authority']);
+    });*/
+       $("#authority_hrn").val("{{authority_name}}");
+       var availableTags = [
+    {% if authorities %}
+        {% for authority in authorities %}
+            {% if authority.name %}
+                {value:"{{ authority.name }}",label:"{{authority.name}}"},
+                       // to show only full name
+           // {% else %}
+           //     {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
+            {% endif %}
+        {% endfor %}    
+    {% else %}
+        {value:"",label:"No authority found !!!"}
+    {% endif %}
+    ];
+       // sorting the list
+       availableTags.sort(function(a,b){
+               var nameA=a.value.toLowerCase(), nameB=b.value.toLowerCase();
+               if (nameA < nameB) {
+               return -1;
+               }
+               if (nameA > nameB) {
+               return 1;
+               }
+       return 0;
+       }); 
+    $( "#authority_hrn" ).autocomplete({
+      source: availableTags,
+      minLength: 0,
+      select: function( event, ui ) {console.log(jQuery(this));}
+    });
+
+       $("#submit_pi").click(function() {
+               localStorage.clear();
+       });
+});
+</script>
+{% endblock %}
+
diff --git a/portal/templates/fantaastic/fantaastic_widget-login-user.html b/portal/templates/fantaastic/fantaastic_widget-login-user.html
new file mode 100644 (file)
index 0000000..7529c61
--- /dev/null
@@ -0,0 +1,26 @@
+<div class="login-form">
+       {% if state %}
+       <span class="help-block">{{ state }}</span>
+       {% endif %}
+       <form action="/login/" method="post" role="form">
+         {% csrf_token %}
+         {% if next %}
+         <input type="hidden" name="next" value="{{ next }}" />
+         {% endif %}
+       <div class="form-group">
+       <input type="email" name="username" placeholder="Enter Email / Username">
+       </div>
+       <div class="form-group">
+       <input type="password" name="password" placeholder="Password">
+       </div>
+       <div class="login-submit">
+               <input type="submit" class="btn btn-onelab" value="Sign In" />
+               <span class="lost-password">&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="/portal/pass_reset/">Can't access your account?</a></span>
+       </div>
+       <div class="login-signup">
+               <!-- You don't have yet an account? 
+               
+               <a href="/register">Sign Up!</a> -->
+       </div>
+       </form>
+</div>
index de37b04..bfaaa62 100644 (file)
@@ -1,55 +1,50 @@
-
-<div id="header">
-       <div class="wrapper">
-               <div class="logo">
-                       <a href="/"><img src="{{ STATIC_URL }}img/fantaastic-s.png" alt="FanTaaStic" /></a>
+{% load portal_filters %}
+<div class="header">
+<div class="container">
+       <div class="row">
+               <div class="col-sm-3 col-md-3 logo">
+                       <a href="/"><img height="60" src="{{ STATIC_URL }}img/fantaastic.png" alt="FanTaaStic | testbeds.eu Portal - EIT ICT Labs" /></a>
                </div>
-               
-               <div id="secondary">
+               {% if username %}
+               <div class="col-sm-4 col-md-4 navigation">
                        <ul>
-                               <li>News</li>
-                               <li><a href="/portal/about">About</a></li>
-                               <li><a target="_blank" href="http://www.onelab.eu">Public Website</a></li>
-                               <li><a target="_blank" href="http://intranet.onelab.eu">Intranet</a></li>
+                               <li>
+                                       <a class="dropdown-toggle" data-toggle="dropdown" href="#">
+                                       EXPERIMENT <span class="caret"></span>
+                               </a>
+                                       
+                                       <div class="dropdown-menu" style="z-index:99;">
+                                                       <ul id="dropdown-slice-list">
+                                                               <li class="title"><a href="/portal/slice_request/">Request Slice</a></li>
+                                                       </ul>
+                                       </div>
+                               </li>
+                               {%if 'is_pi'  in pi %}  
+                               <li id="nav-institution" class=""><a href="/institution">MANAGEMENT</a></li>
+                                {%endif%}
+                               <li><a href="/support/">SUPPORT</a></li>
                        </ul>
                </div>
-       </div>
-       
-       {% if username %}
-       <div id="navigation">
-               <div class="wrapper">
-               <ul>
-                       <li id="nav-account"><a href="/portal/account/">{{ username }}</a></li>
-                       <li>|</li>
-                       <li id="nav-institution" class=""><a href="/portal/institution">INSTITUTION</a></li>
-                       <li class="slices">
-                               <a class="dropdown-toggle" data-toggle="dropdown" href="#">
-                                       SLICES <span class="caret"></span>
-                       </a>
+               {% else %}
+               <div class="col-sm-4 col-md-4 navigation">
+               </div>
+               {% endif %}
+               <div class="col-sm-5 col-md-5 secondary">
+                       <ul>
                                
-                               <div class="dropdown-menu" style="z-index:99;">
-                                               <ul>
-                                                       <li><a href="/portal/slice_request/">Request Slice</a></li>
-                                                       <li><a href="/slice/ple.upmc.agent3/">ple.upmc.agent3</a></li>
-                                                   <li><a href="/slice/ple.upmc.agent/">ple.upmc.agent</a></li>
-                                                   <li><a href="/slice/ple.upmc.myslicedemo/">ple.upmc.myslicedemo</a></li>
-                                                   <li><a href="/slice/ple.upmc.slicestat/">ple.upmc.slicestat</a></li>
-                                                   <li><a href="/slice/ple.upmc.agent2/">ple.upmc.agent2</a></li>
-                                               </ul>
-                               </div>
-                               </li>
-                       <li id="nav-request"><a href="/portal/validate">REQUESTS</a></li>
-                       <li id="nav-support"><a href="/portal/support/">SUPPORT</a></li>
-                       <li>|</li>
-                       <li id="nav-logout" style="margin-top: 10px;"><a id="logout" style="cursor:pointer;" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> LOGOUT</a></li>
-               </ul>
+                               <li><a target="_blank" href="http://status.testbeds.eu">Services Status</a></li>
+                               <li><a target="_blank" href="http://testbeds.eu">Web site</a></li>
+                       </ul>
+                       {% if username %}
+                       <div class="account">You are logged in as &nbsp;<a href="/account/">{{ username }}</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a id="logout" style="cursor:pointer;" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+                       {% endif %}
                </div>
        </div>
-       {% else %}
-       <div id="navigation">
-               <div class="wrapper"></div>
-       </div>
-       {% endif %}
+</div>
+</div>
+
+<div class="row">
+{% widget '_widget-message.html' %}
 </div>
 <script>
        $(document).ready(function() {
index 5af90c8..91998cb 100644 (file)
@@ -68,7 +68,7 @@
                                        <p> More Info: <a href="http://myslice.info/" target="_blank">http://myslice.info/</a></p>
                                        <p> Code: <a href="http://git.onelab.eu/?p=myslice.git;a=summary" target="_blank">Git Repository</a> (read only)</p> 
                                        <p> 
-                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@myslice.info">support@myslice.info</a>.
+                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@onelab.eu">support@onelab.eu</a>.
                                        </p>
 
 
index ac85870..13da125 100644 (file)
@@ -1,7 +1,20 @@
-{% extends "layout_wide.html" %}
+{% extends "layout.html" %}
 {% block content %}
 
+<div class="row">
+       <div class="col-md-12">
+                <div class="breadcrumbs">
+                        Account &nbsp;>&nbsp; <a href="/account">{{ person.email }}</a>
+                </div>
+       </div>
+        {%if 'no_creds'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
+    {%endif%}
+        {%if 'creds_expired'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
+    {%endif%}
 
+</div>
 {% if messages %}
 <ul class="messages">
     {% for message in messages %}
     {% endfor %}
 </ul>
 {% endif %}
-<div class="container">
-       <div class="row">
-               <div class="col-md-12">
-                       <ul class="nav nav-tabs nav-section">
-                               <li class="active"><a href="#profile"><img src="{{ STATIC_URL }}icons/user-xs.png" alt="User Account" /> User Profile</a></li>
-                               <li><a href="#account">Account</a></li>
-                               <li><a href="#access">Testbed Access</a></li>
-                       </ul>
-           </div>
-       </div>
+<div class="row">
+       <div class="col-md-12">
+               <ul class="nav nav-tabs nav-section">
+                       <li class="active"><a href="#profile">User Profile</a></li>
+                       <li><a href="#account">Account</a></li>
+                       <li><a href="#access">Testbed Access</a></li>
+               </ul>
+    </div>
 </div>
-<div class="container tab-content">
+<div class="tab-content">
        <div class="tab-pane active row" id="profile">
                
                <div class="col-md-12">
                                        <table class="profile">          
                                        <tr>
                                                <td colspan="2">
-                                                               <div>Platform: Myslice</div>
+                                                               <div><h3>Platform: Myslice</h3></div>
                                                </td>
                                        </tr>
                                        <tr>
                                                <td class="key">Email</td>
                                                <td class="value">
                                                                <span id="emailval" class="value" >{{ person.email }}</span>
-                                                               <button class="btn btn-default btn-xs" type="button" id="edit_email" onclick="editAlert();"  title="To change your affiliation please contact the administrator">
+                                                               <button class="btn btn-default" type="button" id="edit_email" onclick="editAlert();"  title="To change your affiliation please contact the administrator">
                                                                <span class="glyphicon glyphicon-question-sign"></span> Edit
                                                                </button>
                                                        </td>
                                                <tr class="even">
                                                        <td class="key">Generate Keys</td>
                                                        <td>
-                                                               <input type="submit" name="generate" class="btn btn-danger btn-xs" value="Generate a new Key Pair" id="generate_keypair" 
+                                                               <input type="submit" name="generate" class="btn btn-primary" value="Generate a new Key Pair" id="generate_keypair" 
                                                                           onclick="return confirm('Are you sure? If you do so, your current credentials will be overwritten.');" 
                                                                           title="It will generate a new key Pair and your current credentials will be overwritten."/>
                                                </td> 
                                                <td class="value">
                                                                <span id="keyval" class="value">******** </span>
                                                                <span class="hide_this" id="span_upload">
-                                                                       <button type="button" class="btn btn-default btn-xs" title="Cancel" id="cancel_upload"> Cancel </button>
+                                                                       <button type="button" class="btn btn-default" title="Cancel" id="cancel_upload"> Cancel </button>
                                                                        <div style='display:none;'>
                                                                                <input type='hidden'  name='upload'  /></div>
                                                                                <input type="file" name="pubkey" class="required" id="pubkey"/>  
                                                 {%if 'N/A' not in user_private_key%}
                                                <td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform   -->
                                                <td class="value">********<a href="#"></a>
-                                                       <button type="submit" name="dl_pkey" class="btn btn-default btn-xs" title="Download your privaye key" id="dl_pkey">
+                                                       <button type="submit" name="dl_pkey" class="btn btn-default" title="Download your privaye key" id="dl_pkey">
                                                                        <span class="glyphicon glyphicon-download"></span> Download     
                                                                </button>
                                                        <input class="btn btn-danger btn-xs" id="delete" name="delete" type="submit"  value="Delete" title="Delete your private key"
                                                  {%else%}
                                                        <td class="key">Private Key </td> <!-- Hide if priv_key doesn't exist in myslice platform   -->
                                                        <td class="value">********<a href="#"></a>
-                                                       <button type="submit" name="dl_pkey" class="btn btn-default btn-xs disabled" title="Download your privaye key" id="dl_pkey">
+                                                       <button type="submit" name="dl_pkey" class="btn btn-default disabled" title="Download your privaye key" id="dl_pkey">
                                                                <span class="glyphicon glyphicon-download"></span> Download 
                                                        </button>
                                                        <input class="btn btn-danger btn-xs disabled" id="delete" name="delete" type="submit" title="Delete your private key" value="Delete" />
                                                        </td>
                                                 {%endif%}              
                                                </tr>
-                                               <tr class="odd">
-                                                       {%if 'N/A' not in user_private_key%}
-                                                       <td class="key">Identity</td> 
-                                               <td>
-                                                               <button type="submit" name="dl_identity" class="btn btn-default btn-xs" title="You will require it to use jfed" id="dl_identity">
-                                                               <span class="glyphicon glyphicon-download"></span> Download 
+                                       <tr class="even" id="sfi_config_row">
+                                               <td class="key">sfi_config </td>
+                                               <td class="value">use sfi_config file with sfi.py package (pip install sfa)<a href="#"></a>
+                                                       <button type="submit" name="dl_sfi_config" class="btn btn-default btn-xs" title="Download your privaye key" id="dl_sfi_config">
+                                                                       <span class="glyphicon glyphicon-download"></span> Download
                                                                </button>
-                                                       </td>
-                                                       {%else%}
-                                                       <td class="key">Identity</td> 
-                                                       <td>
-                                                       <button type="submit" name="dl_identity" class="btn btn-default btn-xs disabled" title="You will require it to use jfed" id="dl_identity">
-                                                               <span class="glyphicon glyphicon-download"></span> Download 
-                                                       </button>
-                                                       </td>
-                                                       {%endif%} 
-                                               </tr>
+                                               </td>
+                        </tr>
+
                                                <tr class="even">
                                                <td colspan="2">
-                                                       <p class="message" id="pkey_del_msg"><b> Tradeoff:</b> Ease-of-use vs Security.<br>
-                                                                       <b>Ease-of-use:</b> Automatic account delegation. Don't delete private key.<br>
-                                                                       <b>Security:</b> Manual account delegation. Download & Delete private key.
+                                                               <p class="command">
+                                                                       <a href="#" style="color:green" data-toggle="modal" data-target="#tradeoffmodal">Automatic vs. Manual delegation of credentials:</a>
+                                                                       Trade-off between ease-of-use & security</p>
                                                                </p>
                                                </td>
                                                </tr>
                                                        <button class="btn btn-default btn-xs" name= "dl_user_cert" type="submit" title="Download User Certificate">
                                                                <span class="glyphicon glyphicon-download"></span> Certificate
                                                        </button>
-                                                       <button class="btn btn-default btn-xs" name= "dl_user_p12" type="submit" title="Download User PKCS12">
-                                                               <span class="glyphicon glyphicon-download"></span> PKCS p12
-                                                       </button>
+                             <button class="btn btn-default btn-xs" name= "dl_user_p12" type="submit" title="Download User PKCS12">
+                                 <span class="glyphicon glyphicon-download"></span> PKCS p12
+                             </button>
                                                </td>
                                        </tr>
                                        {%endfor%}
                                {%endif%}
                </div>
        </div>
+<!-- Modal- No credentials -->
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">No credentials are delegated to the portal</h4>
+                    </div>
+                                       <div class="modal-body" style="text-align:justify;">
+                                       <p>You are getting this message for any of the following reasons:</p>
+                                       <ul>
+                                               <li>If your account is still pending for validation</li>
+                                               <li>If you press the "Clear Credentials" button</li>
+                                               <li>If you "Generate a new key pair"</li>
+                                               <li>If a new slice is added to your account</li>
+                                       </ul>
+                                       <p>Unless your account has not yet been validated, it is sufficient to refresh the page or go back to the home page. 
+                                               The portal will then regenerate your credentials. In some cases it may take more time than usual. If nothing works, 
+                                               then please logout and login back into to the portal.
+                                       </p>
+                                       <h3>Manual delegation of credentials</h3>
+                                               <p>
+                                                       You have selected upon sign-up to upload your public key. As you have uploaded your own public key, 
+                                                       the portal can no longer generate your credentials automatically. In order to have your credentials 
+                                                       delegated to the portal, please follow these instructions:
+                                               </p>
+                                               <ul>
+                                                       <li>Your account must first be validated by the manager of your organization.</li>
+                                                       <li>In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to
+                                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a></li>
+                                               </ul>
+                                       </p>
+                                       <h3>Contact support</h3>
+                                       <p>If you don't have the above mentioned cases and still have this message, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
+
+
+<!-- Modal- Trade-off Message  -->
+<div class="modal fade" id="tradeoffmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">
+                                                               Automatic vs. Manual delegation of credentials
+                                                       </h4>
+                    </div>
+                                       <div class="modal-body" style="text-align:justify;">
+                                       <h3>Automatic delegation of credentials</h3>
+                                               <p>Don't delete private key, ease-of-use option:</p>
+                                               <ul>
+                                                       <li>
+                                                               This means that you will keep your private key in the portal and it will automatically delegate your credentials on your behalf.
+                                                       </li>
+                                                       <li>
+                                                               This option does not provide as high of a level of security; however, your private key will still only be used in the portal and 
+                                                               will be available to you and the OneLab admins only.
+                                                       </li>
+                                               </ul>
+                                       <h3>Manual delegation of credentials</h3>
+                                               <p>Download & Delete private key, higher security option:</p>
+                                               <ul>
+                                                       <li>If you delete your private key, you will have more security but the portal will no longer be able to delegate credentials 
+                                                               on your behalf, and you will have to manually
+                                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a>
+                                                       </li>
+                                               </ul>
+                                       <h3>Contact support</h3>
+                                       <p>For more information, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
+
+
 
        <div class="tab-pane row" id="access">
                <div class="col-md-12">
                 <td class="odd"> {{ row.account_type }} </td>
                                <td class="odd"> {{ row.account_reference }} </td>
                                <td class="odd">
-                               <button class="btn btn-danger btn-xs" name="delete_{{row.platform_name}}" type="submit" title="Delete account from this platform">
+                               <button class="btn btn-danger" name="delete_{{row.platform_name}}" type="submit" title="Delete account from this platform">
                                                <span class="glyphicon glyphicon-minus"></span>
                                        </button>
                                </td>
diff --git a/portal/templates/fed4fire/fed4fire_base.html b/portal/templates/fed4fire/fed4fire_base.html
deleted file mode 100644 (file)
index 7eaaf05..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-{# This is required by insert_above #}{% insert_handler %}<!DOCTYPE html>
-<html lang="en"><head>
-<title>Fed4Fire Portal - {{ section }}</title>
-<meta name="viewport" content="width=device-width, initial-scale=1.0">
-<link rel="shortcut icon" href="/static/img/myslice-icon.png">
-{# This is where insert_str will end up #}{% media_container prelude %}
-{% include 'messages-transient-header.html' %}
-<script type="text/javascript"> {# raw js code - use {% insert prelude_js %} ... {% endinsert %} #} {% container prelude_js %}</script>
-<script src="{{ STATIC_URL }}js/jquery.dataTables.min.js"></script>
-<script src="{{ STATIC_URL }}js/bootstrap.datatables.js"></script>
-<script src="{{ STATIC_URL }}js/myslice.js"></script>
-<script src="{{ STATIC_URL }}js/myslice-ui.js"></script>
-<style type="text/css">{# In case we need to add raw css code #}{% container prelude_css %}</style>
-{{ header_prelude }}
-{% block head %} {% endblock head %}
-{# let's add these ones no matter what #}
-{% insert_str prelude "js/jquery.min.js" %}
-{% insert_str prelude "js/angular/angular.min.js" %}
-{% insert_str prelude "js/jquery.html5storage.min.js" %}
-{% insert_str prelude "js/messages-runtime.js" %}
-{% insert_str prelude "js/class.js" %}
-{% insert_str prelude "js/plugin-helper.js" %}
-{% insert_str prelude "js/mustache.js" %}
-{% insert_str prelude "js/hashtable.js" %}
-{% insert_str prelude "js/plugin.js" %}
-{% insert_str prelude "js/manifold.js" %}
-{% insert_str prelude "css/manifold.css" %}
-{% insert_str prelude "css/plugin.css" %}
-{% insert_str prelude "js/bootstrap.js" %}
-{% insert_str prelude "css/bootstrap.css" %}
-{% insert_str prelude "js/bootstrap-datepicker.js" %}
-{% insert_str prelude "css/datepicker.css" %}
-{% insert_str prelude "js/bootstrap-slider.js" %}
-{% insert_str prelude "css/slider.css" %}
-{% insert_str prelude "css/topmenu.css" %}
-{% insert_str prelude "js/logout.js" %}
-<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/{{ theme }}.css">
-</head>
-<body ng-app="ManifoldApp">
-{% block container %}
-       {% block topmenu %}
-       {% include theme|add:"__widget-topmenu.html" %}
-       {% endblock topmenu %}
-       {% include 'messages-transient.html' %}
-       {% block base_content %}
-       {% endblock %}
-{% endblock container %}
-</body>
-</html>
diff --git a/portal/templates/fed4fire/fed4fire_footer.html b/portal/templates/fed4fire/fed4fire_footer.html
new file mode 100644 (file)
index 0000000..e69de29
index 09e4731..4cca20b 100644 (file)
@@ -6,8 +6,56 @@
 {% widget '_widget-news.html' %}
 </div> -->
 {% if username %}
+<!-- Modal- No credentials -->
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">No credentials are delegated to the portal</h4>
+                    </div>
+                    <div class="modal-body" style="text-align:justify;">
+                                       <p>You are getting this message for any of the following reasons:</p>
+                                       <ul>
+                                               <li>If your account is still pending for validation</li>
+                                               <li>If you press the "Clear Credentials" button</li>
+                                               <li>If you "Generate a new key pair"</li>
+                                               <li>If a new slice is added to your account</li>
+                                       </ul>
+                                       <p>Unless your account has not yet been validated, it is sufficient to refresh the page or go back to the home page. 
+                                               The portal will then regenerate your credentials. In some cases it may take more time than usual. If nothing works, 
+                                               then please logout and login back into to the portal.
+                                       </p>
+                                       <h3>Manual delegation of credentials</h3>
+                                               <p>
+                                                       You have selected upon sign-up to upload your public key. As you have uploaded your own public key, 
+                                                       the portal can no longer generate your credentials automatically. In order to have your credentials 
+                                                       delegated to the portal, please follow these instructions:
+                                               </p>
+                                               <ul>
+                                                       <li>Your account must first be validated by the manager of your organization.</li>
+                                                       <li>In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to
+                                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a></li>
+                                               </ul>
+                                       </p>
+                                       <h3>Contact support</h3>
+                                       <p>If you don't have the above mentioned cases and still have this message, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
 <div class="container dashboard">
        <div class="row">
+       {%if 'no_creds'  in user_cred %}
+       <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
+       {%endif%}
+       {%if 'creds_expired'  in user_cred %}
+       <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
+    {%endif%}
+               {%if 'is_pi'  in pi %}
                <div class="col-md-3">
                        <h3>
                                EXPERIMENT
                                <a href="#"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a>
                        </div>
                        <div>
-                               <button id="slicerequestbtn" type="button" style="width: 150px;" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                               <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Slice</button>
+                       </div>
+                       <div>
+                               <p><strong>Your slices </strong>
+                                       <span title="A slice is a set of testbed resources on which you can conduct an experiment. 
+                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'. 
+                                       However, on the OneLab portal, you will only see slices that you have created through OneLab. If you have created slices elsewhere, 
+                                       such as on the PlanetLab Europe portal, those slices will not appear here."
+                                       class="glyphicon glyphicon-info-sign">
+                               </span>
+
+                               </p>
                        </div>
                        <div>   
                                <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
                        </div>
-                        <div>
-                <h3 title="Some tools do their own slice creation and management.">Experiment now</h3>
-                        </div>
-                       <div>
-                                       <a class="btn btn-primary" style="width: 150px;" 
+                       <h3 title="Some tools do their own slice creation and management.">Experiment now</h3>
+                       <a class="btn btn-primary" style="width: 150px;" 
                     href='http://jfed.iminds.be/releases/r1389/webstart/experimenter/jfed-experimenter.jnlp'
                                        title="Click here to start your experiment with jFed" 
                                        onclick="return  launchApplication('http://jfed.iminds.be/releases/r1389/webstart/experimenter/jfed-experimenter.jnlp');">
                     <span class="glyphicon glyphicon-cloud"></span> jFed</a>
-                       </div>
                </div>
                <div class="col-md-3">
                        <h3>MANAGEMENT</h3>
                                SUPPORT
                        </h3>
                        <div>
-                               <a href="http://doc.fed4fire.eu/support.html"><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></a>
+                               <a href="/portal/support"><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></a>
                        </div>
                        <div>
-                               <button id="ticketbtn" type="button" style="width: 150px;" class="btn btn-default"><span class="glyphicon glyphicon-envelope"></span> Contact</button>
+                               <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-envelope"></span> Contact</button>
                        </div>
                        <p></p>
                        <div>
                        <button id="statbtn" type="button" style="width: 150px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' status</button>
                        </div>
+                       <div>
+                       <button id="repbtn" type="button" style="width: 170px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' reputation</button>
+                       </div>
                </div>
                
                <div class="col-md-3">
                                <a href="/portal/account/"><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></a>
                        </div>
                        <div>
-                               <button id="logoutbtn" type="button" style="width: 150px;" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
+                               <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
+                       </div>
+                       <div>
+                               {% if person.last_name %}
+                                       {{person.first_name}} {{person.last_name}}<br />
+                               {% endif %}
+                       <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
+               </div>
+               </div>
+       </div>
+       {%else%}
+       <div class="row">
+               <div class="col-md-4">
+                       <h3>
+                               EXPERIMENT
+                       </h3>
+                       <div>
+                               <a href="#"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
+                       </div>
+                       <div>
+                               <p><strong>Your slices </strong>
+                               <span title="A slice is a set of testbed resources on which you can conduct an experiment. 
+                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'. 
+                                       However, on the OneLab portal, you will only see slices that you have created through OneLab. If you have created slices elsewhere, 
+                                       such as on the PlanetLab Europe portal, those slices will not appear here."
+                                       class="glyphicon glyphicon-info-sign">
+                               </span>
+                               </p>
+                       </div>
+                       <div>   
+                               <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+                       </div>
+                       {% if pending_slices %}
+                       <p><strong>Pending slices</strong>
+                       <span title="Slices that you have requested and are pending for validation by the contact person of your organization."
+                               class="glyphicon glyphicon-info-sign">
+                       <ul>
+                       {% for slices in pending_slices %}
+                       <li>{{slices}}</li>
+                       {% endfor %}
+                       </ul>
+                       </span>
+                       </p>
+                       {%endif%}
+                       <h3 title="Some tools do their own slice creation and management.">Experiment now</h3>
+                       <a class="btn btn-primary" style="width: 150px;" 
+                    href='http://jfed.iminds.be/releases/r1389/webstart/experimenter/jfed-experimenter.jnlp'
+                                       title="Click here to start your experiment with jFed" 
+                                       onclick="return  launchApplication('http://jfed.iminds.be/releases/r1389/webstart/experimenter/jfed-experimenter.jnlp');">
+                    <span class="glyphicon glyphicon-cloud"></span> jFed</a>   
+               </div>
+               <div class="col-md-4">
+                       <h3>
+                               SUPPORT
+                       </h3>
+                       <div>
+                               <a href="/portal/support"><img src="{{ STATIC_URL }}img/icon_support.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-envelope"></span> Contact</button>
+                       </div>
+                       <p></p>
+                       <div>
+                       <button id="statbtn" type="button" style="width: 150px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' status</button>
+                       </div>
+                       <div>
+                       <button id="repbtn" type="button" style="width: 170px;" class="btn btn-default"><span class="glyphicon glyphicon-stats"></span>Testbeds' reputation</button>
+                       </div>
+               </div>
+               
+               <div class="col-md-4">
+                       <h3>
+                               ACCOUNT
+                       </h3>
+                       <div>
+                               <a href="/portal/account/"><img src="{{ STATIC_URL }}img/icon_user_color.png" alt="" /></a>
+                       </div>
+                       <div>
+                               <button id="logoutbtn" type="button" class="btn btn-default" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</button>
                        </div>
                        <div>
                                {% if person.last_name %}
                                        {{person.first_name}} {{person.last_name}}<br />
                                {% endif %}
-                       <span class="label">Email:</span> <a href='/portal/account/'>{{person.email}}</a>
+                       <span class="label">Username:</span> <a href='/portal/account/' title="Click here to see and edit your account details.">{{person.email}}</a>
                </div>
                </div>
        </div>
+       {%endif%}
+
 </div>
 {% else %}
 <div class="container-fluid home">
                        $('div#'+$(this).data('panel')).show();
                });
                $('button#validaterequestbtn').click(function() {
-                       window.location="/portal/validate/";
+                       window.location="/portal/institution#requests";
                });
                $('button#ticketbtn').click(function() {
                        window.location="/portal/contact/";
                $('button#statbtn').click(function() {
                window.location="https://flsmonitor.fed4fire.eu";
                });
+                $('button#repbtn').click(function() {
+               window.location="/portal/reputation";
+                });
                $('button#signupbtn').click(function() {
                        window.location="/portal/register/";
                });
                $('button#slicerequestbtn').click(function() {
                        window.location="/portal/slice_request/";
                });
-/*-------
-List of slices has been moved in 
-portal/templates/base.html
-This should go into session
---------*/
+
+        /*
+            Launch queries to get the resources and leases in Manifold Cache
+        */
+            
+        $.post("/rest/resource/", function( data ) {
+        });
+        $.post("/rest/lease/", function( data ) {
+        });
+        
+        /*-------
+        List of slices has been moved in 
+        portal/templates/base.html
+        This is now in localStorage 
+        --------*/
+        // myslice.user is in LocalStorage
+        if(myslice.user.slices.length>0){
+            $.each( myslice.user.slices, function(i, val) {
+                /*
+                Launch a Query for each slice to get resources and leases in Manifold Cache
+                */
+                $.post("/rest/slice/", { 'filters': { 'slice_hrn' : val } }, function(data) {
+                });
+            });
+        }
 });
 </script>
+
+<!--for jfed tool-->
 <script type="text/javascript" src="{{STATIC_URL}}js/fed4fire_dtjava_orig.js"></script>
 <script>
        function launchApplication(jnlpfile) {
@@ -146,4 +312,7 @@ This should go into session
         return false;
      }
 </script>
+{# widget "_widget-monitor.html" #}
+{# widget "_widget-stats-top-slices.html" #}
+
 {% endblock %}
diff --git a/portal/templates/fed4fire/fed4fire_institution.html b/portal/templates/fed4fire/fed4fire_institution.html
new file mode 100644 (file)
index 0000000..bd361de
--- /dev/null
@@ -0,0 +1,185 @@
+{% extends "layout_wide.html" %}
+
+{% block head %} 
+<script type="text/javascript" src="{{STATIC_URL}}/js/institution.js"></script>
+{% endblock head %}
+
+{% block content %}
+<div class="container">
+       <div class="row">
+               <div class="col-md-12">
+                        <div class="breadcrumbs">
+                                Management &nbsp;>&nbsp; Institution: <span id="authority_name"></span>
+                        </div>
+               </div>
+       </div>
+</div>
+<div class="container">
+       <div class="row">
+               <div class="col-md-12">
+                       <ul class="nav nav-tabs nav-section">
+                               <li class="active"><a href="#about">About</a></li>
+                               <li><a href="#users">Users</a></li>
+                               <li><a href="#slices">Slices</a></li>
+                               <li><a href="#requests">Requests</a></li>
+                       </ul>
+           </div>
+       </div>
+</div>
+<div class="container tab-content">
+       <div class="tab-pane active row" id="about">
+       </div>
+       
+       <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
+               <div class="col-md-12 el">
+                       <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+                               <div id="user-tab-loaded" style="display:none;">
+                               <table id="user-tab" class="table">
+                                       <tr>
+                                       <th>+/-</th>
+                                       <th>Email</th>
+                                       <th>User hrn</th>
+                            <!--
+                                       <th>First name</th>
+                                       <th>Last name</th>
+                                       <th>Enabled</th>
+                            -->
+                                       </tr>
+                               </table>
+                               
+                       </div>
+                       {%if 'is_pi'  in pi %}  
+                       <div>
+                               <button id="deleteusers" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete selected users</button>
+                       </div>
+                       {% endif %}
+               </div>
+       </div>
+
+       <div class="tab-pane row" id="slices">
+               <div class="col-md-12 el">
+           <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
+           <div id="slice-tab-loaded" style="display:none;">
+               <table id="slice-tab" class="table">
+                   <tr>
+                       <th>+/-</th>
+                       <th>Slice hrn</th>
+                       <th>Users</th>
+                       <th>Url</th>
+                       <!-- <th>nodes</th> -->
+                       <th>Creation</th>
+                   </tr>
+               </table>                        
+           </div>
+       {% if 'is_pi'  in pi %}
+        <div>
+               {% if 'is_pi'  in pi %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+                       {% else %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                       {% endif %}
+            <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
+            <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
+        </div>
+               {% endif %} 
+          </div>
+       </div>
+       <div class="tab-pane row" id="requests">
+       </div>
+</div>
+<script>
+$(document).ready(function() {
+    {% if person %}
+    {% if user_details.parent_authority %}
+
+        $.post("/rest/slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+            var list_slices = [];
+            var table_slices = [];
+            /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
+            $.each( data, function( key, val ) {
+                list_slices.push( "<li><a href=\"portal/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></li>" );
+                if(val.nodes=="undefined" || val.nodes==null){
+                    nodes_length=0;
+                }else{
+                    nodes_length=val.nodes.length;
+                }
+                console.log(val);
+                if(val.users=="undefined" || val.users==null){
+                    users_length=0;
+                }else{
+                    users_length=val.users.length;
+                }
+
+                if(val.url=="undefined" || val.url==null){
+                    slice_url="";
+                }else{
+                    slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
+                }
+                
+                slice_row = "<tr id='"+val.slice_hrn+"'>";
+                slice_row += "<td><input type='checkbox' class='slice' id='"+val.slice_hrn+"'></td>";
+                slice_row += "<td><a href=\"/slice/"+val.slice_hrn+"\">" + val.slice_hrn + "</a></td>";
+                slice_row += "<td>"+users_length+"</td>";
+                slice_row += "<td>"+slice_url+"</td>";
+                //slice_row += "<td>"+nodes_length+"</td>";
+                slice_row += "<td>"+val.slice_date_created+"</td>";
+                slice_row += "</tr>";
+                table_slices.push(slice_row);
+                
+            });
+           
+            /* $("div#slice-list").html($( "<ul/>", { html: list_slices.join( "" ) })); */
+            $("table#slice-tab tr:last").after(table_slices.join( "" ));
+            $("div#slice-tab-loaded").css("display","block");
+            $("div#slice-tab-loading").css("display","none");
+        });
+               
+               
+        $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+            var list_users = [];
+            var table_users = [];
+                   /* Available fields
+                   user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
+                   user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
+                   */
+            $.each( data, function( key, val ) {
+                list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
+                user_row = "<tr id='"+val.user_hrn+"'>";
+                user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
+                user_row += "<td>"+val.user_email+"</td>";
+                user_row += "<td>"+val.user_hrn+"</td>";
+                /*
+                user_row += "<td>"+val.user_first_name+"</td>";
+                user_row += "<td>"+val.user_last_name+"</td>";
+                           user_row += "<td>"+val.user_enabled+"</td>";
+                */
+                user_row += "</tr>";
+                table_users.push(user_row);
+            });
+            $("table#user-tab tr:last").after(table_users.join( "" ));
+            $("div#user-tab-loaded").css("display","block");
+            $("div#user-tab-loading").css("display","none");
+        });
+
+    {% endif %}
+    {% endif %}
+
+}); // End document.ready
+
+$(document).ready(function() {
+       $('.nav-tabs a').click(function (e) {
+               e.preventDefault();
+               $(this).tab('show');
+       var id = $(this).attr('href').substr(1);
+       if ((id == 'requests') || (id == 'about'))
+               $("#" + id).load('/management/' + id);
+       });
+       var hash = window.location.hash;
+       if (hash) {
+               $('.nav-tabs a[href='+hash+']').click();
+       } else {
+               $('.nav-tabs a[href=#about]').click();
+       }
+});
+</script>
+{% endblock %}
diff --git a/portal/templates/fed4fire/fed4fire_management-tab-about.html b/portal/templates/fed4fire/fed4fire_management-tab-about.html
new file mode 100644 (file)
index 0000000..bc768a6
--- /dev/null
@@ -0,0 +1,71 @@
+{% load portal_filters %}
+<div class="col-md-6">
+       <div>
+               <img src="{{ STATIC_URL|add:'img/institutions/'|add:authority.authority_hrn|add:'.gif'|file_exists }}" alt="{{authority.name}}">
+       </div>
+       <br />
+    {% if authority.name and authority.url %}
+       <h3><a href="{{authority.url}}">{{authority.name}}</a></h3>
+    {% elif authority.name %}
+       <h3>{{authority.name}}</h3>
+    {% endif %}
+       <p>
+    {% if authority.address %}
+               {{authority.address}} <br />
+    {% endif %}
+    {% if authority.postcode %}
+               {{authority.postcode}} 
+    {% endif %}
+    {% if authority.address %}
+        {{authority.city}} <br />
+    {% endif %}
+    {% if authority.address %}
+               {{authority.country}}
+    {% endif %}
+       </p>
+       <br />
+
+    {% if authority.address %}
+       <h4>Onelab membership</h4> 
+       <p>
+               {{ authority.onelab_membership }}
+       </p>
+    {% endif %}
+</div>
+<div class="col-md-6">
+    {% if authority.legal %}
+       <h4>Legal Contact:</h4>
+       <p>
+       {% for c in authority_contacts.legal %}
+                {{ c }} <br />
+       {% endfor %}
+       </p>
+       <br />
+    {% endif %}
+    {% if authority.scientific %}
+       <h4>Scientific Contact:</h4>
+       <p>
+       {% for c in authority_contacts.scientific %}
+               {{ c }} <br />
+       {% endfor %}
+       </p>
+       <br />
+    {% endif %}
+    {% if authority.technical %}
+       <h4>Technical Contact:</h4>
+       <p>
+       {% for c in authority_contacts.technical %}
+               {{ c }} <br />
+       {% endfor %}
+       </p>
+    {% endif %}
+</div>
+<script>$(document).ready(function() {
+{% if authority.name %}
+    auth_name = "{{authority.name}}";
+{% else %}
+    auth_name = "{{authority.authority_hrn}}";
+{% endif %}
+    $('#authority_name').text(auth_name);
+});
+</script>
diff --git a/portal/templates/fed4fire/fed4fire_management-tab-requests.html b/portal/templates/fed4fire/fed4fire_management-tab-requests.html
new file mode 100644 (file)
index 0000000..e255779
--- /dev/null
@@ -0,0 +1,226 @@
+<script type="text/javascript">
+       $(document).ready(function() {
+               $("li#nav-request").addClass("active");
+       });
+       function on_click_event() {
+               var ids = []; 
+               $('.portal__validate__checkbox').each(function(i, el) {
+                       if ($(el).prop('checked')) {
+                               // portal__validate__checkbox__slice__2
+                               var id_array = $(el).attr('id').split('__');
+                               // push(slice__2)
+                               ids.push(id_array[3] + '__' + id_array[4]);
+                       }
+               });
+               if (ids.length > 0) {
+                       var id_str = ids.join('/');
+                       // XXX spinner
+                       $.getJSON('/portal/validate_action/' + id_str,
+                               function(status) {
+                                       $.each(status, function(request_type__id, request_status) {
+                                               // request_status: NAME -> dict (status, description)
+                                               var status_str = '';
+                                               $.each(request_status, function(name, result) {
+                                                       if (status_str != '')
+                                                               status_str += ' -- ';
+
+                                                       if (result.status) {
+                                                               status_str += '<font color="green">OK</font>';
+                                                               $('#portal__validate__checkbox__' + request_type__id).hide();
+                                                       } else {
+                                                               status_str += '<font color="red">ERROR: ' + result.description + '</font>';
+                                                       }
+                                               });
+                                               $('#portal__status__' + request_type__id).html(status_str);
+
+
+                                       });
+                               }
+                       );
+               }
+       }
+</script>
+
+<div class="col-md-12">
+       <h2>From your authorities</h2>
+</div>
+{% if my_authorities %}
+       
+       {% for authority, requests in my_authorities.items %}
+       
+       <div class="col-md-12">
+               <h2>{{authority}}</h2>
+       </div>
+       
+    <table class="table">
+      <th>
+        <td>Type</td>
+        <td>Id</td>
+        <td>Details</td>
+        <td>Timestamp</td>
+        <td>Status</td>
+      </th>
+    {% for request in requests %}
+
+         <tr>
+               <td>
+               {% if request.allowed == 'allowed' %}
+               <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+               {% else %}
+                       {% if request.allowed == 'expired' %}
+                               expired
+                       {% else %} {# denied #}
+                               denied
+                       {% endif %}
+               {% endif %}
+               </td>
+               <td>{{ request.type }}</td>
+               <td>{{ request.id }}</td>
+               <td>
+        {% if request.type == 'user' %}
+            <b>{{request.first_name}} {{request.last_name}}</b> <a href="mailto:{{request.email}}">{{request.email}}</a>
+        {% else %}
+            {% if request.type == 'slice' %}
+            <b>{{request.slice_name}}</b> -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+            {% else %} {# authority #}
+            <b>{{request.site_name}}</b> ({{request.site_authority}}) -- {{request.address_city}}, {{request.address_country}}
+            {% endif %}
+        {% endif %}
+               </td>
+               <td>{{ request.timestamp }}</td>
+               
+               <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+
+    <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+         </tr>
+
+    {% endfor %}
+       </table>
+       {% endfor %}
+
+{% else %}
+       <div class="col-md-12">
+               <i>There is no pending request waiting for validation.</i>
+       </div>
+{% endif %}
+<div>nnllknjkn<br /><br /></div>
+<div class="col-md-12">
+       <h2>From your sub-authorities</h2>
+</div>
+{% if sub_authorities %}
+       
+       {% for authority, requests in sub_authorities.items %}
+       <div class="col-md-12">
+               <h2>{{authority}}</h2>
+       </div>
+       
+       <table class="table">
+             <th>
+               <td>Type</td>
+               <td>Id</td>
+               <td>Details</td>
+               <td>Timestamp</td>
+               <td>Status</td>
+             </th>
+           {% for request in requests %}
+                 <tr>
+                       <td>
+                       {% if request.allowed == 'allowed' %}
+                       <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+                       {% else %}
+                               {% if request.allowed == 'expired' %}
+                                       expired
+                               {% else %} {# denied #}
+                                       denied
+                               {% endif %}
+                       {% endif %}
+                       </td>
+                       <td>{{ request.type }}</td>
+                       <td>{{ request.id }}</td>
+                       <td>
+               {% if request.type == 'user' %}
+               Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
+               {% else %}
+                   {% if request.type == 'slice' %}
+               Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+                   {% else %} {# authority #}
+               Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+                   {% endif %}
+               {% endif %}
+                       </td>
+                       <td>{{ request.timestamp }}</td>
+                       
+                       <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+       
+           <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+                 </tr>
+           {% endfor %}
+       </table>
+       {% endfor %}
+{% else %}
+<div class="col-md-12">
+       <i>There is no pending request waiting for validation.</i>
+</div>
+{% endif %}
+
+<div class="col-md-12">
+       <h2>From your authorities with delegation</h2>
+</div>
+
+{% if delegation_authorities %}
+       
+       {% for authority, requests in delegation_authorities.items %}
+       <div class="col-md-12">
+               <h3>{{authority}}</h3>
+       </div>
+       <table class="table">
+                     <th>
+                       <td>Type</td>
+                       <td>Id</td>
+                       <td>Details</td>
+                       <td>Timestamp</td>
+                       <td>Status</td>
+                     </th>
+                   {% for request in requests %}
+                         <tr>
+                               <td>
+                               {% if request.allowed == 'allowed' %}
+                               <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+                               {% else %}
+                                       {% if request.allowed == 'expired' %}
+                                               expired
+                                       {% else %} {# denied #}
+                                               denied
+                                       {% endif %}
+                               {% endif %}
+                               </td>
+                               <td>{{ request.type }}</td>
+                               <td>{{ request.id }}</td>
+                               <td>
+                       {% if request.type == 'user' %}
+                       Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
+                       {% else %}
+                           {% if request.type == 'slice' %}
+                       Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+                           {% else %} {# authority #}
+                       Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+                           {% endif %}
+                      {% endif %}
+                               </td>
+                               <td>{{ request.timestamp }}</td>
+                               
+                               <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+               
+                   <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+                         </tr>
+                   {% endfor %}
+       </table>
+               {% endfor %}
+{% else %}
+<div class="col-md-12">
+       <i>There is no pending request waiting for validation.</i>
+</div>
+{% endif %}
+<div class="col-md-12">
+       <button class="btn btn-onelab" type="button" id="portal__validate" onclick="on_click_event();"><span class="glyphicon glyphicon-ok"></span> Validate</button>
+</div>
diff --git a/portal/templates/fed4fire/fed4fire_slice-resource-view.html b/portal/templates/fed4fire/fed4fire_slice-resource-view.html
new file mode 100644 (file)
index 0000000..3fefedf
--- /dev/null
@@ -0,0 +1,121 @@
+{% extends "layout_wide.html" %}
+{% load portal_filters %}
+
+{% block head %}
+<!-- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC1RUj824JAiHRVqgc2CSIg4CpKHhh84Lw&sensor=false"></script> -->
+<script src="{{ STATIC_URL }}js/onelab_slice-resource-view.js"></script>
+<script>
+       //myslice.slice = "{{ slice }}";
+
+$(document).ready(function() {
+            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+        // find the plugin object inside the tab content referenced by the current tabs
+        $('.plugin', $($(e.target).attr('href'))).trigger('shown.bs.tab');
+        $('.plugin', $($(e.target).attr('href'))).trigger('show');
+            });
+});
+</script>
+{% endblock %}
+
+{% block content %}
+{% widget '_widget-slice-sections.html' %}
+<div class="container-fluid container-resource">
+       <div class="row">
+       <div class="col-md-2">
+               <!-- <div id="select-platform" class="list-group"></div> -->
+               {{filter_testbeds}}
+       </div>
+       <div class="col-md-10" style="height:100%;">
+               <div class="row">
+                       {% if msg %}
+                       <div class="col-md-12"><p class="alert-success">{{ msg }}</p></div>
+                       {% endif %}
+               </div>
+       
+               <div class="row">
+                       <div class="col-md-6">
+                               {{ filter_status }}
+                       </div>
+                       <div class="col-md-1">
+                               {{ apply }}
+                       </div>
+               </div>
+               <!--
+               <div class="list-group-item list-resources">
+                       <span class="list-group-item-heading" style="padding-left: 0;">Resource status:</span>
+                       <a class="list-group-item active" data-panel="resources" href="#" style='display: inline-block !important;'>All</a>
+                       <a class="list-group-item" data-panel="reserved" href="#" style='display: inline-block !important;'>Reserved</a>
+                       <a class="list-group-item" data-panel="pending" href="#" style='display: inline-block !important;'>Pending <span class="badge" id="badge-pending" data-number="0"></span></a>
+               </div>
+               -->
+
+               <div class="row">
+                       <div class="col-md-12">
+                       <ul class="nav nav-tabs">
+                         <li class="active"><a href="#resourcelist" role="tab" data-toggle="tab">Table</a></li>
+                         <li> <a href="#resourcemap" role="tab" data-toggle="tab">Map</a></li>
+                         <li> <a href="#resourcescheduler" role="tab" data-toggle="tab">Scheduler</a></li>
+                       </ul>
+                       </div>
+               </div>
+               
+               <!-- Modal - columns selector -->
+               <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+                       <div class="modal-dialog">
+                       <div class="modal-content">
+                               <div class="modal-header">
+                                       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                                               <h4 class="modal-title" id="myModalLabel">Columns selector</h4>
+                               </div>
+                               <div class="modal-body">
+                                       {{columns_editor}}
+                               </div>
+                               <div class="modal-footer">
+                                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                               </div>
+                       </div>
+                       </div>
+               </div>
+               
+               
+               <div class="row">
+                       <div class="col-md-12">
+                       <div class="tab-content" style="height:100%;">
+                               <div class="tab-pane active" id="resourcelist">
+                                        <!-- Button trigger modal - columns selector -->
+                                       <button class="btn btn-default btn-sm" style="float:right;" data-toggle="modal" data-target="#myModal">...</button>
+                       {{list_resources}}
+                                       <!-- <table cellpadding="0" cellspacing="0" border="0" class="table" id="objectList"></table> -->
+                               </div>
+                               <div class="tab-pane" id="resourcemap">
+                       {{map_resources}}
+                               </div>
+                               <div class="tab-pane" id="resourcescheduler">
+                       {{scheduler}}
+                               </div>
+       
+                               <!--
+                               <div id="reserved" class="tab-pane" style="height:370px;display:none;">
+                       <table width="80%">
+                           <tr><th width="50%" style="text-align:center;">resources</th><th width="50%" style="text-align:center;">leases</th></tr>
+                           <tr>
+                               <td style="text-align:center">{{list_reserved_resources}}</td>
+                               <td style="text-align:center">{{list_reserved_leases}}</td>
+                           </tr>
+                       </table>
+                               </div>
+                               <div id="pending" class="tab-pane" style="height:370px;display:none;">
+                       {{pending_resources}}
+                               </div>
+                               <div id="sla_dialog" class="tab-pane" style="height:370px;display:none;">
+                       {{sla_dialog}}
+                               </div>
+       -->
+       
+                       </div>
+               </div>
+       </div>
+       </div>
+       </div>
+</div>
+{% endblock %}
diff --git a/portal/templates/fed4fire/fed4fire_slice-view.html b/portal/templates/fed4fire/fed4fire_slice-view.html
new file mode 100644 (file)
index 0000000..c2d52c3
--- /dev/null
@@ -0,0 +1,18 @@
+{% extends "layout_wide.html" %}
+
+{% block head %}
+{% endblock %}
+
+{% block content %}
+{% include theme|add:"_widget-slice-sections.html" %}
+         
+<div class="container-fluid tab-content container-slice">
+  <div class="tab-pane active row" id="info">...</div>
+  <div class="tab-pane row" id="testbeds">...</div>
+  <div class="tab-pane row" id="resources">...</div>
+  <div class="tab-pane row" id="users">...</div>
+  <!-- <div class="tab-pane row" id="statistics">...</div> -->
+  <!-- <div class="tab-pane row" id="measurements">...</div> -->
+  <div class="tab-pane row" id="experiment">...</div>
+</div>         
+{% endblock %}
diff --git a/portal/templates/fed4fire/fed4fire_slicerequest_view.html b/portal/templates/fed4fire/fed4fire_slicerequest_view.html
new file mode 100644 (file)
index 0000000..211f35d
--- /dev/null
@@ -0,0 +1,108 @@
+{% extends "layout.html" %}
+{% load i18n %}
+
+{% block content %}
+       <div class="row">
+               <div class="col-md-12">
+                        <div class="breadcrumbs">
+                                Experiment &nbsp;>&nbsp; Request a new Slice
+                        </div>
+               </div>
+       </div>
+
+       {% if errors %}
+       <div class="row">
+               <div class="col-md-12">
+               <ul class="error">
+                 {% for error in errors %}
+                 <li>{{ error }}</li>
+                 {% endfor %}
+               </ul>
+               </div>
+       </div>
+       {% endif %}
+       
+       <div class="row">
+               <div class="col-md-8 el">
+                       <form role="form" method="post">
+                       {% csrf_token %}
+                         <div class="form-group" style="display:none">
+                           <input type="email" class="form-control" id="email" style="width:300px" value="{{ email }}" readonly="readonly">
+                         </div>
+                         <div class="form-group">
+                           <input type="text" class="form-control" name="slice_name" id="slice_name" style="width:300px" placeholder="Slice name" value="{{slice_name}}" 
+                               title="Please enter a name for your slice"required="required">
+                         </div>
+                         <div class="form-group">
+                               {%if 'is_pi'  in pi %}
+                               <input type="text" class="form-control" id="authority_hrn" name="org_name" style="width:300px" placeholder="Organization" 
+                               title="An authority responsible for vetting your slice" required="required">
+                               {%else%}
+                           <input type="text" class="form-control" id="authority_hrn" name="org_name" placeholder="Organization" style="width:300px;" 
+                               title="An authority responsible for vetting your slice" required="required" readonly>
+                               {%endif%}
+                         </div>
+                         <div class="form-group">
+                           <input type="text" class="form-control" name="url" id="url" style="width:300px" placeholder="Experiment URL (if one exists)"
+                               title="Please provide the url of your experiment if you have one." value="{{url}}">
+                         </div>
+                         <div class="form-group">
+                               <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Experiment purpose" style="width:300px" 
+                               title="Purpose of your experiment (informative)" required="required">{{ purpose }}</textarea>
+                         </div>
+                         {%if 'is_pi'  in pi %}        
+                         <button type="submit" id=submit_pi class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+                         {%else%}
+                         <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                         {%endif%}     
+                       </form>
+       
+               </div>
+       </div>
+               
+<script>
+jQuery(document).ready(function(){
+       
+       /*$("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) {
+               var jsonData = JSON.parse(data);
+        $(this).attr("value", jsonData[0]['parent_authority']);
+    });*/
+       $("#authority_hrn").val("{{authority_name}}");
+       var availableTags = [
+    {% if authorities %}
+        {% for authority in authorities %}
+            {% if authority.name %}
+                {value:"{{ authority.name }}",label:"{{authority.name}}"},
+                       // to show only full name
+           // {% else %}
+           //     {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
+            {% endif %}
+        {% endfor %}    
+    {% else %}
+        {value:"",label:"No authority found !!!"}
+    {% endif %}
+    ];
+       // sorting the list
+       availableTags.sort(function(a,b){
+               var nameA=a.value.toLowerCase(), nameB=b.value.toLowerCase();
+               if (nameA < nameB) {
+               return -1;
+               }
+               if (nameA > nameB) {
+               return 1;
+               }
+       return 0;
+       }); 
+    $( "#authority_hrn" ).autocomplete({
+      source: availableTags,
+      minLength: 0,
+      select: function( event, ui ) {console.log(jQuery(this));}
+    });
+
+       $("#submit_pi").click(function() {
+               localStorage.clear();
+       });
+});
+</script>
+{% endblock %}
+
index 230a14d..40761b5 100644 (file)
@@ -1,29 +1,37 @@
+<div class="container">
+       <div class="row">
+               <div class="col-md-12">
+                        <div class="breadcrumbs">
+                                Experiment &nbsp;>&nbsp; Slice: {{ slice }}
+                        </div>
+               </div>
+       </div>
+</div>
+<div class="container-fluid container-slice">
+<div class="row">
+               <div class="col-md-12">
 {% if section == "resources" %}
 <ul class="nav nav-tabs nav-section">
-       <li><a href="/slice/{{ slice }}#info"><img src="{{ STATIC_URL }}icons/slices-xs.png" alt="About MySlice" /> {{ slice }}</a></li>
-<!--   <li><a href="/slice/{{ slice }}#testbeds">Testbeds</a></li> -->
+       
+       <!-- <li><a href="/slice/{{ slice }}#testbeds">Testbeds</a></li> -->
        <li class="active"><a class="link" href="/resources/{{ slice }}">Resources</a></li>
        <li><a href="/slice/{{ slice }}#users">Users</a></li>
-       <li class="sla"><a href="/slice/{{ slice }}#sla">SLA</a></li>
-
-<!--   <li><a href="/slice/{{ slice }}#experiment">Statistics</a></li> 
-       <li><a href="/slice/{{ slice }}#measurements">Measurements</a></li>
-       <li><a href="/slice/{{ slice }}#experiment" data-toggle="tab">Experiment</a></li> -->
-
+       <li><a href="/slice/{{ slice }}#info">Information</a></li>
+       <!-- <li><a href="/slice/{{ slice }}#experiment">Statistics</a></li> -->
+       <!-- <li><a href="/slice/{{ slice }}#experiment">Measurements</a></li> -->
+       <li><a href="/slice/{{ slice }}#experiment">Tools</a></li>
 </ul>
 {% else %}
 <ul class="nav nav-tabs nav-section">
-       <li class="active"><a href="#info"><img src="{{ STATIC_URL }}icons/slices-xs.png" alt="About MySlice" /> {{ slice }}</a></li>
-       <!--<li class="testbeds"><a href="#testbeds">Testbeds</a></li> -->
+       <!-- <li class="testbeds"><a href="#testbeds">Testbeds</a></li> -->
        <li><a class="link" href="/resources/{{ slice }}">Resources</a></li>
        <li class="users"><a href="#users">Users</a></li>
-
-       <!-- <li class="statistics"><a href="#experiment">Statistics</a></li>
-       <li class="measurements"><a href="#experiment">Measurements</a></li>
-       <li class="experiment"><a href="#experiment" data-toggle="tab">Experiment</a></li> -->
-       <li class="sla"><a href="#sla">SLA</a></li>
-
+       <li class="active"><a href="#info">Information</a></li>
+       <!-- <li class="statistics"><a href="#experiment">Statistics</a></li> -->
+       <!-- <li class="measurements"><a href="#experiment">Measurements</a></li> -->
+       <li class="experiment"><a href="#experiment">Tools</a></li>
 </ul>
+
 <script>
 $(document).ready(function() {
        $('.nav-tabs a').click(function (e) {
@@ -33,7 +41,16 @@ $(document).ready(function() {
        var id = $(this).attr('href').substr(1);        
        $("#" + id).load('/' + id + '/{{ slice }}/');
        });
-       $('div#info').load('/info/{{ slice }}/');
+       
+       var hash = window.location.hash;
+       if (hash) {
+               $('.nav-tabs a[href='+hash+']').click();
+       } else {
+               $('div#info').load('/info/{{ slice }}/');
+       }
 });
 </script>
 {% endif %}
+</div>
+</div>
+</div>
\ No newline at end of file
index 66a5ce9..ddb4518 100644 (file)
@@ -20,7 +20,7 @@
                <ul>
                        <li id="nav-account"><a href="/portal/account/">{{ username }}</a></li>
                        <li>|</li>
-                       <li id="nav-institution" class=""><a href="/portal/institution">AUTHORITY</a></li>
+                       <!--<li id="nav-institution" class=""><a href="/portal/institution">AUTHORITY</a></li>-->
                        <li class="slices">
                                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                        SLICES <span class="caret"></span>
@@ -39,7 +39,6 @@
                                                </ul>
                                </div>
                                </li>
-                       <li id="nav-request"><a href="/portal/validate">REQUESTS</a></li>
                        <li id="nav-service"><a href="/portal/servicedirectory">SERVICES</a></li>
                        <li id="nav-support"><a href="http://doc.fed4fire.eu/support.html">SUPPORT</a></li>
                        <li>|</li>
diff --git a/portal/templates/fibre/fibre_slice-resource-view.html b/portal/templates/fibre/fibre_slice-resource-view.html
new file mode 100644 (file)
index 0000000..17e1383
--- /dev/null
@@ -0,0 +1,134 @@
+{% extends "layout_wide.html" %}
+{% load portal_filters %}
+
+{% block head %}
+<!-- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC1RUj824JAiHRVqgc2CSIg4CpKHhh84Lw&sensor=false"></script> -->
+<script src="{{ STATIC_URL }}js/onelab_slice-resource-view.js"></script>
+<script>
+       //myslice.slice = "{{ slice }}";
+
+$(document).ready(function() {
+            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+        // find the plugin object inside the tab content referenced by the current tabs
+        $('.plugin', $($(e.target).attr('href'))).trigger('shown.bs.tab');
+        $('.plugin', $($(e.target).attr('href'))).trigger('show');
+            });
+});
+</script>
+{% endblock %}
+
+{% block content %}
+{% widget '_widget-slice-sections.html' %}
+<div class="container-fluid container-resource">
+       <div class="row">
+       <div class="col-md-2">
+               <!-- <div id="select-platform" class="list-group"></div> -->
+               {{filter_testbeds}}
+       </div>
+       <div class="col-md-10" style="height:100%;">
+               <div class="row">
+                       {% if msg %}
+                       <div class="col-md-12"><p class="alert-success">{{ msg }}</p></div>
+                       {% endif %}
+               </div>
+       
+               <div class="row">
+                       <div class="col-md-6">
+                               {{ filter_status }}
+                       </div>
+                       <div class="col-md-1">
+                               {{ apply }}
+                       </div>
+               </div>
+               <!--
+               <div class="list-group-item list-resources">
+                       <span class="list-group-item-heading" style="padding-left: 0;">Resource status:</span>
+                       <a class="list-group-item active" data-panel="resources" href="#" style='display: inline-block !important;'>All</a>
+                       <a class="list-group-item" data-panel="reserved" href="#" style='display: inline-block !important;'>Reserved</a>
+                       <a class="list-group-item" data-panel="pending" href="#" style='display: inline-block !important;'>Pending <span class="badge" id="badge-pending" data-number="0"></span></a>
+               </div>
+               -->
+
+               <div class="row">
+                       <div class="col-md-12">
+                       <ul class="nav nav-tabs">
+                         <li class="active"><a href="#resourcelist" role="tab" data-toggle="tab">Table</a></li>
+                         <li> <a href="#resourcemap" role="tab" data-toggle="tab">Map</a></li>
+              <li> <a href="#resourceflowspace" role="tab" data-toggle="tab">Flowspace</a></li>
+                         <li> <a href="#resourcescheduler" role="tab" data-toggle="tab">Scheduler</a></li>
+                       </ul>
+                       </div>
+               </div>
+               
+               <!-- Modal - columns selector -->
+               <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+                       <div class="modal-dialog">
+                       <div class="modal-content">
+                               <div class="modal-header">
+                                       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                                               <h4 class="modal-title" id="myModalLabel">Columns selector</h4>
+                               </div>
+                               <div class="modal-body">
+                                       {{columns_editor}}
+                               </div>
+                               <div class="modal-footer">
+                                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                               </div>
+                       </div>
+                       </div>
+               </div>
+               
+               
+               <div class="row">
+                       <div class="col-md-12">
+                       <div class="tab-content" style="height:100%;">
+                               <div class="tab-pane active" id="resourcelist">
+                                        <!-- Button trigger modal - columns selector -->
+                                       <button class="btn btn-default btn-sm" style="float:right;" data-toggle="modal" data-target="#myModal">...</button>
+                       {{list_resources}}
+                                       <!-- <table cellpadding="0" cellspacing="0" border="0" class="table" id="objectList"></table> -->
+                               </div>
+                               <div class="tab-pane" id="resourcemap">
+                       {{map_resources}}
+                               </div>
+                <div class="tab-pane" id="resourceflowspace">
+
+                    <p>{{welcome}}</p>
+                    <p>{{flowspaces}}</p>
+                    <p>{{flowspaces_form}}</p>
+                    <p>{{oflowspaces_form}}</p>
+                    <p>{{topology}}</p>
+                    <p>{{resources}}</p>
+
+                    <p>{{below_table}}</p>
+
+                </div>
+                               <div class="tab-pane" id="resourcescheduler">
+                       {{scheduler}}
+                               </div>
+       
+                               <!--
+                               <div id="reserved" class="tab-pane" style="height:370px;display:none;">
+                       <table width="80%">
+                           <tr><th width="50%" style="text-align:center;">resources</th><th width="50%" style="text-align:center;">leases</th></tr>
+                           <tr>
+                               <td style="text-align:center">{{list_reserved_resources}}</td>
+                               <td style="text-align:center">{{list_reserved_leases}}</td>
+                           </tr>
+                       </table>
+                               </div>
+                               <div id="pending" class="tab-pane" style="height:370px;display:none;">
+                       {{pending_resources}}
+                               </div>
+                               <div id="sla_dialog" class="tab-pane" style="height:370px;display:none;">
+                       {{sla_dialog}}
+                               </div>
+       -->
+       
+                       </div>
+               </div>
+       </div>
+       </div>
+       </div>
+</div>
+{% endblock %}
index 57d8034..89d06ba 100644 (file)
        </div>
 </div>
        <div class="form-group" >
-               <p></p>
+               <input type="checkbox" name="agreement" value="agreement" required />&nbsp;&nbsp; I agree to the
+<a href="/terms" target="_blank">terms and conditions.</a>
+
+               <br><br>
                <button type="submit" class="btn btn-onelab">Submit</button>
        </div>
 </form>
index 3679796..ddac594 100644 (file)
@@ -1,6 +1,18 @@
 <script type="text/javascript">
        $(document).ready(function() {
                $("li#nav-request").addClass("active");
+               $('table.requests').dataTable({
+                   "sDom": "frtiS",
+            "bScrollCollapse": true,
+            "bStateSave": true,
+            "bPaginate": false,
+            "bLengthChange": false,
+            "bFilter": false,
+            "bSort": true,
+            "bInfo": false,
+            "bAutoWidth": true,
+            "bAutoHeight": false,
+               });
        });
        function on_click_event() {
                var ids = []; 
                                                $('#portal__status__' + request_type__id).html(status_str);
 
 
+                                       });
+                               }
+                       );
+               }
+       }
+       function on_click_reject() {
+               var ids = []; 
+               $('.portal__validate__checkbox').each(function(i, el) {
+                       if ($(el).prop('checked')) {
+                               // portal__validate__checkbox__slice__2
+                               var id_array = $(el).attr('id').split('__');
+                               // push(slice__2)
+                               ids.push(id_array[3] + '__' + id_array[4]);
+                       }
+               });
+               if (ids.length > 0) {
+                       var id_str = ids.join('/');
+
+                       // XXX spinner
+
+                       $.getJSON('/portal/reject_action/' + id_str,
+                               function(status) {
+                                       $.each(status, function(request_type__id, request_status) {
+                                               // request_status: NAME -> dict (status, description)
+                                               var status_str = '';
+                                               $.each(request_status, function(name, result) {
+                                                       if (status_str != '')
+                                                               status_str += ' -- ';
+
+                                                       if (result.status) {
+                                                               status_str += '<font color="green">Rejected</font>';
+                                                               $('#portal__validate__checkbox__' + request_type__id).hide();
+                                                       } else {
+                                                               status_str += '<font color="red">ERROR: ' + result.description + '</font>';
+                                                       }
+                                               });
+                                               $('#portal__status__' + request_type__id).html(status_str);
+
+
                                        });
                                }
                        );
        }
 </script>
 
+<div class="container-fluid">
 <div class="col-md-12">
-       <h2>Authorities</h2>
+       <h2>From your authorities</h2>
 </div>
 {% if my_authorities %}
-       
+<div class="col-md-12">
+       <table class="table requests">
+           <thead>
+        <tr>
+            <th>ID</th>
+            <th></th>
+            <th>Type</th>
+            <th>Authority</th>
+            <th>Info</th>
+            <th>Date</th>
+            <th>Status</th>
+        </tr>
+        </thead>
+        <tbody>
        {% for authority, requests in my_authorities.items %}
        
-       <div class="col-md-12">
-               <h2>{{authority}}</h2>
-       </div>
-       
-    <table class="table">
-      <th>
-        <td>Type</td>
-        <td>Id</td>
-        <td>Details</td>
-        <td>Timestamp</td>
-        <td>Status</td>
-      </th>
-    {% for request in requests %}
-
-         <tr>
-               <td>
-               {% if request.allowed == 'allowed' %}
-               <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
-               {% else %}
-                       {% if request.allowed == 'expired' %}
-                               expired
-                       {% else %} {# denied #}
-                               denied
-                       {% endif %}
-               {% endif %}
-               </td>
-               <td>{{ request.type }}</td>
-               <td>{{ request.id }}</td>
-               <td>
+        {% for request in requests %}
+        
         {% if request.type == 'user' %}
-        Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
-        {% else %}
-            {% if request.type == 'slice' %}
-        Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
-            {% else %} {# authority #}
-        Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+       <tr>
+       {% elif request.type == 'slice' %}
+       <tr class="info">
+       {% else %}
+       <tr class="active">
+       {% endif %}
+           <td><span class="gray small">{{ request.id }}</span></td>
+           <td>
+            {% if request.allowed == 'allowed' %}
+            <input class='portal__validate__checkbox' id='portal__validate__checkbox__{{request.type}}__{{request.id}}' type='checkbox'/>
+            {% else %}
+                {% if request.allowed == 'expired' %}expired{% else %}denied{% endif %}
             {% endif %}
-        {% endif %}
-               </td>
-               <td>{{ request.timestamp }}</td>
-               
-               <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
-
-    <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
-         </tr>
-
-    {% endfor %}
-       </table>
-       </div>
+            </td>
+            <td><span class="type">{{ request.type }}</span></td>
+           <td><i>{{authority}}{{request.site_authority}}</i></td>
+               <td>
+            {% if request.type == 'user' %}
+                <b>{{request.first_name}} {{request.last_name}}</b> &lt;<a href="mailto:{{request.email}}">{{request.email}}</a>&gt;
+            {% elif request.type == 'slice' %}
+            <b>{{request.slice_name}}</b> -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+            {% else %}
+            <b>{{request.site_name}}</b> ({{request.site_authority}}) -- {{request.address_city}}, {{request.address_country}}
+            {% endif %}
+               </td>
+               <td>{{ request.timestamp }}</td>
+               
+               <td><span id='portal__status__{{request.type}}__{{request.id}}'></span></td>
+    
+        <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
+         </tr>
+    
+        {% endfor %}
+       
        {% endfor %}
-
+          </tbody>
+    </table>
+   </div>
 {% else %}
        <div class="col-md-12">
                <i>There is no pending request waiting for validation.</i>
        </div>
 {% endif %}
+</div>
+
 
+<br />
 <div class="col-md-12">
-       <h2>Sub-Authorities</h2>
+       <h2>From your sub-authorities</h2>
 </div>
 {% if sub_authorities %}
        
        <i>There is no pending request waiting for validation.</i>
 </div>
 {% endif %}
-
+<br />
 <div class="col-md-12">
-       <h2>Authorities with delegation</h2>
+       <h2>From your authorities with delegation</h2>
 </div>
 
 {% if delegation_authorities %}
        <i>There is no pending request waiting for validation.</i>
 </div>
 {% endif %}
+<br />
 <div class="col-md-12">
        <button class="btn btn-onelab" type="button" id="portal__validate" onclick="on_click_event();"><span class="glyphicon glyphicon-ok"></span> Validate</button>
+       <button class="btn btn-danger" type="button" id="portal__reject" onclick="on_click_reject();"><span class="glyphicon glyphicon-remove"></span> Reject</button>
 </div>
diff --git a/portal/templates/manual-delegation.html b/portal/templates/manual-delegation.html
new file mode 100644 (file)
index 0000000..1463b51
--- /dev/null
@@ -0,0 +1,102 @@
+{% extends "layout.html" %}
+
+{% block content %}
+
+<div class="col-md-8">
+       <br>
+       <h2>Manual Delegation</h2>
+       <h3>Install SFA</h3>
+       
+       <p>
+               In order to delegate your credentials to the OneLab portal, you need to install SFA tools.<br>
+       </p>
+       <p>
+               <strong>[Requirement: python 2.7 or higher]</strong>
+       </p>
+       <h4>For Mac and Linux</h4>
+       <p class="command">
+               $ sudo easy_install pip<br>
+               $ sudo pip install sfa
+       </p>
+       <h4>For Windows</h4>
+       <p>Please download <a target="_blank" href="https://bootstrap.pypa.io/get-pip.py">get-pip.py</a></p>
+       <p class="command">
+               $ python get-pip.py<br>
+               $ pip install sfa
+       </p>
+
+       <p>
+       To get more information about pip, please visit: <a target="_blank" href="https://pip.pypa.io/en/latest/installing.html">https://pip.pypa.io/en/latest/installing.html</a>
+       </p>
+       <p>
+       More details about SFA is available at the following address:
+       <a target="_blank" href="http://svn.planet-lab.org/wiki/SFATutorialInstall#installingthroughpipfromPyPI">Installing SFA</a>
+       </p>
+       
+       <h3>Configuring SFA</h3>
+       
+       <p>
+               Once SFA tools are successfully installed, you need to configure the SFA client aka SFI
+       </p>
+       <p class="command">
+               $ mkdir ~/.sfi <br>
+               $ cd ~/.sfi <br>
+               $ cp ~/.ssh/id_rsa ~/.sfi/user-hrn.pkey
+       </p>
+       
+       <p>
+               Here, 'user-hrn' is your SFA hrn. If e.g., your OneLab account email is mohammed-yasin.rahman at upmc.fr, then your user-hrn is <b><i>'onelab.upmc.mohammed-yasin_rahman'.</i></b></p>
+       <p>
+               In this example, a user-hrn is built using the root authority i.e, <b><i>'onelab'</i></b> followed by a <b>'.'</b> then the sub authority i.e., <b><i>'upmc'</i></b>
+               followed by a <b>'.'</b> and then the last fragment in the hrn is made of the local part of your email adress i.e., <b><i>'mohammed-yasin_rahman'</i></b> 
+               (with dots replaced with underscores).
+       </p>
+
+       <p>
+               Next, you will setup your ~/.sfi/sfi_config. The following represents the sfi_config file for a OneLab user:
+       </p>
+       
+       <p class="command">
+               [sfi]<br>
+               auth = onelab.upmc<br>
+               user = onelab.upmc.mohammed-yasin_rahman<br>
+               registry = http://portal.onelab.eu:12345/<br>
+               sm = http://sfa3.planet-lab.eu:12346/<br>
+       </p>
+
+       <p>
+               Here again, <b><i>'user'</i></b> is your user-hrn, and <b><i>'auth'</i></b> is the authority that you belong to, in most cases you should just drop the last part of your hrn.
+       </p>
+       <p>
+               Add the the following to sfi_config for delegating credentials to OneLab portal:
+       </p>    
+       <p class="command">
+               [myslice]<br>
+               <br>
+               backend  = http://portal.onelab.eu:7080<br>
+               delegate = onelab.myslice<br>
+               platform = myslice<br>
+               username = mohammed-yasin.rahman@lip6.fr
+       </p>
+       <p>
+               Test the SFA layer:
+       </p>
+       <p class="command">
+               $ sfi.py version
+       </p>
+       <p>
+               And finally delegate your credentials to the portal
+       </p>
+       <p class="command">
+               $ sfi.py myslice
+       </p>
+       <p>
+       The complete tutorial is available at the following address:
+       <a target="_blank" href="http://trac.myslice.info/wiki/InstallSfa">http://trac.myslice.info/wiki/InstallSfa</a>
+       </p>
+       
+       <br />
+       
+</div>
+{% endblock %}
+
index 5b7eb96..4dbaa8e 100644 (file)
-{% extends "layout.html" %}
+{% extends "layout_wide.html" %}
 
 {% block content %}
-<div class="row">
-       <div class="col-md-12">
-                <div class="breadcrumbs">
-                </div>
-       </div>
-</div>
-<div class="row">
-    <div class="col-md-12">
-        <ul class="nav nav-tabs nav-section">
-            <li class="active"><a href="#about">About</a></li>
-            <li><a href="#components">Underlying technologies</a></li>
-        </ul>
+<div class="container">
+    <div class="row">
+        <div class="col-md-12">
+               <h1><img src="{{ STATIC_URL }}icons/support-xs.png" alt="About" />About</h1>
+        </div>
     </div>
-</div>
-
-
-<div class="tab-content">
-    <div class="tab-pane active row" id="about">
-               <div class="col-md-12">
+       <div class="row"  style="text-align:justify;">
+        <div class="col-md-12">
+                       <p>
+                               The OneLab Portal is the central site that allows users access to all OneLab testbeds. In order to gain access to the portal, 
+                               you must first  <a href="/register">register</a> to the portal. After you submit your sign-up form, you will have immediate but 
+                               limited access to the portal. The OneLab support team, which monitors portal access, will then confirm your new user sign-up request 
+                               and notify the manager of your organization. Once the manager validates your request you will have full access to all testbed resources.
+                       </p>
                        <p>
-                               OneLab Portal is a central place to get acess to all OneLab testbeds.In order to get access to the portal,
-                               an experimenter needs to  <a href="/portal/register">register</a> to the portal. The portal administrative body
-                               is responsible to accept or reject newly registered users.   
+                               OneLab provides users with access to <a href="http://planet-lab.eu/" target="_blank">PlanetLab Europe</a>, 
+                               <a href="http://nitlab.inf.uth.gr/NITlab/index.php/testbed" target="_blank">NITOS</a>, 
+                               and <a href="https://www.iot-lab.info/" target="_blank">IoT-LAB</a> testbeds, each of which has its own characteristics that allow users 
+                               to choose according to the needs of their experiments. PlanetLab Europe is an internet-overlaid platform providing 300 servers for over 
+                               150 European locations, or one thousand total servers at 500 world-wide locations. NITOS wireless mobility testbeds allow users to customize 
+                               environmental components so as to test their experiments in real-world settings; while IoT-LAB platforms offer users over 2700 fixed or mobile 
+                               wireless sensor nodes in six different locations across France.
                        </p>
                        <p>
-                               To learn more about OneLab visit:  <a href="http://onelab.eu/" target="_blank">http://onelab.eu/</a>                    
+                               To learn more about OneLab consortium, please visit:  <a href="https://www.onelab.eu" target="_blank">onelab.eu</a>                     
                        </p>
                        <p>
-                               If you have any questions regarding using the portal visit: <a href="/portal/support">OneLab support</a>
+                               If you have any questions regarding how to use the portal, please visit: <a href="/support">OneLab support</a>
                        </p>
                        <p>
-                               OneLab portal is a community effot. To get more information about OneLab portal team visit: 
-                               <a href="http://myslice.info/community" target="_blank">http://myslice.info/community</a>
+                               The OneLab portal is a community effort. To get more information about the portal team, please visit our member profile page at: 
+                               <a href="http://myslice.info/community" target="_blank">myslice.info/community</a>
                        </p>
                </div>
        </div>
-       <div class="tab-pane row" id="components">
+       <div class="row"  style="text-align:justify;">
                <div class="col-md-12">
-                       <h3>A ready-made and easily customisable user interface for your testbed.</h3>
+                       <br />
+                       <h3>The MySlice Software: A ready-made and easily customizable user interface for your testbed</h3>
+                               <p>
+                                       MySlice is an ambitious project aimed at supporting users and assisting them throughout the lifecycle of their experiments. 
+                                       The MySlice software includes a web front-end as well as a backend called Manifold. Manifold is a component allowing the integration 
+                                       of distributed and heterogeneous data sources, such as measurement platforms or data repositories. 
+                               </p>
                                <p>
-                                       MySlice is an ambitious project aiming to support researchers throughout the lifecycle of experiments that can run on a variety 
-                                       of testbeds spanning different administrative domains and networking technologies. Its basic principle is to bring together 
-                                       available resources with useful information (characteristics, performance, network measurements).
+                                       Experiments can be deployed on a variety of testbeds spanning across different administrative domains and networking technologies. 
+                                       The basic principle of MySlice is to bring together available resources with useful information (characteristics, performance, network measurements).
+
+                               </p>
+                               <p>
+                                       The MySlice initiative started in January 2011 by offering annotation services for the first federated experimental resources. Today, MySlice has 
+                                       taken a big step toward becoming a stand-alone web framework, which will present to its users all available resources from testbeds across the world. 
                                </p>
                                <p>
-                                       MySlice inititiave started in Janury 2011 by offering annotation services for the first ederated experimental resources. Today, 
-                                       MySlice has taken a big step toward becoming a tand-alone web framework, which will present all available resources from testbeds 
-                                       across the world, interconnected through the Slice-based Facility Architecture (SFA) and annotated by the TopHat measurement system.
+                                       The testbeds are interconnected through the Slice-based Facility Architecture (SFA) and annotated by the TopHat measurement system.
                                </p>
                                <p>
-                                       Our framework is built with standard programming tools (python and javascript for the front-end and python for the back-end) 
-                                       and has a modular structure based on the concept of plugins for implementing different core functionalities (query editing, 
-                                       data display, and resource allocation).
+                                       Our framework is built with standard programming tools (python and javascript for the front-end and python for the back-end) and has a modular 
+                                       structure based on the concept of plugins, used for implementing different core functionalities (query editing, data display, and resource allocation).
                                </p>
                                <p>
-                                       The goal is to enable developers with expertise on different testbed technologies and different experimental 
-                                       practices to work in parallel for optimizing the tools presented to the users allowing them for a wide range of choices 
-                                       according to their own requirements. Opening in this way the development of web-based user tools for experimentation and 
-                                       sharing effort and information can increase significantly the chances for the achievement of our challenging objective.
+                                       The goal of MySlice is to enable developers with expertise in different testbed technologies and experimental practices to create, develop, or edit new 
+                                       testbed features. These features allow users to choose from a wide range of testbed characteristics according to their own experiments' requirements. 
+                                       Opening the development of web-based user tools for experimentation and the sharing of information will allow for the achievement of the MySlice objective.
                                </p>
                </div>
                <div class="col-md-12">
+                       <br />
                        <h3>Portal Components</h3>
-                               <h5>Myslice (Web Frontend)</h5>
-                                       <p>
-                                               A full-fledged and modular web portal for a testbed federation allowing user to register, 
-                                               request slices and browse and book resources, with a strong emphasis on measurements.
-                                       </p>
+                               <h4>Myslice</h4>
+                               <ul><li><b>Web Frontend</b>
                                        <p> More Info: <a href="http://myslice.info/" target="_blank">http://myslice.info/</a></p>
                                        <p> Code: <a href="http://git.onelab.eu/?p=myslice.git;a=summary" target="_blank">Git Repository</a> (read only)</p> 
                                        <p> 
-                                               If you need write access to the git repository you need first to send your public key to <a href="mailto:support@myslice.info">support@myslice.info</a>.
+                                               If you need write access to the git repository you mustfirst to send your public key to <a href="mailto:support@onelab.eu">support@onelab.eu</a>.
                                        </p>
+                                       </li>
 
-
-                               <h5>Manifold (Portal backend)</h5>
-                                       <p>
-                                               Manifold is the backend that is running behind the portal. It is a component allowing the integration of distributed 
-                                               and heterogeneous data sources, such as measurement platforms or data repositories.
-                                       </p>
+                               <li><b>Backend (Manifold)</b>
                                        <p> Documentation: <a href="http://trac.myslice.info/" target="_blank">http://trac.myslice.info/</a></p>
                                        <p> Code: <a href="https://git.top-hat.info/?p=tophat.git;a=shortlog;h=refs/heads/devel" target="_blank">Git Repository</a> (read only)</p>     
-
-                               <h5>OneLab Registry</h5>
-                                       <p>It's a SFA registry. SFA Registry is a specific installation mode of the SFAWrapper (Registry Only mode).</p>
+                               </li></ul>
+                               <h4>OneLab Registry</h4>
+                                       <p>The OneLab registry is a SFA registry is a specific installation mode of the SFAWrapper (Registry Only mode).</p>
                                        <p> More Info: <a href="http://svn.planet-lab.org/wiki/SfaDeveloperRegistryTutorial#RunninginRegistry-Onlymode" target="_blank">SFA Registry</a></p>
        </div>
    </div>
 </div>
-
-<script>
-$(document).ready(function() {
-    $('.nav-tabs a').click(function (e) {
-        e.preventDefault();
-        $(this).tab('show');
-    });
-});
-</script>
-
-
 {% endblock %}
index 9941e97..13da125 100644 (file)
@@ -4,9 +4,16 @@
 <div class="row">
        <div class="col-md-12">
                 <div class="breadcrumbs">
-                        Account &nbsp;>&nbsp; {{ person.email }}
+                        Account &nbsp;>&nbsp; <a href="/account">{{ person.email }}</a>
                 </div>
        </div>
+        {%if 'no_creds'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
+    {%endif%}
+        {%if 'creds_expired'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
+    {%endif%}
+
 </div>
 {% if messages %}
 <ul class="messages">
                                                        </td>
                                                 {%endif%}              
                                                </tr>
+                                       <tr class="even" id="sfi_config_row">
+                                               <td class="key">sfi_config </td>
+                                               <td class="value">use sfi_config file with sfi.py package (pip install sfa)<a href="#"></a>
+                                                       <button type="submit" name="dl_sfi_config" class="btn btn-default btn-xs" title="Download your privaye key" id="dl_sfi_config">
+                                                                       <span class="glyphicon glyphicon-download"></span> Download
+                                                               </button>
+                                               </td>
+                        </tr>
+
                                                <tr class="even">
                                                <td colspan="2">
-                                                       <p class="message" id="pkey_del_msg"><b> Tradeoff:</b> Ease-of-use vs Security.<br>
-                                                                       <b>Ease-of-use:</b> Automatic account delegation. Don't delete private key.<br>
-                                                                       <b>Security:</b> Manual account delegation. Download & Delete private key.
+                                                               <p class="command">
+                                                                       <a href="#" style="color:green" data-toggle="modal" data-target="#tradeoffmodal">Automatic vs. Manual delegation of credentials:</a>
+                                                                       Trade-off between ease-of-use & security</p>
                                                                </p>
                                                </td>
                                                </tr>
                                {%endif%}
                </div>
        </div>
+<!-- Modal- No credentials -->
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">No credentials are delegated to the portal</h4>
+                    </div>
+                                       <div class="modal-body" style="text-align:justify;">
+                                       <p>You are getting this message for any of the following reasons:</p>
+                                       <ul>
+                                               <li>If your account is still pending for validation</li>
+                                               <li>If you press the "Clear Credentials" button</li>
+                                               <li>If you "Generate a new key pair"</li>
+                                               <li>If a new slice is added to your account</li>
+                                       </ul>
+                                       <p>Unless your account has not yet been validated, it is sufficient to refresh the page or go back to the home page. 
+                                               The portal will then regenerate your credentials. In some cases it may take more time than usual. If nothing works, 
+                                               then please logout and login back into to the portal.
+                                       </p>
+                                       <h3>Manual delegation of credentials</h3>
+                                               <p>
+                                                       You have selected upon sign-up to upload your public key. As you have uploaded your own public key, 
+                                                       the portal can no longer generate your credentials automatically. In order to have your credentials 
+                                                       delegated to the portal, please follow these instructions:
+                                               </p>
+                                               <ul>
+                                                       <li>Your account must first be validated by the manager of your organization.</li>
+                                                       <li>In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to
+                                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a></li>
+                                               </ul>
+                                       </p>
+                                       <h3>Contact support</h3>
+                                       <p>If you don't have the above mentioned cases and still have this message, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
+
+
+<!-- Modal- Trade-off Message  -->
+<div class="modal fade" id="tradeoffmodal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">
+                                                               Automatic vs. Manual delegation of credentials
+                                                       </h4>
+                    </div>
+                                       <div class="modal-body" style="text-align:justify;">
+                                       <h3>Automatic delegation of credentials</h3>
+                                               <p>Don't delete private key, ease-of-use option:</p>
+                                               <ul>
+                                                       <li>
+                                                               This means that you will keep your private key in the portal and it will automatically delegate your credentials on your behalf.
+                                                       </li>
+                                                       <li>
+                                                               This option does not provide as high of a level of security; however, your private key will still only be used in the portal and 
+                                                               will be available to you and the OneLab admins only.
+                                                       </li>
+                                               </ul>
+                                       <h3>Manual delegation of credentials</h3>
+                                               <p>Download & Delete private key, higher security option:</p>
+                                               <ul>
+                                                       <li>If you delete your private key, you will have more security but the portal will no longer be able to delegate credentials 
+                                                               on your behalf, and you will have to manually
+                                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a>
+                                                       </li>
+                                               </ul>
+                                       <h3>Contact support</h3>
+                                       <p>For more information, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
+
+
 
        <div class="tab-pane row" id="access">
                <div class="col-md-12">
index 21608da..4014ede 100644 (file)
 </div>
 <div class="row">
        <div class="col-md-12">
-       <p>Please check our <a href="/portal/support/">FAQ</a> section. Most of the basic problems are explained there.</p>
+       <p>If you are having any problems, please read our <a href="/portal/support/">FAQ</a> section as many of them are explained there.</p>
        <p>
-       If you haven't find your answes in the FAQ, please contact us by filling the form below.<br />
-       You can also <a href="mailto:support@myslice.info">e-mail</a> us directly.
+       If you cannot find the answers to your questions in our FAQ section, please contact us by filling out the form below.<br />
+       You can also <a href="mailto:support@onelab.eu">e-mail</a> us directly.
        </p>
        </div>
 </div>
index f5d6cf1..9170b4a 100644 (file)
@@ -6,7 +6,55 @@
 {% widget '_widget-news.html' %}
 </div> -->
 {% if username %}
+<!-- Modal- No credentials -->
+<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+            <div class="modal-dialog">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                            <h4 class="modal-title" id="myModalLabel">No credentials are delegated to the portal</h4>
+                    </div>
+                    <div class="modal-body" style="text-align:justify;">
+                                       <p>You are getting this message for any of the following reasons:</p>
+                                       <ul>
+                                               <li>If your account is still pending for validation</li>
+                                               <li>If you press the "Clear Credentials" button</li>
+                                               <li>If you "Generate a new key pair"</li>
+                                               <li>If a new slice is added to your account</li>
+                                       </ul>
+                                       <p>Unless your account has not yet been validated, it is sufficient to refresh the page or go back to the home page. 
+                                               The portal will then regenerate your credentials. In some cases it may take more time than usual. If nothing works, 
+                                               then please logout and login back into to the portal.
+                                       </p>
+                                       <h3>Manual delegation of credentials</h3>
+                                               <p>
+                                                       You have selected upon sign-up to upload your public key. As you have uploaded your own public key, 
+                                                       the portal can no longer generate your credentials automatically. In order to have your credentials 
+                                                       delegated to the portal, please follow these instructions:
+                                               </p>
+                                               <ul>
+                                                       <li>Your account must first be validated by the manager of your organization.</li>
+                                                       <li>In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to
+                                                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a></li>
+                                               </ul>
+                                       </p>
+                                       <h3>Contact support</h3>
+                                       <p>If you don't have the above mentioned cases and still have this message, please  <a href="/contact/" target="_blank">contact us</a>.</p>
+                    </div>
+                    <div class="modal-footer">
+                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                    </div>
+                </div>
+            </div>
+</div>
 <div class="container dashboard">
+          {%if 'no_creds'  in user_cred %}
+      <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">NO CREDENTIALS</a> are delegated to the portal!</p>
+  {%endif%}
+        {%if 'creds_expired'  in user_cred %}
+    <p class="command"><a href="#" style="color:red" data-toggle="modal" data-target="#myModal">EXPIRED CREDENTIALS</a> Please delegate again your credentials to the portal!</p>
+    {%endif%}
+
        <div class="row">
                {%if 'is_pi'  in pi %}
                <div class="col-md-3">
                                <a href="#"><img src="{{ STATIC_URL }}img/icon_slices.png" alt="" /></a>
                        </div>
                        <div>
-                               <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
+                               <button id="slicerequestbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Slice</button>
                        </div>
                        <div>
                                <p><strong>Your slices </strong>
-                                       <span title="A slice is a set of testbed resources on which you can conduct an experiment. 
-                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'." 
-                                       class="glyphicon glyphicon-info-sign">
-                                       </span>
+                                       <span title="A slice is a set of testbed resources on which you can conduct an experiment. 
+                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'. 
+                                       However, on the OneLab portal, you will only see slices that you have created through OneLab. If you have created slices elsewhere, 
+                                       such as on the PlanetLab Europe portal, those slices will not appear here."
+                                       class="glyphicon glyphicon-info-sign">
+                               </span>
+
                                </p>
                        </div>
                        <div>   
                        <div>
                                <p><strong>Your slices </strong>
                                <span title="A slice is a set of testbed resources on which you can conduct an experiment. 
-                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'." 
+                                       Either ask your colleagues to give you access to an existing slice or request a new slice by clicking 'Request Slice'. 
+                                       However, on the OneLab portal, you will only see slices that you have created through OneLab. If you have created slices elsewhere, 
+                                       such as on the PlanetLab Europe portal, those slices will not appear here."
                                        class="glyphicon glyphicon-info-sign">
                                </span>
                                </p>
                        <div>   
                                <div id="home-slice-list"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
                        </div>
+                       {% if pending_slices %}
+                       <p><strong>Pending slices</strong>
+                       <span title="Slices that you have requested and are pending for validation by the contact person of your organization."
+                               class="glyphicon glyphicon-info-sign">
+                       <ul>
+                       {% for slices in pending_slices %}
+                       <li>{{slices}}</li>
+                       {% endfor %}
+                       </ul>
+                       </span>
+                       </p>
+                       {%endif%}       
                </div>
                <div class="col-md-4">
                        <h3>
                $('button#slicerequestbtn').click(function() {
                        window.location="/portal/slice_request/";
                });
-/*-------
-List of slices has been moved in 
-portal/templates/base.html
-This should go into session
---------*/
+
+        /*
+            Launch queries to get the resources and leases in Manifold Cache
+        */
+            
+        $.post("/rest/resource/", function( data ) {
+        });
+        $.post("/rest/lease/", function( data ) {
+        });
+        
+        /*-------
+        List of slices has been moved in 
+        portal/templates/base.html
+        This is now in localStorage 
+        --------*/
+        // myslice.user is in LocalStorage
+        if(myslice.user.slices.length>0){
+            $.each( myslice.user.slices, function(i, val) {
+                /*
+                Launch a Query for each slice to get resources and leases in Manifold Cache
+                */
+                $.post("/rest/slice/", { 'filters': { 'slice_hrn' : val } }, function(data) {
+                });
+            });
+        }
 });
 </script>
+{# widget "_widget-monitor.html" #}
+{# widget "_widget-stats-top-slices.html" #}
+
 {% endblock %}
index 6c35812..bd361de 100644 (file)
@@ -18,7 +18,7 @@
        <div class="row">
                <div class="col-md-12">
                        <ul class="nav nav-tabs nav-section">
-                               <li class="active"><a href="#info">About</a></li>
+                               <li class="active"><a href="#about">About</a></li>
                                <li><a href="#users">Users</a></li>
                                <li><a href="#slices">Slices</a></li>
                                <li><a href="#requests">Requests</a></li>
        </div>
 </div>
 <div class="container tab-content">
-       <div class="tab-pane active row" id="info">
-               <div class="col-md-12 el">
-                       <div id="authority-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Authority" /></div>
-                   <div id="authority-tab-loaded" style="display:none;">
-                       <div id="authority-data" style="float:left; width:50%;"></div>
-                               <div id="onelab_membership" style="float:right; width:50%;">
-                                   <img src="{{ STATIC_URL }}img/onelab-logo.png" alt="" /><br>
-                               <div id="onelab-data"></div>
-                               </div>
-                   </div>
-          </div>
+       <div class="tab-pane active row" id="about">
        </div>
        
        <div class="tab-pane row" id="users" data-authority="{{user_details.parent_authority}}">
                                        <th>+/-</th>
                                        <th>Email</th>
                                        <th>User hrn</th>
+                            <!--
                                        <th>First name</th>
                                        <th>Last name</th>
                                        <th>Enabled</th>
+                            -->
                                        </tr>
                                </table>
                                
 
        <div class="tab-pane row" id="slices">
                <div class="col-md-12 el">
-               {% if 'is_pi'  in pi %}
-               <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
-               {% else %}
-               <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
-               {% endif %}
-               <br /><br />
            <div id="slice-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Slices" /></div>
            <div id="slice-tab-loaded" style="display:none;">
                <table id="slice-tab" class="table">
                        <th>Users</th>
                        <th>Url</th>
                        <!-- <th>nodes</th> -->
-                       <th>Expiration</th>
+                       <th>Creation</th>
                    </tr>
                </table>                        
            </div>
        {% if 'is_pi'  in pi %}
         <div>
+               {% if 'is_pi'  in pi %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+                       {% else %}
+                       <button id="createslice" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                       {% endif %}
             <button id="renewslices" type="button" class="btn btn-primary"><span class="glyphicon glyphicon-refresh"></span> Renew Slices</button>
             <button id="deleteslices" type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove"></span> Delete Slices</button>
         </div>
 $(document).ready(function() {
     {% if person %}
     {% if user_details.parent_authority %}
-        
-        $.post("/rest/authority/",{'filters':{'authority_hrn':'{{user_details.parent_authority}}'}}, function( data ) {
-               
-            var authority_data = [];
-            var onelab_data = [];
-                       /* 'city','enabled','legal','longitude','onelab_membership','address','parent_authority','slice','user','country',
-            'tech','abbreviated_name','url','postcode','description','scientific','authority_hrn','latitude','name'    */
-            $.each( data, function( key, val ) {
-               $('#authority_name').text(val.name);
-                authority_row = "<img src='{{ STATIC_URL }}img/institutions/{{user_details.parent_authority}}.gif' alt='' /><br>";
-                authority_row += "<br>";
-                authority_row += "<b>authority:</b> "+val.authority_hrn+"<br>";
-                               authority_row += "<br>";
-                authority_row += "<b>"+val.name+"</b><br>";
-                authority_row += "<br>";
-                authority_row += "<b>Address:</b> "+val.address+"<br>";
-                authority_row += "<b>City:</b> "+val.postcode+" "+val.city+"<br>";
-                authority_row += "<br>";
-                authority_row += "<b>Country:</b> "+val.country+"<br>";
-                authority_row += "<br>";
-                authority_row += "<br>";
-                authority_row += "<h2>Contacts</h2>";
-                authority_row += "<b>Legal:</b> ";
-                               /*
-
-                TODO: find a way to express JSON correctly given the constrains: CSV / JSON
-
-                legal = jQuery.parseJSON(val.legal);
-                if($.isArray(legal)){
-                    $.each(legal, function(k,v){
-                        authority_row += k+" "+v+"<br>";
-                    });
-                }else{
-                */
-                    authority_row += val.legal+"<br>";
-                //}
-                authority_row += "<br>";
-                authority_row += "<b>Scientific:</b> ";
-                /*
-                scientific = jQuery.parseJSON(val.scientific);
-                if($.isArray(scientific)){
-                    $.each(scientific, function(v){
-                        authority_row += v+", ";
-                    });
-                }else{
-                */
-                    authority_row += val.scientific+"<br>";
-                //}
-                onelab_membership = "<b>Status: </b>"+val.onelab_membership;
-                onelab_data.push(onelab_membership);
-                authority_data.push(authority_row);
 
-            });
-            $("div#authority-data").html(authority_data.join( "" ));
-            $("div#onelab-data").html(onelab_data.join( "" ));
-            $("div#authority-tab-loaded").css("display","block");
-            $("div#authority-tab-loading").css("display","none");
-         });
-
-        $.post("/rest/slice/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+        $.post("/rest/slice/",{'fields':['slice_hrn','users','url','slice_date_created'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
             var list_slices = [];
             var table_slices = [];
             /* "slice_hrn", "slice_description", "slice_type", "parent_authority", "created", "nodes", "slice_url", "slice_last_updated", "users", "slice_urn", "slice_expires" */
@@ -177,10 +110,10 @@ $(document).ready(function() {
                     users_length=val.users.length;
                 }
 
-                if(val.slice_url=="undefined" || val.slice_url==null){
+                if(val.url=="undefined" || val.url==null){
                     slice_url="";
                 }else{
-                    slice_url="<a href='"+val.slice_url+"' target='_blank'>"+val.slice_url+"</a>";
+                    slice_url="<a href='"+val.url+"' target='_blank'>"+val.url+"</a>";
                 }
                 
                 slice_row = "<tr id='"+val.slice_hrn+"'>";
@@ -189,7 +122,7 @@ $(document).ready(function() {
                 slice_row += "<td>"+users_length+"</td>";
                 slice_row += "<td>"+slice_url+"</td>";
                 //slice_row += "<td>"+nodes_length+"</td>";
-                slice_row += "<td>"+val.slice_expires+"</td>";
+                slice_row += "<td>"+val.slice_date_created+"</td>";
                 slice_row += "</tr>";
                 table_slices.push(slice_row);
                 
@@ -202,7 +135,7 @@ $(document).ready(function() {
         });
                
                
-        $.post("/rest/user/",{'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
+        $.post("/rest/user/",{'fields':['user_hrn','user_email'],'filters':{'parent_authority':'{{user_details.parent_authority}}'}}, function( data ) {
             var list_users = [];
             var table_users = [];
                    /* Available fields
@@ -215,9 +148,11 @@ $(document).ready(function() {
                 user_row += "<td><input type='checkbox' class='user' id='"+val.user_hrn+"'></td>";
                 user_row += "<td>"+val.user_email+"</td>";
                 user_row += "<td>"+val.user_hrn+"</td>";
+                /*
                 user_row += "<td>"+val.user_first_name+"</td>";
                 user_row += "<td>"+val.user_last_name+"</td>";
                            user_row += "<td>"+val.user_enabled+"</td>";
+                */
                 user_row += "</tr>";
                 table_users.push(user_row);
             });
@@ -236,12 +171,14 @@ $(document).ready(function() {
                e.preventDefault();
                $(this).tab('show');
        var id = $(this).attr('href').substr(1);
-       if (id == 'requests') 
+       if ((id == 'requests') || (id == 'about'))
                $("#" + id).load('/management/' + id);
        });
        var hash = window.location.hash;
        if (hash) {
                $('.nav-tabs a[href='+hash+']').click();
+       } else {
+               $('.nav-tabs a[href=#about]').click();
        }
 });
 </script>
diff --git a/portal/templates/onelab/onelab_management-tab-about.html b/portal/templates/onelab/onelab_management-tab-about.html
new file mode 100644 (file)
index 0000000..bc768a6
--- /dev/null
@@ -0,0 +1,71 @@
+{% load portal_filters %}
+<div class="col-md-6">
+       <div>
+               <img src="{{ STATIC_URL|add:'img/institutions/'|add:authority.authority_hrn|add:'.gif'|file_exists }}" alt="{{authority.name}}">
+       </div>
+       <br />
+    {% if authority.name and authority.url %}
+       <h3><a href="{{authority.url}}">{{authority.name}}</a></h3>
+    {% elif authority.name %}
+       <h3>{{authority.name}}</h3>
+    {% endif %}
+       <p>
+    {% if authority.address %}
+               {{authority.address}} <br />
+    {% endif %}
+    {% if authority.postcode %}
+               {{authority.postcode}} 
+    {% endif %}
+    {% if authority.address %}
+        {{authority.city}} <br />
+    {% endif %}
+    {% if authority.address %}
+               {{authority.country}}
+    {% endif %}
+       </p>
+       <br />
+
+    {% if authority.address %}
+       <h4>Onelab membership</h4> 
+       <p>
+               {{ authority.onelab_membership }}
+       </p>
+    {% endif %}
+</div>
+<div class="col-md-6">
+    {% if authority.legal %}
+       <h4>Legal Contact:</h4>
+       <p>
+       {% for c in authority_contacts.legal %}
+                {{ c }} <br />
+       {% endfor %}
+       </p>
+       <br />
+    {% endif %}
+    {% if authority.scientific %}
+       <h4>Scientific Contact:</h4>
+       <p>
+       {% for c in authority_contacts.scientific %}
+               {{ c }} <br />
+       {% endfor %}
+       </p>
+       <br />
+    {% endif %}
+    {% if authority.technical %}
+       <h4>Technical Contact:</h4>
+       <p>
+       {% for c in authority_contacts.technical %}
+               {{ c }} <br />
+       {% endfor %}
+       </p>
+    {% endif %}
+</div>
+<script>$(document).ready(function() {
+{% if authority.name %}
+    auth_name = "{{authority.name}}";
+{% else %}
+    auth_name = "{{authority.authority_hrn}}";
+{% endif %}
+    $('#authority_name').text(auth_name);
+});
+</script>
index 3679796..e255779 100644 (file)
@@ -14,9 +14,7 @@
                });
                if (ids.length > 0) {
                        var id_str = ids.join('/');
-
                        // XXX spinner
-
                        $.getJSON('/portal/validate_action/' + id_str,
                                function(status) {
                                        $.each(status, function(request_type__id, request_status) {
@@ -44,7 +42,7 @@
 </script>
 
 <div class="col-md-12">
-       <h2>Authorities</h2>
+       <h2>From your authorities</h2>
 </div>
 {% if my_authorities %}
        
                <td>{{ request.id }}</td>
                <td>
         {% if request.type == 'user' %}
-        Login: {{request.login}} -- First name: {{request.first_name}} -- Last name: {{request.last_name}} -- Email: {{request.email}}
+            <b>{{request.first_name}} {{request.last_name}}</b> <a href="mailto:{{request.email}}">{{request.email}}</a>
         {% else %}
             {% if request.type == 'slice' %}
-        Slice name: {{request.slice_name}} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+            <b>{{request.slice_name}}</b> -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
             {% else %} {# authority #}
-        Authority name: {{request.site_name}} -- authority_hrn: {{request.site_authority}} -- City: {{request.address_city}} -- Country: {{request.address_country}}
+            <b>{{request.site_name}}</b> ({{request.site_authority}}) -- {{request.address_city}}, {{request.address_country}}
             {% endif %}
         {% endif %}
                </td>
@@ -98,7 +96,6 @@
 
     {% endfor %}
        </table>
-       </div>
        {% endfor %}
 
 {% else %}
                <i>There is no pending request waiting for validation.</i>
        </div>
 {% endif %}
-
+<div>nnllknjkn<br /><br /></div>
 <div class="col-md-12">
-       <h2>Sub-Authorities</h2>
+       <h2>From your sub-authorities</h2>
 </div>
 {% if sub_authorities %}
        
        {% for authority, requests in sub_authorities.items %}
        <div class="col-md-12">
-       <h3>{{authority}}</h3>
-           <table class="table">
+               <h2>{{authority}}</h2>
+       </div>
+       
+       <table class="table">
              <th>
                <td>Type</td>
                <td>Id</td>
            <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
                  </tr>
            {% endfor %}
-           </table>
-       </div>
+       </table>
        {% endfor %}
 {% else %}
 <div class="col-md-12">
 {% endif %}
 
 <div class="col-md-12">
-       <h2>Authorities with delegation</h2>
+       <h2>From your authorities with delegation</h2>
 </div>
 
 {% if delegation_authorities %}
        {% for authority, requests in delegation_authorities.items %}
        <div class="col-md-12">
                <h3>{{authority}}</h3>
-                   <table class="table">
+       </div>
+       <table class="table">
                      <th>
                        <td>Type</td>
                        <td>Id</td>
                    <!--<div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> -->
                          </tr>
                    {% endfor %}
-                   </table>
-               </div>
+       </table>
                {% endfor %}
 {% else %}
 <div class="col-md-12">
index 69b417d..b46eab1 100644 (file)
@@ -5,13 +5,12 @@
     <div class="row">
         <div class="col-md-12">
                <h1><img src="{{ STATIC_URL }}icons/slices-xs.png" alt="News" />News</h1>
-               <br />
         </div>
     </div>
  
        <div class="row">
         <div class="col-md-12">
-               <b>15 July 2014</b> - The <b>OneLab</b> Portal opens with the <b>PlanetLab Europe</b>, <b>IOTLab</b> and <b>NITOS</b> testbeds!
+               <b>1 August 2014</b> - The <b>OneLab</b> Portal opens for beta test with the <b>PlanetLab Europe</b>, <b>IOTLab</b> and <b>NITOS</b> testbeds!
                <p>
                        Existing PlanetLab users will be able to open an account with their existing PLE credentials.
                </p>
index ec3c6e7..b9a61a5 100644 (file)
@@ -9,32 +9,31 @@
 </div>
 <div class="row">
        <div class="col-md-12">
-               <p><strong>Questions? <a href="/portal/contact" >Contact us.</a></strong></p>
+               <p><strong>Questions? <a href="/contact" >Contact us.</a></strong></p>
   </div>
 </div>
 {% if errors %}
-<ul>
-  {% for error in errors %}
-  <li>{{ error }}</li>
-  {% endfor %}
-</ul>
+<div class="row">
+       <div class="col-md-12">
+               <ul class="error">
+                 {% for error in errors %}
+                 <li>{{ error | safe }}</li>
+                 {% endfor %}
+               </ul>
+       </div>
+</div>
 {% endif %}
-
-
-<form action="/register" class="cmxform form-horizontal" method="post" enctype="multipart/form-data">
+                               <form action="/register" class="cmxform form-horizontal" method="post" enctype="multipart/form-data">
 <div class="row">
-       
        <div class="col-md-12">
-                       
                        <div class="form-group">
                                {% csrf_token %}
                                <label for="authority_hrn" class="control-label">Organization</label>
                                <p></p>
                                <input id="authority_hrn" name="org_name" class="form-control" style="width:590px" value="{{ organization }}" 
                                title="Choose your organization (company/university) from the list that apears when you click in the field and start to type.
-                                Use the arrow keys to scroll through the list; type part of the name to narrow down the list. If it is not in the list, 
-                               please request its addition by clicking the link below. We will send an email to the managers that we have on record for 
-                               your organization, asking them to validate your sign-up request." required />
+                                Use the arrow keys to scroll through the list; type part of the name to narrow down the list. We will send an email to 
+                                the managers that we have on record for your organization, asking them to validate your sign-up request." required />
                                <p></p>
                                <p>Organization not listed? <a href="/portal/join">Request its addition now.</a></p>
                        </div>
@@ -84,7 +83,7 @@
                <br />
                        <div class="alert alert-danger" id="pkey_del_msg">
                                In order for the portal to contact testbeds on your behalf, so as to list and reserve resources, you will need to 
-                               <a href="http://trac.myslice.info/wiki/InstallSfa" target="_blank">delegate your public key to the portal.</a>
+                               <a href="/portal/manual_delegation" target="_blank">delegate your credentials to the portal.</a>
                        </div>
            </div>
        </div>
        <div class="col-md-10">
                <div class="form-group" id="register">
                        <span class="glyphicon glyphicon-info-sign"></span> &nbsp;
-               If you are a <b>PlanetLab Europe</b> fill in this form using the same email address that you currently use for your PlanetLab Europe account,
-               your existing credentials will be used to validate your OneLab account.
+               If you are a <b>PlanetLab Europe</b> user, please fill in this form using the same email address that you
+                currently use for your PlanetLab Europe account.
+               Your existing credentials will be used to validate your OneLab account.
                Please be sure to specify a different password for your new OneLab account.
            </div>
        </div>
                <div class="form-group" id="register">
                        <p></p> 
                <input class="submit btn btn-onelab" type="submit" value="Sign up" />
-
+               </form>
            </div>
        </div>
 </div>
-</form>
 
        <!-- Modal - columns selector -->
 <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
@@ -489,9 +488,9 @@ $(document).ready(function(){
         {% for authority in authorities %}
             {% if authority.name %}
                 {value:"{{ authority.name }}",label:"{{authority.name}}"},
-                       // to show only full name
-           // {% else %}
-           //     {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
+                       // show hrn if we don't have the name
+            {% else %}
+                {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
             {% endif %}
         {% endfor %}    
     {% else %}
@@ -515,15 +514,10 @@ $(document).ready(function(){
       minLength: 0,
       change: function (event, ui) {
           if(!ui.item){
-              //http://api.jqueryui.com/autocomplete/#event-change -
-              // The item selected from the menu, if any. Otherwise the property is null
-              //so clear the item for force selection
               jQuery("#authority_hrn").val("");
           }
       }
-      //select: function( event, ui ) {console.log(jQuery(this))}
     });
-       // for hover texts
        $('[title!=""]').qtip();
        $("form").validate();
        $("form").submit(function() {
diff --git a/portal/templates/onelab/onelab_slice-resource-view.html b/portal/templates/onelab/onelab_slice-resource-view.html
new file mode 100644 (file)
index 0000000..3fefedf
--- /dev/null
@@ -0,0 +1,121 @@
+{% extends "layout_wide.html" %}
+{% load portal_filters %}
+
+{% block head %}
+<!-- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC1RUj824JAiHRVqgc2CSIg4CpKHhh84Lw&sensor=false"></script> -->
+<script src="{{ STATIC_URL }}js/onelab_slice-resource-view.js"></script>
+<script>
+       //myslice.slice = "{{ slice }}";
+
+$(document).ready(function() {
+            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+        // find the plugin object inside the tab content referenced by the current tabs
+        $('.plugin', $($(e.target).attr('href'))).trigger('shown.bs.tab');
+        $('.plugin', $($(e.target).attr('href'))).trigger('show');
+            });
+});
+</script>
+{% endblock %}
+
+{% block content %}
+{% widget '_widget-slice-sections.html' %}
+<div class="container-fluid container-resource">
+       <div class="row">
+       <div class="col-md-2">
+               <!-- <div id="select-platform" class="list-group"></div> -->
+               {{filter_testbeds}}
+       </div>
+       <div class="col-md-10" style="height:100%;">
+               <div class="row">
+                       {% if msg %}
+                       <div class="col-md-12"><p class="alert-success">{{ msg }}</p></div>
+                       {% endif %}
+               </div>
+       
+               <div class="row">
+                       <div class="col-md-6">
+                               {{ filter_status }}
+                       </div>
+                       <div class="col-md-1">
+                               {{ apply }}
+                       </div>
+               </div>
+               <!--
+               <div class="list-group-item list-resources">
+                       <span class="list-group-item-heading" style="padding-left: 0;">Resource status:</span>
+                       <a class="list-group-item active" data-panel="resources" href="#" style='display: inline-block !important;'>All</a>
+                       <a class="list-group-item" data-panel="reserved" href="#" style='display: inline-block !important;'>Reserved</a>
+                       <a class="list-group-item" data-panel="pending" href="#" style='display: inline-block !important;'>Pending <span class="badge" id="badge-pending" data-number="0"></span></a>
+               </div>
+               -->
+
+               <div class="row">
+                       <div class="col-md-12">
+                       <ul class="nav nav-tabs">
+                         <li class="active"><a href="#resourcelist" role="tab" data-toggle="tab">Table</a></li>
+                         <li> <a href="#resourcemap" role="tab" data-toggle="tab">Map</a></li>
+                         <li> <a href="#resourcescheduler" role="tab" data-toggle="tab">Scheduler</a></li>
+                       </ul>
+                       </div>
+               </div>
+               
+               <!-- Modal - columns selector -->
+               <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+                       <div class="modal-dialog">
+                       <div class="modal-content">
+                               <div class="modal-header">
+                                       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+                                               <h4 class="modal-title" id="myModalLabel">Columns selector</h4>
+                               </div>
+                               <div class="modal-body">
+                                       {{columns_editor}}
+                               </div>
+                               <div class="modal-footer">
+                                       <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+                               </div>
+                       </div>
+                       </div>
+               </div>
+               
+               
+               <div class="row">
+                       <div class="col-md-12">
+                       <div class="tab-content" style="height:100%;">
+                               <div class="tab-pane active" id="resourcelist">
+                                        <!-- Button trigger modal - columns selector -->
+                                       <button class="btn btn-default btn-sm" style="float:right;" data-toggle="modal" data-target="#myModal">...</button>
+                       {{list_resources}}
+                                       <!-- <table cellpadding="0" cellspacing="0" border="0" class="table" id="objectList"></table> -->
+                               </div>
+                               <div class="tab-pane" id="resourcemap">
+                       {{map_resources}}
+                               </div>
+                               <div class="tab-pane" id="resourcescheduler">
+                       {{scheduler}}
+                               </div>
+       
+                               <!--
+                               <div id="reserved" class="tab-pane" style="height:370px;display:none;">
+                       <table width="80%">
+                           <tr><th width="50%" style="text-align:center;">resources</th><th width="50%" style="text-align:center;">leases</th></tr>
+                           <tr>
+                               <td style="text-align:center">{{list_reserved_resources}}</td>
+                               <td style="text-align:center">{{list_reserved_leases}}</td>
+                           </tr>
+                       </table>
+                               </div>
+                               <div id="pending" class="tab-pane" style="height:370px;display:none;">
+                       {{pending_resources}}
+                               </div>
+                               <div id="sla_dialog" class="tab-pane" style="height:370px;display:none;">
+                       {{sla_dialog}}
+                               </div>
+       -->
+       
+                       </div>
+               </div>
+       </div>
+       </div>
+       </div>
+</div>
+{% endblock %}
index 8057609..c2d52c3 100644 (file)
@@ -1,11 +1,9 @@
 {% extends "layout_wide.html" %}
 
 {% block head %}
-
 {% endblock %}
 
 {% block content %}
-
 {% include theme|add:"_widget-slice-sections.html" %}
          
 <div class="container-fluid tab-content container-slice">
index 5d0cf56..211f35d 100644 (file)
@@ -13,7 +13,7 @@
        {% if errors %}
        <div class="row">
                <div class="col-md-12">
-               <ul>
+               <ul class="error">
                  {% for error in errors %}
                  <li>{{ error }}</li>
                  {% endfor %}
@@ -30,7 +30,7 @@
                            <input type="email" class="form-control" id="email" style="width:300px" value="{{ email }}" readonly="readonly">
                          </div>
                          <div class="form-group">
-                           <input type="text" class="form-control" name="slice_name" id="slice_name" style="width:300px" placeholder="Slice Name
+                           <input type="text" class="form-control" name="slice_name" id="slice_name" style="width:300px" placeholder="Slice name" value="{{slice_name}}
                                title="Please enter a name for your slice"required="required">
                          </div>
                          <div class="form-group">
                                {%endif%}
                          </div>
                          <div class="form-group">
-                           <input type="number" class="form-control" name="number_of_nodes" id="number_of_nodes" style="width:300px" placeholder="Number of Nodes"
-                               title="Number of nodes you expect to request (informative)">
+                           <input type="text" class="form-control" name="url" id="url" style="width:300px" placeholder="Experiment URL (if one exists)"
+                               title="Please provide the url of your experiment if you have one." value="{{url}}">
                          </div>
                          <div class="form-group">
-                               <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Experiment Purpose" style="width:300px" 
+                               <textarea id="purpose" name="purpose" class="form-control" rows="6" placeholder="Experiment purpose" style="width:300px" 
                                title="Purpose of your experiment (informative)" required="required">{{ purpose }}</textarea>
                          </div>
-                         <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Request Slice</button>
+                         {%if 'is_pi'  in pi %}        
+                         <button type="submit" id=submit_pi class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Create slice</button>
+                         {%else%}
+                         <button type="submit" class="btn btn-onelab"><span class="glyphicon glyphicon-plus"></span> Request slice</button>
+                         {%endif%}     
                        </form>
        
                </div>
 <script>
 jQuery(document).ready(function(){
        
-       $("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) {
+       /*$("#authority_hrn").load("/rest/user/", {"fields" : ["parent_authority"], "filters": {"user_hrn": "{{ user_hrn }}"}}, function(data) {
                var jsonData = JSON.parse(data);
-               // getting the authority from the view not rest
-        $(this).attr("value", "{{authority_name}}");
-    });
+        $(this).attr("value", jsonData[0]['parent_authority']);
+    });*/
+       $("#authority_hrn").val("{{authority_name}}");
        var availableTags = [
     {% if authorities %}
         {% for authority in authorities %}
@@ -94,6 +98,10 @@ jQuery(document).ready(function(){
       minLength: 0,
       select: function( event, ui ) {console.log(jQuery(this));}
     });
+
+       $("#submit_pi").click(function() {
+               localStorage.clear();
+       });
 });
 </script>
 {% endblock %}
index e33127c..e59d281 100644 (file)
@@ -14,8 +14,7 @@
        <div class="row">
                <div class="col-md-12">
                        <ul class="nav nav-tabs nav-section">
-                               <li class="active"><a href="#support">Tickets</a></li>
-                               <li><a href="#faq">FAQ</a></li>
+                               <li class="active"><a href="#faq">FAQ</a></li>
                                <li><a href="#contact">Contact</a></li>
                        </ul>
            </div>
 </div>
 
 <div class="container tab-content">
-       <div class="tab-pane active row" id="support">
-               <div class="col-md-12">
-                       <h2>Report a Bug</h2>
-                       <p>If you have found a bug or having difficulties accesing some features or found some anomalies, please report it using our ticketing system.</p>
-                       <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Ticket</button>
-<!--                   <h3>Unresolved Tickets</h3>
-                       <table class="mytable table table-bordered table-hover">
-                       <tr>
-                           <th>Ticket No</th>
-                                       <th>Reported By</th>
-                                       <th>Description</th>
-                           <th>Status</th>
-                       </tr>
-                       <tr>
-                           <td>1</td>
-                                       <td>yasin.upmc@gmail.com</td>
-                                       <td> Slice_request page is not working </td>
-                                       <td> Unresolved</td>
-                       </tr>
-                               <tr>
-                                       <td>2</td>
-                                       <td>azerty@lip6.fr</td>
-                                       <td>Unable to Register</td>
-                                       <td>Unresolved</td>
-                               </tr> 
-               
-                   </table> -->
-               </div>
-         </div>
-       <div class="tab-pane row" id="faq">
-               <div class="col-md-12">
+       <div class="tab-pane active row" id="faq">
+               <div class="col-md-12" style="text-align:justify;">
                        <h2>Frequently Asked Questions (FAQs)<h2>
 
+                       <h3>PlanetLab Europe Users</h3>
+                       <ul>
+                               <li>
+                                       <h4>I am already a PlanetLab Europe user, how do I sign up?</h4>
+                                       <p>
+                                               Users that already have an account on PlanetLab Europe will be able to <a href="/register">sign up</a> using the
+                                               available form and selecting their institution from the provided list.<br />
+                                               If the user account on PlanetLab Europe is already enabled it will be automatically validated.
+                                       </p>
+                               </li>
+                               <li>
+                                       <h4>Which testbeds will I be able to access?</h4>
+                                       <p>
+                                               You will be able to access NITOS, a wireless based testbed, and IoT-LAB, a sensor and radio based testbed.
+                                       </p>
+                               </li>
+                               <li>
+                                       <h4>Should I use the OneLab portal for my PlanetLab reservations?</h4>
+                                       <p>
+                                               For the time being, we recommend that you continue to use the PlanetLab Europe portal for reserving nodes on the 
+                                               worldwide PlanetLab system. <br />
+                                               We are working to provide you with an equally good PlanetLab experience through the OneLab portal, 
+                                               and we will invite you to help us beta-test this feature as soon as it is available. <br />
+                                               Other users, who do not have PlanetLab Europe accounts, currently have limited access to
+                                               PlanetLab Europe through the OneLab portal. This is not the same as the full access that you 
+                                               currently enjoy through your PlanetLab Europe account.
+                                       </p>
+                               </li>
+                       </ul>
+                       
                        <h3>Users</h3>
                        <ul>
                        <li><h4>Who is a user?</h4></li>
-                       <p>A user is an experimenter who registers to the OneLab portal and able to use all the facilites that the portal has to offer. However, a user does not
+                       <p>A user is an experimenter who registers to the OneLab portal and able to use all of the facilities that the portal has to offer. However, a user does not
                        have the right to do any admin operation such as managing slices, users and resources.</p>
                        
                        
                        <li><h4>How do I register?</h4></li>
-                       <p>In order to register you must go to the <a href="/portal/register">Registration</a> page. You have to choose your corresponding institution (authority). After registration you have to wait until the PI validates your account. However upon registration, you will be able login to the portal with a limited access. Do not try to re-register with the same email address.</p>
+                       <p>In order to register you must go to the <a href="/register">Registration</a> page. You must choose your corresponding institution (authority). 
+                       After registration you will have to wait until the manager of your organization validates your account. However upon registration, you will be able login to the portal with 
+                       a limited access. Do not try to re-register with the same email address.</p>
                        
                        <li><h4>Why can't I register with my email?</h4></li>
                        <p>If you have already registered then you won't be able to register again with the same email address. However, if you have never registered and still you are not able to use your email then please 
-                       <a href="/portal/contact">Contact Support</a> and mention the error message that you are getting while trying to register.</p>
+                       <a href="/contact">Contact Support</a> and mention the error message that you are getting while trying to register.</p>
                        
-                       <li><h4>In registration, in "My keys" option, what should i choose?</h4></li>
-                       <p>There are two choices.</p> 
-                               <p class="text-justify"><b>1. Generate Key Pairs:</b> This option is for users who have no knowledge about SFA and MySlice i.e., new users. We offer convenience to the new users in order to avoid addtional efforts to delegate keys manually. If you choose this option, the portal will automatically handle your credentials and you would be able use the portal as soon as the PI validates your account. However, you can delete your private key from the portal if you are concerned about privacy issues. In that case once your current credentials expire, you have to delegate your credentials manually using <a href="http://trac.myslice.info/wiki/InstallSfa" target="_blank">SFA</a>. As this needs advance knowledge about SFA and Myslice, we highly recommend to the new users to keep both private and public keys in the portal in order to keep the process automatic. </p>
-                               <p class="text-justify"><b>2. Upload My Public Key:</b> This option is for users who have experience with MySlice and SFA. If you choose this option, once the PI validates your account, you have to delegate your credentials manually using <a href="http://trac.myslice.info/wiki/InstallSfa" target="_blank">SFA</a>. You have to repeat the same process everytime your credentials expire. Normally, credentials expire every one month. You can see the expiration date in your Account page. </p>
+                       <li><h4>In the "My keys" option under registration, what should I choose?</h4></li>
+                       <p>You may choose one of the two options.</p> 
+                               <p ><b>1. Generate Key Pairs:</b> This option is for users who have no knowledge about SFA and MySlice i.e., new users. 
+                                       We offer convenience to the new users in order to avoid additional efforts to delegate keys manually. If you choose this option, 
+                                       the portal will automatically handle your credentials and you would be able use the portal as soon as your organization's manager 
+                                       validates your account. However, you can delete your private key from the portal if you are concerned about privacy issues. In this instance, 
+                                       once your current credentials expire, you will have to delegate your credentials manually using <a href="http://trac.myslice.info/wiki/InstallSfa" target="_blank">SFA</a>. 
+                                       As this needs advance knowledge about SFA and Myslice, we highly recommend to the new users to keep both private and public keys in 
+                                       the portal in order to keep the process automatic. 
+                               </p>
+                               <p><b>2. Upload My Public Key:</b> This option is for users who have experience with MySlice and SFA. If you choose this option, once your organization's manager  validates your account, you will have to delegate your credentials manually using <a href="http://trac.myslice.info/wiki/InstallSfa" target="_blank">SFA</a>. You have will to repeat this same process every time your credentials expire. Credentials must generally be renewed every 30 days. You can see the expiration date in your Account page. </p>
                        
                        <li><h4>Who is responsible for validating my account?</h4></li>
-                       <p>When you register, you choose an authority fromt he list of authorities. For each authority there is a Principal Investigator (PI). PI of your authority will verify your identity and if he finds that you are from his institution, he will validate your account otherwise he will reject your account.</p>
+                       <p>When you register, you choose an authority from he list of authorities. For each authority there is a manager. The manager of your organization will verify your identity and if he finds that you are from his institution, he will validate your account.If you are not a part of his organization, then he will not approve your account.</p>
                        
-                       <li><h4>How long I have to wait for validation?</h4></li>
-                       <p>It depends on the PI of your authority. In general, it should not take more than a week. If you are waiting more than usual, please <a href="/portal/contact">Contact Support</a> and explain your problem.</p>
+                       <li><h4>How long must I wait for validation?</h4></li>
+                       <p>It depends on the PI of your authority. In general, it should not take more than a week. If you are waiting more than usual, please <a href="/contact">Contact Support</a> and explain your problem.</p>
                        <li><h4>I just registered. Why can't I see any slices and resources?</h4></li>
-                       <p>Once you register, you can login to your account with limited access. It means that you can view your account details, modify your name and password. You can also view other pages. However, you will not be able to see any slices as well as resources before your account validation. But you can <a href="/portal/slice_request/">Request Slice</a> before being validated. Therefore, the PI will validate your account as well as your requested slice. Once validated, you will be able to see your slice and if you click on your slice, you will be able to see resources in that slice and you can reserve nodes and start your experiment.</p>
+                       <p>Once you register, you can login to your account with limited access. It means that you can view your account details, modify your name and password. You can also view other pages. However, you will not be able to see any slices as well as resources before your account validation. But you can <a href="/portal/slice_request/">Request Slice</a> before being validated. In this instance, your organization's manager will validate your account as well as your requested slice. Once validated, you will be able to see your slice. If you click on your slice, you will be able to see the resources in that slice and you can reserve nodes and start your experiment.</p>
                        
                        <li><h4>How can I get access to a slice?</h4></li>
-                       <p>If you are a completely new user, you have to <a href="/portal/slice_request/">Request Slice</a>. It is upto the PI of your authority to accept/reject your slice request. </br>On the other hand, if you are a new user to the portal but you already have an account in OneLab SFA registry and you have access to slices, you will be able to see all your slices once your account is validated by the PI.</p> 
+                       <p>If you are a completely new user, you have to <a href="/portal/slice_request/">Request Slice</a>. It is up to the manager of your organization to accept/reject your slice request. </br>On the other hand, if you are a new user to the portal but you already have an account in the OneLab SFA registry and you have access to slices, you will be able to see all of your slices once your account is validated by the PI.</p> 
                        
                        <li><h4>I forgot my password, how to recover it?</h4></li>
                        <p>If you have an account in the portal but you forgot the password, you can always <a href="/portal/pass_reset/">Reset your password</a>.</p></ul>
                        <h3>Managers</h3>
                        <ul>
                        <li><h4>Who is a manager?</h4></li>
-                       <p>A manager is the Principal Investigator (PI) of the institution. Each PI has authority over his own institution. A PI can add, delete, validate users/ 
-                       slices that belong to his institution.</p>
+                       <p>
+                               A manager is the contact person and principal authority of the a particular organization. Each manager has authority over his 
+                               or her own institution/department/team. A manager may add, delete or validate users/slices that belong to his institution.
+
+                       </p>
                        
                        <li><h4>What is pending users/slices?</h4></li>
-                       <p>In <a href="/portal/validate">Requests</a> page you will be able to see all the users that registered under your authority and the slices that users of your authority has requested. Therefore, pending users/slices are those users and slices that are yet to be validated. You can validate/reject these requests based on the policy of your institution.</p>
+                       <p>In  the <a href="/portal/validate">Requests</a> page you will be able to see all the users that have registered under your authority and the slices that they have requested. Therefore, pending users/slices are those users and slices that are yet to be validated. You can validate/reject these requests based on the policy of your institution.</p>
                        
                        <li><h4>How can I manage the users/slices that belong to my institution?</h4></li>
-                       <p>In <a href="/portal/institution">Instution</a> page, under "Users" tab, you will be able to see all the users that belong to your authority. You can delete the users that you don't want anymore. Under "Slices" tab, you will be able to see all the slices that belong to your authority. You can renew/delete the slices based on your requirements. As a PI you can also <a href="/portal/slice_request/">Create Slice</a>. Just fill the form of request slice and the slice will be automatically validated if it is requested by a PI. </p>
+                       <p>
+                               In the <a href="/portal/institution">Instution</a> page, under "Users" tab, you will be able to see all the users that belong to your authority. 
+                               You can delete the users that you don't want anymore. Under "Slices" tab, you will be able to see all the slices that belong to your authority. 
+                               You can renew/delete the slices based on your requirements. As a manager you may also <a href="/portal/slice_request/">Create Slice</a>. 
+                               Just fill in the create slice and the slice will automatically be validated if it is requested by a manager. 
+                       </p>
                        
                        </ul>
                </div>
          </div>
 
-       <div class="tab-pane row" id="contact">
-               <div class="col-md-12">
-                       <h2>Contact Us</h2>
-               
-                       <h3>Mailing List</h3>
-                       <p>You can subscribe to our mailing list by sending a request to: <b>support</b> AT <b>myslice</b> DOT <b>info</b></p>
-                       <p>Also you can adress any issues in the same email address.</p>
-                       
-                       <h3>Mailing Address</h3>
-                       <address>
-                       UPMC - LIP6<br> 
-                       Boîte courrier 16 <br>
-                       Couloir 26-00, Etage 01, Bureau 102<br>
-                       4 place Jussieu<br>
-                       75252 PARIS CEDEX 05<br>
-                       France<br> 
-                       </address>
-               </div>
-         </div>
+       <div class="tab-pane" id="contact">
+               <div class="row">
+                       <div class="col-md-12">
+                               <h2>Contact Us</h2>
+                               <div class="row">
+                                       <div class="col-md-6">
+                                               <h3>Mailing List</h3>
+                                               <p>&nbsp;</p>
+                                               <p>You can subscribe to our mailing list by sending a request at the following E-Mail address:</p>
+                                               <p class="address">
+                                                       <a href="mailto:contact@onelab.eu">contact@onelab.eu</a>
+                                               </p>
+                                               <p>Also you may adress any other issues in the same email address.</p>
+                                       </div>
+                                       <div class="col-md-6">
+                                               <h3>Mailing Address</h3>
+                                               <p>&nbsp;</p>
+                                               <p class="address">
+                                                       <b>OneLab Team</b><br />
+                                                       UPMC - Laboratoire d'Informatique de Paris 6<br />
+                                                       Boite courrier 169<br />
+                                                       4 place Jussieu<br />
+                                                       75252 PARIS cedex 05<br />
+                                                       FRANCE
+                                               </p>
+                                               
+                                               
+                                       </div>
+                               </div>
+                               <div class="row">
+                                       <div class="col-md-6">
+                                               <h3>Report a Bug</h3>
+                                               <p>If you have found a bug, are having difficulties accessing some features or have found some anomalies, 
+                                                       please report it using our ticketing system.
+                                               </p>
+                                               <button id="ticketbtn" type="button" class="btn btn-default"><span class="glyphicon glyphicon-plus"></span> Create Ticket</button>
+                                       </div>
+                               </div>
+                       </div>
+               </div>
+       </div>
 </div>
 
 <script>
 $(document).ready(function() {
     $('button#ticketbtn').click(function() {
-        window.location="/portal/contact/";
+        window.location="/contact/";
     });
        $('.nav-tabs a').click(function (e) {
                e.preventDefault();
diff --git a/portal/templates/onelab/onelab_user_request_email.html b/portal/templates/onelab/onelab_user_request_email.html
new file mode 100644 (file)
index 0000000..4947947
--- /dev/null
@@ -0,0 +1,22 @@
+<img src="https://onelab.eu/static/images/onelab.png"> 
+<br>
+<h1>NEW USER REQUEST</h1>
+<br>
+<p>You are receiving this request because we have you listed as a manager at an organization that uses OneLab.</p> 
+<p>If you believe that you have received this message in error, or if you have any questions, kindly contact support@onelab.eu.</p>
+<br>
+<b>First name   :</b> {{first_name}}<br>
+<b>Last name    :</b> {{last_name}}<br>
+<b>Organization :</b> {{organization}}<br>
+<b>Authority hrn:</b> {{authority_hrn}}<br>
+<b>Public key   :</b> {{public_key}}<br>
+<b>Email        :</b> {{email}}<br>
+<b>User hrn     :</b> {{user_hrn}}<br>
+<b>Portal url  :</b> {{ current_site }}<br>
+<p></p>
+<p>You can see new user request <a href="http://{{current_site}}/portal/validate">in the portal.</a><p>
+<p>Please note that the request will only become visible to you on the OneLab portal once the user has confirmed his/her email address.</p>
+<p>Please only validate users who you know for whose actions you are prepared to take responsibility, as described in the 
+<a href="http://{{current_site}}/terms">OneLab terms and conditions.</a> If you find any anomalies in the request 
+(mistakes/spam/unauthorized persons) please <a href="mailto:support@onelab.eu">notify us.</a></p>
+
diff --git a/portal/templates/onelab/onelab_user_request_email.txt b/portal/templates/onelab/onelab_user_request_email.txt
new file mode 100644 (file)
index 0000000..83ec9d3
--- /dev/null
@@ -0,0 +1,21 @@
+NEW USER REQUEST
+
+You are receiving this request because we have you listed as a manager at an organization that uses OneLab. 
+If you believe that you have received this message in error, or if you have any questions, kindly contact support@onelab.eu.
+
+First name   : {{first_name}}
+Last name    : {{last_name}} 
+Organization :{{organization}}
+Authority hrn: {{authority_hrn}}
+Public key   : {{public_key}}
+Email        : {{email}}
+User hrn     : {{user_hrn}}
+Portal url   : {{ current_site }}
+
+You can see new user request in the portal: http://{{current_site}}/portal/validate
+
+Please note that the request will only become visible to you on the OneLab portal once the user has confirmed his/her email address.
+
+Please only validate users who you know for whose actions you are prepared to take responsibility, as described in the OneLab terms and conditions. 
+If you find any anomalies in the request (mistakes/spam/unauthorized persons)  please notify us at support@onelab.eu.
+
index d7342f8..790c720 100644 (file)
@@ -20,7 +20,7 @@
        <div class="login-signup">
                You don't have yet an account? 
                
-               <a href="/portal/register">Sign Up!</a>
+               <a href="/register">Sign Up!</a>
        </div>
        </form>
 </div>
index 01c8d82..40761b5 100644 (file)
@@ -2,7 +2,7 @@
        <div class="row">
                <div class="col-md-12">
                         <div class="breadcrumbs">
-                                Experiment &nbsp;>&nbsp; {{ slice }}
+                                Experiment &nbsp;>&nbsp; Slice: {{ slice }}
                         </div>
                </div>
        </div>
                <div class="col-md-12">
 {% if section == "resources" %}
 <ul class="nav nav-tabs nav-section">
-       <li><a href="/slice/{{ slice }}#info">Information</a></li>
+       
        <!-- <li><a href="/slice/{{ slice }}#testbeds">Testbeds</a></li> -->
        <li class="active"><a class="link" href="/resources/{{ slice }}">Resources</a></li>
        <li><a href="/slice/{{ slice }}#users">Users</a></li>
+       <li><a href="/slice/{{ slice }}#info">Information</a></li>
        <!-- <li><a href="/slice/{{ slice }}#experiment">Statistics</a></li> -->
        <!-- <li><a href="/slice/{{ slice }}#experiment">Measurements</a></li> -->
        <li><a href="/slice/{{ slice }}#experiment">Tools</a></li>
 </ul>
 {% else %}
 <ul class="nav nav-tabs nav-section">
-       <li class="active"><a href="#info">Information</a></li>
        <!-- <li class="testbeds"><a href="#testbeds">Testbeds</a></li> -->
        <li><a class="link" href="/resources/{{ slice }}">Resources</a></li>
        <li class="users"><a href="#users">Users</a></li>
+       <li class="active"><a href="#info">Information</a></li>
        <!-- <li class="statistics"><a href="#experiment">Statistics</a></li> -->
        <!-- <li class="measurements"><a href="#experiment">Measurements</a></li> -->
        <li class="experiment"><a href="#experiment">Tools</a></li>
index a4fae39..10fbbe1 100644 (file)
@@ -20,9 +20,9 @@
                                        </div>
                                </li>
                                {%if 'is_pi'  in pi %}  
-                               <li id="nav-institution" class=""><a href="/portal/institution">MANAGEMENT</a></li>
+                               <li id="nav-institution" class=""><a href="/institution">MANAGEMENT</a></li>
                                 {%endif%}
-                               <li><a href="/portal/support/">SUPPORT</a></li>
+                               <li><a href="/support/">SUPPORT</a></li>
                        </ul>
                </div>
                {% else %}
                <div class="col-sm-5 col-md-5 secondary">
                        <ul>
                                <li><a href="/news">News</a></li>
-                               <li><a href="/portal/about">About</a></li>
-                               <li><a target="_blank" href="http://new.onelab.eu">Public Website</a></li>
+                               <li><a href="/about">About</a></li>
+                               <li><a target="_blank" href="https://www.onelab.eu">Public Website</a></li>
                                <li><a target="_blank" href="http://intranet.onelab.eu">Intranet</a></li>
                        </ul>
                        {% if username %}
-                       <div class="account">You are logged in as &nbsp;<a href="/portal/account/">{{ username }}</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a id="logout" style="cursor:pointer;" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
+                       <div class="account">You are logged in as &nbsp;<a href="/account/">{{ username }}</a> &nbsp;&nbsp;|&nbsp;&nbsp; <a id="logout" style="cursor:pointer;" data-username="{{ username }}"><span class="glyphicon glyphicon-off"></span> Logout</a></div>
                        {% endif %}
                </div>
        </div>
index 868f818..eed94a0 100644 (file)
@@ -19,7 +19,7 @@
        <div class="col-md-3">
                <form action="" method="post">{% csrf_token %}
                {{ form.new_password1.errors }}
-               <label for="id_new_password1">{% trans 'New password:' %}</label>
+               <label for="id_new_password1">New password:</label>
        </div>
        <div class="col-md-3">
                {{ form.new_password1 }}
@@ -28,7 +28,7 @@
 <div class="row">
        <div class="col-md-3">
                {{ form.new_password2.errors }}
-               <label for="id_new_password2">{% trans 'Confirm password:' %}</label>
+               <label for="id_new_password2">Confirm password:</label>
        </div>
        <div class="col-md-3">  
                {{ form.new_password2 }}
index ab6776c..ef29d3d 100644 (file)
@@ -4,20 +4,24 @@
 
 <div class="row">
        <div class="col-md-12">
-       <h1><img src="{{ STATIC_URL }}icons/user-xs.png" alt="User Registration" />User sign-up</h1>
+               <h1><img src="{{ STATIC_URL }}icons/user-xs.png" alt="User Registration" />User sign-up</h1>
        </div>
 </div>
 <div class="row">
        <div class="col-md-12">
                <p><strong>Questions? <a href="/portal/contact" >Contact us.</a></strong></p>
-  </div>
+       </div>
 </div>
 {% if errors %}
-<ul>
-  {% for error in errors %}
-  <li>{{ error }}</li>
-  {% endfor %}
-</ul>
+<div class="row">
+       <div class="col-md-12">
+               <ul>
+                 {% for error in errors %}
+                 <li>{{ error }}</li>
+                 {% endfor %}
+               </ul>
+       </div>
+</div>
 {% endif %}
 <div class="row">
        <div class="col-md-12">
                </div>
        </div>  
 
-       <!-- LOGIN
-       TODO: Login should be suggested from user email or first/last name, and
-       checked for existence. In addition, the full HRN should be shown to the
-       user.
-    <div class="form-group">
-      <label for="login" class="col-xs-2 control-label">Login</label>
-      <div class="col-xs-4">
-         <input type="text" name="login" size="25" class="form-control" minlength="2" value="{{ login }}" placeholder="Login" required />
-      </div>
-      <div class="col-xs-6"><p class="form-hint">Enter your login</p></div>
-    </div>
-       -->
        <div class="col-md-6">
            <div class="form-group">
              <label for="password" class="control-label">Authentication</label>
                  <p></p>       
              <input type="password"  id="password" name="password"   class="form-control" style="width:250px" minlength="4" value="{{ password }}" 
                        title="Your password allows you to log in to this portal."
-                       placeholder="Password" required/>
+                       placeholder="Password" required />
            </div>
            <div class="form-group">
                        <input type="password"  id="confirmpassword" name="confirmpassword" style="width:250px"  minlength="4" class="form-control" value="" 
-                               placeholder="Confirm password" required/>
+                               placeholder="Confirm password" required />
            </div>
            <div class="form-group">
                <!--<label for="question" class="control-label">Keys</label> -->
                                , with documentation on how to use the tools, pointers to documentation for individual testbeds, and a helpdesk to respond to user questions.
                                </li>
                                        </ul>
-<p align="left">
-    Additional support, such as accompaniment through the design and deployment of experiments and the interpretation of their results, is available through
-    higher levels of service.
-</p>
-<h2 align="left">
-    2.2 Best effort, without guarantees
-</h2>
-<p align="left">
-    OneLab and the owners of the individual OneLab testbeds do their best to provide the services outlined here, with the understanding that Basic level
-    service offers no guarantees. Users should clearly understand the following limitations.
-</p>
-<ul type="disc">
-    <li>
-        <strong>Reliability:</strong>
-        OneLab does not provide any guarantees with respect to the reliability of the portal, of other tools, or of the individual nodes on platforms. These
-        may be taken down for maintenance, rebooted, or reinstalled at any time. Reinstallation implies that disks are wiped, meaning that users should not
-        consider a local disk to be a persistent form of storage.
-    </li>
-    <li>
-        <strong>Fitness:</strong>
-        OneLab does not guarantee that the platforms are suitable for the experiments that users intend to conduct. There may be limitations in the
-        technologies that are offered that prevent certain types of experiments from being carried out.
-    </li>
-    <li>
-        <strong>Privacy</strong>
-        : OneLab does not guarantee the privacy of traffic generated on the platforms (e.g., wireless signals, packets). Unless otherwise specified by an
-        individual platform owner, users should assume that traffic is monitored and logged. Such monitoring may be done intentionally, for example, to allow
-        platform administrators as well as other users to investigate abuse.
-    </li>
-</ul>
-<p align="left">
-    Users who seek such guarantees are invited to consider a higher level of service.
-</p>
-<h2 align="left">
-    2.3 Limitedliability
-</h2>
-<p align="left">
-    In no event shall the partners of the OneLab consortium be liable to any user for any consequential, incidental, punitive, or lost profit damages, or for
-    any damages arising out of loss of use or loss of data, to the extent that such damages arise out of the activities of OneLab consortium partners, or any
-    breach of the present terms and conditions, even if the consortium partner has been advised of the possibility of such damages.
-</p>
-<p align="left">
-    Nothing contained in these terms and conditions shall be deemed as creating any rights or liabilities in or for third parties who are not Basic level users
-    of OneLab.
-</p>
-<h1 align="left">
-    3 Acceptable use policy
-</h1>
-<h2 align="left">
-    3.1 Responsibilities of managers and standard users
-</h2>
-<p align="left">
-    OneLab creates and administers accounts for managers and delegates to managers the responsibility for creating and administering accounts for standard
-    users. Both managers and standard users are required to follow OneLab's acceptable use policy. In addition, managers are fully responsible for the
-    activities of the standard users whose accounts they create.
-</p>
-<p align="left">
-    A manager is expected to grant user access only an individual with whom he or she has a working relationship. In general, this means an individual who
-    works for the same institution as the manager, or, in the case of higher education and research, an individual who is a student at the university where the
-    manager works. Managers may also grant access to individuals from other institutions, provided that they are collaborating on a common project on OneLab.
-    If there is a doubt, a manager should refer the question to support@onelab.eu.
-</p>
-<h2 align="left">
-    3.2 Types of use
-</h2>
-<p align="left">
-    OneLab may be used by enterprise, by scientific researchers, and by educators.
-</p>
-<p align="left">
-    OneLab may be used for pre-commercial research and development. In keeping with OneLab's not-for-profit status, it may not be used to deploy services that
-    are designed to generate a commercial profit.
-</p>
-<p align="left">
-    Not-for-profit use of OneLab to deploy services that are designed to generate revenue requires prior approval through a written agreement, and thus may not
-    be carried out on a Basic level account. Interested users are invited to contact support@onelab.eu.
-</p>
-<p align="left">
-    OneLab may be used for scientific research.
-</p>
-<p align="left">
-    OneLab may be used to host lab exercises for university courses.
-</p>
-<p align="left">
-    Questions about other types of use should be addressed to support@onelab.eu.
-</p>
-<h2 align="left">
-    3.3 Applicable laws and regulations
-</h2>
-<p align="left">
-    OneLab is managed, and the portal is hosted, in France. Information regarding the countries in which individual testbeds are managed and hosted is
-    available from those testbeds. Users are responsible for being aware of the countries in which their experiments are deployed and for ensuring that their
-    use of OneLab fully conforms to the laws and regulations of those countries, as well as the laws and regulations of the country in which they themselves
-    are present when conducting their experiments.
-</p>
-<p align="left">
-    Above and beyond specific national laws, the activities email spamming, phishing through web services, and all types of Internet fraud are prohibited on
-    OneLab.
-</p>
-<h2>
-    3.4 Security and accounting mechanisms
-</h2>
-<p align="left">
-    Users are expected to respect the security and accounting mechanisms put in place by OneLab, its platforms, and federated platforms. For example, access to
-    PlanetLab Europe is designed to take place through the SSH cryptographically-secured connection protocol, which uses public/private key pair
-    authentication, and so users should not attempt to bypass this mechanism. As another example, OneLab's notion of a "slice" associates a set of resources
-    with the group of users who have reserved those resources, and users should not attempt to obscure the identities of participants in a slice.
-</p>
-<p align="left">
-    Hacking attempts against the OneLab portal and testbeds are not permitted. This includes "red team" (hacker test) experiments.
-</p>
-<h2>
-    3.5 Sharing of resources
-</h2>
-<p align="left">
-    OneLab is intended for ambitious experiments. Large numbers of resources and extended leases on resources may legitimately be granted in order to carry
-    these out. At the same time, OneLab and its testbeds are shared environments, and when there is contention for resources, limits must be imposed.
-</p>
-<p align="left">
-    Each OneLab platform sets its own policies for handling resource contention. As a general rule, users are encouraged to design their experiments to use
-    resources efficiently. In particular, spinning/busy-waiting techniques for extended periods of time are strongly discouraged. Some resource contention
-    policies (e.g., PlanetLab Europe's) terminate the jobs that are using the most resources in the case of contention.
-</p>
-<h2>
-    3.6 Internet-connected platforms
-</h2>
-<p align="left">
-    Some of OneLab's platforms allow experiments to take place on resources that have access to the public internet. These experiments can potentially generate
-    traffic to, and receive traffic from, any host or router in the internet.<a></a><a id="_anchor_1" href="#_msocom_1" name="_msoanchor_1">[LB1]</a>
-</p>
-<p align="left">
-    Furthermore, some internet-connected platforms (e.g., PlanetLab Europe) consist of servers that are hosted by a large number of member institutions.
-</p>
-<p align="left">
-    The accessibility of internet-connected platforms and the distributed hosting model of some of these platforms imply certain responsibilities on the part
-    of users, as detailed below.
-</p>
-<h3>
-    3.6.1 General guidance
-</h3>
-<p align="left">
-    A good litmus test when considering whether an experiment is appropriate for such internet-connected platforms is to ask what the network administrator at
-    one's own organisation would say about the experiment running locally. If the experiment disrupts local activity (e.g., uses more than its share of the
-    site's internet bandwidth) or triggers complaints from remote network administrators (e.g., performs systematic port scans), then it is not appropriate for
-    such internet-connected platforms.
-</p>
-<p align="left">
-    It is the responsibility of the user and the user's manager to ensure that an application that will run on an internet-connected platform is tested and
-    debugged in a controlled environment, to better understand its behaviour prior to deployment.
-</p>
-<h3>
-    3.6.2 Standards of network etiquette
-</h3>
-<p align="left">
-    Internet-connected platforms are designed to support experiments that generate unusual traffic, such as network measurements. However, it is expected that
-    all users adhere to widely accepted standards of network etiquette in an effort to minimise complaints from network administrators. Activities that have
-    been interpreted as worm and denial-of-service attacks in the past (and should be avoided) include sending SYN packets to port 80 on random machines,
-    probing random IP addresses, repeatedly pinging routers, overloading bottleneck links with measurement traffic, and probing a single target machine from
-    many nodes.
-</p>
-<p align="left">
-    For internet-connected platforms that have a distributed hosting model, each host institution will have its own acceptable use policy. Users should not
-    knowingly violate such local policies. Conflicts between local policies and OneLab's stated goal of supporting research into wide-area networks should be
-    brought to the attention of OneLab administrators at support@onelab.eu.
-</p>
-<h3>
-    3.6.3 Specific network usage rules
-</h3>
-<p align="left">
-    It is not allowed to use one or more nodes of an internet-connected platform to generate a high number of network flows or flood a site with high traffic
-    to the point of interfering with its normal operation. Use of congestion-controlled flows for large transfers is highly encouraged.
-</p>
-<p align="left">
-    It is not allowed to perform systematic or random port or address block scans from an internet-connected platform.
-</p>
-<p align="left">
-    For internet-connected platforms that use a distributed hosting model, it is not allowed to spoof or sniff traffic on a hosted server or on the network the
-    server belongs to.
-</p>
-<p align="left">
-    Access to a server on a distributed hosting platform may not be used to gain access to other servers or networked equipment that are not part of the
-    testbed.
-</p>
-<h2>
-    3.7 Wireless platforms
-</h2>
-<p align="left">
-    Wireless-connected platforms give users access to nodes that communicate via Wi-Fi and other wireless technologies. They may be capable of detecting
-    wireless activity in the neighbourhood of those nodes: traffic generated by other users of the platform or by individuals not associated with the platform.
-    In general, much of the traffic will be encrypted, with certain aspects (such as SSIDs) not encrypted, but it is also possible that there will be fully
-    unencrypted traffic. They may also be capable of generating wireless activity that reaches equipment outside of the testbed.
-</p>
-<p align="left">
-    Furthermore, some wireless-connected platforms may have built-in limitations to prevent them from generating signals at a strength that exceeds health and
-    safety regulations.
-</p>
-<p align="left">
-    These characteristics of wireless-connected platforms imply certain responsibilities on the part of users, as detailed below.
-</p>
-<h3>
-    3.7.1 Specific network usage rules
-</h3>
-<p align="left">
-    Experimenters may make no attempt to defeat the encryption of encrypted third-party traffic. Furthermore, experimenters must treat with utmost discretion
-    any unencrypted traffic. Limited metadata can be recorded for the bona fide purposes of an experiment, but under no case should third party communications
-    be recorded.
-</p>
-<p align="left">
-    No attempt may be made to reverse engineer traffic in order to learn the identities of the parties who have generated the traffic.
-</p>
-<p align="left">
-    Wireless-connected platforms may not be used to gain access to any network equipment that is not part of the testbed itself.
-</p>
-<p align="left">
-    It is not allowed to perform systematic or random scans of wireless networks that are not part of a wireless-connected platform. Similarly, it is not
-    allowed to spoof or sniff wireless traffic of the institution that hosts a wireless-connected platform or of other networks in the proximity.
-</p>
-<p align="left">
-    Care must be taken so that traffic on wireless-connected platforms does not interfere with the normal functioning of network equipment that is not part of
-    the testbed itself.
-</p>
-<p align="left">
-    No attempt may be made to defeat the mechanisms that limit signal strength on wireless-connected platforms.
-</p>
-<h2>
-    3.8 Handling suspected violations
-</h2>
-<p align="left">
-    Suspected violations of the OneLab acceptable use policy should be reported to support@onelab.eu.
-</p>
-<p align="left">
-    Upon notification or detection of a possible violation, OneLab management will attempt to understand if a violation has in fact occurred. To do so,
-    management will freely communicate with the users concerned, the operators of the platforms concerned, as well as any third parties that might be involved.
-    An example of a third party is a network operator who detects what they believe to be unauthorized traffic emanating from a OneLab platform.
-</p>
-<p align="left">
-    The priority is to resolve any real or apparent violations amicably. However, if OneLab management believes that a violation may have occurred, it can, at
-    its sole discretion, and without prior notice, apply any of the following measures:
-</p>
-<ul type="disc">
-    <li>
-        notification of the users of the concerned slice (set of resources);
-    </li>
-    <li>
-        disabling of the concerned slice;
-    </li>
-    <li>
-        disabling an individual user's account;
-    </li>
-    <li>
-        reporting of the user's activity to his/her manager;
-    </li>
-    <li>
-        disabling of the manager's account and all user accounts for which the manager is responsible;
-    </li>
-    <li>
-        disabling of all accounts associated with the user's institution.
-    </li>
-</ul>
-<p align="left">
-    In the case of suspected illegal activity, OneLab management might need, without prior notice, to notify the relevant authorities.
-</p>
-<div>
-    <div>
-        <div id="_com_1">
-        </div>
-    </div>
-</div>
+                                       <p align="left">
+                                           Additional support, such as accompaniment through the design and deployment of experiments and the interpretation of their results, is available through
+                                           higher levels of service.
+                                       </p>
+                                       <h2 align="left">
+                                           2.2 Best effort, without guarantees
+                                       </h2>
+                                       <p align="left">
+                                           OneLab and the owners of the individual OneLab testbeds do their best to provide the services outlined here, with the understanding that Basic level
+                                           service offers no guarantees. Users should clearly understand the following limitations.
+                                       </p>
+                                       <ul type="disc">
+                                           <li>
+                                               <strong>Reliability:</strong>
+                                               OneLab does not provide any guarantees with respect to the reliability of the portal, of other tools, or of the individual nodes on platforms. These
+                                               may be taken down for maintenance, rebooted, or reinstalled at any time. Reinstallation implies that disks are wiped, meaning that users should not
+                                               consider a local disk to be a persistent form of storage.
+                                           </li>
+                                           <li>
+                                               <strong>Fitness:</strong>
+                                               OneLab does not guarantee that the platforms are suitable for the experiments that users intend to conduct. There may be limitations in the
+                                               technologies that are offered that prevent certain types of experiments from being carried out.
+                                           </li>
+                                           <li>
+                                               <strong>Privacy</strong>
+                                               : OneLab does not guarantee the privacy of traffic generated on the platforms (e.g., wireless signals, packets). Unless otherwise specified by an
+                                               individual platform owner, users should assume that traffic is monitored and logged. Such monitoring may be done intentionally, for example, to allow
+                                               platform administrators as well as other users to investigate abuse.
+                                           </li>
+                                       </ul>
+                                       <p align="left">
+                                           Users who seek such guarantees are invited to consider a higher level of service.
+                                       </p>
+                                       <h2 align="left">
+                                           2.3 Limitedliability
+                                       </h2>
+                                       <p align="left">
+                                           In no event shall the partners of the OneLab consortium be liable to any user for any consequential, incidental, punitive, or lost profit damages, or for
+                                           any damages arising out of loss of use or loss of data, to the extent that such damages arise out of the activities of OneLab consortium partners, or any
+                                           breach of the present terms and conditions, even if the consortium partner has been advised of the possibility of such damages.
+                                       </p>
+                                       <p align="left">
+                                           Nothing contained in these terms and conditions shall be deemed as creating any rights or liabilities in or for third parties who are not Basic level users
+                                           of OneLab.
+                                       </p>
+                                       <h1 align="left">
+                                           3 Acceptable use policy
+                                       </h1>
+                                       <h2 align="left">
+                                           3.1 Responsibilities of managers and standard users
+                                       </h2>
+                                       <p align="left">
+                                           OneLab creates and administers accounts for managers and delegates to managers the responsibility for creating and administering accounts for standard
+                                           users. Both managers and standard users are required to follow OneLab's acceptable use policy. In addition, managers are fully responsible for the
+                                           activities of the standard users whose accounts they create.
+                                       </p>
+                                       <p align="left">
+                                           A manager is expected to grant user access only an individual with whom he or she has a working relationship. In general, this means an individual who
+                                           works for the same institution as the manager, or, in the case of higher education and research, an individual who is a student at the university where the
+                                           manager works. Managers may also grant access to individuals from other institutions, provided that they are collaborating on a common project on OneLab.
+                                           If there is a doubt, a manager should refer the question to support@onelab.eu.
+                                       </p>
+                                       <h2 align="left">
+                                           3.2 Types of use
+                                       </h2>
+                                       <p align="left">
+                                           OneLab may be used by enterprise, by scientific researchers, and by educators.
+                                       </p>
+                                       <p align="left">
+                                           OneLab may be used for pre-commercial research and development. In keeping with OneLab's not-for-profit status, it may not be used to deploy services that
+                                           are designed to generate a commercial profit.
+                                       </p>
+                                       <p align="left">
+                                           Not-for-profit use of OneLab to deploy services that are designed to generate revenue requires prior approval through a written agreement, and thus may not
+                                           be carried out on a Basic level account. Interested users are invited to contact support@onelab.eu.
+                                       </p>
+                                       <p align="left">
+                                           OneLab may be used for scientific research.
+                                       </p>
+                                       <p align="left">
+                                           OneLab may be used to host lab exercises for university courses.
+                                       </p>
+                                       <p align="left">
+                                           Questions about other types of use should be addressed to support@onelab.eu.
+                                       </p>
+                                       <h2 align="left">
+                                           3.3 Applicable laws and regulations
+                                       </h2>
+                                       <p align="left">
+                                           OneLab is managed, and the portal is hosted, in France. Information regarding the countries in which individual testbeds are managed and hosted is
+                                           available from those testbeds. Users are responsible for being aware of the countries in which their experiments are deployed and for ensuring that their
+                                           use of OneLab fully conforms to the laws and regulations of those countries, as well as the laws and regulations of the country in which they themselves
+                                           are present when conducting their experiments.
+                                       </p>
+                                       <p align="left">
+                                           Above and beyond specific national laws, the activities email spamming, phishing through web services, and all types of Internet fraud are prohibited on
+                                           OneLab.
+                                       </p>
+                                       <h2>
+                                           3.4 Security and accounting mechanisms
+                                       </h2>
+                                       <p align="left">
+                                           Users are expected to respect the security and accounting mechanisms put in place by OneLab, its platforms, and federated platforms. For example, access to
+                                           PlanetLab Europe is designed to take place through the SSH cryptographically-secured connection protocol, which uses public/private key pair
+                                           authentication, and so users should not attempt to bypass this mechanism. As another example, OneLab's notion of a "slice" associates a set of resources
+                                           with the group of users who have reserved those resources, and users should not attempt to obscure the identities of participants in a slice.
+                                       </p>
+                                       <p align="left">
+                                           Hacking attempts against the OneLab portal and testbeds are not permitted. This includes "red team" (hacker test) experiments.
+                                       </p>
+                                       <h2>
+                                           3.5 Sharing of resources
+                                       </h2>
+                                       <p align="left">
+                                           OneLab is intended for ambitious experiments. Large numbers of resources and extended leases on resources may legitimately be granted in order to carry
+                                           these out. At the same time, OneLab and its testbeds are shared environments, and when there is contention for resources, limits must be imposed.
+                                       </p>
+                                       <p align="left">
+                                           Each OneLab platform sets its own policies for handling resource contention. As a general rule, users are encouraged to design their experiments to use
+                                           resources efficiently. In particular, spinning/busy-waiting techniques for extended periods of time are strongly discouraged. Some resource contention
+                                           policies (e.g., PlanetLab Europe's) terminate the jobs that are using the most resources in the case of contention.
+                                       </p>
+                                       <h2>
+                                           3.6 Internet-connected platforms
+                                       </h2>
+                                       <p align="left">
+                                           Some of OneLab's platforms allow experiments to take place on resources that have access to the public internet. These experiments can potentially generate
+                                           traffic to, and receive traffic from, any host or router in the internet.<a></a><a id="_anchor_1" href="#_msocom_1" name="_msoanchor_1">[LB1]</a>
+                                       </p>
+                                       <p align="left">
+                                           Furthermore, some internet-connected platforms (e.g., PlanetLab Europe) consist of servers that are hosted by a large number of member institutions.
+                                       </p>
+                                       <p align="left">
+                                           The accessibility of internet-connected platforms and the distributed hosting model of some of these platforms imply certain responsibilities on the part
+                                           of users, as detailed below.
+                                       </p>
+                                       <h3>
+                                           3.6.1 General guidance
+                                       </h3>
+                                       <p align="left">
+                                           A good litmus test when considering whether an experiment is appropriate for such internet-connected platforms is to ask what the network administrator at
+                                           one's own organisation would say about the experiment running locally. If the experiment disrupts local activity (e.g., uses more than its share of the
+                                           site's internet bandwidth) or triggers complaints from remote network administrators (e.g., performs systematic port scans), then it is not appropriate for
+                                           such internet-connected platforms.
+                                       </p>
+                                       <p align="left">
+                                           It is the responsibility of the user and the user's manager to ensure that an application that will run on an internet-connected platform is tested and
+                                           debugged in a controlled environment, to better understand its behaviour prior to deployment.
+                                       </p>
+                                       <h3>
+                                           3.6.2 Standards of network etiquette
+                                       </h3>
+                                       <p align="left">
+                                           Internet-connected platforms are designed to support experiments that generate unusual traffic, such as network measurements. However, it is expected that
+                                           all users adhere to widely accepted standards of network etiquette in an effort to minimise complaints from network administrators. Activities that have
+                                           been interpreted as worm and denial-of-service attacks in the past (and should be avoided) include sending SYN packets to port 80 on random machines,
+                                           probing random IP addresses, repeatedly pinging routers, overloading bottleneck links with measurement traffic, and probing a single target machine from
+                                           many nodes.
+                                       </p>
+                                       <p align="left">
+                                           For internet-connected platforms that have a distributed hosting model, each host institution will have its own acceptable use policy. Users should not
+                                           knowingly violate such local policies. Conflicts between local policies and OneLab's stated goal of supporting research into wide-area networks should be
+                                           brought to the attention of OneLab administrators at support@onelab.eu.
+                                       </p>
+                                       <h3>
+                                           3.6.3 Specific network usage rules
+                                       </h3>
+                                       <p align="left">
+                                           It is not allowed to use one or more nodes of an internet-connected platform to generate a high number of network flows or flood a site with high traffic
+                                           to the point of interfering with its normal operation. Use of congestion-controlled flows for large transfers is highly encouraged.
+                                       </p>
+                                       <p align="left">
+                                           It is not allowed to perform systematic or random port or address block scans from an internet-connected platform.
+                                       </p>
+                                       <p align="left">
+                                           For internet-connected platforms that use a distributed hosting model, it is not allowed to spoof or sniff traffic on a hosted server or on the network the
+                                           server belongs to.
+                                       </p>
+                                       <p align="left">
+                                           Access to a server on a distributed hosting platform may not be used to gain access to other servers or networked equipment that are not part of the
+                                           testbed.
+                                       </p>
+                                       <h2>
+                                           3.7 Wireless platforms
+                                       </h2>
+                                       <p align="left">
+                                           Wireless-connected platforms give users access to nodes that communicate via Wi-Fi and other wireless technologies. They may be capable of detecting
+                                           wireless activity in the neighbourhood of those nodes: traffic generated by other users of the platform or by individuals not associated with the platform.
+                                           In general, much of the traffic will be encrypted, with certain aspects (such as SSIDs) not encrypted, but it is also possible that there will be fully
+                                           unencrypted traffic. They may also be capable of generating wireless activity that reaches equipment outside of the testbed.
+                                       </p>
+                                       <p align="left">
+                                           Furthermore, some wireless-connected platforms may have built-in limitations to prevent them from generating signals at a strength that exceeds health and
+                                           safety regulations.
+                                       </p>
+                                       <p align="left">
+                                           These characteristics of wireless-connected platforms imply certain responsibilities on the part of users, as detailed below.
+                                       </p>
+                                       <h3>
+                                           3.7.1 Specific network usage rules
+                                       </h3>
+                                       <p align="left">
+                                           Experimenters may make no attempt to defeat the encryption of encrypted third-party traffic. Furthermore, experimenters must treat with utmost discretion
+                                           any unencrypted traffic. Limited metadata can be recorded for the bona fide purposes of an experiment, but under no case should third party communications
+                                           be recorded.
+                                       </p>
+                                       <p align="left">
+                                           No attempt may be made to reverse engineer traffic in order to learn the identities of the parties who have generated the traffic.
+                                       </p>
+                                       <p align="left">
+                                           Wireless-connected platforms may not be used to gain access to any network equipment that is not part of the testbed itself.
+                                       </p>
+                                       <p align="left">
+                                           It is not allowed to perform systematic or random scans of wireless networks that are not part of a wireless-connected platform. Similarly, it is not
+                                           allowed to spoof or sniff wireless traffic of the institution that hosts a wireless-connected platform or of other networks in the proximity.
+                                       </p>
+                                       <p align="left">
+                                           Care must be taken so that traffic on wireless-connected platforms does not interfere with the normal functioning of network equipment that is not part of
+                                           the testbed itself.
+                                       </p>
+                                       <p align="left">
+                                           No attempt may be made to defeat the mechanisms that limit signal strength on wireless-connected platforms.
+                                       </p>
+                                       <h2>
+                                           3.8 Handling suspected violations
+                                       </h2>
+                                       <p align="left">
+                                           Suspected violations of the OneLab acceptable use policy should be reported to support@onelab.eu.
+                                       </p>
+                                       <p align="left">
+                                           Upon notification or detection of a possible violation, OneLab management will attempt to understand if a violation has in fact occurred. To do so,
+                                           management will freely communicate with the users concerned, the operators of the platforms concerned, as well as any third parties that might be involved.
+                                           An example of a third party is a network operator who detects what they believe to be unauthorized traffic emanating from a OneLab platform.
+                                       </p>
+                                       <p align="left">
+                                           The priority is to resolve any real or apparent violations amicably. However, if OneLab management believes that a violation may have occurred, it can, at
+                                           its sole discretion, and without prior notice, apply any of the following measures:
+                                       </p>
+                                       <ul type="disc">
+                                           <li>
+                                               notification of the users of the concerned slice (set of resources);
+                                           </li>
+                                           <li>
+                                               disabling of the concerned slice;
+                                           </li>
+                                           <li>
+                                               disabling an individual user's account;
+                                           </li>
+                                           <li>
+                                               reporting of the user's activity to his/her manager;
+                                           </li>
+                                           <li>
+                                               disabling of the manager's account and all user accounts for which the manager is responsible;
+                                           </li>
+                                           <li>
+                                               disabling of all accounts associated with the user's institution.
+                                           </li>
+                                       </ul>
+                                       <p align="left">
+                                           In the case of suspected illegal activity, OneLab management might need, without prior notice, to notify the relevant authorities.
+                                       </p>
+
                                </div>
                                <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                </div>
                        </div>
                        </div>
-               </div>
+</div>
 
     
 <script>
@@ -494,9 +481,9 @@ jQuery(document).ready(function(){
         {% for authority in authorities %}
             {% if authority.name %}
                 {value:"{{ authority.name }}",label:"{{authority.name}}"},
-                       // to show only full name
-           // {% else %}
-           //     {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
+                       // show hrn if we don't have the name
+            {% else %}
+                {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
             {% endif %}
         {% endfor %}    
     {% else %}
diff --git a/portal/templates/reputation.html b/portal/templates/reputation.html
new file mode 100644 (file)
index 0000000..c000ee9
--- /dev/null
@@ -0,0 +1,436 @@
+{% extends "layout-unfold1.html" %}\r
+\r
+{% block head %}\r
+{{ wizard.form.media }}\r
+{% endblock %}\r
+\r
+{% block unfold_main %}\r
+\r
+<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/css/onelab.css" />\r
+\r
+<!-- Reputation Specific -->\r
+<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}reputation_static/css/main.css" />\r
+\r
+<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}reputation_static/css/jquery-ui-1.9.2.custom.min.css" />\r
+\r
+<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}reputation_static/css/jquery.rating.css" /> \r
+\r
+<script src="{{STATIC_URL}}reputation_static/js/jquery-1.9.0.min.js" type="text/javascript"></script>\r
+<script type="text/javascript" src="{{STATIC_URL}}reputation_static/js/ui/jquery-ui-1.9.2.custom.min.js"></script>\r
+<script type="text/javascript" src="{{STATIC_URL}}reputation_static/js/jquery.raty.min.js"></script>\r
+ <style>\r
+       #slicelist a {\r
+               color: rgb(96, 96, 216);\r
+               width:75% !important;\r
+       }\r
+       \r
+       .ui-accordion-header, .ui-accordion-content {\r
+               width:120% !important;\r
+       }\r
+       \r
+       ul {\r
+               list-style: none;\r
+               margin: 0;\r
+               padding: 0;\r
+       }\r
+       ul > li {\r
+               margin: 0;\r
+               padding: 0 0 8px 0;\r
+               height: 25px;\r
+       }\r
+       ol > li {\r
+               height: 60px;\r
+       }\r
+       #slicelist li:last-child {\r
+               padding: 0;\r
+       }\r
+       #slicelist {\r
+               width: 50%;\r
+       }\r
+\r
+       #scoreform {\r
+               width: 500px;\r
+       }\r
+       #submit {\r
+               text-align: center;\r
+       }\r
+       \r
+       #scoreform > ol > li > div > input:first-child {\r
+               margin: 4px 3px 0 0;\r
+       }\r
+       #scoreform > ol > li > div > input:last-child {\r
+               margin: 4px 3px 0 10px;\r
+       }\r
+</style> \r
+\r
+<div id='rep-container' align="center" style="text-align:left;margin-left:1%;"> \r
+\r
+\r
+       <div id="tabs">\r
+         <ul>\r
+           <li><a href="#tabs-1">Testbeds' Reputation</a></li>\r
+           <li><a href="#tabs-2">Evaluate your experiments</a></li>\r
+         </ul>\r
+         <div id="tabs-1">\r
+       \r
+                         \r
+               <table class="reptable table table-bordered table-hover">\r
+                   <tr class="odd">\r
+                               <th> Testbed </th>\r
+                               {% for service in rep_serv %}\r
+                                               <th id='service{{forloop.counter}}' class='{{service}}-class'>Service: {{ service}} </th>\r
+                               {%endfor%}\r
+                   </tr>\r
+                   \r
+                   \r
+                   {% for testbed_rep in reputation %}\r
+                           <tr class="border_bottom">\r
+                               <td class="odd">\r
+                                                       <span> {{ testbed_rep.testbed }} </span>         \r
+                                               </td>\r
+                                       \r
+                                       {% for tb_serv in testbed_rep.services %}\r
+                                               <td>\r
+                                                       {{tb_serv}}\r
+                                               </td>\r
+                                       {%endfor%}\r
+                                               \r
+                           </tr>\r
+                   {%endfor%}\r
+                               \r
+               </table>    \r
+           \r
+         </div>\r
+         <div id="tabs-2">\r
+               <h1>Experiment Evaluation</h1>\r
+               <p><b>List of your unrated experiments</b></p><div id="slicelist">\r
+                       \r
+                       {% for aslice in slicelist %}\r
+                       <h3>Slice <b>{{ aslice.slice_hrn }}</b></h3>\r
+                       <div style="padding-bottom:0;padding-top:0;">\r
+                           <ul><li>\r
+                                   experiment from <b>{{ aslice.start_t }}</b> to <b>{{ aslice.end_t }}</b> | <a href="#" class="rate_button" data-resid={{ aslice.id }}>Rate it</a>\r
+                                       </ul>\r
+                       </div>\r
+               \r
+               \r
+                       {%endfor%}\r
+               </div>  \r
+       \r
+         </div>\r
+       </div>\r
+\r
+</div>\r
+\r
+\r
+<div id="scoreform" style="display:none">\r
+    <ol>\r
+        <li>\r
+            <span>How was your overall experience with NETMODE Testbed?</span> \r
+            <div id="q1">\r
+            </div>\r
+        </li>\r
+       <li>\r
+            Did you experience any problems during the experiment?\r
+            <div id="q2">\r
+                <input type="radio" name="q2" value="1" />Yes\r
+                <input type="radio" name="q2" value="0" />No\r
+            </div>\r
+        </li>\r
+\r
+        <li>\r
+            How would you rate the provided user support (instructions, tutorials, email support)?\r
+            <div id="q3">\r
+            </div>\r
+        </li>\r
+        <li>\r
+            Would you use NETMODE testbed again?\r
+            <div id="q4">\r
+                <input type="radio" name="q4" value="1" />Yes\r
+                <input type="radio" name="q4" value="0" />No\r
+            </div>\r
+        </li>\r
+        <li>\r
+            Would you be willing to pay for this service?\r
+            <div id="q5">\r
+                <input type="radio" name="q5" value="1" />Yes\r
+                <input type="radio" name="q5" value="0" />No\r
+            </div>\r
+        </li>\r
+        <li>\r
+            How would you rate the Node Availability in the experiment?\r
+            <div id="q6">\r
+            </div>\r
+        </li>\r
+        <li>\r
+            How would you rate the Link Quality regarding PDR in the experiment (1:Very Low, 5:Very High )?\r
+            <div id="q7">\r
+            </div>\r
+        </li>\r
+        <li>\r
+            Rate your level of certainty regarding your answers above?\r
+            <div id="q8">\r
+            </div>\r
+        </li>\r
+\r
+    </ol>\r
+    <div id="submit">\r
+        <a href="#">Submit &raquo;</a>\r
+    </div>\r
+</div>\r
+\r
+\r
+</div>\r
+\r
+\r
+       <div id='temp_log' style="display: none;">\r
+\r
+        <table class="mytable table table-bordered table-hover">\r
+            <tr class="odd">\r
+               <th>User Email</th>\r
+                <th>User HRN</th>\r
+                               <th>Slice HRN</th>\r
+                               <th>Resources</th>\r
+                               <th>Leases</th>\r
+                               \r
+            </tr>\r
+            \r
+            {% for slice in slices_users %}\r
+            <tr class="border_bottom">\r
+                <td class="odd">\r
+                                       <a href="/portal/user/{{slice.user}}"><span class="glyphicon glyphicon-search"></span></a>      \r
+                                       {{ slice.user }} \r
+                               </td>\r
+                               <td class="odd"> {{ slice.user_hrn }} </td>\r
+                               <td class="even"> {{ slice.slice_hrn }} </td>\r
+                               <td class="even"> {{ slice.resource }} </td>\r
+                               <td class="even"> {{ slice.lease }} </td>\r
+                               \r
+            </tr>\r
+            {%endfor%}\r
+                        \r
+        </table>\r
+\r
+               <div id='logging_out'>{{ logging_test }}</div>\r
+        \r
+       </div>\r
+\r
+<!-- END of Reputation Specific -->\r
+\r
+\r
+<div class="onelab-title well-lg">\r
+  <h2>Onelab Support</h2>\r
+  <h4>If you have already registered, then please send an <a href="mailto:support@myslice.info">e-mail</a>\r
+  or <a href="http://trac.myslice.info/" >visit us</a></h4>\r
+</div>\r
+\r
+\r
+<!-- Reputation Specific -->\r
+\r
+<script type="text/javascript">\r
+\r
+serv_per_tb = jQuery.parseJSON('{{ serv_per_tb|safe }}');\r
+\r
+$(function() {\r
+       $( "#tabs" ).tabs();\r
+});\r
+\r
+var data = jQuery.parseJSON('{{ json_data|safe }}');\r
+\r
+\r
+\r
+\r
+var resid = -1;\r
+var q1 = -1;\r
+var q2 = -1;\r
+var q3 = -1;\r
+var q4 = -1;\r
+var q5 = -1;\r
+var q6 = -1;\r
+var q7 = -1;\r
+var q8 = -1;\r
+\r
+function initDialog() {\r
+       \r
+       \r
+    $("input:radio").removeAttr("checked");\r
+    $("#submit > a").click(function() {\r
+        if ($("#q2 input:checked").val()) {\r
+            q2 = $("#q2 input:checked").val();\r
+        }\r
+        if ($("#q4 input:checked").val()) {\r
+            q4 = $("#q4 input:checked").val();\r
+        }\r
+        if ($("#q5 input:checked").val()) {\r
+            q5 = $("#q5 input:checked").val();\r
+        }\r
+\r
+        $("a[data-resid='"+resid+"']").css("text-decoration", "line-through").unbind("click").removeAttr("href");\r
+\r
+        //TODO: check input if valid before submitting\r
+\r
+        sum = q1 + q2 + q3 + q4 + q5 + q6 + q7 +q8;\r
+\r
+        if (sum == -8) {\r
+            alert("Please provide at least one rating to submit");\r
+        }\r
+        else {\r
+            $("#scoreform").dialog("close");\r
+            slicedata = {};\r
+               for(var event in data){\r
+                               if ((data[event]).id == resid) {\r
+                                       slicedata = (data[event]);\r
+                               }       \r
+                       }\r
+                       \r
+\r
+                       \r
+                       slicedata["user_eval"] = {'overall':q1, 'problems':q2, 'support':q3, 'reuse':q4, 'pay':q5, 'availability':q6, 'link_quality':q7, 'quality':q8};\r
+                       testbeds_str = JSON.stringify(slicedata['testbeds'])\r
+                       delete slicedata['testbeds'];\r
+            //console.log(JSON.stringify(slicedata))\r
+                        \r
+            $.ajax({\r
+                   type: "GET",\r
+                   url: "reputation/submit_eval",\r
+                   data: {slicedata: slicedata, testbeds: testbeds_str},\r
+                   accepts: "application/json",\r
+                   success: function (data) {\r
+                       var json = $.parseJSON(data);\r
+                       console.log(json);\r
+                       },\r
+                   error: function(xhr,errmsg,err) {\r
+                       alert(" X " + errmsg + " X " + err+ ": " + xhr.responseText);\r
+                   }\r
+               });\r
+        }\r
+\r
+        return false;\r
+    });\r
+    $("#q1").raty({\r
+        number: 5,\r
+        size: 24,\r
+        starOn: 'static/reputation_static/img/star-on.png',\r
+        starOff: 'static/reputation_static/img/star-off.png',\r
+        click: function(score, evt) {\r
+            q1 = score;\r
+        }\r
+    });\r
+    $("#q3").raty({\r
+        number: 5,\r
+        size: 24,\r
+        starOn: 'static/reputation_static/img/star-on.png',\r
+        starOff: 'static/reputation_static/img/star-off.png',\r
+        click: function(score, evt) {\r
+            q3 = score;\r
+        }\r
+    });\r
+    $("#q6").raty({\r
+        number: 5,\r
+        size: 24,\r
+        starOn: 'static/reputation_static/img/star-on.png',\r
+        starOff: 'static/reputation_static/img/star-off.png',\r
+        click: function(score, evt) {\r
+            q6 = score;\r
+        }\r
+    });\r
+    $("#q7").raty({\r
+        number: 5,\r
+        size: 24,\r
+        starOn: 'static/reputation_static/img/star-on.png',\r
+        starOff: 'static/reputation_static/img/star-off.png',\r
+        click: function(score, evt) {\r
+            q7 = score;\r
+        }\r
+    });\r
+    $("#q8").raty({\r
+        number: 5,\r
+        size: 24,\r
+        starOn: 'static/reputation_static/img/star-on.png',\r
+        starOff: 'static/reputation_static/img/star-off.png',\r
+        click: function(score, evt) {\r
+            q8 = score;\r
+        }\r
+    });\r
+}\r
+$(function() {\r
+    /* \r
+        vars with answers to questions\r
+    */\r
+\r
+    $("#slicelist").accordion({\r
+        heightStyle: "content"\r
+    });\r
+\r
+    initDialog();\r
+               \r
+    clone = $("#scoreform").clone(true);\r
+\r
+    $(".rate_button").click(function() {\r
+        q1 = -1;\r
+        q2 = -1;\r
+        q3 = -1;\r
+        q4 = -1;\r
+        q5 = -1;\r
+        q6 = -1;\r
+               q7 = -1;\r
+               q8 = -1;\r
+        resid = $(this).attr("data-resid"); \r
+        \r
+        slicedata = {};\r
+       for(var event in data){\r
+                       if ((data[event]).id == resid) {\r
+                               slicedata = (data[event]);\r
+                       }       \r
+               }       \r
+\r
+               srv_arr = []            \r
+        for (var tb in slicedata["testbeds"]){ \r
+               for (var srv in serv_per_tb[tb]){ \r
+                       if (srv != 'equals') {\r
+                               //console.log(serv_per_tb[tb][srv]); \r
+                               srv_arr.push(serv_per_tb[tb][srv]) \r
+                       } \r
+               } \r
+        }     \r
+        \r
+        cq1 = "overall";\r
+        cq6 = "availability";\r
+        cq7 = "link_quality";\r
+        \r
+        q_to_remove = []\r
+        \r
+        if ($.inArray(cq1, srv_arr) == -1 ){\r
+               $("#scoreform > ol").children(':eq('+0+')').remove();\r
+        } \r
+        if ($.inArray(cq6, srv_arr) == -1 ){\r
+               $("#scoreform > ol").children(':eq('+5+')').remove();\r
+        } \r
+               if ($.inArray(cq7, srv_arr) == -1 ){\r
+               $("#scoreform > ol").children(':eq('+6+')').remove();\r
+        } \r
+        \r
+        $("#scoreform").dialog({\r
+            title: "Rate experiment",\r
+            width: 500,\r
+            modal: true,\r
+            draggable: false,\r
+            resizable: false,\r
+            hide: "fade",\r
+            close : function() {\r
+                $(this).dialog("destroy");\r
+                $("#scoreform").remove();\r
+                $("body").append(clone); \r
+                initDialog();\r
+            }\r
+        });\r
+        return false;\r
+    }); \r
+    \r
+\r
+});\r
+</script>\r
+\r
+<!-- END of Reputation Specific -->\r
+\r
+{% endblock %}
\ No newline at end of file
index f3293ad..0d0a03b 100644 (file)
@@ -1,10 +1,10 @@
-{% extends "layout-unfold1.html" %}
+{% extends "layout.html" %}
 
-{% block unfold_main %}
+{% block content %}
 
-  <h1>Slice created !</h1>
+  <h1>Slice created</h1>
 
-As you are a PI of the site, you slice has directly been created.
+As a manager of your institution, your slice has directly been created directly.
 
 {% endblock %}
 
index a8a9ac9..ff1fc3e 100644 (file)
@@ -26,20 +26,6 @@ $(document).ready(function() {
                {{filter_testbeds}}
        </div>
        <div class="col-md-10" style="height:100%;">
-               <!-- <div class="row slice-pending">
-                       <ul class="nav nav-pills">
-                               <li><a href="">Unreserved</a></li>
-                               <li><a href="">Reserved</a></li>
-                               <li><a href="">Pending<span class="badge" id="badge-pending" style="display:none;"></span></a></li>
-                               <li>
-                                       <button type="button" class="btn btn-primary apply" id="ApplyPendind">Apply</button>
-                                       <button type="button" class="btn btn-default clear">Clear</button>
-                               </li>
-                               <li>
-                                       <div id="loading" style="display:none;"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading" /></div>
-                               </li>
-                       </ul>
-               </div> -->
                <div class="row">
                        {% if msg %}
                        <div class="col-md-12"><p class="alert-success">{{ msg }}</p></div>
@@ -47,10 +33,10 @@ $(document).ready(function() {
                </div>
        
                <div class="row">
-                       <div class="col-md-4">
+                       <div class="col-md-6">
                                {{ filter_status }}
                        </div>
-                       <div class="col-md-2">
+                       <div class="col-md-1">
                                {{ apply }}
                        </div>
                </div>
@@ -68,6 +54,8 @@ $(document).ready(function() {
                        <ul class="nav nav-tabs">
                          <li class="active"><a href="#resourcelist" role="tab" data-toggle="tab">Table</a></li>
                          <li> <a href="#resourcemap" role="tab" data-toggle="tab">Map</a></li>
+              <li> <a href="#openflowcontroller" role="tab" data-toggle="tab">OpenFlow Controller</a></li>
+              <li> <a href="#resourceflowspace" role="tab" data-toggle="tab">Flowspace</a></li>
                          <li> <a href="#resourcescheduler" role="tab" data-toggle="tab">Scheduler</a></li>
                        </ul>
                        </div>
@@ -97,13 +85,31 @@ $(document).ready(function() {
                        <div class="tab-content" style="height:100%;">
                                <div class="tab-pane active" id="resourcelist">
                                         <!-- Button trigger modal - columns selector -->
-                                       <button class="btn btn-primary btn-sm" style="float:right;" data-toggle="modal" data-target="#myModal">...</button>
+                                       <button class="btn btn-default btn-sm" style="float:right;" data-toggle="modal" data-target="#myModal">...</button>
                        {{list_resources}}
                                        <!-- <table cellpadding="0" cellspacing="0" border="0" class="table" id="objectList"></table> -->
                                </div>
                                <div class="tab-pane" id="resourcemap">
                        {{map_resources}}
                                </div>
+                <div class="tab-pane" id="openflowcontroller">
+                    <p>{{vms_list}}</p>
+                    <p>{{vm_form}}</p>
+
+                    <p>{{below_table}}</p>
+                </div>
+
+                <div class="tab-pane" id="resourceflowspace">
+                    <p>{{welcome}}</p>
+                    <p>{{flowspaces}}</p>
+                    <p>{{flowspaces_form}}</p>
+                    <p>{{oflowspaces_form}}</p>
+                    <p>{{topology}}</p>
+                    <p>{{resources}}</p>
+
+                    <p>{{below_table}}</p>
+                </div>
+
                                <div class="tab-pane" id="resourcescheduler">
                        {{scheduler}}
                                </div>
index db9b282..9dca1d1 100644 (file)
@@ -1,8 +1,95 @@
 <div class="col-md-2">
 </div>
 <div class="col-md-8">
-       <h2>Secure Shell (SSH)</h2>
-       <p><img src="{{ STATIC_URL }}img/terminal_icon.png" width="50"></p>
+       <h2>How to access your slice</h2>
+       <h3>PlanetLab Europe</h3>
+       
+       <p>
+               PlanetLab Europe resources are accessible directly via SSH. Your SSH public key is deployed automatically
+               on the reserved nodes. To access your slice on a resource just type the following command:
+       </p>
+       {%if ple_resources%}
+       <p class="command">
+       {%for resource in ple_resources %}
+               $ ssh {{ple_slicename}}@{{resource}}<br>
+       {%endfor%}
+       </p>
+       {%else%}
+               <p><b>NOTE:</b> You did not reserve any PLE resources yet. Once reserved, you will get the actual SSH command. A specimen command is given below:</p>
+               <p class="command">
+               $ ssh {{ple_slicename}}@planetlab-resource.hostname.com<br>
+               </p>
+       {%endif%}
+       <p><strong>NOTE:</strong> Your original slicename <b>{{slicename}}</b> has been converted to PlanetLab specific format <b>{{ple_slicename}}</b> in order to do SSH.</p>
+       <p>Please note that the first '.' is replaced by number 8 and the rest of the dot/s are replaced by underscore/s.</p>
+       <p>
+               Be aware that after you reserve a PlanetLab Europe resource your slice will be deployed with a delay of about 15 minutes, 
+               after witch you will be able to access the resource.
+       </p>
+       
+       <h3>FIT IoT-Lab</h3>
+       <p>FIT IoT-Lab resources are accessible directly via SSH and <a href="https://devgrenoble.senslab.info/testbed/" target="_blank">web GUI.</a>
+               To acess IoT-Lab resources using web GUI, use the same login and  password of OneLab portal. To acess Iot-Lab resources using SSH type
+               the following command:
+       </p>
+       <p class="command">
+               ssh {{username}}@fit3-dev.inrialpes.fr
+       </p>
+       
+       <h3>NITOS</h3>
+       
+       <p>
+        NITOS resources are not directly accessible. You will need to log in on a gateway server and from there access the node.
+        The NITOS server address is nitlab.inf.uth.gr, so to connect to the NITOS server:
+       </p>
+       <p class="command">
+       $ ssh {{slicename}}@nitlab.inf.uth.gr
+       </p>
+       
+       <p>
+       <!-- In order to connect to NITOS server he has to upload his public key on the server. 
+       For now we do it this way: http://nitlab.inf.uth.gr/NITlab/index.php/your-ssh-keys. 
+       I think this is a procedure that needs to be done at the registration phase of the user, 
+       through myslice, Broker etc. but I will answer you in a couple of days for sure. -->
+       </p>
+
+       <p>
+               You will then need to prepare the resource by loading an OMF image on it:
+       </p>
+       
+       <p class="command">
+               $ omf load -i baseline_grid.ndz -t omf.nitos.node016
+       </p>
+
+       <p>
+               Turn on the node:
+       </p>
+       
+       <p class="command">
+               $ omf tell -a on -t omf.nitos.node016
+       </p>
+       <p>
+               And finally ssh on the node:
+       </p>
+       <p class="command">
+               $ ssh root@node016
+       </p>
+       <p>
+               On the node itself you will have to modify the file /etc/omf-resctl-5.3/omf-resctl.yaml according to your slice settings and then
+               restart the OMF Resource Controller and finally execute the experiment:
+       </p>
+       <p class="command">
+               $ omf exec --slice slice_name your_exp.rb
+       </p>
+       <p>
+       The complete tutorial is available at the following address:
+       <a target="_blank" href="http://nitlab.inf.uth.gr/NITlab/index.php/testbed/instructions/basic-tutorial">NITOS basic tutorial</a>
+       </p>
+       
+       <br />
+       
+       <h2>Available Tools</h2>
+       <p><img src="{{ STATIC_URL }}img/terminal_icon.png" width="50"> <b>SSH</b></p>
        <p>
        Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote command-line login, remote command execution, and other secure network services between two networked computers that connects, via a secure channel over an insecure network, a server and a client (running SSH server and SSH client programs, respectively). The protocol specification distinguishes between two major versions that are referred to as SSH-1 and SSH-2.
        </p>
index f0cb9b0..82acd01 100644 (file)
+<script type="text/javascript" src="{{STATIC_URL}}/js/jquery-ui.js"></script>
+<script type="text/javascript" src="{{STATIC_URL}}/js/jquery.qtip.min.js"></script>
+<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/jquery.qtip.min.css">
+<link rel="stylesheet" href="{{ STATIC_URL }}css/jquery-ui.css">
+<script>
+    function get_users_in_slice(authority_hrn){
+        console.log(authority_hrn);
+        $("table#user-tab").html("<tr><th>+/-</th><th>Email</th><th>User hrn</th></tr>");
+       var slice_users = [];
+       var slice_users_removed = [];
+               var slice_users_emails = [];
+       var slice_users_emails_removed = [];
+       $.post("/rest/user/",{'filters':{'parent_authority': authority_hrn}}, function( data ) {
+               var list_users = [];
+               var table_users = [];
+               /* Available fields
+               user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
+           user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
+               */
+               $.each( data, function( key, val ) {
+               list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
+               user_row = "<tr>";
+                       // checking the box for the users that belong to the selected slice
+                       var flag_checkbox = 0;
+                       for(var data in val.slices) {
+                               var element = val.slices[data];
+                               if (element == "{{slice}}"){
+                                       //console.log("the slice is: "+ element);       
+                                       flag_checkbox = 1;
+                                       slice_users.push (val.user_hrn)
+                                       user_row += "<td><input type='checkbox' checked='True' class='user'></td>";
+                               }
+                       }
+                       if(flag_checkbox != 1){
+                       user_row += "<td><input type='checkbox' class='user'></td>";
+                       }
+               user_row += "<td>"+val.user_email+"</td>";
+               user_row += "<td>"+val.user_hrn+"</td>";
+                       //user_row += "<td>"+val.user_enabled+"</td>";
+               user_row += "</tr>";
+               table_users.push(user_row);
+            
+               });
+               $("table#user-tab tr:first").after(table_users.join( "" ));
+               $("div#user-tab-loaded").css("display","block");
+               $("div#user-tab-loading").css("display","none");
+            $("input:checkbox.user").click(function() {
+                user_hrn = $(this).closest('tr').find('td:eq(2)').html();
+                user_email = $(this).closest('tr').find('td:eq(1)').html();
+                if(this.checked){
+                    var record_id = this.id;
+                    slice_users.push (user_hrn);
+                                       slice_users_removed.splice($.inArray(user_hrn, slice_users_removed),1);
+                    slice_users_emails.push (user_email);
+                                       slice_users_emails_removed.splice($.inArray(user_email, slice_users_emails_removed),1); 
+       
+                }else{
+                    slice_users_removed.push (user_hrn);
+                                       slice_users.splice($.inArray(user_hrn, slice_users),1);
+                    slice_users_emails_removed.push (user_email);
+                                       // this one is removing from the list wrong user when u uncheck
+                                       //slice_users_emails.splice($.inArray(user_email, slice_users_emails),1);
+                                       //this one is still buggy cz it still keeps users in both arrays
+                                       // but it's ok for the moment
+                                       slice_users_emails;
+       
+                }
+            });
+       }); // post rest/use
+
+               $('button#addusers').click(function() {
+               $.post("/update/slice/",{'filters':{'slice_hrn':'{{slice}}'},'params':{'users':slice_users}}, function(data) {
+                       if(data.success){
+                       // TODO: highlight row after success
+                       //$('tr[id="'+record_id+'"]').highlight();
+                       mysliceAlert('Success: slice updated','success', true);
+                       }else{
+                       mysliceAlert('Rest Error for: '+data.error,'warning', true);
+                       }
+               }); // post update slice
+                       emails = slice_users_emails.concat(slice_users_emails_removed);
+               $.post("/credentials/clear/",{'emails':emails}, function(data) {
+               }); // post credentials clear
+
+               }); // button#addusers click
+
+    } // get_users_in_slice
+
+    $(document).ready(function() {
+            // TODO: Add a filter based on the list of authorities
+               $.post("/rest/authority/",{'fields':['authority_hrn']}, function( data ) {
+                var list_authorities = [];
+                $.each( data, function( key, val ) {
+                    auth_hrn = val.authority_hrn;
+                    // Keep only the sub authorities, remove root auth
+                    if(auth_hrn.indexOf(".") > -1){
+                        list_authorities.push(auth_hrn);
+                                               list_authorities.sort();
+                        if(auth_hrn=="{{user_details.parent_authority}}"){
+                                                       $('#auth_list').val(auth_hrn);
+                                               }
+                    }
+                });
+                               $( "#auth_list" ).autocomplete({
+                               source: list_authorities,
+                               minLength: 0,
+                               select: function (event, ui) {
+                                               get_users_in_slice(ui.item.value);
+                               }
+                               //select: function( event, ui ) {console.log(jQuery(this))}
+                       });
+            }); // post rest/authority
+
+            get_users_in_slice("{{user_details.parent_authority}}");
+
+       $('[title!=""]').qtip();
+    }); // document ready
+</script>
+
        <div class="col-md-2">
                <div id="select-platform" class="list-group">
                </div>
                        
                <ul class="list-group">
-                 <li class="list-group-item">Authority:<b> {{user_details.parent_authority}}</b>
-                       <!--<select id="auth_list">
-                               <option value="ple.upmc">UPMC</option>
-                               <option value="ple.inria">INRIA</option>
-                               <option value="ple.nitos">NITOS</option>
-                               <option value="ple.iminds">iMinds</option>
-                       </select> -->
-                 </li>
-                 <li class="list-group-item">Filter: slice</li>
-                
+                 <li class="list-group-item">Authority</li>
+                 <li class="list-group-item" style="padding-left:5px;">
+                       <input type="text" id="auth_list"  style ="min-width:190px;" 
+                       title="The default value is  the authority that you belong to and the selected users belong to this slice.
+                                  You can view users of other authorities (organizations) from the list that apears when you click in the field and start to type.
+                                  Use the arrow keys to scroll through the list; type part of the name to narrow down the list."/>
+          </li>
                </ul>
        
        </div>
                <div id="user-tab-loading"><img src="{{ STATIC_URL }}img/loading.gif" alt="Loading Useres" /></div>
                <div id="user-tab-loaded" style="display:none;">
                <table id="user-tab" class="table">
-                       <tr>
-                       <th>+/-</th>
-                       <th>Email</th>
-                       <th>User hrn</th>
-                       <th>Enabled</th>
-                       </tr>
                </table>
 
                 <!-- XXX TODO: for the moment only PIs have access to Update but users that have slice credentials should also have access to that -->
 
-                               {% if 'is_pi'  in pi %}
                                <button id="addusers" type="button" class="btn btn-default"><span class="glyphicon glyphicon-ok"></span> Update users</button>
-                               {%endif%}
                </div>
-<script>
-    $(document).ready(function() {
-            // TODO: Add a filter based on the list of authorities
-               $.post("/rest/authority/",{'fields':['authority_hrn']}, function( data ) {
-                console.log(data);
-            }); // post rest/authority
-
-                       var slice_users = [];
-               $.post("/rest/user/",{'filters':{'parent_authority': "{{user_details.parent_authority}}"}}, function( data ) {
-               var list_users = [];
-               var table_users = [];
-                               /* Available fields
-                               user_gid, user_enabled, slices, pi_authorities, keys, parent_authority, user_first_name,
-                           user_urn, user_last_name, user_phone, user_hrn, user_email, user_type
-                               */
-               $.each( data, function( key, val ) {
-                       list_users.push( "<li><a href=\"portal/user/"+val.user_email+"\">" + val.user_email + "</a></li>" );
-                       user_row = "<tr>";
-                                       // checking the box for the users that belong to the selected slice
-                                       var flag_checkbox = 0;
-                                       for(var data in val.slices) {
-                                       var element = val.slices[data];
-                                               if (element == "{{slice}}"){
-                                                       //console.log("the slice is: "+ element);       
-                                                       flag_checkbox = 1;
-                                                       slice_users.push (val.user_hrn)
-                                                       user_row += "<td><input type='checkbox' checked='True' class='user'></td>";
-                                               }
-                                       }
-                                       if(flag_checkbox != 1){
-                               user_row += "<td><input type='checkbox' class='user'></td>";
-                                       }
-                       user_row += "<td>"+val.user_email+"</td>";
-                       user_row += "<td>"+val.user_hrn+"</td>";
-                                       user_row += "<td>"+val.user_enabled+"</td>";
-                       user_row += "</tr>";
-                       table_users.push(user_row);
-                
-               });
-            
-                               $("table#user-tab tr:last").after(table_users.join( "" ));
-               $("div#user-tab-loaded").css("display","block");
-               $("div#user-tab-loading").css("display","none");
-                $("input:checkbox.user").click(function() {
-                    user_hrn = $(this).closest('tr').find('td:eq(2)').html();
-                    if(this.checked){
-                        var record_id = this.id;
-                        slice_users.push (user_hrn);
-                    }else{
-                        console.log(slice_users);
-                    }
-                });
-           
-               }); // post rest/user
-               $('button#addusers').click(function() {
-                $.post("/update/slice/",{'filters':{'slice_hrn':'{{slice}}'},'params':{'users':slice_users}}, function(data) {
-                       if(data.success){
-                       // TODO: highlight row after success
-                       //$('tr[id="'+record_id+'"]').highlight();
-                       mysliceAlert('Success: slice updated','success', true);
-                       }else{
-                       mysliceAlert('Rest Error for: '+data.error,'warning', true);
-                       }
-                }); // post update slice
-            
-               // TODO: refresh table
-               //window.location="/portal/institution#slices";
-
-            }); // button#addusers click
-
-    }); // document ready
-</script>
 
diff --git a/portal/templates/slice_request_denied.html b/portal/templates/slice_request_denied.html
new file mode 100644 (file)
index 0000000..ab95dee
--- /dev/null
@@ -0,0 +1,20 @@
+<img src="https://onelab.eu/static/images/onelab.png">
+<br>
+<p>Dear OneLab user,</p>
+<p></p>
+<p>You have recently requested the following slice on the OneLab portal({{portal_url}}):</p> 
+<br>
+<b>Slice name   :</b> {{slice_name}}<br>
+<b>URL          :</b> {{url}}<br>
+<b>Purpose      :</b> {{purpose}}<br>
+<br>
+<p>We regret to inform you that, a manager of your institution has not confirmed your request. Please contact the manager of your institution for further information. 
+For any other queries, please contact us by replying to this email.</p>
+<br>
+<p>On behalf of the entire team, I wish you a fruitful user experience on OneLab.</p>
+<br>
+<p>Yours sincerely,</p>
+<br>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
diff --git a/portal/templates/slice_request_denied.txt b/portal/templates/slice_request_denied.txt
new file mode 100644 (file)
index 0000000..521ec5e
--- /dev/null
@@ -0,0 +1,17 @@
+Dear OneLab user,
+
+You have recently requested the following slice on the OneLab portal({{portal_url}}):
+
+Slice name   : {{slice_name}}
+URL          : {{url}}
+Purpose      : {{purpose}}
+We regret to inform you that, a manager of your institution has not confirmed your request. Please contact the manager of your institution for further information. For any other queries, please contact us by replying to this email.
+
+On behalf of the entire team, I wish you a fruitful user experience on OneLab.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
index 417a8bd..4f86902 100644 (file)
@@ -1,11 +1,23 @@
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="https://onelab.eu/static/images/onelab.png">
 <br>
 <h1>NEW SLICE REQUEST</h1>
 <br>
-<b>slice name      :</b> {{slice_name}}</br>
-<b>number of nodes :</b> {{number_of_nodes}}</br>
-<b>purpose         :</b> {{purpose}}</br>
-<b>organization           :</b> {{organization}}
-<b>email           :</b> {{email}}</br>
+<p>You are receiving this request because we have you listed as a manager at an organization that uses OneLab.</p>
+<p>A user from your organization has requested the creation of a new slice, which will allow him or her to reserve testbed resources to conduct an experiment.</p>
+<br>
+<b>Slice name      :</b> {{slice_name}}</br>
+<b>URL                            :</b> {{url}}</br>
+<b>Purpose         :</b> {{purpose}}</br>
+<b>Organization           :</b> {{organization}}</br>
+<b>Email           :</b> {{email}}</br>
 <b>Portal url     :</b> {{current_site}}</br> 
+<p></p>
+<p>You can see new slice request <a href="http://{{current_site}}/portal/validate">in the portal.</a><p>
+<p>Please be sure that you know the user who is requesting this slice, as you are responsible for his or her actions, as described in the 
+<a href="http://{{current_site}}/terms">OneLab terms and conditions.</a></p>
+<p>And kindly ensure that the stated experiment purpose is clear, and, if there is a website that explains the website, that a URL is provided.</p>
+<p>OneLab and its affiliated testbeds exist purely to support useful and interesting work. To ensure the future of these environments, we need to know what work is actually being done.</p>
+<p></p>
+<p>If you believe that you have received this message in error, or if you have any questions, kindly contact support@onelab.eu.</p>
+
 
index 6cd5a2d..997e752 100644 (file)
@@ -1,9 +1,21 @@
 NEW SLICE REQUEST
 
-slice name      : {{slice_name}}
-number of nodes : {{number_of_nodes}}
-purpose         : {{purpose}}
-email           : {{email}}
-organization   : {{organization}}
+You are receiving this request because we have you listed as a manager at an organization that uses OneLab.
+A user from your organization has requested the creation of a new slice, which will allow him or her to reserve testbed resources to conduct an experiment.
+
+Slice name      : {{slice_name}}
+URL                    : {{url}}
+Purpose         : {{purpose}}
+Email           : {{email}}
+Organization   : {{organization}}
 Portal url             : {{current_site}}
 
+You can see new slice request in: http://{{current_site}}/portal/validate
+Please be sure that you know the user who is requesting this slice, as you are responsible for his or her actions, as described in the OneLab terms and conditions:
+       http://{{current_site}}/terms
+And kindly ensure that the stated experiment purpose is clear, and, if there is a website that explains the website, that a URL is provided. 
+OneLab and its affiliated testbeds exist purely to support useful and interesting work. To ensure the future of these environments, we need to know what work is actually being done. 
+
+If you believe that you have received this message in error, or if you have any questions, kindly contact support@onelab.eu.
+
diff --git a/portal/templates/slice_request_validated.html b/portal/templates/slice_request_validated.html
new file mode 100644 (file)
index 0000000..7fac65c
--- /dev/null
@@ -0,0 +1,23 @@
+<img src="https://onelab.eu/static/images/onelab.png">
+<br>
+<p>Dear OneLab user,</p>
+<p></p>
+<p>You have recently requested a slice in the OneLab portal.</p>
+<br>
+<b>Slice name   :</b> {{slice_name}}<br>
+<b>URL          :</b> {{number_of_nodes}}<br>
+<b>Purpose      :</b> {{purpose}}<br>
+<p></p>
+<p>
+       We are pleased to inform you that a manager from your institution has validated your slice request on the OneLab portal. 
+       You can now add resources to you slice and start experimenting.
+</p>
+<p></p>
+<p>On behalf of the entire team, I wish you a fruitful user experience with the OneLab portal.</p>
+<p></p>
+<p>Yours sincerely,</p>
+
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
+
diff --git a/portal/templates/slice_request_validated.txt b/portal/templates/slice_request_validated.txt
new file mode 100644 (file)
index 0000000..993e6ef
--- /dev/null
@@ -0,0 +1,19 @@
+Dear OneLab user,
+
+You have recently requested a slice in the OneLab portal.
+
+Slice name      : {{slice_name}}
+URL             : {{number_of_nodes}}
+Purpose         : {{purpose}}
+
+
+We are pleased to inform you that a manager from your institution has validated your slice request on the OneLab portal. You can now add resources to you slice and start experimenting.
+
+On behalf of the entire team, I wish you a fruitful user experience with the OneLab portal.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
+
index 05c044c..2f6147d 100644 (file)
@@ -5,13 +5,15 @@
 
 {% block unfold_main %}
 
-<center><h1>Book OpenFlow Resources </h1></center>
-
-<p>{{resources}}</p>
+<center><h1>Book OpenFlow Resources</h1></center>
 
 
+<p>{{welcome}}</p>
 <p>{{flowspaces}}</p>
 <p>{{flowspaces_form}}</p>
+<p>{{oflowspaces_form}}</p>
+<p>{{topology}}</p>
+<p>{{resources}}</p>
 
 
 
@@ -19,4 +21,3 @@
 <p>{{below_table}}</p>
       
 {% endblock %}
-
diff --git a/portal/templates/univbrisvtam.html b/portal/templates/univbrisvtam.html
new file mode 100644 (file)
index 0000000..82de78b
--- /dev/null
@@ -0,0 +1,15 @@
+{% extends "layout-unfold1.html" %}
+
+{% block head %}
+{% endblock %}
+
+{% block unfold_main %}
+
+<center><h1>Create New Virtual Machines</h1></center>
+
+<p>{{vms_list}}</p>
+<p>{{vm_form}}</p>
+
+<p>{{below_table}}</p>
+      
+{% endblock %}
index 2bd2f0a..4097b33 100644 (file)
@@ -3,16 +3,20 @@
 {% block content %}
 
 <div class="row">
-       <h1><img src="{{ STATIC_URL }}img/icon_user_small.png" alt="User Registration" /> User sign-up</h1>
+       <div class="col-md-12">
+       <h1><img src="{{ STATIC_URL }}icons/user-xs.png" alt="User Registration" />User sign-up</h1>
+       </div>
 </div>
 <div class="row">
-  <h3>Sign up information received.</h3>
-  <p>You can now log in to the portal. You will have limited access. </p>
-  <p>To gain full access, two steps are required:</p>
-  <ul>
-       <li>1. You confirm your signup request by clicking on the link in the email that we have sent to your email address.</li>
-       <li>2. A manager from your organization validates your request. (We have sent email to your organisation's registered managers.)</li>
-  </ul>                
+       <div class="col-md-12">
+         <h3>Sign up information received.</h3>
+         <p>You can now <a href="/">log in</a> to the portal. You will have limited access. </p>
+         <p>To gain full access, two steps are required:</p>
+         <ul style="list-style-type:decimal;">
+               <li>You confirm your signup request by clicking on the link in the email that we have sent to your email address.</li>
+               <li>A manager from your organization validates your request. (We have sent email to your organisation's registered managers.)</li>
+         </ul>
+       </div>
 </div>
 
 {% endblock %}
diff --git a/portal/templates/user_request_denied.html b/portal/templates/user_request_denied.html
new file mode 100644 (file)
index 0000000..40ad706
--- /dev/null
@@ -0,0 +1,13 @@
+<img src="https://onelab.eu/static/images/onelab.png">
+<br>
+<p>Dear {{first_name}} {{last_name}},</p>
+<p></p>
+<p>You have recently registered as a user to OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.</p>
+<p></p>
+<p>On behalf of the entire team, I wish you all the best.</p>
+<p></p>
+<p>Yours sincerely,</p>
+<p></p>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
+
diff --git a/portal/templates/user_request_denied.txt b/portal/templates/user_request_denied.txt
new file mode 100644 (file)
index 0000000..9f931a2
--- /dev/null
@@ -0,0 +1,11 @@
+Dear {{first_name}} {{last_name}},
+
+You have recently registered as a user to OneLab portal. We are sorry to inform you that, a manager of your institution has rejected your request. Please contact the manager of your institution for further information. For any other queries, contact us by replying to this email.
+
+On behalf of the entire team, I wish you all the best.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
index c198fee..f14eb83 100644 (file)
@@ -1,4 +1,4 @@
-<img src="https://onelab.eu/templates/onelab2/images/logo.png">
+<img src="https://onelab.eu/static/images/onelab.png">
 <br>
 <h1>NEW USER REQUEST</h1>
 <br>
diff --git a/portal/templates/user_request_validated.html b/portal/templates/user_request_validated.html
new file mode 100644 (file)
index 0000000..8821b66
--- /dev/null
@@ -0,0 +1,16 @@
+<img src="https://onelab.eu/static/images/onelab.png">
+<br>
+<p>Dear {{first_name}} {{last_name}},</p>
+<p></p>
+<p>It is my pleasure to welcome you as a fully signed-up user of the OneLab experimental facility. OneLab provides you with access to world class computer networking testbeds, such as IoT-LAB, NITOS, and PlanetLab Europe. Our aim at OneLab is to promote the use of these testbeds for pre-commercial research and development by industry, for scientific research, and for university level laboratory exercises.</p>
+<p></p>
+</p>
+Your entry point for access to the testbeds is the OneLab portal, which provides a web-based interface for browsing and reserving resources on the various testbeds. To run an experiment using those resources, you may log in to the testbed and/or individual nodes on the testbed with your OneLab public/private key pair, or you may use an experiment control tool such as as NEPI or OMF. The OneLab operations team is standing by at support@onelab.eu to provide you with help regarding the portal and to refer your testbed- and tool-specific queries to those best able to answer them.
+</p>
+<p></p>
+</p>On behalf of the entire team, I wish you a fruitful user experience with the OneLab portal.</p>
+<p></p>
+<p>Yours sincerely,</p>
+<p></p>
+<p>Timur Friedman</p>
+<p>Executive Director</p>
diff --git a/portal/templates/user_request_validated.txt b/portal/templates/user_request_validated.txt
new file mode 100644 (file)
index 0000000..6765f3b
--- /dev/null
@@ -0,0 +1,12 @@
+Dear {{first_name}} {{last_name}},
+
+It is my pleasure to welcome you as a fully signed-up user of the OneLab experimental facility. OneLab provides you with access to world class computer networking testbeds, such as IoT-LAB, NITOS, and PlanetLab Europe. Our aim at OneLab is to promote the use of these testbeds for pre-commercial research and development by industry, for scientific research, and for university level laboratory exercises.
+
+Your entry point for access to the testbeds is the OneLab portal, which provides a web-based interface for browsing and reserving resources on the various testbeds. To run an experiment using those resources, you may log in to the testbed and/or to individual nodes on the testbed with your OneLab public/private key pair, or you may use an experiment control tool such as as NEPI or OMF. The OneLab operations team is standing by at support@onelab.eu to provide you with help regarding the portal and to refer your testbed- and tool-specific queries to those best able to answer them.
+
+On behalf of the entire team, I wish you a fruitful user experience with the OneLab portal.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
index 9bd0175..74f113a 100644 (file)
@@ -1,5 +1,6 @@
 from django import template
 from django.template.loader_tags import do_include
+from django.core.files.storage import default_storage
 from myslice.settings import theme
 
 register = template.Library()
@@ -37,4 +38,13 @@ def widget(parser, token):
         raise template.TemplateSyntaxError, \
             "%r tag requires a single argument" % token.contents.split()[0]
 
-    return IncludeNode(template_name[1:-1])
\ No newline at end of file
+    return IncludeNode(template_name[1:-1])
+
+@register.filter(name='file_exists')
+def file_exists(filepath):
+    if default_storage.exists('portal' + filepath):
+        return filepath
+    else:
+        index = filepath.rfind('/')
+        new_filepath = filepath[:index] + '/image.png'
+        return new_filepath
\ No newline at end of file
index 806aaec..7154b8a 100644 (file)
@@ -1,22 +1,26 @@
 import json
+from manifold.core.query         import Query
+from manifoldapi.manifoldapi        import execute_query
 
-from manifold.core.query        import Query
-from manifoldapi.manifoldapi    import execute_query
+from unfold.page                 import Page
+
+from plugins.lists.testbedlist   import TestbedList
+from plugins.lists.slicelist     import SliceList
 
-from unfold.page                import Page
 from unfold.loginrequired       import FreeAccessView
-from unfold.loginrequired       import LoginRequiredAutoLogoutView
-from ui.topmenu                 import topmenu_items_live, the_user
+from unfold.loginrequired        import LoginRequiredAutoLogoutView
 
-from plugins.lists.testbedlist  import TestbedList
-from plugins.lists.slicelist    import SliceList
-from plugins.querytable         import QueryTable
-from plugins.univbrisfoam       import UnivbrisFoam
-from plugins.univbrisfv         import UnivbrisFv
-from plugins.lists.staticlist   import StaticList
-from plugins.lists.slicelist    import SliceList
-from plugins.messages           import Messages
-from plugins.univbrisfvf        import UnivbrisFvf
+from ui.topmenu                  import topmenu_items_live, the_user
+from plugins.querytable          import QueryTable
+from plugins.univbrisfoam       import UnivbrisFoam
+from plugins.univbrisfv                 import UnivbrisFv
+from plugins.lists.staticlist   import StaticList
+from plugins.lists.slicelist     import SliceList
+from plugins.messages          import Messages
+from plugins.univbrisfvf       import UnivbrisFvf
+from plugins.univbrisfvfo      import UnivbrisFvfo
+from plugins.univbris          import Univbris
+from plugins.univbristopo      import UnivbrisTopo
 
 #This view requires login 
 class UnivbrisView (LoginRequiredAutoLogoutView):
@@ -27,22 +31,46 @@ class UnivbrisView (LoginRequiredAutoLogoutView):
         
         page = Page(self.request)
         #print "UNIVBRIS page"
-        
-        #create new query to manifold----query is not called yet
-        #need to modify to get i2cat of resources also
+        metadata = page.get_metadata()
+        page.expose_js_metadata()
+    
+        resource_md = metadata.details_by_object('resource')
+        resource_fields = [column['name'] for column in resource_md['column']]
+    
+        user_md = metadata.details_by_object('user')
+        user_fields = ['user_hrn'] # [column['name'] for column in user_md['column']]
+    
+    
+       #create new query to manifold----query is not called yet
+       #need to modify to get i2cat of resources also
         univbrisfoam_query=Query().get('ofelia-bristol-of:resource').select('urn')
+        #print univbrisfoam_query #.select('urn')
+       #Query().get('ofelia-bristol-of:resource')
+       ##custom query to communication between univbris plugins
+        #univbris_query=Query()
             
-        #queue the query
+       #queue the query
         page.enqueue_query(univbrisfoam_query)
+        #page.enqueue_query(univbris_query)
         page.expose_js_metadata()
-        
-        #plugin which collects different openflow ports from maniford
+    
+    
+       #plugin which display a "gathering resources" message waiting for all resources to be returned by manifold
+        univbriswelcome = Univbris(
+            page  = page,
+            title = 'univbris_welcome',
+            domid = 'univbris_welcome',
+            query = univbrisfoam_query,
+        )
+       
+       #plugin which collects different openflow ports from maniford
         univbrisfoamlist = UnivbrisFoam(
             page  = page,
             title = 'univbris_foam_ports_selection',
             domid = 'univbris_foam_ports_selection',
             query = univbrisfoam_query,
             query_all = univbrisfoam_query,
+           sync_query= univbrisfoam_query,
             checkboxes = False,
             datatables_options = { 
                 'iDisplayLength': 10,
@@ -51,26 +79,42 @@ class UnivbrisView (LoginRequiredAutoLogoutView):
                 },
         )
     
-        #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold
+       #plugin which manages the different flowspaces that the user creates, and also sends flowspaces to manifold
         univbrisfvlist = UnivbrisFv(
-                page  = page,
-                title = 'univbris_flowspace_selection',
-                domid = 'univbris_flowspace_selection',
-            query = None,
-                query_all = None,
-                datatables_options = { 
-                    'iDisplayLength': 5,
-                    'bLengthChange' : True,
-                    'bAutoWidth'    : True,
-                    },
-            )
+            page  = page,
+            title = 'univbris_flowspace_selection',
+            domid = 'univbris_flowspace_selection',
+           query = None,
+            query_all = None,
+           sync_query= univbrisfoam_query,
+            datatables_options = { 
+                'iDisplayLength': 5,
+                'bLengthChange' : True,
+                'bAutoWidth'    : True,
+                },
+        )
     
-        #plugin which allows the definition of a single flowspace
+       #plugin which allows the definition the match criteria on a single PACKET flowspace
         univbrisfvform = UnivbrisFvf(
+            page  = page,
+            title = 'univbris_flowspace_form',
+            domid = 'univbris_flowspace_form',
+           query = None,
+            query_all = None,
+            datatables_options = { 
+                'iDisplayLength': 3,
+                'bLengthChange' : True,
+                'bAutoWidth'    : True,
+                },
+        )
+    
+       #plugin which allows the definition the match criteria on a single OPTICAL flowspace
+    
+        univbrisofvform = UnivbrisFvfo(
                 page  = page,
-                title = 'univbris_flowspace_form',
-                domid = 'univbris_flowspace_form',
-            query = None,
+                title = 'univbris_oflowspace_form',
+                domid = 'univbris_oflowspace_form',
+               query = None,
                 query_all = None,
                 datatables_options = { 
                     'iDisplayLength': 3,
@@ -78,13 +122,25 @@ class UnivbrisView (LoginRequiredAutoLogoutView):
                     'bAutoWidth'    : True,
                     },
             )
-        
-        #render plugins in each context within a single page, but not all plugins are visible at all time.
+    
+    
+       #plugin which display the gathered topology
+        univbristopology = UnivbrisTopo(
+                page  = page,
+                title = 'univbris_topology',
+                domid = 'univbris_topology',
+                query = univbrisfoam_query,
+            )
+       
+       #render plugins in each context within a single page, but not all plugins are visible at all time.
         context = super(UnivbrisView, self).get_context_data(**kwargs)
         context['person']   = self.request.user
+        context['welcome'] = univbriswelcome.render(self.request)
         context['resources'] = univbrisfoamlist.render(self.request)
         context['flowspaces']= univbrisfvlist.render(self.request)
+        context['oflowspaces_form']= univbrisofvform.render(self.request)
         context['flowspaces_form']= univbrisfvform.render(self.request)
+        context['topology']=univbristopology.render(self.request)
     
         # XXX This is repeated in all pages
         # more general variables expected in the template
@@ -93,15 +149,14 @@ class UnivbrisView (LoginRequiredAutoLogoutView):
         context['topmenu_items'] = topmenu_items_live('univbris', page)
         # so we can sho who is logged
         context['username'] = the_user(self.request)
-    
+        
         context.update(page.prelude_env())
         page.expose_js_metadata()
         
-    
+        
         # the page header and other stuff
         context.update(page.prelude_env())
-    
+        
         context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"
-    
+        
         return context
-
diff --git a/portal/univbrisvtam.py b/portal/univbrisvtam.py
new file mode 100644 (file)
index 0000000..c557998
--- /dev/null
@@ -0,0 +1,94 @@
+import json
+from manifold.core.query        import Query
+from manifoldapi.manifoldapi    import execute_query
+
+from unfold.page                import Page
+
+from plugins.lists.testbedlist  import TestbedList
+from plugins.lists.slicelist    import SliceList
+
+from unfold.loginrequired       import FreeAccessView
+from unfold.loginrequired       import LoginRequiredAutoLogoutView
+
+from ui.topmenu                 import topmenu_items_live, the_user
+from plugins.lists.staticlist  import StaticList
+from plugins.lists.slicelist    import SliceList
+from plugins.messages              import Messages
+from plugins.querytable         import QueryTable
+from plugins.univbrisfoam          import UnivbrisFoam
+from plugins.univbrisfv                    import UnivbrisFv
+from plugins.univbrisvtam          import UnivbrisVtam as UnivbrisVtamPlugin
+from plugins.univbrisvtamform  import UnivbrisVtamForm
+
+#This view requires login 
+class UnivbrisVtam (LoginRequiredAutoLogoutView):
+    template_name = "univbrisvtam.html"
+    
+    def get_context_data(self, **kwargs):
+        
+       page = Page(self.request)
+        #print "UNIVBRIS page"
+       
+       #create new query to manifold----query is not called yet
+       #need to modify to get i2cat of resources also
+        univbrisvtamform_query=Query().get('ofelia-i2cat-vt:resource').select('hostname')
+        #print univbrisfoam_query #.select('urn')
+        
+       #queue the query
+        page.enqueue_query(univbrisvtamform_query)
+        page.expose_js_metadata()
+
+
+       #plugin which display a table where an experimenter will add VMs to according to his needs
+        univbrisvtamplugin = UnivbrisVtamPlugin(
+            page  = page,
+            title = 'univbris_vtam',
+            domid = 'univbris_vtam',
+            query = None,
+        )
+
+       #plugin which display a form where an experimenter will specify where a
+        univbrisvtamform = UnivbrisVtamForm(
+            page  = page,
+            title = 'univbris_vtam_form',
+            domid = 'univbris_vtam_form',
+           query = univbrisvtamform_query,
+            query_all = None,
+            datatables_options = { 
+                'iDisplayLength': 3,
+                'bLengthChange' : True,
+                'bAutoWidth'    : True,
+                },
+        )
+       
+       #render plugins in each context within a single page, but not all plugins are visible at all time.
+        context = super(UnivbrisVtam, self).get_context_data(**kwargs)
+        context['person']   = self.request.user
+       #context['welcome'] = univbriswelcome.render(self.request)
+        #context['resources'] = univbrisfoamlist.render(self.request)
+       context['vms_list']= univbrisvtamplugin.render(self.request)
+       context['vm_form']= univbrisvtamform.render(self.request)
+       #context['oflowspaces_form']= univbrisofvform.render(self.request)
+       #context['flowspaces_form']= univbrisfvform.render(self.request)
+       #context['topology']=univbristopology.render(self.request)
+       
+       
+        # XXX This is repeated in all pages
+        # more general variables expected in the template
+        context['title'] = 'Create New Virtual Machines'
+        # the menu items on the top
+        context['topmenu_items'] = topmenu_items_live('univbris', page)
+        # so we can sho who is logged
+        context['username'] = the_user(self.request)
+
+        context.update(page.prelude_env())
+        page.expose_js_metadata()
+       
+
+        # the page header and other stuff
+        context.update(page.prelude_env())
+
+       context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html"
+
+        return context
+
index e6e63e6..42a8dcb 100644 (file)
@@ -44,15 +44,20 @@ from portal.validationview          import ValidatePendingView
 #from portal.experimentview         import ExperimentView
 from portal.termsview               import TermsView
 from portal.univbrisview            import UnivbrisView
+from portal.univbrisvtam            import UnivbrisVtam
 
-from portal.servicedirectory         import ServiceDirectoryView
+from portal.manualdelegationview    import ManualDelegationView
+
+from portal.servicedirectory        import ServiceDirectoryView
 
 from portal.documentationview       import DocumentationView
 from portal.supportview             import SupportView
 from portal.emailactivationview     import ActivateEmailView
 # hopefully these should move in dedicated source files too
-from portal.views               import PresViewView, pres_view_static, pres_view_methods, pres_view_animation
-from portal.django_passresetview import password_reset, password_reset_done, password_reset_confirm, password_reset_complete 
+from portal.views                   import PresViewView, pres_view_static, pres_view_methods, pres_view_animation
+from portal.django_passresetview    import password_reset, password_reset_done, password_reset_confirm, password_reset_complete 
+
+from portal.reputationview      import ReputationView
 
 # DEPRECATED #named_register_forms = (
 # DEPRECATED #    ("step1", RegisterUserForm),
@@ -94,12 +99,13 @@ urlpatterns = patterns('',
     # Slice request
     url(r'^slice_request/?$', SliceRequestView.as_view(), name='slice_request'),
     url(r'^terms/?$', TermsView.as_view(), name='terms'),
+    url(r'^manual_delegation/?$', ManualDelegationView.as_view(), name='manual_delegation'),
     # Validate pending requests
     url(r'^validate/?$', ValidatePendingView.as_view()),
     # http://stackoverflow.com/questions/2360179/django-urls-how-to-pass-a-list-of-items-via-clean-urls
     # (r'^validate_action/(?P<constraints>[^/]+)/(?P<id>\w+)/?$', 'portal.views.pres_view_static'),
     url(r'^validate_action(?P<id>(?:/\w+)+)/?$', 'portal.actions.validate_action'),
-
+    url(r'^reject_action(?P<id>(?:/\w+)+)/?$', 'portal.actions.reject_action'),
     url(r'^pres_view/?$', PresViewView.as_view(), name='pres_view'),
     (r'^methods/(?P<type>\w+)/?$', 'portal.views.pres_view_methods'),
     (r'^animation/(?P<constraints>[^/]+)/(?P<id>\w+)/?$', 'portal.views.pres_view_animation'),
@@ -120,9 +126,15 @@ urlpatterns = patterns('',
         'portal.django_passresetview.password_reset_complete'),
 
     url(r'^univbris/?$', UnivbrisView.as_view(), name='univbris'),
-    
+    url(r'^univbrisvtam/?$', UnivbrisVtam.as_view(), name='univbrisvtam'),   
+
     url(r'^servicedirectory/?$', ServiceDirectoryView.as_view(), name='servicedirectory'),
 
+
+    url(r'^reputation/?$', ReputationView.as_view(), name='reputation'),
+    url(r'^reputation/submit_eval/?$', ReputationView.as_view(), name='reputation_submit_eval'),
+    
+    
 )
 # (r'^accounts/', include('registration.backends.default.urls')),
 
diff --git a/rest/credentials.py b/rest/credentials.py
new file mode 100644 (file)
index 0000000..a8c8ba7
--- /dev/null
@@ -0,0 +1,26 @@
+from django.http                    import HttpResponse
+from portal.actions import clear_user_creds
+import json
+
+def dispatch(request, action):
+    
+    if (action == 'clear') :
+        res=[]
+        emails = request.POST.getlist('emails[]')
+        if not emails:
+            emails = request.GET.getlist('emails[]')
+        if emails :
+            for email in emails :
+                try :
+                    clear = clear_user_creds(request, email)
+                    if clear is not None:
+                        res.append(clear)
+                except :
+                    pass
+        
+        if not res :
+            ret = { "ret" : 1, "emails" : emails }
+        else :
+            ret = { "ret" : 0 }
+    
+    return HttpResponse(json.dumps(ret), content_type="application/json")
diff --git a/rest/monitor.py b/rest/monitor.py
new file mode 100644 (file)
index 0000000..2252189
--- /dev/null
@@ -0,0 +1,62 @@
+from sfa.client.sfaserverproxy import SfaServerProxy
+from sfa.client.return_value import ReturnValue
+from django.http import HttpResponse
+from rest import error
+import os,json
+import ConfigParser    
+
+def servicesStatus(request):
+    Config = ConfigParser.ConfigParser()
+    Config.read(os.getcwd() + "/myslice/monitor.ini")
+    
+    result = {}
+    
+    if not Config.has_option('monitor', 'cert') :
+        return HttpResponse(json.dumps({'error' : '-1'}), content_type="application/json")
+    
+    cert = os.path.abspath(Config.get('monitor', 'cert'))
+    if not os.path.isfile(cert) :
+         return HttpResponse(json.dumps({'error' : '-1'}), content_type="application/json")
+     
+     
+    if not Config.has_option('monitor', 'pkey') :
+        return HttpResponse(json.dumps({'error' : '-2'}), content_type="application/json")
+    
+    pkey = os.path.abspath(Config.get('monitor', 'pkey'))
+    if not os.path.isfile(pkey) :
+         return HttpResponse(json.dumps({'error' : '-2'}), content_type="application/json")
+    
+    services = Config.sections()
+    for s in services :
+        
+        if s == 'monitor' : 
+            continue
+        
+        if Config.has_option(s, 'url') :
+            result[s] = {}
+
+            if Config.has_option(s, 'name') :
+                result[s]['name'] = Config.get(s, 'name')
+            
+            if Config.has_option(s, 'description') :
+                result[s]['description'] = Config.get(s, 'description')
+            
+            if Config.has_option(s, 'type') :
+                result[s]['type'] = Config.get(s, 'type')
+                
+            server = SfaServerProxy(Config.get(s, 'url'), pkey, cert)
+            try:
+                version = server.GetVersion()
+
+                result[s]['status'] = 'ok'
+                
+                if 'interface' in version : # registry
+                    result[s]['version'] = version['sfa']
+                else :
+                    result[s]['version'] = version['geni_api']
+
+            except Exception, e:
+                result[s]['status'] = 'ko'
+
+        
+    return HttpResponse(json.dumps(result), content_type="application/json")
\ No newline at end of file
index b0ff707..988af27 100644 (file)
@@ -70,7 +70,9 @@ from plugins.topmenuvalidation import TopmenuValidation
 # for asynchronous management of topmenu
 def topmenu_items_live (current, page):
     request=page.request
-    query_pi_auths = Query.get('user').filter_by('user_hrn', '==', '$user_hrn' ).select('pi_authorities')
+    # XXX TODO This should be triggered only when user is logged in
+    # We might use local storage instead
+    query_pi_auths = Query.get('user').filter_by('user_hrn', '==', '$user_hrn' ).select('user_hrn','pi_authorities')
     page.enqueue_query(query_pi_auths)
 #        # even though this plugin does not have any html materialization, the corresponding domid
 #        # must exist because it is searched at init-time to create the JS plugin