Skip to content

Commit

Permalink
getStats, Canvas-Designer, RecordRTC, DetectRTC, MultiStreamsMixer, R…
Browse files Browse the repository at this point in the history
…TCMultiConnection-Server,

Chrome-Extensions, cordova-mobile-apps, FileBufferReader, getScreenId,
RTCMultiConnection, video-coferencing, audio/video broadcasting, WebRTC
File Sharing, socket.io, screen-sharing etc. updated.
  • Loading branch information
muaz-khan committed Dec 20, 2018
1 parent 8972b10 commit b03928a
Show file tree
Hide file tree
Showing 383 changed files with 49,734 additions and 37,537 deletions.
30 changes: 13 additions & 17 deletions Canvas-Designer/.npmignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
node_modules
bower_components
# ignore everything
*

*.tar.gz
lib-cov

.*.swp
._*
.DS_Store
.git
.hg
.npmrc
.lock-wscript
.svn
.wafpickle-*
config.gypi
CVS
npm-debug.log
# but not these files...
!canvas-designer-widget.js
!widget.html
!widget.js
!widget.min.js
!dev/webrtc-handler.js
!index.html
!package.json
!bower.json
!server.js
!README.md
17 changes: 16 additions & 1 deletion Canvas-Designer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Demo: https://www.webrtc-experiment.com/Canvas-Designer/

## Advance Demo: [demos/dashboard.html](https://rtcmulticonnection.herokuapp.com/demos/dashboard.html)
## Advance Demo: [demos/dashboard/](https://rtcmulticonnection.herokuapp.com/demos/dashboard/)

Multiple designers demo: https://www.webrtc-experiment.com/Canvas-Designer/multiple.html

Expand Down Expand Up @@ -236,6 +236,14 @@ Pass array-of-points that are shared by remote users using socket.io or websocke
designer.syncData(arrayOfPoints);
```

## `clearCanvas`

Remove and clear all drawings from the canvas:

```javascript
designer.clearCanvas();
```

## `addSyncListener`

This callback is invoked as soon as something new is drawn. An array-of-points is passed over this function. That array MUST be shared with remote users for collaboration.
Expand Down Expand Up @@ -306,6 +314,8 @@ designer.icons = {
text: '/icons/text.png',
image: '/icons/image.png',
pdf: '/icons/pdf.png',
pdf_next: '/icons/pdf-next.png',
pdf_prev: '/icons/pdf-prev.png',
marker: '/icons/marker.png',
zoom: '/icons/zoom.png',
lineWidth: '/icons/lineWidth.png',
Expand All @@ -329,6 +339,11 @@ CanvasDesigner is a widget; that widget should be appended to a DOM object. This

```javascript
designer.appendTo(document.body || document.documentElement);

// or
designer.appendTo(document.body || document.documentElement, function() {
alert('iframe load callback');
});
```

The correct name for `appendTo` is: `append-iframe to target HTML-DOM-element`
Expand Down
2 changes: 1 addition & 1 deletion Canvas-Designer/bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "canvas-designer",
"preferGlobal": false,
"version": "1.2.1",
"version": "1.2.7",
"author": {
"name": "Muaz Khan",
"email": "[email protected]",
Expand Down
22 changes: 21 additions & 1 deletion Canvas-Designer/canvas-designer-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function CanvasDesigner() {
text: null,
image: null,
pdf: null,
pdf_next: null,
pdf_prev: null,
pdf_close: null,
marker: null,
zoom: null,
lineWidth: null,
Expand Down Expand Up @@ -112,8 +115,17 @@ function CanvasDesigner() {

designer.uid = getRandomString();

designer.appendTo = function(parentNode) {
designer.appendTo = function(parentNode, callback) {
callback = callback || function() {};

designer.iframe = document.createElement('iframe');

// designer load callback
designer.iframe.onload = function() {
callback();
callback = null;
};

designer.iframe.src = designer.widgetHtmlURL + '?widgetJsURL=' + designer.widgetJsURL + '&tools=' + JSON.stringify(tools) + '&selectedIcon=' + selectedIcon + '&icons=' + JSON.stringify(designer.icons);
designer.iframe.style.width = '100%';
designer.iframe.style.height = '100%';
Expand Down Expand Up @@ -193,6 +205,14 @@ function CanvasDesigner() {
});
};

designer.clearCanvas = function () {
if (!designer.iframe) return;

designer.postMessage({
clearCanvas: true
});
};

designer.widgetHtmlURL = 'widget.html';
designer.widgetJsURL = 'widget.min.js';
}
5 changes: 4 additions & 1 deletion Canvas-Designer/dev/data-uris.js

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions Canvas-Designer/dev/decorator.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ window.addEventListener('load', function() {
}

addEvent(context.canvas, 'click', function() {
pdfHandler.pdfPageContainer.style.display = 'none';
// pdfHandler.pdfPageContainer.style.display = 'none';

if (textHandler.text.length) {
textHandler.appendPoints();
Expand Down Expand Up @@ -201,8 +201,9 @@ window.addEventListener('load', function() {
image.src = data_uris.dragSingle;
}

decorateDragLastPath();

if (tools.dragSingle === true) {
decorateDragLastPath();
document.getElementById('drag-last-path').style.display = 'block';
}

Expand All @@ -217,8 +218,9 @@ window.addEventListener('load', function() {
image.src = data_uris.dragMultiple;
}

decorateDragAllPaths();

if (tools.dragMultiple === true) {
decorateDragAllPaths();
document.getElementById('drag-all-paths').style.display = 'block';
}

Expand Down
49 changes: 40 additions & 9 deletions Canvas-Designer/dev/pdf-handler.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var pdfHandler = {
lastPdfURL: null,
lastIndex: 0,
lastPageIndex: null,
removeWhiteBackground: true,
lastPointIndex: 0,
removeWhiteBackground: false,
pdfPageContainer: document.getElementById('pdf-page-container'),
pdfPagesList: document.getElementById('pdf-pages-list'),
pdfNext: document.getElementById('pdf-next'),
pdfPrev: document.getElementById('pdf-prev'),
pdfClose: document.getElementById('pdf-close'),
pageNumber: 1,

images: [],
Expand Down Expand Up @@ -37,10 +40,13 @@ var pdfHandler = {

var renderContext = {
canvasContext: ctx,
viewport: viewport,
background: 'rgba(0,0,0,0)'
viewport: viewport
};

if (pdfHandler.removeWhiteBackground === true) {
renderContext.background = 'rgba(0,0,0,0)';
}

page.render(renderContext).then(function() {
if (pdfHandler.removeWhiteBackground === true) {
var imgd = ctx.getImageData(0, 0, cav.width, cav.height);
Expand Down Expand Up @@ -80,6 +86,8 @@ var pdfHandler = {
var t = pdfHandler;
pdfHandler.lastIndex = pdfHandler.images.length;
var point = [lastPage, 60, 20, width, height, pdfHandler.lastIndex];

pdfHandler.lastPointIndex = points.length;
points[points.length] = ['pdf', point, drawHelper.getOptions()];

pdfHandler.pdfPagesList.innerHTML = '';
Expand All @@ -93,14 +101,33 @@ var pdfHandler = {
option.selected = true;
}
}
pdfHandler.pdfPageContainer.style.top = '20px';
pdfHandler.pdfPageContainer.style.left = point[2] + 'px';

pdfHandler.pdfPagesList.onchange = function() {
pdfHandler.load(lastPdfURL);
};

pdfHandler.pdfNext.onclick = function() {
pdfHandler.pdfPagesList.selectedIndex++;
pdfHandler.pdfPagesList.onchange();
};

pdfHandler.pdfPrev.onclick = function() {
pdfHandler.pdfPagesList.selectedIndex--;
pdfHandler.pdfPagesList.onchange();
};

pdfHandler.pdfClose.onclick = function() {
pdfHandler.pdfPageContainer.style.display = 'none';
};

document.getElementById('drag-last-path').click();

pdfHandler.pdfPrev.src = data_uris.pdf_next;
pdfHandler.pdfNext.src = data_uris.pdf_prev;
pdfHandler.pdfClose.src = data_uris.pdf_close;

pdfHandler.pdfPageContainer.style.top = '20px';
pdfHandler.pdfPageContainer.style.left = (point[3] - parseInt(point[3] / 2)) + 'px';
pdfHandler.pdfPageContainer.style.display = 'block';

// share to webrtc
Expand All @@ -124,7 +151,9 @@ var pdfHandler = {

var t = this;
if (t.ismousedown) {
points[points.length] = ['pdf', [pdfHandler.lastPage, t.prevX, t.prevY, x - t.prevX, y - t.prevY, pdfHandler.lastIndex], drawHelper.getOptions()];
if (points[pdfHandler.lastPointIndex]) {
points[pdfHandler.lastPointIndex] = ['pdf', [pdfHandler.lastPage, t.prevX, t.prevY, x - t.prevX, y - t.prevY, pdfHandler.lastIndex], drawHelper.getOptions()];
}

t.ismousedown = false;
}
Expand All @@ -141,9 +170,11 @@ var pdfHandler = {
},
reset_pos: function(x, y) {
pdfHandler.pdfPageContainer.style.top = y + 'px';
pdfHandler.pdfPageContainer.style.left = x + 'px';
if (!points[pdfHandler.lastPointIndex]) return;
var point = points[pdfHandler.lastPointIndex][1];
pdfHandler.pdfPageContainer.style.left = (point[1] + point[3] - parseInt(point[3] / 2) - parseInt(pdfHandler.pdfPageContainer.clientWidth / 2)) + 'px';
},
end: function() {
pdfHandler.pdfPageContainer.style.display = 'none';
// pdfHandler.pdfPageContainer.style.display = 'none';
}
};
6 changes: 6 additions & 0 deletions Canvas-Designer/dev/share-drawings.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ window.addEventListener('message', function(event) {
return;
}

if (event.data.clearCanvas) {
points = [];
drawHelper.redraw();
return;
}

if (!event.data.canvasDesignerSyncData) return;

// drawing is shared here (array of points)
Expand Down
2 changes: 1 addition & 1 deletion Canvas-Designer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ <h2><a href="https://github.com/muaz-khan/Canvas-Designer#how-to-use">How to use

<hr>

<h2><a href="multiple.html">Try multiple designers!</a></h2>
<h2><a href="https://rtcmulticonnection.herokuapp.com/demos/dashboard/">WebRTC Dashboard</a></h2>

<br><br><br>

Expand Down
2 changes: 1 addition & 1 deletion Canvas-Designer/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "canvas-designer",
"preferGlobal": false,
"version": "1.2.1",
"version": "1.2.7",
"author": {
"name": "Muaz Khan",
"email": "[email protected]",
Expand Down
Loading

0 comments on commit b03928a

Please sign in to comment.