| 1 | <$mt:var name="user-auth" value="signin-content"$> |
|---|
| 2 | // The cookie name to use for storing the blog-side comment session cookie. |
|---|
| 3 | var mtCookieName = "<$mt:UserSessionCookieName$>"; |
|---|
| 4 | var mtCookieDomain = "<$mt:UserSessionCookieDomain$>"; |
|---|
| 5 | var mtCookiePath = "<$mt:UserSessionCookiePath$>"; |
|---|
| 6 | var mtCookieTimeout = <$mt:UserSessionCookieTimeout$>; |
|---|
| 7 | var is_preview; |
|---|
| 8 | var user; |
|---|
| 9 | |
|---|
| 10 | var mtFetchedUser = false; |
|---|
| 11 | function mtFetchUser(cb) // Issues a request to the MT comment script to retrieve the currently logged-in user (if any). |
|---|
| 12 | function mtUpdateSignInWidget(u) // A routine that displays various phrases based upon users authenticated status |
|---|
| 13 | function mtGetUser() // Retrieves an object of the currently logged in user's state. If no user is logged in or cookied, this will return null. |
|---|
| 14 | function mtSetUser(u) // Assigns a user object as the actively logged in user; also saves the user information in a browser cookie. |
|---|
| 15 | function mtSaveUser(f) // Persists a copy of the current user cookie into the browser cookie stash. |
|---|
| 16 | function mtSignIn() // Handles the action of the "Sign in" link. First clears any existing user cookie, then directs to the MT comment script to sign the user in. |
|---|
| 17 | function mtSignInOnClick(sign_in_element) // |
|---|
| 18 | function mtSetUserOrLogin(u) // |
|---|
| 19 | function mtSignOut(entry_id) // Handles sign out from the web site. First clears any existing user cookie, then direts to the MT comment script to sign the user out. |
|---|
| 20 | function mtSignOutOnClick() // Handles the action of the "Sign out" link. |
|---|
| 21 | |
|---|
| 22 | /* Cookie *****************************************************************/ |
|---|
| 23 | |
|---|
| 24 | function mtSaveUser(f) // Persists a copy of the current user cookie into the browser cookie stash. |
|---|
| 25 | function mtClearUser() // Clears the blog-side user cookie. |
|---|
| 26 | function mtSetCookie(name, value, expires, path, domain, secure) // Sets a browser cookie. |
|---|
| 27 | function mtGetCookie(name) // Retrieves a browser cookie. |
|---|
| 28 | function mtDeleteCookie(name, path, domain, secure) // Deletes a browser cookie. |
|---|
| 29 | function mtBakeUserCookie(u) // Serializes a user object into a string, suitable for storing as a cookie. |
|---|
| 30 | function mtUnbakeUserCookie(s) // Unserializes a user cookie and returns a user object with the restored state. |
|---|
| 31 | |
|---|
| 32 | /* Utility Functions *****************************************************************/ |
|---|
| 33 | |
|---|
| 34 | function mtFireEvent(eventName,param) // Calls the event named, if there are handlers for it. |
|---|
| 35 | function mtFixDate(date) // |
|---|
| 36 | function mtEscapeJS(s) // Simple function that escapes single quote characters for storing in a cookie. |
|---|
| 37 | function mtUnescapeJS(s) // Simple function that unescapes single quote characters that were stored in a cookie. |
|---|
| 38 | function mtAttachEvent(eventName,func) // A utility function for assigning/adding handlers to window events. |
|---|