id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
152,400
bobbytables/slacker
rtm_publishable_events.go
init
func init() { snowflake, err := gosnow.Default() if err != nil { panic(err) } sf = snowflake }
go
func init() { snowflake, err := gosnow.Default() if err != nil { panic(err) } sf = snowflake }
[ "func", "init", "(", ")", "{", "snowflake", ",", "err", ":=", "gosnow", ".", "Default", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "sf", "=", "snowflake", "\n", "}" ]
// Some events pushed to Slack require an ID that is always incrementing, // the Snowflake ID generator is perfect for this.
[ "Some", "events", "pushed", "to", "Slack", "require", "an", "ID", "that", "is", "always", "incrementing", "the", "Snowflake", "ID", "generator", "is", "perfect", "for", "this", "." ]
0a05912e400e9aacca7296855ba9fb874cdf34c5
https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/rtm_publishable_events.go#L13-L20
152,401
bobbytables/slacker
rtm_publishable_events.go
Publishable
func (e RTMMessage) Publishable() ([]byte, error) { nextID, err := sf.Next() if err != nil { return nil, err } e.ID = nextID e.Type = "message" return json.Marshal(e) }
go
func (e RTMMessage) Publishable() ([]byte, error) { nextID, err := sf.Next() if err != nil { return nil, err } e.ID = nextID e.Type = "message" return json.Marshal(e) }
[ "func", "(", "e", "RTMMessage", ")", "Publishable", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "nextID", ",", "err", ":=", "sf", ".", "Next", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// Publishable implements Publishable
[ "Publishable", "implements", "Publishable" ]
0a05912e400e9aacca7296855ba9fb874cdf34c5
https://github.com/bobbytables/slacker/blob/0a05912e400e9aacca7296855ba9fb874cdf34c5/rtm_publishable_events.go#L23-L33
152,402
vburenin/nsync
sync_flag.go
Set
func (bf *SyncFlag) Set() { bf.Lock() atomic.StoreInt32(&bf.flag, 1) bf.Unlock() }
go
func (bf *SyncFlag) Set() { bf.Lock() atomic.StoreInt32(&bf.flag, 1) bf.Unlock() }
[ "func", "(", "bf", "*", "SyncFlag", ")", "Set", "(", ")", "{", "bf", ".", "Lock", "(", ")", "\n", "atomic", ".", "StoreInt32", "(", "&", "bf", ".", "flag", ",", "1", ")", "\n", "bf", ".", "Unlock", "(", ")", "\n", "}" ]
// Set locks the mutex, sets the flag and unlocks the mutex.
[ "Set", "locks", "the", "mutex", "sets", "the", "flag", "and", "unlocks", "the", "mutex", "." ]
9a75d1c80410815ac45d65fc01ccabac9c98dd4a
https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/sync_flag.go#L18-L22
152,403
vburenin/nsync
sync_flag.go
Unset
func (bf *SyncFlag) Unset() { bf.Lock() atomic.StoreInt32(&bf.flag, 0) bf.Unlock() }
go
func (bf *SyncFlag) Unset() { bf.Lock() atomic.StoreInt32(&bf.flag, 0) bf.Unlock() }
[ "func", "(", "bf", "*", "SyncFlag", ")", "Unset", "(", ")", "{", "bf", ".", "Lock", "(", ")", "\n", "atomic", ".", "StoreInt32", "(", "&", "bf", ".", "flag", ",", "0", ")", "\n", "bf", ".", "Unlock", "(", ")", "\n", "}" ]
// Set locks the mutex, reset the flag and unlocks the mutex.
[ "Set", "locks", "the", "mutex", "reset", "the", "flag", "and", "unlocks", "the", "mutex", "." ]
9a75d1c80410815ac45d65fc01ccabac9c98dd4a
https://github.com/vburenin/nsync/blob/9a75d1c80410815ac45d65fc01ccabac9c98dd4a/sync_flag.go#L25-L29
152,404
drone/go-github
github/contents.go
FindRef
func (r *ContentResource) FindRef(owner, repo, path, ref string) (*Content, error) { content := Content{} url_path := fmt.Sprintf("/repos/%s/%s/contents/%s?ref=%s", owner, repo, path, ref) if err := r.client.do("GET", url_path, nil, &content); err != nil { return nil, err } return &content, nil }
go
func (r *ContentResource) FindRef(owner, repo, path, ref string) (*Content, error) { content := Content{} url_path := fmt.Sprintf("/repos/%s/%s/contents/%s?ref=%s", owner, repo, path, ref) if err := r.client.do("GET", url_path, nil, &content); err != nil { return nil, err } return &content, nil }
[ "func", "(", "r", "*", "ContentResource", ")", "FindRef", "(", "owner", ",", "repo", ",", "path", ",", "ref", "string", ")", "(", "*", "Content", ",", "error", ")", "{", "content", ":=", "Content", "{", "}", "\n", "url_path", ":=", "fmt", ".", "Spr...
// This method returns the contents of a file or directory in a repository.
[ "This", "method", "returns", "the", "contents", "of", "a", "file", "or", "directory", "in", "a", "repository", "." ]
323fe992f17d4e42a048c8406b034863c925cbdc
https://github.com/drone/go-github/blob/323fe992f17d4e42a048c8406b034863c925cbdc/github/contents.go#L40-L48
152,405
wirepair/autogcd
autogcd.go
NewAutoGcd
func NewAutoGcd(settings *Settings) *AutoGcd { auto := &AutoGcd{settings: settings} auto.tabLock = &sync.RWMutex{} auto.tabs = make(map[string]*Tab) auto.debugger = gcd.NewChromeDebugger() auto.debugger.SetTerminationHandler(auto.defaultTerminationHandler) if len(settings.extensions) > 0 { auto.debugger.AddFlags(settings.extensions) } if len(settings.flags) > 0 { auto.debugger.AddFlags(settings.flags) } if settings.timeout > 0 { auto.debugger.SetTimeout(settings.timeout) } if len(settings.env) > 0 { auto.debugger.AddEnvironmentVars(settings.env) } return auto }
go
func NewAutoGcd(settings *Settings) *AutoGcd { auto := &AutoGcd{settings: settings} auto.tabLock = &sync.RWMutex{} auto.tabs = make(map[string]*Tab) auto.debugger = gcd.NewChromeDebugger() auto.debugger.SetTerminationHandler(auto.defaultTerminationHandler) if len(settings.extensions) > 0 { auto.debugger.AddFlags(settings.extensions) } if len(settings.flags) > 0 { auto.debugger.AddFlags(settings.flags) } if settings.timeout > 0 { auto.debugger.SetTimeout(settings.timeout) } if len(settings.env) > 0 { auto.debugger.AddEnvironmentVars(settings.env) } return auto }
[ "func", "NewAutoGcd", "(", "settings", "*", "Settings", ")", "*", "AutoGcd", "{", "auto", ":=", "&", "AutoGcd", "{", "settings", ":", "settings", "}", "\n", "auto", ".", "tabLock", "=", "&", "sync", ".", "RWMutex", "{", "}", "\n", "auto", ".", "tabs"...
// Creates a new AutoGcd based off the provided settings.
[ "Creates", "a", "new", "AutoGcd", "based", "off", "the", "provided", "settings", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L67-L89
152,406
wirepair/autogcd
autogcd.go
SetTerminationHandler
func (auto *AutoGcd) SetTerminationHandler(handler gcd.TerminatedHandler) { auto.debugger.SetTerminationHandler(handler) }
go
func (auto *AutoGcd) SetTerminationHandler(handler gcd.TerminatedHandler) { auto.debugger.SetTerminationHandler(handler) }
[ "func", "(", "auto", "*", "AutoGcd", ")", "SetTerminationHandler", "(", "handler", "gcd", ".", "TerminatedHandler", ")", "{", "auto", ".", "debugger", ".", "SetTerminationHandler", "(", "handler", ")", "\n", "}" ]
// Allow callers to handle chrome terminating.
[ "Allow", "callers", "to", "handle", "chrome", "terminating", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L97-L99
152,407
wirepair/autogcd
autogcd.go
Start
func (auto *AutoGcd) Start() error { if auto.settings.connectToInstance { auto.debugger.ConnectToInstance(auto.settings.chromeHost, auto.settings.chromePort) } else { auto.debugger.StartProcess(auto.settings.chromePath, auto.settings.userDir, auto.settings.chromePort) } tabs, err := auto.debugger.GetTargets() if err != nil { return err } auto.tabLock.Lock() for _, tab := range tabs { t, err := open(tab) if err != nil { return err } auto.tabs[tab.Target.Id] = t } auto.tabLock.Unlock() return nil }
go
func (auto *AutoGcd) Start() error { if auto.settings.connectToInstance { auto.debugger.ConnectToInstance(auto.settings.chromeHost, auto.settings.chromePort) } else { auto.debugger.StartProcess(auto.settings.chromePath, auto.settings.userDir, auto.settings.chromePort) } tabs, err := auto.debugger.GetTargets() if err != nil { return err } auto.tabLock.Lock() for _, tab := range tabs { t, err := open(tab) if err != nil { return err } auto.tabs[tab.Target.Id] = t } auto.tabLock.Unlock() return nil }
[ "func", "(", "auto", "*", "AutoGcd", ")", "Start", "(", ")", "error", "{", "if", "auto", ".", "settings", ".", "connectToInstance", "{", "auto", ".", "debugger", ".", "ConnectToInstance", "(", "auto", ".", "settings", ".", "chromeHost", ",", "auto", ".",...
// Starts Google Chrome with debugging enabled.
[ "Starts", "Google", "Chrome", "with", "debugging", "enabled", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L102-L123
152,408
wirepair/autogcd
autogcd.go
Shutdown
func (auto *AutoGcd) Shutdown() error { if auto.shutdown { return errors.New("AutoGcd already shut down.") } auto.tabLock.Lock() for _, tab := range auto.tabs { tab.close() // exit go routines auto.debugger.CloseTab(tab.ChromeTarget) } auto.tabLock.Unlock() if !auto.settings.connectToInstance { err := auto.debugger.ExitProcess() if auto.settings.removeUserDir == true { return os.RemoveAll(auto.settings.userDir) } return err } auto.shutdown = true return nil }
go
func (auto *AutoGcd) Shutdown() error { if auto.shutdown { return errors.New("AutoGcd already shut down.") } auto.tabLock.Lock() for _, tab := range auto.tabs { tab.close() // exit go routines auto.debugger.CloseTab(tab.ChromeTarget) } auto.tabLock.Unlock() if !auto.settings.connectToInstance { err := auto.debugger.ExitProcess() if auto.settings.removeUserDir == true { return os.RemoveAll(auto.settings.userDir) } return err } auto.shutdown = true return nil }
[ "func", "(", "auto", "*", "AutoGcd", ")", "Shutdown", "(", ")", "error", "{", "if", "auto", ".", "shutdown", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n\n", "auto", ".", "tabLock", ".", "Lock", "(", ")", "\n", "for",...
// Closes all tabs and shuts down the browser.
[ "Closes", "all", "tabs", "and", "shuts", "down", "the", "browser", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L126-L149
152,409
wirepair/autogcd
autogcd.go
RefreshTabList
func (auto *AutoGcd) RefreshTabList() (map[string]*Tab, error) { knownTabs := auto.GetAllTabs() knownIds := make(map[string]struct{}, len(knownTabs)) for _, v := range knownTabs { knownIds[v.Target.Id] = struct{}{} } newTabs, err := auto.debugger.GetNewTargets(knownIds) if err != nil { return nil, err } auto.tabLock.Lock() for _, newTab := range newTabs { t, err := open(newTab) if err != nil { return nil, err } auto.tabs[newTab.Target.Id] = t } auto.tabLock.Unlock() return auto.GetAllTabs(), nil }
go
func (auto *AutoGcd) RefreshTabList() (map[string]*Tab, error) { knownTabs := auto.GetAllTabs() knownIds := make(map[string]struct{}, len(knownTabs)) for _, v := range knownTabs { knownIds[v.Target.Id] = struct{}{} } newTabs, err := auto.debugger.GetNewTargets(knownIds) if err != nil { return nil, err } auto.tabLock.Lock() for _, newTab := range newTabs { t, err := open(newTab) if err != nil { return nil, err } auto.tabs[newTab.Target.Id] = t } auto.tabLock.Unlock() return auto.GetAllTabs(), nil }
[ "func", "(", "auto", "*", "AutoGcd", ")", "RefreshTabList", "(", ")", "(", "map", "[", "string", "]", "*", "Tab", ",", "error", ")", "{", "knownTabs", ":=", "auto", ".", "GetAllTabs", "(", ")", "\n", "knownIds", ":=", "make", "(", "map", "[", "stri...
// Refreshs our internal list of tabs and return all tabs
[ "Refreshs", "our", "internal", "list", "of", "tabs", "and", "return", "all", "tabs" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L152-L174
152,410
wirepair/autogcd
autogcd.go
GetTab
func (auto *AutoGcd) GetTab() (*Tab, error) { auto.tabLock.RLock() defer auto.tabLock.RUnlock() for _, tab := range auto.tabs { if tab.Target.Type == "page" { return tab, nil } } return nil, &InvalidTabErr{Message: "no Page tab types found"} }
go
func (auto *AutoGcd) GetTab() (*Tab, error) { auto.tabLock.RLock() defer auto.tabLock.RUnlock() for _, tab := range auto.tabs { if tab.Target.Type == "page" { return tab, nil } } return nil, &InvalidTabErr{Message: "no Page tab types found"} }
[ "func", "(", "auto", "*", "AutoGcd", ")", "GetTab", "(", ")", "(", "*", "Tab", ",", "error", ")", "{", "auto", ".", "tabLock", ".", "RLock", "(", ")", "\n", "defer", "auto", ".", "tabLock", ".", "RUnlock", "(", ")", "\n", "for", "_", ",", "tab"...
// Returns the first "visual" tab.
[ "Returns", "the", "first", "visual", "tab", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L177-L186
152,411
wirepair/autogcd
autogcd.go
GetAllTabs
func (auto *AutoGcd) GetAllTabs() map[string]*Tab { auto.tabLock.RLock() defer auto.tabLock.RUnlock() tabs := make(map[string]*Tab) for id, tab := range auto.tabs { tabs[id] = tab } return tabs }
go
func (auto *AutoGcd) GetAllTabs() map[string]*Tab { auto.tabLock.RLock() defer auto.tabLock.RUnlock() tabs := make(map[string]*Tab) for id, tab := range auto.tabs { tabs[id] = tab } return tabs }
[ "func", "(", "auto", "*", "AutoGcd", ")", "GetAllTabs", "(", ")", "map", "[", "string", "]", "*", "Tab", "{", "auto", ".", "tabLock", ".", "RLock", "(", ")", "\n", "defer", "auto", ".", "tabLock", ".", "RUnlock", "(", ")", "\n", "tabs", ":=", "ma...
// Returns a safe copy of tabs
[ "Returns", "a", "safe", "copy", "of", "tabs" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L189-L197
152,412
wirepair/autogcd
autogcd.go
ActivateTab
func (auto *AutoGcd) ActivateTab(tab *Tab) error { return auto.debugger.ActivateTab(tab.ChromeTarget) }
go
func (auto *AutoGcd) ActivateTab(tab *Tab) error { return auto.debugger.ActivateTab(tab.ChromeTarget) }
[ "func", "(", "auto", "*", "AutoGcd", ")", "ActivateTab", "(", "tab", "*", "Tab", ")", "error", "{", "return", "auto", ".", "debugger", ".", "ActivateTab", "(", "tab", ".", "ChromeTarget", ")", "\n", "}" ]
// Activate the tab in the chrome UI
[ "Activate", "the", "tab", "in", "the", "chrome", "UI" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L200-L202
152,413
wirepair/autogcd
autogcd.go
ActivateTabById
func (auto *AutoGcd) ActivateTabById(id string) error { tab, err := auto.tabById(id) if err != nil { return err } return auto.ActivateTab(tab) }
go
func (auto *AutoGcd) ActivateTabById(id string) error { tab, err := auto.tabById(id) if err != nil { return err } return auto.ActivateTab(tab) }
[ "func", "(", "auto", "*", "AutoGcd", ")", "ActivateTabById", "(", "id", "string", ")", "error", "{", "tab", ",", "err", ":=", "auto", ".", "tabById", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", ...
// Activate the tab in the chrome UI, by tab id
[ "Activate", "the", "tab", "in", "the", "chrome", "UI", "by", "tab", "id" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L205-L211
152,414
wirepair/autogcd
autogcd.go
NewTab
func (auto *AutoGcd) NewTab() (*Tab, error) { target, err := auto.debugger.NewTab() if err != nil { return nil, &InvalidTabErr{Message: "unable to create tab: " + err.Error()} } auto.tabLock.Lock() defer auto.tabLock.Unlock() tab, err := open(target) if err != nil { return nil, err } auto.tabs[target.Target.Id] = tab return tab, nil }
go
func (auto *AutoGcd) NewTab() (*Tab, error) { target, err := auto.debugger.NewTab() if err != nil { return nil, &InvalidTabErr{Message: "unable to create tab: " + err.Error()} } auto.tabLock.Lock() defer auto.tabLock.Unlock() tab, err := open(target) if err != nil { return nil, err } auto.tabs[target.Target.Id] = tab return tab, nil }
[ "func", "(", "auto", "*", "AutoGcd", ")", "NewTab", "(", ")", "(", "*", "Tab", ",", "error", ")", "{", "target", ",", "err", ":=", "auto", ".", "debugger", ".", "NewTab", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "&",...
// Creates a new tab
[ "Creates", "a", "new", "tab" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L214-L228
152,415
wirepair/autogcd
autogcd.go
CloseTab
func (auto *AutoGcd) CloseTab(tab *Tab) error { tab.close() // kill listening go routines if err := auto.debugger.CloseTab(tab.ChromeTarget); err != nil { return err } auto.tabLock.Lock() defer auto.tabLock.Unlock() delete(auto.tabs, tab.Target.Id) return nil }
go
func (auto *AutoGcd) CloseTab(tab *Tab) error { tab.close() // kill listening go routines if err := auto.debugger.CloseTab(tab.ChromeTarget); err != nil { return err } auto.tabLock.Lock() defer auto.tabLock.Unlock() delete(auto.tabs, tab.Target.Id) return nil }
[ "func", "(", "auto", "*", "AutoGcd", ")", "CloseTab", "(", "tab", "*", "Tab", ")", "error", "{", "tab", ".", "close", "(", ")", "// kill listening go routines", "\n\n", "if", "err", ":=", "auto", ".", "debugger", ".", "CloseTab", "(", "tab", ".", "Chro...
// Closes the provided tab.
[ "Closes", "the", "provided", "tab", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L231-L243
152,416
wirepair/autogcd
autogcd.go
CloseTabById
func (auto *AutoGcd) CloseTabById(id string) error { tab, err := auto.tabById(id) if err != nil { return err } auto.CloseTab(tab) return nil }
go
func (auto *AutoGcd) CloseTabById(id string) error { tab, err := auto.tabById(id) if err != nil { return err } auto.CloseTab(tab) return nil }
[ "func", "(", "auto", "*", "AutoGcd", ")", "CloseTabById", "(", "id", "string", ")", "error", "{", "tab", ",", "err", ":=", "auto", ".", "tabById", "(", "id", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "auto", ".",...
// Closes a tab based off the tab id.
[ "Closes", "a", "tab", "based", "off", "the", "tab", "id", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L246-L253
152,417
wirepair/autogcd
autogcd.go
tabById
func (auto *AutoGcd) tabById(id string) (*Tab, error) { auto.tabLock.RLock() tab := auto.tabs[id] auto.tabLock.RUnlock() if tab == nil { return nil, &InvalidTabErr{"unknown tab id " + id} } return tab, nil }
go
func (auto *AutoGcd) tabById(id string) (*Tab, error) { auto.tabLock.RLock() tab := auto.tabs[id] auto.tabLock.RUnlock() if tab == nil { return nil, &InvalidTabErr{"unknown tab id " + id} } return tab, nil }
[ "func", "(", "auto", "*", "AutoGcd", ")", "tabById", "(", "id", "string", ")", "(", "*", "Tab", ",", "error", ")", "{", "auto", ".", "tabLock", ".", "RLock", "(", ")", "\n", "tab", ":=", "auto", ".", "tabs", "[", "id", "]", "\n", "auto", ".", ...
// Finds the tab by its id.
[ "Finds", "the", "tab", "by", "its", "id", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/autogcd.go#L256-L264
152,418
wirepair/autogcd
tab_subscribers.go
subscribeLoadEvent
func (t *Tab) subscribeLoadEvent() { t.Subscribe("Page.loadEventFired", func(target *gcd.ChromeTarget, payload []byte) { if t.IsNavigating() { select { case t.navigationCh <- 0: case <-t.exitCh: } } }) }
go
func (t *Tab) subscribeLoadEvent() { t.Subscribe("Page.loadEventFired", func(target *gcd.ChromeTarget, payload []byte) { if t.IsNavigating() { select { case t.navigationCh <- 0: case <-t.exitCh: } } }) }
[ "func", "(", "t", "*", "Tab", ")", "subscribeLoadEvent", "(", ")", "{", "t", ".", "Subscribe", "(", "\"", "\"", ",", "func", "(", "target", "*", "gcd", ".", "ChromeTarget", ",", "payload", "[", "]", "byte", ")", "{", "if", "t", ".", "IsNavigating",...
// our default loadFiredEvent handler, returns a response to resp channel to navigate once complete.
[ "our", "default", "loadFiredEvent", "handler", "returns", "a", "response", "to", "resp", "channel", "to", "navigate", "once", "complete", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab_subscribers.go#L60-L70
152,419
drone/go-github
github/github.go
New
func New(token string) *Client { c := &Client{} c.Token = token c.Keys = &KeyResource{c} c.Repos = &RepoResource{c} c.Users = &UserResource{c} c.Orgs = &OrgResource{c} c.Emails = &EmailResource{c} c.Hooks = &HookResource{c} c.Contents = &ContentResource{c} c.RepoKeys = &RepoKeyResource{c} c.ApiUrl = "https://api.github.com" return c }
go
func New(token string) *Client { c := &Client{} c.Token = token c.Keys = &KeyResource{c} c.Repos = &RepoResource{c} c.Users = &UserResource{c} c.Orgs = &OrgResource{c} c.Emails = &EmailResource{c} c.Hooks = &HookResource{c} c.Contents = &ContentResource{c} c.RepoKeys = &RepoKeyResource{c} c.ApiUrl = "https://api.github.com" return c }
[ "func", "New", "(", "token", "string", ")", "*", "Client", "{", "c", ":=", "&", "Client", "{", "}", "\n", "c", ".", "Token", "=", "token", "\n\n", "c", ".", "Keys", "=", "&", "KeyResource", "{", "c", "}", "\n", "c", ".", "Repos", "=", "&", "R...
// New creates an instance of the Github Client
[ "New", "creates", "an", "instance", "of", "the", "Github", "Client" ]
323fe992f17d4e42a048c8406b034863c925cbdc
https://github.com/drone/go-github/blob/323fe992f17d4e42a048c8406b034863c925cbdc/github/github.go#L4-L18
152,420
sadbox/mediawiki
mediawiki.go
PageSlice
func (r *Response) PageSlice() []Page { pl := []Page{} for _, page := range r.Query.Pages { pl = append(pl, page) } return pl }
go
func (r *Response) PageSlice() []Page { pl := []Page{} for _, page := range r.Query.Pages { pl = append(pl, page) } return pl }
[ "func", "(", "r", "*", "Response", ")", "PageSlice", "(", ")", "[", "]", "Page", "{", "pl", ":=", "[", "]", "Page", "{", "}", "\n", "for", "_", ",", "page", ":=", "range", "r", ".", "Query", ".", "Pages", "{", "pl", "=", "append", "(", "pl", ...
// PageSlice generates a slice from Pages to work around the sillyness in // the MediaWiki API.
[ "PageSlice", "generates", "a", "slice", "from", "Pages", "to", "work", "around", "the", "sillyness", "in", "the", "MediaWiki", "API", "." ]
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L82-L88
152,421
sadbox/mediawiki
mediawiki.go
checkError
func checkError(response []byte) error { var mwerror mwError err := json.Unmarshal(response, &mwerror) if err != nil { return nil } else if mwerror.Error.Code != "" { return errors.New(mwerror.Error.Code + ": " + mwerror.Error.Info) } else { return nil } }
go
func checkError(response []byte) error { var mwerror mwError err := json.Unmarshal(response, &mwerror) if err != nil { return nil } else if mwerror.Error.Code != "" { return errors.New(mwerror.Error.Code + ": " + mwerror.Error.Info) } else { return nil } }
[ "func", "checkError", "(", "response", "[", "]", "byte", ")", "error", "{", "var", "mwerror", "mwError", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "response", ",", "&", "mwerror", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", "\n...
// Helper function for translating MediaWiki errors in to Golang errors.
[ "Helper", "function", "for", "translating", "MediaWiki", "errors", "in", "to", "Golang", "errors", "." ]
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L138-L148
152,422
sadbox/mediawiki
mediawiki.go
postForm
func (m *MWApi) postForm(query url.Values) ([]byte, error) { request, err := http.NewRequest("POST", m.url.String(), strings.NewReader(query.Encode())) if err != nil { return nil, err } request.Header.Set("Content-Type", "application/x-www-form-urlencoded") request.Header.Set("user-agent", m.userAgent) if m.UseBasicAuth { request.SetBasicAuth(m.BasicAuthUser, m.BasicAuthPass) } resp, err := m.client.Do(request) if err != nil { return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } if err = checkError(body); err != nil { return nil, err } return body, nil }
go
func (m *MWApi) postForm(query url.Values) ([]byte, error) { request, err := http.NewRequest("POST", m.url.String(), strings.NewReader(query.Encode())) if err != nil { return nil, err } request.Header.Set("Content-Type", "application/x-www-form-urlencoded") request.Header.Set("user-agent", m.userAgent) if m.UseBasicAuth { request.SetBasicAuth(m.BasicAuthUser, m.BasicAuthPass) } resp, err := m.client.Do(request) if err != nil { return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } if err = checkError(body); err != nil { return nil, err } return body, nil }
[ "func", "(", "m", "*", "MWApi", ")", "postForm", "(", "query", "url", ".", "Values", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "request", ",", "err", ":=", "http", ".", "NewRequest", "(", "\"", "\"", ",", "m", ".", "url", ".", "String...
// This will automatically add the user agent and encode the http request properly
[ "This", "will", "automatically", "add", "the", "user", "agent", "and", "encode", "the", "http", "request", "properly" ]
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L180-L205
152,423
sadbox/mediawiki
mediawiki.go
Download
func (m *MWApi) Download(filename string) (io.ReadCloser, error) { // First get the direct url of the file query := map[string]string{ "action": "query", "prop": "imageinfo", "iiprop": "url", "titles": filename, } body, err := m.API(query) if err != nil { return nil, err } var response Response err = json.Unmarshal(body, &response) if err != nil { return nil, err } pl := response.PageSlice() if len(pl) < 1 { return nil, errors.New("no file found") } page := pl[0] if len(page.Imageinfo) < 1 { return nil, errors.New("no file found") } fileurl := page.Imageinfo[0].Url // Then return the body of the response request, err := http.NewRequest("GET", fileurl, nil) if err != nil { return nil, err } request.Header.Set("user-agent", m.userAgent) if m.UseBasicAuth { request.SetBasicAuth(m.BasicAuthUser, m.BasicAuthPass) } resp, err := m.client.Do(request) if err != nil { return nil, err } return resp.Body, nil }
go
func (m *MWApi) Download(filename string) (io.ReadCloser, error) { // First get the direct url of the file query := map[string]string{ "action": "query", "prop": "imageinfo", "iiprop": "url", "titles": filename, } body, err := m.API(query) if err != nil { return nil, err } var response Response err = json.Unmarshal(body, &response) if err != nil { return nil, err } pl := response.PageSlice() if len(pl) < 1 { return nil, errors.New("no file found") } page := pl[0] if len(page.Imageinfo) < 1 { return nil, errors.New("no file found") } fileurl := page.Imageinfo[0].Url // Then return the body of the response request, err := http.NewRequest("GET", fileurl, nil) if err != nil { return nil, err } request.Header.Set("user-agent", m.userAgent) if m.UseBasicAuth { request.SetBasicAuth(m.BasicAuthUser, m.BasicAuthPass) } resp, err := m.client.Do(request) if err != nil { return nil, err } return resp.Body, nil }
[ "func", "(", "m", "*", "MWApi", ")", "Download", "(", "filename", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "// First get the direct url of the file", "query", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "\...
// Download a file. // // Returns a readcloser that must be closed manually. Refer to the // example app for additional usage.
[ "Download", "a", "file", ".", "Returns", "a", "readcloser", "that", "must", "be", "closed", "manually", ".", "Refer", "to", "the", "example", "app", "for", "additional", "usage", "." ]
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L211-L256
152,424
sadbox/mediawiki
mediawiki.go
Upload
func (m *MWApi) Upload(dstFilename string, file io.Reader) error { if m.edittoken == "" { err := m.GetEditToken() if err != nil { return err } } query := map[string]string{ "action": "upload", "filename": dstFilename, "token": m.edittoken, "format": m.format, } buffer := &bytes.Buffer{} writer := multipart.NewWriter(buffer) for key, value := range query { err := writer.WriteField(key, value) if err != nil { return err } } part, err := writer.CreateFormFile("file", dstFilename) _, err = io.Copy(part, file) if err != nil { return err } err = writer.Close() if err != nil { return err } request, err := http.NewRequest("POST", m.url.String(), buffer) if err != nil { return err } request.Header.Set("Content-Type", writer.FormDataContentType()) request.Header.Set("user-agent", m.userAgent) if m.UseBasicAuth { request.SetBasicAuth(m.BasicAuthUser, m.BasicAuthPass) } resp, err := m.client.Do(request) if err != nil { return err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return err } if err = checkError(body); err != nil { return err } var response uploadResponse err = json.Unmarshal(body, &response) if err != nil { return err } if !(response.Upload.Result == "Success" || response.Upload.Result == "Warning") { return errors.New(response.Upload.Result) } return nil }
go
func (m *MWApi) Upload(dstFilename string, file io.Reader) error { if m.edittoken == "" { err := m.GetEditToken() if err != nil { return err } } query := map[string]string{ "action": "upload", "filename": dstFilename, "token": m.edittoken, "format": m.format, } buffer := &bytes.Buffer{} writer := multipart.NewWriter(buffer) for key, value := range query { err := writer.WriteField(key, value) if err != nil { return err } } part, err := writer.CreateFormFile("file", dstFilename) _, err = io.Copy(part, file) if err != nil { return err } err = writer.Close() if err != nil { return err } request, err := http.NewRequest("POST", m.url.String(), buffer) if err != nil { return err } request.Header.Set("Content-Type", writer.FormDataContentType()) request.Header.Set("user-agent", m.userAgent) if m.UseBasicAuth { request.SetBasicAuth(m.BasicAuthUser, m.BasicAuthPass) } resp, err := m.client.Do(request) if err != nil { return err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return err } if err = checkError(body); err != nil { return err } var response uploadResponse err = json.Unmarshal(body, &response) if err != nil { return err } if !(response.Upload.Result == "Success" || response.Upload.Result == "Warning") { return errors.New(response.Upload.Result) } return nil }
[ "func", "(", "m", "*", "MWApi", ")", "Upload", "(", "dstFilename", "string", ",", "file", "io", ".", "Reader", ")", "error", "{", "if", "m", ".", "edittoken", "==", "\"", "\"", "{", "err", ":=", "m", ".", "GetEditToken", "(", ")", "\n", "if", "er...
// Upload a file // // This does a simple, but more error-prone upload. Mediawiki // has a chunked upload version but it is only available in newer // versions of the API. // // Automatically retrieves an edit token if necessary.
[ "Upload", "a", "file", "This", "does", "a", "simple", "but", "more", "error", "-", "prone", "upload", ".", "Mediawiki", "has", "a", "chunked", "upload", "version", "but", "it", "is", "only", "available", "in", "newer", "versions", "of", "the", "API", "."...
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L265-L334
152,425
sadbox/mediawiki
mediawiki.go
Login
func (m *MWApi) Login(username, password string) error { if username == "" { return errors.New("empty username supplied") } if password == "" { return errors.New("empty password supplied") } m.username = username m.password = password query := map[string]string{ "action": "login", "lgname": m.username, "lgpassword": m.password, } if m.Domain != "" { query["lgdomain"] = m.Domain } body, err := m.API(query) if err != nil { return err } var response outerLogin err = json.Unmarshal(body, &response) if err != nil { return err } if response.Login.Result == "Success" { return nil } else if response.Login.Result != "NeedToken" { return errors.New("Error logging in: " + response.Login.Result) } // Need to use the login token query["lgtoken"] = response.Login.Token body, err = m.API(query) if err != nil { return err } err = json.Unmarshal(body, &response) if err != nil { return err } if response.Login.Result != "Success" { return errors.New("Error logging in: " + response.Login.Result) } return nil }
go
func (m *MWApi) Login(username, password string) error { if username == "" { return errors.New("empty username supplied") } if password == "" { return errors.New("empty password supplied") } m.username = username m.password = password query := map[string]string{ "action": "login", "lgname": m.username, "lgpassword": m.password, } if m.Domain != "" { query["lgdomain"] = m.Domain } body, err := m.API(query) if err != nil { return err } var response outerLogin err = json.Unmarshal(body, &response) if err != nil { return err } if response.Login.Result == "Success" { return nil } else if response.Login.Result != "NeedToken" { return errors.New("Error logging in: " + response.Login.Result) } // Need to use the login token query["lgtoken"] = response.Login.Token body, err = m.API(query) if err != nil { return err } err = json.Unmarshal(body, &response) if err != nil { return err } if response.Login.Result != "Success" { return errors.New("Error logging in: " + response.Login.Result) } return nil }
[ "func", "(", "m", "*", "MWApi", ")", "Login", "(", "username", ",", "password", "string", ")", "error", "{", "if", "username", "==", "\"", "\"", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}", "\n", "if", "password", "==", "...
// Login to the Mediawiki Website.
[ "Login", "to", "the", "Mediawiki", "Website", "." ]
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L337-L391
152,426
sadbox/mediawiki
mediawiki.go
Read
func (m *MWApi) Read(pageName string) (*Page, error) { query := map[string]string{ "action": "query", "prop": "revisions", "titles": pageName, "rvlimit": "1", "rvprop": "content|timestamp|user|comment", } body, err := m.API(query) if err != nil { return nil, err } var response Response err = json.Unmarshal(body, &response) if err != nil { return nil, err } if len(response.Query.Pages) != 1 { return nil, errors.New("received unexpected number of pages") } // we use a hacky way of extracting the map's lone value var page *Page for _, pg := range response.Query.Pages { page = &pg } return page, nil }
go
func (m *MWApi) Read(pageName string) (*Page, error) { query := map[string]string{ "action": "query", "prop": "revisions", "titles": pageName, "rvlimit": "1", "rvprop": "content|timestamp|user|comment", } body, err := m.API(query) if err != nil { return nil, err } var response Response err = json.Unmarshal(body, &response) if err != nil { return nil, err } if len(response.Query.Pages) != 1 { return nil, errors.New("received unexpected number of pages") } // we use a hacky way of extracting the map's lone value var page *Page for _, pg := range response.Query.Pages { page = &pg } return page, nil }
[ "func", "(", "m", "*", "MWApi", ")", "Read", "(", "pageName", "string", ")", "(", "*", "Page", ",", "error", ")", "{", "query", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "\"", "\"", ",", "\"", "\"", ":", "\"", "\"", ","...
// Read returns the most recent revision of a Page. If an error occurs, nil is // returned.
[ "Read", "returns", "the", "most", "recent", "revision", "of", "a", "Page", ".", "If", "an", "error", "occurs", "nil", "is", "returned", "." ]
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L473-L502
152,427
sadbox/mediawiki
mediawiki.go
API
func (m *MWApi) API(values ...map[string]string) ([]byte, error) { query := m.url.Query() for _, valuemap := range values { for key, value := range valuemap { query.Set(key, value) } } query.Set("format", m.format) body, err := m.postForm(query) if err != nil { return nil, err } return body, nil }
go
func (m *MWApi) API(values ...map[string]string) ([]byte, error) { query := m.url.Query() for _, valuemap := range values { for key, value := range valuemap { query.Set(key, value) } } query.Set("format", m.format) body, err := m.postForm(query) if err != nil { return nil, err } return body, nil }
[ "func", "(", "m", "*", "MWApi", ")", "API", "(", "values", "...", "map", "[", "string", "]", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "query", ":=", "m", ".", "url", ".", "Query", "(", ")", "\n", "for", "_", ",", "valuema...
// API is a generic interface to the Mediawiki API. // Refer to the MediaWiki API reference for details. // // This is used by all internal functions to interact with the API.
[ "API", "is", "a", "generic", "interface", "to", "the", "Mediawiki", "API", ".", "Refer", "to", "the", "MediaWiki", "API", "reference", "for", "details", ".", "This", "is", "used", "by", "all", "internal", "functions", "to", "interact", "with", "the", "API"...
1e1eeee8043508da6a35a9807f3c78565c46b09f
https://github.com/sadbox/mediawiki/blob/1e1eeee8043508da6a35a9807f3c78565c46b09f/mediawiki.go#L508-L521
152,428
appc/goaci
proj2aci/asset.go
processAsset
func processAsset(asset, rootfs string, placeholderMapping map[string]string) ([]string, error) { splitAsset := filepath.SplitList(asset) if len(splitAsset) != 2 { return nil, fmt.Errorf("Malformed asset option: '%v' - expected two absolute paths separated with %v", asset, listSeparator()) } ACIAsset := replacePlaceholders(splitAsset[0], placeholderMapping) localAsset := replacePlaceholders(splitAsset[1], placeholderMapping) if err := validateAsset(ACIAsset, localAsset); err != nil { return nil, err } ACIAssetSubPath := filepath.Join(rootfs, filepath.Dir(ACIAsset)) err := os.MkdirAll(ACIAssetSubPath, 0755) if err != nil { return nil, fmt.Errorf("Failed to create directory tree for asset '%v': %v", asset, err) } err = copyTree(localAsset, filepath.Join(rootfs, ACIAsset)) if err != nil { return nil, fmt.Errorf("Failed to copy assets for %q: %v", asset, err) } additionalAssets, err := getSoLibs(localAsset) if err != nil { return nil, fmt.Errorf("Failed to get dependent assets for %q: %v", localAsset, err) } // HACK! if we are copying libc then try to copy libnss_* libs // (glibc name service switch libs used in networking) if matched, err := filepath.Match("libc.*", filepath.Base(localAsset)); err == nil && matched { toGlob := filepath.Join(filepath.Dir(localAsset), "libnss_*") if matches, err := filepath.Glob(toGlob); err == nil && len(matches) > 0 { matchesAsAssets := make([]string, 0, len(matches)) for _, f := range matches { matchesAsAssets = append(matchesAsAssets, getAssetString(f, f)) } additionalAssets = append(additionalAssets, matchesAsAssets...) } } return additionalAssets, nil }
go
func processAsset(asset, rootfs string, placeholderMapping map[string]string) ([]string, error) { splitAsset := filepath.SplitList(asset) if len(splitAsset) != 2 { return nil, fmt.Errorf("Malformed asset option: '%v' - expected two absolute paths separated with %v", asset, listSeparator()) } ACIAsset := replacePlaceholders(splitAsset[0], placeholderMapping) localAsset := replacePlaceholders(splitAsset[1], placeholderMapping) if err := validateAsset(ACIAsset, localAsset); err != nil { return nil, err } ACIAssetSubPath := filepath.Join(rootfs, filepath.Dir(ACIAsset)) err := os.MkdirAll(ACIAssetSubPath, 0755) if err != nil { return nil, fmt.Errorf("Failed to create directory tree for asset '%v': %v", asset, err) } err = copyTree(localAsset, filepath.Join(rootfs, ACIAsset)) if err != nil { return nil, fmt.Errorf("Failed to copy assets for %q: %v", asset, err) } additionalAssets, err := getSoLibs(localAsset) if err != nil { return nil, fmt.Errorf("Failed to get dependent assets for %q: %v", localAsset, err) } // HACK! if we are copying libc then try to copy libnss_* libs // (glibc name service switch libs used in networking) if matched, err := filepath.Match("libc.*", filepath.Base(localAsset)); err == nil && matched { toGlob := filepath.Join(filepath.Dir(localAsset), "libnss_*") if matches, err := filepath.Glob(toGlob); err == nil && len(matches) > 0 { matchesAsAssets := make([]string, 0, len(matches)) for _, f := range matches { matchesAsAssets = append(matchesAsAssets, getAssetString(f, f)) } additionalAssets = append(additionalAssets, matchesAsAssets...) } } return additionalAssets, nil }
[ "func", "processAsset", "(", "asset", ",", "rootfs", "string", ",", "placeholderMapping", "map", "[", "string", "]", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "splitAsset", ":=", "filepath", ".", "SplitList", "(", "asset", ")", "\n"...
// processAsset validates an asset, replaces placeholders with real // paths and does the copying. It may return additional assets to be // processed when asset is an executable or a library.
[ "processAsset", "validates", "an", "asset", "replaces", "placeholders", "with", "real", "paths", "and", "does", "the", "copying", ".", "It", "may", "return", "additional", "assets", "to", "be", "processed", "when", "asset", "is", "an", "executable", "or", "a",...
a9f06a2e5e7e897acc6a1fbcf21236a406315111
https://github.com/appc/goaci/blob/a9f06a2e5e7e897acc6a1fbcf21236a406315111/proj2aci/asset.go#L90-L126
152,429
appc/goaci
proj2aci/asset.go
getSymlinkedAssets
func getSymlinkedAssets(path string) ([]string, error) { assets := []string{} maxLevels := 100 levels := maxLevels for { if levels < 1 { return nil, fmt.Errorf("Too many levels of symlinks (>$d)", maxLevels) } fi, err := os.Lstat(path) if err != nil { return nil, err } asset := getAssetString(path, path) assets = append(assets, asset) if !isSymlink(fi.Mode()) { break } symTarget, err := os.Readlink(path) if err != nil { return nil, err } if filepath.IsAbs(symTarget) { path = symTarget } else { path = filepath.Join(filepath.Dir(path), symTarget) } levels-- } return assets, nil }
go
func getSymlinkedAssets(path string) ([]string, error) { assets := []string{} maxLevels := 100 levels := maxLevels for { if levels < 1 { return nil, fmt.Errorf("Too many levels of symlinks (>$d)", maxLevels) } fi, err := os.Lstat(path) if err != nil { return nil, err } asset := getAssetString(path, path) assets = append(assets, asset) if !isSymlink(fi.Mode()) { break } symTarget, err := os.Readlink(path) if err != nil { return nil, err } if filepath.IsAbs(symTarget) { path = symTarget } else { path = filepath.Join(filepath.Dir(path), symTarget) } levels-- } return assets, nil }
[ "func", "getSymlinkedAssets", "(", "path", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "assets", ":=", "[", "]", "string", "{", "}", "\n", "maxLevels", ":=", "100", "\n", "levels", ":=", "maxLevels", "\n", "for", "{", "if", "level...
// getSymlinkedAssets returns an array of many assets if given path is // a symlink - useful for getting shared libraries, which are often // surrounded with a bunch of symlinks.
[ "getSymlinkedAssets", "returns", "an", "array", "of", "many", "assets", "if", "given", "path", "is", "a", "symlink", "-", "useful", "for", "getting", "shared", "libraries", "which", "are", "often", "surrounded", "with", "a", "bunch", "of", "symlinks", "." ]
a9f06a2e5e7e897acc6a1fbcf21236a406315111
https://github.com/appc/goaci/blob/a9f06a2e5e7e897acc6a1fbcf21236a406315111/proj2aci/asset.go#L260-L289
152,430
drone/go-github
github/keys.go
List
func (r *KeyResource) List() ([]*Key, error) { keys := []*Key{} const path = "/user/keys" if err := r.client.do("GET", path, nil, &keys); err != nil { return nil, err } return keys, nil }
go
func (r *KeyResource) List() ([]*Key, error) { keys := []*Key{} const path = "/user/keys" if err := r.client.do("GET", path, nil, &keys); err != nil { return nil, err } return keys, nil }
[ "func", "(", "r", "*", "KeyResource", ")", "List", "(", ")", "(", "[", "]", "*", "Key", ",", "error", ")", "{", "keys", ":=", "[", "]", "*", "Key", "{", "}", "\n", "const", "path", "=", "\"", "\"", "\n\n", "if", "err", ":=", "r", ".", "clie...
// Gets a list of the keys associated with an account.
[ "Gets", "a", "list", "of", "the", "keys", "associated", "with", "an", "account", "." ]
323fe992f17d4e42a048c8406b034863c925cbdc
https://github.com/drone/go-github/blob/323fe992f17d4e42a048c8406b034863c925cbdc/github/keys.go#L19-L28
152,431
drone/go-github
github/keys.go
Find
func (r *KeyResource) Find(id int) (*Key, error) { key := Key{} path := fmt.Sprintf("/user/keys/%v", id) if err := r.client.do("GET", path, nil, &key); err != nil { return nil, err } return &key, nil }
go
func (r *KeyResource) Find(id int) (*Key, error) { key := Key{} path := fmt.Sprintf("/user/keys/%v", id) if err := r.client.do("GET", path, nil, &key); err != nil { return nil, err } return &key, nil }
[ "func", "(", "r", "*", "KeyResource", ")", "Find", "(", "id", "int", ")", "(", "*", "Key", ",", "error", ")", "{", "key", ":=", "Key", "{", "}", "\n", "path", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "id", ")", "\n", "if", "err", ...
// Gets the key associated with the specified id.
[ "Gets", "the", "key", "associated", "with", "the", "specified", "id", "." ]
323fe992f17d4e42a048c8406b034863c925cbdc
https://github.com/drone/go-github/blob/323fe992f17d4e42a048c8406b034863c925cbdc/github/keys.go#L31-L39
152,432
drone/go-github
github/keys.go
Create
func (r *KeyResource) Create(key, title string) (*Key, error) { in := Key{ Title: title, Key: key } out := Key{ } const path = "/user/keys" if err := r.client.do("POST", path, &in, &out); err != nil { return nil, err } return &out, nil }
go
func (r *KeyResource) Create(key, title string) (*Key, error) { in := Key{ Title: title, Key: key } out := Key{ } const path = "/user/keys" if err := r.client.do("POST", path, &in, &out); err != nil { return nil, err } return &out, nil }
[ "func", "(", "r", "*", "KeyResource", ")", "Create", "(", "key", ",", "title", "string", ")", "(", "*", "Key", ",", "error", ")", "{", "in", ":=", "Key", "{", "Title", ":", "title", ",", "Key", ":", "key", "}", "\n", "out", ":=", "Key", "{", ...
// Creates a key on the specified account. You must supply a valid key // that is unique across the Github service.
[ "Creates", "a", "key", "on", "the", "specified", "account", ".", "You", "must", "supply", "a", "valid", "key", "that", "is", "unique", "across", "the", "Github", "service", "." ]
323fe992f17d4e42a048c8406b034863c925cbdc
https://github.com/drone/go-github/blob/323fe992f17d4e42a048c8406b034863c925cbdc/github/keys.go#L59-L69
152,433
drone/go-github
github/keys.go
CreateUpdate
func (r *KeyResource) CreateUpdate(key, title string) (*Key, error) { if found, err := r.FindName(title); err == nil { // if the public keys are different we should update if found.Key != key { return r.Update(key, title, found.Id) } // otherwise we should just return the key, since there // is nothing to update return found, nil } return r.Create(key, title) }
go
func (r *KeyResource) CreateUpdate(key, title string) (*Key, error) { if found, err := r.FindName(title); err == nil { // if the public keys are different we should update if found.Key != key { return r.Update(key, title, found.Id) } // otherwise we should just return the key, since there // is nothing to update return found, nil } return r.Create(key, title) }
[ "func", "(", "r", "*", "KeyResource", ")", "CreateUpdate", "(", "key", ",", "title", "string", ")", "(", "*", "Key", ",", "error", ")", "{", "if", "found", ",", "err", ":=", "r", ".", "FindName", "(", "title", ")", ";", "err", "==", "nil", "{", ...
// Creates a key on the specified account, assuming it does not already // exist in the system
[ "Creates", "a", "key", "on", "the", "specified", "account", "assuming", "it", "does", "not", "already", "exist", "in", "the", "system" ]
323fe992f17d4e42a048c8406b034863c925cbdc
https://github.com/drone/go-github/blob/323fe992f17d4e42a048c8406b034863c925cbdc/github/keys.go#L88-L101
152,434
drone/go-github
github/keys.go
DeleteName
func (r *KeyResource) DeleteName(title string) error { key, err := r.FindName(title) if err != nil { return err } return r.Delete(key.Id) }
go
func (r *KeyResource) DeleteName(title string) error { key, err := r.FindName(title) if err != nil { return err } return r.Delete(key.Id) }
[ "func", "(", "r", "*", "KeyResource", ")", "DeleteName", "(", "title", "string", ")", "error", "{", "key", ",", "err", ":=", "r", ".", "FindName", "(", "title", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", ...
// Deletes the named key.
[ "Deletes", "the", "named", "key", "." ]
323fe992f17d4e42a048c8406b034863c925cbdc
https://github.com/drone/go-github/blob/323fe992f17d4e42a048c8406b034863c925cbdc/github/keys.go#L110-L116
152,435
wirepair/autogcd
tab.go
open
func open(target *gcd.ChromeTarget) (*Tab, error) { t := &Tab{ChromeTarget: target} t.eleMutex = &sync.RWMutex{} t.elements = make(map[int]*Element) t.nodeChange = make(chan *NodeChangeEvent) t.navigationCh = make(chan int, 1) // for signaling navigation complete t.docUpdateCh = make(chan struct{}) // wait for documentUpdate to be called during navigation t.crashedCh = make(chan string) // reason the tab crashed/was disconnected. t.exitCh = make(chan struct{}) t.navigationTimeout = 30 * time.Second // default 30 seconds for timeout t.elementTimeout = 5 * time.Second // default 5 seconds for waiting for element. t.stabilityTimeout = 2 * time.Second // default 2 seconds before we give up waiting for stability t.stableAfter = 300 * time.Millisecond // default 300 ms for considering the DOM stable t.domChangeHandler = nil // enable various debugger services if _, err := t.Page.Enable(); err != nil { return nil, err } if _, err := t.DOM.Enable(); err != nil { return nil, err } if _, err := t.Console.Enable(); err != nil { return nil, err } if _, err := t.Debugger.Enable(); err != nil { return nil, err } t.disconnectedHandler = t.defaultDisconnectedHandler t.subscribeEvents() go t.listenDebuggerEvents() return t, nil }
go
func open(target *gcd.ChromeTarget) (*Tab, error) { t := &Tab{ChromeTarget: target} t.eleMutex = &sync.RWMutex{} t.elements = make(map[int]*Element) t.nodeChange = make(chan *NodeChangeEvent) t.navigationCh = make(chan int, 1) // for signaling navigation complete t.docUpdateCh = make(chan struct{}) // wait for documentUpdate to be called during navigation t.crashedCh = make(chan string) // reason the tab crashed/was disconnected. t.exitCh = make(chan struct{}) t.navigationTimeout = 30 * time.Second // default 30 seconds for timeout t.elementTimeout = 5 * time.Second // default 5 seconds for waiting for element. t.stabilityTimeout = 2 * time.Second // default 2 seconds before we give up waiting for stability t.stableAfter = 300 * time.Millisecond // default 300 ms for considering the DOM stable t.domChangeHandler = nil // enable various debugger services if _, err := t.Page.Enable(); err != nil { return nil, err } if _, err := t.DOM.Enable(); err != nil { return nil, err } if _, err := t.Console.Enable(); err != nil { return nil, err } if _, err := t.Debugger.Enable(); err != nil { return nil, err } t.disconnectedHandler = t.defaultDisconnectedHandler t.subscribeEvents() go t.listenDebuggerEvents() return t, nil }
[ "func", "open", "(", "target", "*", "gcd", ".", "ChromeTarget", ")", "(", "*", "Tab", ",", "error", ")", "{", "t", ":=", "&", "Tab", "{", "ChromeTarget", ":", "target", "}", "\n", "t", ".", "eleMutex", "=", "&", "sync", ".", "RWMutex", "{", "}", ...
// Creates a new tab using the underlying ChromeTarget
[ "Creates", "a", "new", "tab", "using", "the", "underlying", "ChromeTarget" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L152-L187
152,436
wirepair/autogcd
tab.go
close
func (t *Tab) close() { if !t.IsShuttingDown() { close(t.exitCh) } t.setShutdownState(true) }
go
func (t *Tab) close() { if !t.IsShuttingDown() { close(t.exitCh) } t.setShutdownState(true) }
[ "func", "(", "t", "*", "Tab", ")", "close", "(", ")", "{", "if", "!", "t", ".", "IsShuttingDown", "(", ")", "{", "close", "(", "t", ".", "exitCh", ")", "\n", "}", "\n", "t", ".", "setShutdownState", "(", "true", ")", "\n", "}" ]
// close our exitch.
[ "close", "our", "exitch", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L190-L195
152,437
wirepair/autogcd
tab.go
IsShuttingDown
func (t *Tab) IsShuttingDown() bool { if flag, ok := t.shutdown.Load().(bool); ok { return flag } return false }
go
func (t *Tab) IsShuttingDown() bool { if flag, ok := t.shutdown.Load().(bool); ok { return flag } return false }
[ "func", "(", "t", "*", "Tab", ")", "IsShuttingDown", "(", ")", "bool", "{", "if", "flag", ",", "ok", ":=", "t", ".", "shutdown", ".", "Load", "(", ")", ".", "(", "bool", ")", ";", "ok", "{", "return", "flag", "\n", "}", "\n", "return", "false",...
// IsShuttingDown answers if we are shutting down or not
[ "IsShuttingDown", "answers", "if", "we", "are", "shutting", "down", "or", "not" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L198-L203
152,438
wirepair/autogcd
tab.go
IsNavigating
func (t *Tab) IsNavigating() bool { if flag, ok := t.isNavigatingFlag.Load().(bool); ok { return flag } return false }
go
func (t *Tab) IsNavigating() bool { if flag, ok := t.isNavigatingFlag.Load().(bool); ok { return flag } return false }
[ "func", "(", "t", "*", "Tab", ")", "IsNavigating", "(", ")", "bool", "{", "if", "flag", ",", "ok", ":=", "t", ".", "isNavigatingFlag", ".", "Load", "(", ")", ".", "(", "bool", ")", ";", "ok", "{", "return", "flag", "\n", "}", "\n", "return", "f...
// IsNavigating answers if we currently navigating
[ "IsNavigating", "answers", "if", "we", "currently", "navigating" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L250-L255
152,439
wirepair/autogcd
tab.go
IsTransitioning
func (t *Tab) IsTransitioning() bool { if flag, ok := t.isTransitioningFlag.Load().(bool); ok { return flag } return false }
go
func (t *Tab) IsTransitioning() bool { if flag, ok := t.isTransitioningFlag.Load().(bool); ok { return flag } return false }
[ "func", "(", "t", "*", "Tab", ")", "IsTransitioning", "(", ")", "bool", "{", "if", "flag", ",", "ok", ":=", "t", ".", "isTransitioningFlag", ".", "Load", "(", ")", ".", "(", "bool", ")", ";", "ok", "{", "return", "flag", "\n", "}", "\n", "return"...
// IsTransitioning returns true if we are transitioning to a new page. This is not set when Navigate is called.
[ "IsTransitioning", "returns", "true", "if", "we", "are", "transitioning", "to", "a", "new", "page", ".", "This", "is", "not", "set", "when", "Navigate", "is", "called", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L262-L267
152,440
wirepair/autogcd
tab.go
GetTopFrameId
func (t *Tab) GetTopFrameId() string { if frameId, ok := t.topFrameId.Load().(string); ok { return frameId } return "" }
go
func (t *Tab) GetTopFrameId() string { if frameId, ok := t.topFrameId.Load().(string); ok { return frameId } return "" }
[ "func", "(", "t", "*", "Tab", ")", "GetTopFrameId", "(", ")", "string", "{", "if", "frameId", ",", "ok", ":=", "t", ".", "topFrameId", ".", "Load", "(", ")", ".", "(", "string", ")", ";", "ok", "{", "return", "frameId", "\n", "}", "\n", "return",...
// GetTopFrameId return the top frame id of this tab
[ "GetTopFrameId", "return", "the", "top", "frame", "id", "of", "this", "tab" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L274-L279
152,441
wirepair/autogcd
tab.go
GetTopNodeId
func (t *Tab) GetTopNodeId() int { if topNodeId, ok := t.topNodeId.Load().(int); ok { return topNodeId } t.debugf("failed getting int from topNodeId") return -1 }
go
func (t *Tab) GetTopNodeId() int { if topNodeId, ok := t.topNodeId.Load().(int); ok { return topNodeId } t.debugf("failed getting int from topNodeId") return -1 }
[ "func", "(", "t", "*", "Tab", ")", "GetTopNodeId", "(", ")", "int", "{", "if", "topNodeId", ",", "ok", ":=", "t", ".", "topNodeId", ".", "Load", "(", ")", ".", "(", "int", ")", ";", "ok", "{", "return", "topNodeId", "\n", "}", "\n", "t", ".", ...
// GetTopNodeId returns the current top node id of this Tab.
[ "GetTopNodeId", "returns", "the", "current", "top", "node", "id", "of", "this", "Tab", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L287-L293
152,442
wirepair/autogcd
tab.go
Navigate
func (t *Tab) Navigate(url string) (string, string, error) { if t.IsNavigating() { return "", "", &InvalidNavigationErr{Message: "Unable to navigate, already navigating."} } t.setIsNavigating(true) t.debugf("navigating to %s", url) defer func() { t.setIsNavigating(false) }() navParams := &gcdapi.PageNavigateParams{Url: url, TransitionType: "typed"} frameId, _, errorText, err := t.Page.NavigateWithParams(navParams) if err != nil { return "", errorText, err } t.lastNodeChangeTimeVal.Store(time.Now()) err = t.readyWait(url) if err != nil { return frameId, "", err } t.debugf("navigation complete") return frameId, "", err }
go
func (t *Tab) Navigate(url string) (string, string, error) { if t.IsNavigating() { return "", "", &InvalidNavigationErr{Message: "Unable to navigate, already navigating."} } t.setIsNavigating(true) t.debugf("navigating to %s", url) defer func() { t.setIsNavigating(false) }() navParams := &gcdapi.PageNavigateParams{Url: url, TransitionType: "typed"} frameId, _, errorText, err := t.Page.NavigateWithParams(navParams) if err != nil { return "", errorText, err } t.lastNodeChangeTimeVal.Store(time.Now()) err = t.readyWait(url) if err != nil { return frameId, "", err } t.debugf("navigation complete") return frameId, "", err }
[ "func", "(", "t", "*", "Tab", ")", "Navigate", "(", "url", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "if", "t", ".", "IsNavigating", "(", ")", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "&", "InvalidNavigationErr", ...
// Navigate to a URL and does not return until the Page.loadEventFired event // as well as all setChildNode events have completed. // If successful, returns frameId. // If failed, returns frameId, friendly error text, and the error.
[ "Navigate", "to", "a", "URL", "and", "does", "not", "return", "until", "the", "Page", ".", "loadEventFired", "event", "as", "well", "as", "all", "setChildNode", "events", "have", "completed", ".", "If", "successful", "returns", "frameId", ".", "If", "failed"...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L299-L324
152,443
wirepair/autogcd
tab.go
DidNavigationFail
func (t *Tab) DidNavigationFail() (bool, string) { // if loadTimeData doesn't exist, or we get a js error, this means no error occurred. rro, err := t.EvaluateScript("loadTimeData.data_.errorCode") if err != nil { return false, "" } if val, ok := rro.Value.(string); ok { return true, val } return false, "" }
go
func (t *Tab) DidNavigationFail() (bool, string) { // if loadTimeData doesn't exist, or we get a js error, this means no error occurred. rro, err := t.EvaluateScript("loadTimeData.data_.errorCode") if err != nil { return false, "" } if val, ok := rro.Value.(string); ok { return true, val } return false, "" }
[ "func", "(", "t", "*", "Tab", ")", "DidNavigationFail", "(", ")", "(", "bool", ",", "string", ")", "{", "// if loadTimeData doesn't exist, or we get a js error, this means no error occurred.", "rro", ",", "err", ":=", "t", ".", "EvaluateScript", "(", "\"", "\"", "...
// An undocumented method of determining if chromium failed to load // a page due to DNS or connection timeouts.
[ "An", "undocumented", "method", "of", "determining", "if", "chromium", "failed", "to", "load", "a", "page", "due", "to", "DNS", "or", "connection", "timeouts", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L328-L340
152,444
wirepair/autogcd
tab.go
readyWait
func (t *Tab) readyWait(url string) error { var navigated bool timeoutTimer := time.NewTimer(t.navigationTimeout) defer timeoutTimer.Stop() for { select { case <-t.navigationCh: navigated = true case <-t.docUpdateCh: return nil case <-timeoutTimer.C: msg := "navigating to: " if navigated == true { msg = "waiting for document updated failed for: " } return &TimeoutErr{Message: msg + url} } } }
go
func (t *Tab) readyWait(url string) error { var navigated bool timeoutTimer := time.NewTimer(t.navigationTimeout) defer timeoutTimer.Stop() for { select { case <-t.navigationCh: navigated = true case <-t.docUpdateCh: return nil case <-timeoutTimer.C: msg := "navigating to: " if navigated == true { msg = "waiting for document updated failed for: " } return &TimeoutErr{Message: msg + url} } } }
[ "func", "(", "t", "*", "Tab", ")", "readyWait", "(", "url", "string", ")", "error", "{", "var", "navigated", "bool", "\n", "timeoutTimer", ":=", "time", ".", "NewTimer", "(", "t", ".", "navigationTimeout", ")", "\n", "defer", "timeoutTimer", ".", "Stop",...
// Set a single timer for both navigation and document updates. // navigationCh waits for a Page.loadEventFired or timeout. // docUpdateCh waits for document updated event from Tab.documentUpdated // event processing to finish so we have a valid set of elements.
[ "Set", "a", "single", "timer", "for", "both", "navigation", "and", "document", "updates", ".", "navigationCh", "waits", "for", "a", "Page", ".", "loadEventFired", "or", "timeout", ".", "docUpdateCh", "waits", "for", "document", "updated", "event", "from", "Tab...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L346-L365
152,445
wirepair/autogcd
tab.go
NavigationHistory
func (t *Tab) NavigationHistory() (int, []*gcdapi.PageNavigationEntry, error) { return t.Page.GetNavigationHistory() }
go
func (t *Tab) NavigationHistory() (int, []*gcdapi.PageNavigationEntry, error) { return t.Page.GetNavigationHistory() }
[ "func", "(", "t", "*", "Tab", ")", "NavigationHistory", "(", ")", "(", "int", ",", "[", "]", "*", "gcdapi", ".", "PageNavigationEntry", ",", "error", ")", "{", "return", "t", ".", "Page", ".", "GetNavigationHistory", "(", ")", "\n", "}" ]
// Returns the current navigation index, history entries or error
[ "Returns", "the", "current", "navigation", "index", "history", "entries", "or", "error" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L368-L370
152,446
wirepair/autogcd
tab.go
Reload
func (t *Tab) Reload(ignoreCache bool, evalScript string) error { _, err := t.Page.Reload(ignoreCache, evalScript) return err }
go
func (t *Tab) Reload(ignoreCache bool, evalScript string) error { _, err := t.Page.Reload(ignoreCache, evalScript) return err }
[ "func", "(", "t", "*", "Tab", ")", "Reload", "(", "ignoreCache", "bool", ",", "evalScript", "string", ")", "error", "{", "_", ",", "err", ":=", "t", ".", "Page", ".", "Reload", "(", "ignoreCache", ",", "evalScript", ")", "\n", "return", "err", "\n", ...
// Reloads the page injecting evalScript to run on load. set ignoreCache to true // to have it act like ctrl+f5.
[ "Reloads", "the", "page", "injecting", "evalScript", "to", "run", "on", "load", ".", "set", "ignoreCache", "to", "true", "to", "have", "it", "act", "like", "ctrl", "+", "f5", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L374-L377
152,447
wirepair/autogcd
tab.go
Forward
func (t *Tab) Forward() error { next, err := t.ForwardEntry() if err != nil { return err } _, err = t.Page.NavigateToHistoryEntry(next.Id) return err }
go
func (t *Tab) Forward() error { next, err := t.ForwardEntry() if err != nil { return err } _, err = t.Page.NavigateToHistoryEntry(next.Id) return err }
[ "func", "(", "t", "*", "Tab", ")", "Forward", "(", ")", "error", "{", "next", ",", "err", ":=", "t", ".", "ForwardEntry", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "err", "=", "t", ".", "Page",...
// Looks up the next navigation entry from the history and navigates to it. // Returns error if we could not find the next entry or navigation failed
[ "Looks", "up", "the", "next", "navigation", "entry", "from", "the", "history", "and", "navigates", "to", "it", ".", "Returns", "error", "if", "we", "could", "not", "find", "the", "next", "entry", "or", "navigation", "failed" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L381-L388
152,448
wirepair/autogcd
tab.go
Back
func (t *Tab) Back() error { prev, err := t.BackEntry() if err != nil { return err } _, err = t.Page.NavigateToHistoryEntry(prev.Id) return err }
go
func (t *Tab) Back() error { prev, err := t.BackEntry() if err != nil { return err } _, err = t.Page.NavigateToHistoryEntry(prev.Id) return err }
[ "func", "(", "t", "*", "Tab", ")", "Back", "(", ")", "error", "{", "prev", ",", "err", ":=", "t", ".", "BackEntry", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "_", ",", "err", "=", "t", ".", "Page", "."...
// Looks up the previous navigation entry from the history and navigates to it. // Returns error if we could not find the previous entry or navigation failed
[ "Looks", "up", "the", "previous", "navigation", "entry", "from", "the", "history", "and", "navigates", "to", "it", ".", "Returns", "error", "if", "we", "could", "not", "find", "the", "previous", "entry", "or", "navigation", "failed" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L406-L413
152,449
wirepair/autogcd
tab.go
BackEntry
func (t *Tab) BackEntry() (*gcdapi.PageNavigationEntry, error) { idx, entries, err := t.NavigationHistory() if err != nil { return nil, err } for i := len(entries); i > 0; i-- { if idx < entries[i].Id { return entries[i], nil } } return nil, &InvalidNavigationErr{Message: "Unable to navigate backward as we are on the first navigation entry"} }
go
func (t *Tab) BackEntry() (*gcdapi.PageNavigationEntry, error) { idx, entries, err := t.NavigationHistory() if err != nil { return nil, err } for i := len(entries); i > 0; i-- { if idx < entries[i].Id { return entries[i], nil } } return nil, &InvalidNavigationErr{Message: "Unable to navigate backward as we are on the first navigation entry"} }
[ "func", "(", "t", "*", "Tab", ")", "BackEntry", "(", ")", "(", "*", "gcdapi", ".", "PageNavigationEntry", ",", "error", ")", "{", "idx", ",", "entries", ",", "err", ":=", "t", ".", "NavigationHistory", "(", ")", "\n", "if", "err", "!=", "nil", "{",...
// Returns the previous entry in our navigation history for this tab.
[ "Returns", "the", "previous", "entry", "in", "our", "navigation", "history", "for", "this", "tab", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L416-L427
152,450
wirepair/autogcd
tab.go
WaitFor
func (t *Tab) WaitFor(rate, timeout time.Duration, conditionFn ConditionalFunc) error { rateTicker := time.NewTicker(rate) timeoutTimer := time.NewTimer(timeout) defer func() { timeoutTimer.Stop() rateTicker.Stop() }() for { select { case <-timeoutTimer.C: return &TimeoutErr{Message: "waiting for conditional func to return true"} case <-rateTicker.C: ret := conditionFn(t) if ret == true { return nil } } } }
go
func (t *Tab) WaitFor(rate, timeout time.Duration, conditionFn ConditionalFunc) error { rateTicker := time.NewTicker(rate) timeoutTimer := time.NewTimer(timeout) defer func() { timeoutTimer.Stop() rateTicker.Stop() }() for { select { case <-timeoutTimer.C: return &TimeoutErr{Message: "waiting for conditional func to return true"} case <-rateTicker.C: ret := conditionFn(t) if ret == true { return nil } } } }
[ "func", "(", "t", "*", "Tab", ")", "WaitFor", "(", "rate", ",", "timeout", "time", ".", "Duration", ",", "conditionFn", "ConditionalFunc", ")", "error", "{", "rateTicker", ":=", "time", ".", "NewTicker", "(", "rate", ")", "\n", "timeoutTimer", ":=", "tim...
// Calls a function every tick until conditionFn returns true or timeout occurs.
[ "Calls", "a", "function", "every", "tick", "until", "conditionFn", "returns", "true", "or", "timeout", "occurs", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L430-L450
152,451
wirepair/autogcd
tab.go
GetScriptSource
func (t *Tab) GetScriptSource(scriptId string) (string, error) { return t.Debugger.GetScriptSource(scriptId) }
go
func (t *Tab) GetScriptSource(scriptId string) (string, error) { return t.Debugger.GetScriptSource(scriptId) }
[ "func", "(", "t", "*", "Tab", ")", "GetScriptSource", "(", "scriptId", "string", ")", "(", "string", ",", "error", ")", "{", "return", "t", ".", "Debugger", ".", "GetScriptSource", "(", "scriptId", ")", "\n", "}" ]
// Returns the source of a script by its scriptId.
[ "Returns", "the", "source", "of", "a", "script", "by", "its", "scriptId", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L495-L497
152,452
wirepair/autogcd
tab.go
GetDocument
func (t *Tab) GetDocument() (*Element, error) { docEle, ok := t.getElement(t.GetTopNodeId()) if !ok { return nil, &ElementNotFoundErr{Message: "top document node id not found."} } return docEle, nil }
go
func (t *Tab) GetDocument() (*Element, error) { docEle, ok := t.getElement(t.GetTopNodeId()) if !ok { return nil, &ElementNotFoundErr{Message: "top document node id not found."} } return docEle, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetDocument", "(", ")", "(", "*", "Element", ",", "error", ")", "{", "docEle", ",", "ok", ":=", "t", ".", "getElement", "(", "t", ".", "GetTopNodeId", "(", ")", ")", "\n", "if", "!", "ok", "{", "return", "nil...
// Returns the top level document element for this tab.
[ "Returns", "the", "top", "level", "document", "element", "for", "this", "tab", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L517-L523
152,453
wirepair/autogcd
tab.go
GetElementByLocation
func (t *Tab) GetElementByLocation(x, y int) (*Element, error) { _, nodeId, err := t.DOM.GetNodeForLocation(x, y, false) if err != nil { return nil, err } ele, _ := t.GetElementByNodeId(nodeId) return ele, nil }
go
func (t *Tab) GetElementByLocation(x, y int) (*Element, error) { _, nodeId, err := t.DOM.GetNodeForLocation(x, y, false) if err != nil { return nil, err } ele, _ := t.GetElementByNodeId(nodeId) return ele, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetElementByLocation", "(", "x", ",", "y", "int", ")", "(", "*", "Element", ",", "error", ")", "{", "_", ",", "nodeId", ",", "err", ":=", "t", ".", "DOM", ".", "GetNodeForLocation", "(", "x", ",", "y", ",", "...
// Returns the element given the x, y coordinates on the page, or returns error.
[ "Returns", "the", "element", "given", "the", "x", "y", "coordinates", "on", "the", "page", "or", "returns", "error", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L545-L552
152,454
wirepair/autogcd
tab.go
GetAllElements
func (t *Tab) GetAllElements() map[int]*Element { t.eleMutex.RLock() allElements := make(map[int]*Element, len(t.elements)) for k, v := range t.elements { allElements[k] = v } t.eleMutex.RUnlock() return allElements }
go
func (t *Tab) GetAllElements() map[int]*Element { t.eleMutex.RLock() allElements := make(map[int]*Element, len(t.elements)) for k, v := range t.elements { allElements[k] = v } t.eleMutex.RUnlock() return allElements }
[ "func", "(", "t", "*", "Tab", ")", "GetAllElements", "(", ")", "map", "[", "int", "]", "*", "Element", "{", "t", ".", "eleMutex", ".", "RLock", "(", ")", "\n", "allElements", ":=", "make", "(", "map", "[", "int", "]", "*", "Element", ",", "len", ...
// Returns a copy of all currently known elements. Note that modifications to elements // maybe unsafe.
[ "Returns", "a", "copy", "of", "all", "currently", "known", "elements", ".", "Note", "that", "modifications", "to", "elements", "maybe", "unsafe", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L556-L564
152,455
wirepair/autogcd
tab.go
GetElementById
func (t *Tab) GetElementById(attributeId string) (*Element, bool, error) { return t.GetDocumentElementById(t.GetTopNodeId(), attributeId) }
go
func (t *Tab) GetElementById(attributeId string) (*Element, bool, error) { return t.GetDocumentElementById(t.GetTopNodeId(), attributeId) }
[ "func", "(", "t", "*", "Tab", ")", "GetElementById", "(", "attributeId", "string", ")", "(", "*", "Element", ",", "bool", ",", "error", ")", "{", "return", "t", ".", "GetDocumentElementById", "(", "t", ".", "GetTopNodeId", "(", ")", ",", "attributeId", ...
// Returns the element by searching the top level document for an element with attributeId // Does not work on frames.
[ "Returns", "the", "element", "by", "searching", "the", "top", "level", "document", "for", "an", "element", "with", "attributeId", "Does", "not", "work", "on", "frames", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L568-L570
152,456
wirepair/autogcd
tab.go
GetDocumentElementById
func (t *Tab) GetDocumentElementById(docNodeId int, attributeId string) (*Element, bool, error) { var err error docNode, ok := t.getElement(docNodeId) if !ok { return nil, false, &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } selector := "#" + attributeId nodeId, err := t.DOM.QuerySelector(docNode.id, selector) if err != nil { return nil, false, err } ele, ready := t.GetElementByNodeId(nodeId) return ele, ready, nil }
go
func (t *Tab) GetDocumentElementById(docNodeId int, attributeId string) (*Element, bool, error) { var err error docNode, ok := t.getElement(docNodeId) if !ok { return nil, false, &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } selector := "#" + attributeId nodeId, err := t.DOM.QuerySelector(docNode.id, selector) if err != nil { return nil, false, err } ele, ready := t.GetElementByNodeId(nodeId) return ele, ready, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetDocumentElementById", "(", "docNodeId", "int", ",", "attributeId", "string", ")", "(", "*", "Element", ",", "bool", ",", "error", ")", "{", "var", "err", "error", "\n\n", "docNode", ",", "ok", ":=", "t", ".", "g...
// Returns an element from a specific Document.
[ "Returns", "an", "element", "from", "a", "specific", "Document", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L573-L589
152,457
wirepair/autogcd
tab.go
GetElementsBySelector
func (t *Tab) GetElementsBySelector(selector string) ([]*Element, error) { return t.GetDocumentElementsBySelector(t.GetTopNodeId(), selector) }
go
func (t *Tab) GetElementsBySelector(selector string) ([]*Element, error) { return t.GetDocumentElementsBySelector(t.GetTopNodeId(), selector) }
[ "func", "(", "t", "*", "Tab", ")", "GetElementsBySelector", "(", "selector", "string", ")", "(", "[", "]", "*", "Element", ",", "error", ")", "{", "return", "t", ".", "GetDocumentElementsBySelector", "(", "t", ".", "GetTopNodeId", "(", ")", ",", "selecto...
// Get all elements that match a selector from the top level document
[ "Get", "all", "elements", "that", "match", "a", "selector", "from", "the", "top", "level", "document" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L592-L594
152,458
wirepair/autogcd
tab.go
GetChildElementsOfType
func (t *Tab) GetChildElementsOfType(element *Element, tagType string) []*Element { elements := make([]*Element, 0) if element == nil || element.node == nil || element.node.Children == nil { return elements } t.recursivelyGetChildren(element.node.Children, &elements, tagType) return elements }
go
func (t *Tab) GetChildElementsOfType(element *Element, tagType string) []*Element { elements := make([]*Element, 0) if element == nil || element.node == nil || element.node.Children == nil { return elements } t.recursivelyGetChildren(element.node.Children, &elements, tagType) return elements }
[ "func", "(", "t", "*", "Tab", ")", "GetChildElementsOfType", "(", "element", "*", "Element", ",", "tagType", "string", ")", "[", "]", "*", "Element", "{", "elements", ":=", "make", "(", "[", "]", "*", "Element", ",", "0", ")", "\n", "if", "element", ...
// Returns all elements of a specific tag type.
[ "Returns", "all", "elements", "of", "a", "specific", "tag", "type", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L602-L609
152,459
wirepair/autogcd
tab.go
GetDocumentElementsBySelector
func (t *Tab) GetDocumentElementsBySelector(docNodeId int, selector string) ([]*Element, error) { docNode, ok := t.getElement(docNodeId) if !ok { return nil, &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } nodeIds, errQuery := t.DOM.QuerySelectorAll(docNode.id, selector) if errQuery != nil { return nil, errQuery } elements := make([]*Element, len(nodeIds)) for k, nodeId := range nodeIds { elements[k], _ = t.GetElementByNodeId(nodeId) } return elements, nil }
go
func (t *Tab) GetDocumentElementsBySelector(docNodeId int, selector string) ([]*Element, error) { docNode, ok := t.getElement(docNodeId) if !ok { return nil, &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } nodeIds, errQuery := t.DOM.QuerySelectorAll(docNode.id, selector) if errQuery != nil { return nil, errQuery } elements := make([]*Element, len(nodeIds)) for k, nodeId := range nodeIds { elements[k], _ = t.GetElementByNodeId(nodeId) } return elements, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetDocumentElementsBySelector", "(", "docNodeId", "int", ",", "selector", "string", ")", "(", "[", "]", "*", "Element", ",", "error", ")", "{", "docNode", ",", "ok", ":=", "t", ".", "getElement", "(", "docNodeId", ")...
// Same as GetChildElementsBySelector
[ "Same", "as", "GetChildElementsBySelector" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L638-L655
152,460
wirepair/autogcd
tab.go
GetElementsBySearch
func (t *Tab) GetElementsBySearch(selector string, includeUserAgentShadowDOM bool) ([]*Element, error) { var s gcdapi.DOMPerformSearchParams s.Query = selector s.IncludeUserAgentShadowDOM = includeUserAgentShadowDOM id, count, err := t.DOM.PerformSearchWithParams(&s) if err != nil { return nil, err } if count < 1 { return make([]*Element, 0), nil } var r gcdapi.DOMGetSearchResultsParams r.SearchId = id r.FromIndex = 0 r.ToIndex = count nodeIds, errQuery := t.DOM.GetSearchResultsWithParams(&r) if errQuery != nil { return nil, errQuery } elements := make([]*Element, len(nodeIds)) for k, nodeId := range nodeIds { elements[k], _ = t.GetElementByNodeId(nodeId) } return elements, nil }
go
func (t *Tab) GetElementsBySearch(selector string, includeUserAgentShadowDOM bool) ([]*Element, error) { var s gcdapi.DOMPerformSearchParams s.Query = selector s.IncludeUserAgentShadowDOM = includeUserAgentShadowDOM id, count, err := t.DOM.PerformSearchWithParams(&s) if err != nil { return nil, err } if count < 1 { return make([]*Element, 0), nil } var r gcdapi.DOMGetSearchResultsParams r.SearchId = id r.FromIndex = 0 r.ToIndex = count nodeIds, errQuery := t.DOM.GetSearchResultsWithParams(&r) if errQuery != nil { return nil, errQuery } elements := make([]*Element, len(nodeIds)) for k, nodeId := range nodeIds { elements[k], _ = t.GetElementByNodeId(nodeId) } return elements, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetElementsBySearch", "(", "selector", "string", ",", "includeUserAgentShadowDOM", "bool", ")", "(", "[", "]", "*", "Element", ",", "error", ")", "{", "var", "s", "gcdapi", ".", "DOMPerformSearchParams", "\n", "s", ".", ...
// Get all elements that match a CSS or XPath selector
[ "Get", "all", "elements", "that", "match", "a", "CSS", "or", "XPath", "selector" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L658-L687
152,461
wirepair/autogcd
tab.go
GetPageSource
func (t *Tab) GetPageSource(docNodeId int) (string, error) { if docNodeId == 0 { docNodeId = t.GetTopNodeId() } doc, ok := t.getElement(docNodeId) if !ok { return "", &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } outerParams := &gcdapi.DOMGetOuterHTMLParams{NodeId: doc.id} return t.DOM.GetOuterHTMLWithParams(outerParams) }
go
func (t *Tab) GetPageSource(docNodeId int) (string, error) { if docNodeId == 0 { docNodeId = t.GetTopNodeId() } doc, ok := t.getElement(docNodeId) if !ok { return "", &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } outerParams := &gcdapi.DOMGetOuterHTMLParams{NodeId: doc.id} return t.DOM.GetOuterHTMLWithParams(outerParams) }
[ "func", "(", "t", "*", "Tab", ")", "GetPageSource", "(", "docNodeId", "int", ")", "(", "string", ",", "error", ")", "{", "if", "docNodeId", "==", "0", "{", "docNodeId", "=", "t", ".", "GetTopNodeId", "(", ")", "\n", "}", "\n", "doc", ",", "ok", "...
// Returns the document's source, as visible, if docId is 0, returns top document source.
[ "Returns", "the", "document", "s", "source", "as", "visible", "if", "docId", "is", "0", "returns", "top", "document", "source", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L690-L700
152,462
wirepair/autogcd
tab.go
GetDocumentCurrentUrl
func (t *Tab) GetDocumentCurrentUrl(docNodeId int) (string, error) { docNode, ok := t.getElement(docNodeId) if !ok { return "", &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } return docNode.node.DocumentURL, nil }
go
func (t *Tab) GetDocumentCurrentUrl(docNodeId int) (string, error) { docNode, ok := t.getElement(docNodeId) if !ok { return "", &ElementNotFoundErr{Message: fmt.Sprintf("docNodeId %d not found", docNodeId)} } return docNode.node.DocumentURL, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetDocumentCurrentUrl", "(", "docNodeId", "int", ")", "(", "string", ",", "error", ")", "{", "docNode", ",", "ok", ":=", "t", ".", "getElement", "(", "docNodeId", ")", "\n", "if", "!", "ok", "{", "return", "\"", ...
// Returns the current url of the provided docNodeId
[ "Returns", "the", "current", "url", "of", "the", "provided", "docNodeId" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L708-L714
152,463
wirepair/autogcd
tab.go
Click
func (t *Tab) Click(x, y float64) error { return t.click(x, y, 1) }
go
func (t *Tab) Click(x, y float64) error { return t.click(x, y, 1) }
[ "func", "(", "t", "*", "Tab", ")", "Click", "(", "x", ",", "y", "float64", ")", "error", "{", "return", "t", ".", "click", "(", "x", ",", "y", ",", "1", ")", "\n", "}" ]
// Issues a left button mousePressed then mouseReleased on the x, y coords provided.
[ "Issues", "a", "left", "button", "mousePressed", "then", "mouseReleased", "on", "the", "x", "y", "coords", "provided", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L717-L719
152,464
wirepair/autogcd
tab.go
DoubleClick
func (t *Tab) DoubleClick(x, y float64) error { return t.click(x, y, 2) }
go
func (t *Tab) DoubleClick(x, y float64) error { return t.click(x, y, 2) }
[ "func", "(", "t", "*", "Tab", ")", "DoubleClick", "(", "x", ",", "y", "float64", ")", "error", "{", "return", "t", ".", "click", "(", "x", ",", "y", ",", "2", ")", "\n", "}" ]
// Issues a double click on the x, y coords provided.
[ "Issues", "a", "double", "click", "on", "the", "x", "y", "coords", "provided", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L750-L752
152,465
wirepair/autogcd
tab.go
MoveMouse
func (t *Tab) MoveMouse(x, y float64) error { mouseMovedParams := &gcdapi.InputDispatchMouseEventParams{TheType: "mouseMoved", X: x, Y: y, } _, err := t.Input.DispatchMouseEventWithParams(mouseMovedParams) return err }
go
func (t *Tab) MoveMouse(x, y float64) error { mouseMovedParams := &gcdapi.InputDispatchMouseEventParams{TheType: "mouseMoved", X: x, Y: y, } _, err := t.Input.DispatchMouseEventWithParams(mouseMovedParams) return err }
[ "func", "(", "t", "*", "Tab", ")", "MoveMouse", "(", "x", ",", "y", "float64", ")", "error", "{", "mouseMovedParams", ":=", "&", "gcdapi", ".", "InputDispatchMouseEventParams", "{", "TheType", ":", "\"", "\"", ",", "X", ":", "x", ",", "Y", ":", "y", ...
// Moves the mouse to the x, y coords provided.
[ "Moves", "the", "mouse", "to", "the", "x", "y", "coords", "provided", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L755-L763
152,466
wirepair/autogcd
tab.go
SendKeys
func (t *Tab) SendKeys(text string) error { inputParams := &gcdapi.InputDispatchKeyEventParams{TheType: "char"} // loop over input, looking for system keys and handling them for _, inputchar := range text { input := string(inputchar) // check system keys switch input { case "\r", "\n", "\t", "\b": if err := t.pressSystemKey(input); err != nil { return err } continue } inputParams.Text = input _, err := t.Input.DispatchKeyEventWithParams(inputParams) if err != nil { return err } } return nil }
go
func (t *Tab) SendKeys(text string) error { inputParams := &gcdapi.InputDispatchKeyEventParams{TheType: "char"} // loop over input, looking for system keys and handling them for _, inputchar := range text { input := string(inputchar) // check system keys switch input { case "\r", "\n", "\t", "\b": if err := t.pressSystemKey(input); err != nil { return err } continue } inputParams.Text = input _, err := t.Input.DispatchKeyEventWithParams(inputParams) if err != nil { return err } } return nil }
[ "func", "(", "t", "*", "Tab", ")", "SendKeys", "(", "text", "string", ")", "error", "{", "inputParams", ":=", "&", "gcdapi", ".", "InputDispatchKeyEventParams", "{", "TheType", ":", "\"", "\"", "}", "\n\n", "// loop over input, looking for system keys and handling...
// Sends keystrokes to whatever is focused, best called from Element.SendKeys which will // try to focus on the element first. Use \n for Enter, \b for backspace or \t for Tab.
[ "Sends", "keystrokes", "to", "whatever", "is", "focused", "best", "called", "from", "Element", ".", "SendKeys", "which", "will", "try", "to", "focus", "on", "the", "element", "first", ".", "Use", "\\", "n", "for", "Enter", "\\", "b", "for", "backspace", ...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L767-L789
152,467
wirepair/autogcd
tab.go
pressSystemKey
func (t *Tab) pressSystemKey(systemKey string) error { inputParams := &gcdapi.InputDispatchKeyEventParams{TheType: "rawKeyDown"} switch systemKey { case "\b": inputParams.UnmodifiedText = "\b" inputParams.Text = "\b" inputParams.WindowsVirtualKeyCode = 8 inputParams.NativeVirtualKeyCode = 8 case "\t": inputParams.UnmodifiedText = "\t" inputParams.Text = "\t" inputParams.WindowsVirtualKeyCode = 9 inputParams.NativeVirtualKeyCode = 9 case "\r", "\n": inputParams.UnmodifiedText = "\r" inputParams.Text = "\r" inputParams.WindowsVirtualKeyCode = 13 inputParams.NativeVirtualKeyCode = 13 } if _, err := t.Input.DispatchKeyEventWithParams(inputParams); err != nil { return err } inputParams.TheType = "char" if _, err := t.Input.DispatchKeyEventWithParams(inputParams); err != nil { return err } inputParams.TheType = "keyUp" if _, err := t.Input.DispatchKeyEventWithParams(inputParams); err != nil { return err } return nil }
go
func (t *Tab) pressSystemKey(systemKey string) error { inputParams := &gcdapi.InputDispatchKeyEventParams{TheType: "rawKeyDown"} switch systemKey { case "\b": inputParams.UnmodifiedText = "\b" inputParams.Text = "\b" inputParams.WindowsVirtualKeyCode = 8 inputParams.NativeVirtualKeyCode = 8 case "\t": inputParams.UnmodifiedText = "\t" inputParams.Text = "\t" inputParams.WindowsVirtualKeyCode = 9 inputParams.NativeVirtualKeyCode = 9 case "\r", "\n": inputParams.UnmodifiedText = "\r" inputParams.Text = "\r" inputParams.WindowsVirtualKeyCode = 13 inputParams.NativeVirtualKeyCode = 13 } if _, err := t.Input.DispatchKeyEventWithParams(inputParams); err != nil { return err } inputParams.TheType = "char" if _, err := t.Input.DispatchKeyEventWithParams(inputParams); err != nil { return err } inputParams.TheType = "keyUp" if _, err := t.Input.DispatchKeyEventWithParams(inputParams); err != nil { return err } return nil }
[ "func", "(", "t", "*", "Tab", ")", "pressSystemKey", "(", "systemKey", "string", ")", "error", "{", "inputParams", ":=", "&", "gcdapi", ".", "InputDispatchKeyEventParams", "{", "TheType", ":", "\"", "\"", "}", "\n\n", "switch", "systemKey", "{", "case", "\...
// Super ghetto, i know.
[ "Super", "ghetto", "i", "know", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L792-L827
152,468
wirepair/autogcd
tab.go
InjectScriptOnLoad
func (t *Tab) InjectScriptOnLoad(scriptSource string) (string, error) { scriptId, err := t.Page.AddScriptToEvaluateOnLoad(scriptSource) if err != nil { return "", err } return scriptId, nil }
go
func (t *Tab) InjectScriptOnLoad(scriptSource string) (string, error) { scriptId, err := t.Page.AddScriptToEvaluateOnLoad(scriptSource) if err != nil { return "", err } return scriptId, nil }
[ "func", "(", "t", "*", "Tab", ")", "InjectScriptOnLoad", "(", "scriptSource", "string", ")", "(", "string", ",", "error", ")", "{", "scriptId", ",", "err", ":=", "t", ".", "Page", ".", "AddScriptToEvaluateOnLoad", "(", "scriptSource", ")", "\n", "if", "e...
// Injects custom javascript prior to the page loading on all frames. Returns scriptId which // can be used to remove the script. If you only want the script to interact with the top // document, you'll need to do checks in the injected script such as testing location.href. // // Alternatively, you can use Tab.EvaluateScript to only work on the global context.
[ "Injects", "custom", "javascript", "prior", "to", "the", "page", "loading", "on", "all", "frames", ".", "Returns", "scriptId", "which", "can", "be", "used", "to", "remove", "the", "script", ".", "If", "you", "only", "want", "the", "script", "to", "interact...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L834-L840
152,469
wirepair/autogcd
tab.go
RemoveScriptFromOnLoad
func (t *Tab) RemoveScriptFromOnLoad(scriptId string) error { _, err := t.Page.RemoveScriptToEvaluateOnLoad(scriptId) return err }
go
func (t *Tab) RemoveScriptFromOnLoad(scriptId string) error { _, err := t.Page.RemoveScriptToEvaluateOnLoad(scriptId) return err }
[ "func", "(", "t", "*", "Tab", ")", "RemoveScriptFromOnLoad", "(", "scriptId", "string", ")", "error", "{", "_", ",", "err", ":=", "t", ".", "Page", ".", "RemoveScriptToEvaluateOnLoad", "(", "scriptId", ")", "\n", "return", "err", "\n", "}" ]
// Removes the script by the scriptId.
[ "Removes", "the", "script", "by", "the", "scriptId", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L843-L846
152,470
wirepair/autogcd
tab.go
GetFullPageScreenShot
func (t *Tab) GetFullPageScreenShot() ([]byte, error) { var imgBytes []byte _, _, rect, err := t.Page.GetLayoutMetrics() if err != nil { return nil, err } params := &gcdapi.PageCaptureScreenshotParams{ Format: "png", Quality: 100, Clip: &gcdapi.PageViewport{ X: rect.X, Y: rect.Y, Width: rect.Width, Height: rect.Height, Scale: float64(1)}, FromSurface: true, } img, err := t.Page.CaptureScreenshotWithParams(params) if err != nil { return nil, err } imgBytes, err = base64.StdEncoding.DecodeString(img) if err != nil { return nil, err } return imgBytes, nil }
go
func (t *Tab) GetFullPageScreenShot() ([]byte, error) { var imgBytes []byte _, _, rect, err := t.Page.GetLayoutMetrics() if err != nil { return nil, err } params := &gcdapi.PageCaptureScreenshotParams{ Format: "png", Quality: 100, Clip: &gcdapi.PageViewport{ X: rect.X, Y: rect.Y, Width: rect.Width, Height: rect.Height, Scale: float64(1)}, FromSurface: true, } img, err := t.Page.CaptureScreenshotWithParams(params) if err != nil { return nil, err } imgBytes, err = base64.StdEncoding.DecodeString(img) if err != nil { return nil, err } return imgBytes, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetFullPageScreenShot", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "imgBytes", "[", "]", "byte", "\n\n", "_", ",", "_", ",", "rect", ",", "err", ":=", "t", ".", "Page", ".", "GetLayoutMetri...
// Takes a full sized screenshot of the currently loaded page
[ "Takes", "a", "full", "sized", "screenshot", "of", "the", "currently", "loaded", "page" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L898-L929
152,471
wirepair/autogcd
tab.go
GetTitle
func (t *Tab) GetTitle() (string, error) { var title string var ok bool resp, err := t.EvaluateScript("window.top.document.title") if err != nil { return "", err } if title, ok = resp.Value.(string); !ok { return "", &ScriptEvaluationErr{Message: "title was not a string", ExceptionText: "unable to retrieve document title, was not a string"} } return title, nil }
go
func (t *Tab) GetTitle() (string, error) { var title string var ok bool resp, err := t.EvaluateScript("window.top.document.title") if err != nil { return "", err } if title, ok = resp.Value.(string); !ok { return "", &ScriptEvaluationErr{Message: "title was not a string", ExceptionText: "unable to retrieve document title, was not a string"} } return title, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetTitle", "(", ")", "(", "string", ",", "error", ")", "{", "var", "title", "string", "\n", "var", "ok", "bool", "\n\n", "resp", ",", "err", ":=", "t", ".", "EvaluateScript", "(", "\"", "\"", ")", "\n", "if", ...
// Returns the top document title
[ "Returns", "the", "top", "document", "title" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L932-L945
152,472
wirepair/autogcd
tab.go
GetFrameResources
func (t *Tab) GetFrameResources() (map[string]string, error) { resources, err := t.Page.GetResourceTree() if err != nil { return nil, err } resourceMap := make(map[string]string) resourceMap[resources.Frame.Id] = resources.Frame.Url recursivelyGetFrameResource(resourceMap, resources) return resourceMap, nil }
go
func (t *Tab) GetFrameResources() (map[string]string, error) { resources, err := t.Page.GetResourceTree() if err != nil { return nil, err } resourceMap := make(map[string]string) resourceMap[resources.Frame.Id] = resources.Frame.Url recursivelyGetFrameResource(resourceMap, resources) return resourceMap, nil }
[ "func", "(", "t", "*", "Tab", ")", "GetFrameResources", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "resources", ",", "err", ":=", "t", ".", "Page", ".", "GetResourceTree", "(", ")", "\n", "if", "err", "!=", "nil", ...
// Gets all frame ids and urls from the top level document.
[ "Gets", "all", "frame", "ids", "and", "urls", "from", "the", "top", "level", "document", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L955-L964
152,473
wirepair/autogcd
tab.go
recursivelyGetFrameResource
func recursivelyGetFrameResource(resourceMap map[string]string, resource *gcdapi.PageFrameResourceTree) { for _, frame := range resource.ChildFrames { resourceMap[frame.Frame.Id] = frame.Frame.Url recursivelyGetFrameResource(resourceMap, frame) } }
go
func recursivelyGetFrameResource(resourceMap map[string]string, resource *gcdapi.PageFrameResourceTree) { for _, frame := range resource.ChildFrames { resourceMap[frame.Frame.Id] = frame.Frame.Url recursivelyGetFrameResource(resourceMap, frame) } }
[ "func", "recursivelyGetFrameResource", "(", "resourceMap", "map", "[", "string", "]", "string", ",", "resource", "*", "gcdapi", ".", "PageFrameResourceTree", ")", "{", "for", "_", ",", "frame", ":=", "range", "resource", ".", "ChildFrames", "{", "resourceMap", ...
// Iterate over frame resources and return a map of id => urls
[ "Iterate", "over", "frame", "resources", "and", "return", "a", "map", "of", "id", "=", ">", "urls" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L967-L972
152,474
wirepair/autogcd
tab.go
GetFrameDocuments
func (t *Tab) GetFrameDocuments() []*Element { frames := make([]*Element, 0) t.eleMutex.RLock() for _, ele := range t.elements { if ok, _ := ele.IsDocument(); ok { frames = append(frames, ele) } } t.eleMutex.RUnlock() return frames }
go
func (t *Tab) GetFrameDocuments() []*Element { frames := make([]*Element, 0) t.eleMutex.RLock() for _, ele := range t.elements { if ok, _ := ele.IsDocument(); ok { frames = append(frames, ele) } } t.eleMutex.RUnlock() return frames }
[ "func", "(", "t", "*", "Tab", ")", "GetFrameDocuments", "(", ")", "[", "]", "*", "Element", "{", "frames", ":=", "make", "(", "[", "]", "*", "Element", ",", "0", ")", "\n", "t", ".", "eleMutex", ".", "RLock", "(", ")", "\n", "for", "_", ",", ...
// Returns all documents as elements that are known.
[ "Returns", "all", "documents", "as", "elements", "that", "are", "known", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L975-L985
152,475
wirepair/autogcd
tab.go
DeleteCookie
func (t *Tab) DeleteCookie(cookieName, url string) error { _, err := t.Page.DeleteCookie(cookieName, url) return err }
go
func (t *Tab) DeleteCookie(cookieName, url string) error { _, err := t.Page.DeleteCookie(cookieName, url) return err }
[ "func", "(", "t", "*", "Tab", ")", "DeleteCookie", "(", "cookieName", ",", "url", "string", ")", "error", "{", "_", ",", "err", ":=", "t", ".", "Page", ".", "DeleteCookie", "(", "cookieName", ",", "url", ")", "\n", "return", "err", "\n", "}" ]
// Deletes the cookie from the browser
[ "Deletes", "the", "cookie", "from", "the", "browser" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L993-L996
152,476
wirepair/autogcd
tab.go
SetUserAgent
func (t *Tab) SetUserAgent(userAgent string) error { _, err := t.Network.SetUserAgentOverrideWithParams(&gcdapi.NetworkSetUserAgentOverrideParams{ UserAgent: userAgent, }) return err }
go
func (t *Tab) SetUserAgent(userAgent string) error { _, err := t.Network.SetUserAgentOverrideWithParams(&gcdapi.NetworkSetUserAgentOverrideParams{ UserAgent: userAgent, }) return err }
[ "func", "(", "t", "*", "Tab", ")", "SetUserAgent", "(", "userAgent", "string", ")", "error", "{", "_", ",", "err", ":=", "t", ".", "Network", ".", "SetUserAgentOverrideWithParams", "(", "&", "gcdapi", ".", "NetworkSetUserAgentOverrideParams", "{", "UserAgent",...
// Override the user agent for requests going out.
[ "Override", "the", "user", "agent", "for", "requests", "going", "out", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L999-L1004
152,477
wirepair/autogcd
tab.go
GetConsoleMessages
func (t *Tab) GetConsoleMessages(messageHandler ConsoleMessageFunc) { t.Subscribe("Console.messageAdded", t.defaultConsoleMessageAdded(messageHandler)) }
go
func (t *Tab) GetConsoleMessages(messageHandler ConsoleMessageFunc) { t.Subscribe("Console.messageAdded", t.defaultConsoleMessageAdded(messageHandler)) }
[ "func", "(", "t", "*", "Tab", ")", "GetConsoleMessages", "(", "messageHandler", "ConsoleMessageFunc", ")", "{", "t", ".", "Subscribe", "(", "\"", "\"", ",", "t", ".", "defaultConsoleMessageAdded", "(", "messageHandler", ")", ")", "\n", "}" ]
// Registers chrome to start retrieving console messages, caller must pass in call back // function to handle it.
[ "Registers", "chrome", "to", "start", "retrieving", "console", "messages", "caller", "must", "pass", "in", "call", "back", "function", "to", "handle", "it", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1008-L1010
152,478
wirepair/autogcd
tab.go
StopConsoleMessages
func (t *Tab) StopConsoleMessages(shouldDisable bool) error { var err error t.Unsubscribe("Console.messageAdded") if shouldDisable { _, err = t.Console.Disable() } return err }
go
func (t *Tab) StopConsoleMessages(shouldDisable bool) error { var err error t.Unsubscribe("Console.messageAdded") if shouldDisable { _, err = t.Console.Disable() } return err }
[ "func", "(", "t", "*", "Tab", ")", "StopConsoleMessages", "(", "shouldDisable", "bool", ")", "error", "{", "var", "err", "error", "\n", "t", ".", "Unsubscribe", "(", "\"", "\"", ")", "\n", "if", "shouldDisable", "{", "_", ",", "err", "=", "t", ".", ...
// Stops the debugger service from sending console messages and closes the channel // Pass shouldDisable as true if you wish to disable Console debugger
[ "Stops", "the", "debugger", "service", "from", "sending", "console", "messages", "and", "closes", "the", "channel", "Pass", "shouldDisable", "as", "true", "if", "you", "wish", "to", "disable", "Console", "debugger" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1014-L1021
152,479
wirepair/autogcd
tab.go
GetNetworkTraffic
func (t *Tab) GetNetworkTraffic(requestHandlerFn NetworkRequestHandlerFunc, responseHandlerFn NetworkResponseHandlerFunc, finishedHandlerFn NetworkFinishedHandlerFunc) error { if requestHandlerFn == nil && responseHandlerFn == nil && finishedHandlerFn == nil { return nil } _, err := t.Network.Enable(maximumTotalBufferSize, maximumResourceBufferSize, maximumPostDataSize) if err != nil { return err } if requestHandlerFn != nil { t.Subscribe("Network.requestWillBeSent", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.NetworkRequestWillBeSentEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params request := &NetworkRequest{RequestId: p.RequestId, FrameId: p.FrameId, LoaderId: p.LoaderId, DocumentURL: p.DocumentURL, Request: p.Request, Timestamp: p.Timestamp, Initiator: p.Initiator, RedirectResponse: p.RedirectResponse, Type: p.Type} requestHandlerFn(t, request) } }) } if responseHandlerFn != nil { t.Subscribe("Network.responseReceived", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.NetworkResponseReceivedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params response := &NetworkResponse{RequestId: p.RequestId, FrameId: p.FrameId, LoaderId: p.LoaderId, Response: p.Response, Timestamp: p.Timestamp, Type: p.Type} responseHandlerFn(t, response) } }) } if finishedHandlerFn != nil { t.Subscribe("Network.loadingFinished", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.NetworkLoadingFinishedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params finishedHandlerFn(t, p.RequestId, p.EncodedDataLength, p.Timestamp) } }) } return nil }
go
func (t *Tab) GetNetworkTraffic(requestHandlerFn NetworkRequestHandlerFunc, responseHandlerFn NetworkResponseHandlerFunc, finishedHandlerFn NetworkFinishedHandlerFunc) error { if requestHandlerFn == nil && responseHandlerFn == nil && finishedHandlerFn == nil { return nil } _, err := t.Network.Enable(maximumTotalBufferSize, maximumResourceBufferSize, maximumPostDataSize) if err != nil { return err } if requestHandlerFn != nil { t.Subscribe("Network.requestWillBeSent", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.NetworkRequestWillBeSentEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params request := &NetworkRequest{RequestId: p.RequestId, FrameId: p.FrameId, LoaderId: p.LoaderId, DocumentURL: p.DocumentURL, Request: p.Request, Timestamp: p.Timestamp, Initiator: p.Initiator, RedirectResponse: p.RedirectResponse, Type: p.Type} requestHandlerFn(t, request) } }) } if responseHandlerFn != nil { t.Subscribe("Network.responseReceived", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.NetworkResponseReceivedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params response := &NetworkResponse{RequestId: p.RequestId, FrameId: p.FrameId, LoaderId: p.LoaderId, Response: p.Response, Timestamp: p.Timestamp, Type: p.Type} responseHandlerFn(t, response) } }) } if finishedHandlerFn != nil { t.Subscribe("Network.loadingFinished", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.NetworkLoadingFinishedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params finishedHandlerFn(t, p.RequestId, p.EncodedDataLength, p.Timestamp) } }) } return nil }
[ "func", "(", "t", "*", "Tab", ")", "GetNetworkTraffic", "(", "requestHandlerFn", "NetworkRequestHandlerFunc", ",", "responseHandlerFn", "NetworkResponseHandlerFunc", ",", "finishedHandlerFn", "NetworkFinishedHandlerFunc", ")", "error", "{", "if", "requestHandlerFn", "==", ...
// Listens to network traffic, each handler can be nil in which case we'll only call the handlers defined.
[ "Listens", "to", "network", "traffic", "each", "handler", "can", "be", "nil", "in", "which", "case", "we", "ll", "only", "call", "the", "handlers", "defined", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1024-L1065
152,480
wirepair/autogcd
tab.go
GetStorageEvents
func (t *Tab) GetStorageEvents(storageFn StorageFunc) error { _, err := t.DOMStorage.Enable() if err != nil { return err } t.Subscribe("Storage.domStorageItemsCleared", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemsClearedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin} storageFn(t, "cleared", storageEvent) } }) t.Subscribe("Storage.domStorageItemRemoved", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemRemovedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin, Key: p.Key} storageFn(t, "removed", storageEvent) } }) t.Subscribe("Storage.domStorageItemAdded", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemAddedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin, Key: p.Key, NewValue: p.NewValue} storageFn(t, "added", storageEvent) } }) t.Subscribe("Storage.domStorageItemUpdated", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemUpdatedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin, Key: p.Key, NewValue: p.NewValue, OldValue: p.OldValue} storageFn(t, "updated", storageEvent) } }) return nil }
go
func (t *Tab) GetStorageEvents(storageFn StorageFunc) error { _, err := t.DOMStorage.Enable() if err != nil { return err } t.Subscribe("Storage.domStorageItemsCleared", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemsClearedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin} storageFn(t, "cleared", storageEvent) } }) t.Subscribe("Storage.domStorageItemRemoved", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemRemovedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin, Key: p.Key} storageFn(t, "removed", storageEvent) } }) t.Subscribe("Storage.domStorageItemAdded", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemAddedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin, Key: p.Key, NewValue: p.NewValue} storageFn(t, "added", storageEvent) } }) t.Subscribe("Storage.domStorageItemUpdated", func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.DOMStorageDomStorageItemUpdatedEvent{} if err := json.Unmarshal(payload, message); err == nil { p := message.Params storageEvent := &StorageEvent{IsLocalStorage: p.StorageId.IsLocalStorage, SecurityOrigin: p.StorageId.SecurityOrigin, Key: p.Key, NewValue: p.NewValue, OldValue: p.OldValue} storageFn(t, "updated", storageEvent) } }) return nil }
[ "func", "(", "t", "*", "Tab", ")", "GetStorageEvents", "(", "storageFn", "StorageFunc", ")", "error", "{", "_", ",", "err", ":=", "t", ".", "DOMStorage", ".", "Enable", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n"...
// Listens for storage events, storageFn should switch on type of cleared, removed, added or updated. // cleared holds IsLocalStorage and SecurityOrigin values only. // removed contains above plus Key. // added contains above plus NewValue. // updated contains above plus OldValue.
[ "Listens", "for", "storage", "events", "storageFn", "should", "switch", "on", "type", "of", "cleared", "removed", "added", "or", "updated", ".", "cleared", "holds", "IsLocalStorage", "and", "SecurityOrigin", "values", "only", ".", "removed", "contains", "above", ...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1085-L1123
152,481
wirepair/autogcd
tab.go
StopStorageEvents
func (t *Tab) StopStorageEvents(shouldDisable bool) error { var err error t.Unsubscribe("Storage.domStorageItemsCleared") t.Unsubscribe("Storage.domStorageItemRemoved") t.Unsubscribe("Storage.domStorageItemAdded") t.Unsubscribe("Storage.domStorageItemUpdated") if shouldDisable { _, err = t.DOMStorage.Disable() } return err }
go
func (t *Tab) StopStorageEvents(shouldDisable bool) error { var err error t.Unsubscribe("Storage.domStorageItemsCleared") t.Unsubscribe("Storage.domStorageItemRemoved") t.Unsubscribe("Storage.domStorageItemAdded") t.Unsubscribe("Storage.domStorageItemUpdated") if shouldDisable { _, err = t.DOMStorage.Disable() } return err }
[ "func", "(", "t", "*", "Tab", ")", "StopStorageEvents", "(", "shouldDisable", "bool", ")", "error", "{", "var", "err", "error", "\n", "t", ".", "Unsubscribe", "(", "\"", "\"", ")", "\n", "t", ".", "Unsubscribe", "(", "\"", "\"", ")", "\n", "t", "."...
// Stops listening for storage events, set shouldDisable to true if you wish to disable DOMStorage debugging.
[ "Stops", "listening", "for", "storage", "events", "set", "shouldDisable", "to", "true", "if", "you", "wish", "to", "disable", "DOMStorage", "debugging", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1126-L1137
152,482
wirepair/autogcd
tab.go
defaultConsoleMessageAdded
func (t *Tab) defaultConsoleMessageAdded(fn ConsoleMessageFunc) GcdResponseFunc { return func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.ConsoleMessageAddedEvent{} err := json.Unmarshal(payload, message) if err == nil { // call the callback handler fn(t, message.Params.Message) } } }
go
func (t *Tab) defaultConsoleMessageAdded(fn ConsoleMessageFunc) GcdResponseFunc { return func(target *gcd.ChromeTarget, payload []byte) { message := &gcdapi.ConsoleMessageAddedEvent{} err := json.Unmarshal(payload, message) if err == nil { // call the callback handler fn(t, message.Params.Message) } } }
[ "func", "(", "t", "*", "Tab", ")", "defaultConsoleMessageAdded", "(", "fn", "ConsoleMessageFunc", ")", "GcdResponseFunc", "{", "return", "func", "(", "target", "*", "gcd", ".", "ChromeTarget", ",", "payload", "[", "]", "byte", ")", "{", "message", ":=", "&...
// handles console messages coming in, responds by calling call back function
[ "handles", "console", "messages", "coming", "in", "responds", "by", "calling", "call", "back", "function" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1157-L1166
152,483
wirepair/autogcd
tab.go
subscribeEvents
func (t *Tab) subscribeEvents() { // DOM Related t.subscribeSetChildNodes() t.subscribeAttributeModified() t.subscribeAttributeRemoved() t.subscribeCharacterDataModified() t.subscribeChildNodeCountUpdated() t.subscribeChildNodeInserted() t.subscribeChildNodeRemoved() t.subscribeDocumentUpdated() // This doesn't seem useful. // t.subscribeInlineStyleInvalidated() // Navigation Related t.subscribeLoadEvent() t.subscribeFrameLoadingEvent() t.subscribeFrameFinishedEvent() // Crash related t.subscribeTargetCrashed() t.subscribeTargetDetached() }
go
func (t *Tab) subscribeEvents() { // DOM Related t.subscribeSetChildNodes() t.subscribeAttributeModified() t.subscribeAttributeRemoved() t.subscribeCharacterDataModified() t.subscribeChildNodeCountUpdated() t.subscribeChildNodeInserted() t.subscribeChildNodeRemoved() t.subscribeDocumentUpdated() // This doesn't seem useful. // t.subscribeInlineStyleInvalidated() // Navigation Related t.subscribeLoadEvent() t.subscribeFrameLoadingEvent() t.subscribeFrameFinishedEvent() // Crash related t.subscribeTargetCrashed() t.subscribeTargetDetached() }
[ "func", "(", "t", "*", "Tab", ")", "subscribeEvents", "(", ")", "{", "// DOM Related", "t", ".", "subscribeSetChildNodes", "(", ")", "\n", "t", ".", "subscribeAttributeModified", "(", ")", "\n", "t", ".", "subscribeAttributeRemoved", "(", ")", "\n", "t", "...
// see tab_subscribers.go
[ "see", "tab_subscribers", ".", "go" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1169-L1191
152,484
wirepair/autogcd
tab.go
listenDebuggerEvents
func (t *Tab) listenDebuggerEvents() { for { select { case nodeChangeEvent := <-t.nodeChange: t.debugf("%s\n", nodeChangeEvent.EventType) t.handleNodeChange(nodeChangeEvent) // if the caller registered a dom change listener, call it if t.domChangeHandler != nil { t.domChangeHandler(t, nodeChangeEvent) } t.lastNodeChangeTimeVal.Store(time.Now()) case reason := <-t.crashedCh: if t.disconnectedHandler != nil { go t.disconnectedHandler(t, reason) } case <-t.exitCh: t.debugf("exiting...") return } } }
go
func (t *Tab) listenDebuggerEvents() { for { select { case nodeChangeEvent := <-t.nodeChange: t.debugf("%s\n", nodeChangeEvent.EventType) t.handleNodeChange(nodeChangeEvent) // if the caller registered a dom change listener, call it if t.domChangeHandler != nil { t.domChangeHandler(t, nodeChangeEvent) } t.lastNodeChangeTimeVal.Store(time.Now()) case reason := <-t.crashedCh: if t.disconnectedHandler != nil { go t.disconnectedHandler(t, reason) } case <-t.exitCh: t.debugf("exiting...") return } } }
[ "func", "(", "t", "*", "Tab", ")", "listenDebuggerEvents", "(", ")", "{", "for", "{", "select", "{", "case", "nodeChangeEvent", ":=", "<-", "t", ".", "nodeChange", ":", "t", ".", "debugf", "(", "\"", "\\n", "\"", ",", "nodeChangeEvent", ".", "EventType...
// Listens for NodeChangeEvents and crash events, dispatches them accordingly. // Calls the user defined domChangeHandler if bound. Updates the lastNodeChangeTime // to the current time. If the target crashes or is detached, call the disconnectedHandler.
[ "Listens", "for", "NodeChangeEvents", "and", "crash", "events", "dispatches", "them", "accordingly", ".", "Calls", "the", "user", "defined", "domChangeHandler", "if", "bound", ".", "Updates", "the", "lastNodeChangeTime", "to", "the", "current", "time", ".", "If", ...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1196-L1216
152,485
wirepair/autogcd
tab.go
handleNodeChange
func (t *Tab) handleNodeChange(change *NodeChangeEvent) { // if we are shutting down, do not handle new node changes. if t.IsShuttingDown() { return } switch change.EventType { case DocumentUpdatedEvent: t.handleDocumentUpdated() case SetChildNodesEvent: t.handleSetChildNodes(change.ParentNodeId, change.Nodes) case AttributeModifiedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.updateAttribute(change.Name, change.Value) } } case AttributeRemovedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.removeAttribute(change.Name) } } case CharacterDataModifiedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.updateCharacterData(change.CharacterData) } } case ChildNodeCountUpdatedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.updateChildNodeCount(change.ChildNodeCount) } // request the child nodes t.requestChildNodes(change.NodeId, 1) } case ChildNodeInsertedEvent: t.handleChildNodeInserted(change.ParentNodeId, change.Node) case ChildNodeRemovedEvent: t.handleChildNodeRemoved(change.ParentNodeId, change.NodeId) } }
go
func (t *Tab) handleNodeChange(change *NodeChangeEvent) { // if we are shutting down, do not handle new node changes. if t.IsShuttingDown() { return } switch change.EventType { case DocumentUpdatedEvent: t.handleDocumentUpdated() case SetChildNodesEvent: t.handleSetChildNodes(change.ParentNodeId, change.Nodes) case AttributeModifiedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.updateAttribute(change.Name, change.Value) } } case AttributeRemovedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.removeAttribute(change.Name) } } case CharacterDataModifiedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.updateCharacterData(change.CharacterData) } } case ChildNodeCountUpdatedEvent: if ele, ok := t.getElement(change.NodeId); ok { if err := ele.WaitForReady(); err == nil { ele.updateChildNodeCount(change.ChildNodeCount) } // request the child nodes t.requestChildNodes(change.NodeId, 1) } case ChildNodeInsertedEvent: t.handleChildNodeInserted(change.ParentNodeId, change.Node) case ChildNodeRemovedEvent: t.handleChildNodeRemoved(change.ParentNodeId, change.NodeId) } }
[ "func", "(", "t", "*", "Tab", ")", "handleNodeChange", "(", "change", "*", "NodeChangeEvent", ")", "{", "// if we are shutting down, do not handle new node changes.", "if", "t", ".", "IsShuttingDown", "(", ")", "{", "return", "\n", "}", "\n\n", "switch", "change",...
// handle node change events, updating, inserting invalidating and removing
[ "handle", "node", "change", "events", "updating", "inserting", "invalidating", "and", "removing" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1219-L1262
152,486
wirepair/autogcd
tab.go
handleSetChildNodes
func (t *Tab) handleSetChildNodes(parentNodeId int, nodes []*gcdapi.DOMNode) { for _, node := range nodes { t.addNodes(node) } parent, ok := t.GetElementByNodeId(parentNodeId) if ok { if err := parent.WaitForReady(); err == nil { parent.addChildren(nodes) } } t.lastNodeChangeTimeVal.Store(time.Now()) }
go
func (t *Tab) handleSetChildNodes(parentNodeId int, nodes []*gcdapi.DOMNode) { for _, node := range nodes { t.addNodes(node) } parent, ok := t.GetElementByNodeId(parentNodeId) if ok { if err := parent.WaitForReady(); err == nil { parent.addChildren(nodes) } } t.lastNodeChangeTimeVal.Store(time.Now()) }
[ "func", "(", "t", "*", "Tab", ")", "handleSetChildNodes", "(", "parentNodeId", "int", ",", "nodes", "[", "]", "*", "gcdapi", ".", "DOMNode", ")", "{", "for", "_", ",", "node", ":=", "range", "nodes", "{", "t", ".", "addNodes", "(", "node", ")", "\n...
// setChildNode event handling will add nodes to our elements map and update // the parent reference Children
[ "setChildNode", "event", "handling", "will", "add", "nodes", "to", "our", "elements", "map", "and", "update", "the", "parent", "reference", "Children" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1266-L1278
152,487
wirepair/autogcd
tab.go
handleDocumentUpdated
func (t *Tab) handleDocumentUpdated() { // set all elements as invalid and destroy the Elements map. t.eleMutex.Lock() for _, ele := range t.elements { ele.setInvalidated(true) } t.elements = make(map[int]*Element) t.eleMutex.Unlock() t.documentUpdated() // notify if navigating that we received the document update event. if t.IsNavigating() { t.docUpdateCh <- struct{}{} // notify listeners document was updated } }
go
func (t *Tab) handleDocumentUpdated() { // set all elements as invalid and destroy the Elements map. t.eleMutex.Lock() for _, ele := range t.elements { ele.setInvalidated(true) } t.elements = make(map[int]*Element) t.eleMutex.Unlock() t.documentUpdated() // notify if navigating that we received the document update event. if t.IsNavigating() { t.docUpdateCh <- struct{}{} // notify listeners document was updated } }
[ "func", "(", "t", "*", "Tab", ")", "handleDocumentUpdated", "(", ")", "{", "// set all elements as invalid and destroy the Elements map.", "t", ".", "eleMutex", ".", "Lock", "(", ")", "\n", "for", "_", ",", "ele", ":=", "range", "t", ".", "elements", "{", "e...
// Handles the document updated event. This occurs after a navigation or redirect. // This is a destructive action which invalidates all document nodeids and their children. // We loop through our current list of elements and invalidate them so any references // can check if they are valid or not. We then recreate the elements map. Finally, if we // are navigating, we want to block Navigate from returning until we have a valid document, // so we use the docUpdateCh to signal when complete.
[ "Handles", "the", "document", "updated", "event", ".", "This", "occurs", "after", "a", "navigation", "or", "redirect", ".", "This", "is", "a", "destructive", "action", "which", "invalidates", "all", "document", "nodeids", "and", "their", "children", ".", "We",...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1286-L1300
152,488
wirepair/autogcd
tab.go
handleChildNodeInserted
func (t *Tab) handleChildNodeInserted(parentNodeId int, node *gcdapi.DOMNode) { t.lastNodeChangeTimeVal.Store(time.Now()) if node == nil { return } t.debugf("child node inserted: id: %d\n", node.NodeId) t.addNodes(node) parent, _ := t.GetElementByNodeId(parentNodeId) // make sure we have the parent before we add children if err := parent.WaitForReady(); err == nil { parent.addChild(node) return } else { t.debugf("err: %s\n", err) } t.debugf("unable to add child %d to parent %d because parent is not ready yet", node.NodeId, parentNodeId) }
go
func (t *Tab) handleChildNodeInserted(parentNodeId int, node *gcdapi.DOMNode) { t.lastNodeChangeTimeVal.Store(time.Now()) if node == nil { return } t.debugf("child node inserted: id: %d\n", node.NodeId) t.addNodes(node) parent, _ := t.GetElementByNodeId(parentNodeId) // make sure we have the parent before we add children if err := parent.WaitForReady(); err == nil { parent.addChild(node) return } else { t.debugf("err: %s\n", err) } t.debugf("unable to add child %d to parent %d because parent is not ready yet", node.NodeId, parentNodeId) }
[ "func", "(", "t", "*", "Tab", ")", "handleChildNodeInserted", "(", "parentNodeId", "int", ",", "node", "*", "gcdapi", ".", "DOMNode", ")", "{", "t", ".", "lastNodeChangeTimeVal", ".", "Store", "(", "time", ".", "Now", "(", ")", ")", "\n", "if", "node",...
// update parent with new child node and add the new nodes.
[ "update", "parent", "with", "new", "child", "node", "and", "add", "the", "new", "nodes", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1303-L1321
152,489
wirepair/autogcd
tab.go
invalidateChildren
func (t *Tab) invalidateChildren(node *gcdapi.DOMNode) { // invalidate & remove ContentDocument node and children if node.ContentDocument != nil { ele, ok := t.getElement(node.ContentDocument.NodeId) if ok { t.invalidateRemove(ele) t.invalidateChildren(node.ContentDocument) } } if node.Children == nil { return } // invalidate node.Children for _, child := range node.Children { ele, ok := t.getElement(child.NodeId) if !ok { continue } t.invalidateRemove(ele) // recurse and remove children of this node t.invalidateChildren(ele.node) } }
go
func (t *Tab) invalidateChildren(node *gcdapi.DOMNode) { // invalidate & remove ContentDocument node and children if node.ContentDocument != nil { ele, ok := t.getElement(node.ContentDocument.NodeId) if ok { t.invalidateRemove(ele) t.invalidateChildren(node.ContentDocument) } } if node.Children == nil { return } // invalidate node.Children for _, child := range node.Children { ele, ok := t.getElement(child.NodeId) if !ok { continue } t.invalidateRemove(ele) // recurse and remove children of this node t.invalidateChildren(ele.node) } }
[ "func", "(", "t", "*", "Tab", ")", "invalidateChildren", "(", "node", "*", "gcdapi", ".", "DOMNode", ")", "{", "// invalidate & remove ContentDocument node and children", "if", "node", ".", "ContentDocument", "!=", "nil", "{", "ele", ",", "ok", ":=", "t", ".",...
// when a childNodeRemoved event occurs, we need to set each child // to invalidated and remove it from our elements map.
[ "when", "a", "childNodeRemoved", "event", "occurs", "we", "need", "to", "set", "each", "child", "to", "invalidated", "and", "remove", "it", "from", "our", "elements", "map", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1353-L1377
152,490
wirepair/autogcd
tab.go
invalidateRemove
func (t *Tab) invalidateRemove(ele *Element) { t.debugf("invalidating nodeId: %d\n", ele.id) ele.setInvalidated(true) t.eleMutex.Lock() delete(t.elements, ele.id) t.eleMutex.Unlock() }
go
func (t *Tab) invalidateRemove(ele *Element) { t.debugf("invalidating nodeId: %d\n", ele.id) ele.setInvalidated(true) t.eleMutex.Lock() delete(t.elements, ele.id) t.eleMutex.Unlock() }
[ "func", "(", "t", "*", "Tab", ")", "invalidateRemove", "(", "ele", "*", "Element", ")", "{", "t", ".", "debugf", "(", "\"", "\\n", "\"", ",", "ele", ".", "id", ")", "\n", "ele", ".", "setInvalidated", "(", "true", ")", "\n", "t", ".", "eleMutex",...
// Sets the element as invalid and removes it from our elements map
[ "Sets", "the", "element", "as", "invalid", "and", "removes", "it", "from", "our", "elements", "map" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1380-L1386
152,491
wirepair/autogcd
tab.go
requestChildNodes
func (t *Tab) requestChildNodes(nodeId, depth int) { _, err := t.DOM.RequestChildNodes(nodeId, depth, false) if err != nil { t.debugf("error requesting child nodes: %s\n", err) } }
go
func (t *Tab) requestChildNodes(nodeId, depth int) { _, err := t.DOM.RequestChildNodes(nodeId, depth, false) if err != nil { t.debugf("error requesting child nodes: %s\n", err) } }
[ "func", "(", "t", "*", "Tab", ")", "requestChildNodes", "(", "nodeId", ",", "depth", "int", ")", "{", "_", ",", "err", ":=", "t", ".", "DOM", ".", "RequestChildNodes", "(", "nodeId", ",", "depth", ",", "false", ")", "\n", "if", "err", "!=", "nil", ...
// Ask the debugger service for child nodes.
[ "Ask", "the", "debugger", "service", "for", "child", "nodes", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1395-L1400
152,492
wirepair/autogcd
tab.go
nodeToElement
func (t *Tab) nodeToElement(node *gcdapi.DOMNode) *Element { if ele, ok := t.getElement(node.NodeId); ok { ele.populateElement(node) return ele } newEle := newReadyElement(t, node) return newEle }
go
func (t *Tab) nodeToElement(node *gcdapi.DOMNode) *Element { if ele, ok := t.getElement(node.NodeId); ok { ele.populateElement(node) return ele } newEle := newReadyElement(t, node) return newEle }
[ "func", "(", "t", "*", "Tab", ")", "nodeToElement", "(", "node", "*", "gcdapi", ".", "DOMNode", ")", "*", "Element", "{", "if", "ele", ",", "ok", ":=", "t", ".", "getElement", "(", "node", ".", "NodeId", ")", ";", "ok", "{", "ele", ".", "populate...
// Called if the element is known about but not yet populated. If it is not // known, we create a new element. If it is known we populate it and return it.
[ "Called", "if", "the", "element", "is", "known", "about", "but", "not", "yet", "populated", ".", "If", "it", "is", "not", "known", "we", "create", "a", "new", "element", ".", "If", "it", "is", "known", "we", "populate", "it", "and", "return", "it", "...
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1404-L1411
152,493
wirepair/autogcd
tab.go
getElement
func (t *Tab) getElement(nodeId int) (*Element, bool) { t.eleMutex.RLock() defer t.eleMutex.RUnlock() ele, ok := t.elements[nodeId] return ele, ok }
go
func (t *Tab) getElement(nodeId int) (*Element, bool) { t.eleMutex.RLock() defer t.eleMutex.RUnlock() ele, ok := t.elements[nodeId] return ele, ok }
[ "func", "(", "t", "*", "Tab", ")", "getElement", "(", "nodeId", "int", ")", "(", "*", "Element", ",", "bool", ")", "{", "t", ".", "eleMutex", ".", "RLock", "(", ")", "\n", "defer", "t", ".", "eleMutex", ".", "RUnlock", "(", ")", "\n", "ele", ",...
// safely returns the element by looking it up by nodeId from our internal map.
[ "safely", "returns", "the", "element", "by", "looking", "it", "up", "by", "nodeId", "from", "our", "internal", "map", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/tab.go#L1414-L1419
152,494
appc/goaci
proj2aci/binary.go
GetBinaryName
func GetBinaryName(binDir, useBinary string) (string, error) { fi, err := ioutil.ReadDir(binDir) if err != nil { return "", err } switch { case len(fi) < 1: return "", fmt.Errorf("No binaries found in %q", binDir) case len(fi) == 1: name := fi[0].Name() if useBinary != "" && name != useBinary { return "", fmt.Errorf("No such binary found in %q: %q. There is only %q", binDir, useBinary, name) } Debug("found binary: ", name) return name, nil case len(fi) > 1: names := []string{} for _, v := range fi { names = append(names, v.Name()) } if useBinary == "" { return "", fmt.Errorf("Found multiple binaries in %q, but no specific binary is preferred. Please specify which binary to pick up. Following binaries are available: %q", binDir, strings.Join(names, `", "`)) } for _, v := range names { if v == useBinary { return v, nil } } return "", fmt.Errorf("No such binary found in %q: %q. There are following binaries available: %q", binDir, useBinary, strings.Join(names, `", "`)) } panic("Reaching this point shouldn't be possible.") }
go
func GetBinaryName(binDir, useBinary string) (string, error) { fi, err := ioutil.ReadDir(binDir) if err != nil { return "", err } switch { case len(fi) < 1: return "", fmt.Errorf("No binaries found in %q", binDir) case len(fi) == 1: name := fi[0].Name() if useBinary != "" && name != useBinary { return "", fmt.Errorf("No such binary found in %q: %q. There is only %q", binDir, useBinary, name) } Debug("found binary: ", name) return name, nil case len(fi) > 1: names := []string{} for _, v := range fi { names = append(names, v.Name()) } if useBinary == "" { return "", fmt.Errorf("Found multiple binaries in %q, but no specific binary is preferred. Please specify which binary to pick up. Following binaries are available: %q", binDir, strings.Join(names, `", "`)) } for _, v := range names { if v == useBinary { return v, nil } } return "", fmt.Errorf("No such binary found in %q: %q. There are following binaries available: %q", binDir, useBinary, strings.Join(names, `", "`)) } panic("Reaching this point shouldn't be possible.") }
[ "func", "GetBinaryName", "(", "binDir", ",", "useBinary", "string", ")", "(", "string", ",", "error", ")", "{", "fi", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "binDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "e...
// GetBinaryName checks if useBinary is in binDir and returns it. If // useBinary is empty it returns a binary name if there is only one // such in binDir. Otherwise it returns an error.
[ "GetBinaryName", "checks", "if", "useBinary", "is", "in", "binDir", "and", "returns", "it", ".", "If", "useBinary", "is", "empty", "it", "returns", "a", "binary", "name", "if", "there", "is", "only", "one", "such", "in", "binDir", ".", "Otherwise", "it", ...
a9f06a2e5e7e897acc6a1fbcf21236a406315111
https://github.com/appc/goaci/blob/a9f06a2e5e7e897acc6a1fbcf21236a406315111/proj2aci/binary.go#L26-L58
152,495
appc/goaci
proj2aci/vcs.go
getId
func getId(dir, cmd string, params []string) (string, error) { args := []string{cmd} args = append(args, params...) buffer := new(bytes.Buffer) cmdPath, err := exec.LookPath(cmd) if err != nil { return "", nil } process := &exec.Cmd{ Path: cmdPath, Args: args, Env: []string{ "PATH=" + os.Getenv("PATH"), }, Dir: dir, Stdout: buffer, } if err := process.Run(); err != nil { return "", err } output := string(buffer.Bytes()) if newline := strings.Index(output, "\n"); newline < 0 { return output, nil } else { return output[:newline], nil } }
go
func getId(dir, cmd string, params []string) (string, error) { args := []string{cmd} args = append(args, params...) buffer := new(bytes.Buffer) cmdPath, err := exec.LookPath(cmd) if err != nil { return "", nil } process := &exec.Cmd{ Path: cmdPath, Args: args, Env: []string{ "PATH=" + os.Getenv("PATH"), }, Dir: dir, Stdout: buffer, } if err := process.Run(); err != nil { return "", err } output := string(buffer.Bytes()) if newline := strings.Index(output, "\n"); newline < 0 { return output, nil } else { return output[:newline], nil } }
[ "func", "getId", "(", "dir", ",", "cmd", "string", ",", "params", "[", "]", "string", ")", "(", "string", ",", "error", ")", "{", "args", ":=", "[", "]", "string", "{", "cmd", "}", "\n", "args", "=", "append", "(", "args", ",", "params", "...", ...
// getId gets first line of commands output which should hold some VCS // specific id of current code checkout.
[ "getId", "gets", "first", "line", "of", "commands", "output", "which", "should", "hold", "some", "VCS", "specific", "id", "of", "current", "code", "checkout", "." ]
a9f06a2e5e7e897acc6a1fbcf21236a406315111
https://github.com/appc/goaci/blob/a9f06a2e5e7e897acc6a1fbcf21236a406315111/proj2aci/vcs.go#L37-L63
152,496
wirepair/autogcd
settings.go
NewSettings
func NewSettings(chromePath, userDir string) *Settings { s := &Settings{} s.chromePath = chromePath s.chromePort = "9222" s.userDir = userDir s.removeUserDir = false s.extensions = make([]string, 0) s.flags = make([]string, 0) s.env = make([]string, 0) return s }
go
func NewSettings(chromePath, userDir string) *Settings { s := &Settings{} s.chromePath = chromePath s.chromePort = "9222" s.userDir = userDir s.removeUserDir = false s.extensions = make([]string, 0) s.flags = make([]string, 0) s.env = make([]string, 0) return s }
[ "func", "NewSettings", "(", "chromePath", ",", "userDir", "string", ")", "*", "Settings", "{", "s", ":=", "&", "Settings", "{", "}", "\n", "s", ".", "chromePath", "=", "chromePath", "\n", "s", ".", "chromePort", "=", "\"", "\"", "\n", "s", ".", "user...
// Creates a new settings object to start Chrome and enable remote debugging
[ "Creates", "a", "new", "settings", "object", "to", "start", "Chrome", "and", "enable", "remote", "debugging" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/settings.go#L46-L56
152,497
wirepair/autogcd
settings.go
SetInstance
func (s *Settings) SetInstance(host, port string) { s.chromeHost = host s.chromePort = port s.connectToInstance = true }
go
func (s *Settings) SetInstance(host, port string) { s.chromeHost = host s.chromePort = port s.connectToInstance = true }
[ "func", "(", "s", "*", "Settings", ")", "SetInstance", "(", "host", ",", "port", "string", ")", "{", "s", ".", "chromeHost", "=", "host", "\n", "s", ".", "chromePort", "=", "port", "\n", "s", ".", "connectToInstance", "=", "true", "\n", "}" ]
//Set a instance to connect to other than start a new process
[ "Set", "a", "instance", "to", "connect", "to", "other", "than", "start", "a", "new", "process" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/settings.go#L59-L63
152,498
wirepair/autogcd
settings.go
AddStartupFlags
func (s *Settings) AddStartupFlags(flags []string) { s.flags = append(s.flags, flags...) }
go
func (s *Settings) AddStartupFlags(flags []string) { s.flags = append(s.flags, flags...) }
[ "func", "(", "s", "*", "Settings", ")", "AddStartupFlags", "(", "flags", "[", "]", "string", ")", "{", "s", ".", "flags", "=", "append", "(", "s", ".", "flags", ",", "flags", "...", ")", "\n", "}" ]
// Adds custom flags when starting the chrome process
[ "Adds", "custom", "flags", "when", "starting", "the", "chrome", "process" ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/settings.go#L90-L92
152,499
wirepair/autogcd
settings.go
AddExtension
func (s *Settings) AddExtension(paths []string) { for _, ext := range paths { s.extensions = append(s.extensions, fmt.Sprintf("--load-extension=%s", ext)) } }
go
func (s *Settings) AddExtension(paths []string) { for _, ext := range paths { s.extensions = append(s.extensions, fmt.Sprintf("--load-extension=%s", ext)) } }
[ "func", "(", "s", "*", "Settings", ")", "AddExtension", "(", "paths", "[", "]", "string", ")", "{", "for", "_", ",", "ext", ":=", "range", "paths", "{", "s", ".", "extensions", "=", "append", "(", "s", ".", "extensions", ",", "fmt", ".", "Sprintf",...
// Adds a custom extension to launch with chrome. Note this extension MAY NOT USE // the chrome.debugger API since you can not attach debuggers to a Tab twice.
[ "Adds", "a", "custom", "extension", "to", "launch", "with", "chrome", ".", "Note", "this", "extension", "MAY", "NOT", "USE", "the", "chrome", ".", "debugger", "API", "since", "you", "can", "not", "attach", "debuggers", "to", "a", "Tab", "twice", "." ]
80392884ea9402ba4b8ecb1eccf361611b171df8
https://github.com/wirepair/autogcd/blob/80392884ea9402ba4b8ecb1eccf361611b171df8/settings.go#L96-L100