Merge branch 'onelab' of ssh://git.onelab.eu/git/myslice into fibre
authorPedro, Carlos and Rezende <pedroeusebio, carlos, rezende@land.ufrj.br>
Fri, 3 Oct 2014 19:51:36 +0000 (16:51 -0300)
committerPedro, Carlos and Rezende <pedroeusebio, carlos, rezende@land.ufrj.br>
Fri, 3 Oct 2014 19:51:36 +0000 (16:51 -0300)
Conflicts:
manifoldapi/manifoldproxy.py
manifoldapi/static/js/manifold.js
myslice/urls.py
portal/actions.py
portal/emailactivationview.py
portal/homeview.py
portal/managementtabrequests.py
portal/registrationview.py
portal/sliceresourceview.py
portal/templates/email_activation.html
portal/templates/management-tab-requests.html
portal/templates/registration_view.html
portal/templates/slice-resource-view.html

163 files changed:
activity/__init__.py
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/templates/apply.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/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
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 [new file with mode: 0644]
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 [new file with mode: 0644]
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]
portal/accountview.py
portal/actions.py
portal/contactview.py
portal/emailactivationview.py
portal/forms.py
portal/homeview.py
portal/joinview.py
portal/managementtababout.py
portal/managementtabrequests.py
portal/manualdelegationview.py [new file with mode: 0644]
portal/registrationview.py
portal/slicerequestview.py
portal/sliceresourceview.py
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/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/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/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
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-view.html
portal/templates/onelab/onelab_slicerequest_view.html
portal/templates/onelab/onelab_supportview.html
portal/templates/onelab/onelab_user_request_email.html
portal/templates/onelab/onelab_user_request_email.txt
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/registration_view.html
portal/templates/slice-request-done-view.html
portal/templates/slice-resource-view.html
portal/templates/slice-tab-experiment.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/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/univbrisview.py
portal/urls.py
rest/credentials.py
rest/monitor.py [new file with mode: 0644]

index d570662..6157bae 100644 (file)
@@ -1,61 +1,92 @@
 #
 # 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
-from datetime import datetime
+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
 
-def logWrite(request, action, message):
-    url = "http://localhost:5000/log"
+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 = {
-        "date" : datetime.today(),
-        "client_ip" : getClientIp(request),
-        "host" : request.get_host(),
-        "referrer" : request.META.get('HTTP_REFERER'),
-        "user" : request.user
+        "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
     }
     
+    if objects and 'slice' in objects :
+        log['slice'] = objects['slice']
+    
+    if objects and 'resource' in objects :
+        log['resource'] = objects['resource']
+    
     try :
-        result = urllib2.urlopen(url, urllib.urlencode(log))
+        result = urllib2.urlopen(server, urllib.urlencode(log))
+        print "===============>> activity: " + action + " <" + request.user + "> " + message
         content = result.read()
     except urllib2.URLError as e:
-        print "Error: connection to " + url + " impossible, logging disabled"
+        print "===============>> activity: connection to " + server + " impossible, could not log action"
 
-def spawnThread(request, action, message):
-    print "aaaaaaaaa"
+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))
+    t = threading.Thread(target=logWrite, args=(request, action, message, objects))
     t.setDaemon(True)
     t.start()
 
-def userLogin(request):
-    spawnThread(request, 'userlogin', 'User logged in')
-
-def userLogout(request):
-    spawnThread(request, 'userlogout', 'User logged out')
-
-def userRegistration(request):
-    spawnThread(request, 'userregistration', 'User registered')
-
-def userSliceRequest(request):
-    spawnThread(request, 'userslicerequest', 'User requested a slice')
-
-def userContactSupport(request):
-    spawnThread(request, 'usercontactsupport', 'User contacted suppport')
-
-def userAddResource(request):
-    spawnThread(request, 'useraddresource', 'User added resource to slice')
-
-def userDelResource(request):
-    spawnThread(request, 'userdelresource', 'User removed resource from slice')
-
-
 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
\ No newline at end of file
+    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 76f6165..433a854 100644 (file)
@@ -55,10 +55,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 manifold_query
-            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"
index 535950e..dfb4ab5 100644 (file)
@@ -17,3 +17,7 @@
     display:none;
     z-index:100;
 }
+.loading img {
+    vertical-align:middle;
+    margin-right:15px;
+}
index 30cb75e..31d4b00 100644 (file)
@@ -344,13 +344,21 @@ 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 record_key_value = manifold.record_get_value(record, record_key);
             
             query_ext.records.put(record_key_value, record);
@@ -553,6 +561,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);
@@ -622,13 +632,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 == '!=') {
@@ -659,7 +672,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");
 
     }
 
@@ -1202,7 +1215,15 @@ 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);
+        var key, new_object;
+
+        if (object.indexOf(':') != -1) {
+            new_object = object.split(':')[1];
+        } else {
+            new_object = object;
+        }
+
+        key = manifold.metadata.get_key(new_object);
         record.hashCode = manifold.record_hashcode(key.sort());
         record.equals   = manifold.record_equals(key);
 
index 495bdc7..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
@@ -318,7 +420,7 @@ var Plugin = Class.extend({
     // you can also call spin_presets() yourself and tweak what you need to, like topmenuvalidation does
     spin: function (message) {
        if (!message) {
-               message = 'Please be patient, this can take a minute or two.';
+               message = 'Please be patient, this operation can take a minute or two.';
        }
        $('div.loading').fadeIn('fast');
        $('div.loading').find('.message').text(message);
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 b318cb0..7b8dea1 100644 (file)
@@ -19,7 +19,14 @@ import portal.newsview
 
 import plugins.cafe.edelberto
 
+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()
@@ -85,7 +92,7 @@ urls = [
     (r'^credentials/(?P<action>[^/]+)/?$', 'rest.credentials.dispatch'),
     #
     # REST monitoring
-    #(r'^monitor/sfa/getversion/?$', 'rest.monitor.sfaGetVersion'),
+    (r'^monitor/services/?$', 'rest.monitor.servicesStatus'),
     #
     #(r'^view/?', include('view.urls')),
     #(r'^list/slices', 'view.list.slices')
@@ -101,12 +108,19 @@ 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'^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'^portal/', include('portal.urls')),
 
index 1a9e805..f05af49 100644 (file)
@@ -6,11 +6,10 @@
         <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...
-               &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-               <img id="applyloading" src="/static/img/loading.gif" />
+                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>
@@ -43,6 +42,6 @@
 
   
   <!-- Button toolbar -->
-  <button class="btn btn-onelab btn-sm"  id="{{domid}}__apply" data-toggle="modal" data-target="#{{domid}}__apply__window">Apply</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 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 3d18757..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);
         }, 
 
         /**************************************************************************
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..7ddf300 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',
     };
index c843926..8da79d4 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 %}
index 04665c6..6b55b92 100755 (executable)
@@ -815,6 +815,7 @@ var SCHEDULER_COLWIDTH = 50;
                 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
index fee3a7d..e554f2b 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
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 22f7f0a..296e5ef 100644 (file)
@@ -1,24 +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>-->
+          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..93653b9 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:
@@ -118,6 +119,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 73cd552..853bc1e 100644 (file)
@@ -1,15 +1,14 @@
 from unfold.plugin import Plugin
 
 class UnivbrisFv (Plugin):
-    """
-    ////////////////////////////////////////
-    modified querytable for univbris foam
-    ///////////////////////////////////////
-    """
+"""
+////////////////////////////////////////
+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'])
+       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
 
index 82581ab..7cefef6 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);
+               alert("verifying before submitting");
+
+               sync_query_uuid=e.data.options.sync_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(sync_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){
+               sync_query_uuid=e.data.options.sync_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.sync_query_uuid,CLEAR_FILTERS);
+                       var filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("optical");
+                       manifold.raise_event(e.data.options.sync_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;
+               sync_query_uuid=e.data.options.sync_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.sync_query_uuid,CLEAR_FILTERS);
+                       var filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("packet");
+                       manifold.raise_event(e.data.options.sync_query_uuid,FILTER_ADDED,filter);
+                       filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("compute");
+                       manifold.raise_event(e.data.options.sync_query_uuid,FILTER_ADDED,filter);
+                       filter=[];
+                       filter.push("link type");
+                       filter.push("!=");
+                       filter.push("federation");
+                       manifold.raise_event(e.data.options.sync_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
diff --git a/plugins/univbrisfvfo/static/js/univbrisfvfo.js b/plugins/univbrisfvfo/static/js/univbrisfvfo.js
new file mode 100644 (file)
index 0000000..7d502a8
--- /dev/null
@@ -0,0 +1,1266 @@
+/**
+ * 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 UnivbrisFvfo = Plugin.extend({
+
+        init: function(options, element) {
+           //alert("foam init called");
+           this.classname="univbrisfvfo";
+            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;
+
+            // We need to remember the active filter for datatables filtering
+            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 = [];
+
+            /* 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 ("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 */
+            //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("univbrisfvfo.on_show");
+            var self = e.data;
+            self.table.fnAdjustColumnSizing();
+       },        
+
+        on_resize: function(e) {
+           if (debug) messages.debug("univbrisfvfo.on_resize");
+            var self = e.data;
+            self.table.fnAdjustColumnSizing();
+       },        
+
+        /* GUI EVENTS */
+
+        /* GUI MANIPULATION */
+
+        initialize_table: function() 
+        {
+            /* 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-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
+                sPaginationType: 'bootstrap',
+                // Handle the null values & the error : Datatables warning Requested unknown parameter
+                // http://datatables.net/forums/discussion/5331/datatables-warning-...-requested-unknown-parameter/p2
+                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: false,      /* Loading */
+                fnDrawCallback: function() { self._querytable_draw_callback.call(self);}
+               //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
+           // xxx DISABLED by jordan: was causing errors in datatables.js
+           // xxx turned back on by Thierry - this is the code that takes python-provided options into account
+           // 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) {
+               actual_options['aoColumnDefs']=this.options.datatables_options['aoColumnDefs'].concat(actual_options['aoColumnDefs']);
+               delete this.options.datatables_options['aoColumnDefs'];
+           }
+           $.extend(actual_options, this.options.datatables_options );
+            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 */
+            var oSelectAll = $('#datatableSelectAll-'+ this.options.plugin_uuid);
+            oSelectAll.html("<span class='glyphicon glyphicon-ok' style='float:right;display:inline-block;'></span>Select All");
+            oSelectAll.button();
+            oSelectAll.css('font-size','11px');
+            oSelectAll.css('float','right');
+            oSelectAll.css('margin-right','15px');
+            oSelectAll.css('margin-bottom','5px');
+            oSelectAll.unbind('click');
+            oSelectAll.click(this._selectAll);
+
+            /* Add a filtering function to the current table 
+             * 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;
+                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);
+               //alert (field);
+                self.hide_column(field);
+               //self.hide_column(field);
+            });
+
+        }, // initialize_table
+
+
+       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( "#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){
+               e.stopPropagation();
+               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 
+         * @param key
+         * @param cols
+         */
+        getColIndex: function(key, cols) {
+            var tabIndex = $.map(cols, function(x, i) { if (x.sTitle == key) return i; });
+            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='univbrisfvfo-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='univbrisfvfo-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");
+               }
+               
+            }
+    
+            // 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()
+        {
+            this.table.fnClearTable();
+        },
+
+        redraw_table: function()
+        {
+            this.table.fnDraw();
+        },
+
+        show_column: function(field)
+        {
+            var oSettings = this.table.fnSettings();
+            var cols = oSettings.aoColumns;
+            var index = this.getColIndex(field,cols);
+            if (index != -1)
+                this.table.fnSetColumnVis(index, true);
+        },
+
+        hide_column: function(field)
+        {
+            var oSettings = this.table.fnSettings();
+            var cols = oSettings.aoColumns;
+            var index = this.getColIndex(field,cols);
+           //index=-1;
+           //alert(field + ": index: " + index );
+            if (index != -1)
+               //alert(field + ": hidden with index: " + index );
+                this.table.fnSetColumnVis(index, false);
+        },
+
+       // this is used at init-time, at which point only init_key can make sense
+       // (because the argument record, if it comes from query, might not have canonical_key set
+       set_checkbox_from_record: function (record, checked) {
+            if (checked === undefined) checked = true;
+           var init_id = record[this.init_key];
+           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("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);
+       },
+
+        /*************************** QUERY HANDLER ****************************/
+
+        on_filter_added: function(filter)
+        {
+            this.filters.push(filter);
+            this.redraw_table();
+        },
+
+        on_filter_removed: function(filter)
+        {
+            // Remove corresponding filters
+            this.filters = $.grep(this.filters, function(x) {
+                return x != filter;
+            });
+            this.redraw_table();
+        },
+        
+        on_filter_clear: function()
+        {
+            // XXX
+            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()
+        {
+            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 ! */
+        /*************************** ALL QUERY HANDLER ****************************/
+
+        on_all_filter_added: function(filter)
+        {
+            // XXX
+            this.redraw_table();
+        },
+
+        on_all_filter_removed: function(filter)
+        {
+            // XXX
+            this.redraw_table();
+        },
+        
+        on_all_filter_clear: function()
+        {
+            // XXX
+            this.redraw_table();
+        },
+
+        on_all_field_added: function(field)
+        {
+            this.show_column(field);
+        },
+
+        on_all_field_removed: function(field)
+        {
+            this.hide_column(field);
+        },
+
+        on_all_field_clear: function()
+        {
+            alert('UnivbrisFvfo::clear_fields() not implemented');
+        },
+
+
+        /*************************** RECORD HANDLER ***************************/
+
+        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()
+        {
+        },
+
+        // Could be the default in parent
+        on_query_in_progress: function()
+        {
+            this.spin();
+        },
+
+        on_query_done: function()
+        {
+            this.received_query = true;
+           // unspin once we have received both
+            if (this.received_all_query && this.received_query) this.unspin();
+        },
+        
+        on_field_state_changed: function(data)
+        {
+            switch(data.request) {
+                case FIELD_REQUEST_ADD:
+                case FIELD_REQUEST_ADD_RESET:
+                    this.set_checkbox_from_data(data.value, true);
+                    break;
+                case FIELD_REQUEST_REMOVE:
+                case FIELD_REQUEST_REMOVE_RESET:
+                    this.set_checkbox_from_data(data.value, false);
+                    break;
+                default:
+                    break;
+            }
+        },
+
+        /* XXX TODO: make this generic a plugin has to subscribe to a set of Queries to avoid duplicated code ! */
+        // all
+        on_all_field_state_changed: function(data)
+        {
+            switch(data.request) {
+                case FIELD_REQUEST_ADD:
+                case FIELD_REQUEST_ADD_RESET:
+                    this.set_checkboxfrom_data(data.value, true);
+                    break;
+                case FIELD_REQUEST_REMOVE:
+                case FIELD_REQUEST_REMOVE_RESET:
+                    this.set_checkbox_from_data(data.value, false);
+                    break;
+                default:
+                    break;
+            }
+        },
+
+        on_all_new_record: function(record)
+        {
+            this.new_record(record);
+        },
+
+        on_all_clear_records: function()
+        {
+            this.clear_table();
+
+        },
+
+        on_all_query_in_progress: function()
+        {
+            // XXX parent
+            this.spin();
+        }, // 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.table.fnAddData (this.buffered_lines);
+           this.buffered_lines=[];
+           
+            var self = this;
+           // if we've already received the slice query, we have not been able to set 
+           // checkboxes on the fly at that time (dom not yet created)
+            $.each(this.buffered_records_to_check, function(i, record) {
+               if (debug) messages.debug ("querytable delayed turning on checkbox " + i + " record= " + record);
+                self.set_checkbox_from_record(record, true);
+            });
+           this.buffered_records_to_check = [];
+
+            this.received_all_query = true;
+           // unspin once we have received both
+            if (this.received_all_query && this.received_query) this.unspin();
+
+        }, // on_all_query_done
+
+        /************************** PRIVATE METHODS ***************************/
+
+        /** 
+         * @brief QueryTable filtering function
+         */
+        _querytable_filter: function(oSettings, aData, iDataIndex)
+        {
+            var ret = true;
+            $.each (this.filters, function(index, filter) { 
+                /* XXX How to manage checkbox ? */
+                var key = filter[0]; 
+                var op = filter[1];
+                var value = filter[2];
+
+                /* Determine index of key in the table columns */
+                var col = $.map(oSettings.aoColumns, function(x, i) {if (x.sTitle == key) return i;})[0];
+
+                /* Unknown key: no filtering */
+                if (typeof(col) == 'undefined')
+                    return;
+
+                col_value=unfold.get_value(aData[col]);
+                /* Test whether current filter is compatible with the column */
+                if (op == '=' || op == '==') {
+                    if ( col_value != value || col_value==null || col_value=="" || col_value=="n/a")
+                        ret = false;
+                }else if (op == '!=') {
+                    if ( col_value == value || col_value==null || col_value=="" || col_value=="n/a")
+                        ret = false;
+                } else if(op=='<') {
+                    if ( parseFloat(col_value) >= value || col_value==null || col_value=="" || col_value=="n/a")
+                        ret = false;
+                } else if(op=='>') {
+                    if ( parseFloat(col_value) <= value || col_value==null || col_value=="" || col_value=="n/a")
+                        ret = false;
+                } else if(op=='<=' || op=='≤') {
+                    if ( parseFloat(col_value) > value || col_value==null || col_value=="" || col_value=="n/a")
+                        ret = false;
+                } else if(op=='>=' || op=='≥') {
+                    if ( parseFloat(col_value) < value || col_value==null || col_value=="" || col_value=="n/a")
+                        ret = false;
+                }else{
+                    // How to break out of a loop ?
+                    alert("filter not supported");
+                    return false;
+                }
+
+            });
+            return ret;
+        },
+
+        _querytable_draw_callback: function()
+        {
+            /* 
+             * Handle clicks on checkboxes: reassociate checkbox click every time
+             * the table is redrawn    
+             */
+            this.elts('querytable-checkbox').unbind('click').click(this, this._check_click);
+           //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;
+
+            /* Remove pagination if we show only a few results */
+            var wrapper = this.table; //.parent().parent().parent();
+            var rowsPerPage = this.table.fnSettings()._iDisplayLength;
+            var rowsToShow = this.table.fnSettings().fnRecordsDisplay();
+            var minRowsPerPage = this.table.fnSettings().aLengthMenu[0];
+
+            if ( rowsToShow <= rowsPerPage || rowsPerPage == -1 ) {
+                $('.querytable_paginate', wrapper).css('visibility', 'hidden');
+            } else {
+                $('.querytable_paginate', wrapper).css('visibility', 'visible');
+            }
+
+            if ( rowsToShow <= minRowsPerPage ) {
+                $('.querytable_length', wrapper).css('visibility', 'hidden');
+            } else {
+                $('.querytable_length', wrapper).css('visibility', 'visible');
+            }
+
+        },
+
+
+
+        _check_click: function(e) 
+        {
+            e.stopPropagation();
+
+            var self = e.data;
+           var id=this.id;
+
+            // 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);
+            //return false; // prevent checkbox to be checked, waiting response from manifold plugin api
+            
+        },
+
+        _selectAll: function() 
+        {
+            // requires jQuery id
+            var uuid=this.id.split("-");
+            var oTable=$("#querytable-"+uuid[1]).dataTable();
+            // Function available in QueryTable 1.9.x
+            // Filter : displayed data only
+            var filterData = oTable._('tr', {"filter":"applied"});   
+            /* TODO: WARNING if too many nodes selected, use filters to reduce nuber of nodes */        
+            if(filterData.length<=100){
+                $.each(filterData, function(index, obj) {
+                    var last=$(obj).last();
+                    var key_value=unfold.get_value(last[0]);
+                    if(typeof($(last[0]).attr('checked'))=="undefined"){
+                        $.publish('selected', 'add/'+key_value);
+                    }
+                });
+            }
+        },
+
+    });
+
+    $.plugin('UnivbrisFvfo', UnivbrisFvfo);
+
+  /* define the 'dom-checkbox' type for sorting in datatables 
+     http://datatables.net/examples/plug-ins/dom_sort.html
+     using trial and error I found that the actual column number
+     was in fact given as a third argument, and not second 
+     as the various online resources had it - go figure */
+    $.fn.dataTableExt.afnSortData['dom-checkbox'] = function  ( oSettings, _, iColumn ) {
+       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/css/univbristopo.css b/plugins/univbristopo/static/css/univbristopo.css
new file mode 100644 (file)
index 0000000..e69de29
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>
+
+
index bf033e6..5048383 100644 (file)
@@ -189,29 +189,36 @@ 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:
+            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
index 285b440..dd1e853 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
 
@@ -15,6 +17,8 @@ from lsapiclient                import LaboraSchedulerClient
 
 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
@@ -45,7 +49,7 @@ 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')
@@ -74,7 +78,8 @@ def clear_user_creds(request, user_email):
                 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('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'))
@@ -209,6 +214,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):
@@ -393,13 +403,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/
 
@@ -427,13 +601,23 @@ def create_slice(wsgi_request, request):
     user_hrn = request.get('user_hrn', None)
     user_hrns = list([user_hrn]) if user_hrn else list()
     
-    user_email = request.get
+    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
     }
@@ -443,12 +627,27 @@ def create_slice(wsgi_request, request):
     results = execute_query(wsgi_request, query)
     if not results:
         raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
-    ## We do not store the email in pendingslice table. As a result receiver's email is unknown ##
-    ## Need modification in pendingslice table ###
-    #else:
-    #    subject = 'Slice created'
-    #    msg = 'A manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.'
-    #    send_mail(subject, msg, 'support@onelab.eu',['yasin.upmc@gmail.com'], fail_silently=False)
+    else:
+        clear_user_creds(wsgi_request,user_email)
+        # log user activity
+        activity.slice.validate(self.request, "Slice validation", { "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
 
@@ -461,8 +660,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['exp_url'],
+        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()
 
@@ -537,7 +737,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) : 
@@ -564,8 +764,19 @@ 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)
+    ## Conflict
+    #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']
@@ -629,8 +840,43 @@ def ls_update_public_key( wsgi_request, request, lsClient, userId ):
     
     return addUserPublicKey
 
-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
 
@@ -647,8 +893,10 @@ def create_user(wsgi_request, request):
     # Add reference accounts for platforms
     manifold_add_reference_user_accounts(wsgi_request, request)
     
+    # Conflict 
+    # sfa_create_user(wsgi_request, request)
     # Add the user to the SFA registry
-    sfa_create_user(wsgi_request, request)
+    sfa_create_user(wsgi_request, request, namespace, as_admin)
   
     # Validate the user using the LS API ( By Bruno - UFG ):
     try:
@@ -758,6 +1006,10 @@ def create_user_in_ldap(wsgi_request, request, user_detail):
         send_mail(subject, msg, 'support@fibre.org.br',[request['email']], fail_silently=False)       
     return results
 
+    # 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):
     """
     """
@@ -788,7 +1040,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 0cd940d..24e06eb 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 e1a6a4b..3dc388b 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, authority_get_pis
+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, authority_get_pis
 #
 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
 from django.contrib.auth.models         import User
 #
 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,60 +50,97 @@ 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:
                 request = PendingUser.objects.filter(email_hash= hash_code)
-               split_authority_hrn = request[0].authority_hrn.split('.')[0]
-               pis = authority_get_pis(request, split_authority_hrn)
-               pi_emails = []
-               for x in pis:
-                   for e in x['pi_users']:
-                       u = e.split('.')[1]
-                       y = User.Objects.get(username = u)
-                       if y.username.count("@") != 0:
-                           if y.username.split("@")[1] == request[0].user_hrn.split("@")[1]:
-                               pi_emails += [y.email]
-               subject = 'User email activated'
-               msg = 'The user %s has validated his/her email. Now you can validate his/her account' % (request[0].login)
-               send_mail(subject, msg, 'support@fibre.org.br', pi_emails, fail_silently = False)
-           except:
-               print "error sending the email!"    
-            #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()
+                split_authority_hrn = request[0].authority_hrn.split('.')[0]
+                pis = authority_get_pis(request, split_authority_hrn)
+                pi_emails = []
+                for x in pis:
+                    for e in x['pi_users']:
+                        u = e.split('.')[1]
+                       y = User.Objects.get(username = u)
+                       if y.username.count("@") != 0:
+                           if y.username.split("@")[1] == request[0].user_hrn.split("@")[1]:
+                               pi_emails += [y.email]
+                subject = 'User email activated'
+                msg = 'The user %s has validated his/her email. Now you can validate his/her account' % (request[0].login)
+                send_mail(subject, msg, 'support@fibre.org.br', pi_emails, fail_silently = False)
+           except:
+               print "error sending the email!"    
+                #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 3fc0cd8..cf3fcba 100644 (file)
@@ -5,6 +5,7 @@ from django.contrib.auth import authenticate, login, logout, get_user_model
 from django.template import RequestContext
 from django.shortcuts import render_to_response
 from django.shortcuts import render
+
 import json
 
 from unfold.loginrequired import FreeAccessView
@@ -34,6 +35,8 @@ from myslice.theme import ThemeView
 # Edelberto LDAP authentication XXX
 import ldap
 
+#import activity.user
+
 class HomeView (FreeAccessView, ThemeView):
     template_name = 'home-view.html'
         
@@ -311,6 +314,8 @@ class HomeView (FreeAccessView, ThemeView):
                        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))
@@ -319,7 +324,12 @@ class HomeView (FreeAccessView, ThemeView):
         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
@@ -333,13 +343,22 @@ class HomeView (FreeAccessView, ThemeView):
                                 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:
+                user_cred = 'has_creds'
+           
+
+            env['pi'] = pi
+            env['user_cred'] = user_cred                
             env['person'] = self.request.user
         else: 
             env['person'] = None
index d28daba..0282e96 100644 (file)
@@ -23,6 +23,8 @@ from portal.actions             import authority_get_pi_emails, manifold_add_use
 
 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
 #
@@ -139,7 +141,7 @@ class JoinView (FreeAccessView, ThemeView):
                     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,
@@ -195,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, 
@@ -211,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') 
 
@@ -269,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)
index 899fbfd..8bd1cdc 100644 (file)
@@ -16,15 +16,11 @@ from myslice.configengine import ConfigEngine
 from myslice.theme import ThemeView
 import json
 
-import activity
-
 class ManagementAboutView (FreeAccessView, ThemeView):
     template_name = 'management-tab-about.html'
 
     def get (self, request):
         
-        activity.userLogin(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)
@@ -32,8 +28,9 @@ class ManagementAboutView (FreeAccessView, ThemeView):
             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')
-            
-            authority_query = Query().get('authority').select('description', 'authority_hrn', 'legal', 'address', 'abbreviated_name', 
+            # 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)
@@ -41,11 +38,13 @@ class ManagementAboutView (FreeAccessView, ThemeView):
             
             if authority_details :
                 authority_contacts = {}
-                authority_contacts['scientific'] = [ x.strip()[1:-1] for x in authority_details[0]['scientific'][1:-1].split(',') ]
-                authority_contacts['technical'] = [ x.strip()[1:-1] for x in authority_details[0]['tech'][1:-1].split(',') ]
-            
-                authority_contacts['legal'] = [ x.strip().replace('"','') for x in authority_details[0]['legal'][1:-1].split(',') ]
                 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
index 0f490e9..66f9991 100644 (file)
@@ -177,11 +177,11 @@ class ManagementRequestsView (LoginRequiredView, ThemeView):
 
         pi_authority = user_authority + '.' + user_username.split("@")[1]
         context = super(ManagementRequestsView, self).get_context_data(**kwargs)
-        print "testing"
-        print ctx_my_authorities
-       print auth_hrn
-       print user_username
-       print pi_authority
+        #print "testing"
+        #print ctx_my_authorities
+           #print auth_hrn
+           #print user_username
+           #print pi_authority
         context['my_authorities']   = ctx_my_authorities
         context['sub_authorities']   = ctx_sub_authorities
         context['delegation_authorities'] = ctx_delegation_authorities
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))
+
index 25a050a..c52689f 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
@@ -23,6 +24,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
 #
@@ -45,12 +48,13 @@ class RegistrationView (FreeAccessView, ThemeView):
         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
@@ -59,9 +63,8 @@ class RegistrationView (FreeAccessView, ThemeView):
             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']     
@@ -69,7 +72,9 @@ class RegistrationView (FreeAccessView, ThemeView):
             # 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()
@@ -88,7 +93,9 @@ class RegistrationView (FreeAccessView, ThemeView):
                 'pi'            : '',
                 'validation_link': 'https://' + 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(".", "_")
@@ -127,7 +134,8 @@ class RegistrationView (FreeAccessView, ThemeView):
             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
@@ -142,6 +150,18 @@ class RegistrationView (FreeAccessView, ThemeView):
             #         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('Please 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
@@ -176,10 +196,13 @@ class RegistrationView (FreeAccessView, ThemeView):
             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, 'REQINST':wsgi_request.POST.get('org_name', '').split(".")[1].upper()}) 
 
         else:
+            print "############ BREAKPOINT A #################"
             user_request = {}
             ## this is coming from onelab website onelab.eu
             reg_form = {
@@ -187,6 +210,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),
@@ -198,4 +224,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)
index c4c00db..97a11dd 100644 (file)
@@ -16,6 +16,8 @@ from myslice.theme import ThemeView
 
 import json, time, re
 
+import activity.user
+
 class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
     template_name = 'slicerequest_view.html'
     
@@ -33,7 +35,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
         errors = []
         slice_name =''
         purpose=''
-        exp_url=''
+        url=''
         authority_hrn = None
         authority_name = None
         # Retrieve the list of authorities
@@ -115,7 +117,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
                 'authority_hrn'     : authority_hrn,
                 'organization'      : wsgi_request.POST.get('org_name', ''),
                 'slice_name'        : wsgi_request.POST.get('slice_name', ''),
-                'exp_url'           : wsgi_request.POST.get('exp_url', ''),
+                'url'               : wsgi_request.POST.get('url', ''),
                 'purpose'           : wsgi_request.POST.get('purpose', ''),
                 'current_site'      : current_site
             }
@@ -148,7 +150,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
             if (purpose is None or purpose == ''):
                 errors.append('Experiment purpose is mandatory')
 
-            exp_url = slice_request['exp_url']
+            url = slice_request['url']
 
             if not errors:
                 if is_pi(wsgi_request, user_hrn, authority_hrn):
@@ -161,6 +163,9 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
                     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 = {}
@@ -173,7 +178,7 @@ class SliceRequestView (LoginRequiredAutoLogoutView, ThemeView):
             'purpose': purpose,
             'email': user_email,
             'user_hrn': user_hrn,
-            'exp_url': exp_url,
+            'url': url,
             'pi': pi,
             'authority_name': authority_name,        
             'authority_hrn': user_authority,
index e5614b0..fd66ffb 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
@@ -24,9 +24,12 @@ from plugins.testbeds                   import TestbedsPlugin
 from plugins.scheduler2                 import Scheduler2
 
 # Bristol plugin
-from plugins.univbrisfoam       import UnivbrisFoam
-from plugins.univbrisfv         import UnivbrisFv
-from plugins.univbrisfvf        import UnivbrisFvf
+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.columns_editor             import ColumnsEditor
 from plugins.sladialog                  import SlaDialog
@@ -63,15 +66,26 @@ 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.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',
-                'lease.lease_id', # Important for NITOS identify already existing leases
+                # - The lease_id is important for NITOS identify already existing
+                #   leases
+                'lease.lease_id', 
+
                 #'user.user_hrn',
                 #'application.measurement_point.counter'
         )
@@ -84,7 +98,7 @@ class SliceResourceView (LoginRequiredView, ThemeView):
         sq_lease       = aq.subquery('lease')
 
         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')
@@ -175,10 +189,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,
         )
 
         # --------------------------------------------------------------------------
@@ -216,22 +231,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(
@@ -290,7 +305,86 @@ class SliceResourceView (LoginRequiredView, ThemeView):
             )
 
             
+        # --------------------------------------------------------------------------
+        # 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 = None,
+                query_all = None,
+                   sync_query = 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,
+            #query = query_resource_all,
+        )
+       
         # --------------------------------------------------------------------------
         # SLA View and accept dialog
         
@@ -341,9 +435,12 @@ class SliceResourceView (LoginRequiredView, ThemeView):
         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['flowspaces_form']= univbrisfvform.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['pending_resources'] = pending_resources.render(self.request)
         template_env['sla_dialog'] = '' # sla_dialog.render(self.request)
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 5be1bf3..623285d 100644 (file)
@@ -8,13 +8,28 @@ body {
     margin:0;
     padding:0;
     height: 100%;
+    letter-spacing:0.3px;
 }
 a, a:active, a:focus {
     outline: 0;
     text-decoration:none;
-    color:#201E62;
+    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;
@@ -41,6 +56,32 @@ h4 {
     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;
@@ -69,6 +110,12 @@ div.breadcrumbs {
     color:gray;
     font-size:10pt;
 }
+div.breadcrumbs a {
+    color:gray;
+}
+div.breadcrumbs a:hover {
+    text-decoration:underline;
+}
 .tab-pane {
     padding-top:15px;
 }
@@ -380,7 +427,9 @@ a.sl-resources, a.sl-resources:hover {
     padding:2px 4px;
     -moz-border-radius: 4px;
     border-radius: 4px;
-    width:125px;
+    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 {
@@ -388,7 +437,13 @@ a.sl-resources.active, a.sl-resources.active:hover, a.sl-resources.active:focus
     -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;
 }
@@ -467,6 +522,8 @@ div#slice-info td {
     padding:3px 5px;
 }
 .slice-pending button.apply {
+    font-size:14px;
+    padding:2px 5px;
 }
 .slice-pending button.clear {
 }
@@ -596,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;
@@ -615,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;
@@ -706,3 +801,20 @@ div.slogan {
     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;
+}
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/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 cbad91c..8f2b0c1 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 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 validates 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..fd7278f 100644 (file)
@@ -18,7 +18,7 @@ You may now log in to the portal using your email address and the password that
        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.
 
 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 aa3062d..a7dc6fd 100644 (file)
@@ -88,10 +88,10 @@ $(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>
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 0ad8769..49fdbff 100644 (file)
@@ -6,9 +6,13 @@
        <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'%}
-               <h3>Signup request confirmed.</h3> 
+       {% if activation_status == 'success' %}
+               <h3>Signup request confirmed.</h3>
                <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>
+    {% 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, 
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>
 
 
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 eeb84a6..d22bdeb 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 = []; 
@@ -40,8 +52,8 @@
                                }
                        );
                }
-        };
-        function showMore(buttonId, divId){
+     };
+     function showMore(buttonId, divId){
           var element = document.getElementById(buttonId);
           var div_element = document.getElementById(divId);
           if (element.value === '(+)'){
             $('#'+divId).slideUp('fast');
           }
           return false;
-        }
+     }
+        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 %}
        {% if authority == pi_authority or authority == "fibre" %}
+
+<!--
        <div class="col-md-12">
                <h2>{{authority}}</h2>
                <table class="table">
                                                <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}}
+                                                       Login: {{request.login}} - First name: {{request.first_name}} - Last name: {{request.last_name}} - Email: {{request.email}}
                                                        <input type = "button" id = "moreBtn_{{request.id}}" value = "(+)" onclick = "showMore('moreBtn_{{request.id}}','reasons_{{request.id}}')" style="color:blue; padding:0; border:none; background:none">
                                                        <div id="reasons_{{request.id}}" style="display:none"> Reasons for Applying:<br> {{request.reasons}} </div> 
                                                {% else %}
                                                {% if request.type == 'slice' %}
-                                                               Slice name: {{request.slice_name}} -- User_hrn: {{ request.user_hrn }} -- Number of nodes: {{request.number_of_nodes}} -- Type of nodes: {{request.type_of_nodes}} -- Purpose: {{request.purpose}}
+                                                               Slice name: {{request.slice_name}} - User_hrn: {{ request.user_hrn }} - 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}}
+                                                               Authority name: {{request.site_name}} - authority_hrn: {{request.site_authority}} - City: {{request.address_city}} - Country: {{request.address_country}}
                                                {% endif %}
                                                {% endif %}
                                                </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 %}'> -->
+                           <!- <div class='portal_validate_request {{request.type}} {% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}'> 
                                {% endif %}
                                </tr>
                        {% endfor %}
                </table>
        </div>
        {% endif %}
-       {% endfor %}
+-->
+       
+        {% for request in requests %}
+        
+        {% if request.type == 'user' %}
+       <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 %}
+            </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;
+                       <input type = "button" id = "moreBtn_{{request.id}}" value = "(+)" onclick = "showMore('moreBtn_{{request.id}}','reasons_{{request.id}}')" style="color:blue; padding:0; border:none; background:none">
+               <div id="reasons_{{request.id}}" style="display:none"> Reasons for Applying:<br> {{request.reasons}} </div> 
 
+            {% 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 %}
        
 {% endif %}
 <br />
 <div class="col-md-12">
-       <h2>Authorities with delegation</h2>
+       <h2>From your authorities with delegation</h2>
 </div>
 
 {% if delegation_authorities %}
 <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..b1b6c29 100644 (file)
@@ -1,44 +1,35 @@
-{% 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">
+        <div class="col-md-12">
                        <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
+                               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="/register">register</a> to the portal. The portal administrative body
                                is responsible to accept or reject newly registered users.   
                        </p>
                        <p>
-                               To learn more about OneLab visit:  <a href="http://onelab.eu/" target="_blank">http://onelab.eu/</a>                    
+                               To learn more about OneLab 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 using the portal 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>
+                               OneLab portal is a community effort. To get more information about OneLab portal team visit: 
+                               <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">
                <div class="col-md-12">
+                       <br />
                        <h3>A ready-made and easily customisable user interface for your testbed.</h3>
                                <p>
                                        MySlice is an ambitious project aiming to support researchers throughout the lifecycle of experiments that can run on a variety 
@@ -47,7 +38,7 @@
                                </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 
+                                       MySlice has taken a big step toward becoming a stand-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.
                                </p>
                                <p>
@@ -63,6 +54,7 @@
                                </p>
                </div>
                <div class="col-md-12">
+                       <br />
                        <h3>Portal Components</h3>
                                <h5>Myslice (Web Frontend)</h5>
                                        <p>
@@ -72,7 +64,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>
 
 
        </div>
    </div>
 </div>
-
-<script>
-$(document).ready(function() {
-    $('.nav-tabs a').click(function (e) {
-        e.preventDefault();
-        $(this).tab('show');
-    });
-});
-</script>
-
-
 {% endblock %}
index 9941e97..199444a 100644 (file)
@@ -4,9 +4,13 @@
 <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%}
+
 </div>
 {% if messages %}
 <ul class="messages">
                                {%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">
index 21608da..2a7c60a 100644 (file)
@@ -17,7 +17,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 5dd577e..b3394d6 100644 (file)
@@ -6,7 +6,45 @@
 {% 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">
+                                       <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="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%}
+
        <div class="row">
                {%if 'is_pi'  in pi %}
                <div class="col-md-3">
@@ -17,7 +55,7 @@
                                <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>
@@ -182,4 +220,7 @@ This should go into session
 --------*/
 });
 </script>
+{# widget "_widget-monitor.html" #}
+{# widget "_widget-stats-top-slices.html" #}
+
 {% endblock %}
index c8a668f..bd361de 100644 (file)
                                        <th>+/-</th>
                                        <th>Email</th>
                                        <th>User hrn</th>
+                            <!--
                                        <th>First name</th>
                                        <th>Last name</th>
                                        <th>Enabled</th>
+                            -->
                                        </tr>
                                </table>
                                
@@ -65,7 +67,7 @@
                        <th>Users</th>
                        <th>Url</th>
                        <!-- <th>nodes</th> -->
-                       <th>Expiration</th>
+                       <th>Creation</th>
                    </tr>
                </table>                        
            </div>
@@ -90,7 +92,7 @@ $(document).ready(function() {
     {% if person %}
     {% if user_details.parent_authority %}
 
-        $.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" */
@@ -108,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+"'>";
@@ -120,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);
                 
@@ -133,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
@@ -146,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);
             });
index 687b7de..bc768a6 100644 (file)
@@ -4,19 +4,36 @@
                <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 />
-               {{authority.postcode}} {{authority.city}} <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 %}
@@ -24,6 +41,8 @@
        {% endfor %}
        </p>
        <br />
+    {% endif %}
+    {% if authority.scientific %}
        <h4>Scientific Contact:</h4>
        <p>
        {% for c in authority_contacts.scientific %}
        {% 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 %}
index 488e63e..e255779 100644 (file)
@@ -42,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>
 {% 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 %}
        
 {% endif %}
 
 <div class="col-md-12">
-       <h2>Authorities with delegation</h2>
+       <h2>From your authorities with delegation</h2>
 </div>
 
 {% if delegation_authorities %}
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() {
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 47068c4..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 %}
                                {%endif%}
                          </div>
                          <div class="form-group">
-                           <input type="text" class="form-control" name="exp_url" id="exp_url" style="width:300px" placeholder="Experiment URL (if one exists)"
-                               title="Please provide the url of your experiment if you have one." value="{{exp_url}}">
+                           <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>
-                         <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>
@@ -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..72e013d 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="tab-pane active row" id="faq">
                <div class="col-md-12">
                        <h2>Frequently Asked Questions (FAQs)<h2>
 
+                       <h3>PlanetLab Europe Users</h3>
+                       <ul>
+                               <li>
+                                       <h4>I am 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 to?</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, but this is not equivalent to the full access you 
+                                               currently enjoy through your PlanetLab Europe account.
+                                       </p>
+                               </li>
+                       </ul>
+                       
                        <h3>Users</h3>
                        <ul>
                        <li><h4>Who is a user?</h4></li>
                        
                        
                        <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 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>
                        
                        <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> 
@@ -79,7 +79,7 @@
                        <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>
                        
                        <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>
+                       <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>
                        
                </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 can adress any 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 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>
+                                       </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();
index fa0e896..4947947 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>
@@ -14,5 +14,9 @@
 <b>User hrn     :</b> {{user_hrn}}<br>
 <b>Portal url  :</b> {{ current_site }}<br>
 <p></p>
-<p>You can validate the user <a href="http://{{current_site}}/portal/validate">here</a>.<p>
-<p>Please note that the validation request will only become visible to you on the OneLab portal once the user has confirmed his/her email address.</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>
+
index b782e71..83ec9d3 100644 (file)
@@ -12,8 +12,10 @@ Email        : {{email}}
 User hrn     : {{user_hrn}}
 Portal url   : {{ current_site }}
 
-You can validate the user here: http://{{current_site}}/portal/validate
+You can see new user request in the portal: http://{{current_site}}/portal/validate
 
-Please note that the validation request will only become visible to you on the OneLab portal once the user has confirmed his/her email address.
+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 ee6c0d4..3520359 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,6 +481,7 @@ jQuery(document).ready(function(){
         {% for authority in authorities %}
             {% if authority.name %}
                 {value:"{{ authority.name }}",label:"{{authority.name}}"},
+                       // show hrn if we don't have the name
             {% else %}
                 {value:"{{ authority.authority_hrn }}",label:"{{authority.authority_hrn}}"},
             {% endif %}
index f3293ad..9419d13 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 you are a manager of your institution, your slice has directly been created.
 
 {% endblock %}
 
index 626b7f5..2346bf2 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>
@@ -50,7 +36,7 @@ $(document).ready(function() {
                        <div class="col-md-6">
                                {{ filter_status }}
                        </div>
-                       <div class="col-md-2">
+                       <div class="col-md-1">
                                {{ apply }}
                        </div>
                </div>
@@ -98,13 +84,25 @@ $(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="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..1430dae 100644 (file)
@@ -1,8 +1,77 @@
 <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>
+       <p class="command">
+               $ ssh your_slice_name@planetlab-resource.hostname.com
+       </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>
+       
+       <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 your_slice_name@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>
diff --git a/portal/templates/slice_request_denied.html b/portal/templates/slice_request_denied.html
new file mode 100644 (file)
index 0000000..c381413
--- /dev/null
@@ -0,0 +1,19 @@
+<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 in 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 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>
+<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..7dcbee3
--- /dev/null
@@ -0,0 +1,17 @@
+Dear OneLab user,
+
+You have recently requested the following slice in 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 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 a fruitful user experience on OneLab..
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
+
index 8306c2b..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>
+<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> {{exp_url}}</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 c8a51b5..997e752 100644 (file)
@@ -1,9 +1,21 @@
 NEW SLICE REQUEST
 
+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                    : {{exp_url}}
+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..c508a24
--- /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 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 glad to inform you that, a manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.</p>
+<p></p>
+<p>On behalf of the entire team, I wish you a fruitful user experience on OneLab.</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..f0cd3c5
--- /dev/null
@@ -0,0 +1,18 @@
+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 glad to inform you that, a manager of your institution has validated your slice request. You can now add resources to the slice and start experimenting.
+
+On behalf of the entire team, I wish you a fruitful user experience on OneLab.
+
+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 %}
-
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..fc88316
--- /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 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 on OneLab.</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..a9f956a
--- /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 individual nodes on the testbed with your OneLab public/private key pair, or 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 on OneLab.
+
+Yours sincerely,
+
+Timur Friedman
+Executive Director
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
-
index e6e63e6..907267c 100644 (file)
@@ -44,6 +44,7 @@ from portal.validationview          import ValidatePendingView
 #from portal.experimentview         import ExperimentView
 from portal.termsview               import TermsView
 from portal.univbrisview            import UnivbrisView
+from portal.manualdelegationview    import ManualDelegationView
 
 from portal.servicedirectory         import ServiceDirectoryView
 
@@ -94,12 +95,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'),
index d63babf..632600a 100644 (file)
@@ -7,15 +7,21 @@ def dispatch(request, action):
     if (action == 'clear') :
         res=[]
         emails = request.POST.getlist('emails[]')
+        if not emails:
+            emails = request.GET.getlist('emails[]')
+        import pdb
+        pdb.set_trace()
         if emails :
             for email in emails :
                 try :
-                    res.append(clear_user_creds(request, email))
+                    clear = clear_user_creds(request, email)
+                    if clear is not None:
+                        res.append(clear)
                 except :
                     pass
         
         if not res :
-            ret = { "ret" : 1, "emails" : res }
+            ret = { "ret" : 1, "emails" : emails }
         else :
             ret = { "ret" : 0 }
     
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