Skip to content

Commit

Permalink
Append + Prepend actions
Browse files Browse the repository at this point in the history
  • Loading branch information
trumae committed Feb 8, 2018
1 parent 5975ccb commit 1015b41
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,32 @@ func Remove(ws *websocket.Conn, target string) error {
return errNotImplemented
}

//InsertTop Insert content at the top of target
func InsertTop(ws *websocket.Conn, target, content string) error {
return errNotImplemented
}
//Append concate content at target
func Append(ws *websocket.Conn, target, content string) error {
c := strings.Replace(content, "\n", "\\n", -1)
c = strings.Replace(c, "\"", "\\\"", -1)
js := fmt.Sprintf("$( \"#%s\" ).append(\"%s\");", target, c)

//InsertBottom Insert content at the bottom of target
func InsertBottom(ws *websocket.Conn, target, content string) error {
return errNotImplemented
err := ws.WriteMessage(websocket.TextMessage, []byte(js))
if err != nil {
return err
}
status.Status.SendedBytes += len(js)
return err
}

//InsertBefore Insert content at the before of target
func InsertBefore(ws *websocket.Conn, target, content string) error {
return errNotImplemented
}
//Prepend concate content at the begin of target
func Prepend(ws *websocket.Conn, target, content string) error {
c := strings.Replace(content, "\n", "\\n", -1)
c = strings.Replace(c, "\"", "\\\"", -1)
js := fmt.Sprintf("$( \"#%s\" ).prepend(\"%s\");", target, c)

//InsertAfter Insert content at the after of target
func InsertAfter(ws *websocket.Conn, target, content string) error {
return errNotImplemented
err := ws.WriteMessage(websocket.TextMessage, []byte(js))
if err != nil {
return err
}
status.Status.SendedBytes += len(js)
return err
}

//Redirect to url
Expand Down

0 comments on commit 1015b41

Please sign in to comment.