Skip to content

Instantly share code, notes, and snippets.

@marbiano
Last active June 22, 2020 02:27
Show Gist options
  • Save marbiano/a28b62ab7cd1aa8b890a011a94db5f6f to your computer and use it in GitHub Desktop.
Save marbiano/a28b62ab7cd1aa8b890a011a94db5f6f to your computer and use it in GitHub Desktop.
Roam demo page with script for tweet chars count
[{"title":"Tweets","children":[{"string":"{{[[roam/js]]}}","create-email":"[email protected]","create-time":1592792246237,"children":[{"string":"Hit `Yes, I know what I'm doing` and enjoy some basic color help while you are writing your tweets.","create-email":"[email protected]","create-time":1592792290376,"uid":"U8O8Mpkwr","edit-time":1592792374917,"edit-email":"[email protected]"},{"string":"This a an example, feel free to edit it and take it up to 280...","create-email":"[email protected]","create-time":1592792377871,"uid":"C4u85Uuc6","edit-time":1592792474950,"edit-email":"[email protected]"},{"string":"","create-email":"[email protected]","create-time":1592792435910,"uid":"MJ6jzGVk9","edit-time":1592792435910,"edit-email":"[email protected]"},{"string":"```javascript\nvar max_size = 280;\nfunction testTweets(e) {\n var el = e.target;\n console.log(el);\n if(el.classList.contains('rm-block-input')) {\n var length = el.value.length;\n console.log(length);\n console.log(max_size);\n if (length > max_size) {\n \tconsole.log(\"this is too long\", el.value.length);\n \tel.style.color = 'red';\n \t} else if(length > max_size - 10) {\n \tel.style.color = 'green';\n } else {\n if(el.style.color === 'red' || el.style.color === 'green') {\n el.style.color = 'inherit'\n }\n }\n } \n}\n\ndocument.body.removeEventListener('keyup', testTweets);\ndocument.body.addEventListener('keyup', testTweets, true);```","create-email":"[email protected]","create-time":1592678264534,"uid":"obNP546md","edit-time":1592792316257,"edit-email":"[email protected]"}],"uid":"IY-6ta0dv","edit-time":1592792271214,"edit-email":"[email protected]"}],"edit-time":1592792229511,"edit-email":"[email protected]"}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment