Use dot notation instead of subscript for response.
This commit is contained in:
		
							parent
							
								
									68f52271f1
								
							
						
					
					
						commit
						7c4229f1fa
					
				
					 6 changed files with 42 additions and 47 deletions
				
			
		|  | @ -338,9 +338,9 @@ function on_save(ed, edit_element_map, display_element_map) | ||||||
| { | { | ||||||
|     function callback(response) |     function callback(response) | ||||||
|     { |     { | ||||||
|         if (response["meta"]["status"] != 200) |         if (response.meta.status != 200) | ||||||
|         { |         { | ||||||
|             ed.show_error("Status: " + response["meta"]["status"]); |             ed.show_error("Status: " + response.meta.status); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -119,15 +119,15 @@ function on_save(ed, edit_element_map, display_element_map) | ||||||
| { | { | ||||||
|     function callback(response) |     function callback(response) | ||||||
|     { |     { | ||||||
|         if (response["meta"]["status"] != 200) |         if (response.meta.status != 200) | ||||||
|         { |         { | ||||||
|             ed.show_error("Status: " + response["meta"]["status"]); |             ed.show_error("Status: " + response.meta.status); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         ed.save(); |         ed.save(); | ||||||
|         display_element_map["title"].href = response["data"]["url"]; |         display_element_map["title"].href = response.data.url; | ||||||
|         display_element_map["url"].href = response["data"]["url"]; |         display_element_map["url"].href = response.data.url; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     edit_element_map["url"].value = edit_element_map["url"].value.trim(); |     edit_element_map["url"].value = edit_element_map["url"].value.trim(); | ||||||
|  |  | ||||||
|  | @ -194,15 +194,14 @@ function request_more_divs() | ||||||
|     data.append("photo_ids", photo_ids); |     data.append("photo_ids", photo_ids); | ||||||
|     function callback(response) |     function callback(response) | ||||||
|     { |     { | ||||||
|         if (response["meta"]["status"] !== 200) |         if (response.meta.status !== 200) | ||||||
|         { |         { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         response = response["data"]; |  | ||||||
|         var holder = document.getElementById("photo_card_holder"); |         var holder = document.getElementById("photo_card_holder"); | ||||||
|         for (photo_id in response) |         for (photo_id in response.data) | ||||||
|         { |         { | ||||||
|             photo_div = common.html_to_element(response[photo_id]); |             photo_div = common.html_to_element(response.data[photo_id]); | ||||||
|             divs[photo_id] = photo_div; |             divs[photo_id] = photo_div; | ||||||
|             needed.delete(photo_id) |             needed.delete(photo_id) | ||||||
|             holder.appendChild(photo_div); |             holder.appendChild(photo_div); | ||||||
|  | @ -238,20 +237,19 @@ function add_remove_tag(action, tagname) | ||||||
| } | } | ||||||
| function add_remove_tag_callback(response) | function add_remove_tag_callback(response) | ||||||
| { | { | ||||||
|     response = response["data"]; |     var tagname = response.data.tagname; | ||||||
|     var tagname = response["tagname"]; |  | ||||||
|     var message_area = document.getElementById("message_area"); |     var message_area = document.getElementById("message_area"); | ||||||
|     var message_positivity; |     var message_positivity; | ||||||
|     var message_text; |     var message_text; | ||||||
| 
 | 
 | ||||||
|     if ("error_type" in response) |     if ("error_type" in response.data) | ||||||
|     { |     { | ||||||
|         message_positivity = "message_negative"; |         message_positivity = "message_negative"; | ||||||
|         message_text = response["error_message"]; |         message_text = response.data.error_message; | ||||||
|     } |     } | ||||||
|     else if ("action" in response) |     else if ("action" in response.data) | ||||||
|     { |     { | ||||||
|         var action = response["action"]; |         var action = response.data.action; | ||||||
|         message_positivity = "message_positive"; |         message_positivity = "message_positive"; | ||||||
|         if (action == "add") |         if (action == "add") | ||||||
|         {message_text = "Added tag " + tagname;} |         {message_text = "Added tag " + tagname;} | ||||||
|  | @ -286,7 +284,7 @@ function remove_tag_form() | ||||||
| 
 | 
 | ||||||
| function download_zip_callback(response) | function download_zip_callback(response) | ||||||
| { | { | ||||||
|     var zip_token = response["data"]["zip_token"]; |     var zip_token = response.data.zip_token; | ||||||
|     var url = `/batch/photos/download_zip/${zip_token}.zip`; |     var url = `/batch/photos/download_zip/${zip_token}.zip`; | ||||||
|     window.location.href = url; |     window.location.href = url; | ||||||
| } | } | ||||||
|  | @ -308,13 +306,12 @@ var refresh_metadata_button = document.getElementById("refresh_metadata_button") | ||||||
| 
 | 
 | ||||||
| function refresh_metadata_callback(response) | function refresh_metadata_callback(response) | ||||||
| { | { | ||||||
|     response = response["data"]; |  | ||||||
|     window[refresh_metadata_button.dataset.spinnerCloser](); |     window[refresh_metadata_button.dataset.spinnerCloser](); | ||||||
|     if ("error_type" in response) |     if ("error_type" in response.data) | ||||||
|     { |     { | ||||||
|         var message_area = document.getElementById("message_area"); |         var message_area = document.getElementById("message_area"); | ||||||
|         var message_positivity = "message_negative"; |         var message_positivity = "message_negative"; | ||||||
|         var message_text = response["error_message"]; |         var message_text = response.data.error_message; | ||||||
|         common.create_message_bubble(message_area, message_positivity, message_text, 8000); |         common.create_message_bubble(message_area, message_positivity, message_text, 8000); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|  | @ -342,14 +339,13 @@ function refresh_metadata_form() | ||||||
| 
 | 
 | ||||||
| function set_unset_searchhidden_callback(response) | function set_unset_searchhidden_callback(response) | ||||||
| { | { | ||||||
|     response = response["data"]; |  | ||||||
|     var message_area = document.getElementById("message_area"); |     var message_area = document.getElementById("message_area"); | ||||||
|     var message_positivity; |     var message_positivity; | ||||||
|     var message_text; |     var message_text; | ||||||
|     if ("error_type" in response) |     if ("error_type" in response.data) | ||||||
|     { |     { | ||||||
|         message_positivity = "message_negative"; |         message_positivity = "message_negative"; | ||||||
|         message_text = response["error_message"]; |         message_text = response.data.error_message; | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|  |  | ||||||
|  | @ -118,10 +118,9 @@ function register_form(event) | ||||||
| 
 | 
 | ||||||
| function login_register_callback(response) | function login_register_callback(response) | ||||||
| { | { | ||||||
|     response = response["data"]; |     if ("error_type" in response.data) | ||||||
|     if ("error_type" in response) |  | ||||||
|     { |     { | ||||||
|         common.create_message_bubble(message_area, "message_negative", response["error_message"]); |         common.create_message_bubble(message_area, "message_negative", response.data.error_message); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|  |  | ||||||
|  | @ -302,21 +302,21 @@ function add_remove_photo_tag_callback(response) | ||||||
| { | { | ||||||
|     var message_text; |     var message_text; | ||||||
|     var message_positivity; |     var message_positivity; | ||||||
|     var tagname = response["data"]["tagname"]; |     var tagname = response.data.tagname; | ||||||
|     if ("error_type" in response["data"]) |     if ("error_type" in response.data) | ||||||
|     { |     { | ||||||
|         message_positivity = "message_negative"; |         message_positivity = "message_negative"; | ||||||
|         message_text = response["data"]["error_message"]; |         message_text = response.data.error_message; | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         var action; |         var action; | ||||||
|         message_positivity = "message_positive"; |         message_positivity = "message_positive"; | ||||||
|         if (response["meta"]["request_url"].includes("add_tag")) |         if (response.meta.request_url.includes("add_tag")) | ||||||
|         { |         { | ||||||
|             message_text = "Added tag " + tagname; |             message_text = "Added tag " + tagname; | ||||||
|         } |         } | ||||||
|         else if (response["meta"]["request_url"].includes("remove_tag")) |         else if (response.meta.request_url.includes("remove_tag")) | ||||||
|         { |         { | ||||||
|             message_text = "Removed tag " + tagname; |             message_text = "Removed tag " + tagname; | ||||||
|         } |         } | ||||||
|  | @ -330,13 +330,13 @@ function add_remove_photo_tag_callback(response) | ||||||
| 
 | 
 | ||||||
| function generate_thumbnail_callback(response) | function generate_thumbnail_callback(response) | ||||||
| { | { | ||||||
|     if (response["meta"]["status"] == 200) |     if (response.meta.status == 200) | ||||||
|     { |     { | ||||||
|         common.create_message_bubble(message_area, "message_positive", "Thumbnail captured", 8000); |         common.create_message_bubble(message_area, "message_positive", "Thumbnail captured", 8000); | ||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         common.create_message_bubble(message_area, "message_negative", response["data"]["error_message"], 8000); |         common.create_message_bubble(message_area, "message_negative", response.data.error_message, 8000); | ||||||
|     } |     } | ||||||
|     generate_thumbnail_button = document.getElementById("generate_thumbnail_button"); |     generate_thumbnail_button = document.getElementById("generate_thumbnail_button"); | ||||||
|     window[generate_thumbnail_button.dataset.spinnerCloser](); |     window[generate_thumbnail_button.dataset.spinnerCloser](); | ||||||
|  |  | ||||||
|  | @ -246,25 +246,25 @@ function easybake_form() | ||||||
| 
 | 
 | ||||||
| function tag_action_callback(response) | function tag_action_callback(response) | ||||||
| { | { | ||||||
|     responses = response["data"]; |     datas = response.data; | ||||||
|     if (!(responses instanceof Array)) |     if (!(datas instanceof Array)) | ||||||
|     { |     { | ||||||
|         responses = [responses]; |         datas = [datas]; | ||||||
|     } |     } | ||||||
|     for (var index = 0; index < responses.length; index += 1) |     for (var index = 0; index < datas.length; index += 1) | ||||||
|     { |     { | ||||||
|         var response = responses[index]; |         var data = datas[index]; | ||||||
|         var tagname = response["tagname"]; |         var tagname = data.tagname; | ||||||
|         var message_positivity; |         var message_positivity; | ||||||
|         var message_text; |         var message_text; | ||||||
|         if ("error_type" in response) |         if ("error_type" in data) | ||||||
|         { |         { | ||||||
|             message_positivity = "message_negative"; |             message_positivity = "message_negative"; | ||||||
|             message_text = response["error_message"]; |             message_text = data.error_message; | ||||||
|         } |         } | ||||||
|         else if ("action" in response) |         else if ("action" in data) | ||||||
|         { |         { | ||||||
|             var action = response["action"]; |             var action = data.action; | ||||||
|             message_positivity = "message_positive"; |             message_positivity = "message_positive"; | ||||||
|             if (action == "new_tag") |             if (action == "new_tag") | ||||||
|             {message_text = `Created tag ${tagname}`;} |             {message_text = `Created tag ${tagname}`;} | ||||||
|  | @ -285,7 +285,7 @@ function tag_action_callback(response) | ||||||
|             {message_text = `Deleted tag ${tagname}`;} |             {message_text = `Deleted tag ${tagname}`;} | ||||||
| 
 | 
 | ||||||
|             else if (action == "delete_synonym") |             else if (action == "delete_synonym") | ||||||
|             {message_text = `Deleted synonym ${response["synonym"]}`;} |             {message_text = `Deleted synonym ${data.synonym}`;} | ||||||
| 
 | 
 | ||||||
|             else if (action == "remove_child") |             else if (action == "remove_child") | ||||||
|             {message_text = `Unlinked tags ${tagname}`;} |             {message_text = `Unlinked tags ${tagname}`;} | ||||||
|  | @ -308,10 +308,10 @@ function on_save(ed, edit_element_map, display_element_map) | ||||||
|     { |     { | ||||||
|         console.log(response); |         console.log(response); | ||||||
|         ed.hide_spinner(); |         ed.hide_spinner(); | ||||||
|         if (response["meta"]["status"] == 200) |         if (response.meta.status == 200) | ||||||
|         { |         { | ||||||
|             var new_name = response["data"]["name"]; |             var new_name = response.data.name; | ||||||
|             var new_description = response["data"]["description"]; |             var new_description = response.data.description; | ||||||
|             document.title = new_name + " | Tags"; |             document.title = new_name + " | Tags"; | ||||||
|             window.history.replaceState(null, null, "/tag/" + new_name); |             window.history.replaceState(null, null, "/tag/" + new_name); | ||||||
|             name_editor.value = new_name; |             name_editor.value = new_name; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue