forked from tgstation/tgstation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port simple files to es6; factor out Babel helpers
- Loading branch information
1 parent
3c48317
commit 22dff9d
Showing
15 changed files
with
62 additions
and
48 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const encode = encodeURIComponent | ||
|
||
// Helper to generate a BYOND href given 'params' as an object (with an optional 'url' for eg winset). | ||
export function href (params = {}, url = '') { | ||
return `byond://${url}?` + Object.keys(params).map(key => `${encode(key)}=#{encode(params[key])}`).join("&") | ||
} | ||
|
||
// Helper to make a BYOND ui_act() call on the UI 'src' given an 'action' and optional 'params'. | ||
export function act (src, action, params = {}) { | ||
params.src = src | ||
params.action = action | ||
location.href = href(params) | ||
} | ||
|
||
// Helper to make a BYOND winset() call on 'window', setting 'key' to 'value' | ||
export function winset (window, key, value) { | ||
location.href = href({[`${window}.${key}`]: value}, "winset") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Constants used in tgui; these are mirrored from the BYOND code. | ||
export const UI_INTERACTIVE = 2 | ||
export const UI_UPDATE = 1 | ||
export const UI_DISABLED = 0 | ||
export const UI_CLOSE = -1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Extensions to the built-in 'Math' object. | ||
|
||
// Helper to limit a number to be inside 'min' and 'max'. | ||
export function clamp (min, max) { | ||
return Math.max(min, Math.min(number, max)) | ||
} | ||
|
||
// Helper to round a number to 'decimals' decimals. | ||
export function fixed (number, decimals = 1) { | ||
return Number(Math.round(number + 'e' + decimals) + 'e-' + decimals) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function upperCaseFirst (str) { | ||
return str[0].toUpperCase() + str.slice(1).toLowerCase() | ||
} | ||
export function titleCase (str) { | ||
return str.replace(/\w\S*/g, upperCaseFirst) | ||
} |