Original preview available at http://experiments.hertzen.com/jsfeedback/
This script allows you to create feedback forms which include:
-
a screenshot, created on the clients browser
-
the user-supplied information
-
all sorts of info gathered about the client.
The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.
The script is based on the html2canvas library, which renders the current page as a canvas image, by reading the DOM and the different styles applied to the elements. This script adds the options for the user to draw elements on top of that image, such as mark points of interest on the image along with the feedback they send.
No plugins, no flash, no interaction needed from the server, just pure JavaScript!
- start a webserver in the root of feedback.js:
python -m http.server --bind 127.0.0.1- start the supplied sample backend:
./sample_backend.py-
open the http://localhost:8000/examples/ URL in the browser
-
submit a feedback, and ignore the error (it's caused by CORS)
-
watch the information gathered at the client side as logged by the sample backend
-
examine the screenshot which the backend saves in the screenshot.png file
Pass to constructor, e.g.
Feedback({
h2cPath:'//cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js',
url: '/rest/feedback'});
Available options:
adapter- sends the data overriding the default adapter in src/send/xhr.jsappendTo- DOM element where to add the feedback button, defaults to document.bodyhighlightClass- CSS class to use for elements that have been highlighted by the user during the screenshot review, defaults tofeedback-highlightedredactClass- CSS class to use for elements that have been redacted by the user during the screenshot review, defaults tofeedback-redactedelements- prompts and input fields to display during the form entry phase, defaults to a single text entry fieldh2cPath- url to html2canvaslang-autofor autodetect from browser or language code likeru_RUpages- dialogs with user. defaults to[Form, Screenshot, Review]url- url to post form dataredactions- whether to offer the user the ability to redact elements during the screenshot review phase, defaults totrue
html2canvas options (see http://html2canvas.hertzen.com/documentation.html#available-options):
- allowTaint
- background
- height
- letterRendering
- logging
- proxy
- taintTest
- timeout
- width
- useCORS
- Install gulp and uglifier at the command line if you don't already have it (uglifier is only needed if you are going to compile the minified version)
npm install gulp gulp-concat
npm install gulp-uglify- Navigate to the feedback.js directory in the terminal and run one of the following
gulp build
gulp build:minor both:
gulp build build:minfeedback.js is released under the MIT license:
The webpages in the examples directory are adapted from example HTML provided by Twitter's Bootstrap project under an Apache-2.0 license, notably the hero example.