Git Product home page Git Product logo

codestory's People

Contributors

nickbradley avatar

Watchers

 avatar

codestory's Issues

2017-02-06 status

@nickbradley - I did some research and a first implementation on the copy operation.

What:

  • Tampermonkey JS module
  • Listener on copy operation, when invoked:
    -- collects most of the content defined in our survey as JS object
    -- saves the original copied text in the same object
    -- puts the JSON-serialized JS object into the default clipboard

Example:

{
  "origin": "CodeStory",
  "originalSelection": "last_nom",
  "questionUrl": "http://stackoverflow.com/questions/1129216/sort-array-of-objects-by-string-property-value-in-javascript",
  "questionContent": "\n\nI have an array of JavaScript objects:\n\nvar objs = [ \n    { first_nom: 'Lazslo', last_nom: 'Jamf'     },\n    { first_nom: 'Pig',    last_nom: 'Bodine'   },\n    { first_nom: 'Pirate', last_nom: 'Prentice' }\n];\n\nHow can I sort them by the value of last_nom in JavaScript?\n\nI know about sort(a,b), but that only seems to work on strings and numbers. Do I need to add a toString method to my objects?\n    ",
  "answerUrl": "http://stackoverflow.com//a/1129270/1105907",
  "accessTime": 1486431788128,
  "fullCodeSnippet": "function compare(a,b) {\n  if (a.last_nom < b.last_nom)\n    return -1;\n  if (a.last_nom > b.last_nom)\n    return 1;\n  return 0;\n}\n\nobjs.sort(compare);",
  "answerContent": "\nIt's easy enough to write your own comparison function:\n\nfunction compare(a,b) {\n  if (a.last_nom < b.last_nom)\n    return -1;\n  if (a.last_nom > b.last_nom)\n    return 1;\n  return 0;\n}\n\nobjs.sort(compare);\n\nOr inline (c/o Marco Demaio): \n\nobjs.sort(function(a,b) {return (a.last_nom > b.last_nom) ? 1 : ((b.last_nom > a.last_nom) ? -1 : 0);} ); \n    ",
  "votes": 1749,
  "accepted": true
}

Issues:

  • It uses the default clipboard, so at the moment...
    -- we're messing with the default copy/paste operation
    -- default clipboard content can still be accessed on the JSON object in the clipboard
    -- but the default paste operation of the OS would definitely insert the JSON string upon default paste
  • I checked for other options, but I'm doubting there is another way:
    -- Saving to files from JS or Chrome Add-Ons is almost a no-go apparently
    -- I think the clipboard is really just a simple text (at least on Mac I can't find anything on the web that would say it's more than that)
    -- I don't think any other storage options will work

Thoughts:

  • I think it might even be enough that way
  • If we ensure we have a OS-level background app/script running it could make sure that only the original copied content is pasted (just parse the JSON and read the originalSelection field)
  • I just did a quick google on the paste operation and so far I wouldn't know how we'd do it ๐Ÿ˜•

Let's talk about it tomorrow or on Wednesday!

Create Atom Extension

Create new key binding in Atom to paste the content from the clipboard and also query our web service

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.