mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
Switching from $.parseJSON to JSON.parse.
There are no modern browsers that do not have built in JSON parsing abilities. We do not need $.parseJSON as it now just serves as a call to JSON.parse.
This commit is contained in:
committed by
Tim Abbott
parent
636d2df868
commit
e52d618f1b
@@ -119,7 +119,7 @@ function make_stream_default(stream_name) {
|
||||
error: function (xhr, error_type) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
$(".active_stream_row button").closest("td").html(
|
||||
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg));
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg));
|
||||
} else {
|
||||
$(".active_stream_row button").text("Failed!");
|
||||
}
|
||||
@@ -248,7 +248,7 @@ function _setup_page() {
|
||||
error: function (xhr, error_type) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
$(".active_default_stream_row button").closest("td").html(
|
||||
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg));
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg));
|
||||
} else {
|
||||
$(".active_default_stream_row button").text("Failed!");
|
||||
}
|
||||
@@ -294,7 +294,7 @@ function _setup_page() {
|
||||
error: function (xhr, error_type) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
row.find("button").closest("td").html(
|
||||
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
|
||||
);
|
||||
} else {
|
||||
row.find("button").text("Failed!");
|
||||
@@ -328,7 +328,7 @@ function _setup_page() {
|
||||
var button = row.find("button");
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
button.closest("td").html(
|
||||
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
|
||||
);
|
||||
} else {
|
||||
button.text(i18n.t("Failed!"));
|
||||
@@ -566,7 +566,7 @@ function _setup_page() {
|
||||
error: function (xhr, error_type) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
row.find("button").closest("td").html(
|
||||
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
|
||||
);
|
||||
} else {
|
||||
row.find("button").text("Failed!");
|
||||
@@ -599,7 +599,7 @@ function _setup_page() {
|
||||
error: function (xhr, error_type) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
$(".active_stream_row button").closest("td").html(
|
||||
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
|
||||
);
|
||||
} else {
|
||||
$(".active_stream_row button").text("Failed!");
|
||||
@@ -622,7 +622,7 @@ function _setup_page() {
|
||||
error: function (xhr, error_type) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
btn.closest("td").html(
|
||||
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
|
||||
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
|
||||
);
|
||||
} else {
|
||||
btn.text("Failed!");
|
||||
@@ -654,7 +654,7 @@ function _setup_page() {
|
||||
},
|
||||
error: function (xhr, error) {
|
||||
$('#admin-emoji-status, #admin-emoji-name-status, #admin-emoji-url-status').hide();
|
||||
var errors = $.parseJSON(xhr.responseText).msg;
|
||||
var errors = JSON.parse(xhr.responseText).msg;
|
||||
if (errors.name !== undefined) {
|
||||
xhr.responseText = JSON.stringify({msg: errors.name});
|
||||
ui.report_error(i18n.t("Failed!"), xhr, emoji_name_status);
|
||||
|
||||
@@ -34,7 +34,7 @@ function call(args, idempotent) {
|
||||
|
||||
if (xhr.status === 403) {
|
||||
try {
|
||||
if ($.parseJSON(xhr.responseText).msg.indexOf("CSRF Error:") !== -1) {
|
||||
if (JSON.parse(xhr.responseText).msg.indexOf("CSRF Error:") !== -1) {
|
||||
reload.initiate({immediate: true,
|
||||
save_pointer: true,
|
||||
save_narrow: true,
|
||||
@@ -117,7 +117,7 @@ exports.xhr_error_message = function (message, xhr) {
|
||||
if (xhr.status.toString().charAt(0) === "4") {
|
||||
// Only display the error response for 4XX, where we've crafted
|
||||
// a nice response.
|
||||
message += ": " + $.parseJSON(xhr.responseText).msg;
|
||||
message += ": " + JSON.parse(xhr.responseText).msg;
|
||||
}
|
||||
return message;
|
||||
};
|
||||
|
||||
@@ -79,7 +79,7 @@ exports.initialize = function () {
|
||||
},
|
||||
error: function (xhr, error_type, xhn) {
|
||||
$('#submit-invitation').button('reset');
|
||||
var arr = $.parseJSON(xhr.responseText);
|
||||
var arr = JSON.parse(xhr.responseText);
|
||||
if (arr.errors === undefined) {
|
||||
// There was a fatal error, no partial processing occurred.
|
||||
invite_status.text(arr.msg)
|
||||
|
||||
@@ -347,8 +347,8 @@ function get_events(options) {
|
||||
// Tornado cache or if we're old enough that our message
|
||||
// queue has been garbage collected, immediately reload.
|
||||
if ((xhr.status === 400) &&
|
||||
($.parseJSON(xhr.responseText).msg.indexOf("too old") !== -1 ||
|
||||
$.parseJSON(xhr.responseText).msg.indexOf("Bad event queue id") !== -1)) {
|
||||
(JSON.parse(xhr.responseText).msg.indexOf("too old") !== -1 ||
|
||||
JSON.parse(xhr.responseText).msg.indexOf("Bad event queue id") !== -1)) {
|
||||
page_params.event_queue_expired = true;
|
||||
reload.initiate({immediate: true,
|
||||
save_pointer: false,
|
||||
|
||||
@@ -255,7 +255,7 @@ function _setup_page() {
|
||||
|
||||
function update_notification_settings_success(resp, statusText, xhr, form) {
|
||||
var message = "Updated notification settings!";
|
||||
var result = $.parseJSON(xhr.responseText);
|
||||
var result = JSON.parse(xhr.responseText);
|
||||
var notify_settings_status = $('#notify-settings-status').expectOne();
|
||||
|
||||
// Stream notification settings.
|
||||
@@ -457,7 +457,7 @@ function _setup_page() {
|
||||
dataType: 'json', // This seems to be ignored. We still get back an xhr.
|
||||
success: function (resp, statusText, xhr, form) {
|
||||
var message = "Updated settings!";
|
||||
var result = $.parseJSON(xhr.responseText);
|
||||
var result = JSON.parse(xhr.responseText);
|
||||
var settings_status = $('#settings-status').expectOne();
|
||||
|
||||
$("#get_api_key_password").val("");
|
||||
@@ -707,7 +707,7 @@ function _setup_page() {
|
||||
data: labs_updates,
|
||||
success: function (resp, statusText, xhr, form) {
|
||||
var message = i18n.t("Updated __product_name__ Labs settings!", page_params);
|
||||
var result = $.parseJSON(xhr.responseText);
|
||||
var result = JSON.parse(xhr.responseText);
|
||||
var ui_settings_status = $('#ui-settings-status').expectOne();
|
||||
|
||||
if (result.autoscroll_forever !== undefined) {
|
||||
|
||||
@@ -602,7 +602,7 @@ function ajaxSubscribe(stream) {
|
||||
success: function (resp, statusText, xhr, form) {
|
||||
$("#create_stream_name").val("");
|
||||
|
||||
var res = $.parseJSON(xhr.responseText);
|
||||
var res = JSON.parse(xhr.responseText);
|
||||
if (!$.isEmptyObject(res.already_subscribed)) {
|
||||
// Display the canonical stream capitalization.
|
||||
true_stream_name = res.already_subscribed[page_params.email][0];
|
||||
@@ -623,7 +623,7 @@ function ajaxUnsubscribe(stream) {
|
||||
url: "/json/subscriptions/remove",
|
||||
data: {"subscriptions": JSON.stringify([stream]) },
|
||||
success: function (resp, statusText, xhr, form) {
|
||||
var name, res = $.parseJSON(xhr.responseText);
|
||||
var name, res = JSON.parse(xhr.responseText);
|
||||
$("#subscriptions-status").hide();
|
||||
// The rest of the work is done via the unsubscribe event we will get
|
||||
},
|
||||
|
||||
@@ -160,7 +160,7 @@ exports.report_error = function (response, xhr, status_box, type) {
|
||||
if (xhr && xhr.status.toString().charAt(0) === "4") {
|
||||
// Only display the error response for 4XX, where we've crafted
|
||||
// a nice response.
|
||||
response += ": " + $.parseJSON(xhr.responseText).msg;
|
||||
response += ": " + JSON.parse(xhr.responseText).msg;
|
||||
}
|
||||
|
||||
ui.report_message(response, status_box, 'alert-error', type);
|
||||
|
||||
Reference in New Issue
Block a user