Coder Social home page Coder Social logo

text-separator's Introduction

Text-Separator

Amends a string of text with additional characters

TO-DO

Add more features
Improve design
Add 'Copy to clipboard'

Changelog

Added Regex conditioning
Code tweaks
Created functions for each separator
Added conditioning to ignore white space
Added to split() function with replace() function and changed regex to array spaces as well as new line
Added maxLength condition to stringArray to limit the input of Array elements
Minor HTML Tweaks
JS revamping
Resigned page

text-separator's People

Contributors

dave-melia avatar matt-major avatar

Watchers

James Cloos avatar  avatar

text-separator's Issues

Improvements to JavaScript Function

I'd suggest changing your function "change()" in "func.js" to the below instead.

(comments excluded for brevity)

  • Comma seperated variable declarations rather than individual. See: https://gist.github.com/cowboy/2588448#comment-298923
  • Storing the DOM element rather than just the value.
  • Change to if() else if ().. to use the elements you have already retrieved from the DOM and just calling their value. No need to re-get them each time you require to use them.
function change() {
    var string_input = (document.getElementById('string_input')),
        stringArray = string_input.value.replace(/^\s+|\s+$/g, '').split(/\s+/),
        radio_comma = document.getElementById("radioComma"),
        radio_singlequote = document.getElementById("radioSingleQuote"),
        radio_dash = document.getElementById("radioDash");

    if (radio_comma.checked) {
        string_output = stringArray.join(radio_comma.value);
    } 
    else if (radio_singlequote.checked) {
        string_output = stringArray.toSingleQuotedString();
    }
    else if (radio_dash.checked) {
        string_output = stringArray.join(radio_dash.value);
    }

    document.getElementById("string_output").value = (string_output);
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.