-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
90 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
export default function requestJson(method: string, url: string, params: object, successCallback, failureCallback) { | ||
method = method.toUpperCase() | ||
|
||
let body = null | ||
if (method === 'GET') { | ||
url = injectQueryStringParams(url, params) | ||
} else { | ||
body = encodeParams(params) | ||
} | ||
|
||
let xhr = new XMLHttpRequest() | ||
xhr.open(method, url, true) | ||
|
||
xhr.onload = function() { | ||
if (xhr.status >= 200 && xhr.status < 400) { | ||
try { | ||
let res = JSON.parse(xhr.responseText) | ||
successCallback(res, xhr) | ||
} catch (err) { | ||
failureCallback('Failure parsing JSON', xhr) | ||
} | ||
} else { | ||
failureCallback('Request failed', xhr) | ||
} | ||
} | ||
|
||
xhr.onerror = function() { | ||
failureCallback('Request failed', xhr) | ||
} | ||
|
||
xhr.send(body) | ||
} | ||
|
||
function injectQueryStringParams(url: string, params) { | ||
return url + | ||
(url.indexOf('?') === -1 ? '?' : '&') + | ||
encodeParams(params) | ||
} | ||
|
||
function encodeParams(params) { | ||
let parts = [] | ||
|
||
for (let key in params) { | ||
parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(params[key])) | ||
} | ||
|
||
return parts.join('&') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
{ | ||
"title": "FullCalendar Google Calendar Plugin", | ||
"dependencies": { | ||
"superagent": "" | ||
} | ||
"title": "FullCalendar Google Calendar Plugin" | ||
} |