Skip to content

Contributing

shu8 edited this page Feb 11, 2016 · 13 revisions

###Welcome to the SOX Contributing Wiki!

It's really easy to contribute to SOX -- just follow some simple steps:

  1. Write a function that implements the new feature you're adding. Give it a simple, unique name in CamelCase
  2. Add it to the bottom of sox.features.js
  3. If you have any extra CSS that you need, add it at the bottom of sox.css
  4. Add the function ID to sox.user.js, in the correct category at the bottom of the file. Make sure you add a description.
  5. Submit a pull request. The changes will be checked and should be pushed in the next dev or main version.

Some rules...

  • A short description of the function (the same you add to sox.user.js) should be added on the first line of the function, in the form of: // Description: [description here]
  • All functions should run within their defined areas, eg. not running unless they need to
  • CSS rule definitions should be prepended with the name of the function for which they are defined. eg .functionName-element

###Helper Functions

SOX has a few helper functions added to it to make it easy to determine common things. You can see these at https://github.com/soscripted/sox/blob/master/sox.helpers.js.

Note: * means the function returns false if the user is not logged in.

  • getUsername()*: returns the logged in user's display name
  • getReputation()*: returns the logged in user's reputation
  • getSiteName(type): if type is api, it will return the api sitename (eg. meta or stackoverflow), else it will return the normal site name (eg. Meta Stack Exchange or Stack Overflow)
  • getSiteType(): returns beta or graduated, depending on the site's status
  • getQuestionId(): returns the question ID
  • isLoggedIn(): returns true if the user is logged in, else it returns false
  • isOnUserProfile(): returns true if the user is on the profile page, else it returns false
  • isOnChat(): returns true if the user is on a chat page, else it returns false
  • hasPriv(priv)*: please see the source to see what the priv parameter may be. This function returns true if the logged in user has the reputation points required to have a certain priv, else it returns false.

Clone this wiki locally