This feature is to implement the standard UWM solution in LEO with the ability to receive emaps from source wafer fab when shipments are made to Leominster.
This feature is to implement the standard UWM solution in LEO with the ability to receive emaps from source wafer fab when shipments are made to Leominster.
Missing check for supplier label at FQA when material has been converted to MU wafers
From Matt: "A situation occurred last week that highlighted a gap in our FQA label check scan of supplier labels/RDS labels for lots being converted to MUs.
RDS#277820 failed the scan because the supplier lot# did not match our OI records. Don investigat",
+ "Effort": 2987,
+ "Id": 109734,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Fuentes Jessica (FE MES P OPR)",
+ "ResolvedDate": null,
+ "Revision": 23,
+ "RiskReductionMinusOpportunityEnablement": 2228,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 2531,
+ "Title": "273 - Missing check for supplier label at FQA when material has been converted to MU wafers",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
In response to ICO-20-34_DI Water Resin High Sodium_8D we need to setup an automatic flag for Cleans tools PM’s and believe that the Reactor PM structure would work good
Would it be possible to take the Reactor PM section of which I have supplied screensh",
+ "Effort": 2228,
+ "Id": 109735,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 3,
+ "Relations": [],
+ "Requester": "Henderson Susan (FE MES FM)",
+ "ResolvedDate": null,
+ "Revision": 20,
+ "RiskReductionMinusOpportunityEnablement": 2152,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 2456,
+ "Title": "433 - Need ability to do PM on Cleans tools",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Need small interface for the user to edit the Cleaner - Carrier IDs
Also, I would like to address an issue that occurs every time a carrier gets pulled when it’s bad/damaged. When this occurs it generally takes a while to get the “NEW” carrier ID in the OI system and to have the actual carrier tags created by facilities.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Implement the RHEL 9 OS and YieldHUB upgrade on the EC network and successfully complete all unit and user testing scenarios. When finished we should be ready to schedule the go-live
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Breakdown of activities is not required.
",
+ "Effort": null,
+ "Id": 110730,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 10,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Operations Support",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Tucker Chase (CSC FI SPS MESLEO)",
+ "BusinessValue": 13076,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:21:59.927Z",
+ "Description": "Create a service to allow multiple PSN to be updated with new thickness and resistivity values by the mean of a template or check box list
ensure service updates both PSN tables in OI ",
+ "Effort": 8152,
+ "Id": 110737,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Cousten Mark (FE MES P UPE)",
+ "ResolvedDate": null,
+ "Revision": 16,
+ "RiskReductionMinusOpportunityEnablement": 13000,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 8835,
+ "Title": "503 - Create a service to allow multiple PSN to be updated with new thickness and resistivity values by the mean of a template",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": null,
+ "BusinessValue": 8228,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:22:54.597Z",
+ "Description": "Do not allow wafers to move to the outbound box unless the RDS has been closed (same as GaN) - need business process change approval
We have collectively had an issue for a while with Epi-Pro WMO’s at FQA. There are times when the operators have something that isn’t properly signed out (typically ROTR results) but they are still able to sign out the post epi section. The end result is",
+ "Effort": 3835,
+ "Id": 110738,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Holland Justin (FE MES P OPR SH C)",
+ "ResolvedDate": null,
+ "Revision": 19,
+ "RiskReductionMinusOpportunityEnablement": 8228,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 2759,
+ "Title": "507 - Do not allow wafers to move to the outbound box unless the RDS has been closed (same as GaN) - need business process chan",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
6/9/24 - keep per Justin OI doesn't always validate data entry, allowing bad dates/qtys/etc to be recorded. ",
+ "Effort": 20380,
+ "Id": 110743,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Holland Justin (FE MES P OPR SH C)",
+ "ResolvedDate": null,
+ "Revision": 18,
+ "RiskReductionMinusOpportunityEnablement": 1759,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 2000,
+ "Title": "636 - Methodically test OI forms for fields lacking data validations; e.g. Unload Qty, Unload Date/Time",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": null,
+ "BusinessValue": 1683,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:34:35.03Z",
+ "Description": "Modify OI to allow generic login and validate user based on badge scan at time of transaction. This is consistent with other sites. The feasibility/risk needs to be validated with assistance from SRP
OI User Access requiring Operator (all staff) to logon to the client with their netwotk credentials is inefficient and drives the "workaround" of using the OI thick client as a second session. ",
+ "Effort": 20456,
+ "Id": 110744,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Fuentes Jessica (FE MES P OPR)",
+ "ResolvedDate": null,
+ "Revision": 18,
+ "RiskReductionMinusOpportunityEnablement": 1683,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 1987,
+ "Title": "637 - Modify OI to allow generic login and validate user based on badge scan at time of transaction. This is consistent with o",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": null,
+ "BusinessValue": 1228,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:35:57.477Z",
+ "Description": "Create a new tool mode to indicate that a tool is ready to be used, but not being used by production
There are tools, such as the BAGGERS(lot packaging tools) that would be physically removed from production, repaired, then left undeployed until needed. The request is to have a mode for non-reactor equipment that would indicate a tool has been repaired, ",
+ "Effort": 1835,
+ "Id": 110750,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Henderson Susan (FE MES FM)",
+ "ResolvedDate": null,
+ "Revision": 19,
+ "RiskReductionMinusOpportunityEnablement": 1228,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 1531,
+ "Title": "714 - Create a new tool mode to indicate that a tool is ready to be used, but not being used by production",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Currently at unload metrology overrides are only required for users not designated as an operator. If the user is designated as a Lead, supervisor, or engineer the data can be manually entered without logging an override. We can change the code to prompt ",
+ "Effort": 8911,
+ "Id": 110757,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Fuentes Jessica (FE MES P OPR)",
+ "ResolvedDate": null,
+ "Revision": 17,
+ "RiskReductionMinusOpportunityEnablement": 2607,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 8759,
+ "Title": "730 - Require and log overrides for ALL users for manual data entry at all metrology entry steps",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Request is to not have to go to two different locations to sign off verifications and calibrations. The request is specifically for the SPV but it would make more sense to do this for all non-reactors. Possibly take the concept of the reactor status form ",
+ "Effort": 5380,
+ "Id": 110759,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "McChesney Peyton (FE MES P UPE)",
+ "ResolvedDate": null,
+ "Revision": 19,
+ "RiskReductionMinusOpportunityEnablement": 2456,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 3228,
+ "Title": "736 - Simplify logging of calibration and verifications into one UI.",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
When an administrator manually executes an ECN training, they are shown a list of the groups currently included in the training. If they clear this list and add new groups, the previous groups are still included in the new training assignment. ",
+ "Effort": 8607,
+ "Id": 110771,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "McIntyre Juanita (FE MES QM)",
+ "ResolvedDate": null,
+ "Revision": 16,
+ "RiskReductionMinusOpportunityEnablement": 3683,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "Fab Approval",
+ "TargetDate": null,
+ "TimeCriticality": 3835,
+ "Title": "783 - Manually executing ECN training does not clear previous groups",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": null,
+ "BusinessValue": 3456,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:46:38.883Z",
+ "Description": "Deactivating user should remove them from all training groups and any active training tasks
There are two methods for deactivating a user in Fab Approval. One method performs the requested actions. The other does not. This request would reconcile these different outcomes.",
+ "Effort": 8380,
+ "Id": 110773,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "McIntyre Juanita (FE MES QM)",
+ "ResolvedDate": null,
+ "Revision": 17,
+ "RiskReductionMinusOpportunityEnablement": 3531,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "Fab Approval",
+ "TargetDate": null,
+ "TimeCriticality": 3683,
+ "Title": "786 - Deactivating user should remove them from all training groups and any active training tasks",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Makeup wafer records are being written to the MAKEUP_WAFERS table when an RDS record is reused/reassigned and was previously a makeup cassette. This triggers a write to the WO_MAT table on the old associated record which propogates to the MAKEUP_WAFERS ta",
+ "Effort": 1076,
+ "Id": 110774,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Fuentes Jessica (FE MES P OPR)",
+ "ResolvedDate": null,
+ "Revision": 17,
+ "RiskReductionMinusOpportunityEnablement": 3456,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 3607,
+ "Title": "796 - Fix root cause of invalid lots showing up in makeup inventory report",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": null,
+ "BusinessValue": 3228,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:46:50.6Z",
+ "Description": "When creating an NCR for a lot on hold, the save process is blocked and the user must navigate away from the current form back to the Pre-Epi form to take the lot off of hold. A method of taking the lot off of hold from the NCR form would avoid this.
Create a dedicated dialog form for hold transactions that can be called from any form and integrate this into the NCR work flow.",
+ "Effort": 2835,
+ "Id": 110776,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Holland Justin (FE MES P OPR SH C)",
+ "ResolvedDate": null,
+ "Revision": 17,
+ "RiskReductionMinusOpportunityEnablement": 3304,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 3456,
+ "Title": "798 - When creating an NCR for a lot on hold, the save process is blocked and the user must navigate away from the current form",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": null,
+ "BusinessValue": 3152,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:46:51.663Z",
+ "Description": "When an RDS is locked by another user and is viewed by another user, OI presents a series of dialog messages regarding the lock that must be clicked through in order to view the form. Ideally users would only receive one dialog message informing them that
Remove additional lock dialog messages from RDS forms. ",
+ "Effort": 2531,
+ "Id": 110777,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Holland Justin (FE MES P OPR SH C)",
+ "ResolvedDate": null,
+ "Revision": 17,
+ "RiskReductionMinusOpportunityEnablement": 3228,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 3380,
+ "Title": "799 - When an RDS is locked by another user and is viewed by another user, OI presents a series of dialog messages regarding th",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Production recipe is not automatically reloaded on HTR reactors after SPV test is done. This has led to running entire cassettes with the test recipe by accident. This improvement would remind the operator to change the recipe in the reactor to the correc",
+ "Effort": 3000,
+ "Id": 110780,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.2",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Holland Justin (FE MES P OPR SH C)",
+ "ResolvedDate": "2024-12-17T07:46:09.727Z",
+ "Revision": 21,
+ "RiskReductionMinusOpportunityEnablement": 13835,
+ "StartDate": null,
+ "State": "Closed",
+ "Tags": "OI",
+ "TargetDate": "2025-02-21T19:00:00Z",
+ "TimeCriticality": 20228,
+ "Title": "810 - Notify operator after SPV test to reload production recipe for HTR reactors",
+ "Violation": null,
+ "WeightedShortestJobFirst": 4,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Possibly tie into the trilam scan with a .R or .L and log to lot history or INV Actions.",
+ "Effort": 1,
+ "Id": 110784,
+ "IterationPath": "ART SPS\\2024\\PI3\\Sprint 3.2",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Holland Justin (MFG SHIFT 3)",
+ "ResolvedDate": "2024-09-18T15:45:48.69Z",
+ "Revision": 10,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": null,
+ "State": "Closed",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 3,
+ "Title": "816 - Build into Packaging routine a way of identifying which bagger was used (R or L)",
+ "Violation": null,
+ "WeightedShortestJobFirst": 3,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": null,
+ "BusinessValue": 20000,
+ "ChangedDate": "2024-10-31T15:00:00.77Z",
+ "ClosedDate": null,
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:47:02.11Z",
+ "Description": "Rework intrusive maintenance checklists to use a small set of process flows rather than individually marking each reactor service as 'intrusive'. (prove-in)
The current design for generating an intrusive maintenance checklist in NICA is triggered by the reactor services being marked as either intrusive or not intrusive. This change would mark each service with an optional process flow that can be refereneced ",
+ "Effort": 13607,
+ "Id": 110785,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Fuentes Jessica (FE MES P OPR)",
+ "ResolvedDate": null,
+ "Revision": 25,
+ "RiskReductionMinusOpportunityEnablement": 20076,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI; OI Web Services",
+ "TargetDate": "2025-01-20T07:00:00Z",
+ "TimeCriticality": 13987,
+ "Title": "820 - Rework intrusive maintenance checklists to use a small set of process flows rather than individually marking each reactor",
+ "Violation": null,
+ "WeightedShortestJobFirst": 2,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
See RDS 634223 and COMM_QA_MET_RESULT lines 165 - 180. It appears the standard deviation max specification is dynamically set and is not defined at the PSN level. Per Justin H. the standard deviation result is no longer necessary because the form now validates whether each wafer is within spec or not.
See RDS 634223 and COMM_QA_MET_RESULT lines 165 - 180. It appears the standard deviation max specification is dynamically set and is not defined at the PSN level. Per Justin H. the standard deviation result is no longer necessary because the form now vali",
+ "Effort": 2152,
+ "Id": 110793,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Cousten Mark (FE MES P UPE)",
+ "ResolvedDate": null,
+ "Revision": 16,
+ "RiskReductionMinusOpportunityEnablement": 8835,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 5228,
+ "Title": "834 - Auto add backside defect parameters when Virgin wafer button is clicked on the PRS Stage form.",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Prompt user to ask if a test wafer is required on the unload operation of the final cassette of an HTR work order only if the next work order is not the same PSN or there is no event scheduled next.
Modify auto-scheduler such that load operations of cassettes do not automatically cause the work order event to be considered engaged (active) and supersede previously scheduled work order events.
",
+ "Effort": 8076,
+ "Id": 110796,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Holland Justin (FE MES P OPR SH C)",
+ "ResolvedDate": null,
+ "Revision": 25,
+ "RiskReductionMinusOpportunityEnablement": 3759,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": "2025-01-31T19:00:00Z",
+ "TimeCriticality": 5456,
+ "Title": "839 - Modify auto-scheduler such that load operations of cassettes do not automatically cause the work order event to be considered engaged (active) and supersede previously scheduled work order events",
+ "Violation": null,
+ "WeightedShortestJobFirst": 1,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Have in OI if the wafer counter equip goes down need to measure 2 wafers slots 1 & 25.
Now that wafer counters are in place, the stratus QA metrology tests prescribed for slot 1 and 25 will be reduced to just slot 25. In the event that the FQA wafer counter for a given wafer size goes into an unproductive state, all unprocessed cassettes should have their prescribed metrology automatically updated such that both slots 1 and 25 are required.
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": "2024-08-29T17:29:48.113Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Stieber Daniel (CSC FI SPS MESLEO)",
+ "BusinessValue": 8987,
+ "ChangedDate": "2025-01-06T19:07:24.353Z",
+ "ClosedDate": "2025-01-06T19:07:24.353Z",
+ "CommentCount": 2,
+ "CreatedDate": "2024-08-14T23:47:12.74Z",
+ "Description": "Wrong RDS #'s entered. NCR created on wrong RDS. Wrong lot # was scrapped out. Possibly use of barcode scanners. Have a pop up block for validation with barcode scanner. If no scanner, undo NCR as an FI function.
Prompt for RDS / WMO barcode scan when creating an NCR. If Barcode does not match the active RDS / WMO box in OI session, then throw error and abort NCR creation.",
+ "Effort": 1456,
+ "Id": 110798,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.2",
+ "Parent": 110729,
+ "Priority": 2,
+ "Relations": [],
+ "Requester": "Fuentes Jessica (FE MES P OPR)",
+ "ResolvedDate": "2025-01-06T19:07:24.353Z",
+ "Revision": 26,
+ "RiskReductionMinusOpportunityEnablement": 8304,
+ "StartDate": null,
+ "State": "Closed",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 8911,
+ "Title": "841 - Wrong RDS #'s entered. NCR created on wrong RDS. Wrong lot # was scrapped out. Possibly use of barcode scanners. Have a p",
+ "Violation": null,
+ "WeightedShortestJobFirst": 0,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Ouellette Jonathan (CSC FI SPS MESLEO)",
+ "BusinessValue": 2,
+ "ChangedDate": "2024-10-21T21:12:49.257Z",
+ "ClosedDate": "2024-09-12T17:23:40.623Z",
+ "CommentCount": 1,
+ "CreatedDate": "2024-08-14T23:47:14.367Z",
+ "Description": "Add the ability to place multiple lots (i.e., RDS or WM_OUT records) on hold at once instead of one at a time.
Currently RDS cassettes can only be placed on hold within the RDS_PRE_EPI form and WM_OUT cassettes can only be placed on hold within the WM_OUT form. Add option to place on hold / take off hold to the NDW_RDS_QUERY and NDW_WM_OUT_QUICK_QUERY forms. Consider refactoring obj_WO_Mat('ToggleHold') function into a service module.",
+ "Effort": 2,
+ "Id": 110799,
+ "IterationPath": "ART SPS\\2024\\PI3\\Sprint 3.2",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Holland Justin (FE MES P OPR SH C)",
+ "ResolvedDate": "2024-09-12T17:23:40.623Z",
+ "Revision": 13,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": null,
+ "State": "Closed",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 3,
+ "Title": "842 - Add the ability to place multiple lots (i.e., RDS or WM_OUT records) on hold at once instead of one at a time.",
+ "Violation": null,
+ "WeightedShortestJobFirst": 3,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": "2024-12-17T07:53:10.31Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Ouellette Jonathan (CSC FI SPS MESLEO)",
+ "BusinessValue": 13911,
+ "ChangedDate": "2025-01-17T16:08:38.517Z",
+ "ClosedDate": "2025-01-17T16:08:38.517Z",
+ "CommentCount": 2,
+ "CreatedDate": "2024-08-14T23:47:15.683Z",
+ "Description": "Recreate a 5S task list similar to production for use in Shipping and Receiving area. This is the result of an audit finding.
Recreate seperately what was created for Fab 5S tracking for use in Shipping and Receiving",
+ "Effort": 1987,
+ "Id": 110800,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.2",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Eschenauer Scott (FE CF OPC MM EPI MLOG REC)",
+ "ResolvedDate": "2024-12-17T07:53:10.31Z",
+ "Revision": 26,
+ "RiskReductionMinusOpportunityEnablement": 13987,
+ "StartDate": null,
+ "State": "Closed",
+ "Tags": "OI",
+ "TargetDate": "2025-01-20T07:00:00Z",
+ "TimeCriticality": 8380,
+ "Title": "843 - Recreate a 5S task list similar to production for use in Shipping and Receiving area. This is the result of an audit find",
+ "Violation": null,
+ "WeightedShortestJobFirst": 6,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
This request requires adding text when hovering over Active Reactor Prove In icon in OI that displays the percent complete of the NICA order. This request also requires a modification to the NICA API in OI Web Services to gather the percent complete and a",
+ "Effort": 1911,
+ "Id": 110801,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Marstein Daniel (FE MES P OPR SH D)",
+ "ResolvedDate": "2025-01-22T23:15:20.397Z",
+ "Revision": 30,
+ "RiskReductionMinusOpportunityEnablement": 5076,
+ "StartDate": null,
+ "State": "Closed",
+ "Tags": "OI; OI Web Services",
+ "TargetDate": null,
+ "TimeCriticality": 5304,
+ "Title": "845 - Display percent complete for reactor prove in orders in NICA",
+ "Violation": null,
+ "WeightedShortestJobFirst": 3,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
",
+ "Effort": null,
+ "Id": 110729,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": null,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "ResolvedDate": null,
+ "Revision": 11,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": "2024-08-04T22:00:00Z",
+ "State": "Active",
+ "Tags": null,
+ "TargetDate": "2024-10-24T22:00:00Z",
+ "TimeCriticality": null,
+ "Title": "MES Small Local Enhancements",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Epic"
+ },
+ "Children": [],
+ "Related": [],
+ "Successors": []
+ },
+ {
+ "WorkItem": {
+ "ActivatedDate": null,
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Ouellette Jonathan (CSC FI SPS MESLEO)",
+ "BusinessValue": 8607,
+ "ChangedDate": "2024-12-17T07:40:15.977Z",
+ "ClosedDate": null,
+ "CommentCount": 2,
+ "CreatedDate": "2024-08-14T23:47:22.18Z",
+ "Description": "Change method for determining eligble cassettes that can be peeled off. Look at Curr Status of all lots in a WO, then determine if they are pre-epi. If they are pre-epi they are eligible to be peeled off.
Currently the method to determine eligible lots is rudementary. It starts by going from the end of a list of lots and stops once it detects a signature. This is a poor method because lots mid WO may have no signature and they are never evaluated to determ",
+ "Effort": 5076,
+ "Id": 110806,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Chow Bobby (FE CF OPC MM EPI)",
+ "ResolvedDate": null,
+ "Revision": 31,
+ "RiskReductionMinusOpportunityEnablement": 8683,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 13228,
+ "Title": "856 - Change method for determining eligible cassettes that can be peeled off. Look at Curr Status of all lots in a WO, then det",
+ "Violation": null,
+ "WeightedShortestJobFirst": 3,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
Currently there is no supported method to re-shipping lots that have returned for an RMA. These are lots that are returned from a customer and are shipped back out to the same customer withg the same part no",
+ "Effort": 5759,
+ "Id": 111882,
+ "IterationPath": "ART SPS\\2024\\PI4\\Sprint 4.4",
+ "Parent": 110729,
+ "Priority": 1,
+ "Relations": [],
+ "Requester": "Quinones Debra (FE CF OPC MM EPI MLOG SHI)",
+ "ResolvedDate": null,
+ "Revision": 26,
+ "RiskReductionMinusOpportunityEnablement": 8531,
+ "StartDate": null,
+ "State": "Active",
+ "Tags": "OI",
+ "TargetDate": null,
+ "TimeCriticality": 5911,
+ "Title": "862 - Create method for re-shipping non-epp and epp lots when they return from customer for an RMA",
+ "Violation": null,
+ "WeightedShortestJobFirst": 2,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
When logging services generates a log file it does so at a pre-defined path. If the path doesn't exist it causes execution of the program to error out and halt. This request is to change Logging Services to create the directory structure defined in the logging path if it doesn't exist.
Currently the mean time to repair (MTTR), mean time between failure (MTBF), and green to green (G2G) charts in Fabtime are incorrect and do not match data extracted from OpenInsight.
Currently notifications for scheduled PMs that are coming due, currently due, or overdue are limited to users on the current shift, next shift, and supervisors. There is a need for notifications to be sent to other groups as needed such as the engineering group.
We\nwould also like to see if we can trigger the NICA checklist using the load lock\nstart up note added by maintenance once a load lock is recorded back up.
\n
Placing load lock down
\n
Load lock repaired and start up note added (Triggers\n NICA Checklist)
Fabtime has the ability to generate charts based on a shift calendar, which enables additional reporting such as month-over-month, year-over-year, etc. OpenInsight needs to generate this shift calendar table based off of the fiscal year table and export it to the Scrape DB.
This feature is to implement the standard UWM solution in LEO with the ability to receive emaps from source wafer fab when shipments are made to Leominster.
This feature is to implement the standard UWM solution in LEO with the ability to receive emaps from source wafer fab when shipments are made to Leominster.
Following completion of production installation and IT buy-off, deploy the RHEL 9-based YieldHUB upgrade on the EC network and successfully complete all unit and user testing scenarios. When finished we should be ready to schedule the go-live
This feature is to implement the Camstar Recipes proof of concept for the Leominster site, as well as evaluate barcode scanning and Tool Plans in assembly where relevant.
After a TECN expires or is canceled, a task needs to be created for the Originator to confirm that the process was returned to its original state. This confirmation should include a comment, a record of who completed the task, and a timestamp of when the task was completed.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
Specific reactor aborts (specific mode categories selected during mode changes) need to trigger their respective NICA OCAP checklist. The NICA document(s) have not yet been created. Currently work instruction "EpiMSA WI-002202 Rev A Process Interruption - Abort - Alarm Checklist" is being used located in MesaDocs (see path below).
\\\\messdv003.infineon.com\\MesaDocs\\1. Mesa Released Documents\\Manufacturing\\Reactor\\Work Instructions\\EpiMSA WI-0022-2 Rev A Process Interruption - Abort - Alarm Checklist
Enhancement comes as a result of an audit finding.
When a calibration is performed such as for Tencor, biorad, or a HgCV tools. We\nuse Open Insight to print the calibration sticker rather than having to hand\nwrite it. The metrology team has to record the calibration in OI, so my\nsuggestion would be using this information to trigger the label to print to\nsmaller zebra printer (MESZBRPRT008) we currently have by the supervisor’s\ndesk.
We\nwould want to print the calibration label with at least:
Currently the wafer size of a reactor needs to be changed manually on top of selecting a reactor log service to install a different susceptor. This should be modified such that the susceptor size of a reactor is instead read from the installed susceptor react item.
",
+ "Effort": null,
+ "Id": 202208,
+ "IterationPath": "ART SPS",
+ "Parent": 110729,
+ "Priority": 4,
+ "Relations": [],
+ "Requester": "Henderson Susan (FE MES FM)",
+ "ResolvedDate": null,
+ "Revision": 4,
+ "RiskReductionMinusOpportunityEnablement": null,
+ "StartDate": null,
+ "State": "New",
+ "Tags": "OI; OI Web Services",
+ "TargetDate": null,
+ "TimeCriticality": null,
+ "Title": "Modify the Wafer Size property of the Reactor to be read from the installed susceptor size",
+ "Violation": null,
+ "WeightedShortestJobFirst": null,
+ "WorkItemType": "Feature"
+ },
+ "Parent": {
+ "ActivatedDate": "2025-01-07T17:06:55.11Z",
+ "AreaPath": "ART SPS\\MES",
+ "AssignedTo": "Jarsey Martha (CSC FI SPS MESLEO)",
+ "BusinessValue": null,
+ "ChangedDate": "2025-01-22T17:03:59.963Z",
+ "ClosedDate": null,
+ "CommentCount": 0,
+ "CreatedDate": "2024-08-14T22:24:37.91Z",
+ "Description": "
Umbrella Epic to represent local requests where effort is < 1 qtr and there are no cross department dependencies.
CoolMOS parts require inspection of the tool every x runs. OpenInsight needs to be able to track the number of cassettes ran on a particular reactor when a CoolMOS part is running. Once x number of cassettes have been unloaded, OpenInsight should automatically place the tool into MAINTENANCE_UNSCHEDULED (or perhaps WAITIING_FOR_MAINTENANCE) and add a service to the REACTOR_LOG for that mode change.
Individual OpenInsight servers for each developer are needed due to a two user limit on MESTSA01EC imposed by ITOS (due to Remote Desktop Services licenses not being issued). Furthermore, only one developer can debug web API requests at any given time.
Add a new tab to the reactor log form (and OI Wizard page) for reactor ratios. Reactors can have up to 16 ratios depending on the reactor type. Upon adding a particular service ID to a reactor log (ask requestor for more details), reactor ratios will be required to be entered on the ratio tab in order to sign the reactor log.
Use ePortal IFAM ECC | Former IR 100 ERP on mobile scanners. This will allow shipping department to scan cassettes and the shelf location for greater accuracy and fewer human errors.
Umbrella Epic to capture demand on capacity for Operations support including; admin tasks, user setup, issues and incidents, routine updates/upgrades, systems monitoring, vendor engagement, production meetings, on-call support.
";
}
element.innerHTML = html.replaceAll(">null<", "> <");
diff --git a/Adaptation/FileHandlers/json/StaticSite/js/jquery/v1.6.4/jquery.js b/Adaptation/FileHandlers/json/StaticSite/js/jquery/v1.6.4/jquery.js
new file mode 100644
index 0000000..55361fe
--- /dev/null
+++ b/Adaptation/FileHandlers/json/StaticSite/js/jquery/v1.6.4/jquery.js
@@ -0,0 +1,9046 @@
+/*!
+ * jQuery JavaScript Library v1.6.4
+ * http://jquery.com/
+ *
+ * Copyright 2011, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2011, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Mon Sep 12 18:54:48 2011 -0400
+ */
+(function( window, undefined ) {
+
+ // Use the correct document accordingly with window argument (sandbox)
+ var document = window.document,
+ navigator = window.navigator,
+ location = window.location;
+ var jQuery = (function() {
+
+ // Define a local copy of jQuery
+ var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context, rootjQuery );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // Prioritize #id over to avoid XSS via location.hash (#9521)
+ quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+
+ // Used for trimming whitespace
+ trimLeft = /^\s+/,
+ trimRight = /\s+$/,
+
+ // Check for digits
+ rdigit = /\d/,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+
+ // Useragent RegExp
+ rwebkit = /(webkit)[ \/]([\w.]+)/,
+ ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
+ rmsie = /(msie) ([\w.]+)/,
+ rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
+
+ // Matches dashed string for camelizing
+ rdashAlpha = /-([a-z]|[0-9])/ig,
+ rmsPrefix = /^-ms-/,
+
+ // Used by jQuery.camelCase as callback to replace()
+ fcamelCase = function( all, letter ) {
+ return ( letter + "" ).toUpperCase();
+ },
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // The deferred used on DOM ready
+ readyList,
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwn = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ trim = String.prototype.trim,
+ indexOf = Array.prototype.indexOf,
+
+ // [[Class]] -> type pairs
+ class2type = {};
+
+ jQuery.fn = jQuery.prototype = {
+ constructor: jQuery,
+ init: function( selector, context, rootjQuery ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // The body element only exists once, optimize finding it
+ if ( selector === "body" && !context && document.body ) {
+ this.context = document;
+ this[0] = document.body;
+ this.selector = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ 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 = quickExpr.exec( selector );
+ }
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ context = context instanceof jQuery ? context[0] : context;
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
+ }
+
+ return jQuery.merge( this, selector );
+
+ // 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: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector != undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.6.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // 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 == undefined ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this[ this.length + num ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = this.constructor();
+
+ if ( jQuery.isArray( elems ) ) {
+ push.apply( ret, elems );
+
+ } else {
+ jQuery.merge( ret, elems );
+ }
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // 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 );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // Add the callback
+ readyList.done( fn );
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ 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: [].sort,
+ splice: [].splice
+ };
+
+ // Give the init function the jQuery prototype for later instantiation
+ jQuery.fn.init.prototype = jQuery.fn;
+
+ jQuery.extend = jQuery.fn.extend = function() {
+ var options, name, src, copy, copyIsArray, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // 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 ( length === i ) {
+ 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({
+ noConflict: function( deep ) {
+ if ( window.$ === jQuery ) {
+ window.$ = _$;
+ }
+
+ if ( deep && window.jQuery === jQuery ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // 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 ) {
+ // Either a released hold or an DOMready/load event and not yet ready
+ if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // 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" ).unbind( "ready" );
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyList ) {
+ return;
+ }
+
+ readyList = jQuery._Deferred();
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent( "onreadystatechange", DOMContentLoaded );
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == undefined;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // 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";
+ },
+
+ // A crude way of determining if an object is a window
+ isWindow: function( obj ) {
+ return obj && typeof obj === "object" && "setInterval" in obj;
+ },
+
+ isNaN: function( obj ) {
+ return obj == undefined || !rdigit.test( obj ) || isNaN( obj );
+ },
+
+ type: function( obj ) {
+ return obj == undefined ?
+ String( obj ) :
+ class2type[ toString.call(obj) ] || "object";
+ },
+
+ isPlainObject: function( obj ) {
+ // 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;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key == undefined || hasOwn.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ error: function( msg ) {
+ throw msg;
+ },
+
+ parseJSON: function( data ) {
+ if ( typeof data !== "string" || !data ) {
+ return null;
+ }
+
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
+ data = jQuery.trim( data );
+
+ // Attempt to parse using the native JSON parser first
+ if ( window.JSON && window.JSON.parse ) {
+ return window.JSON.parse( data );
+ }
+
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if ( rvalidchars.test( data.replace( rvalidescape, "@" )
+ .replace( rvalidtokens, "]" )
+ .replace( rvalidbraces, "")) ) {
+
+ return (new Function( "return " + data ))();
+
+ }
+ jQuery.error( "Invalid JSON: " + data );
+ },
+
+ // Cross-browser xml parsing
+ parseXML: function( data ) {
+ var xml, tmp;
+ 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;
+ },
+
+ noop: function() {},
+
+ // 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 && rnotwhite.test( 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.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length == undefined || jQuery.isFunction( object );
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
+ break;
+ }
+ }
+ }
+ }
+
+ return object;
+ },
+
+ // Use native String.trim function wherever possible
+ trim: trim ?
+ function( text ) {
+ return text == undefined ?
+ "" :
+ trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == undefined ?
+ "" :
+ text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
+ var type = jQuery.type( array );
+
+ if ( array.length == undefined || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( !array ) {
+ return -1;
+ }
+
+ if ( indexOf ) {
+ return indexOf.call( array, elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length,
+ j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+
+ } else {
+ while ( second[j] != undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [], retVal;
+ inv = !!inv;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ retVal = !!callback( elems[ i ], i );
+ if ( inv !== retVal ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var value, key, ret = [],
+ i = 0,
+ length = elems.length,
+ // jquery objects are treated as arrays
+ isArray = elems instanceof jQuery || length != undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
+
+ // Go through the array, translating each of the items to their
+ if ( isArray ) {
+ for ( ; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ // Go through every key on the object,
+ } else {
+ for ( key in elems ) {
+ value = callback( elems[ key ], key, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+ }
+
+ // Flatten any nested arrays
+ return ret.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 ) {
+ if ( typeof context === "string" ) {
+ var 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
+ var args = slice.call( arguments, 2 ),
+ proxy = function() {
+ return fn.apply( context, 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 || proxy.guid || jQuery.guid++;
+
+ return proxy;
+ },
+
+ // Mutifunctional method to get and set values to a collection
+ // The value/s can optionally be executed if it's a function
+ access: function( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ jQuery.access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value != undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : undefined;
+ },
+
+ now: function() {
+ return (new Date()).getTime();
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ ua = ua.toLowerCase();
+
+ var match = rwebkit.exec( ua ) ||
+ ropera.exec( ua ) ||
+ rmsie.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
+ [];
+
+ return { browser: match[1] || "", version: match[2] || "0" };
+ },
+
+ sub: function() {
+ function jQuerySub( selector, context ) {
+ return new jQuerySub.fn.init( selector, context );
+ }
+ jQuery.extend( true, jQuerySub, this );
+ jQuerySub.superclass = this;
+ jQuerySub.fn = jQuerySub.prototype = this();
+ jQuerySub.fn.constructor = jQuerySub;
+ jQuerySub.sub = this.sub;
+ jQuerySub.fn.init = function init( selector, context ) {
+ if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
+ context = jQuerySub( context );
+ }
+
+ return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
+ };
+ jQuerySub.fn.init.prototype = jQuerySub.fn;
+ var rootjQuerySub = jQuerySub(document);
+ return jQuerySub;
+ },
+
+ browser: {}
+ });
+
+ // Populate the class2type map
+ jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+ });
+
+ browserMatch = jQuery.uaMatch( userAgent );
+ if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+ }
+
+ // Deprecated, use jQuery.browser.webkit instead
+ if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+ }
+
+ // IE doesn't match non-breaking spaces with \s
+ if ( rnotwhite.test( "\xA0" ) ) {
+ trimLeft = /^[\s\xA0]+/;
+ trimRight = /[\s\xA0]+$/;
+ }
+
+ // All jQuery objects should point back to these
+ rootjQuery = jQuery(document);
+
+ // Cleanup functions for the document ready method
+ if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+ } else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+ }
+
+ // The DOM ready check for Internet Explorer
+ function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch(e) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+ }
+
+ return jQuery;
+
+ })();
+
+
+ var // Promise methods
+ promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
+ // Static reference to slice
+ sliceDeferred = [].slice;
+
+ jQuery.extend({
+ // Create a simple deferred (one callbacks list)
+ _Deferred: function() {
+ var // callbacks list
+ callbacks = [],
+ // stored [ context , args ]
+ fired,
+ // to avoid firing when already doing so
+ firing,
+ // flag to know if the deferred has been cancelled
+ cancelled,
+ // the deferred itself
+ deferred = {
+
+ // done( f1, f2, ...)
+ done: function() {
+ if ( !cancelled ) {
+ var args = arguments,
+ i,
+ length,
+ elem,
+ type,
+ _fired;
+ if ( fired ) {
+ _fired = fired;
+ fired = 0;
+ }
+ for ( i = 0, length = args.length; i < length; i++ ) {
+ elem = args[ i ];
+ type = jQuery.type( elem );
+ if ( type === "array" ) {
+ deferred.done.apply( deferred, elem );
+ } else if ( type === "function" ) {
+ callbacks.push( elem );
+ }
+ }
+ if ( _fired ) {
+ deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
+ }
+ }
+ return this;
+ },
+
+ // resolve with given context and args
+ resolveWith: function( context, args ) {
+ if ( !cancelled && !fired && !firing ) {
+ // make sure args are available (#8421)
+ args = args || [];
+ firing = 1;
+ try {
+ while( callbacks[ 0 ] ) {
+ callbacks.shift().apply( context, args );
+ }
+ }
+ finally {
+ fired = [ context, args ];
+ firing = 0;
+ }
+ }
+ return this;
+ },
+
+ // resolve with this as context and given arguments
+ resolve: function() {
+ deferred.resolveWith( this, arguments );
+ return this;
+ },
+
+ // Has this deferred been resolved?
+ isResolved: function() {
+ return !!( firing || fired );
+ },
+
+ // Cancel
+ cancel: function() {
+ cancelled = 1;
+ callbacks = [];
+ return this;
+ }
+ };
+
+ return deferred;
+ },
+
+ // Full fledged deferred (two callbacks list)
+ Deferred: function( func ) {
+ var deferred = jQuery._Deferred(),
+ failDeferred = jQuery._Deferred(),
+ promise;
+ // Add errorDeferred methods, then and promise
+ jQuery.extend( deferred, {
+ then: function( doneCallbacks, failCallbacks ) {
+ deferred.done( doneCallbacks ).fail( failCallbacks );
+ return this;
+ },
+ always: function() {
+ return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
+ },
+ fail: failDeferred.done,
+ rejectWith: failDeferred.resolveWith,
+ reject: failDeferred.resolve,
+ isRejected: failDeferred.isResolved,
+ pipe: function( fnDone, fnFail ) {
+ return jQuery.Deferred(function( newDefer ) {
+ jQuery.each( {
+ done: [ fnDone, "resolve" ],
+ fail: [ fnFail, "reject" ]
+ }, function( handler, data ) {
+ var fn = data[ 0 ],
+ action = data[ 1 ],
+ returned;
+ if ( jQuery.isFunction( fn ) ) {
+ deferred[ handler ](function() {
+ returned = fn.apply( this, arguments );
+ if ( returned && jQuery.isFunction( returned.promise ) ) {
+ returned.promise().then( newDefer.resolve, newDefer.reject );
+ } else {
+ newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
+ }
+ });
+ } else {
+ deferred[ handler ]( newDefer[ action ] );
+ }
+ });
+ }).promise();
+ },
+ // Get a promise for this deferred
+ // If obj is provided, the promise aspect is added to the object
+ promise: function( obj ) {
+ if ( obj == undefined ) {
+ if ( promise ) {
+ return promise;
+ }
+ promise = obj = {};
+ }
+ var i = promiseMethods.length;
+ while( i-- ) {
+ obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
+ }
+ return obj;
+ }
+ });
+ // Make sure only one callback list will be used
+ deferred.done( failDeferred.cancel ).fail( deferred.cancel );
+ // Unexpose cancel
+ delete deferred.cancel;
+ // Call given func if any
+ if ( func ) {
+ func.call( deferred, deferred );
+ }
+ return deferred;
+ },
+
+ // Deferred helper
+ when: function( firstParam ) {
+ var args = arguments,
+ i = 0,
+ length = args.length,
+ count = length,
+ deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
+ firstParam :
+ jQuery.Deferred();
+ function resolveFunc( i ) {
+ return function( value ) {
+ args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
+ if ( !( --count ) ) {
+ // Strange bug in FF4:
+ // Values changed onto the arguments object sometimes end up as undefined values
+ // outside the $.when method. Cloning the object into a fresh array solves the issue
+ deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
+ }
+ };
+ }
+ if ( length > 1 ) {
+ for( ; i < length; i++ ) {
+ if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
+ args[ i ].promise().then( resolveFunc(i), deferred.reject );
+ } else {
+ --count;
+ }
+ }
+ if ( !count ) {
+ deferred.resolveWith( deferred, args );
+ }
+ } else if ( deferred !== firstParam ) {
+ deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
+ }
+ return deferred.promise();
+ }
+ });
+
+
+
+ jQuery.support = (function() {
+
+ var div = document.createElement( "div" ),
+ documentElement = document.documentElement,
+ all,
+ a,
+ select,
+ opt,
+ input,
+ marginDiv,
+ support,
+ fragment,
+ body,
+ testElementParent,
+ testElement,
+ testElementStyle,
+ tds,
+ events,
+ eventName,
+ i,
+ isSupported;
+
+ // Preliminary tests
+ div.setAttribute("className", "t");
+ div.innerHTML = "
a";
+
+
+ all = div.getElementsByTagName( "*" );
+ a = div.getElementsByTagName( "a" )[ 0 ];
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return {};
+ }
+
+ // First batch of supports tests
+ select = document.createElement( "select" );
+ opt = select.appendChild( document.createElement("option") );
+ input = div.getElementsByTagName( "input" )[ 0 ];
+
+ support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: ( div.firstChild.nodeType === 3 ),
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName( "tbody" ).length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName( "link" ).length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText instead)
+ style: /top/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: ( input.value === "on" ),
+
+ // 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)
+ optSelected: opt.selected,
+
+ // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
+ getSetAttribute: div.className !== "t",
+
+ // Will be defined later
+ submitBubbles: true,
+ changeBubbles: true,
+ focusinBubbles: false,
+ deleteExpando: true,
+ noCloneEvent: true,
+ inlineBlockNeedsLayout: false,
+ shrinkWrapBlocks: false,
+ reliableMarginRight: true
+ };
+
+ // Make sure checked status is properly cloned
+ input.checked = true;
+ support.noCloneChecked = input.cloneNode( true ).checked;
+
+ // 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;
+
+ // Test to see if it's possible to delete an expando from an element
+ // Fails in Internet Explorer
+ try {
+ delete div.test;
+ } catch( e ) {
+ support.deleteExpando = false;
+ }
+
+ if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
+ div.attachEvent( "onclick", function() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ support.noCloneEvent = false;
+ });
+ div.cloneNode( true ).fireEvent( "onclick" );
+ }
+
+ // Check if a radio maintains it's value
+ // after being appended to the DOM
+ input = document.createElement("input");
+ input.value = "t";
+ input.setAttribute("type", "radio");
+ support.radioValue = input.value === "t";
+
+ input.setAttribute("checked", "checked");
+ div.appendChild( input );
+ fragment = document.createDocumentFragment();
+ fragment.appendChild( div.firstChild );
+
+ // WebKit doesn't clone checked state correctly in fragments
+ support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
+
+ div.innerHTML = "";
+
+ // Figure out if the W3C box model works as expected
+ div.style.width = div.style.paddingLeft = "1px";
+
+ body = document.getElementsByTagName( "body" )[ 0 ];
+ // We use our own, invisible, body unless the body is already present
+ // in which case we use a div (#9239)
+ testElement = document.createElement( body ? "div" : "body" );
+ testElementStyle = {
+ visibility: "hidden",
+ width: 0,
+ height: 0,
+ border: 0,
+ margin: 0,
+ background: "none"
+ };
+ if ( body ) {
+ jQuery.extend( testElementStyle, {
+ position: "absolute",
+ left: "-1000px",
+ top: "-1000px"
+ });
+ }
+ for ( i in testElementStyle ) {
+ testElement.style[ i ] = testElementStyle[ i ];
+ }
+ testElement.appendChild( div );
+ testElementParent = body || documentElement;
+ testElementParent.insertBefore( testElement, testElementParent.firstChild );
+
+ // Check if a disconnected checkbox will retain its checked
+ // value of true after appended to the DOM (IE6/7)
+ support.appendChecked = input.checked;
+
+ support.boxModel = div.offsetWidth === 2;
+
+ if ( "zoom" in div.style ) {
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ // (IE < 8 does this)
+ div.style.display = "inline";
+ div.style.zoom = 1;
+ support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
+
+ // Check if elements with layout shrink-wrap their children
+ // (IE 6 does this)
+ div.style.display = "";
+ div.innerHTML = "";
+ support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
+ }
+
+ div.innerHTML = "
t
";
+ tds = div.getElementsByTagName( "td" );
+
+ // 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).
+ // (only IE 8 fails this test)
+ isSupported = ( tds[ 0 ].offsetHeight === 0 );
+
+ tds[ 0 ].style.display = "";
+ tds[ 1 ].style.display = "none";
+
+ // Check if empty table cells still have offsetWidth/Height
+ // (IE < 8 fail this test)
+ support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
+ div.innerHTML = "";
+
+ // Check if div with explicit width and no margin-right incorrectly
+ // gets computed margin-right based on width of container. For more
+ // info see bug #3333
+ // Fails in WebKit before Feb 2011 nightlies
+ // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+ if ( document.defaultView && document.defaultView.getComputedStyle ) {
+ marginDiv = document.createElement( "div" );
+ marginDiv.style.width = "0";
+ marginDiv.style.marginRight = "0";
+ div.appendChild( marginDiv );
+ support.reliableMarginRight =
+ ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
+ }
+
+ // Remove the body element we added
+ testElement.innerHTML = "";
+ testElementParent.removeChild( testElement );
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ // We only care about the case where non-standard event systems
+ // are used, namely in IE. Short-circuiting here helps us to
+ // avoid an eval call (in setAttribute) which can cause CSP
+ // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
+ if ( div.attachEvent ) {
+ for( i in {
+ submit: 1,
+ change: 1,
+ focusin: 1
+ } ) {
+ eventName = "on" + i;
+ isSupported = ( eventName in div );
+ if ( !isSupported ) {
+ div.setAttribute( eventName, "return;" );
+ isSupported = ( typeof div[ eventName ] === "function" );
+ }
+ support[ i + "Bubbles" ] = isSupported;
+ }
+ }
+
+ // Null connected elements to avoid leaks in IE
+ testElement = fragment = select = opt = body = marginDiv = div = input = null;
+
+ return support;
+ })();
+
+ // Keep track of boxModel
+ jQuery.boxModel = jQuery.support.boxModel;
+
+
+
+
+ var rbrace = /^(?:\{.*\}|\[.*\])$/,
+ rmultiDash = /([A-Z])/g;
+
+ jQuery.extend({
+ cache: {},
+
+ // Please use with caution
+ uuid: 0,
+
+ // Unique for each copy of jQuery on the page
+ // Non-digits removed to match rinlinejQuery
+ expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ // Ban all objects except for Flash (which handle expandos)
+ "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
+ "applet": true
+ },
+
+ hasData: function( elem ) {
+ elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
+
+ return !!elem && !isEmptyDataObject( elem );
+ },
+
+ data: function( elem, name, data, pvt /* Internal Use Only */ ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache, ret,
+ internalKey = jQuery.expando,
+ getByName = typeof name === "string",
+
+ // 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[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
+
+ // 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 || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data == undefined ) {
+ 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 ) {
+ elem[ jQuery.expando ] = id = ++jQuery.uuid;
+ } else {
+ id = jQuery.expando;
+ }
+ }
+
+ if ( !cache[ id ] ) {
+ cache[ id ] = {};
+
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
+ // metadata on plain JS objects when the object is serialized using
+ // JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].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 ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
+ } else {
+ cache[ id ] = jQuery.extend(cache[ id ], name);
+ }
+ }
+
+ thisCache = cache[ id ];
+
+ // Internal jQuery data is stored in a separate object inside the object's data
+ // cache in order to avoid key collisions between internal data and user-defined
+ // data
+ if ( pvt ) {
+ if ( !thisCache[ internalKey ] ) {
+ thisCache[ internalKey ] = {};
+ }
+
+ thisCache = thisCache[ internalKey ];
+ }
+
+ if ( data != undefined ) {
+ thisCache[ jQuery.camelCase( name ) ] = data;
+ }
+
+ // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
+ // not attempt to inspect the internal events object using jQuery.data, as this
+ // internal data object is undocumented and subject to change.
+ if ( name === "events" && !thisCache[name] ) {
+ return thisCache[ internalKey ] && thisCache[ internalKey ].events;
+ }
+
+ // Check for both converted-to-camel and non-converted data property names
+ // If a data property was specified
+ if ( getByName ) {
+
+ // First Try to find as-is property data
+ ret = thisCache[ name ];
+
+ // Test for null|undefined property data
+ if ( ret == undefined ) {
+
+ // Try to find the camelCased property
+ ret = thisCache[ jQuery.camelCase( name ) ];
+ }
+ } else {
+ ret = thisCache;
+ }
+
+ return ret;
+ },
+
+ removeData: function( elem, name, pvt /* Internal Use Only */ ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ var thisCache,
+
+ // Reference to internal data cache key
+ internalKey = jQuery.expando,
+
+ isNode = elem.nodeType,
+
+ // See jQuery.data for more information
+ cache = isNode ? jQuery.cache : elem,
+
+ // See jQuery.data for more information
+ 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 ][ internalKey ] : cache[ id ];
+
+ if ( thisCache ) {
+
+ // Support interoperable removal of hyphenated or camelcased keys
+ if ( !thisCache[ name ] ) {
+ name = jQuery.camelCase( name );
+ }
+
+ delete thisCache[ name ];
+
+ // If there is no data left in the cache, we want to continue
+ // and let the cache object itself get destroyed
+ if ( !isEmptyDataObject(thisCache) ) {
+ return;
+ }
+ }
+ }
+
+ // See jQuery.data for more information
+ if ( pvt ) {
+ delete cache[ id ][ internalKey ];
+
+ // Don't destroy the parent cache unless the internal data object
+ // had been the only thing left in it
+ if ( !isEmptyDataObject(cache[ id ]) ) {
+ return;
+ }
+ }
+
+ var internalCache = cache[ id ][ internalKey ];
+
+ // Browsers that fail expando deletion also refuse to delete expandos on
+ // the window, but it will allow it on all other JS objects; other browsers
+ // don't care
+ // Ensure that `cache` is not a window object #10080
+ if ( jQuery.support.deleteExpando || !cache.setInterval ) {
+ delete cache[ id ];
+ } else {
+ cache[ id ] = null;
+ }
+
+ // We destroyed the entire user cache at once because it's faster than
+ // iterating through each key, but we need to continue to persist internal
+ // data if it existed
+ if ( internalCache ) {
+ cache[ id ] = {};
+ // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
+ // metadata on plain JS objects when the object is serialized using
+ // JSON.stringify
+ if ( !isNode ) {
+ cache[ id ].toJSON = jQuery.noop;
+ }
+
+ cache[ id ][ internalKey ] = internalCache;
+
+ // Otherwise, we need to eliminate the expando on the node to avoid
+ // false lookups in the cache for entries that no longer exist
+ } else if ( isNode ) {
+ // 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 ( jQuery.support.deleteExpando ) {
+ delete elem[ jQuery.expando ];
+ } else if ( elem.removeAttribute ) {
+ elem.removeAttribute( jQuery.expando );
+ } else {
+ elem[ jQuery.expando ] = null;
+ }
+ }
+ },
+
+ // For internal use only.
+ _data: function( elem, name, data ) {
+ return jQuery.data( elem, name, data, true );
+ },
+
+ // A method for determining if a DOM node can handle the data expando
+ acceptData: function( elem ) {
+ if ( elem.nodeName ) {
+ var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
+
+ if ( match ) {
+ return !(match === true || elem.getAttribute("classid") !== match);
+ }
+ }
+
+ return true;
+ }
+ });
+
+ jQuery.fn.extend({
+ data: function( key, value ) {
+ var data = null;
+
+ if ( typeof key === "undefined" ) {
+ if ( this.length ) {
+ data = jQuery.data( this[0] );
+
+ if ( this[0].nodeType === 1 ) {
+ var attr = this[0].attributes, name;
+ for ( var i = 0, l = attr.length; i < l; i++ ) {
+ name = attr[i].name;
+
+ if ( name.indexOf( "data-" ) === 0 ) {
+ name = jQuery.camelCase( name.substring(5) );
+
+ dataAttr( this[0], name, data[ name ] );
+ }
+ }
+ }
+ }
+
+ return data;
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value == undefined ) {
+ data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ // Try to fetch any internally stored data first
+ if ( data == undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ data = dataAttr( this[0], key, data );
+ }
+
+ return data == undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+
+ } else {
+ return this.each(function() {
+ var $this = jQuery( this ),
+ args = [ parts[0], value ];
+
+ $this.triggerHandler( "setData" + parts[1] + "!", args );
+ jQuery.data( this, key, value );
+ $this.triggerHandler( "changeData" + parts[1] + "!", args );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+ });
+
+ 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 :
+ !jQuery.isNaN( data ) ? parseFloat( 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;
+ }
+
+ // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
+ // property to be considered empty objects; this property always exists in
+ // order to make sure JSON.stringify does not expose internal metadata
+ function isEmptyDataObject( obj ) {
+ for ( var name in obj ) {
+ if ( name !== "toJSON" ) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+
+
+
+ function handleQueueMarkDefer( elem, type, src ) {
+ var deferDataKey = type + "defer",
+ queueDataKey = type + "queue",
+ markDataKey = type + "mark",
+ defer = jQuery.data( elem, deferDataKey, undefined, true );
+ if ( defer &&
+ ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
+ ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
+ // Give room for hard-coded callbacks to fire first
+ // and eventually mark/queue something else on the element
+ setTimeout( function() {
+ if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
+ !jQuery.data( elem, markDataKey, undefined, true ) ) {
+ jQuery.removeData( elem, deferDataKey, true );
+ defer.resolve();
+ }
+ }, 0 );
+ }
+ }
+
+ jQuery.extend({
+
+ _mark: function( elem, type ) {
+ if ( elem ) {
+ type = (type || "fx") + "mark";
+ jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
+ }
+ },
+
+ _unmark: function( force, elem, type ) {
+ if ( force !== true ) {
+ type = elem;
+ elem = force;
+ force = false;
+ }
+ if ( elem ) {
+ type = type || "fx";
+ var key = type + "mark",
+ count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
+ if ( count ) {
+ jQuery.data( elem, key, count, true );
+ } else {
+ jQuery.removeData( elem, key, true );
+ handleQueueMarkDefer( elem, type, "mark" );
+ }
+ }
+ },
+
+ queue: function( elem, type, data ) {
+ if ( elem ) {
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type, undefined, true );
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( data ) {
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data), true );
+ } else {
+ q.push( data );
+ }
+ }
+ return q || [];
+ }
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ fn = queue.shift(),
+ defer;
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+
+ if ( !queue.length ) {
+ jQuery.removeData( elem, type + "queue", true );
+ handleQueueMarkDefer( elem, type, "queue" );
+ }
+ }
+ });
+
+ jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data == undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function() {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+ 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, object ) {
+ if ( typeof type !== "string" ) {
+ object = type;
+ type = undefined;
+ }
+ type = type || "fx";
+ var defer = jQuery.Deferred(),
+ elements = this,
+ i = elements.length,
+ count = 1,
+ deferDataKey = type + "defer",
+ queueDataKey = type + "queue",
+ markDataKey = type + "mark",
+ tmp;
+ function resolve() {
+ if ( !( --count ) ) {
+ defer.resolveWith( elements, [ elements ] );
+ }
+ }
+ while( i-- ) {
+ if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
+ ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
+ jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
+ jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
+ count++;
+ tmp.done( resolve );
+ }
+ }
+ resolve();
+ return defer.promise();
+ }
+ });
+
+
+
+
+ var rclass = /[\n\t\r]/g,
+ rspace = /\s+/,
+ rreturn = /\r/g,
+ rtype = /^(?:button|input)$/i,
+ rfocusable = /^(?:button|input|object|select|textarea)$/i,
+ rclickable = /^a(?:rea)?$/i,
+ rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
+ nodeHook, boolHook;
+
+ jQuery.fn.extend({
+ attr: function( name, value ) {
+ return jQuery.access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name ) {
+ return this.each(function() {
+ jQuery.removeAttr( this, name );
+ });
+ },
+
+ prop: function( name, value ) {
+ return jQuery.access( this, name, value, true, jQuery.prop );
+ },
+
+ 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 ) {}
+ });
+ },
+
+ addClass: function( value ) {
+ var classNames, i, l, elem,
+ setClass, c, cl;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).addClass( value.call(this, j, this.className) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ classNames = value.split( rspace );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ elem = this[ i ];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className && classNames.length === 1 ) {
+ elem.className = value;
+
+ } else {
+ setClass = " " + elem.className + " ";
+
+ for ( c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
+ setClass += classNames[ c ] + " ";
+ }
+ }
+ elem.className = jQuery.trim( setClass );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ var classNames, i, l, elem, className, c, cl;
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function( j ) {
+ jQuery( this ).removeClass( value.call(this, j, this.className) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value == undefined ) {
+ classNames = (value || "").split( rspace );
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ elem = this[ i ];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ className = (" " + elem.className + " ").replace( rclass, " " );
+ for ( c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[ c ] + " ", " ");
+ }
+ elem.className = jQuery.trim( className );
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value,
+ isBool = typeof stateVal === "boolean";
+
+ 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 ),
+ state = stateVal,
+ classNames = value.split( rspace );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery._data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ var hooks, ret,
+ elem = this[0];
+
+ if ( !arguments.length ) {
+ if ( elem ) {
+ hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
+
+ 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 == undefined ? "" : ret;
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction( value );
+
+ return this.each(function( i ) {
+ var self = jQuery(this), val;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call( this, i, self.val() );
+ } else {
+ val = value;
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == undefined ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray( val ) ) {
+ val = jQuery.map(val, function ( value ) {
+ return value == undefined ? "" : value + "";
+ });
+ }
+
+ hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
+
+ // 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 ) {
+ // attributes.value is undefined in Blackberry 4.7 but
+ // uses .value. See #6932
+ var val = elem.attributes.value;
+ return !val || val.specified ? elem.value : elem.text;
+ }
+ },
+ select: {
+ get: function( elem ) {
+ var value,
+ index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ // Don't return options that are disabled or in a disabled optgroup
+ if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") == undefined) &&
+ (!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 );
+ }
+ }
+
+ // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
+ if ( one && !values.length && options.length ) {
+ return jQuery( options[ index ] ).val();
+ }
+
+ return values;
+ },
+
+ set: function( elem, value ) {
+ var values = jQuery.makeArray( value );
+
+ jQuery(elem).find("option").each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ elem.selectedIndex = -1;
+ }
+ return values;
+ }
+ }
+ },
+
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attrFix: {
+ // Always normalize to ensure hook usage
+ tabindex: "tabIndex"
+ },
+
+ attr: function( elem, name, value, pass ) {
+ var nType = elem.nodeType;
+
+ // don't get/set attributes on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery( elem )[ name ]( value );
+ }
+
+ // Fallback to prop when attributes are not supported
+ if ( !("getAttribute" in elem) ) {
+ return jQuery.prop( elem, name, value );
+ }
+
+ var ret, hooks,
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
+ // Normalize the name if needed
+ if ( notxml ) {
+ name = jQuery.attrFix[ name ] || name;
+
+ hooks = jQuery.attrHooks[ name ];
+
+ if ( !hooks ) {
+ // Use boolHook for boolean attributes
+ if ( rboolean.test( name ) ) {
+ hooks = boolHook;
+
+ // Use nodeHook if available( IE6/7 )
+ } else if ( nodeHook ) {
+ hooks = nodeHook;
+ }
+ }
+ }
+
+ if ( value != undefined ) {
+
+ if ( value == undefined ) {
+ jQuery.removeAttr( elem, name );
+ return undefined;
+
+ } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) != undefined ) {
+ return ret;
+
+ } else {
+ elem.setAttribute( name, "" + value );
+ return value;
+ }
+
+ } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) != undefined ) {
+ return ret;
+
+ } else {
+
+ ret = elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return ret == undefined ?
+ undefined :
+ ret;
+ }
+ },
+
+ removeAttr: function( elem, name ) {
+ var propName;
+ if ( elem.nodeType === 1 ) {
+ name = jQuery.attrFix[ name ] || name;
+
+ jQuery.attr( elem, name, "" );
+ elem.removeAttribute( name );
+
+ // Set corresponding property to false for boolean attributes
+ if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
+ elem[ propName ] = false;
+ }
+ }
+ },
+
+ attrHooks: {
+ type: {
+ set: function( elem, value ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
+ jQuery.error( "type property can't be changed" );
+ } else if ( !jQuery.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 it's default in case type is set after value
+ // This is for element creation
+ var val = elem.value;
+ elem.setAttribute( "type", value );
+ if ( val ) {
+ elem.value = val;
+ }
+ return value;
+ }
+ }
+ },
+ // Use the value property for back compat
+ // Use the nodeHook for button elements in IE6/7 (#1954)
+ value: {
+ get: function( elem, name ) {
+ if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
+ return nodeHook.get( elem, name );
+ }
+ return name in elem ?
+ elem.value :
+ null;
+ },
+ set: function( elem, value, name ) {
+ if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
+ return nodeHook.set( elem, value, name );
+ }
+ // Does not return so that setAttribute is also used
+ elem.value = value;
+ }
+ }
+ },
+
+ propFix: {
+ tabindex: "tabIndex",
+ readonly: "readOnly",
+ "for": "htmlFor",
+ "class": "className",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ cellpadding: "cellPadding",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ usemap: "useMap",
+ frameborder: "frameBorder",
+ contenteditable: "contentEditable"
+ },
+
+ prop: function( elem, name, value ) {
+ var nType = elem.nodeType;
+
+ // don't get/set properties on text, comment and attribute nodes
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
+ return undefined;
+ }
+
+ var ret, hooks,
+ 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 ) {
+ if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) != undefined ) {
+ return ret;
+
+ } else {
+ return (elem[ name ] = value);
+ }
+
+ } else {
+ if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) != undefined ) {
+ return ret;
+
+ } else {
+ return 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/
+ var attributeNode = elem.getAttributeNode("tabindex");
+
+ return attributeNode && attributeNode.specified ?
+ parseInt( attributeNode.value, 10 ) :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+ }
+ }
+ });
+
+ // Add the tabindex propHook to attrHooks for back-compat
+ jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
+
+ // Hook for boolean attributes
+ boolHook = {
+ get: function( elem, name ) {
+ // Align boolean attributes with corresponding properties
+ // Fall back to attribute presence where some booleans are not supported
+ var attrNode;
+ return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
+ name.toLowerCase() :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ var propName;
+ if ( value === false ) {
+ // Remove boolean attributes when set to false
+ jQuery.removeAttr( elem, name );
+ } else {
+ // value is true since we know at this point it's type boolean and not false
+ // Set boolean attributes to the same name and set the DOM property
+ propName = jQuery.propFix[ name ] || name;
+ if ( propName in elem ) {
+ // Only set the IDL specifically if it already exists on the element
+ elem[ propName ] = true;
+ }
+
+ elem.setAttribute( name, name.toLowerCase() );
+ }
+ return name;
+ }
+ };
+
+ // IE6/7 do not support getting/setting some attributes with get/setAttribute
+ if ( !jQuery.support.getSetAttribute ) {
+
+ // Use this for any attribute in IE6/7
+ // This fixes almost every IE6/7 issue
+ nodeHook = jQuery.valHooks.button = {
+ get: function( elem, name ) {
+ var ret;
+ ret = elem.getAttributeNode( name );
+ // Return undefined if nodeValue is empty string
+ return ret && ret.nodeValue !== "" ?
+ ret.nodeValue :
+ undefined;
+ },
+ set: function( elem, value, name ) {
+ // Set the existing or create a new attribute node
+ var ret = elem.getAttributeNode( name );
+ if ( !ret ) {
+ ret = document.createAttribute( name );
+ elem.setAttributeNode( ret );
+ }
+ return (ret.nodeValue = value + "");
+ }
+ };
+
+ // 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 ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ set: function( elem, value ) {
+ if ( value === "" ) {
+ elem.setAttribute( name, "auto" );
+ return value;
+ }
+ }
+ });
+ });
+ }
+
+
+ // Some attributes require a special call on IE
+ if ( !jQuery.support.hrefNormalized ) {
+ jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
+ jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
+ get: function( elem ) {
+ var ret = elem.getAttribute( name, 2 );
+ return ret == undefined ? undefined : ret;
+ }
+ });
+ });
+ }
+
+ if ( !jQuery.support.style ) {
+ jQuery.attrHooks.style = {
+ get: function( elem ) {
+ // Return undefined in the case of empty string
+ // Normalize to lowercase since IE uppercases css property names
+ return elem.style.cssText.toLowerCase() || undefined;
+ },
+ set: function( elem, value ) {
+ return (elem.style.cssText = "" + value);
+ }
+ };
+ }
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( !jQuery.support.optSelected ) {
+ jQuery.propHooks.selected = jQuery.extend( 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;
+ }
+ });
+ }
+
+ // Radios and checkboxes getter/setter
+ if ( !jQuery.support.checkOn ) {
+ jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = {
+ get: function( elem ) {
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ return elem.getAttribute("value") == undefined ? "on" : elem.value;
+ }
+ };
+ });
+ }
+ jQuery.each([ "radio", "checkbox" ], function() {
+ jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
+ set: function( elem, value ) {
+ if ( jQuery.isArray( value ) ) {
+ return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
+ }
+ }
+ });
+ });
+
+
+
+
+ var rnamespaces = /\.(.*)$/,
+ rformElems = /^(?:textarea|input|select)$/i,
+ rperiod = /\./g,
+ rspaces = / /g,
+ rescape = /[^\w\s.|`]/g,
+ fcleanup = function( nm ) {
+ return nm.replace(rescape, "\\$&");
+ };
+
+ /*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+ jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ if ( handler === false ) {
+ handler = returnFalse;
+ } else if ( !handler ) {
+ // Fixes bug #7229. Fix recommended by jdalton
+ return;
+ }
+
+ var handleObjIn, handleObj;
+
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure
+ var elemData = jQuery._data( elem );
+
+ // If no elemData is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !elemData ) {
+ return;
+ }
+
+ var events = elemData.events,
+ eventHandle = elemData.handle;
+
+ if ( !events ) {
+ elemData.events = events = {};
+ }
+
+ if ( !eventHandle ) {
+ elemData.handle = eventHandle = 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 !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native events in IE.
+ eventHandle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split(" ");
+
+ var type, i = 0, namespaces;
+
+ while ( (type = types[ i++ ]) ) {
+ handleObj = handleObjIn ?
+ jQuery.extend({}, handleObjIn) :
+ { handler: handler, data: data };
+
+ // Namespaced event handlers
+ if ( type.indexOf(".") > -1 ) {
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ handleObj.namespace = namespaces.slice(0).sort().join(".");
+
+ } else {
+ namespaces = [];
+ handleObj.namespace = "";
+ }
+
+ handleObj.type = type;
+ if ( !handleObj.guid ) {
+ handleObj.guid = handler.guid;
+ }
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = jQuery.event.special[ type ] || {};
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = [];
+
+ // Check for a special event handler
+ // 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 the function to the element's handler list
+ handlers.push( handleObj );
+
+ // Keep track of which events have been used, for event optimization
+ jQuery.event.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, pos ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ if ( handler === false ) {
+ handler = returnFalse;
+ }
+
+ var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
+ elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
+ events = elemData && elemData.events;
+
+ if ( !elemData || !events ) {
+ return;
+ }
+
+ // types is actually an event object here
+ if ( types && types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Unbind all events for the element
+ if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
+ types = types || "";
+
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types );
+ }
+
+ return;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(" ");
+
+ while ( (type = types[ i++ ]) ) {
+ origType = type;
+ handleObj = null;
+ all = type.indexOf(".") < 0;
+ namespaces = [];
+
+ if ( !all ) {
+ // Namespaced event handlers
+ namespaces = type.split(".");
+ type = namespaces.shift();
+
+ namespace = new RegExp("(^|\\.)" +
+ jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ eventType = events[ type ];
+
+ if ( !eventType ) {
+ continue;
+ }
+
+ if ( !handler ) {
+ for ( j = 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( all || namespace.test( handleObj.namespace ) ) {
+ jQuery.event.remove( elem, origType, handleObj.handler, j );
+ eventType.splice( j--, 1 );
+ }
+ }
+
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+
+ for ( j = pos || 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( handler.guid === handleObj.guid ) {
+ // remove the given handler for the given type
+ if ( all || namespace.test( handleObj.namespace ) ) {
+ if ( pos == undefined ) {
+ eventType.splice( j--, 1 );
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+
+ if ( pos != null ) {
+ break;
+ }
+ }
+ }
+
+ // remove generic event handler if no more handlers exist
+ if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ ret = null;
+ delete events[ type ];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ var handle = elemData.handle;
+ if ( handle ) {
+ handle.elem = null;
+ }
+
+ delete elemData.events;
+ delete elemData.handle;
+
+ if ( jQuery.isEmptyObject( elemData ) ) {
+ jQuery.removeData( elem, undefined, true );
+ }
+ }
+ },
+
+ // Events that are safe to short-circuit if no handlers are attached.
+ // Native DOM events should not be added, they may have inline handlers.
+ customEvent: {
+ "getData": true,
+ "setData": true,
+ "changeData": true
+ },
+
+ trigger: function( event, data, elem, onlyHandlers ) {
+ // Event object or event type
+ var type = event.type || event,
+ namespaces = [],
+ exclusive;
+
+ if ( type.indexOf("!") >= 0 ) {
+ // Exclusive events trigger only for the exact event (no namespaces)
+ type = type.slice(0, -1);
+ exclusive = true;
+ }
+
+ if ( type.indexOf(".") >= 0 ) {
+ // Namespaced trigger; create a regexp to match event type in handle()
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ namespaces.sort();
+ }
+
+ if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
+ // No jQuery handlers for this event type, and it can't have inline handlers
+ return;
+ }
+
+ // Caller can pass in an Event, Object, or just an event type string
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[ jQuery.expando ] ? event :
+ // Object literal
+ new jQuery.Event( type, event ) :
+ // Just the event type (string)
+ new jQuery.Event( type );
+
+ event.type = type;
+ event.exclusive = exclusive;
+ event.namespace = namespaces.join(".");
+ event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
+
+ // triggerHandler() and global events don't bubble or run the default action
+ if ( onlyHandlers || !elem ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // TODO: Stop taunting the data cache; remove global events and always attach to document
+ jQuery.each( jQuery.cache, function() {
+ // internalKey variable is just used to make it easier to find
+ // and potentially change this stuff later; currently it just
+ // points to jQuery.expando
+ var internalKey = jQuery.expando,
+ internalCache = this[ internalKey ];
+ if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
+ jQuery.event.trigger( event, data, internalCache.handle.elem );
+ }
+ });
+ return;
+ }
+
+ // Don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // Clean up the event in case it is being reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone any incoming data and prepend the event, creating the handler arg list
+ data = data != null ? jQuery.makeArray( data ) : [];
+ data.unshift( event );
+
+ var cur = elem,
+ // IE doesn't like method names with a colon (#3533, #8272)
+ ontype = type.indexOf(":") < 0 ? "on" + type : "";
+
+ // Fire event on the current element, then bubble up the DOM tree
+ do {
+ var handle = jQuery._data( cur, "handle" );
+
+ event.currentTarget = cur;
+ if ( handle ) {
+ handle.apply( cur, data );
+ }
+
+ // Trigger an inline bound script
+ if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
+ event.result = false;
+ event.preventDefault();
+ }
+
+ // Bubble up to document, then to window
+ cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
+ } while ( cur && !event.isPropagationStopped() );
+
+ // If nobody prevented the default action, do it now
+ if ( !event.isDefaultPrevented() ) {
+ var old,
+ special = jQuery.event.special[ type ] || {};
+
+ if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
+ !(type === "click" && jQuery.nodeName( elem, "a" )) && 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.
+ // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
+ try {
+ if ( ontype && elem[ type ] ) {
+ // Don't re-trigger an onFOO event when we call its FOO() method
+ old = elem[ ontype ];
+
+ if ( old ) {
+ elem[ ontype ] = null;
+ }
+
+ jQuery.event.triggered = type;
+ elem[ type ]();
+ }
+ } catch ( ieError ) {}
+
+ if ( old ) {
+ elem[ ontype ] = old;
+ }
+
+ jQuery.event.triggered = undefined;
+ }
+ }
+
+ return event.result;
+ },
+
+ handle: function( event ) {
+ event = jQuery.event.fix( event || window.event );
+ // Snapshot the handlers list since a called handler may add/remove events.
+ var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
+ run_all = !event.exclusive && !event.namespace,
+ args = Array.prototype.slice.call( arguments, 0 );
+
+ // Use the fix-ed Event rather than the (read-only) native event
+ args[0] = event;
+ event.currentTarget = this;
+
+ for ( var j = 0, l = handlers.length; j < l; j++ ) {
+ var handleObj = handlers[ j ];
+
+ // Triggered event must 1) be non-exclusive and have no namespace, or
+ // 2) have namespace(s) a subset or equal to those in the bound event.
+ if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handleObj.handler;
+ event.data = handleObj.data;
+ event.handleObj = handleObj;
+
+ var ret = handleObj.handler.apply( this, args );
+
+ if ( ret != undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+ }
+ }
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ jQuery.expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ // Fixes #1925 where srcElement might not be defined either
+ event.target = event.srcElement || document;
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == undefined && event.clientX != null ) {
+ var eventDocument = event.target.ownerDocument || document,
+ doc = eventDocument.documentElement,
+ body = eventDocument.body;
+
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( event.which == undefined && (event.charCode != null || event.keyCode != null) ) {
+ event.which = event.charCode != null ? event.charCode : event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button != undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( handleObj ) {
+ jQuery.event.add( this,
+ liveConvert( handleObj.origType, handleObj.selector ),
+ jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
+ },
+
+ remove: function( handleObj ) {
+ jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
+ }
+ },
+
+ beforeunload: {
+ setup: function( data, namespaces, eventHandle ) {
+ // We only want to do this special case on windows
+ if ( jQuery.isWindow( this ) ) {
+ this.onbeforeunload = eventHandle;
+ }
+ },
+
+ teardown: function( namespaces, eventHandle ) {
+ if ( this.onbeforeunload === eventHandle ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+ };
+
+ jQuery.removeEvent = document.removeEventListener ?
+ function( elem, type, handle ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle, false );
+ }
+ } :
+ function( elem, type, handle ) {
+ if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, handle );
+ }
+ };
+
+ jQuery.Event = function( src, props ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ 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.returnValue === false ||
+ 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 );
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = jQuery.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+ };
+
+ function returnFalse() {
+ return false;
+ }
+ function returnTrue() {
+ return 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 = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+
+ // otherwise set the returnValue property of the original event to false (IE)
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+ };
+
+ // Checks if an event happened on an element within another element
+ // Used in jQuery.event.special.mouseenter and mouseleave handlers
+ var withinElement = function( event ) {
+
+ // Check if mouse(over|out) are still within the same parent element
+ var related = event.relatedTarget,
+ inside = false,
+ eventType = event.type;
+
+ event.type = event.data;
+
+ if ( related !== this ) {
+
+ if ( related ) {
+ inside = jQuery.contains( this, related );
+ }
+
+ if ( !inside ) {
+
+ jQuery.event.handle.apply( this, arguments );
+
+ event.type = eventType;
+ }
+ }
+ },
+
+ // In case of event delegation, we only need to rename the event.type,
+ // liveHandler will take care of the rest.
+ delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+ };
+
+ // Create mouseenter and mouseleave events
+ jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+ }, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+ });
+
+ // submit delegation
+ if ( !jQuery.support.submitBubbles ) {
+
+ jQuery.event.special.submit = {
+ setup: function( data, namespaces ) {
+ if ( !jQuery.nodeName( this, "form" ) ) {
+ jQuery.event.add(this, "click.specialSubmit", function( e ) {
+ // Avoid triggering error on non-existent type attribute in IE VML (#7071)
+ var elem = e.target,
+ type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
+ var elem = e.target,
+ type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : "";
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ teardown: function( namespaces ) {
+ jQuery.event.remove( this, ".specialSubmit" );
+ }
+ };
+
+ }
+
+ // change delegation, happens here so we have bind.
+ if ( !jQuery.support.changeBubbles ) {
+
+ var changeFilters,
+
+ getVal = function( elem ) {
+ var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
+ val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( jQuery.nodeName( elem, "select" ) ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+ },
+
+ testChange = function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery._data( elem, "_change_data" );
+ val = getVal(elem);
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery._data( elem, "_change_data", val );
+ }
+
+ if ( data == undefined || val === data ) {
+ return;
+ }
+
+ if ( data != null || val ) {
+ e.type = "change";
+ e.liveFired = undefined;
+ jQuery.event.trigger( e, arguments[1], elem );
+ }
+ };
+
+ jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ beforedeactivate: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
+
+ if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
+ testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
+
+ if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information
+ beforeactivate: function( e ) {
+ var elem = e.target;
+ jQuery._data( elem, "_change_data", getVal(elem) );
+ }
+ },
+
+ setup: function( data, namespaces ) {
+ if ( this.type === "file" ) {
+ return false;
+ }
+
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
+ }
+
+ return rformElems.test( this.nodeName );
+ },
+
+ teardown: function( namespaces ) {
+ jQuery.event.remove( this, ".specialChange" );
+
+ return rformElems.test( this.nodeName );
+ }
+ };
+
+ changeFilters = jQuery.event.special.change.filters;
+
+ // Handle when the input is .focus()'d
+ changeFilters.focus = changeFilters.beforeactivate;
+ }
+
+ function trigger( type, elem, args ) {
+ // 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.
+ // Don't pass args or remember liveFired; they apply to the donor event.
+ var event = jQuery.extend( {}, args[ 0 ] );
+ event.type = type;
+ event.originalEvent = {};
+ event.liveFired = undefined;
+ jQuery.event.handle.call( elem, event );
+ if ( event.isDefaultPrevented() ) {
+ args[ 0 ].preventDefault();
+ }
+ }
+
+ // Create "bubbling" focus and blur events
+ if ( !jQuery.support.focusinBubbles ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+
+ // Attach a single capturing handler while someone wants focusin/focusout
+ var attaches = 0;
+
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ if ( attaches++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
+ },
+ teardown: function() {
+ if ( --attaches === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
+ }
+ };
+
+ function handler( donor ) {
+ // Donor event is always a native one; fix it and switch its type.
+ // Let focusin/out handler cancel the donor focus/blur event.
+ var e = jQuery.event.fix( donor );
+ e.type = fix;
+ e.originalEvent = {};
+ jQuery.event.trigger( e, null, e.target );
+ if ( e.isDefaultPrevented() ) {
+ donor.preventDefault();
+ }
+ }
+ });
+ }
+
+ jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ var handler;
+
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( arguments.length === 2 || data === false ) {
+ fn = data;
+ data = undefined;
+ }
+
+ if ( name === "one" ) {
+ handler = function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ };
+ handler.guid = fn.guid || jQuery.guid++;
+ } else {
+ handler = fn;
+ }
+
+ if ( type === "unload" && name !== "one" ) {
+ this.one( type, data, fn );
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ jQuery.event.add( this[i], type, handler, data );
+ }
+ }
+
+ return this;
+ };
+ });
+
+ jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ jQuery.event.remove( this[i], type, fn );
+ }
+ }
+
+ return this;
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.live( types, data, fn, selector );
+ },
+
+ undelegate: function( selector, types, fn ) {
+ if ( arguments.length === 0 ) {
+ return this.unbind( "live" );
+
+ } else {
+ return this.die( types, null, fn, selector );
+ }
+ },
+
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ return jQuery.event.trigger( type, data, this[0], true );
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments,
+ guid = fn.guid || jQuery.guid++,
+ i = 0,
+ toggler = function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ };
+
+ // link all the functions, so any of them can unbind this click handler
+ toggler.guid = guid;
+ while ( i < args.length ) {
+ args[ i++ ].guid = guid;
+ }
+
+ return this.click( toggler );
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+ });
+
+ var liveMap = {
+ focus: "focusin",
+ blur: "focusout",
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+ };
+
+ jQuery.each(["live", "die"], function( i, name ) {
+ jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
+ var type, i = 0, match, namespaces, preType,
+ selector = origSelector || this.selector,
+ context = origSelector ? this : jQuery( this.context );
+
+ if ( typeof types === "object" && !types.preventDefault ) {
+ for ( var key in types ) {
+ context[ name ]( key, data, types[key], selector );
+ }
+
+ return this;
+ }
+
+ if ( name === "die" && !types &&
+ origSelector && origSelector.charAt(0) === "." ) {
+
+ context.unbind( origSelector );
+
+ return this;
+ }
+
+ if ( data === false || jQuery.isFunction( data ) ) {
+ fn = data || returnFalse;
+ data = undefined;
+ }
+
+ types = (types || "").split(" ");
+
+ while ( (type = types[ i++ ]) != null ) {
+ match = rnamespaces.exec( type );
+ namespaces = "";
+
+ if ( match ) {
+ namespaces = match[0];
+ type = type.replace( rnamespaces, "" );
+ }
+
+ if ( type === "hover" ) {
+ types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
+ continue;
+ }
+
+ preType = type;
+
+ if ( liveMap[ type ] ) {
+ types.push( liveMap[ type ] + namespaces );
+ type = type + namespaces;
+
+ } else {
+ type = (liveMap[ type ] || type) + namespaces;
+ }
+
+ if ( name === "live" ) {
+ // bind live handler
+ for ( var j = 0, l = context.length; j < l; j++ ) {
+ jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
+ { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
+ }
+
+ } else {
+ // unbind live handler
+ context.unbind( "live." + liveConvert( type, selector ), fn );
+ }
+ }
+
+ return this;
+ };
+ });
+
+ function liveHandler( event ) {
+ var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
+ elems = [],
+ selectors = [],
+ events = jQuery._data( this, "events" );
+
+ // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
+ if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
+ return;
+ }
+
+ if ( event.namespace ) {
+ namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ event.liveFired = this;
+
+ var live = events.live.slice(0);
+
+ for ( j = 0; j < live.length; j++ ) {
+ handleObj = live[j];
+
+ if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
+ selectors.push( handleObj.selector );
+
+ } else {
+ live.splice( j--, 1 );
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ close = match[i];
+
+ for ( j = 0; j < live.length; j++ ) {
+ handleObj = live[j];
+
+ if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
+ elem = close.elem;
+ related = null;
+
+ // Those two events require additional checking
+ if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
+ event.type = handleObj.preType;
+ related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
+
+ // Make sure not to accidentally match a child element with the same selector
+ if ( related && jQuery.contains( elem, related ) ) {
+ related = elem;
+ }
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, handleObj: handleObj, level: close.level });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+
+ if ( maxLevel && match.level > maxLevel ) {
+ break;
+ }
+
+ event.currentTarget = match.elem;
+ event.data = match.handleObj.data;
+ event.handleObj = match.handleObj;
+
+ ret = match.handleObj.origHandler.apply( match.elem, arguments );
+
+ if ( ret === false || event.isPropagationStopped() ) {
+ maxLevel = match.level;
+
+ if ( ret === false ) {
+ stop = false;
+ }
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+ }
+ }
+
+ return stop;
+ }
+
+ function liveConvert( type, selector ) {
+ return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
+ }
+
+ 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").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ if ( fn == undefined ) {
+ fn = data;
+ data = null;
+ }
+
+ return arguments.length > 0 ?
+ this.bind( name, data, fn ) :
+ this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+ });
+
+
+
+ /*!
+ * Sizzle CSS Selector Engine
+ * Copyright 2011, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+ (function(){
+
+ var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true,
+ rBackslash = /\\/g,
+ rNonWord = /\W/;
+
+ // Here we check if the JavaScript engine is using some sort of
+ // optimization where it does not always call our comparision
+ // function. If that is the case, discard the hasDuplicate value.
+ // Thus far that includes Google Chrome.
+ [0, 0].sort(function() {
+ baseHasDuplicate = false;
+ return 0;
+ });
+
+ var Sizzle = function( selector, context, results, seed ) {
+ results = results || [];
+ context = context || document;
+
+ var origContext = context;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var m, set, checkSet, extra, ret, cur, pop, i,
+ prune = true,
+ contextXML = Sizzle.isXML( context ),
+ parts = [],
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ do {
+ chunker.exec( "" );
+ m = chunker.exec( soFar );
+
+ if ( m ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+ } while ( m );
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+
+ ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ?
+ Sizzle.filter( ret.expr, ret.set )[0] :
+ ret.set[0];
+ }
+
+ if ( context ) {
+ ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+
+ set = ret.expr ?
+ Sizzle.filter( ret.expr, ret.set ) :
+ ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray( set );
+
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ cur = parts.pop();
+ pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == undefined ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ Sizzle.error( cur || selector );
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+
+ } else if ( context && context.nodeType === 1 ) {
+ for ( i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+
+ } else {
+ for ( i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+ };
+
+ Sizzle.uniqueSort = function( results ) {
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[ i - 1 ] ) {
+ results.splice( i--, 1 );
+ }
+ }
+ }
+ }
+
+ return results;
+ };
+
+ Sizzle.matches = function( expr, set ) {
+ return Sizzle( expr, null, null, set );
+ };
+
+ Sizzle.matchesSelector = function( node, expr ) {
+ return Sizzle( expr, null, null, [node] ).length > 0;
+ };
+
+ Sizzle.find = function( expr, context, isXML ) {
+ var set;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var match,
+ type = Expr.order[i];
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice( 1, 1 );
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace( rBackslash, "" );
+ set = Expr.find[ type ]( match, context, isXML );
+
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = typeof context.getElementsByTagName !== "undefined" ?
+ context.getElementsByTagName( "*" ) :
+ [];
+ }
+
+ return { set: set, expr: expr };
+ };
+
+ Sizzle.filter = function( expr, set, inplace, not ) {
+ var match, anyFound,
+ old = expr,
+ result = [],
+ curLoop = set,
+ isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var found, item,
+ filter = Expr.filter[ type ],
+ left = match[1];
+
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+
+ } else {
+ curLoop[i] = false;
+ }
+
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found != undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == undefined ) {
+ Sizzle.error( expr );
+
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+ };
+
+ Sizzle.error = function( msg ) {
+ throw "Syntax error, unrecognized expression: " + msg;
+ };
+
+ var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+
+ leftMatch: {},
+
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+
+ attrHandle: {
+ href: function( elem ) {
+ return elem.getAttribute( "href" );
+ },
+ type: function( elem ) {
+ return elem.getAttribute( "type" );
+ }
+ },
+
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !rNonWord.test( part ),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+
+ ">": function( checkSet, part ) {
+ var elem,
+ isPartStr = typeof part === "string",
+ i = 0,
+ l = checkSet.length;
+
+ if ( isPartStr && !rNonWord.test( part ) ) {
+ part = part.toLowerCase();
+
+ for ( ; i < l; i++ ) {
+ elem = checkSet[i];
+
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+
+ } else {
+ for ( ; i < l; i++ ) {
+ elem = checkSet[i];
+
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+
+ "": function(checkSet, part, isXML){
+ var nodeCheck,
+ doneName = done++,
+ checkFn = dirCheck;
+
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
+ part = part.toLowerCase();
+ nodeCheck = part;
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
+ },
+
+ "~": function( checkSet, part, isXML ) {
+ var nodeCheck,
+ doneName = done++,
+ checkFn = dirCheck;
+
+ if ( typeof part === "string" && !rNonWord.test( part ) ) {
+ part = part.toLowerCase();
+ nodeCheck = part;
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
+ }
+ },
+
+ find: {
+ ID: function( match, context, isXML ) {
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ },
+
+ NAME: function( match, context ) {
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [],
+ results = context.getElementsByName( match[1] );
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+
+ TAG: function( match, context ) {
+ if ( typeof context.getElementsByTagName !== "undefined" ) {
+ return context.getElementsByTagName( match[1] );
+ }
+ }
+ },
+ preFilter: {
+ CLASS: function( match, curLoop, inplace, result, not, isXML ) {
+ match = " " + match[1].replace( rBackslash, "" ) + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+
+ ID: function( match ) {
+ return match[1].replace( rBackslash, "" );
+ },
+
+ TAG: function( match, curLoop ) {
+ return match[1].replace( rBackslash, "" ).toLowerCase();
+ },
+
+ CHILD: function( match ) {
+ if ( match[1] === "nth" ) {
+ if ( !match[2] ) {
+ Sizzle.error( match[0] );
+ }
+
+ match[2] = match[2].replace(/^\+|\s*/g, '');
+
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+ else if ( match[2] ) {
+ Sizzle.error( match[0] );
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+
+ ATTR: function( match, curLoop, inplace, result, not, isXML ) {
+ var name = match[1] = match[1].replace( rBackslash, "" );
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ // Handle if an un-quoted value was used
+ match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+
+ PSEUDO: function( match, curLoop, inplace, result, not ) {
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+
+ return false;
+ }
+
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+
+ POS: function( match ) {
+ match.unshift( true );
+
+ return match;
+ }
+ },
+
+ filters: {
+ enabled: function( elem ) {
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+
+ disabled: function( elem ) {
+ return elem.disabled === true;
+ },
+
+ checked: function( elem ) {
+ return elem.checked === true;
+ },
+
+ 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;
+ },
+
+ parent: function( elem ) {
+ return !!elem.firstChild;
+ },
+
+ empty: function( elem ) {
+ return !elem.firstChild;
+ },
+
+ has: function( elem, i, match ) {
+ return !!Sizzle( match[3], elem ).length;
+ },
+
+ header: function( elem ) {
+ return (/h\d/i).test( elem.nodeName );
+ },
+
+ text: function( elem ) {
+ var attr = elem.getAttribute( "type" ), type = elem.type;
+ // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
+ // use getAttribute instead to test this case
+ return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr == undefined );
+ },
+
+ radio: function( elem ) {
+ return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
+ },
+
+ checkbox: function( elem ) {
+ return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
+ },
+
+ file: function( elem ) {
+ return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
+ },
+
+ password: function( elem ) {
+ return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
+ },
+
+ submit: function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && "submit" === elem.type;
+ },
+
+ image: function( elem ) {
+ return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
+ },
+
+ reset: function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return (name === "input" || name === "button") && "reset" === elem.type;
+ },
+
+ button: function( elem ) {
+ var name = elem.nodeName.toLowerCase();
+ return name === "input" && "button" === elem.type || name === "button";
+ },
+
+ input: function( elem ) {
+ return (/input|select|textarea|button/i).test( elem.nodeName );
+ },
+
+ focus: function( elem ) {
+ return elem === elem.ownerDocument.activeElement;
+ }
+ },
+ setFilters: {
+ first: function( elem, i ) {
+ return i === 0;
+ },
+
+ last: function( elem, i, match, array ) {
+ return i === array.length - 1;
+ },
+
+ even: function( elem, i ) {
+ return i % 2 === 0;
+ },
+
+ odd: function( elem, i ) {
+ return i % 2 === 1;
+ },
+
+ lt: function( elem, i, match ) {
+ return i < match[3] - 0;
+ },
+
+ gt: function( elem, i, match ) {
+ return i > match[3] - 0;
+ },
+
+ nth: function( elem, i, match ) {
+ return match[3] - 0 === i;
+ },
+
+ eq: function( elem, i, match ) {
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function( elem, match, i, array ) {
+ var name = match[1],
+ filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
+
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var j = 0, l = not.length; j < l; j++ ) {
+ if ( not[j] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+
+ } else {
+ Sizzle.error( name );
+ }
+ },
+
+ CHILD: function( elem, match ) {
+ var type = match[1],
+ node = elem;
+
+ switch ( type ) {
+ case "only":
+ case "first":
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ if ( type === "first" ) {
+ return true;
+ }
+
+ node = elem;
+
+ case "last":
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ return true;
+
+ case "nth":
+ var first = match[2],
+ last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+
+ if ( first === 0 ) {
+ return diff === 0;
+
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+
+ ID: function( elem, match ) {
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+
+ TAG: function( elem, match ) {
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+
+ CLASS: function( elem, match ) {
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+
+ ATTR: function( elem, match ) {
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == undefined ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+
+ POS: function( elem, match, i, array ) {
+ var name = match[2],
+ filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+ };
+
+ var origPOS = Expr.match.POS,
+ fescape = function(all, num){
+ return "\\" + (num - 0 + 1);
+ };
+
+ for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
+ }
+
+ var makeArray = function( array, results ) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+ };
+
+ // Perform a simple check to determine if the browser is capable of
+ // converting a NodeList to an array using builtin methods.
+ // Also verifies that the returned array holds DOM nodes
+ // (which is not the case in the Blackberry browser)
+ try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
+
+ // Provide a fallback method if it does not work
+ } catch( e ) {
+ makeArray = function( array, results ) {
+ var i = 0,
+ ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+
+ } else {
+ for ( ; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+ }
+
+ var sortOrder, siblingCheck;
+
+ if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ return a.compareDocumentPosition(b) & 4 ? -1 : 1;
+ };
+
+ } else {
+ sortOrder = function( a, b ) {
+ // The nodes are identical, we can exit early
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+
+ // Fallback to using sourceIndex (in IE) if it's available on both nodes
+ } else if ( a.sourceIndex && b.sourceIndex ) {
+ return a.sourceIndex - b.sourceIndex;
+ }
+
+ var al, bl,
+ ap = [],
+ bp = [],
+ aup = a.parentNode,
+ bup = b.parentNode,
+ cur = aup;
+
+ // If the nodes are siblings (or identical) we can do a quick check
+ if ( aup === bup ) {
+ return siblingCheck( a, b );
+
+ // If no parents were found then the nodes are disconnected
+ } else if ( !aup ) {
+ return -1;
+
+ } else if ( !bup ) {
+ return 1;
+ }
+
+ // Otherwise they're somewhere else in the tree so we need
+ // to build up a full list of the parentNodes for comparison
+ while ( cur ) {
+ ap.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ cur = bup;
+
+ while ( cur ) {
+ bp.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ al = ap.length;
+ bl = bp.length;
+
+ // Start walking down the tree looking for a discrepancy
+ for ( var i = 0; i < al && i < bl; i++ ) {
+ if ( ap[i] !== bp[i] ) {
+ return siblingCheck( ap[i], bp[i] );
+ }
+ }
+
+ // We ended someplace up the tree so do a sibling check
+ return i === al ?
+ siblingCheck( a, bp[i], -1 ) :
+ siblingCheck( ap[i], b, 1 );
+ };
+
+ siblingCheck = function( a, b, ret ) {
+ if ( a === b ) {
+ return ret;
+ }
+
+ var cur = a.nextSibling;
+
+ while ( cur ) {
+ if ( cur === b ) {
+ return -1;
+ }
+
+ cur = cur.nextSibling;
+ }
+
+ return 1;
+ };
+ }
+
+ // Utility function for retreiving the text value of an array of DOM nodes
+ Sizzle.getText = function( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += Sizzle.getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+ };
+
+ // Check to see if the browser returns elements by name when
+ // querying by getElementById (and provide a workaround)
+ (function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date()).getTime(),
+ root = document.documentElement;
+
+ form.innerHTML = "";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function( match, context, isXML ) {
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+
+ return m ?
+ m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
+ [m] :
+ undefined :
+ [];
+ }
+ };
+
+ Expr.filter.ID = function( elem, match ) {
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+
+ // release memory in IE
+ root = form = null;
+ })();
+
+ (function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function( match, context ) {
+ var results = context.getElementsByTagName( match[1] );
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "";
+
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+
+ Expr.attrHandle.href = function( elem ) {
+ return elem.getAttribute( "href", 2 );
+ };
+ }
+
+ // release memory in IE
+ div = null;
+ })();
+
+ if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle,
+ div = document.createElement("div"),
+ id = "__sizzle__";
+
+ div.innerHTML = "";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function( query, context, extra, seed ) {
+ context = context || document;
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && !Sizzle.isXML(context) ) {
+ // See if we find a selector to speed up
+ var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
+
+ if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
+ // Speed-up: Sizzle("TAG")
+ if ( match[1] ) {
+ return makeArray( context.getElementsByTagName( query ), extra );
+
+ // Speed-up: Sizzle(".CLASS")
+ } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
+ return makeArray( context.getElementsByClassName( match[2] ), extra );
+ }
+ }
+
+ if ( context.nodeType === 9 ) {
+ // Speed-up: Sizzle("body")
+ // The body element only exists once, optimize finding it
+ if ( query === "body" && context.body ) {
+ return makeArray( [ context.body ], extra );
+
+ // Speed-up: Sizzle("#ID")
+ } else if ( match && match[3] ) {
+ var elem = context.getElementById( match[3] );
+
+ // 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[3] ) {
+ return makeArray( [ elem ], extra );
+ }
+
+ } else {
+ return makeArray( [], extra );
+ }
+ }
+
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(qsaError) {}
+
+ // 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
+ } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ var oldContext = context,
+ old = context.getAttribute( "id" ),
+ nid = old || id,
+ hasParent = context.parentNode,
+ relativeHierarchySelector = /^\s*[+~]/.test( query );
+
+ if ( !old ) {
+ context.setAttribute( "id", nid );
+ } else {
+ nid = nid.replace( /'/g, "\\$&" );
+ }
+ if ( relativeHierarchySelector && hasParent ) {
+ context = context.parentNode;
+ }
+
+ try {
+ if ( !relativeHierarchySelector || hasParent ) {
+ return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
+ }
+
+ } catch(pseudoError) {
+ } finally {
+ if ( !old ) {
+ oldContext.removeAttribute( "id" );
+ }
+ }
+ }
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ // release memory in IE
+ div = null;
+ })();
+ }
+
+ (function(){
+ var html = document.documentElement,
+ matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
+
+ if ( matches ) {
+ // Check to see if it's possible to do matchesSelector
+ // on a disconnected node (IE 9 fails this)
+ var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
+ pseudoWorks = false;
+
+ try {
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call( document.documentElement, "[test!='']:sizzle" );
+
+ } catch( pseudoError ) {
+ pseudoWorks = true;
+ }
+
+ Sizzle.matchesSelector = function( node, expr ) {
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
+
+ if ( !Sizzle.isXML( node ) ) {
+ try {
+ if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
+ var ret = matches.call( node, expr );
+
+ // IE 9's matchesSelector returns false on disconnected nodes
+ if ( ret || !disconnectedMatch ||
+ // As well, disconnected nodes are said to be in a document
+ // fragment in IE 9, so check for that
+ node.document && node.document.nodeType !== 11 ) {
+ return ret;
+ }
+ }
+ } catch(e) {}
+ }
+
+ return Sizzle(expr, null, null, [node]).length > 0;
+ };
+ }
+ })();
+
+ (function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function( match, context, isXML ) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ // release memory in IE
+ div = null;
+ })();
+
+ function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+
+ if ( elem ) {
+ var match = false;
+
+ elem = elem[dir];
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+ }
+
+ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+
+ if ( elem ) {
+ var match = false;
+
+ elem = elem[dir];
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+ }
+
+ if ( document.documentElement.contains ) {
+ Sizzle.contains = function( a, b ) {
+ return a !== b && (a.contains ? a.contains(b) : true);
+ };
+
+ } else if ( document.documentElement.compareDocumentPosition ) {
+ Sizzle.contains = function( a, b ) {
+ return !!(a.compareDocumentPosition(b) & 16);
+ };
+
+ } else {
+ Sizzle.contains = function() {
+ return false;
+ };
+ }
+
+ 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 : 0).documentElement;
+
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+ };
+
+ var posProcess = function( selector, context ) {
+ var match,
+ tmpSet = [],
+ later = "",
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+ };
+
+ // EXPOSE
+ jQuery.find = Sizzle;
+ jQuery.expr = Sizzle.selectors;
+ jQuery.expr[":"] = jQuery.expr.filters;
+ jQuery.unique = Sizzle.uniqueSort;
+ jQuery.text = Sizzle.getText;
+ jQuery.isXMLDoc = Sizzle.isXML;
+ jQuery.contains = Sizzle.contains;
+
+
+ })();
+
+
+ var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ isSimple = /^.[^:#\[\.,]*$/,
+ slice = Array.prototype.slice,
+ POS = jQuery.expr.match.POS,
+ // methods guaranteed to produce a unique set when starting from a unique set
+ guaranteedUnique = {
+ children: true,
+ contents: true,
+ next: true,
+ prev: true
+ };
+
+ jQuery.fn.extend({
+ find: function( selector ) {
+ var self = this,
+ i, l;
+
+ if ( typeof selector !== "string" ) {
+ return jQuery( selector ).filter(function() {
+ for ( i = 0, l = self.length; i < l; i++ ) {
+ if ( jQuery.contains( self[ i ], this ) ) {
+ return true;
+ }
+ }
+ });
+ }
+
+ var ret = this.pushStack( "", "find", selector ),
+ length, n, r;
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( n = length; n < ret.length; n++ ) {
+ for ( r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && ( typeof selector === "string" ?
+ jQuery.filter( selector, this ).length > 0 :
+ this.filter( selector ).length > 0 );
+ },
+
+ closest: function( selectors, context ) {
+ var ret = [], i, l, cur = this[0];
+
+ // Array
+ if ( jQuery.isArray( selectors ) ) {
+ var match, selector,
+ matches = {},
+ level = 1;
+
+ if ( cur && selectors.length ) {
+ for ( i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[ selector ] ) {
+ matches[ selector ] = POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[ selector ];
+
+ if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
+ ret.push({ selector: selector, elem: cur, level: level });
+ }
+ }
+
+ cur = cur.parentNode;
+ level++;
+ }
+ }
+
+ return ret;
+ }
+
+ // String
+ var pos = POS.test( selectors ) || typeof selectors !== "string" ?
+ jQuery( selectors, context || this.context ) :
+ 0;
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ cur = this[i];
+
+ while ( cur ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
+ ret.push( cur );
+ break;
+
+ } else {
+ cur = cur.parentNode;
+ if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
+ break;
+ }
+ }
+ }
+ }
+
+ ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
+
+ return this.pushStack( ret, "closest", selectors );
+ },
+
+ // 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.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 ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context ) :
+ jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+ });
+
+ // A painfully simple check to see if an element is disconnected
+ // from a document (should be improved, where feasible).
+ function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+ }
+
+ 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 jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "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.makeArray( elem.childNodes );
+ }
+ }, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until ),
+ // The variable 'args' was introduced in
+ // https://github.com/jquery/jquery/commit/52a0238
+ // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
+ // http://code.google.com/p/v8/issues/detail?id=1050
+ args = slice.call(arguments);
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, args.join(",") );
+ };
+ });
+
+ jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 ?
+ jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
+ jQuery.find.matches(expr, elems);
+ },
+
+ 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;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+ });
+
+ // Implement the identical functionality for filter and not
+ function winnow( elements, qualifier, keep ) {
+
+ // Can't pass null or undefined to indexOf in Firefox 4
+ // Set to 0 to skip string check
+ qualifier = qualifier || 0;
+
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ var retVal = !!qualifier.call( elem, i, elem );
+ return retVal === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, filtered );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+ }
+
+
+
+
+ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
+ rtagName = /<([\w:]+)/,
+ rtbody = /", "" ],
+ legend: [ 1, "" ],
+ thead: [ 1, "
", "
" ],
+ tr: [ 2, "
", "
" ],
+ td: [ 3, "
", "
" ],
+ col: [ 2, "
", "
" ],
+ area: [ 1, "" ],
+ _default: [ 0, "", "" ]
+ };
+
+ wrapMap.optgroup = wrapMap.option;
+ wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+ wrapMap.th = wrapMap.td;
+
+ // IE can't serialize and .");
+ }
+ };
+
+ // .on() was added in version 1.7.0, .load() was removed in version 3.0.0 so we fallback to .load() if .on() does
+ // not exist to not break existing applications
+ if (typeof _pageWindow.on === "function") {
+ _pageWindow.on("load", function () { _pageLoaded = true; });
+ }
+ else {
+ _pageWindow.load(function () { _pageLoaded = true; });
+ }
+
+ function validateTransport(requestedTransport, connection) {
+ /// Validates the requested transport by cross checking it with the pre-defined signalR.transports
+ /// The designated transports that the user has specified.
+ /// The connection that will be using the requested transports. Used for logging purposes.
+ ///
+
+ if ($.isArray(requestedTransport)) {
+ // Go through transport array and remove an "invalid" tranports
+ for (var i = requestedTransport.length - 1; i >= 0; i--) {
+ var transport = requestedTransport[i];
+ if ($.type(transport) !== "string" || !signalR.transports[transport]) {
+ connection.log("Invalid transport: " + transport + ", removing it from the transports list.");
+ requestedTransport.splice(i, 1);
+ }
+ }
+
+ // Verify we still have transports left, if we dont then we have invalid transports
+ if (requestedTransport.length === 0) {
+ connection.log("No transports remain within the specified transport array.");
+ requestedTransport = null;
+ }
+ } else if (!signalR.transports[requestedTransport] && requestedTransport !== "auto") {
+ connection.log("Invalid transport: " + requestedTransport.toString() + ".");
+ requestedTransport = null;
+ } else if (requestedTransport === "auto" && signalR._.ieVersion <= 8) {
+ // If we're doing an auto transport and we're IE8 then force longPolling, #1764
+ return ["longPolling"];
+
+ }
+
+ return requestedTransport;
+ }
+
+ function getDefaultPort(protocol) {
+ if (protocol === "http:") {
+ return 80;
+ } else if (protocol === "https:") {
+ return 443;
+ }
+ }
+
+ function addDefaultPort(protocol, url) {
+ // Remove ports from url. We have to check if there's a / or end of line
+ // following the port in order to avoid removing ports such as 8080.
+ if (url.match(/:\d+$/)) {
+ return url;
+ } else {
+ return url + ":" + getDefaultPort(protocol);
+ }
+ }
+
+ function ConnectingMessageBuffer(connection, drainCallback) {
+ var that = this,
+ buffer = [];
+
+ that.tryBuffer = function (message) {
+ if (connection.state === $.signalR.connectionState.connecting) {
+ buffer.push(message);
+
+ return true;
+ }
+
+ return false;
+ };
+
+ that.drain = function () {
+ // Ensure that the connection is connected when we drain (do not want to drain while a connection is not active)
+ if (connection.state === $.signalR.connectionState.connected) {
+ while (buffer.length > 0) {
+ drainCallback(buffer.shift());
+ }
+ }
+ };
+
+ that.clear = function () {
+ buffer = [];
+ };
+ }
+
+ signalR.fn = signalR.prototype = {
+ init: function (url, qs, logging) {
+ var $connection = $(this);
+
+ this.url = url;
+ this.qs = qs;
+ this.lastError = null;
+ this._ = {
+ keepAliveData: {},
+ connectingMessageBuffer: new ConnectingMessageBuffer(this, function (message) {
+ $connection.triggerHandler(events.onReceived, [message]);
+ }),
+ lastMessageAt: new Date().getTime(),
+ lastActiveAt: new Date().getTime(),
+ beatInterval: 5000, // Default value, will only be overridden if keep alive is enabled,
+ beatHandle: null,
+ totalTransportConnectTimeout: 0, // This will be the sum of the TransportConnectTimeout sent in response to negotiate and connection.transportConnectTimeout
+ redirectQs: null
+ };
+ if (typeof (logging) === "boolean") {
+ this.logging = logging;
+ }
+ },
+
+ _parseResponse: function (response) {
+ var that = this;
+
+ if (!response) {
+ return response;
+ } else if (typeof response === "string") {
+ return that.json.parse(response);
+ } else {
+ return response;
+ }
+ },
+
+ _originalJson: window.JSON,
+
+ json: window.JSON,
+
+ isCrossDomain: function (url, against) {
+ /// Checks if url is cross domain
+ /// The base URL
+ ///
+ /// An optional argument to compare the URL against, if not specified it will be set to window.location.
+ /// If specified it must contain a protocol and a host property.
+ ///
+ var link;
+
+ url = $.trim(url);
+
+ against = against || window.location;
+
+ if (url.indexOf("http") !== 0) {
+ return false;
+ }
+
+ // Create an anchor tag.
+ link = window.document.createElement("a");
+ link.href = url;
+
+ // When checking for cross domain we have to special case port 80 because the window.location will remove the
+ return link.protocol + addDefaultPort(link.protocol, link.host) !== against.protocol + addDefaultPort(against.protocol, against.host);
+ },
+
+ ajaxDataType: "text",
+
+ contentType: "application/json; charset=UTF-8",
+
+ logging: false,
+
+ state: signalR.connectionState.disconnected,
+
+ clientProtocol: "2.1",
+
+ // We want to support older servers since the 2.0 change is to support redirection results, which isn't
+ // really breaking in the protocol. So if a user updates their client to 2.0 protocol version there's
+ // no reason they can't still connect to a 1.5 server. The 2.1 protocol is sent by the client so the SignalR
+ // service knows the client will use they query string returned via the RedirectUrl for subsequent requests.
+ // It doesn't matter whether the server reflects back 2.1 or continues using 2.0 as the protocol version.
+ supportedProtocols: ["1.5", "2.0", "2.1"],
+
+ negotiateRedirectSupportedProtocols: ["2.0", "2.1"],
+
+ reconnectDelay: 2000,
+
+ transportConnectTimeout: 0,
+
+ disconnectTimeout: 30000, // This should be set by the server in response to the negotiate request (30s default)
+
+ reconnectWindow: 30000, // This should be set by the server in response to the negotiate request
+
+ keepAliveWarnAt: 2 / 3, // Warn user of slow connection if we breach the X% mark of the keep alive timeout
+
+ start: function (options, callback) {
+ /// Starts the connection
+ /// Options map
+ /// A callback function to execute when the connection has started
+ var connection = this,
+ config = {
+ pingInterval: 300000,
+ waitForPageLoad: true,
+ transport: "auto",
+ jsonp: false
+ },
+ initialize,
+ deferred = connection._deferral || $.Deferred(), // Check to see if there is a pre-existing deferral that's being built on, if so we want to keep using it
+ parser = window.document.createElement("a"),
+ setConnectionUrl = function (connection, url) {
+ if (connection.url === url && connection.baseUrl) {
+ // when the url related properties are already set
+ return;
+ }
+
+ connection.url = url;
+
+ // Resolve the full url
+ parser.href = connection.url;
+ if (!parser.protocol || parser.protocol === ":") {
+ connection.protocol = window.document.location.protocol;
+ connection.host = parser.host || window.document.location.host;
+ } else {
+ connection.protocol = parser.protocol;
+ connection.host = parser.host;
+ }
+
+ connection.baseUrl = connection.protocol + "//" + connection.host;
+
+ // Set the websocket protocol
+ connection.wsProtocol = connection.protocol === "https:" ? "wss://" : "ws://";
+
+ // If the url is protocol relative, prepend the current windows protocol to the url.
+ if (connection.url.indexOf("//") === 0) {
+ connection.url = window.location.protocol + connection.url;
+ connection.log("Protocol relative URL detected, normalizing it to '" + connection.url + "'.");
+ }
+
+ if (connection.isCrossDomain(connection.url)) {
+ connection.log("Auto detected cross domain url.");
+
+ if (config.transport === "auto") {
+ // Cross-domain does not support foreverFrame
+ config.transport = ["webSockets", "serverSentEvents", "longPolling"];
+ }
+
+ if (typeof connection.withCredentials === "undefined") {
+ connection.withCredentials = true;
+ }
+
+ // Determine if jsonp is the only choice for negotiation, ajaxSend and ajaxAbort.
+ // i.e. if the browser doesn't supports CORS
+ // If it is, ignore any preference to the contrary, and switch to jsonp.
+ if (!$.support.cors) {
+ connection.ajaxDataType = "jsonp";
+ connection.log("Using jsonp because this browser doesn't support CORS.");
+ }
+
+ connection.contentType = signalR._.defaultContentType;
+ }
+ };
+
+ connection.lastError = null;
+
+ // Persist the deferral so that if start is called multiple times the same deferral is used.
+ connection._deferral = deferred;
+
+ if (!connection.json) {
+ // no JSON!
+ throw new Error("SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. IE<8.");
+ }
+
+ if ($.type(options) === "function") {
+ // Support calling with single callback parameter
+ callback = options;
+ } else if ($.type(options) === "object") {
+ $.extend(config, options);
+ if ($.type(config.callback) === "function") {
+ callback = config.callback;
+ }
+ }
+
+ config.transport = validateTransport(config.transport, connection);
+
+ // If the transport is invalid throw an error and abort start
+ if (!config.transport) {
+ throw new Error("SignalR: Invalid transport(s) specified, aborting start.");
+ }
+
+ connection._.config = config;
+
+ // Check to see if start is being called prior to page load
+ // If waitForPageLoad is true we then want to re-direct function call to the window load event
+ if (!_pageLoaded && config.waitForPageLoad === true) {
+ connection._.deferredStartHandler = function () {
+ connection.start(options, callback);
+ };
+ _pageWindow.bind("load", connection._.deferredStartHandler);
+
+ return deferred.promise();
+ }
+
+ // If we're already connecting just return the same deferral as the original connection start
+ if (connection.state === signalR.connectionState.connecting) {
+ return deferred.promise();
+ } else if (changeState(connection,
+ signalR.connectionState.disconnected,
+ signalR.connectionState.connecting) === false) {
+ // We're not connecting so try and transition into connecting.
+ // If we fail to transition then we're either in connected or reconnecting.
+
+ deferred.resolve(connection);
+ return deferred.promise();
+ }
+
+ configureStopReconnectingTimeout(connection);
+
+ // If jsonp with no/auto transport is specified, then set the transport to long polling
+ // since that is the only transport for which jsonp really makes sense.
+ // Some developers might actually choose to specify jsonp for same origin requests
+ // as demonstrated by Issue #623.
+ if (config.transport === "auto" && config.jsonp === true) {
+ config.transport = "longPolling";
+ }
+
+ connection.withCredentials = config.withCredentials;
+
+ // Save the original url so that we can reset it when we stop and restart the connection
+ connection._originalUrl = connection.url;
+
+ connection.ajaxDataType = config.jsonp ? "jsonp" : "text";
+
+ setConnectionUrl(connection, connection.url);
+
+ $(connection).bind(events.onStart, function (e, data) {
+ if ($.type(callback) === "function") {
+ callback.call(connection);
+ }
+ deferred.resolve(connection);
+ });
+
+ connection._.initHandler = signalR.transports._logic.initHandler(connection);
+
+ initialize = function (transports, index) {
+ var noTransportError = signalR._.error(resources.noTransportOnInit);
+
+ index = index || 0;
+ if (index >= transports.length) {
+ if (index === 0) {
+ connection.log("No transports supported by the server were selected.");
+ } else if (index === 1) {
+ connection.log("No fallback transports were selected.");
+ } else {
+ connection.log("Fallback transports exhausted.");
+ }
+
+ // No transport initialized successfully
+ $(connection).triggerHandler(events.onError, [noTransportError]);
+ deferred.reject(noTransportError);
+ // Stop the connection if it has connected and move it into the disconnected state
+ connection.stop();
+ return;
+ }
+
+ // The connection was aborted
+ if (connection.state === signalR.connectionState.disconnected) {
+ return;
+ }
+
+ var transportName = transports[index],
+ transport = signalR.transports[transportName],
+ onFallback = function () {
+ initialize(transports, index + 1);
+ };
+
+ connection.transport = transport;
+
+ try {
+ connection._.initHandler.start(transport, function () { // success
+ // Firefox 11+ doesn't allow sync XHR withCredentials: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#withCredentials
+ var isFirefox11OrGreater = signalR._.firefoxMajorVersion(window.navigator.userAgent) >= 11,
+ asyncAbort = true;
+
+ connection.log("The start request succeeded. Transitioning to the connected state.");
+
+ if (supportsKeepAlive(connection)) {
+ signalR.transports._logic.monitorKeepAlive(connection);
+ }
+
+ if (connection._.keepAliveData.activated) {
+ signalR.transports._logic.startHeartbeat(connection);
+ }
+
+ // Used to ensure low activity clients maintain their authentication.
+ // Must be configured once a transport has been decided to perform valid ping requests.
+ signalR._.configurePingInterval(connection);
+
+ if (!changeState(connection,
+ signalR.connectionState.connecting,
+ signalR.connectionState.connected)) {
+ connection.log("WARNING! The connection was not in the connecting state.");
+ }
+
+ // Drain any incoming buffered messages (messages that came in prior to connect)
+ connection._.connectingMessageBuffer.drain();
+
+ $(connection).triggerHandler(events.onStart);
+
+ // wire the stop handler for when the user leaves the page
+ _pageWindow.bind("unload", function () {
+ connection.log("Window unloading, stopping the connection.");
+
+ connection.stop(asyncAbort);
+ });
+
+ if (isFirefox11OrGreater) {
+ // Firefox does not fire cross-domain XHRs in the normal unload handler on tab close.
+ // #2400
+ _pageWindow.bind("beforeunload", function () {
+ // If connection.stop() runs runs in beforeunload and fails, it will also fail
+ // in unload unless connection.stop() runs after a timeout.
+ window.setTimeout(function () {
+ connection.stop(asyncAbort);
+ }, 0);
+ });
+ }
+ }, onFallback);
+ }
+ catch (error) {
+ connection.log(transport.name + " transport threw '" + error.message + "' when attempting to start.");
+ onFallback();
+ }
+ };
+
+ var url = connection.url + "/negotiate",
+ onFailed = function (error, connection) {
+ var err = signalR._.error(resources.errorOnNegotiate, error, connection._.negotiateRequest);
+
+ $(connection).triggerHandler(events.onError, err);
+ deferred.reject(err);
+ // Stop the connection if negotiate failed
+ connection.stop();
+ };
+
+ $(connection).triggerHandler(events.onStarting);
+
+ url = signalR.transports._logic.prepareQueryString(connection, url);
+
+ connection.log("Negotiating with '" + url + "'.");
+
+ // Save the ajax negotiate request object so we can abort it if stop is called while the request is in flight.
+ connection._.negotiateRequest = function () {
+ var res,
+ redirects = 0,
+ MAX_REDIRECTS = 100,
+ keepAliveData,
+ protocolError,
+ transports = [],
+ supportedTransports = [],
+ negotiate = function (connection, onSuccess) {
+ var url = signalR.transports._logic.prepareQueryString(connection, connection.url + "/negotiate");
+ connection.log("Negotiating with '" + url + "'.");
+ var options = {
+ url: url,
+ error: function (error, statusText) {
+ // We don't want to cause any errors if we're aborting our own negotiate request.
+ if (statusText !== _negotiateAbortText) {
+ onFailed(error, connection);
+ } else {
+ // This rejection will noop if the deferred has already been resolved or rejected.
+ deferred.reject(signalR._.error(resources.stoppedWhileNegotiating, null /* error */, connection._.negotiateRequest));
+ }
+ },
+ success: onSuccess
+ };
+
+ if (connection.accessToken) {
+ options.headers = { "Authorization": "Bearer " + connection.accessToken };
+ }
+
+ return signalR.transports._logic.ajax(connection, options);
+ },
+ callback = function (result) {
+ try {
+ res = connection._parseResponse(result);
+ } catch (error) {
+ onFailed(signalR._.error(resources.errorParsingNegotiateResponse, error), connection);
+ return;
+ }
+
+ // Check if the server is an ASP.NET Core app
+ if (res.availableTransports) {
+ protocolError = signalR._.error(resources.aspnetCoreSignalrServer);
+ $(connection).triggerHandler(events.onError, [protocolError]);
+ deferred.reject(protocolError);
+ return;
+ }
+
+ if (!res.ProtocolVersion || (connection.supportedProtocols.indexOf(res.ProtocolVersion) === -1)) {
+ protocolError = signalR._.error(signalR._.format(resources.protocolIncompatible, connection.clientProtocol, res.ProtocolVersion));
+ $(connection).triggerHandler(events.onError, [protocolError]);
+ deferred.reject(protocolError);
+
+ return;
+ }
+
+ // Check for a redirect response (which must have a ProtocolVersion of 2.0 or greater)
+ // ProtocolVersion 2.1 is the highest supported by the client, so we can just check for 2.0 or 2.1 for now
+ // instead of trying to do proper version string comparison in JavaScript.
+ if (connection.negotiateRedirectSupportedProtocols.indexOf(res.ProtocolVersion) !== -1) {
+ if (res.Error) {
+ protocolError = signalR._.error(signalR._.format(resources.errorFromServer, res.Error));
+ $(connection).triggerHandler(events.onError, [protocolError]);
+ deferred.reject(protocolError);
+ return;
+ }
+ else if (res.RedirectUrl) {
+ if (redirects === MAX_REDIRECTS) {
+ onFailed(signalR._.error(resources.errorRedirectionExceedsLimit), connection);
+ return;
+ }
+
+ if (config.transport === "auto") {
+ // Redirected connections do not support foreverFrame
+ config.transport = ["webSockets", "serverSentEvents", "longPolling"];
+ }
+
+ connection.log("Received redirect to: " + res.RedirectUrl);
+ connection.accessToken = res.AccessToken;
+
+ var splitUrlAndQs = res.RedirectUrl.split("?", 2);
+ setConnectionUrl(connection, splitUrlAndQs[0]);
+
+ // Update redirectQs with query string from only the most recent RedirectUrl.
+ connection._.redirectQs = splitUrlAndQs.length === 2 ? splitUrlAndQs[1] : null;
+
+ if (connection.ajaxDataType === "jsonp" && connection.accessToken) {
+ onFailed(signalR._.error(resources.jsonpNotSupportedWithAccessToken), connection);
+ return;
+ }
+
+ redirects++;
+ negotiate(connection, callback);
+ return;
+ }
+ }
+
+ keepAliveData = connection._.keepAliveData;
+ connection.appRelativeUrl = res.Url;
+ connection.id = res.ConnectionId;
+ connection.token = res.ConnectionToken;
+ connection.webSocketServerUrl = res.WebSocketServerUrl;
+
+ // The long poll timeout is the ConnectionTimeout plus 10 seconds
+ connection._.pollTimeout = res.ConnectionTimeout * 1000 + 10000; // in ms
+
+ // Once the server has labeled the PersistentConnection as Disconnected, we should stop attempting to reconnect
+ // after res.DisconnectTimeout seconds.
+ connection.disconnectTimeout = res.DisconnectTimeout * 1000; // in ms
+
+ // Add the TransportConnectTimeout from the response to the transportConnectTimeout from the client to calculate the total timeout
+ connection._.totalTransportConnectTimeout = connection.transportConnectTimeout + res.TransportConnectTimeout * 1000;
+
+ // If we have a keep alive
+ if (res.KeepAliveTimeout) {
+ // Register the keep alive data as activated
+ keepAliveData.activated = true;
+
+ // Timeout to designate when to force the connection into reconnecting converted to milliseconds
+ keepAliveData.timeout = res.KeepAliveTimeout * 1000;
+
+ // Timeout to designate when to warn the developer that the connection may be dead or is not responding.
+ keepAliveData.timeoutWarning = keepAliveData.timeout * connection.keepAliveWarnAt;
+
+ // Instantiate the frequency in which we check the keep alive. It must be short in order to not miss/pick up any changes
+ connection._.beatInterval = (keepAliveData.timeout - keepAliveData.timeoutWarning) / 3;
+ } else {
+ keepAliveData.activated = false;
+ }
+
+ connection.reconnectWindow = connection.disconnectTimeout + (keepAliveData.timeout || 0);
+
+ $.each(signalR.transports, function (key) {
+ if ((key.indexOf("_") === 0) || (key === "webSockets" && !res.TryWebSockets)) {
+ return true;
+ }
+ supportedTransports.push(key);
+ });
+
+ if ($.isArray(config.transport)) {
+ $.each(config.transport, function (_, transport) {
+ if ($.inArray(transport, supportedTransports) >= 0) {
+ transports.push(transport);
+ }
+ });
+ } else if (config.transport === "auto") {
+ transports = supportedTransports;
+ } else if ($.inArray(config.transport, supportedTransports) >= 0) {
+ transports.push(config.transport);
+ }
+
+ initialize(transports);
+ };
+
+ return negotiate(connection, callback);
+ }();
+
+ return deferred.promise();
+ },
+
+ starting: function (callback) {
+ /// Adds a callback that will be invoked before anything is sent over the connection
+ /// A callback function to execute before the connection is fully instantiated.
+ ///
+ var connection = this;
+ $(connection).bind(events.onStarting, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ send: function (data) {
+ /// Sends data over the connection
+ /// The data to send over the connection
+ ///
+ var connection = this;
+
+ if (connection.state === signalR.connectionState.disconnected) {
+ // Connection hasn't been started yet
+ throw new Error("SignalR: Connection must be started before data can be sent. Call .start() before .send()");
+ }
+
+ if (connection.state === signalR.connectionState.connecting) {
+ // Connection hasn't been started yet
+ throw new Error("SignalR: Connection has not been fully initialized. Use .start().done() or .start().fail() to run logic after the connection has started.");
+ }
+
+ connection.transport.send(connection, data);
+ // REVIEW: Should we return deferred here?
+ return connection;
+ },
+
+ received: function (callback) {
+ /// Adds a callback that will be invoked after anything is received over the connection
+ /// A callback function to execute when any data is received on the connection
+ ///
+ var connection = this;
+ $(connection).bind(events.onReceived, function (e, data) {
+ callback.call(connection, data);
+ });
+ return connection;
+ },
+
+ stateChanged: function (callback) {
+ /// Adds a callback that will be invoked when the connection state changes
+ /// A callback function to execute when the connection state changes
+ ///
+ var connection = this;
+ $(connection).bind(events.onStateChanged, function (e, data) {
+ callback.call(connection, data);
+ });
+ return connection;
+ },
+
+ error: function (callback) {
+ /// Adds a callback that will be invoked after an error occurs with the connection
+ /// A callback function to execute when an error occurs on the connection
+ ///
+ var connection = this;
+ $(connection).bind(events.onError, function (e, errorData, sendData) {
+ connection.lastError = errorData;
+ // In practice 'errorData' is the SignalR built error object.
+ // In practice 'sendData' is undefined for all error events except those triggered by
+ // 'ajaxSend' and 'webSockets.send'.'sendData' is the original send payload.
+ callback.call(connection, errorData, sendData);
+ });
+ return connection;
+ },
+
+ disconnected: function (callback) {
+ /// Adds a callback that will be invoked when the client disconnects
+ /// A callback function to execute when the connection is broken
+ ///
+ var connection = this;
+ $(connection).bind(events.onDisconnect, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ connectionSlow: function (callback) {
+ /// Adds a callback that will be invoked when the client detects a slow connection
+ /// A callback function to execute when the connection is slow
+ ///
+ var connection = this;
+ $(connection).bind(events.onConnectionSlow, function (e, data) {
+ callback.call(connection);
+ });
+
+ return connection;
+ },
+
+ reconnecting: function (callback) {
+ /// Adds a callback that will be invoked when the underlying transport begins reconnecting
+ /// A callback function to execute when the connection enters a reconnecting state
+ ///
+ var connection = this;
+ $(connection).bind(events.onReconnecting, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ reconnected: function (callback) {
+ /// Adds a callback that will be invoked when the underlying transport reconnects
+ /// A callback function to execute when the connection is restored
+ ///
+ var connection = this;
+ $(connection).bind(events.onReconnect, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ stop: function (async, notifyServer) {
+ /// Stops listening
+ /// Whether or not to asynchronously abort the connection
+ /// Whether we want to notify the server that we are aborting the connection
+ ///
+ var connection = this,
+ // Save deferral because this is always cleaned up
+ deferral = connection._deferral;
+
+ // Verify that we've bound a load event.
+ if (connection._.deferredStartHandler) {
+ // Unbind the event.
+ _pageWindow.unbind("load", connection._.deferredStartHandler);
+ }
+
+ // Always clean up private non-timeout based state.
+ delete connection._.config;
+ delete connection._.deferredStartHandler;
+
+ // This needs to be checked despite the connection state because a connection start can be deferred until page load.
+ // If we've deferred the start due to a page load we need to unbind the "onLoad" -> start event.
+ if (!_pageLoaded && (!connection._.config || connection._.config.waitForPageLoad === true)) {
+ connection.log("Stopping connection prior to negotiate.");
+
+ // If we have a deferral we should reject it
+ if (deferral) {
+ deferral.reject(signalR._.error(resources.stoppedWhileLoading));
+ }
+
+ // Short-circuit because the start has not been fully started.
+ return;
+ }
+
+ if (connection.state === signalR.connectionState.disconnected) {
+ return;
+ }
+
+ connection.log("Stopping connection.");
+
+ // Clear this no matter what
+ window.clearTimeout(connection._.beatHandle);
+ window.clearInterval(connection._.pingIntervalId);
+
+ if (connection.transport) {
+ connection.transport.stop(connection);
+
+ if (notifyServer !== false) {
+ connection.transport.abort(connection, async);
+ }
+
+ if (supportsKeepAlive(connection)) {
+ signalR.transports._logic.stopMonitoringKeepAlive(connection);
+ }
+
+ connection.transport = null;
+ }
+
+ if (connection._.negotiateRequest) {
+ // If the negotiation request has already completed this will noop.
+ connection._.negotiateRequest.abort(_negotiateAbortText);
+ delete connection._.negotiateRequest;
+ }
+
+ // Ensure that initHandler.stop() is called before connection._deferral is deleted
+ if (connection._.initHandler) {
+ connection._.initHandler.stop();
+ }
+
+ delete connection._deferral;
+ delete connection.messageId;
+ delete connection.groupsToken;
+ delete connection.id;
+ delete connection._.pingIntervalId;
+ delete connection._.lastMessageAt;
+ delete connection._.lastActiveAt;
+
+ // Clear out our message buffer
+ connection._.connectingMessageBuffer.clear();
+
+ // Clean up this event
+ $(connection).unbind(events.onStart);
+
+ // Reset the URL and clear the access token
+ delete connection.accessToken;
+ delete connection.protocol;
+ delete connection.host;
+ delete connection.baseUrl;
+ delete connection.wsProtocol;
+ delete connection.contentType;
+ connection.url = connection._originalUrl;
+ connection._.redirectQs = null;
+
+ // Trigger the disconnect event
+ changeState(connection, connection.state, signalR.connectionState.disconnected);
+ $(connection).triggerHandler(events.onDisconnect);
+
+ return connection;
+ },
+
+ log: function (msg) {
+ log(msg, this.logging);
+ }
+ };
+
+ signalR.fn.init.prototype = signalR.fn;
+
+ signalR.noConflict = function () {
+ /// Reinstates the original value of $.connection and returns the signalR object for manual assignment
+ ///
+ if ($.connection === signalR) {
+ $.connection = _connection;
+ }
+ return signalR;
+ };
+
+ if ($.connection) {
+ _connection = $.connection;
+ }
+
+ $.connection = $.signalR = signalR;
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.common.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ startAbortText = "__Start Aborted__",
+ transportLogic;
+
+ signalR.transports = {};
+
+ function beat(connection) {
+ if (connection._.keepAliveData.monitoring) {
+ checkIfAlive(connection);
+ }
+
+ // Ensure that we successfully marked active before continuing the heartbeat.
+ if (transportLogic.markActive(connection)) {
+ connection._.beatHandle = window.setTimeout(function () {
+ beat(connection);
+ }, connection._.beatInterval);
+ }
+ }
+
+ function checkIfAlive(connection) {
+ var keepAliveData = connection._.keepAliveData,
+ timeElapsed;
+
+ // Only check if we're connected
+ if (connection.state === signalR.connectionState.connected) {
+ timeElapsed = new Date().getTime() - connection._.lastMessageAt;
+
+ // Check if the keep alive has completely timed out
+ if (timeElapsed >= keepAliveData.timeout) {
+ connection.log("Keep alive timed out. Notifying transport that connection has been lost.");
+
+ // Notify transport that the connection has been lost
+ connection.transport.lostConnection(connection);
+ } else if (timeElapsed >= keepAliveData.timeoutWarning) {
+ // This is to assure that the user only gets a single warning
+ if (!keepAliveData.userNotified) {
+ connection.log("Keep alive has been missed, connection may be dead/slow.");
+ $(connection).triggerHandler(events.onConnectionSlow);
+ keepAliveData.userNotified = true;
+ }
+ } else {
+ keepAliveData.userNotified = false;
+ }
+ }
+ }
+
+ function getAjaxUrl(connection, path) {
+ var url = connection.url + path;
+
+ if (connection.transport) {
+ url += "?transport=" + connection.transport.name;
+ }
+
+ return transportLogic.prepareQueryString(connection, url);
+ }
+
+ function InitHandler(connection) {
+ this.connection = connection;
+
+ this.startRequested = false;
+ this.startCompleted = false;
+ this.connectionStopped = false;
+ }
+
+ InitHandler.prototype = {
+ start: function (transport, onSuccess, onFallback) {
+ var that = this,
+ connection = that.connection,
+ failCalled = false;
+
+ if (that.startRequested || that.connectionStopped) {
+ connection.log("WARNING! " + transport.name + " transport cannot be started. Initialization ongoing or completed.");
+ return;
+ }
+
+ connection.log(transport.name + " transport starting.");
+
+ transport.start(connection, function () {
+ if (!failCalled) {
+ that.initReceived(transport, onSuccess);
+ }
+ }, function (error) {
+ // Don't allow the same transport to cause onFallback to be called twice
+ if (!failCalled) {
+ failCalled = true;
+ that.transportFailed(transport, error, onFallback);
+ }
+
+ // Returns true if the transport should stop;
+ // false if it should attempt to reconnect
+ return !that.startCompleted || that.connectionStopped;
+ });
+
+ that.transportTimeoutHandle = window.setTimeout(function () {
+ if (!failCalled) {
+ failCalled = true;
+ connection.log(transport.name + " transport timed out when trying to connect.");
+ that.transportFailed(transport, undefined, onFallback);
+ }
+ }, connection._.totalTransportConnectTimeout);
+ },
+
+ stop: function () {
+ this.connectionStopped = true;
+ window.clearTimeout(this.transportTimeoutHandle);
+ signalR.transports._logic.tryAbortStartRequest(this.connection);
+ },
+
+ initReceived: function (transport, onSuccess) {
+ var that = this,
+ connection = that.connection;
+
+ if (that.startRequested) {
+ connection.log("WARNING! The client received multiple init messages.");
+ return;
+ }
+
+ if (that.connectionStopped) {
+ return;
+ }
+
+ that.startRequested = true;
+ window.clearTimeout(that.transportTimeoutHandle);
+
+ connection.log(transport.name + " transport connected. Initiating start request.");
+ signalR.transports._logic.ajaxStart(connection, function () {
+ that.startCompleted = true;
+ onSuccess();
+ });
+ },
+
+ transportFailed: function (transport, error, onFallback) {
+ var connection = this.connection,
+ deferred = connection._deferral,
+ wrappedError;
+
+ if (this.connectionStopped) {
+ return;
+ }
+
+ window.clearTimeout(this.transportTimeoutHandle);
+
+ if (!this.startRequested) {
+ transport.stop(connection);
+
+ connection.log(transport.name + " transport failed to connect. Attempting to fall back.");
+ onFallback();
+ } else if (!this.startCompleted) {
+ // Do not attempt to fall back if a start request is ongoing during a transport failure.
+ // Instead, trigger an error and stop the connection.
+ wrappedError = signalR._.error(signalR.resources.errorDuringStartRequest, error);
+
+ connection.log(transport.name + " transport failed during the start request. Stopping the connection.");
+ $(connection).triggerHandler(events.onError, [wrappedError]);
+ if (deferred) {
+ deferred.reject(wrappedError);
+ }
+
+ connection.stop();
+ } else {
+ // The start request has completed, but the connection has not stopped.
+ // No need to do anything here. The transport should attempt its normal reconnect logic.
+ }
+ }
+ };
+
+ transportLogic = signalR.transports._logic = {
+ ajax: function (connection, options) {
+ return $.ajax(
+ $.extend(/*deep copy*/ true, {}, $.signalR.ajaxDefaults, {
+ type: "GET",
+ data: {},
+ xhrFields: { withCredentials: connection.withCredentials },
+ contentType: connection.contentType,
+ dataType: connection.ajaxDataType
+ }, options));
+ },
+
+ pingServer: function (connection) {
+ /// Pings the server
+ /// Connection associated with the server ping
+ ///
+ var url,
+ xhr,
+ deferral = $.Deferred();
+
+ if (connection.transport) {
+ url = connection.url + "/ping";
+
+ url = transportLogic.addQs(url, connection.qs);
+
+ xhr = transportLogic.ajax(connection, {
+ url: url,
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ success: function (result) {
+ var data;
+
+ try {
+ data = connection._parseResponse(result);
+ }
+ catch (error) {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.pingServerFailedParse,
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ connection.stop();
+ return;
+ }
+
+ if (data.Response === "pong") {
+ deferral.resolve();
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR._.format(signalR.resources.pingServerFailedInvalidResponse, result),
+ connection.transport,
+ null /* error */,
+ xhr
+ )
+ );
+ }
+ },
+ error: function (error) {
+ if (error.status === 401 || error.status === 403) {
+ deferral.reject(
+ signalR._.transportError(
+ signalR._.format(signalR.resources.pingServerFailedStatusCode, error.status),
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ connection.stop();
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.pingServerFailed,
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ }
+ }
+ });
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.noConnectionTransport,
+ connection.transport
+ )
+ );
+ }
+
+ return deferral.promise();
+ },
+
+ prepareQueryString: function (connection, url) {
+ var preparedUrl;
+
+ // Use addQs to start since it handles the ?/& prefix for us
+ preparedUrl = transportLogic.addQs(url, "clientProtocol=" + connection.clientProtocol);
+
+ if (typeof (connection._.redirectQs) === "string") {
+ // Add the redirect-specified query string params if any
+ preparedUrl = transportLogic.addQs(preparedUrl, connection._.redirectQs);
+ } else {
+ // Otherwise, add the user-specified query string params if any
+ preparedUrl = transportLogic.addQs(preparedUrl, connection.qs);
+ }
+
+ if (connection.token) {
+ preparedUrl += "&connectionToken=" + window.encodeURIComponent(connection.token);
+ }
+
+ if (connection.data) {
+ preparedUrl += "&connectionData=" + window.encodeURIComponent(connection.data);
+ }
+
+ return preparedUrl;
+ },
+
+ addQs: function (url, qs) {
+ var appender = url.indexOf("?") !== -1 ? "&" : "?",
+ firstChar;
+
+ if (!qs) {
+ return url;
+ }
+
+ if (typeof (qs) === "object") {
+ return url + appender + $.param(qs);
+ }
+
+ if (typeof (qs) === "string") {
+ firstChar = qs.charAt(0);
+
+ if (firstChar === "?" || firstChar === "&") {
+ appender = "";
+ }
+
+ return url + appender + qs;
+ }
+
+ throw new Error("Query string property must be either a string or object.");
+ },
+
+ // BUG #2953: The url needs to be same otherwise it will cause a memory leak
+ getUrl: function (connection, transport, reconnecting, poll, ajaxPost) {
+ /// Gets the url for making a GET based connect request
+ var baseUrl = transport === "webSockets" ? "" : connection.baseUrl,
+ url = baseUrl + connection.appRelativeUrl,
+ qs = "transport=" + transport;
+
+ if (!ajaxPost && connection.groupsToken) {
+ qs += "&groupsToken=" + window.encodeURIComponent(connection.groupsToken);
+ }
+
+ if (!reconnecting) {
+ url += "/connect";
+ } else {
+ if (poll) {
+ // longPolling transport specific
+ url += "/poll";
+ } else {
+ url += "/reconnect";
+ }
+
+ if (!ajaxPost && connection.messageId) {
+ qs += "&messageId=" + window.encodeURIComponent(connection.messageId);
+ }
+ }
+ url += "?" + qs;
+ url = transportLogic.prepareQueryString(connection, url);
+
+ // With sse or ws, access_token in request header is not supported
+ if (connection.transport && connection.accessToken) {
+ if (connection.transport.name === "serverSentEvents" || connection.transport.name === "webSockets") {
+ url += "&access_token=" + window.encodeURIComponent(connection.accessToken);
+ }
+ }
+
+ if (!ajaxPost) {
+ url += "&tid=" + Math.floor(Math.random() * 11);
+ }
+
+ return url;
+ },
+
+ maximizePersistentResponse: function (minPersistentResponse) {
+ return {
+ MessageId: minPersistentResponse.C,
+ Messages: minPersistentResponse.M,
+ Initialized: typeof (minPersistentResponse.S) !== "undefined" ? true : false,
+ ShouldReconnect: typeof (minPersistentResponse.T) !== "undefined" ? true : false,
+ LongPollDelay: minPersistentResponse.L,
+ GroupsToken: minPersistentResponse.G,
+ Error: minPersistentResponse.E
+ };
+ },
+
+ updateGroups: function (connection, groupsToken) {
+ if (groupsToken) {
+ connection.groupsToken = groupsToken;
+ }
+ },
+
+ stringifySend: function (connection, message) {
+ if (typeof (message) === "string" || typeof (message) === "undefined" || message == undefined) {
+ return message;
+ }
+ return connection.json.stringify(message);
+ },
+
+ ajaxSend: function (connection, data) {
+ var payload = transportLogic.stringifySend(connection, data),
+ url = getAjaxUrl(connection, "/send"),
+ xhr,
+ onFail = function (error, connection) {
+ $(connection).triggerHandler(events.onError, [signalR._.transportError(signalR.resources.sendFailed, connection.transport, error, xhr), data]);
+ };
+
+
+ xhr = transportLogic.ajax(connection, {
+ url: url,
+ type: connection.ajaxDataType === "jsonp" ? "GET" : "POST",
+ contentType: signalR._.defaultContentType,
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ data: {
+ data: payload
+ },
+ success: function (result) {
+ var res;
+
+ if (result) {
+ try {
+ res = connection._parseResponse(result);
+ }
+ catch (error) {
+ onFail(error, connection);
+ connection.stop();
+ return;
+ }
+
+ transportLogic.triggerReceived(connection, res);
+ }
+ },
+ error: function (error, textStatus) {
+ if (textStatus === "abort" || textStatus === "parsererror") {
+ // The parsererror happens for sends that don't return any data, and hence
+ // don't write the jsonp callback to the response. This is harder to fix on the server
+ // so just hack around it on the client for now.
+ return;
+ }
+
+ onFail(error, connection);
+ }
+ });
+
+ return xhr;
+ },
+
+ ajaxAbort: function (connection, async) {
+ if (typeof (connection.transport) === "undefined") {
+ return;
+ }
+
+ // Async by default unless explicitly overidden
+ async = typeof async === "undefined" ? true : async;
+
+ var url = getAjaxUrl(connection, "/abort");
+
+ var requestHeaders = connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {};
+
+ //option #1 - send "fetch" with keepalive
+ if (window.fetch) {
+ // use the fetch API with keepalive
+ window.fetch(url, {
+ method: "POST",
+ keepalive: true,
+ headers: requestHeaders,
+ credentials: connection.withCredentials === true ? "include" : "same-origin"
+ });
+ }
+ else {
+ // fetch is not available - fallback to $.ajax
+ transportLogic.ajax(connection, {
+ url: url,
+ async: async,
+ timeout: 1000,
+ type: "POST",
+ headers: requestHeaders,
+ dataType: "text" // We don't want to use JSONP here even when JSONP is enabled
+ });
+ }
+
+ connection.log("Fired ajax abort async = " + async + ".");
+ },
+
+ ajaxStart: function (connection, onSuccess) {
+ var rejectDeferred = function (error) {
+ var deferred = connection._deferral;
+ if (deferred) {
+ deferred.reject(error);
+ }
+ },
+ triggerStartError = function (error) {
+ connection.log("The start request failed. Stopping the connection.");
+ $(connection).triggerHandler(events.onError, [error]);
+ rejectDeferred(error);
+ connection.stop();
+ };
+
+ connection._.startRequest = transportLogic.ajax(connection, {
+ url: getAjaxUrl(connection, "/start"),
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ success: function (result, statusText, xhr) {
+ var data;
+
+ try {
+ data = connection._parseResponse(result);
+ } catch (error) {
+ triggerStartError(signalR._.error(
+ signalR._.format(signalR.resources.errorParsingStartResponse, result),
+ error, xhr));
+ return;
+ }
+
+ if (data.Response === "started") {
+ onSuccess();
+ } else {
+ triggerStartError(signalR._.error(
+ signalR._.format(signalR.resources.invalidStartResponse, result),
+ null /* error */, xhr));
+ }
+ },
+ error: function (xhr, statusText, error) {
+ if (statusText !== startAbortText) {
+ triggerStartError(signalR._.error(
+ signalR.resources.errorDuringStartRequest,
+ error, xhr));
+ } else {
+ // Stop has been called, no need to trigger the error handler
+ // or stop the connection again with onStartError
+ connection.log("The start request aborted because connection.stop() was called.");
+ rejectDeferred(signalR._.error(
+ signalR.resources.stoppedDuringStartRequest,
+ null /* error */, xhr));
+ }
+ }
+ });
+ },
+
+ tryAbortStartRequest: function (connection) {
+ if (connection._.startRequest) {
+ // If the start request has already completed this will noop.
+ connection._.startRequest.abort(startAbortText);
+ delete connection._.startRequest;
+ }
+ },
+
+ tryInitialize: function (connection, persistentResponse, onInitialized) {
+ if (persistentResponse.Initialized && onInitialized) {
+ onInitialized();
+ } else if (persistentResponse.Initialized) {
+ connection.log("WARNING! The client received an init message after reconnecting.");
+ }
+
+ },
+
+ triggerReceived: function (connection, data) {
+ if (!connection._.connectingMessageBuffer.tryBuffer(data)) {
+ $(connection).triggerHandler(events.onReceived, [data]);
+ }
+ },
+
+ processMessages: function (connection, minData, onInitialized) {
+ var data;
+
+ if(minData && (typeof minData.I !== "undefined")) {
+ // This is a response to a message the client sent
+ transportLogic.triggerReceived(connection, minData);
+ return;
+ }
+
+ // Update the last message time stamp
+ transportLogic.markLastMessage(connection);
+
+ if (minData) {
+ // This is a message send directly to the client
+ data = transportLogic.maximizePersistentResponse(minData);
+
+ if (data.Error) {
+ // This is a global error, stop the connection.
+ connection.log("Received an error message from the server: " + minData.E);
+ $(connection).triggerHandler(signalR.events.onError, [signalR._.error(minData.E, /* source */ "ServerError")]);
+ connection.stop(/* async */ false, /* notifyServer */ false);
+ return;
+ }
+
+ transportLogic.updateGroups(connection, data.GroupsToken);
+
+ if (data.MessageId) {
+ connection.messageId = data.MessageId;
+ }
+
+ if (data.Messages) {
+ $.each(data.Messages, function (index, message) {
+ transportLogic.triggerReceived(connection, message);
+ });
+
+ transportLogic.tryInitialize(connection, data, onInitialized);
+ }
+ }
+ },
+
+ monitorKeepAlive: function (connection) {
+ var keepAliveData = connection._.keepAliveData;
+
+ // If we haven't initiated the keep alive timeouts then we need to
+ if (!keepAliveData.monitoring) {
+ keepAliveData.monitoring = true;
+
+ transportLogic.markLastMessage(connection);
+
+ // Save the function so we can unbind it on stop
+ connection._.keepAliveData.reconnectKeepAliveUpdate = function () {
+ // Mark a new message so that keep alive doesn't time out connections
+ transportLogic.markLastMessage(connection);
+ };
+
+ // Update Keep alive on reconnect
+ $(connection).bind(events.onReconnect, connection._.keepAliveData.reconnectKeepAliveUpdate);
+
+ connection.log("Now monitoring keep alive with a warning timeout of " + keepAliveData.timeoutWarning + ", keep alive timeout of " + keepAliveData.timeout + " and disconnecting timeout of " + connection.disconnectTimeout);
+ } else {
+ connection.log("Tried to monitor keep alive but it's already being monitored.");
+ }
+ },
+
+ stopMonitoringKeepAlive: function (connection) {
+ var keepAliveData = connection._.keepAliveData;
+
+ // Only attempt to stop the keep alive monitoring if its being monitored
+ if (keepAliveData.monitoring) {
+ // Stop monitoring
+ keepAliveData.monitoring = false;
+
+ // Remove the updateKeepAlive function from the reconnect event
+ $(connection).unbind(events.onReconnect, connection._.keepAliveData.reconnectKeepAliveUpdate);
+
+ // Clear all the keep alive data
+ connection._.keepAliveData = {};
+ connection.log("Stopping the monitoring of the keep alive.");
+ }
+ },
+
+ startHeartbeat: function (connection) {
+ connection._.lastActiveAt = new Date().getTime();
+ beat(connection);
+ },
+
+ markLastMessage: function (connection) {
+ connection._.lastMessageAt = new Date().getTime();
+ connection._.lastActiveAt = connection._.lastMessageAt;
+ },
+
+ markActive: function (connection) {
+ if (transportLogic.verifyLastActive(connection)) {
+ connection._.lastActiveAt = new Date().getTime();
+ return true;
+ }
+
+ return false;
+ },
+
+ isConnectedOrReconnecting: function (connection) {
+ return connection.state === signalR.connectionState.connected ||
+ connection.state === signalR.connectionState.reconnecting;
+ },
+
+ ensureReconnectingState: function (connection) {
+ if (changeState(connection,
+ signalR.connectionState.connected,
+ signalR.connectionState.reconnecting) === true) {
+ $(connection).triggerHandler(events.onReconnecting);
+ }
+ return connection.state === signalR.connectionState.reconnecting;
+ },
+
+ clearReconnectTimeout: function (connection) {
+ if (connection && connection._.reconnectTimeout) {
+ window.clearTimeout(connection._.reconnectTimeout);
+ delete connection._.reconnectTimeout;
+ }
+ },
+
+ verifyLastActive: function (connection) {
+ // If there is no keep alive configured, we cannot assume that timer callbacks will
+ // run frequently enough to keep lastActiveAt updated.
+ // https://github.com/SignalR/SignalR/issues/4536
+ if (!connection._.keepAliveData.activated ||
+ new Date().getTime() - connection._.lastActiveAt < connection.reconnectWindow) {
+ return true;
+ }
+
+ var message = signalR._.format(signalR.resources.reconnectWindowTimeout, new Date(connection._.lastActiveAt), connection.reconnectWindow);
+ connection.log(message);
+ $(connection).triggerHandler(events.onError, [signalR._.error(message, /* source */ "TimeoutException")]);
+ connection.stop(/* async */ false, /* notifyServer */ false);
+ return false;
+ },
+
+ reconnect: function (connection, transportName) {
+ var transport = signalR.transports[transportName];
+
+ // We should only set a reconnectTimeout if we are currently connected
+ // and a reconnectTimeout isn't already set.
+ if (transportLogic.isConnectedOrReconnecting(connection) && !connection._.reconnectTimeout) {
+ // Need to verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ connection._.reconnectTimeout = window.setTimeout(function () {
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ transport.stop(connection);
+
+ if (transportLogic.ensureReconnectingState(connection)) {
+ connection.log(transportName + " reconnecting.");
+ transport.start(connection);
+ }
+ }, connection.reconnectDelay);
+ }
+ },
+
+ handleParseFailure: function (connection, result, error, onFailed, context) {
+ var wrappedError = signalR._.transportError(
+ signalR._.format(signalR.resources.parseFailed, result),
+ connection.transport,
+ error,
+ context);
+
+ // If we're in the initialization phase trigger onFailed, otherwise stop the connection.
+ if (onFailed && onFailed(wrappedError)) {
+ connection.log("Failed to parse server response while attempting to connect.");
+ } else {
+ $(connection).triggerHandler(events.onError, [wrappedError]);
+ connection.stop();
+ }
+ },
+
+ initHandler: function (connection) {
+ return new InitHandler(connection);
+ },
+
+ foreverFrame: {
+ count: 0,
+ connections: {}
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.webSockets.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic;
+
+ signalR.transports.webSockets = {
+ name: "webSockets",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ send: function (connection, data) {
+ var payload = transportLogic.stringifySend(connection, data);
+
+ try {
+ connection.socket.send(payload);
+ } catch (ex) {
+ $(connection).triggerHandler(events.onError,
+ [signalR._.transportError(
+ signalR.resources.webSocketsInvalidState,
+ connection.transport,
+ ex,
+ connection.socket
+ ),
+ data]);
+ }
+ },
+
+ start: function (connection, onSuccess, onFailed) {
+ var url,
+ opened = false,
+ that = this,
+ reconnecting = !onSuccess,
+ $connection = $(connection);
+
+ if (!window.WebSocket) {
+ onFailed();
+ return;
+ }
+
+ if (!connection.socket) {
+ if (connection.webSocketServerUrl) {
+ url = connection.webSocketServerUrl;
+ } else {
+ url = connection.wsProtocol + connection.host;
+ }
+
+ url += transportLogic.getUrl(connection, this.name, reconnecting);
+
+ connection.log("Connecting to websocket endpoint '" + url + "'.");
+ connection.socket = new window.WebSocket(url);
+
+ connection.socket.onopen = function () {
+ opened = true;
+ connection.log("Websocket opened.");
+
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ $connection.triggerHandler(events.onReconnect);
+ }
+ };
+
+ connection.socket.onclose = function (event) {
+ var error;
+
+ // Only handle a socket close if the close is from the current socket.
+ // Sometimes on disconnect the server will push down an onclose event
+ // to an expired socket.
+
+ if (this === connection.socket) {
+ if (opened && typeof event.wasClean !== "undefined" && event.wasClean === false) {
+ // Ideally this would use the websocket.onerror handler (rather than checking wasClean in onclose) but
+ // I found in some circumstances Chrome won't call onerror. This implementation seems to work on all browsers.
+ error = signalR._.transportError(
+ signalR.resources.webSocketClosed,
+ connection.transport,
+ event);
+
+ connection.log("Unclean disconnect from websocket: " + (event.reason || "[no reason given]."));
+ } else {
+ connection.log("Websocket closed.");
+ }
+
+ if (!onFailed || !onFailed(error)) {
+ if (error) {
+ $(connection).triggerHandler(events.onError, [error]);
+ }
+
+ that.reconnect(connection);
+ }
+ }
+ };
+
+ connection.socket.onmessage = function (event) {
+ var data;
+
+ try {
+ data = connection._parseResponse(event.data);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(connection, event.data, error, onFailed, event);
+ return;
+ }
+
+ if (data) {
+ transportLogic.processMessages(connection, data, onSuccess);
+ }
+ };
+ }
+ },
+
+ reconnect: function (connection) {
+ transportLogic.reconnect(connection, this.name);
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ stop: function (connection) {
+ // Don't trigger a reconnect after stopping
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (connection.socket) {
+ connection.log("Closing the Websocket.");
+ connection.socket.close();
+ connection.socket = null;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.serverSentEvents.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic,
+ clearReconnectAttemptTimeout = function (connection) {
+ window.clearTimeout(connection._.reconnectAttemptTimeoutHandle);
+ delete connection._.reconnectAttemptTimeoutHandle;
+ };
+
+ signalR.transports.serverSentEvents = {
+ name: "serverSentEvents",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ timeOut: 3000,
+
+ start: function (connection, onSuccess, onFailed) {
+ var that = this,
+ opened = false,
+ $connection = $(connection),
+ reconnecting = !onSuccess,
+ url;
+
+ if (connection.eventSource) {
+ connection.log("The connection already has an event source. Stopping it.");
+ connection.stop();
+ }
+
+ if (!window.EventSource) {
+ if (onFailed) {
+ connection.log("This browser doesn't support SSE.");
+ onFailed();
+ }
+ return;
+ }
+
+ url = transportLogic.getUrl(connection, this.name, reconnecting);
+
+ try {
+ connection.log("Attempting to connect to SSE endpoint '" + url + "'.");
+ connection.eventSource = new window.EventSource(url, { withCredentials: connection.withCredentials });
+ }
+ catch (e) {
+ connection.log("EventSource failed trying to connect with error " + e.Message + ".");
+ if (onFailed) {
+ // The connection failed, call the failed callback
+ onFailed();
+ } else {
+ $connection.triggerHandler(events.onError, [signalR._.transportError(signalR.resources.eventSourceFailedToConnect, connection.transport, e)]);
+ if (reconnecting) {
+ // If we were reconnecting, rather than doing initial connect, then try reconnect again
+ that.reconnect(connection);
+ }
+ }
+ return;
+ }
+
+ if (reconnecting) {
+ connection._.reconnectAttemptTimeoutHandle = window.setTimeout(function () {
+ if (opened === false) {
+ // If we're reconnecting and the event source is attempting to connect,
+ // don't keep retrying. This causes duplicate connections to spawn.
+ if (connection.eventSource.readyState !== window.EventSource.OPEN) {
+ // If we were reconnecting, rather than doing initial connect, then try reconnect again
+ that.reconnect(connection);
+ }
+ }
+ },
+ that.timeOut);
+ }
+
+ connection.eventSource.addEventListener("open", function (e) {
+ connection.log("EventSource connected.");
+
+ clearReconnectAttemptTimeout(connection);
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (opened === false) {
+ opened = true;
+
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ $connection.triggerHandler(events.onReconnect);
+ }
+ }
+ }, false);
+
+ connection.eventSource.addEventListener("message", function (e) {
+ var res;
+
+ // process messages
+ if (e.data === "initialized") {
+ return;
+ }
+
+ try {
+ res = connection._parseResponse(e.data);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(connection, e.data, error, onFailed, e);
+ return;
+ }
+
+ transportLogic.processMessages(connection, res, onSuccess);
+ }, false);
+
+ connection.eventSource.addEventListener("error", function (e) {
+ var error = signalR._.transportError(
+ signalR.resources.eventSourceError,
+ connection.transport,
+ e);
+
+ // Only handle an error if the error is from the current Event Source.
+ // Sometimes on disconnect the server will push down an error event
+ // to an expired Event Source.
+ if (this !== connection.eventSource) {
+ return;
+ }
+
+ if (onFailed && onFailed(error)) {
+ return;
+ }
+
+ connection.log("EventSource readyState: " + connection.eventSource.readyState + ".");
+
+ if (e.eventPhase === window.EventSource.CLOSED) {
+ // We don't use the EventSource's native reconnect function as it
+ // doesn't allow us to change the URL when reconnecting. We need
+ // to change the URL to not include the /connect suffix, and pass
+ // the last message id we received.
+ connection.log("EventSource reconnecting due to the server connection ending.");
+ that.reconnect(connection);
+ } else {
+ // connection error
+ connection.log("EventSource error.");
+ $connection.triggerHandler(events.onError, [error]);
+ }
+ }, false);
+ },
+
+ reconnect: function (connection) {
+ transportLogic.reconnect(connection, this.name);
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ stop: function (connection) {
+ // Don't trigger a reconnect after stopping
+ clearReconnectAttemptTimeout(connection);
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (connection && connection.eventSource) {
+ connection.log("EventSource calling close().");
+ connection.eventSource.close();
+ connection.eventSource = null;
+ delete connection.eventSource;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.foreverFrame.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic,
+ createFrame = function () {
+ var frame = window.document.createElement("iframe");
+ frame.setAttribute("style", "position:absolute;top:0;left:0;width:0;height:0;visibility:hidden;");
+ return frame;
+ },
+ // Used to prevent infinite loading icon spins in older versions of ie
+ // We build this object inside a closure so we don't pollute the rest of
+ // the foreverFrame transport with unnecessary functions/utilities.
+ loadPreventer = (function () {
+ var loadingFixIntervalId = null,
+ loadingFixInterval = 1000,
+ attachedTo = 0;
+
+ return {
+ prevent: function () {
+ // Prevent additional iframe removal procedures from newer browsers
+ if (signalR._.ieVersion <= 8) {
+ // We only ever want to set the interval one time, so on the first attachedTo
+ if (attachedTo === 0) {
+ // Create and destroy iframe every 3 seconds to prevent loading icon, super hacky
+ loadingFixIntervalId = window.setInterval(function () {
+ var tempFrame = createFrame();
+
+ window.document.body.appendChild(tempFrame);
+ window.document.body.removeChild(tempFrame);
+
+ tempFrame = null;
+ }, loadingFixInterval);
+ }
+
+ attachedTo++;
+ }
+ },
+ cancel: function () {
+ // Only clear the interval if there's only one more object that the loadPreventer is attachedTo
+ if (attachedTo === 1) {
+ window.clearInterval(loadingFixIntervalId);
+ }
+
+ if (attachedTo > 0) {
+ attachedTo--;
+ }
+ }
+ };
+ })();
+
+ signalR.transports.foreverFrame = {
+ name: "foreverFrame",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ // Added as a value here so we can create tests to verify functionality
+ iframeClearThreshold: 50,
+
+ start: function (connection, onSuccess, onFailed) {
+ if (connection.accessToken) {
+ if (onFailed) {
+ connection.log("Forever Frame does not support connections that require a Bearer token to connect, such as the Azure SignalR Service.");
+ onFailed();
+ }
+ return;
+ }
+
+ var that = this,
+ frameId = (transportLogic.foreverFrame.count += 1),
+ url,
+ frame = createFrame(),
+ frameLoadHandler = function () {
+ connection.log("Forever frame iframe finished loading and is no longer receiving messages.");
+ if (!onFailed || !onFailed()) {
+ that.reconnect(connection);
+ }
+ };
+
+ if (window.EventSource) {
+ // If the browser supports SSE, don't use Forever Frame
+ if (onFailed) {
+ connection.log("Forever Frame is not supported by SignalR on browsers with SSE support.");
+ onFailed();
+ }
+ return;
+ }
+
+ frame.setAttribute("data-signalr-connection-id", connection.id);
+
+ // Start preventing loading icon
+ // This will only perform work if the loadPreventer is not attached to another connection.
+ loadPreventer.prevent();
+
+ // Build the url
+ url = transportLogic.getUrl(connection, this.name);
+ url += "&frameId=" + frameId;
+
+ // add frame to the document prior to setting URL to avoid caching issues.
+ window.document.documentElement.appendChild(frame);
+
+ connection.log("Binding to iframe's load event.");
+
+ if (frame.addEventListener) {
+ frame.addEventListener("load", frameLoadHandler, false);
+ } else if (frame.attachEvent) {
+ frame.attachEvent("onload", frameLoadHandler);
+ }
+
+ frame.src = url;
+ transportLogic.foreverFrame.connections[frameId] = connection;
+
+ connection.frame = frame;
+ connection.frameId = frameId;
+
+ if (onSuccess) {
+ connection.onSuccess = function () {
+ connection.log("Iframe transport started.");
+ onSuccess();
+ };
+ }
+ },
+
+ reconnect: function (connection) {
+ var that = this;
+
+ // Need to verify connection state and verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
+ if (transportLogic.isConnectedOrReconnecting(connection) && transportLogic.verifyLastActive(connection)) {
+ window.setTimeout(function () {
+ // Verify that we're ok to reconnect.
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ if (connection.frame && transportLogic.ensureReconnectingState(connection)) {
+ var frame = connection.frame,
+ src = transportLogic.getUrl(connection, that.name, true) + "&frameId=" + connection.frameId;
+ connection.log("Updating iframe src to '" + src + "'.");
+ frame.src = src;
+ }
+ }, connection.reconnectDelay);
+ }
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ receive: function (connection, data) {
+ var cw,
+ body,
+ response;
+
+ if (connection.json !== connection._originalJson) {
+ // If there's a custom JSON parser configured then serialize the object
+ // using the original (browser) JSON parser and then deserialize it using
+ // the custom parser (connection._parseResponse does that). This is so we
+ // can easily send the response from the server as "raw" JSON but still
+ // support custom JSON deserialization in the browser.
+ data = connection._originalJson.stringify(data);
+ }
+
+ response = connection._parseResponse(data);
+
+ transportLogic.processMessages(connection, response, connection.onSuccess);
+
+ // Protect against connection stopping from a callback trigger within the processMessages above.
+ if (connection.state === $.signalR.connectionState.connected) {
+ // Delete the script & div elements
+ connection.frameMessageCount = (connection.frameMessageCount || 0) + 1;
+ if (connection.frameMessageCount > signalR.transports.foreverFrame.iframeClearThreshold) {
+ connection.frameMessageCount = 0;
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw && cw.document && cw.document.body) {
+ body = cw.document.body;
+
+ // Remove all the child elements from the iframe's body to conserver memory
+ while (body.firstChild) {
+ body.removeChild(body.firstChild);
+ }
+ }
+ }
+ }
+ },
+
+ stop: function (connection) {
+ var cw = null;
+
+ // Stop attempting to prevent loading icon
+ loadPreventer.cancel();
+
+ if (connection.frame) {
+ if (connection.frame.stop) {
+ connection.frame.stop();
+ } else {
+ try {
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw.document && cw.document.execCommand) {
+ cw.document.execCommand("Stop");
+ }
+ }
+ catch (e) {
+ connection.log("Error occurred when stopping foreverFrame transport. Message = " + e.message + ".");
+ }
+ }
+
+ // Ensure the iframe is where we left it
+ if (connection.frame.parentNode === window.document.documentElement) {
+ window.document.documentElement.removeChild(connection.frame);
+ }
+
+ delete transportLogic.foreverFrame.connections[connection.frameId];
+ connection.frame = null;
+ connection.frameId = null;
+ delete connection.frame;
+ delete connection.frameId;
+ delete connection.onSuccess;
+ delete connection.frameMessageCount;
+ connection.log("Stopping forever frame.");
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ },
+
+ getConnection: function (id) {
+ return transportLogic.foreverFrame.connections[id];
+ },
+
+ started: function (connection) {
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+
+ $(connection).triggerHandler(events.onReconnect);
+ }
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.longPolling.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ isDisconnecting = $.signalR.isDisconnecting,
+ transportLogic = signalR.transports._logic;
+
+ signalR.transports.longPolling = {
+ name: "longPolling",
+
+ supportsKeepAlive: function () {
+ return false;
+ },
+
+ reconnectDelay: 3000,
+
+ start: function (connection, onSuccess, onFailed) {
+ /// Starts the long polling connection
+ /// The SignalR connection to start
+ var that = this,
+ fireConnect = function () {
+ fireConnect = $.noop;
+
+ connection.log("LongPolling connected.");
+
+ if (onSuccess) {
+ onSuccess();
+ } else {
+ connection.log("WARNING! The client received an init message after reconnecting.");
+ }
+ },
+ tryFailConnect = function (error) {
+ if (onFailed(error)) {
+ connection.log("LongPolling failed to connect.");
+ return true;
+ }
+
+ return false;
+ },
+ privateData = connection._,
+ reconnectErrors = 0,
+ fireReconnected = function (instance) {
+ window.clearTimeout(privateData.reconnectTimeoutId);
+ privateData.reconnectTimeoutId = null;
+
+ if (changeState(instance,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ // Successfully reconnected!
+ instance.log("Raising the reconnect event");
+ $(instance).triggerHandler(events.onReconnect);
+ }
+ },
+ // 1 hour
+ maxFireReconnectedTimeout = 3600000;
+
+ if (connection.pollXhr) {
+ connection.log("Polling xhr requests already exists, aborting.");
+ connection.stop();
+ }
+
+ connection.messageId = null;
+
+ privateData.reconnectTimeoutId = null;
+
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ (function poll(instance, raiseReconnect) {
+ var messageId = instance.messageId,
+ connect = (messageId == undefined),
+ reconnecting = !connect,
+ polling = !raiseReconnect,
+ url = transportLogic.getUrl(instance, that.name, reconnecting, polling, true /* use Post for longPolling */),
+ postData = {};
+
+ if (instance.messageId) {
+ postData.messageId = instance.messageId;
+ }
+
+ if (instance.groupsToken) {
+ postData.groupsToken = instance.groupsToken;
+ }
+
+ // If we've disconnected during the time we've tried to re-instantiate the poll then stop.
+ if (isDisconnecting(instance) === true) {
+ return;
+ }
+
+ connection.log("Opening long polling request to '" + url + "'.");
+ instance.pollXhr = transportLogic.ajax(connection, {
+ xhrFields: {
+ onprogress: function () {
+ transportLogic.markLastMessage(connection);
+ }
+ },
+ url: url,
+ type: "POST",
+ contentType: signalR._.defaultContentType,
+ data: postData,
+ timeout: connection._.pollTimeout,
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ success: function (result) {
+ var minData,
+ delay = 0,
+ data,
+ shouldReconnect;
+
+ connection.log("Long poll complete.");
+
+ // Reset our reconnect errors so if we transition into a reconnecting state again we trigger
+ // reconnected quickly
+ reconnectErrors = 0;
+
+ try {
+ // Remove any keep-alives from the beginning of the result
+ minData = connection._parseResponse(result);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(instance, result, error, tryFailConnect, instance.pollXhr);
+ return;
+ }
+
+ // If there's currently a timeout to trigger reconnect, fire it now before processing messages
+ if (privateData.reconnectTimeoutId != undefined) {
+ fireReconnected(instance);
+ }
+
+ if (minData) {
+ data = transportLogic.maximizePersistentResponse(minData);
+ }
+
+ transportLogic.processMessages(instance, minData, fireConnect);
+
+ if (data &&
+ $.type(data.LongPollDelay) === "number") {
+ delay = data.LongPollDelay;
+ }
+
+ if (isDisconnecting(instance) === true) {
+ return;
+ }
+
+ shouldReconnect = data && data.ShouldReconnect;
+ if (shouldReconnect) {
+ // Transition into the reconnecting state
+ // If this fails then that means that the user transitioned the connection into a invalid state in processMessages.
+ if (!transportLogic.ensureReconnectingState(instance)) {
+ return;
+ }
+ }
+
+ // We never want to pass a raiseReconnect flag after a successful poll. This is handled via the error function
+ if (delay > 0) {
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ poll(instance, shouldReconnect);
+ }, delay);
+ } else {
+ poll(instance, shouldReconnect);
+ }
+ },
+
+ error: function (data, textStatus) {
+ var error = signalR._.transportError(signalR.resources.longPollFailed, connection.transport, data, instance.pollXhr);
+
+ // Stop trying to trigger reconnect, connection is in an error state
+ // If we're not in the reconnect state this will noop
+ window.clearTimeout(privateData.reconnectTimeoutId);
+ privateData.reconnectTimeoutId = null;
+
+ if (textStatus === "abort") {
+ connection.log("Aborted xhr request.");
+ return;
+ }
+
+ if (!tryFailConnect(error)) {
+
+ // Increment our reconnect errors, we assume all errors to be reconnect errors
+ // In the case that it's our first error this will cause Reconnect to be fired
+ // after 1 second due to reconnectErrors being = 1.
+ reconnectErrors++;
+
+ if (connection.state !== signalR.connectionState.reconnecting) {
+ connection.log("An error occurred using longPolling. Status = " + textStatus + ". Response = " + data.responseText + ".");
+ $(instance).triggerHandler(events.onError, [error]);
+ }
+
+ // We check the state here to verify that we're not in an invalid state prior to verifying Reconnect.
+ // If we're not in connected or reconnecting then the next ensureReconnectingState check will fail and will return.
+ // Therefore we don't want to change that failure code path.
+ if ((connection.state === signalR.connectionState.connected ||
+ connection.state === signalR.connectionState.reconnecting) &&
+ !transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ // Transition into the reconnecting state
+ // If this fails then that means that the user transitioned the connection into the disconnected or connecting state within the above error handler trigger.
+ if (!transportLogic.ensureReconnectingState(instance)) {
+ return;
+ }
+
+ // Call poll with the raiseReconnect flag as true after the reconnect delay
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ poll(instance, true);
+ }, that.reconnectDelay);
+ }
+ }
+ });
+
+ // This will only ever pass after an error has occurred via the poll ajax procedure.
+ if (reconnecting && raiseReconnect === true) {
+ // We wait to reconnect depending on how many times we've failed to reconnect.
+ // This is essentially a heuristic that will exponentially increase in wait time before
+ // triggering reconnected. This depends on the "error" handler of Poll to cancel this
+ // timeout if it triggers before the Reconnected event fires.
+ // The Math.min at the end is to ensure that the reconnect timeout does not overflow.
+ privateData.reconnectTimeoutId = window.setTimeout(function () { fireReconnected(instance); }, Math.min(1000 * (Math.pow(2, reconnectErrors) - 1), maxFireReconnectedTimeout));
+ }
+ }(connection));
+ }, 250); // Have to delay initial poll so Chrome doesn't show loader spinner in tab
+ },
+
+ lostConnection: function (connection) {
+ if (connection.pollXhr) {
+ connection.pollXhr.abort("lostConnection");
+ }
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ stop: function (connection) {
+ /// Stops the long polling connection
+ /// The SignalR connection to stop
+
+ window.clearTimeout(connection._.pollTimeoutId);
+ window.clearTimeout(connection._.reconnectTimeoutId);
+
+ delete connection._.pollTimeoutId;
+ delete connection._.reconnectTimeoutId;
+
+ if (connection.pollXhr) {
+ connection.pollXhr.abort();
+ connection.pollXhr = null;
+ delete connection.pollXhr;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.hubs.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var nextGuid = 0;
+ var eventNamespace = ".hubProxy",
+ signalR = $.signalR;
+
+ function makeEventName(event) {
+ return event + eventNamespace;
+ }
+
+ // Equivalent to Array.prototype.map
+ function map(arr, fun, thisp) {
+ var i,
+ length = arr.length,
+ result = [];
+ for (i = 0; i < length; i += 1) {
+ if (arr.hasOwnProperty(i)) {
+ result[i] = fun.call(thisp, arr[i], i, arr);
+ }
+ }
+ return result;
+ }
+
+ function getArgValue(a) {
+ return $.isFunction(a) ? null : ($.type(a) === "undefined" ? null : a);
+ }
+
+ function hasMembers(obj) {
+ for (var key in obj) {
+ // If we have any properties in our callback map then we have callbacks and can exit the loop via return
+ if (obj.hasOwnProperty(key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function clearInvocationCallbacks(connection, error) {
+ ///
+ var callbacks = connection._.invocationCallbacks,
+ callback;
+
+ if (hasMembers(callbacks)) {
+ connection.log("Clearing hub invocation callbacks with error: " + error + ".");
+ }
+
+ // Reset the callback cache now as we have a local var referencing it
+ connection._.invocationCallbackId = 0;
+ delete connection._.invocationCallbacks;
+ connection._.invocationCallbacks = {};
+
+ // Loop over the callbacks and invoke them.
+ // We do this using a local var reference and *after* we've cleared the cache
+ // so that if a fail callback itself tries to invoke another method we don't
+ // end up with its callback in the list we're looping over.
+ for (var callbackId in callbacks) {
+ callback = callbacks[callbackId];
+ callback.method.call(callback.scope, { E: error });
+ }
+ }
+
+ function isCallbackFromGeneratedHubProxy(callback) {
+ // https://github.com/SignalR/SignalR/issues/4310
+ // The stringified callback from the old generated hub proxy is 137 characters in Edge, Firefox and Chrome.
+ // We slice to avoid wasting too many cycles searching through the text of a long large function.
+ return $.isFunction(callback) && callback.toString().slice(0, 256).indexOf("// Call the client hub method") >= 0;
+ }
+
+ // hubProxy
+ function hubProxy(hubConnection, hubName) {
+ ///
+ /// Creates a new proxy object for the given hub connection that can be used to invoke
+ /// methods on server hubs and handle client method invocation requests from the server.
+ ///
+ return new hubProxy.fn.init(hubConnection, hubName);
+ }
+
+ hubProxy.fn = hubProxy.prototype = {
+ init: function (connection, hubName) {
+ this.state = {};
+ this.connection = connection;
+ this.hubName = hubName;
+ this._ = {
+ callbackMap: {}
+ };
+ },
+
+ constructor: hubProxy,
+
+ hasSubscriptions: function () {
+ return hasMembers(this._.callbackMap);
+ },
+
+ on: function (eventName, callback, callbackIdentity) {
+ /// Wires up a callback to be invoked when a invocation request is received from the server hub.
+ /// The name of the hub event to register the callback for.
+ /// The callback to be invoked.
+ /// An optional object to use as the "identity" for the callback when checking if the handler has already been registered. Defaults to the value of 'callback' if not provided.
+ var that = this,
+ callbackMap = that._.callbackMap,
+ isFromOldGeneratedHubProxy = !callbackIdentity && isCallbackFromGeneratedHubProxy(callback);
+
+ // We need the third "identity" argument because the registerHubProxies call made by signalr/js wraps the user-provided callback in a custom wrapper which breaks the identity comparison.
+ // callbackIdentity allows the caller of `on` to provide a separate object to use as the "identity". `registerHubProxies` uses the original user callback as this identity object.
+ callbackIdentity = callbackIdentity || callback;
+
+ // Assign a global ID to the identity object. This tags the object so we can detect the same object when it comes back.
+ if(!callbackIdentity._signalRGuid) {
+ callbackIdentity._signalRGuid = nextGuid++;
+ }
+
+ // Normalize the event name to lowercase
+ eventName = eventName.toLowerCase();
+
+ // If there is not an event registered for this callback yet we want to create its event space in the callback map.
+ var callbackSpace = callbackMap[eventName];
+ if (!callbackSpace) {
+ callbackSpace = [];
+ callbackMap[eventName] = callbackSpace;
+ }
+
+ // Check if there's already a registration
+ var registration;
+ for (var i = 0; i < callbackSpace.length; i++) {
+ if (callbackSpace[i].guid === callbackIdentity._signalRGuid || (isFromOldGeneratedHubProxy && callbackSpace[i].isFromOldGeneratedHubProxy)) {
+ registration = callbackSpace[i];
+ }
+ }
+
+ // Create a registration if there isn't one already
+ if (!registration) {
+ registration = {
+ guid: callbackIdentity._signalRGuid,
+ eventHandlers: [],
+ isFromOldGeneratedHubProxy: isFromOldGeneratedHubProxy
+ };
+ callbackMap[eventName].push(registration);
+ }
+
+ var handler = function (e, data) {
+ callback.apply(that, data);
+ };
+ registration.eventHandlers.push(handler);
+
+ $(that).bind(makeEventName(eventName), handler);
+
+ return that;
+ },
+
+ off: function (eventName, callback, callbackIdentity) {
+ /// Removes the callback invocation request from the server hub for the given event name.
+ /// The name of the hub event to unregister the callback for.
+ /// The callback to be removed.
+ /// An optional object to use as the "identity" when looking up the callback. Corresponds to the same parameter provided to 'on'. Defaults to the value of 'callback' if not provided.
+ var that = this,
+ callbackMap = that._.callbackMap,
+ callbackSpace,
+ isFromOldGeneratedHubProxy = !callbackIdentity && isCallbackFromGeneratedHubProxy(callback);
+
+ callbackIdentity = callbackIdentity || callback;
+
+ // Normalize the event name to lowercase
+ eventName = eventName.toLowerCase();
+
+ callbackSpace = callbackMap[eventName];
+
+ // Verify that there is an event space to unbind
+ if (callbackSpace) {
+
+ if (callback) {
+ // Find the callback registration
+ var callbackRegistration;
+ var callbackIndex;
+ for (var i = 0; i < callbackSpace.length; i++) {
+ if (callbackSpace[i].guid === callbackIdentity._signalRGuid || (isFromOldGeneratedHubProxy && callbackSpace[i].isFromOldGeneratedHubProxy)) {
+ callbackIndex = i;
+ callbackRegistration = callbackSpace[i];
+ }
+ }
+
+ // Only unbind if there's an event bound with eventName and a callback with the specified callback
+ if (callbackRegistration) {
+ // Unbind all event handlers associated with the registration.
+ for (var j = 0; j < callbackRegistration.eventHandlers.length; j++) {
+ $(that).unbind(makeEventName(eventName), callbackRegistration.eventHandlers[j]);
+ }
+
+ // Remove the registration from the list
+ callbackSpace.splice(i, 1);
+
+ // Check if there are any registrations left, if not we need to destroy it.
+ if (callbackSpace.length === 0) {
+ delete callbackMap[eventName];
+ }
+ }
+ } else if (!callback) { // Check if we're removing the whole event and we didn't error because of an invalid callback
+ $(that).unbind(makeEventName(eventName));
+
+ delete callbackMap[eventName];
+ }
+ }
+
+ return that;
+ },
+
+ invoke: function (methodName) {
+ /// Invokes a server hub method with the given arguments.
+ /// The name of the server hub method.
+
+ var that = this,
+ connection = that.connection,
+ args = $.makeArray(arguments).slice(1),
+ argValues = map(args, getArgValue),
+ data = { H: that.hubName, M: methodName, A: argValues, I: connection._.invocationCallbackId },
+ d = $.Deferred(),
+ callback = function (minResult) {
+ var result = that._maximizeHubResponse(minResult),
+ source,
+ error;
+
+ // Update the hub state
+ $.extend(that.state, result.State);
+
+ if (result.Progress) {
+ if (d.notifyWith) {
+ // Progress is only supported in jQuery 1.7+
+ d.notifyWith(that, [result.Progress.Data]);
+ } else if (!connection._.progressjQueryVersionLogged) {
+ connection.log("A hub method invocation progress update was received but the version of jQuery in use (" + $.prototype.jquery + ") does not support progress updates. Upgrade to jQuery 1.7+ to receive progress notifications.");
+ connection._.progressjQueryVersionLogged = true;
+ }
+ } else if (result.Error) {
+ // Server hub method threw an exception, log it & reject the deferred
+ if (result.StackTrace) {
+ connection.log(result.Error + "\n" + result.StackTrace + ".");
+ }
+
+ // result.ErrorData is only set if a HubException was thrown
+ source = result.IsHubException ? "HubException" : "Exception";
+ error = signalR._.error(result.Error, source);
+ error.data = result.ErrorData;
+
+ connection.log(that.hubName + "." + methodName + " failed to execute. Error: " + error.message);
+ d.rejectWith(that, [error]);
+ } else {
+ // Server invocation succeeded, resolve the deferred
+ connection.log("Invoked " + that.hubName + "." + methodName);
+ d.resolveWith(that, [result.Result]);
+ }
+ };
+
+ connection._.invocationCallbacks[connection._.invocationCallbackId.toString()] = { scope: that, method: callback };
+ connection._.invocationCallbackId += 1;
+
+ if (!$.isEmptyObject(that.state)) {
+ data.S = that.state;
+ }
+
+ connection.log("Invoking " + that.hubName + "." + methodName);
+ connection.send(data);
+
+ return d.promise();
+ },
+
+ _maximizeHubResponse: function (minHubResponse) {
+ return {
+ State: minHubResponse.S,
+ Result: minHubResponse.R,
+ Progress: minHubResponse.P ? {
+ Id: minHubResponse.P.I,
+ Data: minHubResponse.P.D
+ } : null,
+ Id: minHubResponse.I,
+ IsHubException: minHubResponse.H,
+ Error: minHubResponse.E,
+ StackTrace: minHubResponse.T,
+ ErrorData: minHubResponse.D
+ };
+ }
+ };
+
+ hubProxy.fn.init.prototype = hubProxy.fn;
+
+ // hubConnection
+ function hubConnection(url, options) {
+ /// Creates a new hub connection.
+ /// [Optional] The hub route url, defaults to "/signalr".
+ /// [Optional] Settings to use when creating the hubConnection.
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ };
+
+ $.extend(settings, options);
+
+ if (!url || settings.useDefaultPath) {
+ url = (url || "") + "/signalr";
+ }
+ return new hubConnection.fn.init(url, settings);
+ }
+
+ hubConnection.fn = hubConnection.prototype = $.connection();
+
+ hubConnection.fn.init = function (url, options) {
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ },
+ connection = this;
+
+ $.extend(settings, options);
+
+ // Call the base constructor
+ $.signalR.fn.init.call(connection, url, settings.qs, settings.logging);
+
+ // Object to store hub proxies for this connection
+ connection.proxies = {};
+
+ connection._.invocationCallbackId = 0;
+ connection._.invocationCallbacks = {};
+
+ // Wire up the received handler
+ connection.received(function (minData) {
+ var data, proxy, dataCallbackId, callback, hubName, eventName;
+ if (!minData) {
+ return;
+ }
+
+ // We have to handle progress updates first in order to ensure old clients that receive
+ // progress updates enter the return value branch and then no-op when they can't find
+ // the callback in the map (because the minData.I value will not be a valid callback ID)
+ // Process progress notification
+ if (typeof (minData.P) !== "undefined") {
+ dataCallbackId = minData.P.I.toString();
+ callback = connection._.invocationCallbacks[dataCallbackId];
+ if (callback) {
+ callback.method.call(callback.scope, minData);
+ }
+ } else if (typeof (minData.I) !== "undefined") {
+ // We received the return value from a server method invocation, look up callback by id and call it
+ dataCallbackId = minData.I.toString();
+ callback = connection._.invocationCallbacks[dataCallbackId];
+ if (callback) {
+ // Delete the callback from the proxy
+ connection._.invocationCallbacks[dataCallbackId] = null;
+ delete connection._.invocationCallbacks[dataCallbackId];
+
+ // Invoke the callback
+ callback.method.call(callback.scope, minData);
+ }
+ } else {
+ data = this._maximizeClientHubInvocation(minData);
+
+ // We received a client invocation request, i.e. broadcast from server hub
+ connection.log("Triggering client hub event '" + data.Method + "' on hub '" + data.Hub + "'.");
+
+ // Normalize the names to lowercase
+ hubName = data.Hub.toLowerCase();
+ eventName = data.Method.toLowerCase();
+
+ // Trigger the local invocation event
+ proxy = this.proxies[hubName];
+
+ // Update the hub state
+ $.extend(proxy.state, data.State);
+ $(proxy).triggerHandler(makeEventName(eventName), [data.Args]);
+ }
+ });
+
+ connection.error(function (errData, origData) {
+ var callbackId, callback;
+
+ if (!origData) {
+ // No original data passed so this is not a send error
+ return;
+ }
+
+ callbackId = origData.I;
+ callback = connection._.invocationCallbacks[callbackId];
+
+ // Verify that there is a callback bound (could have been cleared)
+ if (callback) {
+ // Delete the callback
+ connection._.invocationCallbacks[callbackId] = null;
+ delete connection._.invocationCallbacks[callbackId];
+
+ // Invoke the callback with an error to reject the promise
+ callback.method.call(callback.scope, { E: errData });
+ }
+ });
+
+ connection.reconnecting(function () {
+ if (connection.transport && connection.transport.name === "webSockets") {
+ clearInvocationCallbacks(connection, "Connection started reconnecting before invocation result was received.");
+ }
+ });
+
+ connection.disconnected(function () {
+ clearInvocationCallbacks(connection, "Connection was disconnected before invocation result was received.");
+ });
+ };
+
+ hubConnection.fn._maximizeClientHubInvocation = function (minClientHubInvocation) {
+ return {
+ Hub: minClientHubInvocation.H,
+ Method: minClientHubInvocation.M,
+ Args: minClientHubInvocation.A,
+ State: minClientHubInvocation.S
+ };
+ };
+
+ hubConnection.fn._registerSubscribedHubs = function () {
+ ///
+ /// Sets the starting event to loop through the known hubs and register any new hubs
+ /// that have been added to the proxy.
+ ///
+ var connection = this;
+
+ if (!connection._subscribedToHubs) {
+ connection._subscribedToHubs = true;
+ connection.starting(function () {
+ // Set the connection's data object with all the hub proxies with active subscriptions.
+ // These proxies will receive notifications from the server.
+ var subscribedHubs = [];
+
+ $.each(connection.proxies, function (key) {
+ if (this.hasSubscriptions()) {
+ subscribedHubs.push({ name: key });
+ connection.log("Client subscribed to hub '" + key + "'.");
+ }
+ });
+
+ if (subscribedHubs.length === 0) {
+ connection.log("No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.");
+ }
+
+ connection.data = connection.json.stringify(subscribedHubs);
+ });
+ }
+ };
+
+ hubConnection.fn.createHubProxy = function (hubName) {
+ ///
+ /// Creates a new proxy object for the given hub connection that can be used to invoke
+ /// methods on server hubs and handle client method invocation requests from the server.
+ ///
+ ///
+ /// The name of the hub on the server to create the proxy for.
+ ///
+
+ // Normalize the name to lowercase
+ hubName = hubName.toLowerCase();
+
+ var proxy = this.proxies[hubName];
+ if (!proxy) {
+ proxy = hubProxy(this, hubName);
+ this.proxies[hubName] = proxy;
+ }
+
+ this._registerSubscribedHubs();
+
+ return proxy;
+ };
+
+ hubConnection.fn.init.prototype = hubConnection.fn;
+
+ $.hubConnection = hubConnection;
+
+}(window.jQuery, window));
+/* jquery.signalR.version.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+(function ($, undefined) {
+ // This will be modified by the build script
+ $.signalR.version = "2.4.3";
+}(window.jQuery));
diff --git a/Adaptation/FileHandlers/json/StaticSite/js/scripts/jquery.signalR-2.4.3.min.js b/Adaptation/FileHandlers/json/StaticSite/js/scripts/jquery.signalR-2.4.3.min.js
new file mode 100644
index 0000000..3b60a2f
--- /dev/null
+++ b/Adaptation/FileHandlers/json/StaticSite/js/scripts/jquery.signalR-2.4.3.min.js
@@ -0,0 +1,9 @@
+/*!
+ * ASP.NET SignalR JavaScript Library 2.4.3
+ * http://signalr.net/
+ *
+ * Copyright (c) .NET Foundation. All rights reserved.
+ * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+ *
+ */
+(function(n,t,i){function w(t,i){var u,f;if(n.isArray(t)){for(u=t.length-1;u>=0;u--)f=t[u],n.type(f)==="string"&&r.transports[f]||(i.log("Invalid transport: "+f+", removing it from the transports list."),t.splice(u,1));t.length===0&&(i.log("No transports remain within the specified transport array."),t=null)}else if(r.transports[t]||t==="auto"){if(t==="auto"&&r._.ieVersion<=8)return["longPolling"]}else i.log("Invalid transport: "+t.toString()+"."),t=null;return t}function b(n){return n==="http:"?80:n==="https:"?443:void 0}function a(n,t){return t.match(/:\d+$/)?t:t+":"+b(n)}function k(t,i){var u=this,r=[];u.tryBuffer=function(i){return t.state===n.signalR.connectionState.connecting?(r.push(i),!0):!1};u.drain=function(){if(t.state===n.signalR.connectionState.connected)while(r.length>0)i(r.shift())};u.clear=function(){r=[]}}var f={nojQuery:"jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.",noTransportOnInit:"No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.",errorOnNegotiate:"Error during negotiation request.",stoppedWhileLoading:"The connection was stopped during page load.",stoppedWhileNegotiating:"The connection was stopped during the negotiate request.",errorParsingNegotiateResponse:"Error parsing negotiate response.",errorRedirectionExceedsLimit:"Negotiate redirection limit exceeded.",errorDuringStartRequest:"Error during start request. Stopping the connection.",errorFromServer:"Error message received from the server: '{0}'.",stoppedDuringStartRequest:"The connection was stopped during the start request.",errorParsingStartResponse:"Error parsing start response: '{0}'. Stopping the connection.",invalidStartResponse:"Invalid start response: '{0}'. Stopping the connection.",protocolIncompatible:"You are using a version of the client that isn't compatible with the server. Client version {0}, server version {1}.",aspnetCoreSignalrServer:"Detected a connection attempt to an ASP.NET Core SignalR Server. This client only supports connecting to an ASP.NET SignalR Server. See https://aka.ms/signalr-core-differences for details.",sendFailed:"Send failed.",parseFailed:"Failed at parsing response: {0}",longPollFailed:"Long polling request failed.",eventSourceFailedToConnect:"EventSource failed to connect.",eventSourceError:"Error raised by EventSource",webSocketClosed:"WebSocket closed.",pingServerFailedInvalidResponse:"Invalid ping response when pinging server: '{0}'.",pingServerFailed:"Failed to ping server.",pingServerFailedStatusCode:"Failed to ping server. Server responded with status code {0}, stopping the connection.",pingServerFailedParse:"Failed to parse ping server response, stopping the connection.",noConnectionTransport:"Connection is in an invalid state, there is no transport active.",webSocketsInvalidState:"The Web Socket transport is in an invalid state, transitioning into reconnecting.",reconnectTimeout:"Couldn't reconnect within the configured timeout of {0} ms, disconnecting.",reconnectWindowTimeout:"The client has been inactive since {0} and it has exceeded the inactivity timeout of {1} ms. Stopping the connection.",jsonpNotSupportedWithAccessToken:"The JSONP protocol does not support connections that require a Bearer token to connect, such as the Azure SignalR Service."};if(typeof n!="function")throw new Error(f.nojQuery);var r,h,o=t.document.readyState==="complete",e=n(t),c="__Negotiate Aborted__",u={onStart:"onStart",onStarting:"onStarting",onReceived:"onReceived",onError:"onError",onConnectionSlow:"onConnectionSlow",onReconnecting:"onReconnecting",onReconnect:"onReconnect",onStateChanged:"onStateChanged",onDisconnect:"onDisconnect"},v=function(n,i){if(i!==!1){var r;typeof t.console!="undefined"&&(r="["+(new Date).toTimeString()+"] SignalR: "+n,t.console.debug?t.console.debug(r):t.console.log&&t.console.log(r))}},s=function(t,i,r){return i===t.state?(t.state=r,n(t).triggerHandler(u.onStateChanged,[{oldState:i,newState:r}]),!0):!1},y=function(n){return n.state===r.connectionState.disconnected},l=function(n){return n._.keepAliveData.activated&&n.transport.supportsKeepAlive(n)},p=function(i){var f,e;i._.configuredStopReconnectingTimeout||(e=function(t){var i=r._.format(r.resources.reconnectTimeout,t.disconnectTimeout);t.log(i);n(t).triggerHandler(u.onError,[r._.error(i,"TimeoutException")]);t.stop(!1,!1)},i.reconnecting(function(){var n=this;n.state===r.connectionState.reconnecting&&(f=t.setTimeout(function(){e(n)},n.disconnectTimeout))}),i.stateChanged(function(n){n.oldState===r.connectionState.reconnecting&&t.clearTimeout(f)}),i._.configuredStopReconnectingTimeout=!0)};if(r=function(n,t,i){return new r.fn.init(n,t,i)},r._={defaultContentType:"application/x-www-form-urlencoded; charset=UTF-8",ieVersion:function(){var i,n;return t.navigator.appName==="Microsoft Internet Explorer"&&(n=/MSIE ([0-9]+\.[0-9]+)/.exec(t.navigator.userAgent),n&&(i=t.parseFloat(n[1]))),i}(),error:function(n,t,i){var r=new Error(n);return r.source=t,typeof i!="undefined"&&(r.context=i),r},transportError:function(n,t,r,u){var f=this.error(n,r,u);return f.transport=t?t.name:i,f},format:function(){for(var t=arguments[0],n=0;n<\/script>.");}},typeof e.on=="function")e.on("load",function(){o=!0});else e.load(function(){o=!0});r.fn=r.prototype={init:function(t,i,r){var f=n(this);this.url=t;this.qs=i;this.lastError=null;this._={keepAliveData:{},connectingMessageBuffer:new k(this,function(n){f.triggerHandler(u.onReceived,[n])}),lastMessageAt:(new Date).getTime(),lastActiveAt:(new Date).getTime(),beatInterval:5e3,beatHandle:null,totalTransportConnectTimeout:0,redirectQs:null};typeof r=="boolean"&&(this.logging=r)},_parseResponse:function(n){var t=this;return n?typeof n=="string"?t.json.parse(n):n:n},_originalJson:t.JSON,json:t.JSON,isCrossDomain:function(i,r){var u;return(i=n.trim(i),r=r||t.location,i.indexOf("http")!==0)?!1:(u=t.document.createElement("a"),u.href=i,u.protocol+a(u.protocol,u.host)!==r.protocol+a(r.protocol,r.host))},ajaxDataType:"text",contentType:"application/json; charset=UTF-8",logging:!1,state:r.connectionState.disconnected,clientProtocol:"2.1",supportedProtocols:["1.5","2.0","2.1"],negotiateRedirectSupportedProtocols:["2.0","2.1"],reconnectDelay:2e3,transportConnectTimeout:0,disconnectTimeout:3e4,reconnectWindow:3e4,keepAliveWarnAt:2/3,start:function(i,h){var a=this,v={pingInterval:3e5,waitForPageLoad:!0,transport:"auto",jsonp:!1},g,y=a._deferral||n.Deferred(),b=t.document.createElement("a"),nt=function(i,u){i.url===u&&i.baseUrl||(i.url=u,b.href=i.url,b.protocol&&b.protocol!==":"?(i.protocol=b.protocol,i.host=b.host):(i.protocol=t.document.location.protocol,i.host=b.host||t.document.location.host),i.baseUrl=i.protocol+"//"+i.host,i.wsProtocol=i.protocol==="https:"?"wss://":"ws://",i.url.indexOf("//")===0&&(i.url=t.location.protocol+i.url,i.log("Protocol relative URL detected, normalizing it to '"+i.url+"'.")),i.isCrossDomain(i.url)&&(i.log("Auto detected cross domain url."),v.transport==="auto"&&(v.transport=["webSockets","serverSentEvents","longPolling"]),typeof i.withCredentials=="undefined"&&(i.withCredentials=!0),n.support.cors||(i.ajaxDataType="jsonp",i.log("Using jsonp because this browser doesn't support CORS.")),i.contentType=r._.defaultContentType))},d,k;if(a.lastError=null,a._deferral=y,!a.json)throw new Error("SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. IE<8.");if(n.type(i)==="function"?h=i:n.type(i)==="object"&&(n.extend(v,i),n.type(v.callback)==="function"&&(h=v.callback)),v.transport=w(v.transport,a),!v.transport)throw new Error("SignalR: Invalid transport(s) specified, aborting start.");return(a._.config=v,!o&&v.waitForPageLoad===!0)?(a._.deferredStartHandler=function(){a.start(i,h)},e.bind("load",a._.deferredStartHandler),y.promise()):a.state===r.connectionState.connecting?y.promise():s(a,r.connectionState.disconnected,r.connectionState.connecting)===!1?(y.resolve(a),y.promise()):(p(a),v.transport==="auto"&&v.jsonp===!0&&(v.transport="longPolling"),a.withCredentials=v.withCredentials,a._originalUrl=a.url,a.ajaxDataType=v.jsonp?"jsonp":"text",nt(a,a.url),n(a).bind(u.onStart,function(){n.type(h)==="function"&&h.call(a);y.resolve(a)}),a._.initHandler=r.transports._logic.initHandler(a),g=function(i,o){var c=r._.error(f.noTransportOnInit);if(o=o||0,o>=i.length){o===0?a.log("No transports supported by the server were selected."):o===1?a.log("No fallback transports were selected."):a.log("Fallback transports exhausted.");n(a).triggerHandler(u.onError,[c]);y.reject(c);a.stop();return}if(a.state!==r.connectionState.disconnected){var p=i[o],h=r.transports[p],v=function(){g(i,o+1)};a.transport=h;try{a._.initHandler.start(h,function(){var f=r._.firefoxMajorVersion(t.navigator.userAgent)>=11,i=!0;a.log("The start request succeeded. Transitioning to the connected state.");l(a)&&r.transports._logic.monitorKeepAlive(a);a._.keepAliveData.activated&&r.transports._logic.startHeartbeat(a);r._.configurePingInterval(a);s(a,r.connectionState.connecting,r.connectionState.connected)||a.log("WARNING! The connection was not in the connecting state.");a._.connectingMessageBuffer.drain();n(a).triggerHandler(u.onStart);e.bind("unload",function(){a.log("Window unloading, stopping the connection.");a.stop(i)});f&&e.bind("beforeunload",function(){t.setTimeout(function(){a.stop(i)},0)})},v)}catch(w){a.log(h.name+" transport threw '"+w.message+"' when attempting to start.");v()}}},d=a.url+"/negotiate",k=function(t,i){var e=r._.error(f.errorOnNegotiate,t,i._.negotiateRequest);n(i).triggerHandler(u.onError,e);y.reject(e);i.stop()},n(a).triggerHandler(u.onStarting),d=r.transports._logic.prepareQueryString(a,d),a.log("Negotiating with '"+d+"'."),a._.negotiateRequest=function(){var t,h=0,w=100,i,e,o=[],s=[],l=function(n,t){var u=r.transports._logic.prepareQueryString(n,n.url+"/negotiate"),i;return n.log("Negotiating with '"+u+"'."),i={url:u,error:function(t,i){i!==c?k(t,n):y.reject(r._.error(f.stoppedWhileNegotiating,null,n._.negotiateRequest))},success:t},n.accessToken&&(i.headers={Authorization:"Bearer "+n.accessToken}),r.transports._logic.ajax(n,i)},p=function(c){try{t=a._parseResponse(c)}catch(d){k(r._.error(f.errorParsingNegotiateResponse,d),a);return}if(t.availableTransports){e=r._.error(f.aspnetCoreSignalrServer);n(a).triggerHandler(u.onError,[e]);y.reject(e);return}if(!t.ProtocolVersion||a.supportedProtocols.indexOf(t.ProtocolVersion)===-1){e=r._.error(r._.format(f.protocolIncompatible,a.clientProtocol,t.ProtocolVersion));n(a).triggerHandler(u.onError,[e]);y.reject(e);return}if(a.negotiateRedirectSupportedProtocols.indexOf(t.ProtocolVersion)!==-1){if(t.Error){e=r._.error(r._.format(f.errorFromServer,t.Error));n(a).triggerHandler(u.onError,[e]);y.reject(e);return}if(t.RedirectUrl){if(h===w){k(r._.error(f.errorRedirectionExceedsLimit),a);return}v.transport==="auto"&&(v.transport=["webSockets","serverSentEvents","longPolling"]);a.log("Received redirect to: "+t.RedirectUrl);a.accessToken=t.AccessToken;var b=t.RedirectUrl.split("?",2);if(nt(a,b[0]),a._.redirectQs=b.length===2?b[1]:null,a.ajaxDataType==="jsonp"&&a.accessToken){k(r._.error(f.jsonpNotSupportedWithAccessToken),a);return}h++;l(a,p);return}}i=a._.keepAliveData;a.appRelativeUrl=t.Url;a.id=t.ConnectionId;a.token=t.ConnectionToken;a.webSocketServerUrl=t.WebSocketServerUrl;a._.pollTimeout=t.ConnectionTimeout*1e3+1e4;a.disconnectTimeout=t.DisconnectTimeout*1e3;a._.totalTransportConnectTimeout=a.transportConnectTimeout+t.TransportConnectTimeout*1e3;t.KeepAliveTimeout?(i.activated=!0,i.timeout=t.KeepAliveTimeout*1e3,i.timeoutWarning=i.timeout*a.keepAliveWarnAt,a._.beatInterval=(i.timeout-i.timeoutWarning)/3):i.activated=!1;a.reconnectWindow=a.disconnectTimeout+(i.timeout||0);n.each(r.transports,function(n){if(n.indexOf("_")===0||n==="webSockets"&&!t.TryWebSockets)return!0;s.push(n)});n.isArray(v.transport)?n.each(v.transport,function(t,i){n.inArray(i,s)>=0&&o.push(i)}):v.transport==="auto"?o=s:n.inArray(v.transport,s)>=0&&o.push(v.transport);g(o)};return l(a,p)}(),y.promise())},starting:function(t){var i=this;return n(i).bind(u.onStarting,function(){t.call(i)}),i},send:function(n){var t=this;if(t.state===r.connectionState.disconnected)throw new Error("SignalR: Connection must be started before data can be sent. Call .start() before .send()");if(t.state===r.connectionState.connecting)throw new Error("SignalR: Connection has not been fully initialized. Use .start().done() or .start().fail() to run logic after the connection has started.");return t.transport.send(t,n),t},received:function(t){var i=this;return n(i).bind(u.onReceived,function(n,r){t.call(i,r)}),i},stateChanged:function(t){var i=this;return n(i).bind(u.onStateChanged,function(n,r){t.call(i,r)}),i},error:function(t){var i=this;return n(i).bind(u.onError,function(n,r,u){i.lastError=r;t.call(i,r,u)}),i},disconnected:function(t){var i=this;return n(i).bind(u.onDisconnect,function(){t.call(i)}),i},connectionSlow:function(t){var i=this;return n(i).bind(u.onConnectionSlow,function(){t.call(i)}),i},reconnecting:function(t){var i=this;return n(i).bind(u.onReconnecting,function(){t.call(i)}),i},reconnected:function(t){var i=this;return n(i).bind(u.onReconnect,function(){t.call(i)}),i},stop:function(i,h){var a=this,v=a._deferral;if(a._.deferredStartHandler&&e.unbind("load",a._.deferredStartHandler),delete a._.config,delete a._.deferredStartHandler,!o&&(!a._.config||a._.config.waitForPageLoad===!0)){a.log("Stopping connection prior to negotiate.");v&&v.reject(r._.error(f.stoppedWhileLoading));return}if(a.state!==r.connectionState.disconnected)return a.log("Stopping connection."),t.clearTimeout(a._.beatHandle),t.clearInterval(a._.pingIntervalId),a.transport&&(a.transport.stop(a),h!==!1&&a.transport.abort(a,i),l(a)&&r.transports._logic.stopMonitoringKeepAlive(a),a.transport=null),a._.negotiateRequest&&(a._.negotiateRequest.abort(c),delete a._.negotiateRequest),a._.initHandler&&a._.initHandler.stop(),delete a._deferral,delete a.messageId,delete a.groupsToken,delete a.id,delete a._.pingIntervalId,delete a._.lastMessageAt,delete a._.lastActiveAt,a._.connectingMessageBuffer.clear(),n(a).unbind(u.onStart),delete a.accessToken,delete a.protocol,delete a.host,delete a.baseUrl,delete a.wsProtocol,delete a.contentType,a.url=a._originalUrl,a._.redirectQs=null,s(a,a.state,r.connectionState.disconnected),n(a).triggerHandler(u.onDisconnect),a},log:function(n){v(n,this.logging)}};r.fn.init.prototype=r.fn;r.noConflict=function(){return n.connection===r&&(n.connection=h),r};n.connection&&(h=n.connection);n.connection=n.signalR=r})(window.jQuery,window),function(n,t,i){function s(n){n._.keepAliveData.monitoring&&l(n);u.markActive(n)&&(n._.beatHandle=t.setTimeout(function(){s(n)},n._.beatInterval))}function l(t){var i=t._.keepAliveData,u;t.state===r.connectionState.connected&&(u=(new Date).getTime()-t._.lastMessageAt,u>=i.timeout?(t.log("Keep alive timed out. Notifying transport that connection has been lost."),t.transport.lostConnection(t)):u>=i.timeoutWarning?i.userNotified||(t.log("Keep alive has been missed, connection may be dead/slow."),n(t).triggerHandler(f.onConnectionSlow),i.userNotified=!0):i.userNotified=!1)}function e(n,t){var i=n.url+t;return n.transport&&(i+="?transport="+n.transport.name),u.prepareQueryString(n,i)}function h(n){this.connection=n;this.startRequested=!1;this.startCompleted=!1;this.connectionStopped=!1}var r=n.signalR,f=n.signalR.events,c=n.signalR.changeState,o="__Start Aborted__",u;r.transports={};h.prototype={start:function(n,r,u){var f=this,e=f.connection,o=!1;if(f.startRequested||f.connectionStopped){e.log("WARNING! "+n.name+" transport cannot be started. Initialization ongoing or completed.");return}e.log(n.name+" transport starting.");n.start(e,function(){o||f.initReceived(n,r)},function(t){return o||(o=!0,f.transportFailed(n,t,u)),!f.startCompleted||f.connectionStopped});f.transportTimeoutHandle=t.setTimeout(function(){o||(o=!0,e.log(n.name+" transport timed out when trying to connect."),f.transportFailed(n,i,u))},e._.totalTransportConnectTimeout)},stop:function(){this.connectionStopped=!0;t.clearTimeout(this.transportTimeoutHandle);r.transports._logic.tryAbortStartRequest(this.connection)},initReceived:function(n,i){var u=this,f=u.connection;if(u.startRequested){f.log("WARNING! The client received multiple init messages.");return}u.connectionStopped||(u.startRequested=!0,t.clearTimeout(u.transportTimeoutHandle),f.log(n.name+" transport connected. Initiating start request."),r.transports._logic.ajaxStart(f,function(){u.startCompleted=!0;i()}))},transportFailed:function(i,u,e){var o=this.connection,h=o._deferral,s;this.connectionStopped||(t.clearTimeout(this.transportTimeoutHandle),this.startRequested?this.startCompleted||(s=r._.error(r.resources.errorDuringStartRequest,u),o.log(i.name+" transport failed during the start request. Stopping the connection."),n(o).triggerHandler(f.onError,[s]),h&&h.reject(s),o.stop()):(i.stop(o),o.log(i.name+" transport failed to connect. Attempting to fall back."),e()))}};u=r.transports._logic={ajax:function(t,i){return n.ajax(n.extend(!0,{},n.signalR.ajaxDefaults,{type:"GET",data:{},xhrFields:{withCredentials:t.withCredentials},contentType:t.contentType,dataType:t.ajaxDataType},i))},pingServer:function(t){var e,f,i=n.Deferred();return t.transport?(e=t.url+"/ping",e=u.addQs(e,t.qs),f=u.ajax(t,{url:e,headers:t.accessToken?{Authorization:"Bearer "+t.accessToken}:{},success:function(n){var u;try{u=t._parseResponse(n)}catch(e){i.reject(r._.transportError(r.resources.pingServerFailedParse,t.transport,e,f));t.stop();return}u.Response==="pong"?i.resolve():i.reject(r._.transportError(r._.format(r.resources.pingServerFailedInvalidResponse,n),t.transport,null,f))},error:function(n){n.status===401||n.status===403?(i.reject(r._.transportError(r._.format(r.resources.pingServerFailedStatusCode,n.status),t.transport,n,f)),t.stop()):i.reject(r._.transportError(r.resources.pingServerFailed,t.transport,n,f))}})):i.reject(r._.transportError(r.resources.noConnectionTransport,t.transport)),i.promise()},prepareQueryString:function(n,i){var r;return r=u.addQs(i,"clientProtocol="+n.clientProtocol),r=typeof n._.redirectQs=="string"?u.addQs(r,n._.redirectQs):u.addQs(r,n.qs),n.token&&(r+="&connectionToken="+t.encodeURIComponent(n.token)),n.data&&(r+="&connectionData="+t.encodeURIComponent(n.data)),r},addQs:function(t,i){var r=t.indexOf("?")!==-1?"&":"?",u;if(!i)return t;if(typeof i=="object")return t+r+n.param(i);if(typeof i=="string")return u=i.charAt(0),(u==="?"||u==="&")&&(r=""),t+r+i;throw new Error("Query string property must be either a string or object.");},getUrl:function(n,i,r,f,e){var h=i==="webSockets"?"":n.baseUrl,o=h+n.appRelativeUrl,s="transport="+i;return!e&&n.groupsToken&&(s+="&groupsToken="+t.encodeURIComponent(n.groupsToken)),r?(o+=f?"/poll":"/reconnect",!e&&n.messageId&&(s+="&messageId="+t.encodeURIComponent(n.messageId))):o+="/connect",o+="?"+s,o=u.prepareQueryString(n,o),n.transport&&n.accessToken&&(n.transport.name==="serverSentEvents"||n.transport.name==="webSockets")&&(o+="&access_token="+t.encodeURIComponent(n.accessToken)),e||(o+="&tid="+Math.floor(Math.random()*11)),o},maximizePersistentResponse:function(n){return{MessageId:n.C,Messages:n.M,Initialized:typeof n.S!="undefined"?!0:!1,ShouldReconnect:typeof n.T!="undefined"?!0:!1,LongPollDelay:n.L,GroupsToken:n.G,Error:n.E}},updateGroups:function(n,t){t&&(n.groupsToken=t)},stringifySend:function(n,t){return typeof t=="string"||typeof t=="undefined"||t===null?t:n.json.stringify(t)},ajaxSend:function(t,i){var h=u.stringifySend(t,i),c=e(t,"/send"),o,s=function(t,u){n(u).triggerHandler(f.onError,[r._.transportError(r.resources.sendFailed,u.transport,t,o),i])};return o=u.ajax(t,{url:c,type:t.ajaxDataType==="jsonp"?"GET":"POST",contentType:r._.defaultContentType,headers:t.accessToken?{Authorization:"Bearer "+t.accessToken}:{},data:{data:h},success:function(n){var i;if(n){try{i=t._parseResponse(n)}catch(r){s(r,t);t.stop();return}u.triggerReceived(t,i)}},error:function(n,i){i!=="abort"&&i!=="parsererror"&&s(n,t)}})},ajaxAbort:function(n,i){if(typeof n.transport!="undefined"){i=typeof i=="undefined"?!0:i;var r=e(n,"/abort"),f=n.accessToken?{Authorization:"Bearer "+n.accessToken}:{};t.fetch?t.fetch(r,{method:"POST",keepalive:!0,headers:f,credentials:n.withCredentials===!0?"include":"same-origin"}):u.ajax(n,{url:r,async:i,timeout:1e3,type:"POST",headers:f,dataType:"text"});n.log("Fired ajax abort async = "+i+".")}},ajaxStart:function(t,i){var h=function(n){var i=t._deferral;i&&i.reject(n)},s=function(i){t.log("The start request failed. Stopping the connection.");n(t).triggerHandler(f.onError,[i]);h(i);t.stop()};t._.startRequest=u.ajax(t,{url:e(t,"/start"),headers:t.accessToken?{Authorization:"Bearer "+t.accessToken}:{},success:function(n,u,f){var e;try{e=t._parseResponse(n)}catch(o){s(r._.error(r._.format(r.resources.errorParsingStartResponse,n),o,f));return}e.Response==="started"?i():s(r._.error(r._.format(r.resources.invalidStartResponse,n),null,f))},error:function(n,i,u){i!==o?s(r._.error(r.resources.errorDuringStartRequest,u,n)):(t.log("The start request aborted because connection.stop() was called."),h(r._.error(r.resources.stoppedDuringStartRequest,null,n)))}})},tryAbortStartRequest:function(n){n._.startRequest&&(n._.startRequest.abort(o),delete n._.startRequest)},tryInitialize:function(n,t,i){t.Initialized&&i?i():t.Initialized&&n.log("WARNING! The client received an init message after reconnecting.")},triggerReceived:function(t,i){t._.connectingMessageBuffer.tryBuffer(i)||n(t).triggerHandler(f.onReceived,[i])},processMessages:function(t,i,f){var e;if(i&&typeof i.I!="undefined"){u.triggerReceived(t,i);return}if(u.markLastMessage(t),i){if(e=u.maximizePersistentResponse(i),e.Error){t.log("Received an error message from the server: "+i.E);n(t).triggerHandler(r.events.onError,[r._.error(i.E,"ServerError")]);t.stop(!1,!1);return}u.updateGroups(t,e.GroupsToken);e.MessageId&&(t.messageId=e.MessageId);e.Messages&&(n.each(e.Messages,function(n,i){u.triggerReceived(t,i)}),u.tryInitialize(t,e,f))}},monitorKeepAlive:function(t){var i=t._.keepAliveData;i.monitoring?t.log("Tried to monitor keep alive but it's already being monitored."):(i.monitoring=!0,u.markLastMessage(t),t._.keepAliveData.reconnectKeepAliveUpdate=function(){u.markLastMessage(t)},n(t).bind(f.onReconnect,t._.keepAliveData.reconnectKeepAliveUpdate),t.log("Now monitoring keep alive with a warning timeout of "+i.timeoutWarning+", keep alive timeout of "+i.timeout+" and disconnecting timeout of "+t.disconnectTimeout))},stopMonitoringKeepAlive:function(t){var i=t._.keepAliveData;i.monitoring&&(i.monitoring=!1,n(t).unbind(f.onReconnect,t._.keepAliveData.reconnectKeepAliveUpdate),t._.keepAliveData={},t.log("Stopping the monitoring of the keep alive."))},startHeartbeat:function(n){n._.lastActiveAt=(new Date).getTime();s(n)},markLastMessage:function(n){n._.lastMessageAt=(new Date).getTime();n._.lastActiveAt=n._.lastMessageAt},markActive:function(n){return u.verifyLastActive(n)?(n._.lastActiveAt=(new Date).getTime(),!0):!1},isConnectedOrReconnecting:function(n){return n.state===r.connectionState.connected||n.state===r.connectionState.reconnecting},ensureReconnectingState:function(t){return c(t,r.connectionState.connected,r.connectionState.reconnecting)===!0&&n(t).triggerHandler(f.onReconnecting),t.state===r.connectionState.reconnecting},clearReconnectTimeout:function(n){n&&n._.reconnectTimeout&&(t.clearTimeout(n._.reconnectTimeout),delete n._.reconnectTimeout)},verifyLastActive:function(t){if(!t._.keepAliveData.activated||(new Date).getTime()-t._.lastActiveAt0&&n--}}}();r.transports.foreverFrame={name:"foreverFrame",supportsKeepAlive:function(){return!0},iframeClearThreshold:50,start:function(n,r,e){if(n.accessToken){e&&(n.log("Forever Frame does not support connections that require a Bearer token to connect, such as the Azure SignalR Service."),e());return}var l=this,s=i.foreverFrame.count+=1,h,o=u(),c=function(){n.log("Forever frame iframe finished loading and is no longer receiving messages.");e&&e()||l.reconnect(n)};if(t.EventSource){e&&(n.log("Forever Frame is not supported by SignalR on browsers with SSE support."),e());return}o.setAttribute("data-signalr-connection-id",n.id);f.prevent();h=i.getUrl(n,this.name);h+="&frameId="+s;t.document.documentElement.appendChild(o);n.log("Binding to iframe's load event.");o.addEventListener?o.addEventListener("load",c,!1):o.attachEvent&&o.attachEvent("onload",c);o.src=h;i.foreverFrame.connections[s]=n;n.frame=o;n.frameId=s;r&&(n.onSuccess=function(){n.log("Iframe transport started.");r()})},reconnect:function(n){var r=this;i.isConnectedOrReconnecting(n)&&i.verifyLastActive(n)&&t.setTimeout(function(){if(i.verifyLastActive(n)&&n.frame&&i.ensureReconnectingState(n)){var u=n.frame,t=i.getUrl(n,r.name,!0)+"&frameId="+n.frameId;n.log("Updating iframe src to '"+t+"'.");u.src=t}},n.reconnectDelay)},lostConnection:function(n){this.reconnect(n)},send:function(n,t){i.ajaxSend(n,t)},receive:function(t,u){var f,e,o;if(t.json!==t._originalJson&&(u=t._originalJson.stringify(u)),o=t._parseResponse(u),i.processMessages(t,o,t.onSuccess),t.state===n.signalR.connectionState.connected&&(t.frameMessageCount=(t.frameMessageCount||0)+1,t.frameMessageCount>r.transports.foreverFrame.iframeClearThreshold&&(t.frameMessageCount=0,f=t.frame.contentWindow||t.frame.contentDocument,f&&f.document&&f.document.body)))for(e=f.document.body;e.firstChild;)e.removeChild(e.firstChild)},stop:function(n){var r=null;if(f.cancel(),n.frame){if(n.frame.stop)n.frame.stop();else try{r=n.frame.contentWindow||n.frame.contentDocument;r.document&&r.document.execCommand&&r.document.execCommand("Stop")}catch(u){n.log("Error occurred when stopping foreverFrame transport. Message = "+u.message+".")}n.frame.parentNode===t.document.documentElement&&t.document.documentElement.removeChild(n.frame);delete i.foreverFrame.connections[n.frameId];n.frame=null;n.frameId=null;delete n.frame;delete n.frameId;delete n.onSuccess;delete n.frameMessageCount;n.log("Stopping forever frame.")}},abort:function(n,t){i.ajaxAbort(n,t)},getConnection:function(n){return i.foreverFrame.connections[n]},started:function(t){o(t,r.connectionState.reconnecting,r.connectionState.connected)===!0&&n(t).triggerHandler(e.onReconnect)}}}(window.jQuery,window),function(n,t){var r=n.signalR,u=n.signalR.events,e=n.signalR.changeState,f=n.signalR.isDisconnecting,i=r.transports._logic;r.transports.longPolling={name:"longPolling",supportsKeepAlive:function(){return!1},reconnectDelay:3e3,start:function(o,s,h){var a=this,v=function(){v=n.noop;o.log("LongPolling connected.");s?s():o.log("WARNING! The client received an init message after reconnecting.")},y=function(n){return h(n)?(o.log("LongPolling failed to connect."),!0):!1},c=o._,l=0,p=function(i){t.clearTimeout(c.reconnectTimeoutId);c.reconnectTimeoutId=null;e(i,r.connectionState.reconnecting,r.connectionState.connected)===!0&&(i.log("Raising the reconnect event"),n(i).triggerHandler(u.onReconnect))},w=36e5;o.pollXhr&&(o.log("Polling xhr requests already exists, aborting."),o.stop());o.messageId=null;c.reconnectTimeoutId=null;c.pollTimeoutId=t.setTimeout(function(){(function e(s,h){var g=s.messageId,nt=g===null,k=!nt,tt=!h,d=i.getUrl(s,a.name,k,tt,!0),b={};(s.messageId&&(b.messageId=s.messageId),s.groupsToken&&(b.groupsToken=s.groupsToken),f(s)!==!0)&&(o.log("Opening long polling request to '"+d+"'."),s.pollXhr=i.ajax(o,{xhrFields:{onprogress:function(){i.markLastMessage(o)}},url:d,type:"POST",contentType:r._.defaultContentType,data:b,timeout:o._.pollTimeout,headers:o.accessToken?{Authorization:"Bearer "+o.accessToken}:{},success:function(r){var h,w=0,u,a;o.log("Long poll complete.");l=0;try{h=o._parseResponse(r)}catch(b){i.handleParseFailure(s,r,b,y,s.pollXhr);return}(c.reconnectTimeoutId!==null&&p(s),h&&(u=i.maximizePersistentResponse(h)),i.processMessages(s,h,v),u&&n.type(u.LongPollDelay)==="number"&&(w=u.LongPollDelay),f(s)!==!0)&&(a=u&&u.ShouldReconnect,!a||i.ensureReconnectingState(s))&&(w>0?c.pollTimeoutId=t.setTimeout(function(){e(s,a)},w):e(s,a))},error:function(f,h){var v=r._.transportError(r.resources.longPollFailed,o.transport,f,s.pollXhr);if(t.clearTimeout(c.reconnectTimeoutId),c.reconnectTimeoutId=null,h==="abort"){o.log("Aborted xhr request.");return}if(!y(v)){if(l++,o.state!==r.connectionState.reconnecting&&(o.log("An error occurred using longPolling. Status = "+h+". Response = "+f.responseText+"."),n(s).triggerHandler(u.onError,[v])),(o.state===r.connectionState.connected||o.state===r.connectionState.reconnecting)&&!i.verifyLastActive(o))return;if(!i.ensureReconnectingState(s))return;c.pollTimeoutId=t.setTimeout(function(){e(s,!0)},a.reconnectDelay)}}}),k&&h===!0&&(c.reconnectTimeoutId=t.setTimeout(function(){p(s)},Math.min(1e3*(Math.pow(2,l)-1),w))))})(o)},250)},lostConnection:function(n){n.pollXhr&&n.pollXhr.abort("lostConnection")},send:function(n,t){i.ajaxSend(n,t)},stop:function(n){t.clearTimeout(n._.pollTimeoutId);t.clearTimeout(n._.reconnectTimeoutId);delete n._.pollTimeoutId;delete n._.reconnectTimeoutId;n.pollXhr&&(n.pollXhr.abort(),n.pollXhr=null,delete n.pollXhr)},abort:function(n,t){i.ajaxAbort(n,t)}}}(window.jQuery,window),function(n){function r(n){return n+s}function c(n,t,i){for(var f=n.length,u=[],r=0;r=0}function i(n,t){return new i.fn.init(n,t)}function t(i,r){var u={qs:null,logging:!1,useDefaultPath:!0};return n.extend(u,r),(!i||u.useDefaultPath)&&(i=(i||"")+"/signalr"),new t.fn.init(i,u)}var o=0,s=".hubProxy",h=n.signalR;i.fn=i.prototype={init:function(n,t){this.state={};this.connection=n;this.hubName=t;this._={callbackMap:{}}},constructor:i,hasSubscriptions:function(){return u(this._.callbackMap)},on:function(t,i,u){var c=this,l=c._.callbackMap,v=!u&&e(i),f,h,s,a;for(u=u||i,u._signalRGuid||(u._signalRGuid=o++),t=t.toLowerCase(),f=l[t],f||(f=[],l[t]=f),s=0;s {
+return /******/ (() => { // webpackBootstrap
+/******/ "use strict";
+/******/ // The require scope
+/******/ var __webpack_require__ = {};
+/******/
+/************************************************************************/
+/******/ /* webpack/runtime/define property getters */
+/******/ (() => {
+/******/ // define getter functions for harmony exports
+/******/ __webpack_require__.d = (exports, definition) => {
+/******/ for(var key in definition) {
+/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
+/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
+/******/ }
+/******/ }
+/******/ };
+/******/ })();
+/******/
+/******/ /* webpack/runtime/global */
+/******/ (() => {
+/******/ __webpack_require__.g = (function() {
+/******/ if (typeof globalThis === 'object') return globalThis;
+/******/ try {
+/******/ return this || new Function('return this')();
+/******/ } catch (e) {
+/******/ if (typeof window === 'object') return window;
+/******/ }
+/******/ })();
+/******/ })();
+/******/
+/******/ /* webpack/runtime/hasOwnProperty shorthand */
+/******/ (() => {
+/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
+/******/ })();
+/******/
+/******/ /* webpack/runtime/make namespace object */
+/******/ (() => {
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = (exports) => {
+/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
+/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
+/******/ }
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/ })();
+/******/
+/************************************************************************/
+var __webpack_exports__ = {};
+// ESM COMPAT FLAG
+__webpack_require__.r(__webpack_exports__);
+
+// EXPORTS
+__webpack_require__.d(__webpack_exports__, {
+ "AbortError": () => (/* reexport */ AbortError),
+ "DefaultHttpClient": () => (/* reexport */ DefaultHttpClient),
+ "HttpClient": () => (/* reexport */ HttpClient),
+ "HttpError": () => (/* reexport */ HttpError),
+ "HttpResponse": () => (/* reexport */ HttpResponse),
+ "HttpTransportType": () => (/* reexport */ HttpTransportType),
+ "HubConnection": () => (/* reexport */ HubConnection),
+ "HubConnectionBuilder": () => (/* reexport */ HubConnectionBuilder),
+ "HubConnectionState": () => (/* reexport */ HubConnectionState),
+ "JsonHubProtocol": () => (/* reexport */ JsonHubProtocol),
+ "LogLevel": () => (/* reexport */ LogLevel),
+ "MessageType": () => (/* reexport */ MessageType),
+ "NullLogger": () => (/* reexport */ NullLogger),
+ "Subject": () => (/* reexport */ Subject),
+ "TimeoutError": () => (/* reexport */ TimeoutError),
+ "TransferFormat": () => (/* reexport */ TransferFormat),
+ "VERSION": () => (/* reexport */ VERSION)
+});
+
+;// CONCATENATED MODULE: ./src/Errors.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+/** Error thrown when an HTTP request fails. */
+class HttpError extends Error {
+ /** Constructs a new instance of {@link @microsoft/signalr.HttpError}.
+ *
+ * @param {string} errorMessage A descriptive error message.
+ * @param {number} statusCode The HTTP status code represented by this error.
+ */
+ constructor(errorMessage, statusCode) {
+ const trueProto = new.target.prototype;
+ super(`${errorMessage}: Status code '${statusCode}'`);
+ this.statusCode = statusCode;
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+/** Error thrown when a timeout elapses. */
+class TimeoutError extends Error {
+ /** Constructs a new instance of {@link @microsoft/signalr.TimeoutError}.
+ *
+ * @param {string} errorMessage A descriptive error message.
+ */
+ constructor(errorMessage = "A timeout occurred.") {
+ const trueProto = new.target.prototype;
+ super(errorMessage);
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+/** Error thrown when an action is aborted. */
+class AbortError extends Error {
+ /** Constructs a new instance of {@link AbortError}.
+ *
+ * @param {string} errorMessage A descriptive error message.
+ */
+ constructor(errorMessage = "An abort occurred.") {
+ const trueProto = new.target.prototype;
+ super(errorMessage);
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+/** Error thrown when the selected transport is unsupported by the browser. */
+/** @private */
+class UnsupportedTransportError extends Error {
+ /** Constructs a new instance of {@link @microsoft/signalr.UnsupportedTransportError}.
+ *
+ * @param {string} message A descriptive error message.
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
+ */
+ constructor(message, transport) {
+ const trueProto = new.target.prototype;
+ super(message);
+ this.transport = transport;
+ this.errorType = 'UnsupportedTransportError';
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+/** Error thrown when the selected transport is disabled by the browser. */
+/** @private */
+class DisabledTransportError extends Error {
+ /** Constructs a new instance of {@link @microsoft/signalr.DisabledTransportError}.
+ *
+ * @param {string} message A descriptive error message.
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
+ */
+ constructor(message, transport) {
+ const trueProto = new.target.prototype;
+ super(message);
+ this.transport = transport;
+ this.errorType = 'DisabledTransportError';
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+/** Error thrown when the selected transport cannot be started. */
+/** @private */
+class FailedToStartTransportError extends Error {
+ /** Constructs a new instance of {@link @microsoft/signalr.FailedToStartTransportError}.
+ *
+ * @param {string} message A descriptive error message.
+ * @param {HttpTransportType} transport The {@link @microsoft/signalr.HttpTransportType} this error occurred on.
+ */
+ constructor(message, transport) {
+ const trueProto = new.target.prototype;
+ super(message);
+ this.transport = transport;
+ this.errorType = 'FailedToStartTransportError';
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+/** Error thrown when the negotiation with the server failed to complete. */
+/** @private */
+class FailedToNegotiateWithServerError extends Error {
+ /** Constructs a new instance of {@link @microsoft/signalr.FailedToNegotiateWithServerError}.
+ *
+ * @param {string} message A descriptive error message.
+ */
+ constructor(message) {
+ const trueProto = new.target.prototype;
+ super(message);
+ this.errorType = 'FailedToNegotiateWithServerError';
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+/** Error thrown when multiple errors have occurred. */
+/** @private */
+class AggregateErrors extends Error {
+ /** Constructs a new instance of {@link @microsoft/signalr.AggregateErrors}.
+ *
+ * @param {string} message A descriptive error message.
+ * @param {Error[]} innerErrors The collection of errors this error is aggregating.
+ */
+ constructor(message, innerErrors) {
+ const trueProto = new.target.prototype;
+ super(message);
+ this.innerErrors = innerErrors;
+ // Workaround issue in Typescript compiler
+ // https://github.com/Microsoft/TypeScript/issues/13965#issuecomment-278570200
+ this.__proto__ = trueProto;
+ }
+}
+
+;// CONCATENATED MODULE: ./src/HttpClient.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+/** Represents an HTTP response. */
+class HttpResponse {
+ constructor(statusCode, statusText, content) {
+ this.statusCode = statusCode;
+ this.statusText = statusText;
+ this.content = content;
+ }
+}
+/** Abstraction over an HTTP client.
+ *
+ * This class provides an abstraction over an HTTP client so that a different implementation can be provided on different platforms.
+ */
+class HttpClient {
+ get(url, options) {
+ return this.send({
+ ...options,
+ method: "GET",
+ url,
+ });
+ }
+ post(url, options) {
+ return this.send({
+ ...options,
+ method: "POST",
+ url,
+ });
+ }
+ delete(url, options) {
+ return this.send({
+ ...options,
+ method: "DELETE",
+ url,
+ });
+ }
+ /** Gets all cookies that apply to the specified URL.
+ *
+ * @param url The URL that the cookies are valid for.
+ * @returns {string} A string containing all the key-value cookie pairs for the specified URL.
+ */
+ // @ts-ignore
+ getCookieString(url) {
+ return "";
+ }
+}
+
+;// CONCATENATED MODULE: ./src/ILogger.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// These values are designed to match the ASP.NET Log Levels since that's the pattern we're emulating here.
+/** Indicates the severity of a log message.
+ *
+ * Log Levels are ordered in increasing severity. So `Debug` is more severe than `Trace`, etc.
+ */
+var LogLevel;
+(function (LogLevel) {
+ /** Log level for very low severity diagnostic messages. */
+ LogLevel[LogLevel["Trace"] = 0] = "Trace";
+ /** Log level for low severity diagnostic messages. */
+ LogLevel[LogLevel["Debug"] = 1] = "Debug";
+ /** Log level for informational diagnostic messages. */
+ LogLevel[LogLevel["Information"] = 2] = "Information";
+ /** Log level for diagnostic messages that indicate a non-fatal problem. */
+ LogLevel[LogLevel["Warning"] = 3] = "Warning";
+ /** Log level for diagnostic messages that indicate a failure in the current operation. */
+ LogLevel[LogLevel["Error"] = 4] = "Error";
+ /** Log level for diagnostic messages that indicate a failure that will terminate the entire application. */
+ LogLevel[LogLevel["Critical"] = 5] = "Critical";
+ /** The highest possible log level. Used when configuring logging to indicate that no log messages should be emitted. */
+ LogLevel[LogLevel["None"] = 6] = "None";
+})(LogLevel || (LogLevel = {}));
+
+;// CONCATENATED MODULE: ./src/Loggers.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+/** A logger that does nothing when log messages are sent to it. */
+class NullLogger {
+ constructor() { }
+ /** @inheritDoc */
+ // eslint-disable-next-line
+ log(_logLevel, _message) {
+ }
+}
+/** The singleton instance of the {@link @microsoft/signalr.NullLogger}. */
+NullLogger.instance = new NullLogger();
+
+;// CONCATENATED MODULE: ./src/Utils.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+// Version token that will be replaced by the prepack command
+/** The version of the SignalR client. */
+const VERSION = "7.0.5";
+/** @private */
+class Arg {
+ static isRequired(val, name) {
+ if (val == undefined || val == undefined) {
+ throw new Error(`The '${name}' argument is required.`);
+ }
+ }
+ static isNotEmpty(val, name) {
+ if (!val || val.match(/^\s*$/)) {
+ throw new Error(`The '${name}' argument should not be empty.`);
+ }
+ }
+ static isIn(val, values, name) {
+ // TypeScript enums have keys for **both** the name and the value of each enum member on the type itself.
+ if (!(val in values)) {
+ throw new Error(`Unknown ${name} value: ${val}.`);
+ }
+ }
+}
+/** @private */
+class Platform {
+ // react-native has a window but no document so we should check both
+ static get isBrowser() {
+ return typeof window === "object" && typeof window.document === "object";
+ }
+ // WebWorkers don't have a window object so the isBrowser check would fail
+ static get isWebWorker() {
+ return typeof self === "object" && "importScripts" in self;
+ }
+ // react-native has a window but no document
+ static get isReactNative() {
+ return typeof window === "object" && typeof window.document === "undefined";
+ }
+ // Node apps shouldn't have a window object, but WebWorkers don't either
+ // so we need to check for both WebWorker and window
+ static get isNode() {
+ return !this.isBrowser && !this.isWebWorker && !this.isReactNative;
+ }
+}
+/** @private */
+function getDataDetail(data, includeContent) {
+ let detail = "";
+ if (isArrayBuffer(data)) {
+ detail = `Binary data of length ${data.byteLength}`;
+ if (includeContent) {
+ detail += `. Content: '${formatArrayBuffer(data)}'`;
+ }
+ }
+ else if (typeof data === "string") {
+ detail = `String data of length ${data.length}`;
+ if (includeContent) {
+ detail += `. Content: '${data}'`;
+ }
+ }
+ return detail;
+}
+/** @private */
+function formatArrayBuffer(data) {
+ const view = new Uint8Array(data);
+ // Uint8Array.map only supports returning another Uint8Array?
+ let str = "";
+ view.forEach((num) => {
+ const pad = num < 16 ? "0" : "";
+ str += `0x${pad}${num.toString(16)} `;
+ });
+ // Trim of trailing space.
+ return str.substr(0, str.length - 1);
+}
+// Also in signalr-protocol-msgpack/Utils.ts
+/** @private */
+function isArrayBuffer(val) {
+ return val && typeof ArrayBuffer !== "undefined" &&
+ (val instanceof ArrayBuffer ||
+ // Sometimes we get an ArrayBuffer that doesn't satisfy instanceof
+ (val.constructor && val.constructor.name === "ArrayBuffer"));
+}
+/** @private */
+async function sendMessage(logger, transportName, httpClient, url, content, options) {
+ const headers = {};
+ const [name, value] = getUserAgentHeader();
+ headers[name] = value;
+ logger.log(LogLevel.Trace, `(${transportName} transport) sending data. ${getDataDetail(content, options.logMessageContent)}.`);
+ const responseType = isArrayBuffer(content) ? "arraybuffer" : "text";
+ const response = await httpClient.post(url, {
+ content,
+ headers: { ...headers, ...options.headers },
+ responseType,
+ timeout: options.timeout,
+ withCredentials: options.withCredentials,
+ });
+ logger.log(LogLevel.Trace, `(${transportName} transport) request complete. Response status: ${response.statusCode}.`);
+}
+/** @private */
+function createLogger(logger) {
+ if (logger == undefined) {
+ return new ConsoleLogger(LogLevel.Information);
+ }
+ if (logger == undefined) {
+ return NullLogger.instance;
+ }
+ if (logger.log != undefined) {
+ return logger;
+ }
+ return new ConsoleLogger(logger);
+}
+/** @private */
+class SubjectSubscription {
+ constructor(subject, observer) {
+ this._subject = subject;
+ this._observer = observer;
+ }
+ dispose() {
+ const index = this._subject.observers.indexOf(this._observer);
+ if (index > -1) {
+ this._subject.observers.splice(index, 1);
+ }
+ if (this._subject.observers.length === 0 && this._subject.cancelCallback) {
+ this._subject.cancelCallback().catch((_) => { });
+ }
+ }
+}
+/** @private */
+class ConsoleLogger {
+ constructor(minimumLogLevel) {
+ this._minLevel = minimumLogLevel;
+ this.out = console;
+ }
+ log(logLevel, message) {
+ if (logLevel >= this._minLevel) {
+ const msg = `[${new Date().toISOString()}] ${LogLevel[logLevel]}: ${message}`;
+ switch (logLevel) {
+ case LogLevel.Critical:
+ case LogLevel.Error:
+ this.out.error(msg);
+ break;
+ case LogLevel.Warning:
+ this.out.warn(msg);
+ break;
+ case LogLevel.Information:
+ this.out.info(msg);
+ break;
+ default:
+ // console.debug only goes to attached debuggers in Node, so we use console.log for Trace and Debug
+ this.out.log(msg);
+ break;
+ }
+ }
+ }
+}
+/** @private */
+function getUserAgentHeader() {
+ let userAgentHeaderName = "X-SignalR-User-Agent";
+ if (Platform.isNode) {
+ userAgentHeaderName = "User-Agent";
+ }
+ return [userAgentHeaderName, constructUserAgent(VERSION, getOsName(), getRuntime(), getRuntimeVersion())];
+}
+/** @private */
+function constructUserAgent(version, os, runtime, runtimeVersion) {
+ // Microsoft SignalR/[Version] ([Detailed Version]; [Operating System]; [Runtime]; [Runtime Version])
+ let userAgent = "Microsoft SignalR/";
+ const majorAndMinor = version.split(".");
+ userAgent += `${majorAndMinor[0]}.${majorAndMinor[1]}`;
+ userAgent += ` (${version}; `;
+ if (os && os !== "") {
+ userAgent += `${os}; `;
+ }
+ else {
+ userAgent += "Unknown OS; ";
+ }
+ userAgent += `${runtime}`;
+ if (runtimeVersion) {
+ userAgent += `; ${runtimeVersion}`;
+ }
+ else {
+ userAgent += "; Unknown Runtime Version";
+ }
+ userAgent += ")";
+ return userAgent;
+}
+// eslint-disable-next-line spaced-comment
+/*#__PURE__*/ function getOsName() {
+ if (Platform.isNode) {
+ switch (process.platform) {
+ case "win32":
+ return "Windows NT";
+ case "darwin":
+ return "macOS";
+ case "linux":
+ return "Linux";
+ default:
+ return process.platform;
+ }
+ }
+ else {
+ return "";
+ }
+}
+// eslint-disable-next-line spaced-comment
+/*#__PURE__*/ function getRuntimeVersion() {
+ if (Platform.isNode) {
+ return process.versions.node;
+ }
+ return undefined;
+}
+function getRuntime() {
+ if (Platform.isNode) {
+ return "NodeJS";
+ }
+ else {
+ return "Browser";
+ }
+}
+/** @private */
+function getErrorString(e) {
+ if (e.stack) {
+ return e.stack;
+ }
+ else if (e.message) {
+ return e.message;
+ }
+ return `${e}`;
+}
+/** @private */
+function getGlobalThis() {
+ // globalThis is semi-new and not available in Node until v12
+ if (typeof globalThis !== "undefined") {
+ return globalThis;
+ }
+ if (typeof self !== "undefined") {
+ return self;
+ }
+ if (typeof window !== "undefined") {
+ return window;
+ }
+ if (typeof __webpack_require__.g !== "undefined") {
+ return __webpack_require__.g;
+ }
+ throw new Error("could not find global");
+}
+
+;// CONCATENATED MODULE: ./src/FetchHttpClient.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+class FetchHttpClient extends HttpClient {
+ constructor(logger) {
+ super();
+ this._logger = logger;
+ if (typeof fetch === "undefined") {
+ // In order to ignore the dynamic require in webpack builds we need to do this magic
+ // @ts-ignore: TS doesn't know about these names
+ const requireFunc = true ? require : 0;
+ // Cookies aren't automatically handled in Node so we need to add a CookieJar to preserve cookies across requests
+ this._jar = new (requireFunc("tough-cookie")).CookieJar();
+ this._fetchType = requireFunc("node-fetch");
+ // node-fetch doesn't have a nice API for getting and setting cookies
+ // fetch-cookie will wrap a fetch implementation with a default CookieJar or a provided one
+ this._fetchType = requireFunc("fetch-cookie")(this._fetchType, this._jar);
+ }
+ else {
+ this._fetchType = fetch.bind(getGlobalThis());
+ }
+ if (typeof AbortController === "undefined") {
+ // In order to ignore the dynamic require in webpack builds we need to do this magic
+ // @ts-ignore: TS doesn't know about these names
+ const requireFunc = true ? require : 0;
+ // Node needs EventListener methods on AbortController which our custom polyfill doesn't provide
+ this._abortControllerType = requireFunc("abort-controller");
+ }
+ else {
+ this._abortControllerType = AbortController;
+ }
+ }
+ /** @inheritDoc */
+ async send(request) {
+ // Check that abort was not signaled before calling send
+ if (request.abortSignal && request.abortSignal.aborted) {
+ throw new AbortError();
+ }
+ if (!request.method) {
+ throw new Error("No method defined.");
+ }
+ if (!request.url) {
+ throw new Error("No url defined.");
+ }
+ const abortController = new this._abortControllerType();
+ let error;
+ // Hook our abortSignal into the abort controller
+ if (request.abortSignal) {
+ request.abortSignal.onabort = () => {
+ abortController.abort();
+ error = new AbortError();
+ };
+ }
+ // If a timeout has been passed in, setup a timeout to call abort
+ // Type needs to be any to fit window.setTimeout and NodeJS.setTimeout
+ let timeoutId = null;
+ if (request.timeout) {
+ const msTimeout = request.timeout;
+ timeoutId = setTimeout(() => {
+ abortController.abort();
+ this._logger.log(LogLevel.Warning, `Timeout from HTTP request.`);
+ error = new TimeoutError();
+ }, msTimeout);
+ }
+ if (request.content === "") {
+ request.content = undefined;
+ }
+ if (request.content) {
+ // Explicitly setting the Content-Type header for React Native on Android platform.
+ request.headers = request.headers || {};
+ if (isArrayBuffer(request.content)) {
+ request.headers["Content-Type"] = "application/octet-stream";
+ }
+ else {
+ request.headers["Content-Type"] = "text/plain;charset=UTF-8";
+ }
+ }
+ let response;
+ try {
+ response = await this._fetchType(request.url, {
+ body: request.content,
+ cache: "no-cache",
+ credentials: request.withCredentials === true ? "include" : "same-origin",
+ headers: {
+ "X-Requested-With": "XMLHttpRequest",
+ ...request.headers,
+ },
+ method: request.method,
+ mode: "cors",
+ redirect: "follow",
+ signal: abortController.signal,
+ });
+ }
+ catch (e) {
+ if (error) {
+ throw error;
+ }
+ this._logger.log(LogLevel.Warning, `Error from HTTP request. ${e}.`);
+ throw e;
+ }
+ finally {
+ if (timeoutId) {
+ clearTimeout(timeoutId);
+ }
+ if (request.abortSignal) {
+ request.abortSignal.onabort = null;
+ }
+ }
+ if (!response.ok) {
+ const errorMessage = await deserializeContent(response, "text");
+ throw new HttpError(errorMessage || response.statusText, response.status);
+ }
+ const content = deserializeContent(response, request.responseType);
+ const payload = await content;
+ return new HttpResponse(response.status, response.statusText, payload);
+ }
+ getCookieString(url) {
+ let cookies = "";
+ if (Platform.isNode && this._jar) {
+ // @ts-ignore: unused variable
+ this._jar.getCookies(url, (e, c) => cookies = c.join("; "));
+ }
+ return cookies;
+ }
+}
+function deserializeContent(response, responseType) {
+ let content;
+ switch (responseType) {
+ case "arraybuffer":
+ content = response.arrayBuffer();
+ break;
+ case "text":
+ content = response.text();
+ break;
+ case "blob":
+ case "document":
+ case "json":
+ throw new Error(`${responseType} is not supported.`);
+ default:
+ content = response.text();
+ break;
+ }
+ return content;
+}
+
+;// CONCATENATED MODULE: ./src/XhrHttpClient.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+class XhrHttpClient extends HttpClient {
+ constructor(logger) {
+ super();
+ this._logger = logger;
+ }
+ /** @inheritDoc */
+ send(request) {
+ // Check that abort was not signaled before calling send
+ if (request.abortSignal && request.abortSignal.aborted) {
+ return Promise.reject(new AbortError());
+ }
+ if (!request.method) {
+ return Promise.reject(new Error("No method defined."));
+ }
+ if (!request.url) {
+ return Promise.reject(new Error("No url defined."));
+ }
+ return new Promise((resolve, reject) => {
+ const xhr = new XMLHttpRequest();
+ xhr.open(request.method, request.url, true);
+ xhr.withCredentials = request.withCredentials == undefined ? true : request.withCredentials;
+ xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
+ if (request.content === "") {
+ request.content = undefined;
+ }
+ if (request.content) {
+ // Explicitly setting the Content-Type header for React Native on Android platform.
+ if (isArrayBuffer(request.content)) {
+ xhr.setRequestHeader("Content-Type", "application/octet-stream");
+ }
+ else {
+ xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
+ }
+ }
+ const headers = request.headers;
+ if (headers) {
+ Object.keys(headers)
+ .forEach((header) => {
+ xhr.setRequestHeader(header, headers[header]);
+ });
+ }
+ if (request.responseType) {
+ xhr.responseType = request.responseType;
+ }
+ if (request.abortSignal) {
+ request.abortSignal.onabort = () => {
+ xhr.abort();
+ reject(new AbortError());
+ };
+ }
+ if (request.timeout) {
+ xhr.timeout = request.timeout;
+ }
+ xhr.onload = () => {
+ if (request.abortSignal) {
+ request.abortSignal.onabort = null;
+ }
+ if (xhr.status >= 200 && xhr.status < 300) {
+ resolve(new HttpResponse(xhr.status, xhr.statusText, xhr.response || xhr.responseText));
+ }
+ else {
+ reject(new HttpError(xhr.response || xhr.responseText || xhr.statusText, xhr.status));
+ }
+ };
+ xhr.onerror = () => {
+ this._logger.log(LogLevel.Warning, `Error from HTTP request. ${xhr.status}: ${xhr.statusText}.`);
+ reject(new HttpError(xhr.statusText, xhr.status));
+ };
+ xhr.ontimeout = () => {
+ this._logger.log(LogLevel.Warning, `Timeout from HTTP request.`);
+ reject(new TimeoutError());
+ };
+ xhr.send(request.content);
+ });
+ }
+}
+
+;// CONCATENATED MODULE: ./src/DefaultHttpClient.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+
+/** Default implementation of {@link @microsoft/signalr.HttpClient}. */
+class DefaultHttpClient extends HttpClient {
+ /** Creates a new instance of the {@link @microsoft/signalr.DefaultHttpClient}, using the provided {@link @microsoft/signalr.ILogger} to log messages. */
+ constructor(logger) {
+ super();
+ if (typeof fetch !== "undefined" || Platform.isNode) {
+ this._httpClient = new FetchHttpClient(logger);
+ }
+ else if (typeof XMLHttpRequest !== "undefined") {
+ this._httpClient = new XhrHttpClient(logger);
+ }
+ else {
+ throw new Error("No usable HttpClient found.");
+ }
+ }
+ /** @inheritDoc */
+ send(request) {
+ // Check that abort was not signaled before calling send
+ if (request.abortSignal && request.abortSignal.aborted) {
+ return Promise.reject(new AbortError());
+ }
+ if (!request.method) {
+ return Promise.reject(new Error("No method defined."));
+ }
+ if (!request.url) {
+ return Promise.reject(new Error("No url defined."));
+ }
+ return this._httpClient.send(request);
+ }
+ getCookieString(url) {
+ return this._httpClient.getCookieString(url);
+ }
+}
+
+;// CONCATENATED MODULE: ./src/TextMessageFormat.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// Not exported from index
+/** @private */
+class TextMessageFormat {
+ static write(output) {
+ return `${output}${TextMessageFormat.RecordSeparator}`;
+ }
+ static parse(input) {
+ if (input[input.length - 1] !== TextMessageFormat.RecordSeparator) {
+ throw new Error("Message is incomplete.");
+ }
+ const messages = input.split(TextMessageFormat.RecordSeparator);
+ messages.pop();
+ return messages;
+ }
+}
+TextMessageFormat.RecordSeparatorCode = 0x1e;
+TextMessageFormat.RecordSeparator = String.fromCharCode(TextMessageFormat.RecordSeparatorCode);
+
+;// CONCATENATED MODULE: ./src/HandshakeProtocol.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+/** @private */
+class HandshakeProtocol {
+ // Handshake request is always JSON
+ writeHandshakeRequest(handshakeRequest) {
+ return TextMessageFormat.write(JSON.stringify(handshakeRequest));
+ }
+ parseHandshakeResponse(data) {
+ let messageData;
+ let remainingData;
+ if (isArrayBuffer(data)) {
+ // Format is binary but still need to read JSON text from handshake response
+ const binaryData = new Uint8Array(data);
+ const separatorIndex = binaryData.indexOf(TextMessageFormat.RecordSeparatorCode);
+ if (separatorIndex === -1) {
+ throw new Error("Message is incomplete.");
+ }
+ // content before separator is handshake response
+ // optional content after is additional messages
+ const responseLength = separatorIndex + 1;
+ messageData = String.fromCharCode.apply(null, Array.prototype.slice.call(binaryData.slice(0, responseLength)));
+ remainingData = (binaryData.byteLength > responseLength) ? binaryData.slice(responseLength).buffer : null;
+ }
+ else {
+ const textData = data;
+ const separatorIndex = textData.indexOf(TextMessageFormat.RecordSeparator);
+ if (separatorIndex === -1) {
+ throw new Error("Message is incomplete.");
+ }
+ // content before separator is handshake response
+ // optional content after is additional messages
+ const responseLength = separatorIndex + 1;
+ messageData = textData.substring(0, responseLength);
+ remainingData = (textData.length > responseLength) ? textData.substring(responseLength) : null;
+ }
+ // At this point we should have just the single handshake message
+ const messages = TextMessageFormat.parse(messageData);
+ const response = JSON.parse(messages[0]);
+ if (response.type) {
+ throw new Error("Expected a handshake response from the server.");
+ }
+ const responseMessage = response;
+ // multiple messages could have arrived with handshake
+ // return additional data to be parsed as usual, or null if all parsed
+ return [remainingData, responseMessage];
+ }
+}
+
+;// CONCATENATED MODULE: ./src/IHubProtocol.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+/** Defines the type of a Hub Message. */
+var MessageType;
+(function (MessageType) {
+ /** Indicates the message is an Invocation message and implements the {@link @microsoft/signalr.InvocationMessage} interface. */
+ MessageType[MessageType["Invocation"] = 1] = "Invocation";
+ /** Indicates the message is a StreamItem message and implements the {@link @microsoft/signalr.StreamItemMessage} interface. */
+ MessageType[MessageType["StreamItem"] = 2] = "StreamItem";
+ /** Indicates the message is a Completion message and implements the {@link @microsoft/signalr.CompletionMessage} interface. */
+ MessageType[MessageType["Completion"] = 3] = "Completion";
+ /** Indicates the message is a Stream Invocation message and implements the {@link @microsoft/signalr.StreamInvocationMessage} interface. */
+ MessageType[MessageType["StreamInvocation"] = 4] = "StreamInvocation";
+ /** Indicates the message is a Cancel Invocation message and implements the {@link @microsoft/signalr.CancelInvocationMessage} interface. */
+ MessageType[MessageType["CancelInvocation"] = 5] = "CancelInvocation";
+ /** Indicates the message is a Ping message and implements the {@link @microsoft/signalr.PingMessage} interface. */
+ MessageType[MessageType["Ping"] = 6] = "Ping";
+ /** Indicates the message is a Close message and implements the {@link @microsoft/signalr.CloseMessage} interface. */
+ MessageType[MessageType["Close"] = 7] = "Close";
+})(MessageType || (MessageType = {}));
+
+;// CONCATENATED MODULE: ./src/Subject.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+/** Stream implementation to stream items to the server. */
+class Subject {
+ constructor() {
+ this.observers = [];
+ }
+ next(item) {
+ for (const observer of this.observers) {
+ observer.next(item);
+ }
+ }
+ error(err) {
+ for (const observer of this.observers) {
+ if (observer.error) {
+ observer.error(err);
+ }
+ }
+ }
+ complete() {
+ for (const observer of this.observers) {
+ if (observer.complete) {
+ observer.complete();
+ }
+ }
+ }
+ subscribe(observer) {
+ this.observers.push(observer);
+ return new SubjectSubscription(this, observer);
+ }
+}
+
+;// CONCATENATED MODULE: ./src/HubConnection.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+
+
+const DEFAULT_TIMEOUT_IN_MS = 30 * 1000;
+const DEFAULT_PING_INTERVAL_IN_MS = 15 * 1000;
+/** Describes the current state of the {@link HubConnection} to the server. */
+var HubConnectionState;
+(function (HubConnectionState) {
+ /** The hub connection is disconnected. */
+ HubConnectionState["Disconnected"] = "Disconnected";
+ /** The hub connection is connecting. */
+ HubConnectionState["Connecting"] = "Connecting";
+ /** The hub connection is connected. */
+ HubConnectionState["Connected"] = "Connected";
+ /** The hub connection is disconnecting. */
+ HubConnectionState["Disconnecting"] = "Disconnecting";
+ /** The hub connection is reconnecting. */
+ HubConnectionState["Reconnecting"] = "Reconnecting";
+})(HubConnectionState || (HubConnectionState = {}));
+/** Represents a connection to a SignalR Hub. */
+class HubConnection {
+ constructor(connection, logger, protocol, reconnectPolicy) {
+ this._nextKeepAlive = 0;
+ this._freezeEventListener = () => {
+ this._logger.log(LogLevel.Warning, "The page is being frozen, this will likely lead to the connection being closed and messages being lost. For more information see the docs at https://docs.microsoft.com/aspnet/core/signalr/javascript-client#bsleep");
+ };
+ Arg.isRequired(connection, "connection");
+ Arg.isRequired(logger, "logger");
+ Arg.isRequired(protocol, "protocol");
+ this.serverTimeoutInMilliseconds = DEFAULT_TIMEOUT_IN_MS;
+ this.keepAliveIntervalInMilliseconds = DEFAULT_PING_INTERVAL_IN_MS;
+ this._logger = logger;
+ this._protocol = protocol;
+ this.connection = connection;
+ this._reconnectPolicy = reconnectPolicy;
+ this._handshakeProtocol = new HandshakeProtocol();
+ this.connection.onreceive = (data) => this._processIncomingData(data);
+ this.connection.onclose = (error) => this._connectionClosed(error);
+ this._callbacks = {};
+ this._methods = {};
+ this._closedCallbacks = [];
+ this._reconnectingCallbacks = [];
+ this._reconnectedCallbacks = [];
+ this._invocationId = 0;
+ this._receivedHandshakeResponse = false;
+ this._connectionState = HubConnectionState.Disconnected;
+ this._connectionStarted = false;
+ this._cachedPingMessage = this._protocol.writeMessage({ type: MessageType.Ping });
+ }
+ /** @internal */
+ // Using a public static factory method means we can have a private constructor and an _internal_
+ // create method that can be used by HubConnectionBuilder. An "internal" constructor would just
+ // be stripped away and the '.d.ts' file would have no constructor, which is interpreted as a
+ // public parameter-less constructor.
+ static create(connection, logger, protocol, reconnectPolicy) {
+ return new HubConnection(connection, logger, protocol, reconnectPolicy);
+ }
+ /** Indicates the state of the {@link HubConnection} to the server. */
+ get state() {
+ return this._connectionState;
+ }
+ /** Represents the connection id of the {@link HubConnection} on the server. The connection id will be null when the connection is either
+ * in the disconnected state or if the negotiation step was skipped.
+ */
+ get connectionId() {
+ return this.connection ? (this.connection.connectionId || null) : null;
+ }
+ /** Indicates the url of the {@link HubConnection} to the server. */
+ get baseUrl() {
+ return this.connection.baseUrl || "";
+ }
+ /**
+ * Sets a new url for the HubConnection. Note that the url can only be changed when the connection is in either the Disconnected or
+ * Reconnecting states.
+ * @param {string} url The url to connect to.
+ */
+ set baseUrl(url) {
+ if (this._connectionState !== HubConnectionState.Disconnected && this._connectionState !== HubConnectionState.Reconnecting) {
+ throw new Error("The HubConnection must be in the Disconnected or Reconnecting state to change the url.");
+ }
+ if (!url) {
+ throw new Error("The HubConnection url must be a valid url.");
+ }
+ this.connection.baseUrl = url;
+ }
+ /** Starts the connection.
+ *
+ * @returns {Promise} A Promise that resolves when the connection has been successfully established, or rejects with an error.
+ */
+ start() {
+ this._startPromise = this._startWithStateTransitions();
+ return this._startPromise;
+ }
+ async _startWithStateTransitions() {
+ if (this._connectionState !== HubConnectionState.Disconnected) {
+ return Promise.reject(new Error("Cannot start a HubConnection that is not in the 'Disconnected' state."));
+ }
+ this._connectionState = HubConnectionState.Connecting;
+ this._logger.log(LogLevel.Debug, "Starting HubConnection.");
+ try {
+ await this._startInternal();
+ if (Platform.isBrowser) {
+ // Log when the browser freezes the tab so users know why their connection unexpectedly stopped working
+ window.document.addEventListener("freeze", this._freezeEventListener);
+ }
+ this._connectionState = HubConnectionState.Connected;
+ this._connectionStarted = true;
+ this._logger.log(LogLevel.Debug, "HubConnection connected successfully.");
+ }
+ catch (e) {
+ this._connectionState = HubConnectionState.Disconnected;
+ this._logger.log(LogLevel.Debug, `HubConnection failed to start successfully because of error '${e}'.`);
+ return Promise.reject(e);
+ }
+ }
+ async _startInternal() {
+ this._stopDuringStartError = undefined;
+ this._receivedHandshakeResponse = false;
+ // Set up the promise before any connection is (re)started otherwise it could race with received messages
+ const handshakePromise = new Promise((resolve, reject) => {
+ this._handshakeResolver = resolve;
+ this._handshakeRejecter = reject;
+ });
+ await this.connection.start(this._protocol.transferFormat);
+ try {
+ const handshakeRequest = {
+ protocol: this._protocol.name,
+ version: this._protocol.version,
+ };
+ this._logger.log(LogLevel.Debug, "Sending handshake request.");
+ await this._sendMessage(this._handshakeProtocol.writeHandshakeRequest(handshakeRequest));
+ this._logger.log(LogLevel.Information, `Using HubProtocol '${this._protocol.name}'.`);
+ // defensively cleanup timeout in case we receive a message from the server before we finish start
+ this._cleanupTimeout();
+ this._resetTimeoutPeriod();
+ this._resetKeepAliveInterval();
+ await handshakePromise;
+ // It's important to check the stopDuringStartError instead of just relying on the handshakePromise
+ // being rejected on close, because this continuation can run after both the handshake completed successfully
+ // and the connection was closed.
+ if (this._stopDuringStartError) {
+ // It's important to throw instead of returning a rejected promise, because we don't want to allow any state
+ // transitions to occur between now and the calling code observing the exceptions. Returning a rejected promise
+ // will cause the calling continuation to get scheduled to run later.
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
+ throw this._stopDuringStartError;
+ }
+ if (!this.connection.features.inherentKeepAlive) {
+ await this._sendMessage(this._cachedPingMessage);
+ }
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Debug, `Hub handshake failed with error '${e}' during start(). Stopping HubConnection.`);
+ this._cleanupTimeout();
+ this._cleanupPingTimer();
+ // HttpConnection.stop() should not complete until after the onclose callback is invoked.
+ // This will transition the HubConnection to the disconnected state before HttpConnection.stop() completes.
+ await this.connection.stop(e);
+ throw e;
+ }
+ }
+ /** Stops the connection.
+ *
+ * @returns {Promise} A Promise that resolves when the connection has been successfully terminated, or rejects with an error.
+ */
+ async stop() {
+ // Capture the start promise before the connection might be restarted in an onclose callback.
+ const startPromise = this._startPromise;
+ this._stopPromise = this._stopInternal();
+ await this._stopPromise;
+ try {
+ // Awaiting undefined continues immediately
+ await startPromise;
+ }
+ catch (e) {
+ // This exception is returned to the user as a rejected Promise from the start method.
+ }
+ }
+ _stopInternal(error) {
+ if (this._connectionState === HubConnectionState.Disconnected) {
+ this._logger.log(LogLevel.Debug, `Call to HubConnection.stop(${error}) ignored because it is already in the disconnected state.`);
+ return Promise.resolve();
+ }
+ if (this._connectionState === HubConnectionState.Disconnecting) {
+ this._logger.log(LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnecting state.`);
+ return this._stopPromise;
+ }
+ this._connectionState = HubConnectionState.Disconnecting;
+ this._logger.log(LogLevel.Debug, "Stopping HubConnection.");
+ if (this._reconnectDelayHandle) {
+ // We're in a reconnect delay which means the underlying connection is currently already stopped.
+ // Just clear the handle to stop the reconnect loop (which no one is waiting on thankfully) and
+ // fire the onclose callbacks.
+ this._logger.log(LogLevel.Debug, "Connection stopped during reconnect delay. Done reconnecting.");
+ clearTimeout(this._reconnectDelayHandle);
+ this._reconnectDelayHandle = undefined;
+ this._completeClose();
+ return Promise.resolve();
+ }
+ this._cleanupTimeout();
+ this._cleanupPingTimer();
+ this._stopDuringStartError = error || new AbortError("The connection was stopped before the hub handshake could complete.");
+ // HttpConnection.stop() should not complete until after either HttpConnection.start() fails
+ // or the onclose callback is invoked. The onclose callback will transition the HubConnection
+ // to the disconnected state if need be before HttpConnection.stop() completes.
+ return this.connection.stop(error);
+ }
+ /** Invokes a streaming hub method on the server using the specified name and arguments.
+ *
+ * @typeparam T The type of the items returned by the server.
+ * @param {string} methodName The name of the server method to invoke.
+ * @param {any[]} args The arguments used to invoke the server method.
+ * @returns {IStreamResult} An object that yields results from the server as they are received.
+ */
+ stream(methodName, ...args) {
+ const [streams, streamIds] = this._replaceStreamingParams(args);
+ const invocationDescriptor = this._createStreamInvocation(methodName, args, streamIds);
+ // eslint-disable-next-line prefer-const
+ let promiseQueue;
+ const subject = new Subject();
+ subject.cancelCallback = () => {
+ const cancelInvocation = this._createCancelInvocation(invocationDescriptor.invocationId);
+ delete this._callbacks[invocationDescriptor.invocationId];
+ return promiseQueue.then(() => {
+ return this._sendWithProtocol(cancelInvocation);
+ });
+ };
+ this._callbacks[invocationDescriptor.invocationId] = (invocationEvent, error) => {
+ if (error) {
+ subject.error(error);
+ return;
+ }
+ else if (invocationEvent) {
+ // invocationEvent will not be null when an error is not passed to the callback
+ if (invocationEvent.type === MessageType.Completion) {
+ if (invocationEvent.error) {
+ subject.error(new Error(invocationEvent.error));
+ }
+ else {
+ subject.complete();
+ }
+ }
+ else {
+ subject.next((invocationEvent.item));
+ }
+ }
+ };
+ promiseQueue = this._sendWithProtocol(invocationDescriptor)
+ .catch((e) => {
+ subject.error(e);
+ delete this._callbacks[invocationDescriptor.invocationId];
+ });
+ this._launchStreams(streams, promiseQueue);
+ return subject;
+ }
+ _sendMessage(message) {
+ this._resetKeepAliveInterval();
+ return this.connection.send(message);
+ }
+ /**
+ * Sends a js object to the server.
+ * @param message The js object to serialize and send.
+ */
+ _sendWithProtocol(message) {
+ return this._sendMessage(this._protocol.writeMessage(message));
+ }
+ /** Invokes a hub method on the server using the specified name and arguments. Does not wait for a response from the receiver.
+ *
+ * The Promise returned by this method resolves when the client has sent the invocation to the server. The server may still
+ * be processing the invocation.
+ *
+ * @param {string} methodName The name of the server method to invoke.
+ * @param {any[]} args The arguments used to invoke the server method.
+ * @returns {Promise} A Promise that resolves when the invocation has been successfully sent, or rejects with an error.
+ */
+ send(methodName, ...args) {
+ const [streams, streamIds] = this._replaceStreamingParams(args);
+ const sendPromise = this._sendWithProtocol(this._createInvocation(methodName, args, true, streamIds));
+ this._launchStreams(streams, sendPromise);
+ return sendPromise;
+ }
+ /** Invokes a hub method on the server using the specified name and arguments.
+ *
+ * The Promise returned by this method resolves when the server indicates it has finished invoking the method. When the promise
+ * resolves, the server has finished invoking the method. If the server method returns a result, it is produced as the result of
+ * resolving the Promise.
+ *
+ * @typeparam T The expected return type.
+ * @param {string} methodName The name of the server method to invoke.
+ * @param {any[]} args The arguments used to invoke the server method.
+ * @returns {Promise} A Promise that resolves with the result of the server method (if any), or rejects with an error.
+ */
+ invoke(methodName, ...args) {
+ const [streams, streamIds] = this._replaceStreamingParams(args);
+ const invocationDescriptor = this._createInvocation(methodName, args, false, streamIds);
+ const p = new Promise((resolve, reject) => {
+ // invocationId will always have a value for a non-blocking invocation
+ this._callbacks[invocationDescriptor.invocationId] = (invocationEvent, error) => {
+ if (error) {
+ reject(error);
+ return;
+ }
+ else if (invocationEvent) {
+ // invocationEvent will not be null when an error is not passed to the callback
+ if (invocationEvent.type === MessageType.Completion) {
+ if (invocationEvent.error) {
+ reject(new Error(invocationEvent.error));
+ }
+ else {
+ resolve(invocationEvent.result);
+ }
+ }
+ else {
+ reject(new Error(`Unexpected message type: ${invocationEvent.type}`));
+ }
+ }
+ };
+ const promiseQueue = this._sendWithProtocol(invocationDescriptor)
+ .catch((e) => {
+ reject(e);
+ // invocationId will always have a value for a non-blocking invocation
+ delete this._callbacks[invocationDescriptor.invocationId];
+ });
+ this._launchStreams(streams, promiseQueue);
+ });
+ return p;
+ }
+ on(methodName, newMethod) {
+ if (!methodName || !newMethod) {
+ return;
+ }
+ methodName = methodName.toLowerCase();
+ if (!this._methods[methodName]) {
+ this._methods[methodName] = [];
+ }
+ // Preventing adding the same handler multiple times.
+ if (this._methods[methodName].indexOf(newMethod) !== -1) {
+ return;
+ }
+ this._methods[methodName].push(newMethod);
+ }
+ off(methodName, method) {
+ if (!methodName) {
+ return;
+ }
+ methodName = methodName.toLowerCase();
+ const handlers = this._methods[methodName];
+ if (!handlers) {
+ return;
+ }
+ if (method) {
+ const removeIdx = handlers.indexOf(method);
+ if (removeIdx !== -1) {
+ handlers.splice(removeIdx, 1);
+ if (handlers.length === 0) {
+ delete this._methods[methodName];
+ }
+ }
+ }
+ else {
+ delete this._methods[methodName];
+ }
+ }
+ /** Registers a handler that will be invoked when the connection is closed.
+ *
+ * @param {Function} callback The handler that will be invoked when the connection is closed. Optionally receives a single argument containing the error that caused the connection to close (if any).
+ */
+ onclose(callback) {
+ if (callback) {
+ this._closedCallbacks.push(callback);
+ }
+ }
+ /** Registers a handler that will be invoked when the connection starts reconnecting.
+ *
+ * @param {Function} callback The handler that will be invoked when the connection starts reconnecting. Optionally receives a single argument containing the error that caused the connection to start reconnecting (if any).
+ */
+ onreconnecting(callback) {
+ if (callback) {
+ this._reconnectingCallbacks.push(callback);
+ }
+ }
+ /** Registers a handler that will be invoked when the connection successfully reconnects.
+ *
+ * @param {Function} callback The handler that will be invoked when the connection successfully reconnects.
+ */
+ onreconnected(callback) {
+ if (callback) {
+ this._reconnectedCallbacks.push(callback);
+ }
+ }
+ _processIncomingData(data) {
+ this._cleanupTimeout();
+ if (!this._receivedHandshakeResponse) {
+ data = this._processHandshakeResponse(data);
+ this._receivedHandshakeResponse = true;
+ }
+ // Data may have all been read when processing handshake response
+ if (data) {
+ // Parse the messages
+ const messages = this._protocol.parseMessages(data, this._logger);
+ for (const message of messages) {
+ switch (message.type) {
+ case MessageType.Invocation:
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
+ this._invokeClientMethod(message);
+ break;
+ case MessageType.StreamItem:
+ case MessageType.Completion: {
+ const callback = this._callbacks[message.invocationId];
+ if (callback) {
+ if (message.type === MessageType.Completion) {
+ delete this._callbacks[message.invocationId];
+ }
+ try {
+ callback(message);
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `Stream callback threw error: ${getErrorString(e)}`);
+ }
+ }
+ break;
+ }
+ case MessageType.Ping:
+ // Don't care about pings
+ break;
+ case MessageType.Close: {
+ this._logger.log(LogLevel.Information, "Close message received from server.");
+ const error = message.error ? new Error("Server returned an error on close: " + message.error) : undefined;
+ if (message.allowReconnect === true) {
+ // It feels wrong not to await connection.stop() here, but processIncomingData is called as part of an onreceive callback which is not async,
+ // this is already the behavior for serverTimeout(), and HttpConnection.Stop() should catch and log all possible exceptions.
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
+ this.connection.stop(error);
+ }
+ else {
+ // We cannot await stopInternal() here, but subsequent calls to stop() will await this if stopInternal() is still ongoing.
+ this._stopPromise = this._stopInternal(error);
+ }
+ break;
+ }
+ default:
+ this._logger.log(LogLevel.Warning, `Invalid message type: ${message.type}.`);
+ break;
+ }
+ }
+ }
+ this._resetTimeoutPeriod();
+ }
+ _processHandshakeResponse(data) {
+ let responseMessage;
+ let remainingData;
+ try {
+ [remainingData, responseMessage] = this._handshakeProtocol.parseHandshakeResponse(data);
+ }
+ catch (e) {
+ const message = "Error parsing handshake response: " + e;
+ this._logger.log(LogLevel.Error, message);
+ const error = new Error(message);
+ this._handshakeRejecter(error);
+ throw error;
+ }
+ if (responseMessage.error) {
+ const message = "Server returned handshake error: " + responseMessage.error;
+ this._logger.log(LogLevel.Error, message);
+ const error = new Error(message);
+ this._handshakeRejecter(error);
+ throw error;
+ }
+ else {
+ this._logger.log(LogLevel.Debug, "Server handshake complete.");
+ }
+ this._handshakeResolver();
+ return remainingData;
+ }
+ _resetKeepAliveInterval() {
+ if (this.connection.features.inherentKeepAlive) {
+ return;
+ }
+ // Set the time we want the next keep alive to be sent
+ // Timer will be setup on next message receive
+ this._nextKeepAlive = new Date().getTime() + this.keepAliveIntervalInMilliseconds;
+ this._cleanupPingTimer();
+ }
+ _resetTimeoutPeriod() {
+ if (!this.connection.features || !this.connection.features.inherentKeepAlive) {
+ // Set the timeout timer
+ this._timeoutHandle = setTimeout(() => this.serverTimeout(), this.serverTimeoutInMilliseconds);
+ // Set keepAlive timer if there isn't one
+ if (this._pingServerHandle == undefined) {
+ let nextPing = this._nextKeepAlive - new Date().getTime();
+ if (nextPing < 0) {
+ nextPing = 0;
+ }
+ // The timer needs to be set from a networking callback to avoid Chrome timer throttling from causing timers to run once a minute
+ this._pingServerHandle = setTimeout(async () => {
+ if (this._connectionState === HubConnectionState.Connected) {
+ try {
+ await this._sendMessage(this._cachedPingMessage);
+ }
+ catch {
+ // We don't care about the error. It should be seen elsewhere in the client.
+ // The connection is probably in a bad or closed state now, cleanup the timer so it stops triggering
+ this._cleanupPingTimer();
+ }
+ }
+ }, nextPing);
+ }
+ }
+ }
+ // eslint-disable-next-line @typescript-eslint/naming-convention
+ serverTimeout() {
+ // The server hasn't talked to us in a while. It doesn't like us anymore ... :(
+ // Terminate the connection, but we don't need to wait on the promise. This could trigger reconnecting.
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
+ this.connection.stop(new Error("Server timeout elapsed without receiving a message from the server."));
+ }
+ async _invokeClientMethod(invocationMessage) {
+ const methodName = invocationMessage.target.toLowerCase();
+ const methods = this._methods[methodName];
+ if (!methods) {
+ this._logger.log(LogLevel.Warning, `No client method with the name '${methodName}' found.`);
+ // No handlers provided by client but the server is expecting a response still, so we send an error
+ if (invocationMessage.invocationId) {
+ this._logger.log(LogLevel.Warning, `No result given for '${methodName}' method and invocation ID '${invocationMessage.invocationId}'.`);
+ await this._sendWithProtocol(this._createCompletionMessage(invocationMessage.invocationId, "Client didn't provide a result.", null));
+ }
+ return;
+ }
+ // Avoid issues with handlers removing themselves thus modifying the list while iterating through it
+ const methodsCopy = methods.slice();
+ // Server expects a response
+ const expectsResponse = invocationMessage.invocationId ? true : false;
+ // We preserve the last result or exception but still call all handlers
+ let res;
+ let exception;
+ let completionMessage;
+ for (const m of methodsCopy) {
+ try {
+ const prevRes = res;
+ res = await m.apply(this, invocationMessage.arguments);
+ if (expectsResponse && res && prevRes) {
+ this._logger.log(LogLevel.Error, `Multiple results provided for '${methodName}'. Sending error to server.`);
+ completionMessage = this._createCompletionMessage(invocationMessage.invocationId, `Client provided multiple results.`, null);
+ }
+ // Ignore exception if we got a result after, the exception will be logged
+ exception = undefined;
+ }
+ catch (e) {
+ exception = e;
+ this._logger.log(LogLevel.Error, `A callback for the method '${methodName}' threw error '${e}'.`);
+ }
+ }
+ if (completionMessage) {
+ await this._sendWithProtocol(completionMessage);
+ }
+ else if (expectsResponse) {
+ // If there is an exception that means either no result was given or a handler after a result threw
+ if (exception) {
+ completionMessage = this._createCompletionMessage(invocationMessage.invocationId, `${exception}`, null);
+ }
+ else if (res != undefined) {
+ completionMessage = this._createCompletionMessage(invocationMessage.invocationId, null, res);
+ }
+ else {
+ this._logger.log(LogLevel.Warning, `No result given for '${methodName}' method and invocation ID '${invocationMessage.invocationId}'.`);
+ // Client didn't provide a result or throw from a handler, server expects a response so we send an error
+ completionMessage = this._createCompletionMessage(invocationMessage.invocationId, "Client didn't provide a result.", null);
+ }
+ await this._sendWithProtocol(completionMessage);
+ }
+ else {
+ if (res) {
+ this._logger.log(LogLevel.Error, `Result given for '${methodName}' method but server is not expecting a result.`);
+ }
+ }
+ }
+ _connectionClosed(error) {
+ this._logger.log(LogLevel.Debug, `HubConnection.connectionClosed(${error}) called while in state ${this._connectionState}.`);
+ // Triggering this.handshakeRejecter is insufficient because it could already be resolved without the continuation having run yet.
+ this._stopDuringStartError = this._stopDuringStartError || error || new AbortError("The underlying connection was closed before the hub handshake could complete.");
+ // If the handshake is in progress, start will be waiting for the handshake promise, so we complete it.
+ // If it has already completed, this should just noop.
+ if (this._handshakeResolver) {
+ this._handshakeResolver();
+ }
+ this._cancelCallbacksWithError(error || new Error("Invocation canceled due to the underlying connection being closed."));
+ this._cleanupTimeout();
+ this._cleanupPingTimer();
+ if (this._connectionState === HubConnectionState.Disconnecting) {
+ this._completeClose(error);
+ }
+ else if (this._connectionState === HubConnectionState.Connected && this._reconnectPolicy) {
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
+ this._reconnect(error);
+ }
+ else if (this._connectionState === HubConnectionState.Connected) {
+ this._completeClose(error);
+ }
+ // If none of the above if conditions were true were called the HubConnection must be in either:
+ // 1. The Connecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail it.
+ // 2. The Reconnecting state in which case the handshakeResolver will complete it and stopDuringStartError will fail the current reconnect attempt
+ // and potentially continue the reconnect() loop.
+ // 3. The Disconnected state in which case we're already done.
+ }
+ _completeClose(error) {
+ if (this._connectionStarted) {
+ this._connectionState = HubConnectionState.Disconnected;
+ this._connectionStarted = false;
+ if (Platform.isBrowser) {
+ window.document.removeEventListener("freeze", this._freezeEventListener);
+ }
+ try {
+ this._closedCallbacks.forEach((c) => c.apply(this, [error]));
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `An onclose callback called with error '${error}' threw error '${e}'.`);
+ }
+ }
+ }
+ async _reconnect(error) {
+ const reconnectStartTime = Date.now();
+ let previousReconnectAttempts = 0;
+ let retryError = error != undefined ? error : new Error("Attempting to reconnect due to a unknown error.");
+ let nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, 0, retryError);
+ if (nextRetryDelay == undefined) {
+ this._logger.log(LogLevel.Debug, "Connection not reconnecting because the IRetryPolicy returned null on the first reconnect attempt.");
+ this._completeClose(error);
+ return;
+ }
+ this._connectionState = HubConnectionState.Reconnecting;
+ if (error) {
+ this._logger.log(LogLevel.Information, `Connection reconnecting because of error '${error}'.`);
+ }
+ else {
+ this._logger.log(LogLevel.Information, "Connection reconnecting.");
+ }
+ if (this._reconnectingCallbacks.length !== 0) {
+ try {
+ this._reconnectingCallbacks.forEach((c) => c.apply(this, [error]));
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `An onreconnecting callback called with error '${error}' threw error '${e}'.`);
+ }
+ // Exit early if an onreconnecting callback called connection.stop().
+ if (this._connectionState !== HubConnectionState.Reconnecting) {
+ this._logger.log(LogLevel.Debug, "Connection left the reconnecting state in onreconnecting callback. Done reconnecting.");
+ return;
+ }
+ }
+ while (nextRetryDelay != undefined) {
+ this._logger.log(LogLevel.Information, `Reconnect attempt number ${previousReconnectAttempts} will start in ${nextRetryDelay} ms.`);
+ await new Promise((resolve) => {
+ this._reconnectDelayHandle = setTimeout(resolve, nextRetryDelay);
+ });
+ this._reconnectDelayHandle = undefined;
+ if (this._connectionState !== HubConnectionState.Reconnecting) {
+ this._logger.log(LogLevel.Debug, "Connection left the reconnecting state during reconnect delay. Done reconnecting.");
+ return;
+ }
+ try {
+ await this._startInternal();
+ this._connectionState = HubConnectionState.Connected;
+ this._logger.log(LogLevel.Information, "HubConnection reconnected successfully.");
+ if (this._reconnectedCallbacks.length !== 0) {
+ try {
+ this._reconnectedCallbacks.forEach((c) => c.apply(this, [this.connection.connectionId]));
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `An onreconnected callback called with connectionId '${this.connection.connectionId}; threw error '${e}'.`);
+ }
+ }
+ return;
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Information, `Reconnect attempt failed because of error '${e}'.`);
+ if (this._connectionState !== HubConnectionState.Reconnecting) {
+ this._logger.log(LogLevel.Debug, `Connection moved to the '${this._connectionState}' from the reconnecting state during reconnect attempt. Done reconnecting.`);
+ // The TypeScript compiler thinks that connectionState must be Connected here. The TypeScript compiler is wrong.
+ if (this._connectionState === HubConnectionState.Disconnecting) {
+ this._completeClose();
+ }
+ return;
+ }
+ retryError = e instanceof Error ? e : new Error(e.toString());
+ nextRetryDelay = this._getNextRetryDelay(previousReconnectAttempts++, Date.now() - reconnectStartTime, retryError);
+ }
+ }
+ this._logger.log(LogLevel.Information, `Reconnect retries have been exhausted after ${Date.now() - reconnectStartTime} ms and ${previousReconnectAttempts} failed attempts. Connection disconnecting.`);
+ this._completeClose();
+ }
+ _getNextRetryDelay(previousRetryCount, elapsedMilliseconds, retryReason) {
+ try {
+ return this._reconnectPolicy.nextRetryDelayInMilliseconds({
+ elapsedMilliseconds,
+ previousRetryCount,
+ retryReason,
+ });
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `IRetryPolicy.nextRetryDelayInMilliseconds(${previousRetryCount}, ${elapsedMilliseconds}) threw error '${e}'.`);
+ return null;
+ }
+ }
+ _cancelCallbacksWithError(error) {
+ const callbacks = this._callbacks;
+ this._callbacks = {};
+ Object.keys(callbacks)
+ .forEach((key) => {
+ const callback = callbacks[key];
+ try {
+ callback(null, error);
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `Stream 'error' callback called with '${error}' threw error: ${getErrorString(e)}`);
+ }
+ });
+ }
+ _cleanupPingTimer() {
+ if (this._pingServerHandle) {
+ clearTimeout(this._pingServerHandle);
+ this._pingServerHandle = undefined;
+ }
+ }
+ _cleanupTimeout() {
+ if (this._timeoutHandle) {
+ clearTimeout(this._timeoutHandle);
+ }
+ }
+ _createInvocation(methodName, args, nonblocking, streamIds) {
+ if (nonblocking) {
+ if (streamIds.length !== 0) {
+ return {
+ arguments: args,
+ streamIds,
+ target: methodName,
+ type: MessageType.Invocation,
+ };
+ }
+ else {
+ return {
+ arguments: args,
+ target: methodName,
+ type: MessageType.Invocation,
+ };
+ }
+ }
+ else {
+ const invocationId = this._invocationId;
+ this._invocationId++;
+ if (streamIds.length !== 0) {
+ return {
+ arguments: args,
+ invocationId: invocationId.toString(),
+ streamIds,
+ target: methodName,
+ type: MessageType.Invocation,
+ };
+ }
+ else {
+ return {
+ arguments: args,
+ invocationId: invocationId.toString(),
+ target: methodName,
+ type: MessageType.Invocation,
+ };
+ }
+ }
+ }
+ _launchStreams(streams, promiseQueue) {
+ if (streams.length === 0) {
+ return;
+ }
+ // Synchronize stream data so they arrive in-order on the server
+ if (!promiseQueue) {
+ promiseQueue = Promise.resolve();
+ }
+ // We want to iterate over the keys, since the keys are the stream ids
+ // eslint-disable-next-line guard-for-in
+ for (const streamId in streams) {
+ streams[streamId].subscribe({
+ complete: () => {
+ promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createCompletionMessage(streamId)));
+ },
+ error: (err) => {
+ let message;
+ if (err instanceof Error) {
+ message = err.message;
+ }
+ else if (err && err.toString) {
+ message = err.toString();
+ }
+ else {
+ message = "Unknown error";
+ }
+ promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createCompletionMessage(streamId, message)));
+ },
+ next: (item) => {
+ promiseQueue = promiseQueue.then(() => this._sendWithProtocol(this._createStreamItemMessage(streamId, item)));
+ },
+ });
+ }
+ }
+ _replaceStreamingParams(args) {
+ const streams = [];
+ const streamIds = [];
+ for (let i = 0; i < args.length; i++) {
+ const argument = args[i];
+ if (this._isObservable(argument)) {
+ const streamId = this._invocationId;
+ this._invocationId++;
+ // Store the stream for later use
+ streams[streamId] = argument;
+ streamIds.push(streamId.toString());
+ // remove stream from args
+ args.splice(i, 1);
+ }
+ }
+ return [streams, streamIds];
+ }
+ _isObservable(arg) {
+ // This allows other stream implementations to just work (like rxjs)
+ return arg && arg.subscribe && typeof arg.subscribe === "function";
+ }
+ _createStreamInvocation(methodName, args, streamIds) {
+ const invocationId = this._invocationId;
+ this._invocationId++;
+ if (streamIds.length !== 0) {
+ return {
+ arguments: args,
+ invocationId: invocationId.toString(),
+ streamIds,
+ target: methodName,
+ type: MessageType.StreamInvocation,
+ };
+ }
+ else {
+ return {
+ arguments: args,
+ invocationId: invocationId.toString(),
+ target: methodName,
+ type: MessageType.StreamInvocation,
+ };
+ }
+ }
+ _createCancelInvocation(id) {
+ return {
+ invocationId: id,
+ type: MessageType.CancelInvocation,
+ };
+ }
+ _createStreamItemMessage(id, item) {
+ return {
+ invocationId: id,
+ item,
+ type: MessageType.StreamItem,
+ };
+ }
+ _createCompletionMessage(id, error, result) {
+ if (error) {
+ return {
+ error,
+ invocationId: id,
+ type: MessageType.Completion,
+ };
+ }
+ return {
+ invocationId: id,
+ result,
+ type: MessageType.Completion,
+ };
+ }
+}
+
+;// CONCATENATED MODULE: ./src/DefaultReconnectPolicy.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// 0, 2, 10, 30 second delays before reconnect attempts.
+const DEFAULT_RETRY_DELAYS_IN_MILLISECONDS = [0, 2000, 10000, 30000, null];
+/** @private */
+class DefaultReconnectPolicy {
+ constructor(retryDelays) {
+ this._retryDelays = retryDelays != undefined ? [...retryDelays, null] : DEFAULT_RETRY_DELAYS_IN_MILLISECONDS;
+ }
+ nextRetryDelayInMilliseconds(retryContext) {
+ return this._retryDelays[retryContext.previousRetryCount];
+ }
+}
+
+;// CONCATENATED MODULE: ./src/HeaderNames.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+class HeaderNames {
+}
+HeaderNames.Authorization = "Authorization";
+HeaderNames.Cookie = "Cookie";
+
+;// CONCATENATED MODULE: ./src/AccessTokenHttpClient.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+/** @private */
+class AccessTokenHttpClient extends HttpClient {
+ constructor(innerClient, accessTokenFactory) {
+ super();
+ this._innerClient = innerClient;
+ this._accessTokenFactory = accessTokenFactory;
+ }
+ async send(request) {
+ let allowRetry = true;
+ if (this._accessTokenFactory && (!this._accessToken || (request.url && request.url.indexOf("/negotiate?") > 0))) {
+ // don't retry if the request is a negotiate or if we just got a potentially new token from the access token factory
+ allowRetry = false;
+ this._accessToken = await this._accessTokenFactory();
+ }
+ this._setAuthorizationHeader(request);
+ const response = await this._innerClient.send(request);
+ if (allowRetry && response.statusCode === 401 && this._accessTokenFactory) {
+ this._accessToken = await this._accessTokenFactory();
+ this._setAuthorizationHeader(request);
+ return await this._innerClient.send(request);
+ }
+ return response;
+ }
+ _setAuthorizationHeader(request) {
+ if (!request.headers) {
+ request.headers = {};
+ }
+ if (this._accessToken) {
+ request.headers[HeaderNames.Authorization] = `Bearer ${this._accessToken}`;
+ }
+ // don't remove the header if there isn't an access token factory, the user manually added the header in this case
+ else if (this._accessTokenFactory) {
+ if (request.headers[HeaderNames.Authorization]) {
+ delete request.headers[HeaderNames.Authorization];
+ }
+ }
+ }
+ getCookieString(url) {
+ return this._innerClient.getCookieString(url);
+ }
+}
+
+;// CONCATENATED MODULE: ./src/ITransport.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// This will be treated as a bit flag in the future, so we keep it using power-of-two values.
+/** Specifies a specific HTTP transport type. */
+var HttpTransportType;
+(function (HttpTransportType) {
+ /** Specifies no transport preference. */
+ HttpTransportType[HttpTransportType["None"] = 0] = "None";
+ /** Specifies the WebSockets transport. */
+ HttpTransportType[HttpTransportType["WebSockets"] = 1] = "WebSockets";
+ /** Specifies the Server-Sent Events transport. */
+ HttpTransportType[HttpTransportType["ServerSentEvents"] = 2] = "ServerSentEvents";
+ /** Specifies the Long Polling transport. */
+ HttpTransportType[HttpTransportType["LongPolling"] = 4] = "LongPolling";
+})(HttpTransportType || (HttpTransportType = {}));
+/** Specifies the transfer format for a connection. */
+var TransferFormat;
+(function (TransferFormat) {
+ /** Specifies that only text data will be transmitted over the connection. */
+ TransferFormat[TransferFormat["Text"] = 1] = "Text";
+ /** Specifies that binary data will be transmitted over the connection. */
+ TransferFormat[TransferFormat["Binary"] = 2] = "Binary";
+})(TransferFormat || (TransferFormat = {}));
+
+;// CONCATENATED MODULE: ./src/AbortController.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// Rough polyfill of https://developer.mozilla.org/en-US/docs/Web/API/AbortController
+// We don't actually ever use the API being polyfilled, we always use the polyfill because
+// it's a very new API right now.
+// Not exported from index.
+/** @private */
+class AbortController_AbortController {
+ constructor() {
+ this._isAborted = false;
+ this.onabort = null;
+ }
+ abort() {
+ if (!this._isAborted) {
+ this._isAborted = true;
+ if (this.onabort) {
+ this.onabort();
+ }
+ }
+ }
+ get signal() {
+ return this;
+ }
+ get aborted() {
+ return this._isAborted;
+ }
+}
+
+;// CONCATENATED MODULE: ./src/LongPollingTransport.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+
+// Not exported from 'index', this type is internal.
+/** @private */
+class LongPollingTransport {
+ constructor(httpClient, logger, options) {
+ this._httpClient = httpClient;
+ this._logger = logger;
+ this._pollAbort = new AbortController_AbortController();
+ this._options = options;
+ this._running = false;
+ this.onreceive = null;
+ this.onclose = null;
+ }
+ // This is an internal type, not exported from 'index' so this is really just internal.
+ get pollAborted() {
+ return this._pollAbort.aborted;
+ }
+ async connect(url, transferFormat) {
+ Arg.isRequired(url, "url");
+ Arg.isRequired(transferFormat, "transferFormat");
+ Arg.isIn(transferFormat, TransferFormat, "transferFormat");
+ this._url = url;
+ this._logger.log(LogLevel.Trace, "(LongPolling transport) Connecting.");
+ // Allow binary format on Node and Browsers that support binary content (indicated by the presence of responseType property)
+ if (transferFormat === TransferFormat.Binary &&
+ (typeof XMLHttpRequest !== "undefined" && typeof new XMLHttpRequest().responseType !== "string")) {
+ throw new Error("Binary protocols over XmlHttpRequest not implementing advanced features are not supported.");
+ }
+ const [name, value] = getUserAgentHeader();
+ const headers = { [name]: value, ...this._options.headers };
+ const pollOptions = {
+ abortSignal: this._pollAbort.signal,
+ headers,
+ timeout: 100000,
+ withCredentials: this._options.withCredentials,
+ };
+ if (transferFormat === TransferFormat.Binary) {
+ pollOptions.responseType = "arraybuffer";
+ }
+ // Make initial long polling request
+ // Server uses first long polling request to finish initializing connection and it returns without data
+ const pollUrl = `${url}&_=${Date.now()}`;
+ this._logger.log(LogLevel.Trace, `(LongPolling transport) polling: ${pollUrl}.`);
+ const response = await this._httpClient.get(pollUrl, pollOptions);
+ if (response.statusCode !== 200) {
+ this._logger.log(LogLevel.Error, `(LongPolling transport) Unexpected response code: ${response.statusCode}.`);
+ // Mark running as false so that the poll immediately ends and runs the close logic
+ this._closeError = new HttpError(response.statusText || "", response.statusCode);
+ this._running = false;
+ }
+ else {
+ this._running = true;
+ }
+ this._receiving = this._poll(this._url, pollOptions);
+ }
+ async _poll(url, pollOptions) {
+ try {
+ while (this._running) {
+ try {
+ const pollUrl = `${url}&_=${Date.now()}`;
+ this._logger.log(LogLevel.Trace, `(LongPolling transport) polling: ${pollUrl}.`);
+ const response = await this._httpClient.get(pollUrl, pollOptions);
+ if (response.statusCode === 204) {
+ this._logger.log(LogLevel.Information, "(LongPolling transport) Poll terminated by server.");
+ this._running = false;
+ }
+ else if (response.statusCode !== 200) {
+ this._logger.log(LogLevel.Error, `(LongPolling transport) Unexpected response code: ${response.statusCode}.`);
+ // Unexpected status code
+ this._closeError = new HttpError(response.statusText || "", response.statusCode);
+ this._running = false;
+ }
+ else {
+ // Process the response
+ if (response.content) {
+ this._logger.log(LogLevel.Trace, `(LongPolling transport) data received. ${getDataDetail(response.content, this._options.logMessageContent)}.`);
+ if (this.onreceive) {
+ this.onreceive(response.content);
+ }
+ }
+ else {
+ // This is another way timeout manifest.
+ this._logger.log(LogLevel.Trace, "(LongPolling transport) Poll timed out, reissuing.");
+ }
+ }
+ }
+ catch (e) {
+ if (!this._running) {
+ // Log but disregard errors that occur after stopping
+ this._logger.log(LogLevel.Trace, `(LongPolling transport) Poll errored after shutdown: ${e.message}`);
+ }
+ else {
+ if (e instanceof TimeoutError) {
+ // Ignore timeouts and reissue the poll.
+ this._logger.log(LogLevel.Trace, "(LongPolling transport) Poll timed out, reissuing.");
+ }
+ else {
+ // Close the connection with the error as the result.
+ this._closeError = e;
+ this._running = false;
+ }
+ }
+ }
+ }
+ }
+ finally {
+ this._logger.log(LogLevel.Trace, "(LongPolling transport) Polling complete.");
+ // We will reach here with pollAborted==false when the server returned a response causing the transport to stop.
+ // If pollAborted==true then client initiated the stop and the stop method will raise the close event after DELETE is sent.
+ if (!this.pollAborted) {
+ this._raiseOnClose();
+ }
+ }
+ }
+ async send(data) {
+ if (!this._running) {
+ return Promise.reject(new Error("Cannot send until the transport is connected"));
+ }
+ return sendMessage(this._logger, "LongPolling", this._httpClient, this._url, data, this._options);
+ }
+ async stop() {
+ this._logger.log(LogLevel.Trace, "(LongPolling transport) Stopping polling.");
+ // Tell receiving loop to stop, abort any current request, and then wait for it to finish
+ this._running = false;
+ this._pollAbort.abort();
+ try {
+ await this._receiving;
+ // Send DELETE to clean up long polling on the server
+ this._logger.log(LogLevel.Trace, `(LongPolling transport) sending DELETE request to ${this._url}.`);
+ const headers = {};
+ const [name, value] = getUserAgentHeader();
+ headers[name] = value;
+ const deleteOptions = {
+ headers: { ...headers, ...this._options.headers },
+ timeout: this._options.timeout,
+ withCredentials: this._options.withCredentials,
+ };
+ await this._httpClient.delete(this._url, deleteOptions);
+ this._logger.log(LogLevel.Trace, "(LongPolling transport) DELETE request sent.");
+ }
+ finally {
+ this._logger.log(LogLevel.Trace, "(LongPolling transport) Stop finished.");
+ // Raise close event here instead of in polling
+ // It needs to happen after the DELETE request is sent
+ this._raiseOnClose();
+ }
+ }
+ _raiseOnClose() {
+ if (this.onclose) {
+ let logMessage = "(LongPolling transport) Firing onclose event.";
+ if (this._closeError) {
+ logMessage += " Error: " + this._closeError;
+ }
+ this._logger.log(LogLevel.Trace, logMessage);
+ this.onclose(this._closeError);
+ }
+ }
+}
+
+;// CONCATENATED MODULE: ./src/ServerSentEventsTransport.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+/** @private */
+class ServerSentEventsTransport {
+ constructor(httpClient, accessToken, logger, options) {
+ this._httpClient = httpClient;
+ this._accessToken = accessToken;
+ this._logger = logger;
+ this._options = options;
+ this.onreceive = null;
+ this.onclose = null;
+ }
+ async connect(url, transferFormat) {
+ Arg.isRequired(url, "url");
+ Arg.isRequired(transferFormat, "transferFormat");
+ Arg.isIn(transferFormat, TransferFormat, "transferFormat");
+ this._logger.log(LogLevel.Trace, "(SSE transport) Connecting.");
+ // set url before accessTokenFactory because this._url is only for send and we set the auth header instead of the query string for send
+ this._url = url;
+ if (this._accessToken) {
+ url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(this._accessToken)}`;
+ }
+ return new Promise((resolve, reject) => {
+ let opened = false;
+ if (transferFormat !== TransferFormat.Text) {
+ reject(new Error("The Server-Sent Events transport only supports the 'Text' transfer format"));
+ return;
+ }
+ let eventSource;
+ if (Platform.isBrowser || Platform.isWebWorker) {
+ eventSource = new this._options.EventSource(url, { withCredentials: this._options.withCredentials });
+ }
+ else {
+ // Non-browser passes cookies via the dictionary
+ const cookies = this._httpClient.getCookieString(url);
+ const headers = {};
+ headers.Cookie = cookies;
+ const [name, value] = getUserAgentHeader();
+ headers[name] = value;
+ eventSource = new this._options.EventSource(url, { withCredentials: this._options.withCredentials, headers: { ...headers, ...this._options.headers } });
+ }
+ try {
+ eventSource.onmessage = (e) => {
+ if (this.onreceive) {
+ try {
+ this._logger.log(LogLevel.Trace, `(SSE transport) data received. ${getDataDetail(e.data, this._options.logMessageContent)}.`);
+ this.onreceive(e.data);
+ }
+ catch (error) {
+ this._close(error);
+ return;
+ }
+ }
+ };
+ // @ts-ignore: not using event on purpose
+ eventSource.onerror = (e) => {
+ // EventSource doesn't give any useful information about server side closes.
+ if (opened) {
+ this._close();
+ }
+ else {
+ reject(new Error("EventSource failed to connect. The connection could not be found on the server,"
+ + " either the connection ID is not present on the server, or a proxy is refusing/buffering the connection."
+ + " If you have multiple servers check that sticky sessions are enabled."));
+ }
+ };
+ eventSource.onopen = () => {
+ this._logger.log(LogLevel.Information, `SSE connected to ${this._url}`);
+ this._eventSource = eventSource;
+ opened = true;
+ resolve();
+ };
+ }
+ catch (e) {
+ reject(e);
+ return;
+ }
+ });
+ }
+ async send(data) {
+ if (!this._eventSource) {
+ return Promise.reject(new Error("Cannot send until the transport is connected"));
+ }
+ return sendMessage(this._logger, "SSE", this._httpClient, this._url, data, this._options);
+ }
+ stop() {
+ this._close();
+ return Promise.resolve();
+ }
+ _close(e) {
+ if (this._eventSource) {
+ this._eventSource.close();
+ this._eventSource = undefined;
+ if (this.onclose) {
+ this.onclose(e);
+ }
+ }
+ }
+}
+
+;// CONCATENATED MODULE: ./src/WebSocketTransport.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+/** @private */
+class WebSocketTransport {
+ constructor(httpClient, accessTokenFactory, logger, logMessageContent, webSocketConstructor, headers) {
+ this._logger = logger;
+ this._accessTokenFactory = accessTokenFactory;
+ this._logMessageContent = logMessageContent;
+ this._webSocketConstructor = webSocketConstructor;
+ this._httpClient = httpClient;
+ this.onreceive = null;
+ this.onclose = null;
+ this._headers = headers;
+ }
+ async connect(url, transferFormat) {
+ Arg.isRequired(url, "url");
+ Arg.isRequired(transferFormat, "transferFormat");
+ Arg.isIn(transferFormat, TransferFormat, "transferFormat");
+ this._logger.log(LogLevel.Trace, "(WebSockets transport) Connecting.");
+ let token;
+ if (this._accessTokenFactory) {
+ token = await this._accessTokenFactory();
+ }
+ return new Promise((resolve, reject) => {
+ url = url.replace(/^http/, "ws");
+ let webSocket;
+ const cookies = this._httpClient.getCookieString(url);
+ let opened = false;
+ if (Platform.isNode || Platform.isReactNative) {
+ const headers = {};
+ const [name, value] = getUserAgentHeader();
+ headers[name] = value;
+ if (token) {
+ headers[HeaderNames.Authorization] = `Bearer ${token}`;
+ }
+ if (cookies) {
+ headers[HeaderNames.Cookie] = cookies;
+ }
+ // Only pass headers when in non-browser environments
+ webSocket = new this._webSocketConstructor(url, undefined, {
+ headers: { ...headers, ...this._headers },
+ });
+ }
+ else {
+ if (token) {
+ url += (url.indexOf("?") < 0 ? "?" : "&") + `access_token=${encodeURIComponent(token)}`;
+ }
+ }
+ if (!webSocket) {
+ // Chrome is not happy with passing 'undefined' as protocol
+ webSocket = new this._webSocketConstructor(url);
+ }
+ if (transferFormat === TransferFormat.Binary) {
+ webSocket.binaryType = "arraybuffer";
+ }
+ webSocket.onopen = (_event) => {
+ this._logger.log(LogLevel.Information, `WebSocket connected to ${url}.`);
+ this._webSocket = webSocket;
+ opened = true;
+ resolve();
+ };
+ webSocket.onerror = (event) => {
+ let error = null;
+ // ErrorEvent is a browser only type we need to check if the type exists before using it
+ if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
+ error = event.error;
+ }
+ else {
+ error = "There was an error with the transport";
+ }
+ this._logger.log(LogLevel.Information, `(WebSockets transport) ${error}.`);
+ };
+ webSocket.onmessage = (message) => {
+ this._logger.log(LogLevel.Trace, `(WebSockets transport) data received. ${getDataDetail(message.data, this._logMessageContent)}.`);
+ if (this.onreceive) {
+ try {
+ this.onreceive(message.data);
+ }
+ catch (error) {
+ this._close(error);
+ return;
+ }
+ }
+ };
+ webSocket.onclose = (event) => {
+ // Don't call close handler if connection was never established
+ // We'll reject the connect call instead
+ if (opened) {
+ this._close(event);
+ }
+ else {
+ let error = null;
+ // ErrorEvent is a browser only type we need to check if the type exists before using it
+ if (typeof ErrorEvent !== "undefined" && event instanceof ErrorEvent) {
+ error = event.error;
+ }
+ else {
+ error = "WebSocket failed to connect. The connection could not be found on the server,"
+ + " either the endpoint may not be a SignalR endpoint,"
+ + " the connection ID is not present on the server, or there is a proxy blocking WebSockets."
+ + " If you have multiple servers check that sticky sessions are enabled.";
+ }
+ reject(new Error(error));
+ }
+ };
+ });
+ }
+ send(data) {
+ if (this._webSocket && this._webSocket.readyState === this._webSocketConstructor.OPEN) {
+ this._logger.log(LogLevel.Trace, `(WebSockets transport) sending data. ${getDataDetail(data, this._logMessageContent)}.`);
+ this._webSocket.send(data);
+ return Promise.resolve();
+ }
+ return Promise.reject("WebSocket is not in the OPEN state");
+ }
+ stop() {
+ if (this._webSocket) {
+ // Manually invoke onclose callback inline so we know the HttpConnection was closed properly before returning
+ // This also solves an issue where websocket.onclose could take 18+ seconds to trigger during network disconnects
+ this._close(undefined);
+ }
+ return Promise.resolve();
+ }
+ _close(event) {
+ // webSocket will be null if the transport did not start successfully
+ if (this._webSocket) {
+ // Clear websocket handlers because we are considering the socket closed now
+ this._webSocket.onclose = () => { };
+ this._webSocket.onmessage = () => { };
+ this._webSocket.onerror = () => { };
+ this._webSocket.close();
+ this._webSocket = undefined;
+ }
+ this._logger.log(LogLevel.Trace, "(WebSockets transport) socket closed.");
+ if (this.onclose) {
+ if (this._isCloseEvent(event) && (event.wasClean === false || event.code !== 1000)) {
+ this.onclose(new Error(`WebSocket closed with status code: ${event.code} (${event.reason || "no reason given"}).`));
+ }
+ else if (event instanceof Error) {
+ this.onclose(event);
+ }
+ else {
+ this.onclose();
+ }
+ }
+ }
+ _isCloseEvent(event) {
+ return event && typeof event.wasClean === "boolean" && typeof event.code === "number";
+ }
+}
+
+;// CONCATENATED MODULE: ./src/HttpConnection.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+
+
+
+
+
+const MAX_REDIRECTS = 100;
+/** @private */
+class HttpConnection {
+ constructor(url, options = {}) {
+ this._stopPromiseResolver = () => { };
+ this.features = {};
+ this._negotiateVersion = 1;
+ Arg.isRequired(url, "url");
+ this._logger = createLogger(options.logger);
+ this.baseUrl = this._resolveUrl(url);
+ options = options || {};
+ options.logMessageContent = options.logMessageContent == undefined ? false : options.logMessageContent;
+ if (typeof options.withCredentials === "boolean" || options.withCredentials == undefined) {
+ options.withCredentials = options.withCredentials == undefined ? true : options.withCredentials;
+ }
+ else {
+ throw new Error("withCredentials option was not a 'boolean' or 'undefined' value");
+ }
+ options.timeout = options.timeout == undefined ? 100 * 1000 : options.timeout;
+ let webSocketModule = null;
+ let eventSourceModule = null;
+ if (Platform.isNode && "function" !== "undefined") {
+ // In order to ignore the dynamic require in webpack builds we need to do this magic
+ // @ts-ignore: TS doesn't know about these names
+ const requireFunc = true ? require : 0;
+ webSocketModule = requireFunc("ws");
+ eventSourceModule = requireFunc("eventsource");
+ }
+ if (!Platform.isNode && typeof WebSocket !== "undefined" && !options.WebSocket) {
+ options.WebSocket = WebSocket;
+ }
+ else if (Platform.isNode && !options.WebSocket) {
+ if (webSocketModule) {
+ options.WebSocket = webSocketModule;
+ }
+ }
+ if (!Platform.isNode && typeof EventSource !== "undefined" && !options.EventSource) {
+ options.EventSource = EventSource;
+ }
+ else if (Platform.isNode && !options.EventSource) {
+ if (typeof eventSourceModule !== "undefined") {
+ options.EventSource = eventSourceModule;
+ }
+ }
+ this._httpClient = new AccessTokenHttpClient(options.httpClient || new DefaultHttpClient(this._logger), options.accessTokenFactory);
+ this._connectionState = "Disconnected" /* Disconnected */;
+ this._connectionStarted = false;
+ this._options = options;
+ this.onreceive = null;
+ this.onclose = null;
+ }
+ async start(transferFormat) {
+ transferFormat = transferFormat || TransferFormat.Binary;
+ Arg.isIn(transferFormat, TransferFormat, "transferFormat");
+ this._logger.log(LogLevel.Debug, `Starting connection with transfer format '${TransferFormat[transferFormat]}'.`);
+ if (this._connectionState !== "Disconnected" /* Disconnected */) {
+ return Promise.reject(new Error("Cannot start an HttpConnection that is not in the 'Disconnected' state."));
+ }
+ this._connectionState = "Connecting" /* Connecting */;
+ this._startInternalPromise = this._startInternal(transferFormat);
+ await this._startInternalPromise;
+ // The TypeScript compiler thinks that connectionState must be Connecting here. The TypeScript compiler is wrong.
+ if (this._connectionState === "Disconnecting" /* Disconnecting */) {
+ // stop() was called and transitioned the client into the Disconnecting state.
+ const message = "Failed to start the HttpConnection before stop() was called.";
+ this._logger.log(LogLevel.Error, message);
+ // We cannot await stopPromise inside startInternal since stopInternal awaits the startInternalPromise.
+ await this._stopPromise;
+ return Promise.reject(new AbortError(message));
+ }
+ else if (this._connectionState !== "Connected" /* Connected */) {
+ // stop() was called and transitioned the client into the Disconnecting state.
+ const message = "HttpConnection.startInternal completed gracefully but didn't enter the connection into the connected state!";
+ this._logger.log(LogLevel.Error, message);
+ return Promise.reject(new AbortError(message));
+ }
+ this._connectionStarted = true;
+ }
+ send(data) {
+ if (this._connectionState !== "Connected" /* Connected */) {
+ return Promise.reject(new Error("Cannot send data if the connection is not in the 'Connected' State."));
+ }
+ if (!this._sendQueue) {
+ this._sendQueue = new TransportSendQueue(this.transport);
+ }
+ // Transport will not be null if state is connected
+ return this._sendQueue.send(data);
+ }
+ async stop(error) {
+ if (this._connectionState === "Disconnected" /* Disconnected */) {
+ this._logger.log(LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnected state.`);
+ return Promise.resolve();
+ }
+ if (this._connectionState === "Disconnecting" /* Disconnecting */) {
+ this._logger.log(LogLevel.Debug, `Call to HttpConnection.stop(${error}) ignored because the connection is already in the disconnecting state.`);
+ return this._stopPromise;
+ }
+ this._connectionState = "Disconnecting" /* Disconnecting */;
+ this._stopPromise = new Promise((resolve) => {
+ // Don't complete stop() until stopConnection() completes.
+ this._stopPromiseResolver = resolve;
+ });
+ // stopInternal should never throw so just observe it.
+ await this._stopInternal(error);
+ await this._stopPromise;
+ }
+ async _stopInternal(error) {
+ // Set error as soon as possible otherwise there is a race between
+ // the transport closing and providing an error and the error from a close message
+ // We would prefer the close message error.
+ this._stopError = error;
+ try {
+ await this._startInternalPromise;
+ }
+ catch (e) {
+ // This exception is returned to the user as a rejected Promise from the start method.
+ }
+ // The transport's onclose will trigger stopConnection which will run our onclose event.
+ // The transport should always be set if currently connected. If it wasn't set, it's likely because
+ // stop was called during start() and start() failed.
+ if (this.transport) {
+ try {
+ await this.transport.stop();
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `HttpConnection.transport.stop() threw error '${e}'.`);
+ this._stopConnection();
+ }
+ this.transport = undefined;
+ }
+ else {
+ this._logger.log(LogLevel.Debug, "HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.");
+ }
+ }
+ async _startInternal(transferFormat) {
+ // Store the original base url and the access token factory since they may change
+ // as part of negotiating
+ let url = this.baseUrl;
+ this._accessTokenFactory = this._options.accessTokenFactory;
+ this._httpClient._accessTokenFactory = this._accessTokenFactory;
+ try {
+ if (this._options.skipNegotiation) {
+ if (this._options.transport === HttpTransportType.WebSockets) {
+ // No need to add a connection ID in this case
+ this.transport = this._constructTransport(HttpTransportType.WebSockets);
+ // We should just call connect directly in this case.
+ // No fallback or negotiate in this case.
+ await this._startTransport(url, transferFormat);
+ }
+ else {
+ throw new Error("Negotiation can only be skipped when using the WebSocket transport directly.");
+ }
+ }
+ else {
+ let negotiateResponse = null;
+ let redirects = 0;
+ do {
+ negotiateResponse = await this._getNegotiationResponse(url);
+ // the user tries to stop the connection when it is being started
+ if (this._connectionState === "Disconnecting" /* Disconnecting */ || this._connectionState === "Disconnected" /* Disconnected */) {
+ throw new AbortError("The connection was stopped during negotiation.");
+ }
+ if (negotiateResponse.error) {
+ throw new Error(negotiateResponse.error);
+ }
+ if (negotiateResponse.ProtocolVersion) {
+ throw new Error("Detected a connection attempt to an ASP.NET SignalR Server. This client only supports connecting to an ASP.NET Core SignalR Server. See https://aka.ms/signalr-core-differences for details.");
+ }
+ if (negotiateResponse.url) {
+ url = negotiateResponse.url;
+ }
+ if (negotiateResponse.accessToken) {
+ // Replace the current access token factory with one that uses
+ // the returned access token
+ const accessToken = negotiateResponse.accessToken;
+ this._accessTokenFactory = () => accessToken;
+ // set the factory to undefined so the AccessTokenHttpClient won't retry with the same token, since we know it won't change until a connection restart
+ this._httpClient._accessToken = accessToken;
+ this._httpClient._accessTokenFactory = undefined;
+ }
+ redirects++;
+ } while (negotiateResponse.url && redirects < MAX_REDIRECTS);
+ if (redirects === MAX_REDIRECTS && negotiateResponse.url) {
+ throw new Error("Negotiate redirection limit exceeded.");
+ }
+ await this._createTransport(url, this._options.transport, negotiateResponse, transferFormat);
+ }
+ if (this.transport instanceof LongPollingTransport) {
+ this.features.inherentKeepAlive = true;
+ }
+ if (this._connectionState === "Connecting" /* Connecting */) {
+ // Ensure the connection transitions to the connected state prior to completing this.startInternalPromise.
+ // start() will handle the case when stop was called and startInternal exits still in the disconnecting state.
+ this._logger.log(LogLevel.Debug, "The HttpConnection connected successfully.");
+ this._connectionState = "Connected" /* Connected */;
+ }
+ // stop() is waiting on us via this.startInternalPromise so keep this.transport around so it can clean up.
+ // This is the only case startInternal can exit in neither the connected nor disconnected state because stopConnection()
+ // will transition to the disconnected state. start() will wait for the transition using the stopPromise.
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, "Failed to start the connection: " + e);
+ this._connectionState = "Disconnected" /* Disconnected */;
+ this.transport = undefined;
+ // if start fails, any active calls to stop assume that start will complete the stop promise
+ this._stopPromiseResolver();
+ return Promise.reject(e);
+ }
+ }
+ async _getNegotiationResponse(url) {
+ const headers = {};
+ const [name, value] = getUserAgentHeader();
+ headers[name] = value;
+ const negotiateUrl = this._resolveNegotiateUrl(url);
+ this._logger.log(LogLevel.Debug, `Sending negotiation request: ${negotiateUrl}.`);
+ try {
+ const response = await this._httpClient.post(negotiateUrl, {
+ content: "",
+ headers: { ...headers, ...this._options.headers },
+ timeout: this._options.timeout,
+ withCredentials: this._options.withCredentials,
+ });
+ if (response.statusCode !== 200) {
+ return Promise.reject(new Error(`Unexpected status code returned from negotiate '${response.statusCode}'`));
+ }
+ const negotiateResponse = JSON.parse(response.content);
+ if (!negotiateResponse.negotiateVersion || negotiateResponse.negotiateVersion < 1) {
+ // Negotiate version 0 doesn't use connectionToken
+ // So we set it equal to connectionId so all our logic can use connectionToken without being aware of the negotiate version
+ negotiateResponse.connectionToken = negotiateResponse.connectionId;
+ }
+ return negotiateResponse;
+ }
+ catch (e) {
+ let errorMessage = "Failed to complete negotiation with the server: " + e;
+ if (e instanceof HttpError) {
+ if (e.statusCode === 404) {
+ errorMessage = errorMessage + " Either this is not a SignalR endpoint or there is a proxy blocking the connection.";
+ }
+ }
+ this._logger.log(LogLevel.Error, errorMessage);
+ return Promise.reject(new FailedToNegotiateWithServerError(errorMessage));
+ }
+ }
+ _createConnectUrl(url, connectionToken) {
+ if (!connectionToken) {
+ return url;
+ }
+ return url + (url.indexOf("?") === -1 ? "?" : "&") + `id=${connectionToken}`;
+ }
+ async _createTransport(url, requestedTransport, negotiateResponse, requestedTransferFormat) {
+ let connectUrl = this._createConnectUrl(url, negotiateResponse.connectionToken);
+ if (this._isITransport(requestedTransport)) {
+ this._logger.log(LogLevel.Debug, "Connection was provided an instance of ITransport, using that directly.");
+ this.transport = requestedTransport;
+ await this._startTransport(connectUrl, requestedTransferFormat);
+ this.connectionId = negotiateResponse.connectionId;
+ return;
+ }
+ const transportExceptions = [];
+ const transports = negotiateResponse.availableTransports || [];
+ let negotiate = negotiateResponse;
+ for (const endpoint of transports) {
+ const transportOrError = this._resolveTransportOrError(endpoint, requestedTransport, requestedTransferFormat);
+ if (transportOrError instanceof Error) {
+ // Store the error and continue, we don't want to cause a re-negotiate in these cases
+ transportExceptions.push(`${endpoint.transport} failed:`);
+ transportExceptions.push(transportOrError);
+ }
+ else if (this._isITransport(transportOrError)) {
+ this.transport = transportOrError;
+ if (!negotiate) {
+ try {
+ negotiate = await this._getNegotiationResponse(url);
+ }
+ catch (ex) {
+ return Promise.reject(ex);
+ }
+ connectUrl = this._createConnectUrl(url, negotiate.connectionToken);
+ }
+ try {
+ await this._startTransport(connectUrl, requestedTransferFormat);
+ this.connectionId = negotiate.connectionId;
+ return;
+ }
+ catch (ex) {
+ this._logger.log(LogLevel.Error, `Failed to start the transport '${endpoint.transport}': ${ex}`);
+ negotiate = undefined;
+ transportExceptions.push(new FailedToStartTransportError(`${endpoint.transport} failed: ${ex}`, HttpTransportType[endpoint.transport]));
+ if (this._connectionState !== "Connecting" /* Connecting */) {
+ const message = "Failed to select transport before stop() was called.";
+ this._logger.log(LogLevel.Debug, message);
+ return Promise.reject(new AbortError(message));
+ }
+ }
+ }
+ }
+ if (transportExceptions.length > 0) {
+ return Promise.reject(new AggregateErrors(`Unable to connect to the server with any of the available transports. ${transportExceptions.join(" ")}`, transportExceptions));
+ }
+ return Promise.reject(new Error("None of the transports supported by the client are supported by the server."));
+ }
+ _constructTransport(transport) {
+ switch (transport) {
+ case HttpTransportType.WebSockets:
+ if (!this._options.WebSocket) {
+ throw new Error("'WebSocket' is not supported in your environment.");
+ }
+ return new WebSocketTransport(this._httpClient, this._accessTokenFactory, this._logger, this._options.logMessageContent, this._options.WebSocket, this._options.headers || {});
+ case HttpTransportType.ServerSentEvents:
+ if (!this._options.EventSource) {
+ throw new Error("'EventSource' is not supported in your environment.");
+ }
+ return new ServerSentEventsTransport(this._httpClient, this._httpClient._accessToken, this._logger, this._options);
+ case HttpTransportType.LongPolling:
+ return new LongPollingTransport(this._httpClient, this._logger, this._options);
+ default:
+ throw new Error(`Unknown transport: ${transport}.`);
+ }
+ }
+ _startTransport(url, transferFormat) {
+ this.transport.onreceive = this.onreceive;
+ this.transport.onclose = (e) => this._stopConnection(e);
+ return this.transport.connect(url, transferFormat);
+ }
+ _resolveTransportOrError(endpoint, requestedTransport, requestedTransferFormat) {
+ const transport = HttpTransportType[endpoint.transport];
+ if (transport == undefined || transport == undefined) {
+ this._logger.log(LogLevel.Debug, `Skipping transport '${endpoint.transport}' because it is not supported by this client.`);
+ return new Error(`Skipping transport '${endpoint.transport}' because it is not supported by this client.`);
+ }
+ else {
+ if (transportMatches(requestedTransport, transport)) {
+ const transferFormats = endpoint.transferFormats.map((s) => TransferFormat[s]);
+ if (transferFormats.indexOf(requestedTransferFormat) >= 0) {
+ if ((transport === HttpTransportType.WebSockets && !this._options.WebSocket) ||
+ (transport === HttpTransportType.ServerSentEvents && !this._options.EventSource)) {
+ this._logger.log(LogLevel.Debug, `Skipping transport '${HttpTransportType[transport]}' because it is not supported in your environment.'`);
+ return new UnsupportedTransportError(`'${HttpTransportType[transport]}' is not supported in your environment.`, transport);
+ }
+ else {
+ this._logger.log(LogLevel.Debug, `Selecting transport '${HttpTransportType[transport]}'.`);
+ try {
+ return this._constructTransport(transport);
+ }
+ catch (ex) {
+ return ex;
+ }
+ }
+ }
+ else {
+ this._logger.log(LogLevel.Debug, `Skipping transport '${HttpTransportType[transport]}' because it does not support the requested transfer format '${TransferFormat[requestedTransferFormat]}'.`);
+ return new Error(`'${HttpTransportType[transport]}' does not support ${TransferFormat[requestedTransferFormat]}.`);
+ }
+ }
+ else {
+ this._logger.log(LogLevel.Debug, `Skipping transport '${HttpTransportType[transport]}' because it was disabled by the client.`);
+ return new DisabledTransportError(`'${HttpTransportType[transport]}' is disabled by the client.`, transport);
+ }
+ }
+ }
+ _isITransport(transport) {
+ return transport && typeof (transport) === "object" && "connect" in transport;
+ }
+ _stopConnection(error) {
+ this._logger.log(LogLevel.Debug, `HttpConnection.stopConnection(${error}) called while in state ${this._connectionState}.`);
+ this.transport = undefined;
+ // If we have a stopError, it takes precedence over the error from the transport
+ error = this._stopError || error;
+ this._stopError = undefined;
+ if (this._connectionState === "Disconnected" /* Disconnected */) {
+ this._logger.log(LogLevel.Debug, `Call to HttpConnection.stopConnection(${error}) was ignored because the connection is already in the disconnected state.`);
+ return;
+ }
+ if (this._connectionState === "Connecting" /* Connecting */) {
+ this._logger.log(LogLevel.Warning, `Call to HttpConnection.stopConnection(${error}) was ignored because the connection is still in the connecting state.`);
+ throw new Error(`HttpConnection.stopConnection(${error}) was called while the connection is still in the connecting state.`);
+ }
+ if (this._connectionState === "Disconnecting" /* Disconnecting */) {
+ // A call to stop() induced this call to stopConnection and needs to be completed.
+ // Any stop() awaiters will be scheduled to continue after the onclose callback fires.
+ this._stopPromiseResolver();
+ }
+ if (error) {
+ this._logger.log(LogLevel.Error, `Connection disconnected with error '${error}'.`);
+ }
+ else {
+ this._logger.log(LogLevel.Information, "Connection disconnected.");
+ }
+ if (this._sendQueue) {
+ this._sendQueue.stop().catch((e) => {
+ this._logger.log(LogLevel.Error, `TransportSendQueue.stop() threw error '${e}'.`);
+ });
+ this._sendQueue = undefined;
+ }
+ this.connectionId = undefined;
+ this._connectionState = "Disconnected" /* Disconnected */;
+ if (this._connectionStarted) {
+ this._connectionStarted = false;
+ try {
+ if (this.onclose) {
+ this.onclose(error);
+ }
+ }
+ catch (e) {
+ this._logger.log(LogLevel.Error, `HttpConnection.onclose(${error}) threw error '${e}'.`);
+ }
+ }
+ }
+ _resolveUrl(url) {
+ // startsWith is not supported in IE
+ if (url.lastIndexOf("https://", 0) === 0 || url.lastIndexOf("http://", 0) === 0) {
+ return url;
+ }
+ if (!Platform.isBrowser) {
+ throw new Error(`Cannot resolve '${url}'.`);
+ }
+ // Setting the url to the href propery of an anchor tag handles normalization
+ // for us. There are 3 main cases.
+ // 1. Relative path normalization e.g "b" -> "http://localhost:5000/a/b"
+ // 2. Absolute path normalization e.g "/a/b" -> "http://localhost:5000/a/b"
+ // 3. Networkpath reference normalization e.g "//localhost:5000/a/b" -> "http://localhost:5000/a/b"
+ const aTag = window.document.createElement("a");
+ aTag.href = url;
+ this._logger.log(LogLevel.Information, `Normalizing '${url}' to '${aTag.href}'.`);
+ return aTag.href;
+ }
+ _resolveNegotiateUrl(url) {
+ const index = url.indexOf("?");
+ let negotiateUrl = url.substring(0, index === -1 ? url.length : index);
+ if (negotiateUrl[negotiateUrl.length - 1] !== "/") {
+ negotiateUrl += "/";
+ }
+ negotiateUrl += "negotiate";
+ negotiateUrl += index === -1 ? "" : url.substring(index);
+ if (negotiateUrl.indexOf("negotiateVersion") === -1) {
+ negotiateUrl += index === -1 ? "?" : "&";
+ negotiateUrl += "negotiateVersion=" + this._negotiateVersion;
+ }
+ return negotiateUrl;
+ }
+}
+function transportMatches(requestedTransport, actualTransport) {
+ return !requestedTransport || ((actualTransport & requestedTransport) !== 0);
+}
+/** @private */
+class TransportSendQueue {
+ constructor(_transport) {
+ this._transport = _transport;
+ this._buffer = [];
+ this._executing = true;
+ this._sendBufferedData = new PromiseSource();
+ this._transportResult = new PromiseSource();
+ this._sendLoopPromise = this._sendLoop();
+ }
+ send(data) {
+ this._bufferData(data);
+ if (!this._transportResult) {
+ this._transportResult = new PromiseSource();
+ }
+ return this._transportResult.promise;
+ }
+ stop() {
+ this._executing = false;
+ this._sendBufferedData.resolve();
+ return this._sendLoopPromise;
+ }
+ _bufferData(data) {
+ if (this._buffer.length && typeof (this._buffer[0]) !== typeof (data)) {
+ throw new Error(`Expected data to be of type ${typeof (this._buffer)} but was of type ${typeof (data)}`);
+ }
+ this._buffer.push(data);
+ this._sendBufferedData.resolve();
+ }
+ async _sendLoop() {
+ while (true) {
+ await this._sendBufferedData.promise;
+ if (!this._executing) {
+ if (this._transportResult) {
+ this._transportResult.reject("Connection stopped.");
+ }
+ break;
+ }
+ this._sendBufferedData = new PromiseSource();
+ const transportResult = this._transportResult;
+ this._transportResult = undefined;
+ const data = typeof (this._buffer[0]) === "string" ?
+ this._buffer.join("") :
+ TransportSendQueue._concatBuffers(this._buffer);
+ this._buffer.length = 0;
+ try {
+ await this._transport.send(data);
+ transportResult.resolve();
+ }
+ catch (error) {
+ transportResult.reject(error);
+ }
+ }
+ }
+ static _concatBuffers(arrayBuffers) {
+ const totalLength = arrayBuffers.map((b) => b.byteLength).reduce((a, b) => a + b);
+ const result = new Uint8Array(totalLength);
+ let offset = 0;
+ for (const item of arrayBuffers) {
+ result.set(new Uint8Array(item), offset);
+ offset += item.byteLength;
+ }
+ return result.buffer;
+ }
+}
+class PromiseSource {
+ constructor() {
+ this.promise = new Promise((resolve, reject) => [this._resolver, this._rejecter] = [resolve, reject]);
+ }
+ resolve() {
+ this._resolver();
+ }
+ reject(reason) {
+ this._rejecter(reason);
+ }
+}
+
+;// CONCATENATED MODULE: ./src/JsonHubProtocol.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+
+const JSON_HUB_PROTOCOL_NAME = "json";
+/** Implements the JSON Hub Protocol. */
+class JsonHubProtocol {
+ constructor() {
+ /** @inheritDoc */
+ this.name = JSON_HUB_PROTOCOL_NAME;
+ /** @inheritDoc */
+ this.version = 1;
+ /** @inheritDoc */
+ this.transferFormat = TransferFormat.Text;
+ }
+ /** Creates an array of {@link @microsoft/signalr.HubMessage} objects from the specified serialized representation.
+ *
+ * @param {string} input A string containing the serialized representation.
+ * @param {ILogger} logger A logger that will be used to log messages that occur during parsing.
+ */
+ parseMessages(input, logger) {
+ // The interface does allow "ArrayBuffer" to be passed in, but this implementation does not. So let's throw a useful error.
+ if (typeof input !== "string") {
+ throw new Error("Invalid input for JSON hub protocol. Expected a string.");
+ }
+ if (!input) {
+ return [];
+ }
+ if (logger == undefined) {
+ logger = NullLogger.instance;
+ }
+ // Parse the messages
+ const messages = TextMessageFormat.parse(input);
+ const hubMessages = [];
+ for (const message of messages) {
+ const parsedMessage = JSON.parse(message);
+ if (typeof parsedMessage.type !== "number") {
+ throw new Error("Invalid payload.");
+ }
+ switch (parsedMessage.type) {
+ case MessageType.Invocation:
+ this._isInvocationMessage(parsedMessage);
+ break;
+ case MessageType.StreamItem:
+ this._isStreamItemMessage(parsedMessage);
+ break;
+ case MessageType.Completion:
+ this._isCompletionMessage(parsedMessage);
+ break;
+ case MessageType.Ping:
+ // Single value, no need to validate
+ break;
+ case MessageType.Close:
+ // All optional values, no need to validate
+ break;
+ default:
+ // Future protocol changes can add message types, old clients can ignore them
+ logger.log(LogLevel.Information, "Unknown message type '" + parsedMessage.type + "' ignored.");
+ continue;
+ }
+ hubMessages.push(parsedMessage);
+ }
+ return hubMessages;
+ }
+ /** Writes the specified {@link @microsoft/signalr.HubMessage} to a string and returns it.
+ *
+ * @param {HubMessage} message The message to write.
+ * @returns {string} A string containing the serialized representation of the message.
+ */
+ writeMessage(message) {
+ return TextMessageFormat.write(JSON.stringify(message));
+ }
+ _isInvocationMessage(message) {
+ this._assertNotEmptyString(message.target, "Invalid payload for Invocation message.");
+ if (message.invocationId != undefined) {
+ this._assertNotEmptyString(message.invocationId, "Invalid payload for Invocation message.");
+ }
+ }
+ _isStreamItemMessage(message) {
+ this._assertNotEmptyString(message.invocationId, "Invalid payload for StreamItem message.");
+ if (message.item == undefined) {
+ throw new Error("Invalid payload for StreamItem message.");
+ }
+ }
+ _isCompletionMessage(message) {
+ if (message.result && message.error) {
+ throw new Error("Invalid payload for Completion message.");
+ }
+ if (!message.result && message.error) {
+ this._assertNotEmptyString(message.error, "Invalid payload for Completion message.");
+ }
+ this._assertNotEmptyString(message.invocationId, "Invalid payload for Completion message.");
+ }
+ _assertNotEmptyString(value, errorMessage) {
+ if (typeof value !== "string" || value === "") {
+ throw new Error(errorMessage);
+ }
+ }
+}
+
+;// CONCATENATED MODULE: ./src/HubConnectionBuilder.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+
+
+
+const LogLevelNameMapping = {
+ trace: LogLevel.Trace,
+ debug: LogLevel.Debug,
+ info: LogLevel.Information,
+ information: LogLevel.Information,
+ warn: LogLevel.Warning,
+ warning: LogLevel.Warning,
+ error: LogLevel.Error,
+ critical: LogLevel.Critical,
+ none: LogLevel.None,
+};
+function parseLogLevel(name) {
+ // Case-insensitive matching via lower-casing
+ // Yes, I know case-folding is a complicated problem in Unicode, but we only support
+ // the ASCII strings defined in LogLevelNameMapping anyway, so it's fine -anurse.
+ const mapping = LogLevelNameMapping[name.toLowerCase()];
+ if (typeof mapping !== "undefined") {
+ return mapping;
+ }
+ else {
+ throw new Error(`Unknown log level: ${name}`);
+ }
+}
+/** A builder for configuring {@link @microsoft/signalr.HubConnection} instances. */
+class HubConnectionBuilder {
+ configureLogging(logging) {
+ Arg.isRequired(logging, "logging");
+ if (isLogger(logging)) {
+ this.logger = logging;
+ }
+ else if (typeof logging === "string") {
+ const logLevel = parseLogLevel(logging);
+ this.logger = new ConsoleLogger(logLevel);
+ }
+ else {
+ this.logger = new ConsoleLogger(logging);
+ }
+ return this;
+ }
+ withUrl(url, transportTypeOrOptions) {
+ Arg.isRequired(url, "url");
+ Arg.isNotEmpty(url, "url");
+ this.url = url;
+ // Flow-typing knows where it's at. Since HttpTransportType is a number and IHttpConnectionOptions is guaranteed
+ // to be an object, we know (as does TypeScript) this comparison is all we need to figure out which overload was called.
+ if (typeof transportTypeOrOptions === "object") {
+ this.httpConnectionOptions = { ...this.httpConnectionOptions, ...transportTypeOrOptions };
+ }
+ else {
+ this.httpConnectionOptions = {
+ ...this.httpConnectionOptions,
+ transport: transportTypeOrOptions,
+ };
+ }
+ return this;
+ }
+ /** Configures the {@link @microsoft/signalr.HubConnection} to use the specified Hub Protocol.
+ *
+ * @param {IHubProtocol} protocol The {@link @microsoft/signalr.IHubProtocol} implementation to use.
+ */
+ withHubProtocol(protocol) {
+ Arg.isRequired(protocol, "protocol");
+ this.protocol = protocol;
+ return this;
+ }
+ withAutomaticReconnect(retryDelaysOrReconnectPolicy) {
+ if (this.reconnectPolicy) {
+ throw new Error("A reconnectPolicy has already been set.");
+ }
+ if (!retryDelaysOrReconnectPolicy) {
+ this.reconnectPolicy = new DefaultReconnectPolicy();
+ }
+ else if (Array.isArray(retryDelaysOrReconnectPolicy)) {
+ this.reconnectPolicy = new DefaultReconnectPolicy(retryDelaysOrReconnectPolicy);
+ }
+ else {
+ this.reconnectPolicy = retryDelaysOrReconnectPolicy;
+ }
+ return this;
+ }
+ /** Creates a {@link @microsoft/signalr.HubConnection} from the configuration options specified in this builder.
+ *
+ * @returns {HubConnection} The configured {@link @microsoft/signalr.HubConnection}.
+ */
+ build() {
+ // If httpConnectionOptions has a logger, use it. Otherwise, override it with the one
+ // provided to configureLogger
+ const httpConnectionOptions = this.httpConnectionOptions || {};
+ // If it's 'null', the user **explicitly** asked for null, don't mess with it.
+ if (httpConnectionOptions.logger == undefined) {
+ // If our logger is undefined or null, that's OK, the HttpConnection constructor will handle it.
+ httpConnectionOptions.logger = this.logger;
+ }
+ // Now create the connection
+ if (!this.url) {
+ throw new Error("The 'HubConnectionBuilder.withUrl' method must be called before building the connection.");
+ }
+ const connection = new HttpConnection(this.url, httpConnectionOptions);
+ return HubConnection.create(connection, this.logger || NullLogger.instance, this.protocol || new JsonHubProtocol(), this.reconnectPolicy);
+ }
+}
+function isLogger(logger) {
+ return logger.log != undefined;
+}
+
+;// CONCATENATED MODULE: ./src/index.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+
+
+
+
+
+
+
+
+
+
+
+
+;// CONCATENATED MODULE: ./src/browser-index.ts
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// This is where we add any polyfills we'll need for the browser. It is the entry module for browser-specific builds.
+// Copy from Array.prototype into Uint8Array to polyfill on IE. It's OK because the implementations of indexOf and slice use properties
+// that exist on Uint8Array with the same name, and JavaScript is magic.
+// We make them 'writable' because the Buffer polyfill messes with it as well.
+if (!Uint8Array.prototype.indexOf) {
+ Object.defineProperty(Uint8Array.prototype, "indexOf", {
+ value: Array.prototype.indexOf,
+ writable: true,
+ });
+}
+if (!Uint8Array.prototype.slice) {
+ Object.defineProperty(Uint8Array.prototype, "slice", {
+ // wrap the slice in Uint8Array so it looks like a Uint8Array.slice call
+ // eslint-disable-next-line object-shorthand
+ value: function (start, end) { return new Uint8Array(Array.prototype.slice.call(this, start, end)); },
+ writable: true,
+ });
+}
+if (!Uint8Array.prototype.forEach) {
+ Object.defineProperty(Uint8Array.prototype, "forEach", {
+ value: Array.prototype.forEach,
+ writable: true,
+ });
+}
+
+
+/******/ return __webpack_exports__;
+/******/ })()
+;
+});
+//# sourceMappingURL=signalr.js.map
\ No newline at end of file
diff --git a/Adaptation/FileHandlers/json/StaticSite/js/signalr/hubs.js b/Adaptation/FileHandlers/json/StaticSite/js/signalr/hubs.js
new file mode 100644
index 0000000..fef2503
--- /dev/null
+++ b/Adaptation/FileHandlers/json/StaticSite/js/signalr/hubs.js
@@ -0,0 +1,95 @@
+/*!
+ * ASP.NET SignalR JavaScript Library 2.4.3
+ * http://signalr.net/
+ *
+ * Copyright (c) .NET Foundation. All rights reserved.
+ * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+ *
+ */
+
+///
+///
+(function ($, window, undefined) {
+ ///
+ "use strict";
+
+ if (typeof ($.signalR) !== "function") {
+ throw new Error("SignalR: SignalR is not loaded. Please ensure jquery.signalR-x.js is referenced before ~/signalr/js.");
+ }
+
+ var signalR = $.signalR;
+
+ function makeProxyCallback(hub, callback) {
+ return function () {
+ // Call the client hub method
+ callback.apply(hub, $.makeArray(arguments));
+ };
+ }
+
+ function registerHubProxies(instance, shouldSubscribe) {
+ var key, hub, memberKey, memberValue, subscriptionMethod;
+
+ for (key in instance) {
+ if (instance.hasOwnProperty(key)) {
+ hub = instance[key];
+
+ if (!(hub.hubName)) {
+ // Not a client hub
+ continue;
+ }
+
+ if (shouldSubscribe) {
+ // We want to subscribe to the hub events
+ subscriptionMethod = hub.on;
+ } else {
+ // We want to unsubscribe from the hub events
+ subscriptionMethod = hub.off;
+ }
+
+ // Loop through all members on the hub and find client hub functions to subscribe/unsubscribe
+ for (memberKey in hub.client) {
+ if (hub.client.hasOwnProperty(memberKey)) {
+ memberValue = hub.client[memberKey];
+
+ if (!$.isFunction(memberValue)) {
+ // Not a client hub function
+ continue;
+ }
+
+ // Use the actual user-provided callback as the "identity" value for the registration.
+ subscriptionMethod.call(hub, memberKey, makeProxyCallback(hub, memberValue), memberValue);
+ }
+ }
+ }
+ }
+ }
+
+ $.hubConnection.prototype.createHubProxies = function () {
+ var proxies = {};
+ this.starting(function () {
+ // Register the hub proxies as subscribed
+ // (instance, shouldSubscribe)
+ registerHubProxies(proxies, true);
+
+ this._registerSubscribedHubs();
+ }).disconnected(function () {
+ // Unsubscribe all hub proxies when we "disconnect". This is to ensure that we do not re-add functional call backs.
+ // (instance, shouldSubscribe)
+ registerHubProxies(proxies, false);
+ });
+
+ proxies['weightedShortestJobFirstHub'] = this.createHubProxy('weightedShortestJobFirstHub');
+ proxies['weightedShortestJobFirstHub'].client = { };
+ proxies['weightedShortestJobFirstHub'].server = {
+ send: function (name, message) {
+ return proxies['weightedShortestJobFirstHub'].invoke.apply(proxies['weightedShortestJobFirstHub'], $.merge(["Send"], $.makeArray(arguments)));
+ }
+ };
+
+ return proxies;
+ };
+
+ signalR.hub = $.hubConnection("/signalr", { useDefaultPath: false });
+ $.extend(signalR, signalR.hub.createHubProxies());
+
+}(window.jQuery, window));
\ No newline at end of file
diff --git a/Adaptation/FileHandlers/json/StaticSite/js/signalr/v2.1.0/jquery.signalR.js b/Adaptation/FileHandlers/json/StaticSite/js/signalr/v2.1.0/jquery.signalR.js
new file mode 100644
index 0000000..d969998
--- /dev/null
+++ b/Adaptation/FileHandlers/json/StaticSite/js/signalr/v2.1.0/jquery.signalR.js
@@ -0,0 +1,2818 @@
+/* jquery.signalR.core.js */
+/*global window:false */
+/*!
+ * ASP.NET SignalR JavaScript Library v2.1.0
+ * http://signalr.net/
+ *
+ * Copyright (C) Microsoft Corporation. All rights reserved.
+ *
+ */
+
+///
+///
+(function ($, window, undefined) {
+
+ var resources = {
+ nojQuery: "jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.",
+ noTransportOnInit: "No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.",
+ errorOnNegotiate: "Error during negotiation request.",
+ stoppedWhileLoading: "The connection was stopped during page load.",
+ stoppedWhileNegotiating: "The connection was stopped during the negotiate request.",
+ errorParsingNegotiateResponse: "Error parsing negotiate response.",
+ errorDuringStartRequest: "Error during start request. Stopping the connection.",
+ stoppedDuringStartRequest: "The connection was stopped during the start request.",
+ errorParsingStartResponse: "Error parsing start response: '{0}'. Stopping the connection.",
+ invalidStartResponse: "Invalid start response: '{0}'. Stopping the connection.",
+ protocolIncompatible: "You are using a version of the client that isn't compatible with the server. Client version {0}, server version {1}.",
+ sendFailed: "Send failed.",
+ parseFailed: "Failed at parsing response: {0}",
+ longPollFailed: "Long polling request failed.",
+ eventSourceFailedToConnect: "EventSource failed to connect.",
+ eventSourceError: "Error raised by EventSource",
+ webSocketClosed: "WebSocket closed.",
+ pingServerFailedInvalidResponse: "Invalid ping response when pinging server: '{0}'.",
+ pingServerFailed: "Failed to ping server.",
+ pingServerFailedStatusCode: "Failed to ping server. Server responded with status code {0}, stopping the connection.",
+ pingServerFailedParse: "Failed to parse ping server response, stopping the connection.",
+ noConnectionTransport: "Connection is in an invalid state, there is no transport active.",
+ webSocketsInvalidState: "The Web Socket transport is in an invalid state, transitioning into reconnecting.",
+ reconnectTimeout: "Couldn't reconnect within the configured timeout of {0} ms, disconnecting.",
+ reconnectWindowTimeout: "The client has been inactive since {0} and it has exceeded the inactivity timeout of {1} ms. Stopping the connection."
+ };
+
+ if (typeof ($) !== "function") {
+ // no jQuery!
+ throw new Error(resources.nojQuery);
+ }
+
+ var signalR,
+ _connection,
+ _pageLoaded = (window.document.readyState === "complete"),
+ _pageWindow = $(window),
+ _negotiateAbortText = "__Negotiate Aborted__",
+ events = {
+ onStart: "onStart",
+ onStarting: "onStarting",
+ onReceived: "onReceived",
+ onError: "onError",
+ onConnectionSlow: "onConnectionSlow",
+ onReconnecting: "onReconnecting",
+ onReconnect: "onReconnect",
+ onStateChanged: "onStateChanged",
+ onDisconnect: "onDisconnect"
+ },
+ ajaxDefaults = {
+ processData: true,
+ timeout: null,
+ async: true,
+ global: false,
+ cache: false
+ },
+ log = function (msg, logging) {
+ if (logging === false) {
+ return;
+ }
+ var m;
+ if (typeof (window.console) === "undefined") {
+ return;
+ }
+ m = "[" + new Date().toTimeString() + "] SignalR: " + msg;
+ if (window.console.debug) {
+ window.console.debug(m);
+ } else if (window.console.log) {
+ window.console.log(m);
+ }
+ },
+
+ changeState = function (connection, expectedState, newState) {
+ if (expectedState === connection.state) {
+ connection.state = newState;
+
+ $(connection).triggerHandler(events.onStateChanged, [{ oldState: expectedState, newState: newState }]);
+ return true;
+ }
+
+ return false;
+ },
+
+ isDisconnecting = function (connection) {
+ return connection.state === signalR.connectionState.disconnected;
+ },
+
+ supportsKeepAlive = function (connection) {
+ return connection._.keepAliveData.activated &&
+ connection.transport.supportsKeepAlive(connection);
+ },
+
+ configureStopReconnectingTimeout = function (connection) {
+ var stopReconnectingTimeout,
+ onReconnectTimeout;
+
+ // Check if this connection has already been configured to stop reconnecting after a specified timeout.
+ // Without this check if a connection is stopped then started events will be bound multiple times.
+ if (!connection._.configuredStopReconnectingTimeout) {
+ onReconnectTimeout = function (connection) {
+ var message = signalR._.format(signalR.resources.reconnectTimeout, connection.disconnectTimeout);
+ connection.log(message);
+ $(connection).triggerHandler(events.onError, [signalR._.error(message, /* source */ "TimeoutException")]);
+ connection.stop(/* async */ false, /* notifyServer */ false);
+ };
+
+ connection.reconnecting(function () {
+ var connection = this;
+
+ // Guard against state changing in a previous user defined even handler
+ if (connection.state === signalR.connectionState.reconnecting) {
+ stopReconnectingTimeout = window.setTimeout(function () { onReconnectTimeout(connection); }, connection.disconnectTimeout);
+ }
+ });
+
+ connection.stateChanged(function (data) {
+ if (data.oldState === signalR.connectionState.reconnecting) {
+ // Clear the pending reconnect timeout check
+ window.clearTimeout(stopReconnectingTimeout);
+ }
+ });
+
+ connection._.configuredStopReconnectingTimeout = true;
+ }
+ };
+
+ signalR = function (url, qs, logging) {
+ /// Creates a new SignalR connection for the given url
+ /// The URL of the long polling endpoint
+ ///
+ /// [Optional] Custom querystring parameters to add to the connection URL.
+ /// If an object, every non-function member will be added to the querystring.
+ /// If a string, it's added to the QS as specified.
+ ///
+ ///
+ /// [Optional] A flag indicating whether connection logging is enabled to the browser
+ /// console/log. Defaults to false.
+ ///
+
+ return new signalR.fn.init(url, qs, logging);
+ };
+
+ signalR._ = {
+ defaultContentType: "application/x-www-form-urlencoded; charset=UTF-8",
+
+ ieVersion: (function () {
+ var version,
+ matches;
+
+ if (window.navigator.appName === 'Microsoft Internet Explorer') {
+ // Check if the user agent has the pattern "MSIE (one or more numbers).(one or more numbers)";
+ matches = /MSIE ([0-9]+\.[0-9]+)/.exec(window.navigator.userAgent);
+
+ if (matches) {
+ version = window.parseFloat(matches[1]);
+ }
+ }
+
+ // undefined value means not IE
+ return version;
+ })(),
+
+ error: function (message, source, context) {
+ var e = new Error(message);
+ e.source = source;
+
+ if (typeof context !== "undefined") {
+ e.context = context;
+ }
+
+ return e;
+ },
+
+ transportError: function (message, transport, source, context) {
+ var e = this.error(message, source, context);
+ e.transport = transport ? transport.name : undefined;
+ return e;
+ },
+
+ format: function () {
+ /// Usage: format("Hi {0}, you are {1}!", "Foo", 100)
+ var s = arguments[0];
+ for (var i = 0; i < arguments.length - 1; i++) {
+ s = s.replace("{" + i + "}", arguments[i + 1]);
+ }
+ return s;
+ },
+
+ firefoxMajorVersion: function (userAgent) {
+ // Firefox user agents: http://useragentstring.com/pages/Firefox/
+ var matches = userAgent.match(/Firefox\/(\d+)/);
+ if (!matches || !matches.length || matches.length < 2) {
+ return 0;
+ }
+ return parseInt(matches[1], 10 /* radix */);
+ },
+
+ configurePingInterval: function (connection) {
+ var config = connection._.config,
+ onFail = function (error) {
+ $(connection).triggerHandler(events.onError, [error]);
+ };
+
+ if (config && !connection._.pingIntervalId && config.pingInterval) {
+ connection._.pingIntervalId = window.setInterval(function () {
+ signalR.transports._logic.pingServer(connection).fail(onFail);
+ }, config.pingInterval);
+ }
+ }
+ };
+
+ signalR.events = events;
+
+ signalR.resources = resources;
+
+ signalR.ajaxDefaults = ajaxDefaults;
+
+ signalR.changeState = changeState;
+
+ signalR.isDisconnecting = isDisconnecting;
+
+ signalR.connectionState = {
+ connecting: 0,
+ connected: 1,
+ reconnecting: 2,
+ disconnected: 4
+ };
+
+ signalR.hub = {
+ start: function () {
+ // This will get replaced with the real hub connection start method when hubs is referenced correctly
+ throw new Error("SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. .");
+ }
+ };
+
+ _pageWindow.load(function () { _pageLoaded = true; });
+
+ function validateTransport(requestedTransport, connection) {
+ /// Validates the requested transport by cross checking it with the pre-defined signalR.transports
+ /// The designated transports that the user has specified.
+ /// The connection that will be using the requested transports. Used for logging purposes.
+ ///
+
+ if ($.isArray(requestedTransport)) {
+ // Go through transport array and remove an "invalid" tranports
+ for (var i = requestedTransport.length - 1; i >= 0; i--) {
+ var transport = requestedTransport[i];
+ if ($.type(transport) !== "string" || !signalR.transports[transport]) {
+ connection.log("Invalid transport: " + transport + ", removing it from the transports list.");
+ requestedTransport.splice(i, 1);
+ }
+ }
+
+ // Verify we still have transports left, if we dont then we have invalid transports
+ if (requestedTransport.length === 0) {
+ connection.log("No transports remain within the specified transport array.");
+ requestedTransport = null;
+ }
+ } else if (!signalR.transports[requestedTransport] && requestedTransport !== "auto") {
+ connection.log("Invalid transport: " + requestedTransport.toString() + ".");
+ requestedTransport = null;
+ } else if (requestedTransport === "auto" && signalR._.ieVersion <= 8) {
+ // If we're doing an auto transport and we're IE8 then force longPolling, #1764
+ return ["longPolling"];
+
+ }
+
+ return requestedTransport;
+ }
+
+ function getDefaultPort(protocol) {
+ if (protocol === "http:") {
+ return 80;
+ } else if (protocol === "https:") {
+ return 443;
+ }
+ }
+
+ function addDefaultPort(protocol, url) {
+ // Remove ports from url. We have to check if there's a / or end of line
+ // following the port in order to avoid removing ports such as 8080.
+ if (url.match(/:\d+$/)) {
+ return url;
+ } else {
+ return url + ":" + getDefaultPort(protocol);
+ }
+ }
+
+ function ConnectingMessageBuffer(connection, drainCallback) {
+ var that = this,
+ buffer = [];
+
+ that.tryBuffer = function (message) {
+ if (connection.state === $.signalR.connectionState.connecting) {
+ buffer.push(message);
+
+ return true;
+ }
+
+ return false;
+ };
+
+ that.drain = function () {
+ // Ensure that the connection is connected when we drain (do not want to drain while a connection is not active)
+ if (connection.state === $.signalR.connectionState.connected) {
+ while (buffer.length > 0) {
+ drainCallback(buffer.shift());
+ }
+ }
+ };
+
+ that.clear = function () {
+ buffer = [];
+ };
+ }
+
+ signalR.fn = signalR.prototype = {
+ init: function (url, qs, logging) {
+ var $connection = $(this);
+
+ this.url = url;
+ this.qs = qs;
+ this.lastError = null;
+ this._ = {
+ keepAliveData: {},
+ connectingMessageBuffer: new ConnectingMessageBuffer(this, function (message) {
+ $connection.triggerHandler(events.onReceived, [message]);
+ }),
+ onFailedTimeoutHandle: null,
+ lastMessageAt: new Date().getTime(),
+ lastActiveAt: new Date().getTime(),
+ beatInterval: 5000, // Default value, will only be overridden if keep alive is enabled,
+ beatHandle: null,
+ totalTransportConnectTimeout: 0 // This will be the sum of the TransportConnectTimeout sent in response to negotiate and connection.transportConnectTimeout
+ };
+ if (typeof (logging) === "boolean") {
+ this.logging = logging;
+ }
+ },
+
+ _parseResponse: function (response) {
+ var that = this;
+
+ if (!response) {
+ return response;
+ } else if (typeof response === "string") {
+ return that.json.parse(response);
+ } else {
+ return response;
+ }
+ },
+
+ _originalJson: window.JSON,
+
+ json: window.JSON,
+
+ isCrossDomain: function (url, against) {
+ /// Checks if url is cross domain
+ /// The base URL
+ ///
+ /// An optional argument to compare the URL against, if not specified it will be set to window.location.
+ /// If specified it must contain a protocol and a host property.
+ ///
+ var link;
+
+ url = $.trim(url);
+
+ against = against || window.location;
+
+ if (url.indexOf("http") !== 0) {
+ return false;
+ }
+
+ // Create an anchor tag.
+ link = window.document.createElement("a");
+ link.href = url;
+
+ // When checking for cross domain we have to special case port 80 because the window.location will remove the
+ return link.protocol + addDefaultPort(link.protocol, link.host) !== against.protocol + addDefaultPort(against.protocol, against.host);
+ },
+
+ ajaxDataType: "text",
+
+ contentType: "application/json; charset=UTF-8",
+
+ logging: false,
+
+ state: signalR.connectionState.disconnected,
+
+ clientProtocol: "1.4",
+
+ reconnectDelay: 2000,
+
+ transportConnectTimeout: 0,
+
+ disconnectTimeout: 30000, // This should be set by the server in response to the negotiate request (30s default)
+
+ reconnectWindow: 30000, // This should be set by the server in response to the negotiate request
+
+ keepAliveWarnAt: 2 / 3, // Warn user of slow connection if we breach the X% mark of the keep alive timeout
+
+ start: function (options, callback) {
+ /// Starts the connection
+ /// Options map
+ /// A callback function to execute when the connection has started
+ var connection = this,
+ config = {
+ pingInterval: 300000,
+ waitForPageLoad: true,
+ transport: "auto",
+ jsonp: false
+ },
+ initialize,
+ deferred = connection._deferral || $.Deferred(), // Check to see if there is a pre-existing deferral that's being built on, if so we want to keep using it
+ parser = window.document.createElement("a");
+
+ connection.lastError = null;
+
+ // Persist the deferral so that if start is called multiple times the same deferral is used.
+ connection._deferral = deferred;
+
+ if (!connection.json) {
+ // no JSON!
+ throw new Error("SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. IE<8.");
+ }
+
+ if ($.type(options) === "function") {
+ // Support calling with single callback parameter
+ callback = options;
+ } else if ($.type(options) === "object") {
+ $.extend(config, options);
+ if ($.type(config.callback) === "function") {
+ callback = config.callback;
+ }
+ }
+
+ config.transport = validateTransport(config.transport, connection);
+
+ // If the transport is invalid throw an error and abort start
+ if (!config.transport) {
+ throw new Error("SignalR: Invalid transport(s) specified, aborting start.");
+ }
+
+ connection._.config = config;
+
+ // Check to see if start is being called prior to page load
+ // If waitForPageLoad is true we then want to re-direct function call to the window load event
+ if (!_pageLoaded && config.waitForPageLoad === true) {
+ connection._.deferredStartHandler = function () {
+ connection.start(options, callback);
+ };
+ _pageWindow.bind("load", connection._.deferredStartHandler);
+
+ return deferred.promise();
+ }
+
+ // If we're already connecting just return the same deferral as the original connection start
+ if (connection.state === signalR.connectionState.connecting) {
+ return deferred.promise();
+ } else if (changeState(connection,
+ signalR.connectionState.disconnected,
+ signalR.connectionState.connecting) === false) {
+ // We're not connecting so try and transition into connecting.
+ // If we fail to transition then we're either in connected or reconnecting.
+
+ deferred.resolve(connection);
+ return deferred.promise();
+ }
+
+ configureStopReconnectingTimeout(connection);
+
+ // Resolve the full url
+ parser.href = connection.url;
+ if (!parser.protocol || parser.protocol === ":") {
+ connection.protocol = window.document.location.protocol;
+ connection.host = parser.host || window.document.location.host;
+ } else {
+ connection.protocol = parser.protocol;
+ connection.host = parser.host;
+ }
+
+ connection.baseUrl = connection.protocol + "//" + connection.host;
+
+ // Set the websocket protocol
+ connection.wsProtocol = connection.protocol === "https:" ? "wss://" : "ws://";
+
+ // If jsonp with no/auto transport is specified, then set the transport to long polling
+ // since that is the only transport for which jsonp really makes sense.
+ // Some developers might actually choose to specify jsonp for same origin requests
+ // as demonstrated by Issue #623.
+ if (config.transport === "auto" && config.jsonp === true) {
+ config.transport = "longPolling";
+ }
+
+ // If the url is protocol relative, prepend the current windows protocol to the url.
+ if (connection.url.indexOf("//") === 0) {
+ connection.url = window.location.protocol + connection.url;
+ connection.log("Protocol relative URL detected, normalizing it to '" + connection.url + "'.");
+ }
+
+ if (this.isCrossDomain(connection.url)) {
+ connection.log("Auto detected cross domain url.");
+
+ if (config.transport === "auto") {
+ // TODO: Support XDM with foreverFrame
+ config.transport = ["webSockets", "serverSentEvents", "longPolling"];
+ }
+
+ if (typeof (config.withCredentials) === "undefined") {
+ config.withCredentials = true;
+ }
+
+ // Determine if jsonp is the only choice for negotiation, ajaxSend and ajaxAbort.
+ // i.e. if the browser doesn't supports CORS
+ // If it is, ignore any preference to the contrary, and switch to jsonp.
+ if (!config.jsonp) {
+ config.jsonp = !$.support.cors;
+
+ if (config.jsonp) {
+ connection.log("Using jsonp because this browser doesn't support CORS.");
+ }
+ }
+
+ connection.contentType = signalR._.defaultContentType;
+ }
+
+ connection.withCredentials = config.withCredentials;
+
+ connection.ajaxDataType = config.jsonp ? "jsonp" : "text";
+
+ $(connection).bind(events.onStart, function (e, data) {
+ if ($.type(callback) === "function") {
+ callback.call(connection);
+ }
+ deferred.resolve(connection);
+ });
+
+ initialize = function (transports, index) {
+ var noTransportError = signalR._.error(resources.noTransportOnInit);
+
+ index = index || 0;
+ if (index >= transports.length) {
+ // No transport initialized successfully
+ $(connection).triggerHandler(events.onError, [noTransportError]);
+ deferred.reject(noTransportError);
+ // Stop the connection if it has connected and move it into the disconnected state
+ connection.stop();
+ return;
+ }
+
+ // The connection was aborted
+ if (connection.state === signalR.connectionState.disconnected) {
+ return;
+ }
+
+ var transportName = transports[index],
+ transport = signalR.transports[transportName],
+ initializationComplete = false,
+ onFailed = function () {
+ // Check if we've already triggered onFailed, onStart
+ if (!initializationComplete) {
+ initializationComplete = true;
+ window.clearTimeout(connection._.onFailedTimeoutHandle);
+ transport.stop(connection);
+ initialize(transports, index + 1);
+ }
+ };
+
+ connection.transport = transport;
+
+ try {
+ connection._.onFailedTimeoutHandle = window.setTimeout(function () {
+ connection.log(transport.name + " timed out when trying to connect.");
+ onFailed();
+ }, connection._.totalTransportConnectTimeout);
+
+ transport.start(connection, function () { // success
+ // Firefox 11+ doesn't allow sync XHR withCredentials: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#withCredentials
+ var isFirefox11OrGreater = signalR._.firefoxMajorVersion(window.navigator.userAgent) >= 11,
+ asyncAbort = !!connection.withCredentials && isFirefox11OrGreater;
+
+ // The connection was aborted while initializing transports
+ if (connection.state === signalR.connectionState.disconnected) {
+ return;
+ }
+
+ if (!initializationComplete) {
+ initializationComplete = true;
+
+ window.clearTimeout(connection._.onFailedTimeoutHandle);
+
+ if (supportsKeepAlive(connection)) {
+ signalR.transports._logic.monitorKeepAlive(connection);
+ }
+
+ signalR.transports._logic.startHeartbeat(connection);
+
+ // Used to ensure low activity clients maintain their authentication.
+ // Must be configured once a transport has been decided to perform valid ping requests.
+ signalR._.configurePingInterval(connection);
+
+ changeState(connection,
+ signalR.connectionState.connecting,
+ signalR.connectionState.connected);
+
+ // Drain any incoming buffered messages (messages that came in prior to connect)
+ connection._.connectingMessageBuffer.drain();
+
+ $(connection).triggerHandler(events.onStart);
+
+ // wire the stop handler for when the user leaves the page
+ _pageWindow.bind("unload", function () {
+ connection.log("Window unloading, stopping the connection.");
+
+ connection.stop(asyncAbort);
+ });
+
+ if (isFirefox11OrGreater) {
+ // Firefox does not fire cross-domain XHRs in the normal unload handler on tab close.
+ // #2400
+ _pageWindow.bind("beforeunload", function () {
+ // If connection.stop() runs runs in beforeunload and fails, it will also fail
+ // in unload unless connection.stop() runs after a timeout.
+ window.setTimeout(function () {
+ connection.stop(asyncAbort);
+ }, 0);
+ });
+ }
+ }
+ }, onFailed);
+ }
+ catch (error) {
+ connection.log(transport.name + " transport threw '" + error.message + "' when attempting to start.");
+ onFailed();
+ }
+ };
+
+ var url = connection.url + "/negotiate",
+ onFailed = function (error, connection) {
+ var err = signalR._.error(resources.errorOnNegotiate, error, connection._.negotiateRequest);
+
+ $(connection).triggerHandler(events.onError, err);
+ deferred.reject(err);
+ // Stop the connection if negotiate failed
+ connection.stop();
+ };
+
+ $(connection).triggerHandler(events.onStarting);
+
+ url = signalR.transports._logic.prepareQueryString(connection, url);
+
+ connection.log("Negotiating with '" + url + "'.");
+
+ // Save the ajax negotiate request object so we can abort it if stop is called while the request is in flight.
+ connection._.negotiateRequest = signalR.transports._logic.ajax(connection, {
+ url: url,
+ error: function (error, statusText) {
+ // We don't want to cause any errors if we're aborting our own negotiate request.
+ if (statusText !== _negotiateAbortText) {
+ onFailed(error, connection);
+ } else {
+ // This rejection will noop if the deferred has already been resolved or rejected.
+ deferred.reject(signalR._.error(resources.stoppedWhileNegotiating, null /* error */, connection._.negotiateRequest));
+ }
+ },
+ success: function (result) {
+ var res,
+ keepAliveData,
+ protocolError,
+ transports = [],
+ supportedTransports = [];
+
+ try {
+ res = connection._parseResponse(result);
+ } catch (error) {
+ onFailed(signalR._.error(resources.errorParsingNegotiateResponse, error), connection);
+ return;
+ }
+
+ keepAliveData = connection._.keepAliveData;
+ connection.appRelativeUrl = res.Url;
+ connection.id = res.ConnectionId;
+ connection.token = res.ConnectionToken;
+ connection.webSocketServerUrl = res.WebSocketServerUrl;
+ connection._.longPollDelay = res.LongPollDelay * 1000; // in ms
+
+ // Once the server has labeled the PersistentConnection as Disconnected, we should stop attempting to reconnect
+ // after res.DisconnectTimeout seconds.
+ connection.disconnectTimeout = res.DisconnectTimeout * 1000; // in ms
+
+ // Add the TransportConnectTimeout from the response to the transportConnectTimeout from the client to calculate the total timeout
+ connection._.totalTransportConnectTimeout = connection.transportConnectTimeout + res.TransportConnectTimeout * 1000;
+
+ // If we have a keep alive
+ if (res.KeepAliveTimeout) {
+ // Register the keep alive data as activated
+ keepAliveData.activated = true;
+
+ // Timeout to designate when to force the connection into reconnecting converted to milliseconds
+ keepAliveData.timeout = res.KeepAliveTimeout * 1000;
+
+ // Timeout to designate when to warn the developer that the connection may be dead or is not responding.
+ keepAliveData.timeoutWarning = keepAliveData.timeout * connection.keepAliveWarnAt;
+
+ // Instantiate the frequency in which we check the keep alive. It must be short in order to not miss/pick up any changes
+ connection._.beatInterval = (keepAliveData.timeout - keepAliveData.timeoutWarning) / 3;
+ } else {
+ keepAliveData.activated = false;
+ }
+
+ connection.reconnectWindow = connection.disconnectTimeout + (keepAliveData.timeout || 0);
+
+ if (!res.ProtocolVersion || res.ProtocolVersion !== connection.clientProtocol) {
+ protocolError = signalR._.error(signalR._.format(resources.protocolIncompatible, connection.clientProtocol, res.ProtocolVersion));
+ $(connection).triggerHandler(events.onError, [protocolError]);
+ deferred.reject(protocolError);
+
+ return;
+ }
+
+ $.each(signalR.transports, function (key) {
+ if ((key.indexOf("_") === 0) || (key === "webSockets" && !res.TryWebSockets)) {
+ return true;
+ }
+ supportedTransports.push(key);
+ });
+
+ if ($.isArray(config.transport)) {
+ $.each(config.transport, function (_, transport) {
+ if ($.inArray(transport, supportedTransports) >= 0) {
+ transports.push(transport);
+ }
+ });
+ } else if (config.transport === "auto") {
+ transports = supportedTransports;
+ } else if ($.inArray(config.transport, supportedTransports) >= 0) {
+ transports.push(config.transport);
+ }
+
+ initialize(transports);
+ }
+ });
+
+ return deferred.promise();
+ },
+
+ starting: function (callback) {
+ /// Adds a callback that will be invoked before anything is sent over the connection
+ /// A callback function to execute before the connection is fully instantiated.
+ ///
+ var connection = this;
+ $(connection).bind(events.onStarting, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ send: function (data) {
+ /// Sends data over the connection
+ /// The data to send over the connection
+ ///
+ var connection = this;
+
+ if (connection.state === signalR.connectionState.disconnected) {
+ // Connection hasn't been started yet
+ throw new Error("SignalR: Connection must be started before data can be sent. Call .start() before .send()");
+ }
+
+ if (connection.state === signalR.connectionState.connecting) {
+ // Connection hasn't been started yet
+ throw new Error("SignalR: Connection has not been fully initialized. Use .start().done() or .start().fail() to run logic after the connection has started.");
+ }
+
+ connection.transport.send(connection, data);
+ // REVIEW: Should we return deferred here?
+ return connection;
+ },
+
+ received: function (callback) {
+ /// Adds a callback that will be invoked after anything is received over the connection
+ /// A callback function to execute when any data is received on the connection
+ ///
+ var connection = this;
+ $(connection).bind(events.onReceived, function (e, data) {
+ callback.call(connection, data);
+ });
+ return connection;
+ },
+
+ stateChanged: function (callback) {
+ /// Adds a callback that will be invoked when the connection state changes
+ /// A callback function to execute when the connection state changes
+ ///
+ var connection = this;
+ $(connection).bind(events.onStateChanged, function (e, data) {
+ callback.call(connection, data);
+ });
+ return connection;
+ },
+
+ error: function (callback) {
+ /// Adds a callback that will be invoked after an error occurs with the connection
+ /// A callback function to execute when an error occurs on the connection
+ ///
+ var connection = this;
+ $(connection).bind(events.onError, function (e, errorData, sendData) {
+ connection.lastError = errorData;
+ // In practice 'errorData' is the SignalR built error object.
+ // In practice 'sendData' is undefined for all error events except those triggered by
+ // 'ajaxSend' and 'webSockets.send'.'sendData' is the original send payload.
+ callback.call(connection, errorData, sendData);
+ });
+ return connection;
+ },
+
+ disconnected: function (callback) {
+ /// Adds a callback that will be invoked when the client disconnects
+ /// A callback function to execute when the connection is broken
+ ///
+ var connection = this;
+ $(connection).bind(events.onDisconnect, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ connectionSlow: function (callback) {
+ /// Adds a callback that will be invoked when the client detects a slow connection
+ /// A callback function to execute when the connection is slow
+ ///
+ var connection = this;
+ $(connection).bind(events.onConnectionSlow, function (e, data) {
+ callback.call(connection);
+ });
+
+ return connection;
+ },
+
+ reconnecting: function (callback) {
+ /// Adds a callback that will be invoked when the underlying transport begins reconnecting
+ /// A callback function to execute when the connection enters a reconnecting state
+ ///
+ var connection = this;
+ $(connection).bind(events.onReconnecting, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ reconnected: function (callback) {
+ /// Adds a callback that will be invoked when the underlying transport reconnects
+ /// A callback function to execute when the connection is restored
+ ///
+ var connection = this;
+ $(connection).bind(events.onReconnect, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ stop: function (async, notifyServer) {
+ /// Stops listening
+ /// Whether or not to asynchronously abort the connection
+ /// Whether we want to notify the server that we are aborting the connection
+ ///
+ var connection = this,
+ // Save deferral because this is always cleaned up
+ deferral = connection._deferral;
+
+ // Verify that we've bound a load event.
+ if (connection._.deferredStartHandler) {
+ // Unbind the event.
+ _pageWindow.unbind("load", connection._.deferredStartHandler);
+ }
+
+ // Always clean up private non-timeout based state.
+ delete connection._.config;
+ delete connection._.deferredStartHandler;
+
+ // This needs to be checked despite the connection state because a connection start can be deferred until page load.
+ // If we've deferred the start due to a page load we need to unbind the "onLoad" -> start event.
+ if (!_pageLoaded && (!connection._.config || connection._.config.waitForPageLoad === true)) {
+ connection.log("Stopping connection prior to negotiate.");
+
+ // If we have a deferral we should reject it
+ if (deferral) {
+ deferral.reject(signalR._.error(resources.stoppedWhileLoading));
+ }
+
+ // Short-circuit because the start has not been fully started.
+ return;
+ }
+
+ if (connection.state === signalR.connectionState.disconnected) {
+ return;
+ }
+
+ connection.log("Stopping connection.");
+
+ changeState(connection, connection.state, signalR.connectionState.disconnected);
+
+ // Clear this no matter what
+ window.clearTimeout(connection._.beatHandle);
+ window.clearTimeout(connection._.onFailedTimeoutHandle);
+ window.clearInterval(connection._.pingIntervalId);
+
+ if (connection.transport) {
+ connection.transport.stop(connection);
+
+ if (notifyServer !== false) {
+ connection.transport.abort(connection, async);
+ }
+
+ if (supportsKeepAlive(connection)) {
+ signalR.transports._logic.stopMonitoringKeepAlive(connection);
+ }
+
+ connection.transport = null;
+ }
+
+ if (connection._.negotiateRequest) {
+ // If the negotiation request has already completed this will noop.
+ connection._.negotiateRequest.abort(_negotiateAbortText);
+ delete connection._.negotiateRequest;
+ }
+
+ // Ensure that tryAbortStartRequest is called before connection._deferral is deleted
+ signalR.transports._logic.tryAbortStartRequest(connection);
+
+ // Trigger the disconnect event
+ $(connection).triggerHandler(events.onDisconnect);
+
+ delete connection._deferral;
+ delete connection.messageId;
+ delete connection.groupsToken;
+ delete connection.id;
+ delete connection._.pingIntervalId;
+ delete connection._.lastMessageAt;
+ delete connection._.lastActiveAt;
+ delete connection._.longPollDelay;
+
+ // Clear out our message buffer
+ connection._.connectingMessageBuffer.clear();
+
+ return connection;
+ },
+
+ log: function (msg) {
+ log(msg, this.logging);
+ }
+ };
+
+ signalR.fn.init.prototype = signalR.fn;
+
+ signalR.noConflict = function () {
+ /// Reinstates the original value of $.connection and returns the signalR object for manual assignment
+ ///
+ if ($.connection === signalR) {
+ $.connection = _connection;
+ }
+ return signalR;
+ };
+
+ if ($.connection) {
+ _connection = $.connection;
+ }
+
+ $.connection = $.signalR = signalR;
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.common.js */
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ startAbortText = "__Start Aborted__",
+ transportLogic;
+
+ signalR.transports = {};
+
+ function beat(connection) {
+ if (connection._.keepAliveData.monitoring) {
+ checkIfAlive(connection);
+ }
+
+ // Ensure that we successfully marked active before continuing the heartbeat.
+ if (transportLogic.markActive(connection)) {
+ connection._.beatHandle = window.setTimeout(function () {
+ beat(connection);
+ }, connection._.beatInterval);
+ }
+ }
+
+ function checkIfAlive(connection) {
+ var keepAliveData = connection._.keepAliveData,
+ timeElapsed;
+
+ // Only check if we're connected
+ if (connection.state === signalR.connectionState.connected) {
+ timeElapsed = new Date().getTime() - connection._.lastMessageAt;
+
+ // Check if the keep alive has completely timed out
+ if (timeElapsed >= keepAliveData.timeout) {
+ connection.log("Keep alive timed out. Notifying transport that connection has been lost.");
+
+ // Notify transport that the connection has been lost
+ connection.transport.lostConnection(connection);
+ } else if (timeElapsed >= keepAliveData.timeoutWarning) {
+ // This is to assure that the user only gets a single warning
+ if (!keepAliveData.userNotified) {
+ connection.log("Keep alive has been missed, connection may be dead/slow.");
+ $(connection).triggerHandler(events.onConnectionSlow);
+ keepAliveData.userNotified = true;
+ }
+ } else {
+ keepAliveData.userNotified = false;
+ }
+ }
+ }
+
+ function getAjaxUrl(connection, path) {
+ var url = connection.url + path;
+
+ if (connection.transport) {
+ url += "?transport=" + connection.transport.name;
+ }
+
+ return transportLogic.prepareQueryString(connection, url);
+ }
+
+ transportLogic = signalR.transports._logic = {
+ ajax: function (connection, options) {
+ return $.ajax(
+ $.extend(/*deep copy*/ true, {}, $.signalR.ajaxDefaults, {
+ type: "GET",
+ data: {},
+ xhrFields: { withCredentials: connection.withCredentials },
+ contentType: connection.contentType,
+ dataType: connection.ajaxDataType
+ }, options));
+ },
+
+ pingServer: function (connection) {
+ /// Pings the server
+ /// Connection associated with the server ping
+ ///
+ var url,
+ xhr,
+ deferral = $.Deferred();
+
+ if (connection.transport) {
+ url = connection.url + "/ping";
+
+ url = transportLogic.addQs(url, connection.qs);
+
+ xhr = transportLogic.ajax(connection, {
+ url: url,
+ success: function (result) {
+ var data;
+
+ try {
+ data = connection._parseResponse(result);
+ }
+ catch (error) {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.pingServerFailedParse,
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ connection.stop();
+ return;
+ }
+
+ if (data.Response === "pong") {
+ deferral.resolve();
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR._.format(signalR.resources.pingServerFailedInvalidResponse, result),
+ connection.transport,
+ null /* error */,
+ xhr
+ )
+ );
+ }
+ },
+ error: function (error) {
+ if (error.status === 401 || error.status === 403) {
+ deferral.reject(
+ signalR._.transportError(
+ signalR._.format(signalR.resources.pingServerFailedStatusCode, error.status),
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ connection.stop();
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.pingServerFailed,
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ }
+ }
+ });
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.noConnectionTransport,
+ connection.transport
+ )
+ );
+ }
+
+ return deferral.promise();
+ },
+
+ prepareQueryString: function (connection, url) {
+ var preparedUrl;
+
+ // Use addQs to start since it handles the ?/& prefix for us
+ preparedUrl = transportLogic.addQs(url, "clientProtocol=" + connection.clientProtocol);
+
+ // Add the user-specified query string params if any
+ preparedUrl = transportLogic.addQs(preparedUrl, connection.qs);
+
+ if (connection.token) {
+ preparedUrl += "&connectionToken=" + window.encodeURIComponent(connection.token);
+ }
+
+ if (connection.data) {
+ preparedUrl += "&connectionData=" + window.encodeURIComponent(connection.data);
+ }
+
+ return preparedUrl;
+ },
+
+ addQs: function (url, qs) {
+ var appender = url.indexOf("?") !== -1 ? "&" : "?",
+ firstChar;
+
+ if (!qs) {
+ return url;
+ }
+
+ if (typeof (qs) === "object") {
+ return url + appender + $.param(qs);
+ }
+
+ if (typeof (qs) === "string") {
+ firstChar = qs.charAt(0);
+
+ if (firstChar === "?" || firstChar === "&") {
+ appender = "";
+ }
+
+ return url + appender + qs;
+ }
+
+ throw new Error("Query string property must be either a string or object.");
+ },
+
+ getUrl: function (connection, transport, reconnecting, poll) {
+ /// Gets the url for making a GET based connect request
+ var baseUrl = transport === "webSockets" ? "" : connection.baseUrl,
+ url = baseUrl + connection.appRelativeUrl,
+ qs = "transport=" + transport;
+
+ if (connection.groupsToken) {
+ qs += "&groupsToken=" + window.encodeURIComponent(connection.groupsToken);
+ }
+
+ if (!reconnecting) {
+ url += "/connect";
+ } else {
+ if (poll) {
+ // longPolling transport specific
+ url += "/poll";
+ } else {
+ url += "/reconnect";
+ }
+
+ if (connection.messageId) {
+ qs += "&messageId=" + window.encodeURIComponent(connection.messageId);
+ }
+ }
+ url += "?" + qs;
+ url = transportLogic.prepareQueryString(connection, url);
+ url += "&tid=" + Math.floor(Math.random() * 11);
+ return url;
+ },
+
+ maximizePersistentResponse: function (minPersistentResponse) {
+ return {
+ MessageId: minPersistentResponse.C,
+ Messages: minPersistentResponse.M,
+ Initialized: typeof (minPersistentResponse.S) !== "undefined" ? true : false,
+ Disconnect: typeof (minPersistentResponse.D) !== "undefined" ? true : false,
+ ShouldReconnect: typeof (minPersistentResponse.T) !== "undefined" ? true : false,
+ LongPollDelay: minPersistentResponse.L,
+ GroupsToken: minPersistentResponse.G
+ };
+ },
+
+ updateGroups: function (connection, groupsToken) {
+ if (groupsToken) {
+ connection.groupsToken = groupsToken;
+ }
+ },
+
+ stringifySend: function (connection, message) {
+ if (typeof (message) === "string" || typeof (message) === "undefined" || message == undefined) {
+ return message;
+ }
+ return connection.json.stringify(message);
+ },
+
+ ajaxSend: function (connection, data) {
+ var payload = transportLogic.stringifySend(connection, data),
+ url = getAjaxUrl(connection, "/send"),
+ xhr,
+ onFail = function (error, connection) {
+ $(connection).triggerHandler(events.onError, [signalR._.transportError(signalR.resources.sendFailed, connection.transport, error, xhr), data]);
+ };
+
+
+ xhr = transportLogic.ajax(connection, {
+ url: url,
+ type: connection.ajaxDataType === "jsonp" ? "GET" : "POST",
+ contentType: signalR._.defaultContentType,
+ data: {
+ data: payload
+ },
+ success: function (result) {
+ var res;
+
+ if (result) {
+ try {
+ res = connection._parseResponse(result);
+ }
+ catch (error) {
+ onFail(error, connection);
+ connection.stop();
+ return;
+ }
+
+ transportLogic.triggerReceived(connection, res);
+ }
+ },
+ error: function (error, textStatus) {
+ if (textStatus === "abort" || textStatus === "parsererror") {
+ // The parsererror happens for sends that don't return any data, and hence
+ // don't write the jsonp callback to the response. This is harder to fix on the server
+ // so just hack around it on the client for now.
+ return;
+ }
+
+ onFail(error, connection);
+ }
+ });
+
+ return xhr;
+ },
+
+ ajaxAbort: function (connection, async) {
+ if (typeof (connection.transport) === "undefined") {
+ return;
+ }
+
+ // Async by default unless explicitly overidden
+ async = typeof async === "undefined" ? true : async;
+
+ var url = getAjaxUrl(connection, "/abort");
+
+ transportLogic.ajax(connection, {
+ url: url,
+ async: async,
+ timeout: 1000,
+ type: "POST"
+ });
+
+ connection.log("Fired ajax abort async = " + async + ".");
+ },
+
+ tryInitialize: function (connection, persistentResponse, onInitialized) {
+ var startUrl,
+ xhr,
+ rejectDeferred = function (error) {
+ var deferred = connection._deferral;
+ if (deferred) {
+ deferred.reject(error);
+ }
+ },
+ triggerStartError = function (error) {
+ $(connection).triggerHandler(events.onError, [error]);
+ rejectDeferred(error);
+ connection.stop();
+ };
+
+ if (persistentResponse.Initialized) {
+ startUrl = getAjaxUrl(connection, "/start");
+
+ xhr = transportLogic.ajax(connection, {
+ url: startUrl,
+ success: function (result) {
+ var data;
+
+ try {
+ data = connection._parseResponse(result);
+ } catch (error) {
+ triggerStartError(signalR._.error(
+ signalR._.format(signalR.resources.errorParsingStartResponse, result),
+ error, xhr));
+ return;
+ }
+
+ if (data.Response === "started") {
+ onInitialized();
+ } else {
+ triggerStartError(signalR._.error(
+ signalR._.format(signalR.resources.invalidStartResponse, result),
+ null /* error */, xhr));
+ }
+ },
+ error: function (error, statusText) {
+ if (statusText !== startAbortText) {
+ triggerStartError(signalR._.error(
+ signalR.resources.errorDuringStartRequest,
+ error, xhr));
+ } else {
+ // Stop has been called
+ rejectDeferred(signalR._.error(
+ signalR.resources.stoppedDuringStartRequest,
+ null /* error */, xhr));
+ }
+ }
+ });
+
+ connection._.startRequest = xhr;
+ }
+ },
+
+ tryAbortStartRequest: function (connection) {
+ if (connection._.startRequest) {
+ // If the start request has already completed this will noop.
+ connection._.startRequest.abort(startAbortText);
+ delete connection._.startRequest;
+ }
+ },
+
+ triggerReceived: function (connection, data) {
+ if (!connection._.connectingMessageBuffer.tryBuffer(data)) {
+ $(connection).triggerHandler(events.onReceived, [data]);
+ }
+ },
+
+ processMessages: function (connection, minData, onInitialized) {
+ var data;
+
+ // Update the last message time stamp
+ transportLogic.markLastMessage(connection);
+
+ if (minData) {
+ data = transportLogic.maximizePersistentResponse(minData);
+
+ transportLogic.updateGroups(connection, data.GroupsToken);
+
+ if (data.MessageId) {
+ connection.messageId = data.MessageId;
+ }
+
+ if (data.Messages) {
+ $.each(data.Messages, function (index, message) {
+ transportLogic.triggerReceived(connection, message);
+ });
+
+ transportLogic.tryInitialize(connection, data, onInitialized);
+ }
+ }
+ },
+
+ monitorKeepAlive: function (connection) {
+ var keepAliveData = connection._.keepAliveData;
+
+ // If we haven't initiated the keep alive timeouts then we need to
+ if (!keepAliveData.monitoring) {
+ keepAliveData.monitoring = true;
+
+ transportLogic.markLastMessage(connection);
+
+ // Save the function so we can unbind it on stop
+ connection._.keepAliveData.reconnectKeepAliveUpdate = function () {
+ // Mark a new message so that keep alive doesn't time out connections
+ transportLogic.markLastMessage(connection);
+ };
+
+ // Update Keep alive on reconnect
+ $(connection).bind(events.onReconnect, connection._.keepAliveData.reconnectKeepAliveUpdate);
+
+ connection.log("Now monitoring keep alive with a warning timeout of " + keepAliveData.timeoutWarning + " and a connection lost timeout of " + keepAliveData.timeout + ".");
+ } else {
+ connection.log("Tried to monitor keep alive but it's already being monitored.");
+ }
+ },
+
+ stopMonitoringKeepAlive: function (connection) {
+ var keepAliveData = connection._.keepAliveData;
+
+ // Only attempt to stop the keep alive monitoring if its being monitored
+ if (keepAliveData.monitoring) {
+ // Stop monitoring
+ keepAliveData.monitoring = false;
+
+ // Remove the updateKeepAlive function from the reconnect event
+ $(connection).unbind(events.onReconnect, connection._.keepAliveData.reconnectKeepAliveUpdate);
+
+ // Clear all the keep alive data
+ connection._.keepAliveData = {};
+ connection.log("Stopping the monitoring of the keep alive.");
+ }
+ },
+
+ startHeartbeat: function (connection) {
+ connection._.lastActiveAt = new Date().getTime();
+ beat(connection);
+ },
+
+ markLastMessage: function (connection) {
+ connection._.lastMessageAt = new Date().getTime();
+ },
+
+ markActive: function (connection) {
+ if (transportLogic.verifyLastActive(connection)) {
+ connection._.lastActiveAt = new Date().getTime();
+ return true;
+ }
+
+ return false;
+ },
+
+ isConnectedOrReconnecting: function (connection) {
+ return connection.state === signalR.connectionState.connected ||
+ connection.state === signalR.connectionState.reconnecting;
+ },
+
+ ensureReconnectingState: function (connection) {
+ if (changeState(connection,
+ signalR.connectionState.connected,
+ signalR.connectionState.reconnecting) === true) {
+ $(connection).triggerHandler(events.onReconnecting);
+ }
+ return connection.state === signalR.connectionState.reconnecting;
+ },
+
+ clearReconnectTimeout: function (connection) {
+ if (connection && connection._.reconnectTimeout) {
+ window.clearTimeout(connection._.reconnectTimeout);
+ delete connection._.reconnectTimeout;
+ }
+ },
+
+ verifyLastActive: function (connection) {
+ if (new Date().getTime() - connection._.lastActiveAt >= connection.reconnectWindow) {
+ var message = signalR._.format(signalR.resources.reconnectWindowTimeout, new Date(connection._.lastActiveAt), connection.reconnectWindow);
+ connection.log(message);
+ $(connection).triggerHandler(events.onError, [signalR._.error(message, /* source */ "TimeoutException")]);
+ connection.stop(/* async */ false, /* notifyServer */ false);
+ return false;
+ }
+
+ return true;
+ },
+
+ reconnect: function (connection, transportName) {
+ var transport = signalR.transports[transportName];
+
+ // We should only set a reconnectTimeout if we are currently connected
+ // and a reconnectTimeout isn't already set.
+ if (transportLogic.isConnectedOrReconnecting(connection) && !connection._.reconnectTimeout) {
+ // Need to verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ connection._.reconnectTimeout = window.setTimeout(function () {
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ transport.stop(connection);
+
+ if (transportLogic.ensureReconnectingState(connection)) {
+ connection.log(transportName + " reconnecting.");
+ transport.start(connection);
+ }
+ }, connection.reconnectDelay);
+ }
+ },
+
+ handleParseFailure: function (connection, result, error, onFailed, context) {
+ // If we're in the initialization phase trigger onFailed, otherwise stop the connection.
+ if (connection.state === signalR.connectionState.connecting) {
+ connection.log("Failed to parse server response while attempting to connect.");
+ onFailed();
+ } else {
+ $(connection).triggerHandler(events.onError, [
+ signalR._.transportError(
+ signalR._.format(signalR.resources.parseFailed, result),
+ connection.transport,
+ error,
+ context)]);
+ connection.stop();
+ }
+ },
+
+ foreverFrame: {
+ count: 0,
+ connections: {}
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.webSockets.js */
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic;
+
+ signalR.transports.webSockets = {
+ name: "webSockets",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ send: function (connection, data) {
+ var payload = transportLogic.stringifySend(connection, data);
+
+ try {
+ connection.socket.send(payload);
+ } catch (ex) {
+ $(connection).triggerHandler(events.onError,
+ [signalR._.transportError(
+ signalR.resources.webSocketsInvalidState,
+ connection.transport,
+ ex,
+ connection.socket
+ ),
+ data]);
+ }
+ },
+
+ start: function (connection, onSuccess, onFailed) {
+ var url,
+ opened = false,
+ that = this,
+ reconnecting = !onSuccess,
+ $connection = $(connection);
+
+ if (!window.WebSocket) {
+ onFailed();
+ return;
+ }
+
+ if (!connection.socket) {
+ if (connection.webSocketServerUrl) {
+ url = connection.webSocketServerUrl;
+ } else {
+ url = connection.wsProtocol + connection.host;
+ }
+
+ url += transportLogic.getUrl(connection, this.name, reconnecting);
+
+ connection.log("Connecting to websocket endpoint '" + url + "'.");
+ connection.socket = new window.WebSocket(url);
+
+ connection.socket.onopen = function () {
+ opened = true;
+ connection.log("Websocket opened.");
+
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ $connection.triggerHandler(events.onReconnect);
+ }
+ };
+
+ connection.socket.onclose = function (event) {
+ // Only handle a socket close if the close is from the current socket.
+ // Sometimes on disconnect the server will push down an onclose event
+ // to an expired socket.
+
+ if (this === connection.socket) {
+ if (!opened) {
+ if (onFailed) {
+ onFailed();
+ } else if (reconnecting) {
+ that.reconnect(connection);
+ }
+ return;
+ } else if (typeof event.wasClean !== "undefined" && event.wasClean === false) {
+ // Ideally this would use the websocket.onerror handler (rather than checking wasClean in onclose) but
+ // I found in some circumstances Chrome won't call onerror. This implementation seems to work on all browsers.
+ $(connection).triggerHandler(events.onError, [signalR._.transportError(
+ signalR.resources.webSocketClosed,
+ connection.transport,
+ event)]);
+ connection.log("Unclean disconnect from websocket: " + event.reason || "[no reason given].");
+ } else {
+ connection.log("Websocket closed.");
+ }
+
+ that.reconnect(connection);
+ }
+ };
+
+ connection.socket.onmessage = function (event) {
+ var data;
+
+ try {
+ data = connection._parseResponse(event.data);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(connection, event.data, error, onFailed, event);
+ return;
+ }
+
+ if (data) {
+ // data.M is PersistentResponse.Messages
+ if ($.isEmptyObject(data) || data.M) {
+ transportLogic.processMessages(connection, data, onSuccess);
+ } else {
+ // For websockets we need to trigger onReceived
+ // for callbacks to outgoing hub calls.
+ transportLogic.triggerReceived(connection, data);
+ }
+ }
+ };
+ }
+ },
+
+ reconnect: function (connection) {
+ transportLogic.reconnect(connection, this.name);
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ stop: function (connection) {
+ // Don't trigger a reconnect after stopping
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (connection.socket) {
+ connection.log("Closing the Websocket.");
+ connection.socket.close();
+ connection.socket = null;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.serverSentEvents.js */
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic,
+ clearReconnectAttemptTimeout = function (connection) {
+ window.clearTimeout(connection._.reconnectAttemptTimeoutHandle);
+ delete connection._.reconnectAttemptTimeoutHandle;
+ };
+
+ signalR.transports.serverSentEvents = {
+ name: "serverSentEvents",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ timeOut: 3000,
+
+ start: function (connection, onSuccess, onFailed) {
+ var that = this,
+ opened = false,
+ $connection = $(connection),
+ reconnecting = !onSuccess,
+ url;
+
+ if (connection.eventSource) {
+ connection.log("The connection already has an event source. Stopping it.");
+ connection.stop();
+ }
+
+ if (!window.EventSource) {
+ if (onFailed) {
+ connection.log("This browser doesn't support SSE.");
+ onFailed();
+ }
+ return;
+ }
+
+ url = transportLogic.getUrl(connection, this.name, reconnecting);
+
+ try {
+ connection.log("Attempting to connect to SSE endpoint '" + url + "'.");
+ connection.eventSource = new window.EventSource(url, { withCredentials: connection.withCredentials });
+ }
+ catch (e) {
+ connection.log("EventSource failed trying to connect with error " + e.Message + ".");
+ if (onFailed) {
+ // The connection failed, call the failed callback
+ onFailed();
+ } else {
+ $connection.triggerHandler(events.onError, [signalR._.transportError(signalR.resources.eventSourceFailedToConnect, connection.transport, e)]);
+ if (reconnecting) {
+ // If we were reconnecting, rather than doing initial connect, then try reconnect again
+ that.reconnect(connection);
+ }
+ }
+ return;
+ }
+
+ if (reconnecting) {
+ connection._.reconnectAttemptTimeoutHandle = window.setTimeout(function () {
+ if (opened === false) {
+ // If we're reconnecting and the event source is attempting to connect,
+ // don't keep retrying. This causes duplicate connections to spawn.
+ if (connection.eventSource.readyState !== window.EventSource.OPEN) {
+ // If we were reconnecting, rather than doing initial connect, then try reconnect again
+ that.reconnect(connection);
+ }
+ }
+ },
+ that.timeOut);
+ }
+
+ connection.eventSource.addEventListener("open", function (e) {
+ connection.log("EventSource connected.");
+
+ clearReconnectAttemptTimeout(connection);
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (opened === false) {
+ opened = true;
+
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ $connection.triggerHandler(events.onReconnect);
+ }
+ }
+ }, false);
+
+ connection.eventSource.addEventListener("message", function (e) {
+ var res;
+
+ // process messages
+ if (e.data === "initialized") {
+ return;
+ }
+
+ try {
+ res = connection._parseResponse(e.data);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(connection, e.data, error, onFailed, e);
+ return;
+ }
+
+ transportLogic.processMessages(connection, res, onSuccess);
+ }, false);
+
+ connection.eventSource.addEventListener("error", function (e) {
+ // Only handle an error if the error is from the current Event Source.
+ // Sometimes on disconnect the server will push down an error event
+ // to an expired Event Source.
+ if (this !== connection.eventSource) {
+ return;
+ }
+
+ if (!opened) {
+ if (onFailed) {
+ onFailed();
+ }
+
+ return;
+ }
+
+ connection.log("EventSource readyState: " + connection.eventSource.readyState + ".");
+
+ if (e.eventPhase === window.EventSource.CLOSED) {
+ // We don't use the EventSource's native reconnect function as it
+ // doesn't allow us to change the URL when reconnecting. We need
+ // to change the URL to not include the /connect suffix, and pass
+ // the last message id we received.
+ connection.log("EventSource reconnecting due to the server connection ending.");
+ that.reconnect(connection);
+ } else {
+ // connection error
+ connection.log("EventSource error.");
+ $connection.triggerHandler(events.onError, [signalR._.transportError(signalR.resources.eventSourceError, connection.transport, e)]);
+ }
+ }, false);
+ },
+
+ reconnect: function (connection) {
+ transportLogic.reconnect(connection, this.name);
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ stop: function (connection) {
+ // Don't trigger a reconnect after stopping
+ clearReconnectAttemptTimeout(connection);
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (connection && connection.eventSource) {
+ connection.log("EventSource calling close().");
+ connection.eventSource.close();
+ connection.eventSource = null;
+ delete connection.eventSource;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.foreverFrame.js */
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic,
+ createFrame = function () {
+ var frame = window.document.createElement("iframe");
+ frame.setAttribute("style", "position:absolute;top:0;left:0;width:0;height:0;visibility:hidden;");
+ return frame;
+ },
+ // Used to prevent infinite loading icon spins in older versions of ie
+ // We build this object inside a closure so we don't pollute the rest of
+ // the foreverFrame transport with unnecessary functions/utilities.
+ loadPreventer = (function () {
+ var loadingFixIntervalId = null,
+ loadingFixInterval = 1000,
+ attachedTo = 0;
+
+ return {
+ prevent: function () {
+ // Prevent additional iframe removal procedures from newer browsers
+ if (signalR._.ieVersion <= 8) {
+ // We only ever want to set the interval one time, so on the first attachedTo
+ if (attachedTo === 0) {
+ // Create and destroy iframe every 3 seconds to prevent loading icon, super hacky
+ loadingFixIntervalId = window.setInterval(function () {
+ var tempFrame = createFrame();
+
+ window.document.body.appendChild(tempFrame);
+ window.document.body.removeChild(tempFrame);
+
+ tempFrame = null;
+ }, loadingFixInterval);
+ }
+
+ attachedTo++;
+ }
+ },
+ cancel: function () {
+ // Only clear the interval if there's only one more object that the loadPreventer is attachedTo
+ if (attachedTo === 1) {
+ window.clearInterval(loadingFixIntervalId);
+ }
+
+ if (attachedTo > 0) {
+ attachedTo--;
+ }
+ }
+ };
+ })();
+
+ signalR.transports.foreverFrame = {
+ name: "foreverFrame",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ // Added as a value here so we can create tests to verify functionality
+ iframeClearThreshold: 50,
+
+ start: function (connection, onSuccess, onFailed) {
+ var that = this,
+ frameId = (transportLogic.foreverFrame.count += 1),
+ url,
+ frame = createFrame(),
+ frameLoadHandler = function () {
+ connection.log("Forever frame iframe finished loading and is no longer receiving messages.");
+ that.reconnect(connection);
+ };
+
+ if (window.EventSource) {
+ // If the browser supports SSE, don't use Forever Frame
+ if (onFailed) {
+ connection.log("This browser supports SSE, skipping Forever Frame.");
+ onFailed();
+ }
+ return;
+ }
+
+ frame.setAttribute("data-signalr-connection-id", connection.id);
+
+ // Start preventing loading icon
+ // This will only perform work if the loadPreventer is not attached to another connection.
+ loadPreventer.prevent();
+
+ // Build the url
+ url = transportLogic.getUrl(connection, this.name);
+ url += "&frameId=" + frameId;
+
+ // Set body prior to setting URL to avoid caching issues.
+ window.document.body.appendChild(frame);
+
+ connection.log("Binding to iframe's load event.");
+
+ if (frame.addEventListener) {
+ frame.addEventListener("load", frameLoadHandler, false);
+ } else if (frame.attachEvent) {
+ frame.attachEvent("onload", frameLoadHandler);
+ }
+
+ frame.src = url;
+ transportLogic.foreverFrame.connections[frameId] = connection;
+
+ connection.frame = frame;
+ connection.frameId = frameId;
+
+ if (onSuccess) {
+ connection.onSuccess = function () {
+ connection.log("Iframe transport started.");
+ onSuccess();
+ };
+ }
+ },
+
+ reconnect: function (connection) {
+ var that = this;
+
+ // Need to verify connection state and verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
+ if (transportLogic.isConnectedOrReconnecting(connection) && transportLogic.verifyLastActive(connection)) {
+ window.setTimeout(function () {
+ // Verify that we're ok to reconnect.
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ if (connection.frame && transportLogic.ensureReconnectingState(connection)) {
+ var frame = connection.frame,
+ src = transportLogic.getUrl(connection, that.name, true) + "&frameId=" + connection.frameId;
+ connection.log("Updating iframe src to '" + src + "'.");
+ frame.src = src;
+ }
+ }, connection.reconnectDelay);
+ }
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ receive: function (connection, data) {
+ var cw,
+ body,
+ response;
+
+ if (connection.json !== connection._originalJson) {
+ // If there's a custom JSON parser configured then serialize the object
+ // using the original (browser) JSON parser and then deserialize it using
+ // the custom parser (connection._parseResponse does that). This is so we
+ // can easily send the response from the server as "raw" JSON but still
+ // support custom JSON deserialization in the browser.
+ data = connection._originalJson.stringify(data);
+ }
+
+ response = connection._parseResponse(data);
+
+ transportLogic.processMessages(connection, response, connection.onSuccess);
+
+ // Protect against connection stopping from a callback trigger within the processMessages above.
+ if (connection.state === $.signalR.connectionState.connected) {
+ // Delete the script & div elements
+ connection.frameMessageCount = (connection.frameMessageCount || 0) + 1;
+ if (connection.frameMessageCount > signalR.transports.foreverFrame.iframeClearThreshold) {
+ connection.frameMessageCount = 0;
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw && cw.document && cw.document.body) {
+ body = cw.document.body;
+
+ // Remove all the child elements from the iframe's body to conserver memory
+ while (body.firstChild) {
+ body.removeChild(body.firstChild);
+ }
+ }
+ }
+ }
+ },
+
+ stop: function (connection) {
+ var cw = null;
+
+ // Stop attempting to prevent loading icon
+ loadPreventer.cancel();
+
+ if (connection.frame) {
+ if (connection.frame.stop) {
+ connection.frame.stop();
+ } else {
+ try {
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw.document && cw.document.execCommand) {
+ cw.document.execCommand("Stop");
+ }
+ }
+ catch (e) {
+ connection.log("Error occured when stopping foreverFrame transport. Message = " + e.message + ".");
+ }
+ }
+
+ // Ensure the iframe is where we left it
+ if (connection.frame.parentNode === window.document.body) {
+ window.document.body.removeChild(connection.frame);
+ }
+
+ delete transportLogic.foreverFrame.connections[connection.frameId];
+ connection.frame = null;
+ connection.frameId = null;
+ delete connection.frame;
+ delete connection.frameId;
+ delete connection.onSuccess;
+ delete connection.frameMessageCount;
+ connection.log("Stopping forever frame.");
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ },
+
+ getConnection: function (id) {
+ return transportLogic.foreverFrame.connections[id];
+ },
+
+ started: function (connection) {
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ // If there's no onSuccess handler we assume this is a reconnect
+ $(connection).triggerHandler(events.onReconnect);
+ }
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.longPolling.js */
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ isDisconnecting = $.signalR.isDisconnecting,
+ transportLogic = signalR.transports._logic,
+ browserSupportsXHRProgress = (function () {
+ try {
+ return "onprogress" in new window.XMLHttpRequest();
+ } catch (e) {
+ // No XHR means no XHR progress event
+ return false;
+ }
+ })();
+
+ signalR.transports.longPolling = {
+ name: "longPolling",
+
+ supportsKeepAlive: function (connection) {
+ return browserSupportsXHRProgress &&
+ connection.ajaxDataType !== "jsonp" &&
+ // Don't check for keep alives if there is a delay configured between poll requests.
+ // Don't check for keep alives if the server didn't send back the "LongPollDelay" as
+ // part of the response to /negotiate. That indicates the server is running an older
+ // version of SignalR that doesn't send long polling keep alives.
+ connection._.longPollDelay === 0;
+ },
+
+ reconnectDelay: 3000,
+
+ start: function (connection, onSuccess, onFailed) {
+ /// Starts the long polling connection
+ /// The SignalR connection to start
+ var that = this,
+ fireConnect = function () {
+ fireConnect = $.noop;
+
+ // Reset onFailed to null because it shouldn't be called again
+ onFailed = null;
+
+ connection.log("LongPolling connected.");
+ onSuccess();
+ },
+ tryFailConnect = function () {
+ if (onFailed) {
+ onFailed();
+ onFailed = null;
+ connection.log("LongPolling failed to connect.");
+ return true;
+ }
+
+ return false;
+ },
+ privateData = connection._,
+ reconnectErrors = 0,
+ fireReconnected = function (instance) {
+ window.clearTimeout(privateData.reconnectTimeoutId);
+ privateData.reconnectTimeoutId = null;
+
+ if (changeState(instance,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ // Successfully reconnected!
+ instance.log("Raising the reconnect event");
+ $(instance).triggerHandler(events.onReconnect);
+ }
+ },
+ // 1 hour
+ maxFireReconnectedTimeout = 3600000;
+
+ if (connection.pollXhr) {
+ connection.log("Polling xhr requests already exists, aborting.");
+ connection.stop();
+ }
+
+ connection.messageId = null;
+
+ privateData.reconnectTimeoutId = null;
+
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ (function poll(instance, raiseReconnect) {
+ var messageId = instance.messageId,
+ connect = (messageId == undefined),
+ reconnecting = !connect,
+ polling = !raiseReconnect,
+ url = transportLogic.getUrl(instance, that.name, reconnecting, polling);
+
+ // If we've disconnected during the time we've tried to re-instantiate the poll then stop.
+ if (isDisconnecting(instance) === true) {
+ return;
+ }
+
+ connection.log("Opening long polling request to '" + url + "'.");
+ instance.pollXhr = transportLogic.ajax(connection, {
+ xhrFields: {
+ onprogress: function () {
+ transportLogic.markLastMessage(connection);
+ }
+ },
+ url: url,
+ success: function (result) {
+ var minData,
+ delay = 0,
+ data,
+ shouldReconnect;
+
+ connection.log("Long poll complete.");
+
+ // Reset our reconnect errors so if we transition into a reconnecting state again we trigger
+ // reconnected quickly
+ reconnectErrors = 0;
+
+ try {
+ // Remove any keep-alives from the beginning of the result
+ minData = connection._parseResponse(result);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(instance, result, error, tryFailConnect, instance.pollXhr);
+ return;
+ }
+
+ // If there's currently a timeout to trigger reconnect, fire it now before processing messages
+ if (privateData.reconnectTimeoutId != undefined) {
+ fireReconnected(instance);
+ }
+
+ if (minData) {
+ data = transportLogic.maximizePersistentResponse(minData);
+ }
+
+ transportLogic.processMessages(instance, minData, fireConnect);
+
+ if (data &&
+ $.type(data.LongPollDelay) === "number") {
+ delay = data.LongPollDelay;
+ }
+
+ if (data && data.Disconnect) {
+ return;
+ }
+
+ if (isDisconnecting(instance) === true) {
+ return;
+ }
+
+ shouldReconnect = data && data.ShouldReconnect;
+ if (shouldReconnect) {
+ // Transition into the reconnecting state
+ // If this fails then that means that the user transitioned the connection into a invalid state in processMessages.
+ if (!transportLogic.ensureReconnectingState(instance)) {
+ return;
+ }
+ }
+
+ // We never want to pass a raiseReconnect flag after a successful poll. This is handled via the error function
+ if (delay > 0) {
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ poll(instance, shouldReconnect);
+ }, delay);
+ } else {
+ poll(instance, shouldReconnect);
+ }
+ },
+
+ error: function (data, textStatus) {
+ // Stop trying to trigger reconnect, connection is in an error state
+ // If we're not in the reconnect state this will noop
+ window.clearTimeout(privateData.reconnectTimeoutId);
+ privateData.reconnectTimeoutId = null;
+
+ if (textStatus === "abort") {
+ connection.log("Aborted xhr request.");
+ return;
+ }
+
+ if (!tryFailConnect()) {
+
+ // Increment our reconnect errors, we assume all errors to be reconnect errors
+ // In the case that it's our first error this will cause Reconnect to be fired
+ // after 1 second due to reconnectErrors being = 1.
+ reconnectErrors++;
+
+ if (connection.state !== signalR.connectionState.reconnecting) {
+ connection.log("An error occurred using longPolling. Status = " + textStatus + ". Response = " + data.responseText + ".");
+ $(instance).triggerHandler(events.onError, [signalR._.transportError(signalR.resources.longPollFailed, connection.transport, data, instance.pollXhr)]);
+ }
+
+ // We check the state here to verify that we're not in an invalid state prior to verifying Reconnect.
+ // If we're not in connected or reconnecting then the next ensureReconnectingState check will fail and will return.
+ // Therefore we don't want to change that failure code path.
+ if ((connection.state === signalR.connectionState.connected ||
+ connection.state === signalR.connectionState.reconnecting) &&
+ !transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ // Transition into the reconnecting state
+ // If this fails then that means that the user transitioned the connection into the disconnected or connecting state within the above error handler trigger.
+ if (!transportLogic.ensureReconnectingState(instance)) {
+ return;
+ }
+
+ // Call poll with the raiseReconnect flag as true after the reconnect delay
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ poll(instance, true);
+ }, that.reconnectDelay);
+ }
+ }
+ });
+
+ // This will only ever pass after an error has occured via the poll ajax procedure.
+ if (reconnecting && raiseReconnect === true) {
+ // We wait to reconnect depending on how many times we've failed to reconnect.
+ // This is essentially a heuristic that will exponentially increase in wait time before
+ // triggering reconnected. This depends on the "error" handler of Poll to cancel this
+ // timeout if it triggers before the Reconnected event fires.
+ // The Math.min at the end is to ensure that the reconnect timeout does not overflow.
+ privateData.reconnectTimeoutId = window.setTimeout(function () { fireReconnected(instance); }, Math.min(1000 * (Math.pow(2, reconnectErrors) - 1), maxFireReconnectedTimeout));
+ }
+ }(connection));
+ }, 250); // Have to delay initial poll so Chrome doesn't show loader spinner in tab
+ },
+
+ lostConnection: function (connection) {
+ if (connection.pollXhr) {
+ connection.pollXhr.abort("lostConnection");
+ }
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ stop: function (connection) {
+ /// Stops the long polling connection
+ /// The SignalR connection to stop
+
+ window.clearTimeout(connection._.pollTimeoutId);
+ window.clearTimeout(connection._.reconnectTimeoutId);
+
+ delete connection._.pollTimeoutId;
+ delete connection._.reconnectTimeoutId;
+
+ if (connection.pollXhr) {
+ connection.pollXhr.abort();
+ connection.pollXhr = null;
+ delete connection.pollXhr;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.hubs.js */
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var eventNamespace = ".hubProxy",
+ signalR = $.signalR;
+
+ function makeEventName(event) {
+ return event + eventNamespace;
+ }
+
+ // Equivalent to Array.prototype.map
+ function map(arr, fun, thisp) {
+ var i,
+ length = arr.length,
+ result = [];
+ for (i = 0; i < length; i += 1) {
+ if (arr.hasOwnProperty(i)) {
+ result[i] = fun.call(thisp, arr[i], i, arr);
+ }
+ }
+ return result;
+ }
+
+ function getArgValue(a) {
+ return $.isFunction(a) ? null : ($.type(a) === "undefined" ? null : a);
+ }
+
+ function hasMembers(obj) {
+ for (var key in obj) {
+ // If we have any properties in our callback map then we have callbacks and can exit the loop via return
+ if (obj.hasOwnProperty(key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function clearInvocationCallbacks(connection, error) {
+ ///
+ var callbacks = connection._.invocationCallbacks,
+ callback;
+
+ if (hasMembers(callbacks)) {
+ connection.log("Clearing hub invocation callbacks with error: " + error + ".");
+ }
+
+ // Reset the callback cache now as we have a local var referencing it
+ connection._.invocationCallbackId = 0;
+ delete connection._.invocationCallbacks;
+ connection._.invocationCallbacks = {};
+
+ // Loop over the callbacks and invoke them.
+ // We do this using a local var reference and *after* we've cleared the cache
+ // so that if a fail callback itself tries to invoke another method we don't
+ // end up with its callback in the list we're looping over.
+ for (var callbackId in callbacks) {
+ callback = callbacks[callbackId];
+ callback.method.call(callback.scope, { E: error });
+ }
+ }
+
+ // hubProxy
+ function hubProxy(hubConnection, hubName) {
+ ///
+ /// Creates a new proxy object for the given hub connection that can be used to invoke
+ /// methods on server hubs and handle client method invocation requests from the server.
+ ///
+ return new hubProxy.fn.init(hubConnection, hubName);
+ }
+
+ hubProxy.fn = hubProxy.prototype = {
+ init: function (connection, hubName) {
+ this.state = {};
+ this.connection = connection;
+ this.hubName = hubName;
+ this._ = {
+ callbackMap: {}
+ };
+ },
+
+ hasSubscriptions: function () {
+ return hasMembers(this._.callbackMap);
+ },
+
+ on: function (eventName, callback) {
+ /// Wires up a callback to be invoked when a invocation request is received from the server hub.
+ /// The name of the hub event to register the callback for.
+ /// The callback to be invoked.
+ var that = this,
+ callbackMap = that._.callbackMap;
+
+ // Normalize the event name to lowercase
+ eventName = eventName.toLowerCase();
+
+ // If there is not an event registered for this callback yet we want to create its event space in the callback map.
+ if (!callbackMap[eventName]) {
+ callbackMap[eventName] = {};
+ }
+
+ // Map the callback to our encompassed function
+ callbackMap[eventName][callback] = function (e, data) {
+ callback.apply(that, data);
+ };
+
+ $(that).bind(makeEventName(eventName), callbackMap[eventName][callback]);
+
+ return that;
+ },
+
+ off: function (eventName, callback) {
+ /// Removes the callback invocation request from the server hub for the given event name.
+ /// The name of the hub event to unregister the callback for.
+ /// The callback to be invoked.
+ var that = this,
+ callbackMap = that._.callbackMap,
+ callbackSpace;
+
+ // Normalize the event name to lowercase
+ eventName = eventName.toLowerCase();
+
+ callbackSpace = callbackMap[eventName];
+
+ // Verify that there is an event space to unbind
+ if (callbackSpace) {
+ // Only unbind if there's an event bound with eventName and a callback with the specified callback
+ if (callbackSpace[callback]) {
+ $(that).unbind(makeEventName(eventName), callbackSpace[callback]);
+
+ // Remove the callback from the callback map
+ delete callbackSpace[callback];
+
+ // Check if there are any members left on the event, if not we need to destroy it.
+ if (!hasMembers(callbackSpace)) {
+ delete callbackMap[eventName];
+ }
+ } else if (!callback) { // Check if we're removing the whole event and we didn't error because of an invalid callback
+ $(that).unbind(makeEventName(eventName));
+
+ delete callbackMap[eventName];
+ }
+ }
+
+ return that;
+ },
+
+ invoke: function (methodName) {
+ /// Invokes a server hub method with the given arguments.
+ /// The name of the server hub method.
+
+ var that = this,
+ connection = that.connection,
+ args = $.makeArray(arguments).slice(1),
+ argValues = map(args, getArgValue),
+ data = { H: that.hubName, M: methodName, A: argValues, I: connection._.invocationCallbackId },
+ d = $.Deferred(),
+ callback = function (minResult) {
+ var result = that._maximizeHubResponse(minResult),
+ source,
+ error;
+
+ // Update the hub state
+ $.extend(that.state, result.State);
+
+ if (result.Progress) {
+ if (d.notifyWith) {
+ // Progress is only supported in jQuery 1.7+
+ d.notifyWith(that, [result.Progress.Data]);
+ } else if(!connection._.progressjQueryVersionLogged) {
+ connection.log("A hub method invocation progress update was received but the version of jQuery in use (" + $.prototype.jquery + ") does not support progress updates. Upgrade to jQuery 1.7+ to receive progress notifications.");
+ connection._.progressjQueryVersionLogged = true;
+ }
+ } else if (result.Error) {
+ // Server hub method threw an exception, log it & reject the deferred
+ if (result.StackTrace) {
+ connection.log(result.Error + "\n" + result.StackTrace + ".");
+ }
+
+ // result.ErrorData is only set if a HubException was thrown
+ source = result.IsHubException ? "HubException" : "Exception";
+ error = signalR._.error(result.Error, source);
+ error.data = result.ErrorData;
+
+ connection.log(that.hubName + "." + methodName + " failed to execute. Error: " + error.message);
+ d.rejectWith(that, [error]);
+ } else {
+ // Server invocation succeeded, resolve the deferred
+ connection.log("Invoked " + that.hubName + "." + methodName);
+ d.resolveWith(that, [result.Result]);
+ }
+ };
+
+ connection._.invocationCallbacks[connection._.invocationCallbackId.toString()] = { scope: that, method: callback };
+ connection._.invocationCallbackId += 1;
+
+ if (!$.isEmptyObject(that.state)) {
+ data.S = that.state;
+ }
+
+ connection.log("Invoking " + that.hubName + "." + methodName);
+ connection.send(data);
+
+ return d.promise();
+ },
+
+ _maximizeHubResponse: function (minHubResponse) {
+ return {
+ State: minHubResponse.S,
+ Result: minHubResponse.R,
+ Progress: minHubResponse.P ? {
+ Id: minHubResponse.P.I,
+ Data: minHubResponse.P.D
+ } : null,
+ Id: minHubResponse.I,
+ IsHubException: minHubResponse.H,
+ Error: minHubResponse.E,
+ StackTrace: minHubResponse.T,
+ ErrorData: minHubResponse.D
+ };
+ }
+ };
+
+ hubProxy.fn.init.prototype = hubProxy.fn;
+
+ // hubConnection
+ function hubConnection(url, options) {
+ /// Creates a new hub connection.
+ /// [Optional] The hub route url, defaults to "/signalr".
+ /// [Optional] Settings to use when creating the hubConnection.
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ };
+
+ $.extend(settings, options);
+
+ if (!url || settings.useDefaultPath) {
+ url = (url || "") + "/signalr";
+ }
+ return new hubConnection.fn.init(url, settings);
+ }
+
+ hubConnection.fn = hubConnection.prototype = $.connection();
+
+ hubConnection.fn.init = function (url, options) {
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ },
+ connection = this;
+
+ $.extend(settings, options);
+
+ // Call the base constructor
+ $.signalR.fn.init.call(connection, url, settings.qs, settings.logging);
+
+ // Object to store hub proxies for this connection
+ connection.proxies = {};
+
+ connection._.invocationCallbackId = 0;
+ connection._.invocationCallbacks = {};
+
+ // Wire up the received handler
+ connection.received(function (minData) {
+ var data, proxy, dataCallbackId, callback, hubName, eventName;
+ if (!minData) {
+ return;
+ }
+
+ // We have to handle progress updates first in order to ensure old clients that receive
+ // progress updates enter the return value branch and then no-op when they can't find
+ // the callback in the map (because the minData.I value will not be a valid callback ID)
+ if (typeof (minData.P) !== "undefined") {
+ // Process progress notification
+ dataCallbackId = minData.P.I.toString();
+ callback = connection._.invocationCallbacks[dataCallbackId];
+ if (callback) {
+ callback.method.call(callback.scope, minData);
+ }
+ } else if (typeof (minData.I) !== "undefined") {
+ // We received the return value from a server method invocation, look up callback by id and call it
+ dataCallbackId = minData.I.toString();
+ callback = connection._.invocationCallbacks[dataCallbackId];
+ if (callback) {
+ // Delete the callback from the proxy
+ connection._.invocationCallbacks[dataCallbackId] = null;
+ delete connection._.invocationCallbacks[dataCallbackId];
+
+ // Invoke the callback
+ callback.method.call(callback.scope, minData);
+ }
+ } else {
+ data = this._maximizeClientHubInvocation(minData);
+
+ // We received a client invocation request, i.e. broadcast from server hub
+ connection.log("Triggering client hub event '" + data.Method + "' on hub '" + data.Hub + "'.");
+
+ // Normalize the names to lowercase
+ hubName = data.Hub.toLowerCase();
+ eventName = data.Method.toLowerCase();
+
+ // Trigger the local invocation event
+ proxy = this.proxies[hubName];
+
+ // Update the hub state
+ $.extend(proxy.state, data.State);
+ $(proxy).triggerHandler(makeEventName(eventName), [data.Args]);
+ }
+ });
+
+ connection.error(function (errData, origData) {
+ var callbackId, callback;
+
+ if (!origData) {
+ // No original data passed so this is not a send error
+ return;
+ }
+
+ callbackId = origData.I;
+ callback = connection._.invocationCallbacks[callbackId];
+
+ // Verify that there is a callback bound (could have been cleared)
+ if (callback) {
+ // Delete the callback
+ connection._.invocationCallbacks[callbackId] = null;
+ delete connection._.invocationCallbacks[callbackId];
+
+ // Invoke the callback with an error to reject the promise
+ callback.method.call(callback.scope, { E: errData });
+ }
+ });
+
+ connection.reconnecting(function () {
+ if (connection.transport && connection.transport.name === "webSockets") {
+ clearInvocationCallbacks(connection, "Connection started reconnecting before invocation result was received.");
+ }
+ });
+
+ connection.disconnected(function () {
+ clearInvocationCallbacks(connection, "Connection was disconnected before invocation result was received.");
+ });
+ };
+
+ hubConnection.fn._maximizeClientHubInvocation = function (minClientHubInvocation) {
+ return {
+ Hub: minClientHubInvocation.H,
+ Method: minClientHubInvocation.M,
+ Args: minClientHubInvocation.A,
+ State: minClientHubInvocation.S
+ };
+ };
+
+ hubConnection.fn._registerSubscribedHubs = function () {
+ ///
+ /// Sets the starting event to loop through the known hubs and register any new hubs
+ /// that have been added to the proxy.
+ ///
+ var connection = this;
+
+ if (!connection._subscribedToHubs) {
+ connection._subscribedToHubs = true;
+ connection.starting(function () {
+ // Set the connection's data object with all the hub proxies with active subscriptions.
+ // These proxies will receive notifications from the server.
+ var subscribedHubs = [];
+
+ $.each(connection.proxies, function (key) {
+ if (this.hasSubscriptions()) {
+ subscribedHubs.push({ name: key });
+ connection.log("Client subscribed to hub '" + key + "'.");
+ }
+ });
+
+ if (subscribedHubs.length === 0) {
+ connection.log("No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.");
+ }
+
+ connection.data = connection.json.stringify(subscribedHubs);
+ });
+ }
+ };
+
+ hubConnection.fn.createHubProxy = function (hubName) {
+ ///
+ /// Creates a new proxy object for the given hub connection that can be used to invoke
+ /// methods on server hubs and handle client method invocation requests from the server.
+ ///
+ ///
+ /// The name of the hub on the server to create the proxy for.
+ ///
+
+ // Normalize the name to lowercase
+ hubName = hubName.toLowerCase();
+
+ var proxy = this.proxies[hubName];
+ if (!proxy) {
+ proxy = hubProxy(this, hubName);
+ this.proxies[hubName] = proxy;
+ }
+
+ this._registerSubscribedHubs();
+
+ return proxy;
+ };
+
+ hubConnection.fn.init.prototype = hubConnection.fn;
+
+ $.hubConnection = hubConnection;
+
+}(window.jQuery, window));
+/* jquery.signalR.version.js */
+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
+
+/*global window:false */
+///
+(function ($, undefined) {
+ $.signalR.version = "2.1.0";
+}(window.jQuery));
\ No newline at end of file
diff --git a/Adaptation/FileHandlers/json/StaticSite/js/signalr/v2.4.3/jquery.signalR.js b/Adaptation/FileHandlers/json/StaticSite/js/signalr/v2.4.3/jquery.signalR.js
new file mode 100644
index 0000000..4b2f9c1
--- /dev/null
+++ b/Adaptation/FileHandlers/json/StaticSite/js/signalr/v2.4.3/jquery.signalR.js
@@ -0,0 +1,3174 @@
+/* jquery.signalR.core.js */
+/*global window:false */
+/*!
+ * ASP.NET SignalR JavaScript Library 2.4.3
+ * http://signalr.net/
+ *
+ * Copyright (c) .NET Foundation. All rights reserved.
+ * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+ *
+ */
+
+///
+///
+(function ($, window, undefined) {
+
+ var resources = {
+ nojQuery: "jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.",
+ noTransportOnInit: "No transport could be initialized successfully. Try specifying a different transport or none at all for auto initialization.",
+ errorOnNegotiate: "Error during negotiation request.",
+ stoppedWhileLoading: "The connection was stopped during page load.",
+ stoppedWhileNegotiating: "The connection was stopped during the negotiate request.",
+ errorParsingNegotiateResponse: "Error parsing negotiate response.",
+ errorRedirectionExceedsLimit: "Negotiate redirection limit exceeded.",
+ errorDuringStartRequest: "Error during start request. Stopping the connection.",
+ errorFromServer: "Error message received from the server: '{0}'.",
+ stoppedDuringStartRequest: "The connection was stopped during the start request.",
+ errorParsingStartResponse: "Error parsing start response: '{0}'. Stopping the connection.",
+ invalidStartResponse: "Invalid start response: '{0}'. Stopping the connection.",
+ protocolIncompatible: "You are using a version of the client that isn't compatible with the server. Client version {0}, server version {1}.",
+ aspnetCoreSignalrServer: "Detected a connection attempt to an ASP.NET Core SignalR Server. This client only supports connecting to an ASP.NET SignalR Server. See https://aka.ms/signalr-core-differences for details.",
+ sendFailed: "Send failed.",
+ parseFailed: "Failed at parsing response: {0}",
+ longPollFailed: "Long polling request failed.",
+ eventSourceFailedToConnect: "EventSource failed to connect.",
+ eventSourceError: "Error raised by EventSource",
+ webSocketClosed: "WebSocket closed.",
+ pingServerFailedInvalidResponse: "Invalid ping response when pinging server: '{0}'.",
+ pingServerFailed: "Failed to ping server.",
+ pingServerFailedStatusCode: "Failed to ping server. Server responded with status code {0}, stopping the connection.",
+ pingServerFailedParse: "Failed to parse ping server response, stopping the connection.",
+ noConnectionTransport: "Connection is in an invalid state, there is no transport active.",
+ webSocketsInvalidState: "The Web Socket transport is in an invalid state, transitioning into reconnecting.",
+ reconnectTimeout: "Couldn't reconnect within the configured timeout of {0} ms, disconnecting.",
+ reconnectWindowTimeout: "The client has been inactive since {0} and it has exceeded the inactivity timeout of {1} ms. Stopping the connection.",
+ jsonpNotSupportedWithAccessToken: "The JSONP protocol does not support connections that require a Bearer token to connect, such as the Azure SignalR Service."
+ };
+
+ if (typeof ($) !== "function") {
+ // no jQuery!
+ throw new Error(resources.nojQuery);
+ }
+
+ var signalR,
+ _connection,
+ _pageLoaded = (window.document.readyState === "complete"),
+ _pageWindow = $(window),
+ _negotiateAbortText = "__Negotiate Aborted__",
+ events = {
+ onStart: "onStart",
+ onStarting: "onStarting",
+ onReceived: "onReceived",
+ onError: "onError",
+ onConnectionSlow: "onConnectionSlow",
+ onReconnecting: "onReconnecting",
+ onReconnect: "onReconnect",
+ onStateChanged: "onStateChanged",
+ onDisconnect: "onDisconnect"
+ },
+ ajaxDefaults = {
+ processData: true,
+ timeout: null,
+ async: true,
+ global: false,
+ cache: false
+ },
+ log = function (msg, logging) {
+ if (logging === false) {
+ return;
+ }
+ var m;
+ if (typeof (window.console) === "undefined") {
+ return;
+ }
+ m = "[" + new Date().toTimeString() + "] SignalR: " + msg;
+ if (window.console.debug) {
+ window.console.debug(m);
+ } else if (window.console.log) {
+ window.console.log(m);
+ }
+ },
+
+ changeState = function (connection, expectedState, newState) {
+ if (expectedState === connection.state) {
+ connection.state = newState;
+
+ $(connection).triggerHandler(events.onStateChanged, [{ oldState: expectedState, newState: newState }]);
+ return true;
+ }
+
+ return false;
+ },
+
+ isDisconnecting = function (connection) {
+ return connection.state === signalR.connectionState.disconnected;
+ },
+
+ supportsKeepAlive = function (connection) {
+ return connection._.keepAliveData.activated &&
+ connection.transport.supportsKeepAlive(connection);
+ },
+
+ configureStopReconnectingTimeout = function (connection) {
+ var stopReconnectingTimeout,
+ onReconnectTimeout;
+
+ // Check if this connection has already been configured to stop reconnecting after a specified timeout.
+ // Without this check if a connection is stopped then started events will be bound multiple times.
+ if (!connection._.configuredStopReconnectingTimeout) {
+ onReconnectTimeout = function (connection) {
+ var message = signalR._.format(signalR.resources.reconnectTimeout, connection.disconnectTimeout);
+ connection.log(message);
+ $(connection).triggerHandler(events.onError, [signalR._.error(message, /* source */ "TimeoutException")]);
+ connection.stop(/* async */ false, /* notifyServer */ false);
+ };
+
+ connection.reconnecting(function () {
+ var connection = this;
+
+ // Guard against state changing in a previous user defined even handler
+ if (connection.state === signalR.connectionState.reconnecting) {
+ stopReconnectingTimeout = window.setTimeout(function () { onReconnectTimeout(connection); }, connection.disconnectTimeout);
+ }
+ });
+
+ connection.stateChanged(function (data) {
+ if (data.oldState === signalR.connectionState.reconnecting) {
+ // Clear the pending reconnect timeout check
+ window.clearTimeout(stopReconnectingTimeout);
+ }
+ });
+
+ connection._.configuredStopReconnectingTimeout = true;
+ }
+ };
+
+ signalR = function (url, qs, logging) {
+ /// Creates a new SignalR connection for the given url
+ /// The URL of the long polling endpoint
+ ///
+ /// [Optional] Custom querystring parameters to add to the connection URL.
+ /// If an object, every non-function member will be added to the querystring.
+ /// If a string, it's added to the QS as specified.
+ ///
+ ///
+ /// [Optional] A flag indicating whether connection logging is enabled to the browser
+ /// console/log. Defaults to false.
+ ///
+
+ return new signalR.fn.init(url, qs, logging);
+ };
+
+ signalR._ = {
+ defaultContentType: "application/x-www-form-urlencoded; charset=UTF-8",
+
+ ieVersion: (function () {
+ var version,
+ matches;
+
+ if (window.navigator.appName === 'Microsoft Internet Explorer') {
+ // Check if the user agent has the pattern "MSIE (one or more numbers).(one or more numbers)";
+ matches = /MSIE ([0-9]+\.[0-9]+)/.exec(window.navigator.userAgent);
+
+ if (matches) {
+ version = window.parseFloat(matches[1]);
+ }
+ }
+
+ // undefined value means not IE
+ return version;
+ })(),
+
+ error: function (message, source, context) {
+ var e = new Error(message);
+ e.source = source;
+
+ if (typeof context !== "undefined") {
+ e.context = context;
+ }
+
+ return e;
+ },
+
+ transportError: function (message, transport, source, context) {
+ var e = this.error(message, source, context);
+ e.transport = transport ? transport.name : undefined;
+ return e;
+ },
+
+ format: function () {
+ /// Usage: format("Hi {0}, you are {1}!", "Foo", 100)
+ var s = arguments[0];
+ for (var i = 0; i < arguments.length - 1; i++) {
+ s = s.replace("{" + i + "}", arguments[i + 1]);
+ }
+ return s;
+ },
+
+ firefoxMajorVersion: function (userAgent) {
+ // Firefox user agents: http://useragentstring.com/pages/Firefox/
+ var matches = userAgent.match(/Firefox\/(\d+)/);
+ if (!matches || !matches.length || matches.length < 2) {
+ return 0;
+ }
+ return parseInt(matches[1], 10 /* radix */);
+ },
+
+ configurePingInterval: function (connection) {
+ var config = connection._.config,
+ onFail = function (error) {
+ $(connection).triggerHandler(events.onError, [error]);
+ };
+
+ if (config && !connection._.pingIntervalId && config.pingInterval) {
+ connection._.pingIntervalId = window.setInterval(function () {
+ signalR.transports._logic.pingServer(connection).fail(onFail);
+ }, config.pingInterval);
+ }
+ }
+ };
+
+ signalR.events = events;
+
+ signalR.resources = resources;
+
+ signalR.ajaxDefaults = ajaxDefaults;
+
+ signalR.changeState = changeState;
+
+ signalR.isDisconnecting = isDisconnecting;
+
+ signalR.connectionState = {
+ connecting: 0,
+ connected: 1,
+ reconnecting: 2,
+ disconnected: 4
+ };
+
+ signalR.hub = {
+ start: function () {
+ // This will get replaced with the real hub connection start method when hubs is referenced correctly
+ throw new Error("SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. .");
+ }
+ };
+
+ // .on() was added in version 1.7.0, .load() was removed in version 3.0.0 so we fallback to .load() if .on() does
+ // not exist to not break existing applications
+ if (typeof _pageWindow.on === "function") {
+ _pageWindow.on("load", function () { _pageLoaded = true; });
+ }
+ else {
+ _pageWindow.load(function () { _pageLoaded = true; });
+ }
+
+ function validateTransport(requestedTransport, connection) {
+ /// Validates the requested transport by cross checking it with the pre-defined signalR.transports
+ /// The designated transports that the user has specified.
+ /// The connection that will be using the requested transports. Used for logging purposes.
+ ///
+
+ if ($.isArray(requestedTransport)) {
+ // Go through transport array and remove an "invalid" tranports
+ for (var i = requestedTransport.length - 1; i >= 0; i--) {
+ var transport = requestedTransport[i];
+ if ($.type(transport) !== "string" || !signalR.transports[transport]) {
+ connection.log("Invalid transport: " + transport + ", removing it from the transports list.");
+ requestedTransport.splice(i, 1);
+ }
+ }
+
+ // Verify we still have transports left, if we dont then we have invalid transports
+ if (requestedTransport.length === 0) {
+ connection.log("No transports remain within the specified transport array.");
+ requestedTransport = null;
+ }
+ } else if (!signalR.transports[requestedTransport] && requestedTransport !== "auto") {
+ connection.log("Invalid transport: " + requestedTransport.toString() + ".");
+ requestedTransport = null;
+ } else if (requestedTransport === "auto" && signalR._.ieVersion <= 8) {
+ // If we're doing an auto transport and we're IE8 then force longPolling, #1764
+ return ["longPolling"];
+
+ }
+
+ return requestedTransport;
+ }
+
+ function getDefaultPort(protocol) {
+ if (protocol === "http:") {
+ return 80;
+ } else if (protocol === "https:") {
+ return 443;
+ }
+ }
+
+ function addDefaultPort(protocol, url) {
+ // Remove ports from url. We have to check if there's a / or end of line
+ // following the port in order to avoid removing ports such as 8080.
+ if (url.match(/:\d+$/)) {
+ return url;
+ } else {
+ return url + ":" + getDefaultPort(protocol);
+ }
+ }
+
+ function ConnectingMessageBuffer(connection, drainCallback) {
+ var that = this,
+ buffer = [];
+
+ that.tryBuffer = function (message) {
+ if (connection.state === $.signalR.connectionState.connecting) {
+ buffer.push(message);
+
+ return true;
+ }
+
+ return false;
+ };
+
+ that.drain = function () {
+ // Ensure that the connection is connected when we drain (do not want to drain while a connection is not active)
+ if (connection.state === $.signalR.connectionState.connected) {
+ while (buffer.length > 0) {
+ drainCallback(buffer.shift());
+ }
+ }
+ };
+
+ that.clear = function () {
+ buffer = [];
+ };
+ }
+
+ signalR.fn = signalR.prototype = {
+ init: function (url, qs, logging) {
+ var $connection = $(this);
+
+ this.url = url;
+ this.qs = qs;
+ this.lastError = null;
+ this._ = {
+ keepAliveData: {},
+ connectingMessageBuffer: new ConnectingMessageBuffer(this, function (message) {
+ $connection.triggerHandler(events.onReceived, [message]);
+ }),
+ lastMessageAt: new Date().getTime(),
+ lastActiveAt: new Date().getTime(),
+ beatInterval: 5000, // Default value, will only be overridden if keep alive is enabled,
+ beatHandle: null,
+ totalTransportConnectTimeout: 0, // This will be the sum of the TransportConnectTimeout sent in response to negotiate and connection.transportConnectTimeout
+ redirectQs: null
+ };
+ if (typeof (logging) === "boolean") {
+ this.logging = logging;
+ }
+ },
+
+ _parseResponse: function (response) {
+ var that = this;
+
+ if (!response) {
+ return response;
+ } else if (typeof response === "string") {
+ return that.json.parse(response);
+ } else {
+ return response;
+ }
+ },
+
+ _originalJson: window.JSON,
+
+ json: window.JSON,
+
+ isCrossDomain: function (url, against) {
+ /// Checks if url is cross domain
+ /// The base URL
+ ///
+ /// An optional argument to compare the URL against, if not specified it will be set to window.location.
+ /// If specified it must contain a protocol and a host property.
+ ///
+ var link;
+
+ url = $.trim(url);
+
+ against = against || window.location;
+
+ if (url.indexOf("http") !== 0) {
+ return false;
+ }
+
+ // Create an anchor tag.
+ link = window.document.createElement("a");
+ link.href = url;
+
+ // When checking for cross domain we have to special case port 80 because the window.location will remove the
+ return link.protocol + addDefaultPort(link.protocol, link.host) !== against.protocol + addDefaultPort(against.protocol, against.host);
+ },
+
+ ajaxDataType: "text",
+
+ contentType: "application/json; charset=UTF-8",
+
+ logging: false,
+
+ state: signalR.connectionState.disconnected,
+
+ clientProtocol: "2.1",
+
+ // We want to support older servers since the 2.0 change is to support redirection results, which isn't
+ // really breaking in the protocol. So if a user updates their client to 2.0 protocol version there's
+ // no reason they can't still connect to a 1.5 server. The 2.1 protocol is sent by the client so the SignalR
+ // service knows the client will use they query string returned via the RedirectUrl for subsequent requests.
+ // It doesn't matter whether the server reflects back 2.1 or continues using 2.0 as the protocol version.
+ supportedProtocols: ["1.5", "2.0", "2.1"],
+
+ negotiateRedirectSupportedProtocols: ["2.0", "2.1"],
+
+ reconnectDelay: 2000,
+
+ transportConnectTimeout: 0,
+
+ disconnectTimeout: 30000, // This should be set by the server in response to the negotiate request (30s default)
+
+ reconnectWindow: 30000, // This should be set by the server in response to the negotiate request
+
+ keepAliveWarnAt: 2 / 3, // Warn user of slow connection if we breach the X% mark of the keep alive timeout
+
+ start: function (options, callback) {
+ /// Starts the connection
+ /// Options map
+ /// A callback function to execute when the connection has started
+ var connection = this,
+ config = {
+ pingInterval: 300000,
+ waitForPageLoad: true,
+ transport: "auto",
+ jsonp: false
+ },
+ initialize,
+ deferred = connection._deferral || $.Deferred(), // Check to see if there is a pre-existing deferral that's being built on, if so we want to keep using it
+ parser = window.document.createElement("a"),
+ setConnectionUrl = function (connection, url) {
+ if (connection.url === url && connection.baseUrl) {
+ // when the url related properties are already set
+ return;
+ }
+
+ connection.url = url;
+
+ // Resolve the full url
+ parser.href = connection.url;
+ if (!parser.protocol || parser.protocol === ":") {
+ connection.protocol = window.document.location.protocol;
+ connection.host = parser.host || window.document.location.host;
+ } else {
+ connection.protocol = parser.protocol;
+ connection.host = parser.host;
+ }
+
+ connection.baseUrl = connection.protocol + "//" + connection.host;
+
+ // Set the websocket protocol
+ connection.wsProtocol = connection.protocol === "https:" ? "wss://" : "ws://";
+
+ // If the url is protocol relative, prepend the current windows protocol to the url.
+ if (connection.url.indexOf("//") === 0) {
+ connection.url = window.location.protocol + connection.url;
+ connection.log("Protocol relative URL detected, normalizing it to '" + connection.url + "'.");
+ }
+
+ if (connection.isCrossDomain(connection.url)) {
+ connection.log("Auto detected cross domain url.");
+
+ if (config.transport === "auto") {
+ // Cross-domain does not support foreverFrame
+ config.transport = ["webSockets", "serverSentEvents", "longPolling"];
+ }
+
+ if (typeof connection.withCredentials === "undefined") {
+ connection.withCredentials = true;
+ }
+
+ // Determine if jsonp is the only choice for negotiation, ajaxSend and ajaxAbort.
+ // i.e. if the browser doesn't supports CORS
+ // If it is, ignore any preference to the contrary, and switch to jsonp.
+ if (!$.support.cors) {
+ connection.ajaxDataType = "jsonp";
+ connection.log("Using jsonp because this browser doesn't support CORS.");
+ }
+
+ connection.contentType = signalR._.defaultContentType;
+ }
+ };
+
+ connection.lastError = null;
+
+ // Persist the deferral so that if start is called multiple times the same deferral is used.
+ connection._deferral = deferred;
+
+ if (!connection.json) {
+ // no JSON!
+ throw new Error("SignalR: No JSON parser found. Please ensure json2.js is referenced before the SignalR.js file if you need to support clients without native JSON parsing support, e.g. IE<8.");
+ }
+
+ if ($.type(options) === "function") {
+ // Support calling with single callback parameter
+ callback = options;
+ } else if ($.type(options) === "object") {
+ $.extend(config, options);
+ if ($.type(config.callback) === "function") {
+ callback = config.callback;
+ }
+ }
+
+ config.transport = validateTransport(config.transport, connection);
+
+ // If the transport is invalid throw an error and abort start
+ if (!config.transport) {
+ throw new Error("SignalR: Invalid transport(s) specified, aborting start.");
+ }
+
+ connection._.config = config;
+
+ // Check to see if start is being called prior to page load
+ // If waitForPageLoad is true we then want to re-direct function call to the window load event
+ if (!_pageLoaded && config.waitForPageLoad === true) {
+ connection._.deferredStartHandler = function () {
+ connection.start(options, callback);
+ };
+ _pageWindow.bind("load", connection._.deferredStartHandler);
+
+ return deferred.promise();
+ }
+
+ // If we're already connecting just return the same deferral as the original connection start
+ if (connection.state === signalR.connectionState.connecting) {
+ return deferred.promise();
+ } else if (changeState(connection,
+ signalR.connectionState.disconnected,
+ signalR.connectionState.connecting) === false) {
+ // We're not connecting so try and transition into connecting.
+ // If we fail to transition then we're either in connected or reconnecting.
+
+ deferred.resolve(connection);
+ return deferred.promise();
+ }
+
+ configureStopReconnectingTimeout(connection);
+
+ // If jsonp with no/auto transport is specified, then set the transport to long polling
+ // since that is the only transport for which jsonp really makes sense.
+ // Some developers might actually choose to specify jsonp for same origin requests
+ // as demonstrated by Issue #623.
+ if (config.transport === "auto" && config.jsonp === true) {
+ config.transport = "longPolling";
+ }
+
+ connection.withCredentials = config.withCredentials;
+
+ // Save the original url so that we can reset it when we stop and restart the connection
+ connection._originalUrl = connection.url;
+
+ connection.ajaxDataType = config.jsonp ? "jsonp" : "text";
+
+ setConnectionUrl(connection, connection.url);
+
+ $(connection).bind(events.onStart, function (e, data) {
+ if ($.type(callback) === "function") {
+ callback.call(connection);
+ }
+ deferred.resolve(connection);
+ });
+
+ connection._.initHandler = signalR.transports._logic.initHandler(connection);
+
+ initialize = function (transports, index) {
+ var noTransportError = signalR._.error(resources.noTransportOnInit);
+
+ index = index || 0;
+ if (index >= transports.length) {
+ if (index === 0) {
+ connection.log("No transports supported by the server were selected.");
+ } else if (index === 1) {
+ connection.log("No fallback transports were selected.");
+ } else {
+ connection.log("Fallback transports exhausted.");
+ }
+
+ // No transport initialized successfully
+ $(connection).triggerHandler(events.onError, [noTransportError]);
+ deferred.reject(noTransportError);
+ // Stop the connection if it has connected and move it into the disconnected state
+ connection.stop();
+ return;
+ }
+
+ // The connection was aborted
+ if (connection.state === signalR.connectionState.disconnected) {
+ return;
+ }
+
+ var transportName = transports[index],
+ transport = signalR.transports[transportName],
+ onFallback = function () {
+ initialize(transports, index + 1);
+ };
+
+ connection.transport = transport;
+
+ try {
+ connection._.initHandler.start(transport, function () { // success
+ // Firefox 11+ doesn't allow sync XHR withCredentials: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest#withCredentials
+ var isFirefox11OrGreater = signalR._.firefoxMajorVersion(window.navigator.userAgent) >= 11,
+ asyncAbort = true;
+
+ connection.log("The start request succeeded. Transitioning to the connected state.");
+
+ if (supportsKeepAlive(connection)) {
+ signalR.transports._logic.monitorKeepAlive(connection);
+ }
+
+ if (connection._.keepAliveData.activated) {
+ signalR.transports._logic.startHeartbeat(connection);
+ }
+
+ // Used to ensure low activity clients maintain their authentication.
+ // Must be configured once a transport has been decided to perform valid ping requests.
+ signalR._.configurePingInterval(connection);
+
+ if (!changeState(connection,
+ signalR.connectionState.connecting,
+ signalR.connectionState.connected)) {
+ connection.log("WARNING! The connection was not in the connecting state.");
+ }
+
+ // Drain any incoming buffered messages (messages that came in prior to connect)
+ connection._.connectingMessageBuffer.drain();
+
+ $(connection).triggerHandler(events.onStart);
+
+ // wire the stop handler for when the user leaves the page
+ _pageWindow.bind("unload", function () {
+ connection.log("Window unloading, stopping the connection.");
+
+ connection.stop(asyncAbort);
+ });
+
+ if (isFirefox11OrGreater) {
+ // Firefox does not fire cross-domain XHRs in the normal unload handler on tab close.
+ // #2400
+ _pageWindow.bind("beforeunload", function () {
+ // If connection.stop() runs runs in beforeunload and fails, it will also fail
+ // in unload unless connection.stop() runs after a timeout.
+ window.setTimeout(function () {
+ connection.stop(asyncAbort);
+ }, 0);
+ });
+ }
+ }, onFallback);
+ }
+ catch (error) {
+ connection.log(transport.name + " transport threw '" + error.message + "' when attempting to start.");
+ onFallback();
+ }
+ };
+
+ var url = connection.url + "/negotiate",
+ onFailed = function (error, connection) {
+ var err = signalR._.error(resources.errorOnNegotiate, error, connection._.negotiateRequest);
+
+ $(connection).triggerHandler(events.onError, err);
+ deferred.reject(err);
+ // Stop the connection if negotiate failed
+ connection.stop();
+ };
+
+ $(connection).triggerHandler(events.onStarting);
+
+ url = signalR.transports._logic.prepareQueryString(connection, url);
+
+ connection.log("Negotiating with '" + url + "'.");
+
+ // Save the ajax negotiate request object so we can abort it if stop is called while the request is in flight.
+ connection._.negotiateRequest = function () {
+ var res,
+ redirects = 0,
+ MAX_REDIRECTS = 100,
+ keepAliveData,
+ protocolError,
+ transports = [],
+ supportedTransports = [],
+ negotiate = function (connection, onSuccess) {
+ var url = signalR.transports._logic.prepareQueryString(connection, connection.url + "/negotiate");
+ connection.log("Negotiating with '" + url + "'.");
+ var options = {
+ url: url,
+ error: function (error, statusText) {
+ // We don't want to cause any errors if we're aborting our own negotiate request.
+ if (statusText !== _negotiateAbortText) {
+ onFailed(error, connection);
+ } else {
+ // This rejection will noop if the deferred has already been resolved or rejected.
+ deferred.reject(signalR._.error(resources.stoppedWhileNegotiating, null /* error */, connection._.negotiateRequest));
+ }
+ },
+ success: onSuccess
+ };
+
+ if (connection.accessToken) {
+ options.headers = { "Authorization": "Bearer " + connection.accessToken };
+ }
+
+ return signalR.transports._logic.ajax(connection, options);
+ },
+ callback = function (result) {
+ try {
+ res = connection._parseResponse(result);
+ } catch (error) {
+ onFailed(signalR._.error(resources.errorParsingNegotiateResponse, error), connection);
+ return;
+ }
+
+ // Check if the server is an ASP.NET Core app
+ if (res.availableTransports) {
+ protocolError = signalR._.error(resources.aspnetCoreSignalrServer);
+ $(connection).triggerHandler(events.onError, [protocolError]);
+ deferred.reject(protocolError);
+ return;
+ }
+
+ if (!res.ProtocolVersion || (connection.supportedProtocols.indexOf(res.ProtocolVersion) === -1)) {
+ protocolError = signalR._.error(signalR._.format(resources.protocolIncompatible, connection.clientProtocol, res.ProtocolVersion));
+ $(connection).triggerHandler(events.onError, [protocolError]);
+ deferred.reject(protocolError);
+
+ return;
+ }
+
+ // Check for a redirect response (which must have a ProtocolVersion of 2.0 or greater)
+ // ProtocolVersion 2.1 is the highest supported by the client, so we can just check for 2.0 or 2.1 for now
+ // instead of trying to do proper version string comparison in JavaScript.
+ if (connection.negotiateRedirectSupportedProtocols.indexOf(res.ProtocolVersion) !== -1) {
+ if (res.Error) {
+ protocolError = signalR._.error(signalR._.format(resources.errorFromServer, res.Error));
+ $(connection).triggerHandler(events.onError, [protocolError]);
+ deferred.reject(protocolError);
+ return;
+ }
+ else if (res.RedirectUrl) {
+ if (redirects === MAX_REDIRECTS) {
+ onFailed(signalR._.error(resources.errorRedirectionExceedsLimit), connection);
+ return;
+ }
+
+ if (config.transport === "auto") {
+ // Redirected connections do not support foreverFrame
+ config.transport = ["webSockets", "serverSentEvents", "longPolling"];
+ }
+
+ connection.log("Received redirect to: " + res.RedirectUrl);
+ connection.accessToken = res.AccessToken;
+
+ var splitUrlAndQs = res.RedirectUrl.split("?", 2);
+ setConnectionUrl(connection, splitUrlAndQs[0]);
+
+ // Update redirectQs with query string from only the most recent RedirectUrl.
+ connection._.redirectQs = splitUrlAndQs.length === 2 ? splitUrlAndQs[1] : null;
+
+ if (connection.ajaxDataType === "jsonp" && connection.accessToken) {
+ onFailed(signalR._.error(resources.jsonpNotSupportedWithAccessToken), connection);
+ return;
+ }
+
+ redirects++;
+ negotiate(connection, callback);
+ return;
+ }
+ }
+
+ keepAliveData = connection._.keepAliveData;
+ connection.appRelativeUrl = res.Url;
+ connection.id = res.ConnectionId;
+ connection.token = res.ConnectionToken;
+ connection.webSocketServerUrl = res.WebSocketServerUrl;
+
+ // The long poll timeout is the ConnectionTimeout plus 10 seconds
+ connection._.pollTimeout = res.ConnectionTimeout * 1000 + 10000; // in ms
+
+ // Once the server has labeled the PersistentConnection as Disconnected, we should stop attempting to reconnect
+ // after res.DisconnectTimeout seconds.
+ connection.disconnectTimeout = res.DisconnectTimeout * 1000; // in ms
+
+ // Add the TransportConnectTimeout from the response to the transportConnectTimeout from the client to calculate the total timeout
+ connection._.totalTransportConnectTimeout = connection.transportConnectTimeout + res.TransportConnectTimeout * 1000;
+
+ // If we have a keep alive
+ if (res.KeepAliveTimeout) {
+ // Register the keep alive data as activated
+ keepAliveData.activated = true;
+
+ // Timeout to designate when to force the connection into reconnecting converted to milliseconds
+ keepAliveData.timeout = res.KeepAliveTimeout * 1000;
+
+ // Timeout to designate when to warn the developer that the connection may be dead or is not responding.
+ keepAliveData.timeoutWarning = keepAliveData.timeout * connection.keepAliveWarnAt;
+
+ // Instantiate the frequency in which we check the keep alive. It must be short in order to not miss/pick up any changes
+ connection._.beatInterval = (keepAliveData.timeout - keepAliveData.timeoutWarning) / 3;
+ } else {
+ keepAliveData.activated = false;
+ }
+
+ connection.reconnectWindow = connection.disconnectTimeout + (keepAliveData.timeout || 0);
+
+ $.each(signalR.transports, function (key) {
+ if ((key.indexOf("_") === 0) || (key === "webSockets" && !res.TryWebSockets)) {
+ return true;
+ }
+ supportedTransports.push(key);
+ });
+
+ if ($.isArray(config.transport)) {
+ $.each(config.transport, function (_, transport) {
+ if ($.inArray(transport, supportedTransports) >= 0) {
+ transports.push(transport);
+ }
+ });
+ } else if (config.transport === "auto") {
+ transports = supportedTransports;
+ } else if ($.inArray(config.transport, supportedTransports) >= 0) {
+ transports.push(config.transport);
+ }
+
+ initialize(transports);
+ };
+
+ return negotiate(connection, callback);
+ }();
+
+ return deferred.promise();
+ },
+
+ starting: function (callback) {
+ /// Adds a callback that will be invoked before anything is sent over the connection
+ /// A callback function to execute before the connection is fully instantiated.
+ ///
+ var connection = this;
+ $(connection).bind(events.onStarting, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ send: function (data) {
+ /// Sends data over the connection
+ /// The data to send over the connection
+ ///
+ var connection = this;
+
+ if (connection.state === signalR.connectionState.disconnected) {
+ // Connection hasn't been started yet
+ throw new Error("SignalR: Connection must be started before data can be sent. Call .start() before .send()");
+ }
+
+ if (connection.state === signalR.connectionState.connecting) {
+ // Connection hasn't been started yet
+ throw new Error("SignalR: Connection has not been fully initialized. Use .start().done() or .start().fail() to run logic after the connection has started.");
+ }
+
+ connection.transport.send(connection, data);
+ // REVIEW: Should we return deferred here?
+ return connection;
+ },
+
+ received: function (callback) {
+ /// Adds a callback that will be invoked after anything is received over the connection
+ /// A callback function to execute when any data is received on the connection
+ ///
+ var connection = this;
+ $(connection).bind(events.onReceived, function (e, data) {
+ callback.call(connection, data);
+ });
+ return connection;
+ },
+
+ stateChanged: function (callback) {
+ /// Adds a callback that will be invoked when the connection state changes
+ /// A callback function to execute when the connection state changes
+ ///
+ var connection = this;
+ $(connection).bind(events.onStateChanged, function (e, data) {
+ callback.call(connection, data);
+ });
+ return connection;
+ },
+
+ error: function (callback) {
+ /// Adds a callback that will be invoked after an error occurs with the connection
+ /// A callback function to execute when an error occurs on the connection
+ ///
+ var connection = this;
+ $(connection).bind(events.onError, function (e, errorData, sendData) {
+ connection.lastError = errorData;
+ // In practice 'errorData' is the SignalR built error object.
+ // In practice 'sendData' is undefined for all error events except those triggered by
+ // 'ajaxSend' and 'webSockets.send'.'sendData' is the original send payload.
+ callback.call(connection, errorData, sendData);
+ });
+ return connection;
+ },
+
+ disconnected: function (callback) {
+ /// Adds a callback that will be invoked when the client disconnects
+ /// A callback function to execute when the connection is broken
+ ///
+ var connection = this;
+ $(connection).bind(events.onDisconnect, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ connectionSlow: function (callback) {
+ /// Adds a callback that will be invoked when the client detects a slow connection
+ /// A callback function to execute when the connection is slow
+ ///
+ var connection = this;
+ $(connection).bind(events.onConnectionSlow, function (e, data) {
+ callback.call(connection);
+ });
+
+ return connection;
+ },
+
+ reconnecting: function (callback) {
+ /// Adds a callback that will be invoked when the underlying transport begins reconnecting
+ /// A callback function to execute when the connection enters a reconnecting state
+ ///
+ var connection = this;
+ $(connection).bind(events.onReconnecting, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ reconnected: function (callback) {
+ /// Adds a callback that will be invoked when the underlying transport reconnects
+ /// A callback function to execute when the connection is restored
+ ///
+ var connection = this;
+ $(connection).bind(events.onReconnect, function (e, data) {
+ callback.call(connection);
+ });
+ return connection;
+ },
+
+ stop: function (async, notifyServer) {
+ /// Stops listening
+ /// Whether or not to asynchronously abort the connection
+ /// Whether we want to notify the server that we are aborting the connection
+ ///
+ var connection = this,
+ // Save deferral because this is always cleaned up
+ deferral = connection._deferral;
+
+ // Verify that we've bound a load event.
+ if (connection._.deferredStartHandler) {
+ // Unbind the event.
+ _pageWindow.unbind("load", connection._.deferredStartHandler);
+ }
+
+ // Always clean up private non-timeout based state.
+ delete connection._.config;
+ delete connection._.deferredStartHandler;
+
+ // This needs to be checked despite the connection state because a connection start can be deferred until page load.
+ // If we've deferred the start due to a page load we need to unbind the "onLoad" -> start event.
+ if (!_pageLoaded && (!connection._.config || connection._.config.waitForPageLoad === true)) {
+ connection.log("Stopping connection prior to negotiate.");
+
+ // If we have a deferral we should reject it
+ if (deferral) {
+ deferral.reject(signalR._.error(resources.stoppedWhileLoading));
+ }
+
+ // Short-circuit because the start has not been fully started.
+ return;
+ }
+
+ if (connection.state === signalR.connectionState.disconnected) {
+ return;
+ }
+
+ connection.log("Stopping connection.");
+
+ // Clear this no matter what
+ window.clearTimeout(connection._.beatHandle);
+ window.clearInterval(connection._.pingIntervalId);
+
+ if (connection.transport) {
+ connection.transport.stop(connection);
+
+ if (notifyServer !== false) {
+ connection.transport.abort(connection, async);
+ }
+
+ if (supportsKeepAlive(connection)) {
+ signalR.transports._logic.stopMonitoringKeepAlive(connection);
+ }
+
+ connection.transport = null;
+ }
+
+ if (connection._.negotiateRequest) {
+ // If the negotiation request has already completed this will noop.
+ connection._.negotiateRequest.abort(_negotiateAbortText);
+ delete connection._.negotiateRequest;
+ }
+
+ // Ensure that initHandler.stop() is called before connection._deferral is deleted
+ if (connection._.initHandler) {
+ connection._.initHandler.stop();
+ }
+
+ delete connection._deferral;
+ delete connection.messageId;
+ delete connection.groupsToken;
+ delete connection.id;
+ delete connection._.pingIntervalId;
+ delete connection._.lastMessageAt;
+ delete connection._.lastActiveAt;
+
+ // Clear out our message buffer
+ connection._.connectingMessageBuffer.clear();
+
+ // Clean up this event
+ $(connection).unbind(events.onStart);
+
+ // Reset the URL and clear the access token
+ delete connection.accessToken;
+ delete connection.protocol;
+ delete connection.host;
+ delete connection.baseUrl;
+ delete connection.wsProtocol;
+ delete connection.contentType;
+ connection.url = connection._originalUrl;
+ connection._.redirectQs = null;
+
+ // Trigger the disconnect event
+ changeState(connection, connection.state, signalR.connectionState.disconnected);
+ $(connection).triggerHandler(events.onDisconnect);
+
+ return connection;
+ },
+
+ log: function (msg) {
+ log(msg, this.logging);
+ }
+ };
+
+ signalR.fn.init.prototype = signalR.fn;
+
+ signalR.noConflict = function () {
+ /// Reinstates the original value of $.connection and returns the signalR object for manual assignment
+ ///
+ if ($.connection === signalR) {
+ $.connection = _connection;
+ }
+ return signalR;
+ };
+
+ if ($.connection) {
+ _connection = $.connection;
+ }
+
+ $.connection = $.signalR = signalR;
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.common.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ startAbortText = "__Start Aborted__",
+ transportLogic;
+
+ signalR.transports = {};
+
+ function beat(connection) {
+ if (connection._.keepAliveData.monitoring) {
+ checkIfAlive(connection);
+ }
+
+ // Ensure that we successfully marked active before continuing the heartbeat.
+ if (transportLogic.markActive(connection)) {
+ connection._.beatHandle = window.setTimeout(function () {
+ beat(connection);
+ }, connection._.beatInterval);
+ }
+ }
+
+ function checkIfAlive(connection) {
+ var keepAliveData = connection._.keepAliveData,
+ timeElapsed;
+
+ // Only check if we're connected
+ if (connection.state === signalR.connectionState.connected) {
+ timeElapsed = new Date().getTime() - connection._.lastMessageAt;
+
+ // Check if the keep alive has completely timed out
+ if (timeElapsed >= keepAliveData.timeout) {
+ connection.log("Keep alive timed out. Notifying transport that connection has been lost.");
+
+ // Notify transport that the connection has been lost
+ connection.transport.lostConnection(connection);
+ } else if (timeElapsed >= keepAliveData.timeoutWarning) {
+ // This is to assure that the user only gets a single warning
+ if (!keepAliveData.userNotified) {
+ connection.log("Keep alive has been missed, connection may be dead/slow.");
+ $(connection).triggerHandler(events.onConnectionSlow);
+ keepAliveData.userNotified = true;
+ }
+ } else {
+ keepAliveData.userNotified = false;
+ }
+ }
+ }
+
+ function getAjaxUrl(connection, path) {
+ var url = connection.url + path;
+
+ if (connection.transport) {
+ url += "?transport=" + connection.transport.name;
+ }
+
+ return transportLogic.prepareQueryString(connection, url);
+ }
+
+ function InitHandler(connection) {
+ this.connection = connection;
+
+ this.startRequested = false;
+ this.startCompleted = false;
+ this.connectionStopped = false;
+ }
+
+ InitHandler.prototype = {
+ start: function (transport, onSuccess, onFallback) {
+ var that = this,
+ connection = that.connection,
+ failCalled = false;
+
+ if (that.startRequested || that.connectionStopped) {
+ connection.log("WARNING! " + transport.name + " transport cannot be started. Initialization ongoing or completed.");
+ return;
+ }
+
+ connection.log(transport.name + " transport starting.");
+
+ transport.start(connection, function () {
+ if (!failCalled) {
+ that.initReceived(transport, onSuccess);
+ }
+ }, function (error) {
+ // Don't allow the same transport to cause onFallback to be called twice
+ if (!failCalled) {
+ failCalled = true;
+ that.transportFailed(transport, error, onFallback);
+ }
+
+ // Returns true if the transport should stop;
+ // false if it should attempt to reconnect
+ return !that.startCompleted || that.connectionStopped;
+ });
+
+ that.transportTimeoutHandle = window.setTimeout(function () {
+ if (!failCalled) {
+ failCalled = true;
+ connection.log(transport.name + " transport timed out when trying to connect.");
+ that.transportFailed(transport, undefined, onFallback);
+ }
+ }, connection._.totalTransportConnectTimeout);
+ },
+
+ stop: function () {
+ this.connectionStopped = true;
+ window.clearTimeout(this.transportTimeoutHandle);
+ signalR.transports._logic.tryAbortStartRequest(this.connection);
+ },
+
+ initReceived: function (transport, onSuccess) {
+ var that = this,
+ connection = that.connection;
+
+ if (that.startRequested) {
+ connection.log("WARNING! The client received multiple init messages.");
+ return;
+ }
+
+ if (that.connectionStopped) {
+ return;
+ }
+
+ that.startRequested = true;
+ window.clearTimeout(that.transportTimeoutHandle);
+
+ connection.log(transport.name + " transport connected. Initiating start request.");
+ signalR.transports._logic.ajaxStart(connection, function () {
+ that.startCompleted = true;
+ onSuccess();
+ });
+ },
+
+ transportFailed: function (transport, error, onFallback) {
+ var connection = this.connection,
+ deferred = connection._deferral,
+ wrappedError;
+
+ if (this.connectionStopped) {
+ return;
+ }
+
+ window.clearTimeout(this.transportTimeoutHandle);
+
+ if (!this.startRequested) {
+ transport.stop(connection);
+
+ connection.log(transport.name + " transport failed to connect. Attempting to fall back.");
+ onFallback();
+ } else if (!this.startCompleted) {
+ // Do not attempt to fall back if a start request is ongoing during a transport failure.
+ // Instead, trigger an error and stop the connection.
+ wrappedError = signalR._.error(signalR.resources.errorDuringStartRequest, error);
+
+ connection.log(transport.name + " transport failed during the start request. Stopping the connection.");
+ $(connection).triggerHandler(events.onError, [wrappedError]);
+ if (deferred) {
+ deferred.reject(wrappedError);
+ }
+
+ connection.stop();
+ } else {
+ // The start request has completed, but the connection has not stopped.
+ // No need to do anything here. The transport should attempt its normal reconnect logic.
+ }
+ }
+ };
+
+ transportLogic = signalR.transports._logic = {
+ ajax: function (connection, options) {
+ return $.ajax(
+ $.extend(/*deep copy*/ true, {}, $.signalR.ajaxDefaults, {
+ type: "GET",
+ data: {},
+ xhrFields: { withCredentials: connection.withCredentials },
+ contentType: connection.contentType,
+ dataType: connection.ajaxDataType
+ }, options));
+ },
+
+ pingServer: function (connection) {
+ /// Pings the server
+ /// Connection associated with the server ping
+ ///
+ var url,
+ xhr,
+ deferral = $.Deferred();
+
+ if (connection.transport) {
+ url = connection.url + "/ping";
+
+ url = transportLogic.addQs(url, connection.qs);
+
+ xhr = transportLogic.ajax(connection, {
+ url: url,
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ success: function (result) {
+ var data;
+
+ try {
+ data = connection._parseResponse(result);
+ }
+ catch (error) {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.pingServerFailedParse,
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ connection.stop();
+ return;
+ }
+
+ if (data.Response === "pong") {
+ deferral.resolve();
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR._.format(signalR.resources.pingServerFailedInvalidResponse, result),
+ connection.transport,
+ null /* error */,
+ xhr
+ )
+ );
+ }
+ },
+ error: function (error) {
+ if (error.status === 401 || error.status === 403) {
+ deferral.reject(
+ signalR._.transportError(
+ signalR._.format(signalR.resources.pingServerFailedStatusCode, error.status),
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ connection.stop();
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.pingServerFailed,
+ connection.transport,
+ error,
+ xhr
+ )
+ );
+ }
+ }
+ });
+ }
+ else {
+ deferral.reject(
+ signalR._.transportError(
+ signalR.resources.noConnectionTransport,
+ connection.transport
+ )
+ );
+ }
+
+ return deferral.promise();
+ },
+
+ prepareQueryString: function (connection, url) {
+ var preparedUrl;
+
+ // Use addQs to start since it handles the ?/& prefix for us
+ preparedUrl = transportLogic.addQs(url, "clientProtocol=" + connection.clientProtocol);
+
+ if (typeof (connection._.redirectQs) === "string") {
+ // Add the redirect-specified query string params if any
+ preparedUrl = transportLogic.addQs(preparedUrl, connection._.redirectQs);
+ } else {
+ // Otherwise, add the user-specified query string params if any
+ preparedUrl = transportLogic.addQs(preparedUrl, connection.qs);
+ }
+
+ if (connection.token) {
+ preparedUrl += "&connectionToken=" + window.encodeURIComponent(connection.token);
+ }
+
+ if (connection.data) {
+ preparedUrl += "&connectionData=" + window.encodeURIComponent(connection.data);
+ }
+
+ return preparedUrl;
+ },
+
+ addQs: function (url, qs) {
+ var appender = url.indexOf("?") !== -1 ? "&" : "?",
+ firstChar;
+
+ if (!qs) {
+ return url;
+ }
+
+ if (typeof (qs) === "object") {
+ return url + appender + $.param(qs);
+ }
+
+ if (typeof (qs) === "string") {
+ firstChar = qs.charAt(0);
+
+ if (firstChar === "?" || firstChar === "&") {
+ appender = "";
+ }
+
+ return url + appender + qs;
+ }
+
+ throw new Error("Query string property must be either a string or object.");
+ },
+
+ // BUG #2953: The url needs to be same otherwise it will cause a memory leak
+ getUrl: function (connection, transport, reconnecting, poll, ajaxPost) {
+ /// Gets the url for making a GET based connect request
+ var baseUrl = transport === "webSockets" ? "" : connection.baseUrl,
+ url = baseUrl + connection.appRelativeUrl,
+ qs = "transport=" + transport;
+
+ if (!ajaxPost && connection.groupsToken) {
+ qs += "&groupsToken=" + window.encodeURIComponent(connection.groupsToken);
+ }
+
+ if (!reconnecting) {
+ url += "/connect";
+ } else {
+ if (poll) {
+ // longPolling transport specific
+ url += "/poll";
+ } else {
+ url += "/reconnect";
+ }
+
+ if (!ajaxPost && connection.messageId) {
+ qs += "&messageId=" + window.encodeURIComponent(connection.messageId);
+ }
+ }
+ url += "?" + qs;
+ url = transportLogic.prepareQueryString(connection, url);
+
+ // With sse or ws, access_token in request header is not supported
+ if (connection.transport && connection.accessToken) {
+ if (connection.transport.name === "serverSentEvents" || connection.transport.name === "webSockets") {
+ url += "&access_token=" + window.encodeURIComponent(connection.accessToken);
+ }
+ }
+
+ if (!ajaxPost) {
+ url += "&tid=" + Math.floor(Math.random() * 11);
+ }
+
+ return url;
+ },
+
+ maximizePersistentResponse: function (minPersistentResponse) {
+ return {
+ MessageId: minPersistentResponse.C,
+ Messages: minPersistentResponse.M,
+ Initialized: typeof (minPersistentResponse.S) !== "undefined" ? true : false,
+ ShouldReconnect: typeof (minPersistentResponse.T) !== "undefined" ? true : false,
+ LongPollDelay: minPersistentResponse.L,
+ GroupsToken: minPersistentResponse.G,
+ Error: minPersistentResponse.E
+ };
+ },
+
+ updateGroups: function (connection, groupsToken) {
+ if (groupsToken) {
+ connection.groupsToken = groupsToken;
+ }
+ },
+
+ stringifySend: function (connection, message) {
+ if (typeof (message) === "string" || typeof (message) === "undefined" || message == undefined) {
+ return message;
+ }
+ return connection.json.stringify(message);
+ },
+
+ ajaxSend: function (connection, data) {
+ var payload = transportLogic.stringifySend(connection, data),
+ url = getAjaxUrl(connection, "/send"),
+ xhr,
+ onFail = function (error, connection) {
+ $(connection).triggerHandler(events.onError, [signalR._.transportError(signalR.resources.sendFailed, connection.transport, error, xhr), data]);
+ };
+
+
+ xhr = transportLogic.ajax(connection, {
+ url: url,
+ type: connection.ajaxDataType === "jsonp" ? "GET" : "POST",
+ contentType: signalR._.defaultContentType,
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ data: {
+ data: payload
+ },
+ success: function (result) {
+ var res;
+
+ if (result) {
+ try {
+ res = connection._parseResponse(result);
+ }
+ catch (error) {
+ onFail(error, connection);
+ connection.stop();
+ return;
+ }
+
+ transportLogic.triggerReceived(connection, res);
+ }
+ },
+ error: function (error, textStatus) {
+ if (textStatus === "abort" || textStatus === "parsererror") {
+ // The parsererror happens for sends that don't return any data, and hence
+ // don't write the jsonp callback to the response. This is harder to fix on the server
+ // so just hack around it on the client for now.
+ return;
+ }
+
+ onFail(error, connection);
+ }
+ });
+
+ return xhr;
+ },
+
+ ajaxAbort: function (connection, async) {
+ if (typeof (connection.transport) === "undefined") {
+ return;
+ }
+
+ // Async by default unless explicitly overidden
+ async = typeof async === "undefined" ? true : async;
+
+ var url = getAjaxUrl(connection, "/abort");
+
+ var requestHeaders = connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {};
+
+ //option #1 - send "fetch" with keepalive
+ if (window.fetch) {
+ // use the fetch API with keepalive
+ window.fetch(url, {
+ method: "POST",
+ keepalive: true,
+ headers: requestHeaders,
+ credentials: connection.withCredentials === true ? "include" : "same-origin"
+ });
+ }
+ else {
+ // fetch is not available - fallback to $.ajax
+ transportLogic.ajax(connection, {
+ url: url,
+ async: async,
+ timeout: 1000,
+ type: "POST",
+ headers: requestHeaders,
+ dataType: "text" // We don't want to use JSONP here even when JSONP is enabled
+ });
+ }
+
+ connection.log("Fired ajax abort async = " + async + ".");
+ },
+
+ ajaxStart: function (connection, onSuccess) {
+ var rejectDeferred = function (error) {
+ var deferred = connection._deferral;
+ if (deferred) {
+ deferred.reject(error);
+ }
+ },
+ triggerStartError = function (error) {
+ connection.log("The start request failed. Stopping the connection.");
+ $(connection).triggerHandler(events.onError, [error]);
+ rejectDeferred(error);
+ connection.stop();
+ };
+
+ connection._.startRequest = transportLogic.ajax(connection, {
+ url: getAjaxUrl(connection, "/start"),
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ success: function (result, statusText, xhr) {
+ var data;
+
+ try {
+ data = connection._parseResponse(result);
+ } catch (error) {
+ triggerStartError(signalR._.error(
+ signalR._.format(signalR.resources.errorParsingStartResponse, result),
+ error, xhr));
+ return;
+ }
+
+ if (data.Response === "started") {
+ onSuccess();
+ } else {
+ triggerStartError(signalR._.error(
+ signalR._.format(signalR.resources.invalidStartResponse, result),
+ null /* error */, xhr));
+ }
+ },
+ error: function (xhr, statusText, error) {
+ if (statusText !== startAbortText) {
+ triggerStartError(signalR._.error(
+ signalR.resources.errorDuringStartRequest,
+ error, xhr));
+ } else {
+ // Stop has been called, no need to trigger the error handler
+ // or stop the connection again with onStartError
+ connection.log("The start request aborted because connection.stop() was called.");
+ rejectDeferred(signalR._.error(
+ signalR.resources.stoppedDuringStartRequest,
+ null /* error */, xhr));
+ }
+ }
+ });
+ },
+
+ tryAbortStartRequest: function (connection) {
+ if (connection._.startRequest) {
+ // If the start request has already completed this will noop.
+ connection._.startRequest.abort(startAbortText);
+ delete connection._.startRequest;
+ }
+ },
+
+ tryInitialize: function (connection, persistentResponse, onInitialized) {
+ if (persistentResponse.Initialized && onInitialized) {
+ onInitialized();
+ } else if (persistentResponse.Initialized) {
+ connection.log("WARNING! The client received an init message after reconnecting.");
+ }
+
+ },
+
+ triggerReceived: function (connection, data) {
+ if (!connection._.connectingMessageBuffer.tryBuffer(data)) {
+ $(connection).triggerHandler(events.onReceived, [data]);
+ }
+ },
+
+ processMessages: function (connection, minData, onInitialized) {
+ var data;
+
+ if(minData && (typeof minData.I !== "undefined")) {
+ // This is a response to a message the client sent
+ transportLogic.triggerReceived(connection, minData);
+ return;
+ }
+
+ // Update the last message time stamp
+ transportLogic.markLastMessage(connection);
+
+ if (minData) {
+ // This is a message send directly to the client
+ data = transportLogic.maximizePersistentResponse(minData);
+
+ if (data.Error) {
+ // This is a global error, stop the connection.
+ connection.log("Received an error message from the server: " + minData.E);
+ $(connection).triggerHandler(signalR.events.onError, [signalR._.error(minData.E, /* source */ "ServerError")]);
+ connection.stop(/* async */ false, /* notifyServer */ false);
+ return;
+ }
+
+ transportLogic.updateGroups(connection, data.GroupsToken);
+
+ if (data.MessageId) {
+ connection.messageId = data.MessageId;
+ }
+
+ if (data.Messages) {
+ $.each(data.Messages, function (index, message) {
+ transportLogic.triggerReceived(connection, message);
+ });
+
+ transportLogic.tryInitialize(connection, data, onInitialized);
+ }
+ }
+ },
+
+ monitorKeepAlive: function (connection) {
+ var keepAliveData = connection._.keepAliveData;
+
+ // If we haven't initiated the keep alive timeouts then we need to
+ if (!keepAliveData.monitoring) {
+ keepAliveData.monitoring = true;
+
+ transportLogic.markLastMessage(connection);
+
+ // Save the function so we can unbind it on stop
+ connection._.keepAliveData.reconnectKeepAliveUpdate = function () {
+ // Mark a new message so that keep alive doesn't time out connections
+ transportLogic.markLastMessage(connection);
+ };
+
+ // Update Keep alive on reconnect
+ $(connection).bind(events.onReconnect, connection._.keepAliveData.reconnectKeepAliveUpdate);
+
+ connection.log("Now monitoring keep alive with a warning timeout of " + keepAliveData.timeoutWarning + ", keep alive timeout of " + keepAliveData.timeout + " and disconnecting timeout of " + connection.disconnectTimeout);
+ } else {
+ connection.log("Tried to monitor keep alive but it's already being monitored.");
+ }
+ },
+
+ stopMonitoringKeepAlive: function (connection) {
+ var keepAliveData = connection._.keepAliveData;
+
+ // Only attempt to stop the keep alive monitoring if its being monitored
+ if (keepAliveData.monitoring) {
+ // Stop monitoring
+ keepAliveData.monitoring = false;
+
+ // Remove the updateKeepAlive function from the reconnect event
+ $(connection).unbind(events.onReconnect, connection._.keepAliveData.reconnectKeepAliveUpdate);
+
+ // Clear all the keep alive data
+ connection._.keepAliveData = {};
+ connection.log("Stopping the monitoring of the keep alive.");
+ }
+ },
+
+ startHeartbeat: function (connection) {
+ connection._.lastActiveAt = new Date().getTime();
+ beat(connection);
+ },
+
+ markLastMessage: function (connection) {
+ connection._.lastMessageAt = new Date().getTime();
+ connection._.lastActiveAt = connection._.lastMessageAt;
+ },
+
+ markActive: function (connection) {
+ if (transportLogic.verifyLastActive(connection)) {
+ connection._.lastActiveAt = new Date().getTime();
+ return true;
+ }
+
+ return false;
+ },
+
+ isConnectedOrReconnecting: function (connection) {
+ return connection.state === signalR.connectionState.connected ||
+ connection.state === signalR.connectionState.reconnecting;
+ },
+
+ ensureReconnectingState: function (connection) {
+ if (changeState(connection,
+ signalR.connectionState.connected,
+ signalR.connectionState.reconnecting) === true) {
+ $(connection).triggerHandler(events.onReconnecting);
+ }
+ return connection.state === signalR.connectionState.reconnecting;
+ },
+
+ clearReconnectTimeout: function (connection) {
+ if (connection && connection._.reconnectTimeout) {
+ window.clearTimeout(connection._.reconnectTimeout);
+ delete connection._.reconnectTimeout;
+ }
+ },
+
+ verifyLastActive: function (connection) {
+ // If there is no keep alive configured, we cannot assume that timer callbacks will
+ // run frequently enough to keep lastActiveAt updated.
+ // https://github.com/SignalR/SignalR/issues/4536
+ if (!connection._.keepAliveData.activated ||
+ new Date().getTime() - connection._.lastActiveAt < connection.reconnectWindow) {
+ return true;
+ }
+
+ var message = signalR._.format(signalR.resources.reconnectWindowTimeout, new Date(connection._.lastActiveAt), connection.reconnectWindow);
+ connection.log(message);
+ $(connection).triggerHandler(events.onError, [signalR._.error(message, /* source */ "TimeoutException")]);
+ connection.stop(/* async */ false, /* notifyServer */ false);
+ return false;
+ },
+
+ reconnect: function (connection, transportName) {
+ var transport = signalR.transports[transportName];
+
+ // We should only set a reconnectTimeout if we are currently connected
+ // and a reconnectTimeout isn't already set.
+ if (transportLogic.isConnectedOrReconnecting(connection) && !connection._.reconnectTimeout) {
+ // Need to verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ connection._.reconnectTimeout = window.setTimeout(function () {
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ transport.stop(connection);
+
+ if (transportLogic.ensureReconnectingState(connection)) {
+ connection.log(transportName + " reconnecting.");
+ transport.start(connection);
+ }
+ }, connection.reconnectDelay);
+ }
+ },
+
+ handleParseFailure: function (connection, result, error, onFailed, context) {
+ var wrappedError = signalR._.transportError(
+ signalR._.format(signalR.resources.parseFailed, result),
+ connection.transport,
+ error,
+ context);
+
+ // If we're in the initialization phase trigger onFailed, otherwise stop the connection.
+ if (onFailed && onFailed(wrappedError)) {
+ connection.log("Failed to parse server response while attempting to connect.");
+ } else {
+ $(connection).triggerHandler(events.onError, [wrappedError]);
+ connection.stop();
+ }
+ },
+
+ initHandler: function (connection) {
+ return new InitHandler(connection);
+ },
+
+ foreverFrame: {
+ count: 0,
+ connections: {}
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.webSockets.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic;
+
+ signalR.transports.webSockets = {
+ name: "webSockets",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ send: function (connection, data) {
+ var payload = transportLogic.stringifySend(connection, data);
+
+ try {
+ connection.socket.send(payload);
+ } catch (ex) {
+ $(connection).triggerHandler(events.onError,
+ [signalR._.transportError(
+ signalR.resources.webSocketsInvalidState,
+ connection.transport,
+ ex,
+ connection.socket
+ ),
+ data]);
+ }
+ },
+
+ start: function (connection, onSuccess, onFailed) {
+ var url,
+ opened = false,
+ that = this,
+ reconnecting = !onSuccess,
+ $connection = $(connection);
+
+ if (!window.WebSocket) {
+ onFailed();
+ return;
+ }
+
+ if (!connection.socket) {
+ if (connection.webSocketServerUrl) {
+ url = connection.webSocketServerUrl;
+ } else {
+ url = connection.wsProtocol + connection.host;
+ }
+
+ url += transportLogic.getUrl(connection, this.name, reconnecting);
+
+ connection.log("Connecting to websocket endpoint '" + url + "'.");
+ connection.socket = new window.WebSocket(url);
+
+ connection.socket.onopen = function () {
+ opened = true;
+ connection.log("Websocket opened.");
+
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ $connection.triggerHandler(events.onReconnect);
+ }
+ };
+
+ connection.socket.onclose = function (event) {
+ var error;
+
+ // Only handle a socket close if the close is from the current socket.
+ // Sometimes on disconnect the server will push down an onclose event
+ // to an expired socket.
+
+ if (this === connection.socket) {
+ if (opened && typeof event.wasClean !== "undefined" && event.wasClean === false) {
+ // Ideally this would use the websocket.onerror handler (rather than checking wasClean in onclose) but
+ // I found in some circumstances Chrome won't call onerror. This implementation seems to work on all browsers.
+ error = signalR._.transportError(
+ signalR.resources.webSocketClosed,
+ connection.transport,
+ event);
+
+ connection.log("Unclean disconnect from websocket: " + (event.reason || "[no reason given]."));
+ } else {
+ connection.log("Websocket closed.");
+ }
+
+ if (!onFailed || !onFailed(error)) {
+ if (error) {
+ $(connection).triggerHandler(events.onError, [error]);
+ }
+
+ that.reconnect(connection);
+ }
+ }
+ };
+
+ connection.socket.onmessage = function (event) {
+ var data;
+
+ try {
+ data = connection._parseResponse(event.data);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(connection, event.data, error, onFailed, event);
+ return;
+ }
+
+ if (data) {
+ transportLogic.processMessages(connection, data, onSuccess);
+ }
+ };
+ }
+ },
+
+ reconnect: function (connection) {
+ transportLogic.reconnect(connection, this.name);
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ stop: function (connection) {
+ // Don't trigger a reconnect after stopping
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (connection.socket) {
+ connection.log("Closing the Websocket.");
+ connection.socket.close();
+ connection.socket = null;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.serverSentEvents.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic,
+ clearReconnectAttemptTimeout = function (connection) {
+ window.clearTimeout(connection._.reconnectAttemptTimeoutHandle);
+ delete connection._.reconnectAttemptTimeoutHandle;
+ };
+
+ signalR.transports.serverSentEvents = {
+ name: "serverSentEvents",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ timeOut: 3000,
+
+ start: function (connection, onSuccess, onFailed) {
+ var that = this,
+ opened = false,
+ $connection = $(connection),
+ reconnecting = !onSuccess,
+ url;
+
+ if (connection.eventSource) {
+ connection.log("The connection already has an event source. Stopping it.");
+ connection.stop();
+ }
+
+ if (!window.EventSource) {
+ if (onFailed) {
+ connection.log("This browser doesn't support SSE.");
+ onFailed();
+ }
+ return;
+ }
+
+ url = transportLogic.getUrl(connection, this.name, reconnecting);
+
+ try {
+ connection.log("Attempting to connect to SSE endpoint '" + url + "'.");
+ connection.eventSource = new window.EventSource(url, { withCredentials: connection.withCredentials });
+ }
+ catch (e) {
+ connection.log("EventSource failed trying to connect with error " + e.Message + ".");
+ if (onFailed) {
+ // The connection failed, call the failed callback
+ onFailed();
+ } else {
+ $connection.triggerHandler(events.onError, [signalR._.transportError(signalR.resources.eventSourceFailedToConnect, connection.transport, e)]);
+ if (reconnecting) {
+ // If we were reconnecting, rather than doing initial connect, then try reconnect again
+ that.reconnect(connection);
+ }
+ }
+ return;
+ }
+
+ if (reconnecting) {
+ connection._.reconnectAttemptTimeoutHandle = window.setTimeout(function () {
+ if (opened === false) {
+ // If we're reconnecting and the event source is attempting to connect,
+ // don't keep retrying. This causes duplicate connections to spawn.
+ if (connection.eventSource.readyState !== window.EventSource.OPEN) {
+ // If we were reconnecting, rather than doing initial connect, then try reconnect again
+ that.reconnect(connection);
+ }
+ }
+ },
+ that.timeOut);
+ }
+
+ connection.eventSource.addEventListener("open", function (e) {
+ connection.log("EventSource connected.");
+
+ clearReconnectAttemptTimeout(connection);
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (opened === false) {
+ opened = true;
+
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ $connection.triggerHandler(events.onReconnect);
+ }
+ }
+ }, false);
+
+ connection.eventSource.addEventListener("message", function (e) {
+ var res;
+
+ // process messages
+ if (e.data === "initialized") {
+ return;
+ }
+
+ try {
+ res = connection._parseResponse(e.data);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(connection, e.data, error, onFailed, e);
+ return;
+ }
+
+ transportLogic.processMessages(connection, res, onSuccess);
+ }, false);
+
+ connection.eventSource.addEventListener("error", function (e) {
+ var error = signalR._.transportError(
+ signalR.resources.eventSourceError,
+ connection.transport,
+ e);
+
+ // Only handle an error if the error is from the current Event Source.
+ // Sometimes on disconnect the server will push down an error event
+ // to an expired Event Source.
+ if (this !== connection.eventSource) {
+ return;
+ }
+
+ if (onFailed && onFailed(error)) {
+ return;
+ }
+
+ connection.log("EventSource readyState: " + connection.eventSource.readyState + ".");
+
+ if (e.eventPhase === window.EventSource.CLOSED) {
+ // We don't use the EventSource's native reconnect function as it
+ // doesn't allow us to change the URL when reconnecting. We need
+ // to change the URL to not include the /connect suffix, and pass
+ // the last message id we received.
+ connection.log("EventSource reconnecting due to the server connection ending.");
+ that.reconnect(connection);
+ } else {
+ // connection error
+ connection.log("EventSource error.");
+ $connection.triggerHandler(events.onError, [error]);
+ }
+ }, false);
+ },
+
+ reconnect: function (connection) {
+ transportLogic.reconnect(connection, this.name);
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ stop: function (connection) {
+ // Don't trigger a reconnect after stopping
+ clearReconnectAttemptTimeout(connection);
+ transportLogic.clearReconnectTimeout(connection);
+
+ if (connection && connection.eventSource) {
+ connection.log("EventSource calling close().");
+ connection.eventSource.close();
+ connection.eventSource = null;
+ delete connection.eventSource;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.foreverFrame.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ transportLogic = signalR.transports._logic,
+ createFrame = function () {
+ var frame = window.document.createElement("iframe");
+ frame.setAttribute("style", "position:absolute;top:0;left:0;width:0;height:0;visibility:hidden;");
+ return frame;
+ },
+ // Used to prevent infinite loading icon spins in older versions of ie
+ // We build this object inside a closure so we don't pollute the rest of
+ // the foreverFrame transport with unnecessary functions/utilities.
+ loadPreventer = (function () {
+ var loadingFixIntervalId = null,
+ loadingFixInterval = 1000,
+ attachedTo = 0;
+
+ return {
+ prevent: function () {
+ // Prevent additional iframe removal procedures from newer browsers
+ if (signalR._.ieVersion <= 8) {
+ // We only ever want to set the interval one time, so on the first attachedTo
+ if (attachedTo === 0) {
+ // Create and destroy iframe every 3 seconds to prevent loading icon, super hacky
+ loadingFixIntervalId = window.setInterval(function () {
+ var tempFrame = createFrame();
+
+ window.document.body.appendChild(tempFrame);
+ window.document.body.removeChild(tempFrame);
+
+ tempFrame = null;
+ }, loadingFixInterval);
+ }
+
+ attachedTo++;
+ }
+ },
+ cancel: function () {
+ // Only clear the interval if there's only one more object that the loadPreventer is attachedTo
+ if (attachedTo === 1) {
+ window.clearInterval(loadingFixIntervalId);
+ }
+
+ if (attachedTo > 0) {
+ attachedTo--;
+ }
+ }
+ };
+ })();
+
+ signalR.transports.foreverFrame = {
+ name: "foreverFrame",
+
+ supportsKeepAlive: function () {
+ return true;
+ },
+
+ // Added as a value here so we can create tests to verify functionality
+ iframeClearThreshold: 50,
+
+ start: function (connection, onSuccess, onFailed) {
+ if (connection.accessToken) {
+ if (onFailed) {
+ connection.log("Forever Frame does not support connections that require a Bearer token to connect, such as the Azure SignalR Service.");
+ onFailed();
+ }
+ return;
+ }
+
+ var that = this,
+ frameId = (transportLogic.foreverFrame.count += 1),
+ url,
+ frame = createFrame(),
+ frameLoadHandler = function () {
+ connection.log("Forever frame iframe finished loading and is no longer receiving messages.");
+ if (!onFailed || !onFailed()) {
+ that.reconnect(connection);
+ }
+ };
+
+ if (window.EventSource) {
+ // If the browser supports SSE, don't use Forever Frame
+ if (onFailed) {
+ connection.log("Forever Frame is not supported by SignalR on browsers with SSE support.");
+ onFailed();
+ }
+ return;
+ }
+
+ frame.setAttribute("data-signalr-connection-id", connection.id);
+
+ // Start preventing loading icon
+ // This will only perform work if the loadPreventer is not attached to another connection.
+ loadPreventer.prevent();
+
+ // Build the url
+ url = transportLogic.getUrl(connection, this.name);
+ url += "&frameId=" + frameId;
+
+ // add frame to the document prior to setting URL to avoid caching issues.
+ window.document.documentElement.appendChild(frame);
+
+ connection.log("Binding to iframe's load event.");
+
+ if (frame.addEventListener) {
+ frame.addEventListener("load", frameLoadHandler, false);
+ } else if (frame.attachEvent) {
+ frame.attachEvent("onload", frameLoadHandler);
+ }
+
+ frame.src = url;
+ transportLogic.foreverFrame.connections[frameId] = connection;
+
+ connection.frame = frame;
+ connection.frameId = frameId;
+
+ if (onSuccess) {
+ connection.onSuccess = function () {
+ connection.log("Iframe transport started.");
+ onSuccess();
+ };
+ }
+ },
+
+ reconnect: function (connection) {
+ var that = this;
+
+ // Need to verify connection state and verify before the setTimeout occurs because an application sleep could occur during the setTimeout duration.
+ if (transportLogic.isConnectedOrReconnecting(connection) && transportLogic.verifyLastActive(connection)) {
+ window.setTimeout(function () {
+ // Verify that we're ok to reconnect.
+ if (!transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ if (connection.frame && transportLogic.ensureReconnectingState(connection)) {
+ var frame = connection.frame,
+ src = transportLogic.getUrl(connection, that.name, true) + "&frameId=" + connection.frameId;
+ connection.log("Updating iframe src to '" + src + "'.");
+ frame.src = src;
+ }
+ }, connection.reconnectDelay);
+ }
+ },
+
+ lostConnection: function (connection) {
+ this.reconnect(connection);
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ receive: function (connection, data) {
+ var cw,
+ body,
+ response;
+
+ if (connection.json !== connection._originalJson) {
+ // If there's a custom JSON parser configured then serialize the object
+ // using the original (browser) JSON parser and then deserialize it using
+ // the custom parser (connection._parseResponse does that). This is so we
+ // can easily send the response from the server as "raw" JSON but still
+ // support custom JSON deserialization in the browser.
+ data = connection._originalJson.stringify(data);
+ }
+
+ response = connection._parseResponse(data);
+
+ transportLogic.processMessages(connection, response, connection.onSuccess);
+
+ // Protect against connection stopping from a callback trigger within the processMessages above.
+ if (connection.state === $.signalR.connectionState.connected) {
+ // Delete the script & div elements
+ connection.frameMessageCount = (connection.frameMessageCount || 0) + 1;
+ if (connection.frameMessageCount > signalR.transports.foreverFrame.iframeClearThreshold) {
+ connection.frameMessageCount = 0;
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw && cw.document && cw.document.body) {
+ body = cw.document.body;
+
+ // Remove all the child elements from the iframe's body to conserver memory
+ while (body.firstChild) {
+ body.removeChild(body.firstChild);
+ }
+ }
+ }
+ }
+ },
+
+ stop: function (connection) {
+ var cw = null;
+
+ // Stop attempting to prevent loading icon
+ loadPreventer.cancel();
+
+ if (connection.frame) {
+ if (connection.frame.stop) {
+ connection.frame.stop();
+ } else {
+ try {
+ cw = connection.frame.contentWindow || connection.frame.contentDocument;
+ if (cw.document && cw.document.execCommand) {
+ cw.document.execCommand("Stop");
+ }
+ }
+ catch (e) {
+ connection.log("Error occurred when stopping foreverFrame transport. Message = " + e.message + ".");
+ }
+ }
+
+ // Ensure the iframe is where we left it
+ if (connection.frame.parentNode === window.document.documentElement) {
+ window.document.documentElement.removeChild(connection.frame);
+ }
+
+ delete transportLogic.foreverFrame.connections[connection.frameId];
+ connection.frame = null;
+ connection.frameId = null;
+ delete connection.frame;
+ delete connection.frameId;
+ delete connection.onSuccess;
+ delete connection.frameMessageCount;
+ connection.log("Stopping forever frame.");
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ },
+
+ getConnection: function (id) {
+ return transportLogic.foreverFrame.connections[id];
+ },
+
+ started: function (connection) {
+ if (changeState(connection,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+
+ $(connection).triggerHandler(events.onReconnect);
+ }
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.transports.longPolling.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var signalR = $.signalR,
+ events = $.signalR.events,
+ changeState = $.signalR.changeState,
+ isDisconnecting = $.signalR.isDisconnecting,
+ transportLogic = signalR.transports._logic;
+
+ signalR.transports.longPolling = {
+ name: "longPolling",
+
+ supportsKeepAlive: function () {
+ return false;
+ },
+
+ reconnectDelay: 3000,
+
+ start: function (connection, onSuccess, onFailed) {
+ /// Starts the long polling connection
+ /// The SignalR connection to start
+ var that = this,
+ fireConnect = function () {
+ fireConnect = $.noop;
+
+ connection.log("LongPolling connected.");
+
+ if (onSuccess) {
+ onSuccess();
+ } else {
+ connection.log("WARNING! The client received an init message after reconnecting.");
+ }
+ },
+ tryFailConnect = function (error) {
+ if (onFailed(error)) {
+ connection.log("LongPolling failed to connect.");
+ return true;
+ }
+
+ return false;
+ },
+ privateData = connection._,
+ reconnectErrors = 0,
+ fireReconnected = function (instance) {
+ window.clearTimeout(privateData.reconnectTimeoutId);
+ privateData.reconnectTimeoutId = null;
+
+ if (changeState(instance,
+ signalR.connectionState.reconnecting,
+ signalR.connectionState.connected) === true) {
+ // Successfully reconnected!
+ instance.log("Raising the reconnect event");
+ $(instance).triggerHandler(events.onReconnect);
+ }
+ },
+ // 1 hour
+ maxFireReconnectedTimeout = 3600000;
+
+ if (connection.pollXhr) {
+ connection.log("Polling xhr requests already exists, aborting.");
+ connection.stop();
+ }
+
+ connection.messageId = null;
+
+ privateData.reconnectTimeoutId = null;
+
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ (function poll(instance, raiseReconnect) {
+ var messageId = instance.messageId,
+ connect = (messageId == undefined),
+ reconnecting = !connect,
+ polling = !raiseReconnect,
+ url = transportLogic.getUrl(instance, that.name, reconnecting, polling, true /* use Post for longPolling */),
+ postData = {};
+
+ if (instance.messageId) {
+ postData.messageId = instance.messageId;
+ }
+
+ if (instance.groupsToken) {
+ postData.groupsToken = instance.groupsToken;
+ }
+
+ // If we've disconnected during the time we've tried to re-instantiate the poll then stop.
+ if (isDisconnecting(instance) === true) {
+ return;
+ }
+
+ connection.log("Opening long polling request to '" + url + "'.");
+ instance.pollXhr = transportLogic.ajax(connection, {
+ xhrFields: {
+ onprogress: function () {
+ transportLogic.markLastMessage(connection);
+ }
+ },
+ url: url,
+ type: "POST",
+ contentType: signalR._.defaultContentType,
+ data: postData,
+ timeout: connection._.pollTimeout,
+ headers: connection.accessToken ? { "Authorization": "Bearer " + connection.accessToken } : {},
+ success: function (result) {
+ var minData,
+ delay = 0,
+ data,
+ shouldReconnect;
+
+ connection.log("Long poll complete.");
+
+ // Reset our reconnect errors so if we transition into a reconnecting state again we trigger
+ // reconnected quickly
+ reconnectErrors = 0;
+
+ try {
+ // Remove any keep-alives from the beginning of the result
+ minData = connection._parseResponse(result);
+ }
+ catch (error) {
+ transportLogic.handleParseFailure(instance, result, error, tryFailConnect, instance.pollXhr);
+ return;
+ }
+
+ // If there's currently a timeout to trigger reconnect, fire it now before processing messages
+ if (privateData.reconnectTimeoutId != undefined) {
+ fireReconnected(instance);
+ }
+
+ if (minData) {
+ data = transportLogic.maximizePersistentResponse(minData);
+ }
+
+ transportLogic.processMessages(instance, minData, fireConnect);
+
+ if (data &&
+ $.type(data.LongPollDelay) === "number") {
+ delay = data.LongPollDelay;
+ }
+
+ if (isDisconnecting(instance) === true) {
+ return;
+ }
+
+ shouldReconnect = data && data.ShouldReconnect;
+ if (shouldReconnect) {
+ // Transition into the reconnecting state
+ // If this fails then that means that the user transitioned the connection into a invalid state in processMessages.
+ if (!transportLogic.ensureReconnectingState(instance)) {
+ return;
+ }
+ }
+
+ // We never want to pass a raiseReconnect flag after a successful poll. This is handled via the error function
+ if (delay > 0) {
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ poll(instance, shouldReconnect);
+ }, delay);
+ } else {
+ poll(instance, shouldReconnect);
+ }
+ },
+
+ error: function (data, textStatus) {
+ var error = signalR._.transportError(signalR.resources.longPollFailed, connection.transport, data, instance.pollXhr);
+
+ // Stop trying to trigger reconnect, connection is in an error state
+ // If we're not in the reconnect state this will noop
+ window.clearTimeout(privateData.reconnectTimeoutId);
+ privateData.reconnectTimeoutId = null;
+
+ if (textStatus === "abort") {
+ connection.log("Aborted xhr request.");
+ return;
+ }
+
+ if (!tryFailConnect(error)) {
+
+ // Increment our reconnect errors, we assume all errors to be reconnect errors
+ // In the case that it's our first error this will cause Reconnect to be fired
+ // after 1 second due to reconnectErrors being = 1.
+ reconnectErrors++;
+
+ if (connection.state !== signalR.connectionState.reconnecting) {
+ connection.log("An error occurred using longPolling. Status = " + textStatus + ". Response = " + data.responseText + ".");
+ $(instance).triggerHandler(events.onError, [error]);
+ }
+
+ // We check the state here to verify that we're not in an invalid state prior to verifying Reconnect.
+ // If we're not in connected or reconnecting then the next ensureReconnectingState check will fail and will return.
+ // Therefore we don't want to change that failure code path.
+ if ((connection.state === signalR.connectionState.connected ||
+ connection.state === signalR.connectionState.reconnecting) &&
+ !transportLogic.verifyLastActive(connection)) {
+ return;
+ }
+
+ // Transition into the reconnecting state
+ // If this fails then that means that the user transitioned the connection into the disconnected or connecting state within the above error handler trigger.
+ if (!transportLogic.ensureReconnectingState(instance)) {
+ return;
+ }
+
+ // Call poll with the raiseReconnect flag as true after the reconnect delay
+ privateData.pollTimeoutId = window.setTimeout(function () {
+ poll(instance, true);
+ }, that.reconnectDelay);
+ }
+ }
+ });
+
+ // This will only ever pass after an error has occurred via the poll ajax procedure.
+ if (reconnecting && raiseReconnect === true) {
+ // We wait to reconnect depending on how many times we've failed to reconnect.
+ // This is essentially a heuristic that will exponentially increase in wait time before
+ // triggering reconnected. This depends on the "error" handler of Poll to cancel this
+ // timeout if it triggers before the Reconnected event fires.
+ // The Math.min at the end is to ensure that the reconnect timeout does not overflow.
+ privateData.reconnectTimeoutId = window.setTimeout(function () { fireReconnected(instance); }, Math.min(1000 * (Math.pow(2, reconnectErrors) - 1), maxFireReconnectedTimeout));
+ }
+ }(connection));
+ }, 250); // Have to delay initial poll so Chrome doesn't show loader spinner in tab
+ },
+
+ lostConnection: function (connection) {
+ if (connection.pollXhr) {
+ connection.pollXhr.abort("lostConnection");
+ }
+ },
+
+ send: function (connection, data) {
+ transportLogic.ajaxSend(connection, data);
+ },
+
+ stop: function (connection) {
+ /// Stops the long polling connection
+ /// The SignalR connection to stop
+
+ window.clearTimeout(connection._.pollTimeoutId);
+ window.clearTimeout(connection._.reconnectTimeoutId);
+
+ delete connection._.pollTimeoutId;
+ delete connection._.reconnectTimeoutId;
+
+ if (connection.pollXhr) {
+ connection.pollXhr.abort();
+ connection.pollXhr = null;
+ delete connection.pollXhr;
+ }
+ },
+
+ abort: function (connection, async) {
+ transportLogic.ajaxAbort(connection, async);
+ }
+ };
+
+}(window.jQuery, window));
+/* jquery.signalR.hubs.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+/*global window:false */
+///
+
+(function ($, window, undefined) {
+
+ var nextGuid = 0;
+ var eventNamespace = ".hubProxy",
+ signalR = $.signalR;
+
+ function makeEventName(event) {
+ return event + eventNamespace;
+ }
+
+ // Equivalent to Array.prototype.map
+ function map(arr, fun, thisp) {
+ var i,
+ length = arr.length,
+ result = [];
+ for (i = 0; i < length; i += 1) {
+ if (arr.hasOwnProperty(i)) {
+ result[i] = fun.call(thisp, arr[i], i, arr);
+ }
+ }
+ return result;
+ }
+
+ function getArgValue(a) {
+ return $.isFunction(a) ? null : ($.type(a) === "undefined" ? null : a);
+ }
+
+ function hasMembers(obj) {
+ for (var key in obj) {
+ // If we have any properties in our callback map then we have callbacks and can exit the loop via return
+ if (obj.hasOwnProperty(key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ function clearInvocationCallbacks(connection, error) {
+ ///
+ var callbacks = connection._.invocationCallbacks,
+ callback;
+
+ if (hasMembers(callbacks)) {
+ connection.log("Clearing hub invocation callbacks with error: " + error + ".");
+ }
+
+ // Reset the callback cache now as we have a local var referencing it
+ connection._.invocationCallbackId = 0;
+ delete connection._.invocationCallbacks;
+ connection._.invocationCallbacks = {};
+
+ // Loop over the callbacks and invoke them.
+ // We do this using a local var reference and *after* we've cleared the cache
+ // so that if a fail callback itself tries to invoke another method we don't
+ // end up with its callback in the list we're looping over.
+ for (var callbackId in callbacks) {
+ callback = callbacks[callbackId];
+ callback.method.call(callback.scope, { E: error });
+ }
+ }
+
+ function isCallbackFromGeneratedHubProxy(callback) {
+ // https://github.com/SignalR/SignalR/issues/4310
+ // The stringified callback from the old generated hub proxy is 137 characters in Edge, Firefox and Chrome.
+ // We slice to avoid wasting too many cycles searching through the text of a long large function.
+ return $.isFunction(callback) && callback.toString().slice(0, 256).indexOf("// Call the client hub method") >= 0;
+ }
+
+ // hubProxy
+ function hubProxy(hubConnection, hubName) {
+ ///
+ /// Creates a new proxy object for the given hub connection that can be used to invoke
+ /// methods on server hubs and handle client method invocation requests from the server.
+ ///
+ return new hubProxy.fn.init(hubConnection, hubName);
+ }
+
+ hubProxy.fn = hubProxy.prototype = {
+ init: function (connection, hubName) {
+ this.state = {};
+ this.connection = connection;
+ this.hubName = hubName;
+ this._ = {
+ callbackMap: {}
+ };
+ },
+
+ constructor: hubProxy,
+
+ hasSubscriptions: function () {
+ return hasMembers(this._.callbackMap);
+ },
+
+ on: function (eventName, callback, callbackIdentity) {
+ /// Wires up a callback to be invoked when a invocation request is received from the server hub.
+ /// The name of the hub event to register the callback for.
+ /// The callback to be invoked.
+ /// An optional object to use as the "identity" for the callback when checking if the handler has already been registered. Defaults to the value of 'callback' if not provided.
+ var that = this,
+ callbackMap = that._.callbackMap,
+ isFromOldGeneratedHubProxy = !callbackIdentity && isCallbackFromGeneratedHubProxy(callback);
+
+ // We need the third "identity" argument because the registerHubProxies call made by signalr/js wraps the user-provided callback in a custom wrapper which breaks the identity comparison.
+ // callbackIdentity allows the caller of `on` to provide a separate object to use as the "identity". `registerHubProxies` uses the original user callback as this identity object.
+ callbackIdentity = callbackIdentity || callback;
+
+ // Assign a global ID to the identity object. This tags the object so we can detect the same object when it comes back.
+ if(!callbackIdentity._signalRGuid) {
+ callbackIdentity._signalRGuid = nextGuid++;
+ }
+
+ // Normalize the event name to lowercase
+ eventName = eventName.toLowerCase();
+
+ // If there is not an event registered for this callback yet we want to create its event space in the callback map.
+ var callbackSpace = callbackMap[eventName];
+ if (!callbackSpace) {
+ callbackSpace = [];
+ callbackMap[eventName] = callbackSpace;
+ }
+
+ // Check if there's already a registration
+ var registration;
+ for (var i = 0; i < callbackSpace.length; i++) {
+ if (callbackSpace[i].guid === callbackIdentity._signalRGuid || (isFromOldGeneratedHubProxy && callbackSpace[i].isFromOldGeneratedHubProxy)) {
+ registration = callbackSpace[i];
+ }
+ }
+
+ // Create a registration if there isn't one already
+ if (!registration) {
+ registration = {
+ guid: callbackIdentity._signalRGuid,
+ eventHandlers: [],
+ isFromOldGeneratedHubProxy: isFromOldGeneratedHubProxy
+ };
+ callbackMap[eventName].push(registration);
+ }
+
+ var handler = function (e, data) {
+ callback.apply(that, data);
+ };
+ registration.eventHandlers.push(handler);
+
+ $(that).bind(makeEventName(eventName), handler);
+
+ return that;
+ },
+
+ off: function (eventName, callback, callbackIdentity) {
+ /// Removes the callback invocation request from the server hub for the given event name.
+ /// The name of the hub event to unregister the callback for.
+ /// The callback to be removed.
+ /// An optional object to use as the "identity" when looking up the callback. Corresponds to the same parameter provided to 'on'. Defaults to the value of 'callback' if not provided.
+ var that = this,
+ callbackMap = that._.callbackMap,
+ callbackSpace,
+ isFromOldGeneratedHubProxy = !callbackIdentity && isCallbackFromGeneratedHubProxy(callback);
+
+ callbackIdentity = callbackIdentity || callback;
+
+ // Normalize the event name to lowercase
+ eventName = eventName.toLowerCase();
+
+ callbackSpace = callbackMap[eventName];
+
+ // Verify that there is an event space to unbind
+ if (callbackSpace) {
+
+ if (callback) {
+ // Find the callback registration
+ var callbackRegistration;
+ var callbackIndex;
+ for (var i = 0; i < callbackSpace.length; i++) {
+ if (callbackSpace[i].guid === callbackIdentity._signalRGuid || (isFromOldGeneratedHubProxy && callbackSpace[i].isFromOldGeneratedHubProxy)) {
+ callbackIndex = i;
+ callbackRegistration = callbackSpace[i];
+ }
+ }
+
+ // Only unbind if there's an event bound with eventName and a callback with the specified callback
+ if (callbackRegistration) {
+ // Unbind all event handlers associated with the registration.
+ for (var j = 0; j < callbackRegistration.eventHandlers.length; j++) {
+ $(that).unbind(makeEventName(eventName), callbackRegistration.eventHandlers[j]);
+ }
+
+ // Remove the registration from the list
+ callbackSpace.splice(i, 1);
+
+ // Check if there are any registrations left, if not we need to destroy it.
+ if (callbackSpace.length === 0) {
+ delete callbackMap[eventName];
+ }
+ }
+ } else if (!callback) { // Check if we're removing the whole event and we didn't error because of an invalid callback
+ $(that).unbind(makeEventName(eventName));
+
+ delete callbackMap[eventName];
+ }
+ }
+
+ return that;
+ },
+
+ invoke: function (methodName) {
+ /// Invokes a server hub method with the given arguments.
+ /// The name of the server hub method.
+
+ var that = this,
+ connection = that.connection,
+ args = $.makeArray(arguments).slice(1),
+ argValues = map(args, getArgValue),
+ data = { H: that.hubName, M: methodName, A: argValues, I: connection._.invocationCallbackId },
+ d = $.Deferred(),
+ callback = function (minResult) {
+ var result = that._maximizeHubResponse(minResult),
+ source,
+ error;
+
+ // Update the hub state
+ $.extend(that.state, result.State);
+
+ if (result.Progress) {
+ if (d.notifyWith) {
+ // Progress is only supported in jQuery 1.7+
+ d.notifyWith(that, [result.Progress.Data]);
+ } else if (!connection._.progressjQueryVersionLogged) {
+ connection.log("A hub method invocation progress update was received but the version of jQuery in use (" + $.prototype.jquery + ") does not support progress updates. Upgrade to jQuery 1.7+ to receive progress notifications.");
+ connection._.progressjQueryVersionLogged = true;
+ }
+ } else if (result.Error) {
+ // Server hub method threw an exception, log it & reject the deferred
+ if (result.StackTrace) {
+ connection.log(result.Error + "\n" + result.StackTrace + ".");
+ }
+
+ // result.ErrorData is only set if a HubException was thrown
+ source = result.IsHubException ? "HubException" : "Exception";
+ error = signalR._.error(result.Error, source);
+ error.data = result.ErrorData;
+
+ connection.log(that.hubName + "." + methodName + " failed to execute. Error: " + error.message);
+ d.rejectWith(that, [error]);
+ } else {
+ // Server invocation succeeded, resolve the deferred
+ connection.log("Invoked " + that.hubName + "." + methodName);
+ d.resolveWith(that, [result.Result]);
+ }
+ };
+
+ connection._.invocationCallbacks[connection._.invocationCallbackId.toString()] = { scope: that, method: callback };
+ connection._.invocationCallbackId += 1;
+
+ if (!$.isEmptyObject(that.state)) {
+ data.S = that.state;
+ }
+
+ connection.log("Invoking " + that.hubName + "." + methodName);
+ connection.send(data);
+
+ return d.promise();
+ },
+
+ _maximizeHubResponse: function (minHubResponse) {
+ return {
+ State: minHubResponse.S,
+ Result: minHubResponse.R,
+ Progress: minHubResponse.P ? {
+ Id: minHubResponse.P.I,
+ Data: minHubResponse.P.D
+ } : null,
+ Id: minHubResponse.I,
+ IsHubException: minHubResponse.H,
+ Error: minHubResponse.E,
+ StackTrace: minHubResponse.T,
+ ErrorData: minHubResponse.D
+ };
+ }
+ };
+
+ hubProxy.fn.init.prototype = hubProxy.fn;
+
+ // hubConnection
+ function hubConnection(url, options) {
+ /// Creates a new hub connection.
+ /// [Optional] The hub route url, defaults to "/signalr".
+ /// [Optional] Settings to use when creating the hubConnection.
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ };
+
+ $.extend(settings, options);
+
+ if (!url || settings.useDefaultPath) {
+ url = (url || "") + "/signalr";
+ }
+ return new hubConnection.fn.init(url, settings);
+ }
+
+ hubConnection.fn = hubConnection.prototype = $.connection();
+
+ hubConnection.fn.init = function (url, options) {
+ var settings = {
+ qs: null,
+ logging: false,
+ useDefaultPath: true
+ },
+ connection = this;
+
+ $.extend(settings, options);
+
+ // Call the base constructor
+ $.signalR.fn.init.call(connection, url, settings.qs, settings.logging);
+
+ // Object to store hub proxies for this connection
+ connection.proxies = {};
+
+ connection._.invocationCallbackId = 0;
+ connection._.invocationCallbacks = {};
+
+ // Wire up the received handler
+ connection.received(function (minData) {
+ var data, proxy, dataCallbackId, callback, hubName, eventName;
+ if (!minData) {
+ return;
+ }
+
+ // We have to handle progress updates first in order to ensure old clients that receive
+ // progress updates enter the return value branch and then no-op when they can't find
+ // the callback in the map (because the minData.I value will not be a valid callback ID)
+ // Process progress notification
+ if (typeof (minData.P) !== "undefined") {
+ dataCallbackId = minData.P.I.toString();
+ callback = connection._.invocationCallbacks[dataCallbackId];
+ if (callback) {
+ callback.method.call(callback.scope, minData);
+ }
+ } else if (typeof (minData.I) !== "undefined") {
+ // We received the return value from a server method invocation, look up callback by id and call it
+ dataCallbackId = minData.I.toString();
+ callback = connection._.invocationCallbacks[dataCallbackId];
+ if (callback) {
+ // Delete the callback from the proxy
+ connection._.invocationCallbacks[dataCallbackId] = null;
+ delete connection._.invocationCallbacks[dataCallbackId];
+
+ // Invoke the callback
+ callback.method.call(callback.scope, minData);
+ }
+ } else {
+ data = this._maximizeClientHubInvocation(minData);
+
+ // We received a client invocation request, i.e. broadcast from server hub
+ connection.log("Triggering client hub event '" + data.Method + "' on hub '" + data.Hub + "'.");
+
+ // Normalize the names to lowercase
+ hubName = data.Hub.toLowerCase();
+ eventName = data.Method.toLowerCase();
+
+ // Trigger the local invocation event
+ proxy = this.proxies[hubName];
+
+ // Update the hub state
+ $.extend(proxy.state, data.State);
+ $(proxy).triggerHandler(makeEventName(eventName), [data.Args]);
+ }
+ });
+
+ connection.error(function (errData, origData) {
+ var callbackId, callback;
+
+ if (!origData) {
+ // No original data passed so this is not a send error
+ return;
+ }
+
+ callbackId = origData.I;
+ callback = connection._.invocationCallbacks[callbackId];
+
+ // Verify that there is a callback bound (could have been cleared)
+ if (callback) {
+ // Delete the callback
+ connection._.invocationCallbacks[callbackId] = null;
+ delete connection._.invocationCallbacks[callbackId];
+
+ // Invoke the callback with an error to reject the promise
+ callback.method.call(callback.scope, { E: errData });
+ }
+ });
+
+ connection.reconnecting(function () {
+ if (connection.transport && connection.transport.name === "webSockets") {
+ clearInvocationCallbacks(connection, "Connection started reconnecting before invocation result was received.");
+ }
+ });
+
+ connection.disconnected(function () {
+ clearInvocationCallbacks(connection, "Connection was disconnected before invocation result was received.");
+ });
+ };
+
+ hubConnection.fn._maximizeClientHubInvocation = function (minClientHubInvocation) {
+ return {
+ Hub: minClientHubInvocation.H,
+ Method: minClientHubInvocation.M,
+ Args: minClientHubInvocation.A,
+ State: minClientHubInvocation.S
+ };
+ };
+
+ hubConnection.fn._registerSubscribedHubs = function () {
+ ///
+ /// Sets the starting event to loop through the known hubs and register any new hubs
+ /// that have been added to the proxy.
+ ///
+ var connection = this;
+
+ if (!connection._subscribedToHubs) {
+ connection._subscribedToHubs = true;
+ connection.starting(function () {
+ // Set the connection's data object with all the hub proxies with active subscriptions.
+ // These proxies will receive notifications from the server.
+ var subscribedHubs = [];
+
+ $.each(connection.proxies, function (key) {
+ if (this.hasSubscriptions()) {
+ subscribedHubs.push({ name: key });
+ connection.log("Client subscribed to hub '" + key + "'.");
+ }
+ });
+
+ if (subscribedHubs.length === 0) {
+ connection.log("No hubs have been subscribed to. The client will not receive data from hubs. To fix, declare at least one client side function prior to connection start for each hub you wish to subscribe to.");
+ }
+
+ connection.data = connection.json.stringify(subscribedHubs);
+ });
+ }
+ };
+
+ hubConnection.fn.createHubProxy = function (hubName) {
+ ///
+ /// Creates a new proxy object for the given hub connection that can be used to invoke
+ /// methods on server hubs and handle client method invocation requests from the server.
+ ///
+ ///
+ /// The name of the hub on the server to create the proxy for.
+ ///
+
+ // Normalize the name to lowercase
+ hubName = hubName.toLowerCase();
+
+ var proxy = this.proxies[hubName];
+ if (!proxy) {
+ proxy = hubProxy(this, hubName);
+ this.proxies[hubName] = proxy;
+ }
+
+ this._registerSubscribedHubs();
+
+ return proxy;
+ };
+
+ hubConnection.fn.init.prototype = hubConnection.fn;
+
+ $.hubConnection = hubConnection;
+
+}(window.jQuery, window));
+/* jquery.signalR.version.js */
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+
+/*global window:false */
+///
+(function ($, undefined) {
+ // This will be modified by the build script
+ $.signalR.version = "2.4.3";
+}(window.jQuery));
\ No newline at end of file
diff --git a/Adaptation/FileHandlers/json/StaticSite/js/time.js b/Adaptation/FileHandlers/json/StaticSite/js/time.js
index 5a4bbd7..a9e6540 100644
--- a/Adaptation/FileHandlers/json/StaticSite/js/time.js
+++ b/Adaptation/FileHandlers/json/StaticSite/js/time.js
@@ -1,22 +1,22 @@
var _apiUrl = null;
function compareFunction(a, b) {
- if (a.TimeCriticality === null || b.TimeCriticality === null) {
+ if (a.TimeCriticality == undefined || b.TimeCriticality == undefined) {
var aPollValue = a.PollValue.split('-');
var bPollValue = b.PollValue.split('-');
- return bPollValue[0].trim() - aPollValue[0].trim() || b.State[0] - a.State[0] || bPollValue[bPollValue.length - 1].trim()[0] - aPollValue[aPollValue.length - 1].trim()[0] || b.ParentId - a.ParentId || a.Id - b.Id;
+ return b.State[0] - a.State[0] || bPollValue[0] - aPollValue[0] || bPollValue[bPollValue.length - 1].trim()[0] - aPollValue[aPollValue.length - 1].trim()[0] || b.ParentId - a.ParentId || a.Id - b.Id;
} else {
return b.TimeCriticality - a.TimeCriticality || b.State[0] - a.State[0] || b.ParentId - a.ParentId || a.Id - b.Id;
}
}
function showOne(rowData) {
- if (rowData == null)
+ if (rowData == undefined)
return;
var data = [];
data.push({ name: "Edit in ADO", value: 'Edit in ADO ' + rowData["Id"] + '' });
for (const property in rowData) {
- if (rowData[property] == null)
+ if (rowData[property] == undefined)
continue;
data.push({ name: property, value: rowData[property].toString() });
}
@@ -30,7 +30,7 @@ function showOne(rowData) {
function loadOne() {
var selectedRow = $("#HeaderGrid").data("igGridSelection").selectedRow();
- if (selectedRow == null)
+ if (selectedRow == undefined)
return;
var rowData = $("#HeaderGrid").data("igGrid").dataSource.dataView()[selectedRow.index];
showOne(rowData);
@@ -45,7 +45,7 @@ function detailSelectionChangedRunInfo(evt, ui) {
function getState(state) {
var result;
- if (state == null)
+ if (state == undefined)
result = "9-Null";
else if (state === "New")
result = `1-${state}`;
@@ -66,7 +66,7 @@ function getPriority(workItemType, priority) {
var result;
if (workItemType === "Bug")
result = "0-Bug";
- else if (priority == null || priority === 0)
+ else if (priority == undefined || priority === 0)
result = "9-Null";
else if (priority === 1)
result = `${priority}-High`;
@@ -81,45 +81,34 @@ function getPriority(workItemType, priority) {
return result;
}
-function getInversePriority(priority) {
+function getPollValue(description, pollValue) {
var result;
- if (priority == null || priority === 0)
- result = "0.000";
- else if (priority === 1)
- result = "3.000";
- else if (priority === 2)
- result = "2.000";
- else if (priority === 3)
- result = "1.000";
+ if (pollValue == undefined || pollValue.TimeCriticality == undefined || pollValue.TimeCriticality.InverseAverage == undefined)
+ result = "";
+ else if (pollValue.TimeCriticality.InverseAverage >= 4)
+ result = `${pollValue.TimeCriticality.InverseAverage} - 1-Highest (Most ${description}) - ${pollValue.Count} Vote(s)`;
+ else if (pollValue.TimeCriticality.InverseAverage >= 3)
+ result = `${pollValue.TimeCriticality.InverseAverage} - 2-High - ${pollValue.Count} Vote(s)`;
+ else if (pollValue.TimeCriticality.InverseAverage >= 2)
+ result = `${pollValue.TimeCriticality.InverseAverage} - 3-Medium - ${pollValue.Count} Vote(s)`;
+ else if (pollValue.TimeCriticality.InverseAverage >= 1)
+ result = `${pollValue.TimeCriticality.InverseAverage} - 4-Low - ${pollValue.Count} Vote(s)`;
+ else if (pollValue.TimeCriticality.InverseAverage >= 0)
+ result = `${pollValue.TimeCriticality.InverseAverage} - 5-Lowest - ${pollValue.Count} Vote(s)`;
else
- result = "0.000";
- return result;
-}
-
-function getPollValue(description, priority, priorityDisplay, pollValue) {
- var result;
- if (pollValue === undefined || pollValue.Records.length === undefined || pollValue.Records.length === 0 || pollValue.Average === null)
- result = getInversePriority(priority) + ' - ' + priorityDisplay + ' - *Priority';
- else if (pollValue.Average > 2)
- result = `${pollValue.Average} - 1-High (Most ${description}) - ${pollValue.Count} Vote(s)`;
- else if (pollValue.Average > 1)
- result = `${pollValue.Average} - 2-Medium - ${pollValue.Count} Vote(s)`;
- else if (pollValue.Average > 0)
- result = `${pollValue.Average} - 3-Low - ${pollValue.Count} Vote(s)`;
- else
- result = getInversePriority(priority) + ' - ' + priorityDisplay + ' - *Priority';
+ result = "";
return result;
}
function updateRecordCoD(workItem) {
- if (workItem !== null) {
- if (workItem.Effort === null)
+ if (workItem != undefined) {
+ if (workItem.Effort == undefined)
workItem.Effort = 10123;
- if (workItem.BusinessValue === null)
+ if (workItem.BusinessValue == undefined)
workItem.BusinessValue = 99999;
- if (workItem.TimeCriticality === null)
+ if (workItem.TimeCriticality == undefined)
workItem.TimeCriticality = 99999;
- if (workItem.RiskReductionMinusOpportunityEnablement === null)
+ if (workItem.RiskReductionMinusOpportunityEnablement == undefined)
workItem.RiskReductionMinusOpportunityEnablement = 99999;
workItem.CoD = workItem.RiskReductionMinusOpportunityEnablement + workItem.TimeCriticality + workItem.BusinessValue;
}
@@ -128,12 +117,12 @@ function updateRecordCoD(workItem) {
function updateRecordOther(workItem, dataB, description) {
workItem["State"] = getState(workItem["State"]);
var priority = getPriority(workItem["WorkItemType"], workItem["Priority"]);
- workItem["PollValue"] = getPollValue(description, workItem["Priority"], priority, dataB[workItem.Id]);
+ workItem["PollValue"] = getPollValue(description, dataB[workItem.Id]);
workItem["Priority"] = priority;
}
function updateRecordParent(parent, workItem) {
- if (parent === null) {
+ if (parent == undefined) {
workItem["ParentId"] = 9999999;
workItem["ParentTitle"] = null;
workItem["ParentState"] = null;
@@ -183,13 +172,47 @@ function sendValue(element, page, id) {
});
}
+function getFibonacciValue(average) {
+ var result;
+ if (average >= 7)
+ result = 34;
+ else if (average >= 6)
+ result = 21;
+ else if (average >= 5)
+ result = 13;
+ else if (average >= 4)
+ result = 8;
+ else if (average >= 3)
+ result = 5;
+ else if (average >= 2)
+ result = 3;
+ else if (average >= 1)
+ result = 2;
+ else if (average >= 0)
+ result = 1;
+ else
+ result = "";
+ return result;
+}
+
+
function setRecords(workItems, page, description, th) {
var record;
- var html = "
Parent Id
Parent Title
Id
Requester
Title
Assigned To
System(s)
State
Value
Up
Down
Poll Value
" + th + "
";
+ var array = [];
+ var count = "";
+ var select = "";
+ var average = "";
+ var fibonacciValue = "";
+ var html = "
Parent Id
Parent Title
Id
Requester
Title
Assigned To
System(s)
State
Value
Poll Average
Fibonacci
Poll Description
Vote(s)
" + th + "
Up
Down
";
const element = document.getElementById("HeaderGrid");
for (var i = 0; i < workItems.length; i++) {
record = workItems[i];
- var length = record.TimeCriticality === null ? "" : record.TimeCriticality.toString().length;
+ array = record.PollValue.split('-')
+ average = array.length > 0 ? array[0] : "";
+ fibonacciValue = getFibonacciValue(average);
+ select = array.length > 2 ? array[1] + '-' + array[2] : "";
+ count = array.length > 3 ? array[3].trim().split(' ')[0] : "";
+ var length = record.TimeCriticality == undefined ? "" : record.TimeCriticality.toString().length;
html += "