Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function parseTags(text) {
- var inTag,
- afterOpenTag,
- afterClosingTag,
- inUpperCase,
- inLowerCase,
- inMixCase,
- i,
- len,
- trueOrFalse,
- result = '',
- ;
- for (i = 0, len = text.length; i < len; i += 1) {
- if (text[i] === '<') {
- inTag = true;
- afterOpenTag = true;
- }
- if(inTag && afterOpenTag && text[i] === '/'){
- afterClosingTag = true;
- afterOpenTag = false;
- }
- if (inTag && afterOpenTag && text[i] === 'u') {
- inUpperCase = true;
- afterOpenTag = false;
- }
- if (inTag && afterOpenTag && text[i] === 'l') {
- inLowerCase = true;
- afterOpenTag = false;
- }
- if (inTag && afterOpenTag && text[i] === 'm') {
- inMixCase = true;
- afterOpenTag = false;
- }
- if (inTag && afterClosingTag && text[i] === 'u') {
- inUpperCase = false;
- afterClosingTag = false;
- }
- if (inTag && afterClosingTag && text[i] === 'l') {
- inLowerCase = false;
- afterClosingTag = false;
- }
- if (inTag && afterClosingTag && text[i] === 'm') {
- inMixCase = false;
- afterClosingTag = false;
- console.log("close mix " + inMixCase);
- }
- if (!inTag && inUpperCase) {
- result += text[i].toUpperCase();
- }
- if (!inTag && inLowerCase) {
- result += text[i].toLowerCase();
- }
- if (!inTag && inMixCase) {
- console.log("in mix " + inMixCase);
- trueOrFalse = Math.round(Math.random());
- if (trueOrFalse) {
- result += text[i].toUpperCase();
- } else {
- result += text[i].toLowerCase();
- }
- }
- if (!inTag && !inLowerCase && !inUpperCase && !inMixCase) {
- result += text[i];
- }
- if (text[i] === '>') {
- inTag = false;
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement