Skip to content

Commit

Permalink
att
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusmoutinho committed Aug 30, 2024
1 parent 75062de commit f0f13e0
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 28 deletions.
37 changes: 16 additions & 21 deletions bin/hydration/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ let private_cweb_actions_handlers = {
set_session_storage: function (data) {
sessionStorage.setItem(data["key"], data["value"]);
},
remove_session_storage_data: function (data) {
sessionStorage.removeItem(data["key"]);
},
add_cookie_with_time: function (data) {
let expires = "";
if (data.days) {
Expand Down Expand Up @@ -85,40 +88,32 @@ let private_cweb_actions_handlers = {
add_class_by_query_selector: function (data) {
let element = document.querySelector(data.query_selector);
if (!element) {
return;
return;
}
element.classList.add(data.class_name);
},

remove_class_by_query_selector: function (data) {
let element = document.querySelector(data.query_selector);
if (!element) {
return;
return;
}
element.classList.remove(data.class_name);
},


add_class_by_id: function (data) {
let element = document.getElementById(data.id);
if (!element) {
return;
}
element.classList.add(data.class_name);
let element = document.getElementById(data.id);
if (!element) {
return;
}
element.classList.add(data.class_name);
},

remove_class_by_id: function (data) {
let element = document.getElementById(data.id);
if (!element) {
return;
}
element.classList.remove(data.class_name);
}

let element = document.getElementById(data.id);
if (!element) {
return;
}
element.classList.remove(data.class_name);
},
};






9 changes: 7 additions & 2 deletions src/functions/hydratation/bridge/action/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ void CWebHyDrationBridge_set_session_storage_data(
privateCWebHyDrationBridge_add_response(self,"set_session_storage",obj);
}

void CWebHyDrationBridge_remove_session_storage_data(CWebHyDrationBridge *self,const char*key){
cJSON *obj = cJSON_CreateObject();
cJSON_AddStringToObject(obj,CWEB_HYDRATON_JSON_KEY, key);
privateCWebHyDrationBridge_add_response(self,"remove_session_storage_data",obj);
}


void CWebHyDrationBridge_alert(CWebHyDrationBridge *self,const char *menssage,...){
if(CWebHyDrationBridge_has_errors(self)){
return ;
Expand Down Expand Up @@ -387,5 +394,3 @@ void CWebHyDrationBridge_add_class_by_query_selector(CWebHyDrationBridge *self,
privateCWebHyDrationBridge_add_response(self, "add_class_by_id", obj);
free(menssage_formated);
}


6 changes: 2 additions & 4 deletions src/functions/hydratation/bridge/action/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ void privateCWebHyDrationBridge_add_response(CWebHyDrationBridge *self,const cha

void CWebHyDrationBridge_set_session_storage_data(CWebHyDrationBridge *self,const char*key, const char *value,...);

void CWebHyDrationBridge_remove_session_storage_data(CWebHyDrationBridge *self,const char*key);

void CWebHyDrationBridge_alert(CWebHyDrationBridge *self,const char *menssage,...);

void CWebHyDrationBridge_execute_script(CWebHyDrationBridge *self,const char *code,...);
Expand Down Expand Up @@ -78,7 +80,3 @@ void CWebHyDrationBridge_remove_class_by_id(CWebHyDrationBridge *self, const cha
void CWebHyDrationBridge_add_class_by_id(CWebHyDrationBridge *self, const char *id, const char *class_name, ...);
void CWebHyDrationBridge_remove_class_by_query_selector(CWebHyDrationBridge *self, const char *element, const char *class_name, ...);
void CWebHyDrationBridge_add_class_by_query_selector(CWebHyDrationBridge *self, const char *element, const char *class_name, ...);




2 changes: 2 additions & 0 deletions src/functions/namespace/hydratation_module/actions/actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
CWebHydrationActionsNamespace newCWebHydrationActionsNamespace(){
CWebHydrationActionsNamespace self ={0};


self.replace_element_by_query_selector = CWebHyDrationBridge_replace_element_by_query_selector;
self.append_by_query_selector = CWebHyDrationBridge_append_by_query_selector;
self.destroy_by_query_selector = CWebHyDrationBridge_destroy_by_query_selector;
self.remove_session_storage_data = CWebHyDrationBridge_remove_session_storage_data;
self.hide_element_by_query_selector = CWebHyDrationBridge_hide_element_by_query_selector;
self.unhide_element_by_query_selector= CWebHyDrationBridge_unhide_element_by_query_selector;
self.hide_element_by_id = CWebHyDrationBridge_hide_element_by_id;
Expand Down
2 changes: 1 addition & 1 deletion src/globals/hydration.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/types/namespace/hydration/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ typedef struct CWebHydrationResponseNamespace {
const char *code,
...
);
void (*remove_session_storage_data)(CWebHyDrationBridge *self,const char*key);

void (*append_by_query_selector)(
CWebHyDrationBridge *self,
Expand Down

0 comments on commit f0f13e0

Please sign in to comment.