Jump to content

Fratozzi

Members
  • Content Count

    23
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Fratozzi

  • Rank
    Member
  1. I searched the internet and found this library (https://github.com/ericblade/quagga2) that is right for me. Now I would like to be able to implement code 32, I read on the internet that the conversion is the same as code 39 (already existing in the library), I created this file and added it to the list of barcodes to use, but it doesn't work, I also found this on the internet for coding ... can you tell me where am i wrong? file created by me : code_32.js import BarcodeReader from './barcode_reader'; import ArrayHelper from '../common/array_helper.ts'; function Code32Reader() { BarcodeReader.call(this); } var properties = { ALPHABETH_STRING: {value: '0123456789BCDFGHJKLMNPQRSTUVWXYZ*'}, ALPHABET: {value: [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 66, 67, 68, 70, 71, 72, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 42]}, CHARACTER_ENCODINGS: {value: [0x034, 0x121, 0x061, 0x160, 0x031, 0x130, 0x070, 0x025, 0x124, 0x064, 0x049, 0x148, 0x019, 0x058, 0x00D, 0x10C, 0x01C, 0x103, 0x043, 0x142, 0x013, 0x052, 0x007, 0x106, 0x046, 0x016, 0x181, 0x0C1, 0x1C0, 0x091, 0x190, 0x0D0, 0x094, ]}, ASTERISK: {value: 0x094}, FORMAT: {value: 'code_32', writeable: false}, }; Code32Reader.prototype = Object.create(BarcodeReader.prototype, properties); Code32Reader.prototype.constructor = Code32Reader; Code32Reader.prototype._decode = function() { var self = this, counters = [0, 0, 0, 0, 0, 0, 0, 0, 0], result = [], start = self._findStart(), decodedChar, lastStart, pattern, nextStart; if (!start) { return null; } nextStart = self._nextSet(self._row, start.end); do { counters = self._toCounters(nextStart, counters); pattern = self._toPattern(counters); if (pattern < 0) { return null; } decodedChar = self._patternToChar(pattern); if (decodedChar < 0){ return null; } result.push(decodedChar); lastStart = nextStart; nextStart += ArrayHelper.sum(counters); nextStart = self._nextSet(self._row, nextStart); } while (decodedChar !== '*'); result.pop(); if (!result.length) { return null; } if (!self._verifyTrailingWhitespace(lastStart, nextStart, counters)) { return null; } return { code: result.join(''), start: start.start, end: nextStart, startInfo: start, decodedCodes: result, }; }; Code32Reader.prototype._verifyTrailingWhitespace = function(lastStart, nextStart, counters) { var trailingWhitespaceEnd, patternSize = ArrayHelper.sum(counters); trailingWhitespaceEnd = nextStart - lastStart - patternSize; if ((trailingWhitespaceEnd * 3) >= patternSize) { return true; } return false; }; Code32Reader.prototype._patternToChar = function(pattern) { var i, self = this; for (i = 0; i < self.CHARACTER_ENCODINGS.length; i++) { if (self.CHARACTER_ENCODINGS[i] === pattern) { return String.fromCharCode(self.ALPHABET[i]); } } return -1; }; Code32Reader.prototype._findNextWidth = function(counters, current) { var i, minWidth = Number.MAX_VALUE; for (i = 0; i < counters.length; i++) { if (counters[i] < minWidth && counters[i] > current) { minWidth = counters[i]; } } return minWidth; }; Code32Reader.prototype._toPattern = function(counters) { var numCounters = counters.length, maxNarrowWidth = 0, numWideBars = numCounters, wideBarWidth = 0, self = this, pattern, i; while (numWideBars > 3) { maxNarrowWidth = self._findNextWidth(counters, maxNarrowWidth); numWideBars = 0; pattern = 0; for (i = 0; i < numCounters; i++) { if (counters[i] > maxNarrowWidth) { pattern |= 1 << (numCounters - 1 - i); numWideBars++; wideBarWidth += counters[i]; } } if (numWideBars === 3) { for (i = 0; i < numCounters && numWideBars > 0; i++) { if (counters[i] > maxNarrowWidth) { numWideBars--; if ((counters[i] * 2) >= wideBarWidth) { return -1; } } } return pattern; } } return -1; }; Code32Reader.prototype._findStart = function() { var self = this, offset = self._nextSet(self._row), patternStart = offset, counter = [0, 0, 0, 0, 0, 0, 0, 0, 0], counterPos = 0, isWhite = false, i, j, whiteSpaceMustStart; for ( i = offset; i < self._row.length; i++) { if (self._row[i] ^ isWhite) { counter[counterPos]++; } else { if (counterPos === counter.length - 1) { // find start pattern if (self._toPattern(counter) === self.ASTERISK) { whiteSpaceMustStart = Math.floor(Math.max(0, patternStart - ((i - patternStart) / 4))); if (self._matchRange(whiteSpaceMustStart, patternStart, 0)) { return { start: patternStart, end: i, }; } } patternStart += counter[0] + counter[1]; for ( j = 0; j < 7; j++) { counter[j] = counter[j + 2]; } counter[7] = 0; counter[8] = 0; counterPos--; } else { counterPos++; } counter[counterPos] = 1; isWhite = !isWhite; } } return null; }; export default Code32Reader; Conversion method (Found online): ` Conversion from CODE 39 ` to Italian Farmaceutical Code ` for bar code reader ` whithout automatic conversion ` R.V. 29/07/2000 C_TEXT($1;$0) C_REAL($result) C_INTEGER($len;$base10;$base32) $result:=0 $len:=Length($1) For ($X;1;$len) $char:=($1<=($len-$X+1)>=) $base32:=Ascii($char) $base10:=$base32-(48+(8*Num($base32>65))+*Num($base32>69)+*Num($base32>73)+*Num($base32>79)) $result:=$result+($base10*(32^($X-1))) End for $0:=String($result) $0:=("0"*Num(Length($0)=8))+$0 ` Conversion from CODE 39 ` to CODE 32 Farmacod ` (Italian farmaceutical code) ` R.V. 29/07/2002 C_TEXT($1;$0) C_REAL($value) C_INTEGER($X;$codASCII) C_LONGINT($base32) $value:=Num($1) $0:="" For ($X;1;6) $base32:=$value-(Int($value/32)*32) $codASCII:=$base32+48+((8*Num($base32>9))+Num($base32>12)+Num($base32>15)+Num($base32>20)) $0:=Char($codASCII)+$0 $value:=Int($value/32) End for Characters exclude A, E, I, O
  2. If I convert from table to list, with a checkbox clicked (checked true) I would like the clicked checkbox to appear in the list, but instead it appears as not clicked if I look at the checkbox status using console.log () it is checked true
  3. I have the following code, in practice I have a problem, if i have the checkbox checked it copies the status but does not show it to me checked. can you please help me? .... <table id="table-files" class="uk-table uk-table-responsive uk-table-middle"> <thead> <tr> <th class="uk-table-shrink"><input name="checkbox-all-files" type="checkbox" class="uk-checkbox"></th> <th id="table-image" class="uk-table-shrink"></th> <th id="table-name" class="uk-table-expand">Name</th> <th id="table-file" class="uk-table-shrink">File</th> <th id="table-folder" class="uk-table-shrink">Folder</th> <th id="table-tools">Date</th> </tr> </thead> <tbody> <tr class="check-files" data-user="2" data-file="10"> <td><input name="checkbox-files" value="43" type="checkbox" class="uk-checkbox"></td> <td data-image="1"><img alt="User" src="/user/user_profile.jpg" width="60" height="60"></td> <td class="uk-text-nowrap">Mark Zu</td> <td class="uk-text-nowrap" name="tools-table"><a href="/files/Test.jpg">Test.jpg</a></td> <td class="uk-text-nowrap">Main</td> <td name="tools-table"></td> </tr> </tbody> </table> .... <script src="/functions/table-to-ul.js" type="text/javascript"></script> THE FUNCTION CONVERSION IS ON FILE TABLE-TO-UL.JS function convert_table_to_list_files(table_id) { var list_id = table_id.replace("table-", "ul-"); var ul = $("<ul id='"+list_id+"' class='uk-grid uk-grid-medium uk-child-width-1-2@s uk-child-width-1-3@l uk-child-width-1-4@xl' uk-grid uk-height-match='target: > div > .uk-card'>"); $("#"+table_id+" tbody tr").each(function(){ var classTR = this.className; var userTR = this.attributes["data-user"].value; var fileTR = this.attributes["data-file"].value; var li = $("<li class='"+classTR+"' data-user='"+userTR+"' data-file='"+fileTR+"'>"); var checkboxCell = this.children[0].innerHTML; var ImgCell = this.children[1].attributes["data-image"].value; var userCell = this.children[2].innerHTML; var fileCell = this.children[3].innerHTML; var fileHrefCell = this.children[3].firstElementChild.firstElementChild.href; var resultOutput = `<div class="uk-card uk-card-box"> <div class="uk-card-teaser uk-position-relative"> <div class="uk-background-cover" style="background-image: url('`+fileHrefCell+`');"> </div> <canvas width="1200" height="800"></canvas> </div> <div class="uk-text-truncate"><div class="uk-flex uk-flex-center uk-flex-middle">`+ checkboxCell+`<span>`+fileCell+`</span>`+ `</div><hr>`+ `<div data-image="`+ImgCell+`">`+userCell+`</div>` +`</div> </div>`; li.append(output); ul.append(li); }) $("table#"+table_id).replaceWith(ul); }
  4. Hi everyone, I'm trying to read a barcode like Code 32 Italian Pharmacological Code, use this function in JS. But I can't, do you know where I'm wrong or do you know some free library to use? Thank you var barcode = function() { var localMediaStream = null; var bars = []; var handler = null; var dimensions = { height: 0, width: 0, start: 0, end: 0 } var elements = { video: null, canvas: null, ctx: null, canvasg: null, ctxg: null } var upc = { '0': [3, 2, 1, 1], '1': [2, 2, 2, 1], '2': [2, 1, 2, 2], '3': [1, 4, 1, 1], '4': [1, 1, 3, 2], '5': [1, 2, 3, 1], '6': [1, 1, 1, 4], '7': [1, 3, 1, 2], '8': [1, 2, 1, 3], '9': [3, 1, 1, 2] }; var check = { 'oooooo': '0', 'ooeoee': '1', 'ooeeoe': '2', 'ooeeeo': '3', 'oeooee': '4', 'oeeooe': '5', 'oeeeoo': '6', 'oeoeoe': '7', 'oeoeeo': '8', 'oeeoeo': '9' } var config = { strokeColor: '#f00', start: 0.1, end: 0.9, threshold: 160, quality: 0.45, delay: 100, video: '', canvas: '', canvasg: '' } function init() { window.URL = window.URL || window.webkitURL; navigator.getUserMedia = navigator.getUserMedia || navigator.mozGetUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia; elements.video = document.querySelector(config.video); elements.canvas = document.querySelector(config.canvas); elements.ctx = elements.canvas.getContext('2d'); elements.canvasg = document.querySelector(config.canvasg); elements.ctxg = elements.canvasg.getContext('2d'); if (navigator.getUserMedia) { navigator.getUserMedia({audio: false, video: true}, function(stream) { elements.video.srcObject = stream; }); } elements.video.addEventListener('canplay', function(e) { dimensions.height = elements.video.videoHeight; dimensions.width = elements.video.videoWidth; dimensions.start = dimensions.width * config.start; dimensions.end = dimensions.width * config.end; elements.canvas.width = dimensions.width; elements.canvas.height = dimensions.height; elements.canvasg.width = dimensions.width; elements.canvasg.height = dimensions.height; drawGraphics(); setInterval(function(){snapshot()}, config.delay); }, false); } function snapshot() { elements.ctx.drawImage(elements.video, 0, 0, dimensions.width, dimensions.height); processImage(); } function processImage() { bars = []; var pixels = []; var binary = []; var pixelBars = []; // convert to grayscale var imgd = elements.ctx.getImageData(dimensions.start, dimensions.height * 0.5, dimensions.end - dimensions.start, 1); var rgbpixels = imgd.data; for (var i = 0, ii = rgbpixels.length; i < ii; i = i + 4) { pixels.push(Math.round(rgbpixels * 0.2126 + rgbpixels[i + 1] * 0.7152 + rgbpixels[ i + 2] * 0.0722)); } // normalize and convert to binary var min = Math.min.apply(null, pixels); var max = Math.max.apply(null, pixels); for (var i = 0, ii = pixels.length; i < ii; i++) { if (Math.round((pixels - min) / (max - min) * 255) > config.threshold) { binary.push(1); } else { binary.push(0); } } // determine bar widths var current = binary[0]; var count = 0; for (var i = 0, ii = binary.length; i < ii; i++) { if (binary == current) { count++; } else { pixelBars.push(count); count = 1; current = binary } } pixelBars.push(count); // quality check if (pixelBars.length < (3 + 24 + 5 + 24 + 3 + 1)) { return; } // find starting sequence var startIndex = 0; var minFactor = 0.5; var maxFactor = 1.5; for (var i = 3, ii = pixelBars.length; i < ii; i++) { var refLength = (pixelBars + pixelBars[i-1] + pixelBars[i-2]) / 3; if ( (pixelBars > (minFactor * refLength) || pixelBars < (maxFactor * refLength)) && (pixelBars[i-1] > (minFactor * refLength) || pixelBars[i-1] < (maxFactor * refLength)) && (pixelBars[i-2] > (minFactor * refLength) || pixelBars[i-2] < (maxFactor * refLength)) && (pixelBars[i-3] > 3 * refLength) ) { startIndex = i - 2; break; } } // return if no starting sequence found if (startIndex == 0) { return; } // discard leading and trailing patterns pixelBars = pixelBars.slice(startIndex, startIndex + 3 + 24 + 5 + 24 + 3); // calculate relative widths var ref = (pixelBars[0] + pixelBars[1] + pixelBars[2]) / 3; for (var i = 0, ii = pixelBars.length; i < ii; i++) { bars.push(Math.round(pixelBars / ref * 100) / 100); } // analyze pattern analyze(); } function analyze() { // determine parity first digit and reverse sequence if necessary var first = normalize(bars.slice(3, 3 + 4), 7); if (!isOdd(Math.round(first[1] + first[3]))) { bars = bars.reverse(); } // split into digits var digits = [ normalize(bars.slice(3, 3 + 4), 7), normalize(bars.slice(7, 7 + 4), 7), normalize(bars.slice(11, 11 + 4), 7), normalize(bars.slice(15, 15 + 4), 7), normalize(bars.slice(19, 19 + 4), 7), normalize(bars.slice(23, 23 + 4), 7), normalize(bars.slice(32, 32 + 4), 7), normalize(bars.slice(36, 36 + 4), 7), normalize(bars.slice(40, 40 + 4), 7), normalize(bars.slice(44, 44 + 4), 7), normalize(bars.slice(48, 48 + 4), 7), normalize(bars.slice(52, 52 + 4), 7) ] // determine parity and reverse if necessary var parities = []; for (var i = 0; i < 6; i++) { if (parity(digits)) { parities.push('o'); } else { parities.push('e'); digits = digits.reverse(); } } // identify digits var result = []; var quality = 0; for (var i = 0, ii = digits.length; i < ii; i++) { var distance = 9; var bestKey = ''; for (key in upc) { if (maxDistance(digits, upc[key]) < distance) { distance = maxDistance(digits, upc[key]); bestKey = key; } } result.push(bestKey); if (distance > quality) { quality = distance; } } // check digit var checkDigit = check[parities.join('')]; // output if(quality < config.quality) { if (handler != null) { handler(checkDigit + result.join('')); } } } function setHandler(h) { handler = h; } function normalize(input, total) { var sum = 0; var result = []; for (var i = 0, ii = input.length; i < ii; i++) { sum = sum + input; } for (var i = 0, ii = input.length; i < ii; i++) { result.push(input / sum * total); } return result; } function isOdd(num) { return num % 2; } function maxDistance(a, b) { var distance = 0; for (var i = 0, ii = a.length; i < ii; i++) { if (Math.abs(a - b) > distance) { distance = Math.abs(a - b); } } return distance; } function parity(digit) { return isOdd(Math.round(digit[1] + digit[3])); } function drawGraphics() { elements.ctxg.strokeStyle = config.strokeColor; elements.ctxg.lineWidth = 3; elements.ctxg.beginPath(); elements.ctxg.moveTo(dimensions.start, dimensions.height * 0.5); elements.ctxg.lineTo(dimensions.end, dimensions.height * 0.5); elements.ctxg.stroke(); } return { init: init, setHandler: setHandler, config: config }; // debugging utilities function drawBars(binary) { for (var i = 0, ii = binary.length; i < ii; i++) { if (binary == 1) { elements.ctxg.strokeStyle = '#fff'; } else { elements.ctxg.strokeStyle = '#000'; } elements.ctxg.lineWidth = 3; elements.ctxg.beginPath(); elements.ctxg.moveTo(start + i, height * 0.5); elements.ctxg.lineTo(start + i + 1, height * 0.5); elements.ctxg.stroke(); } } }();
  5. Hello everyone, I need some information for sending sms with whatsapp via PHP function ... I would like to know first of all if the service is free and if it is possible to do so, without joining any third party service such as Twilio .. Have you already encountered this problem? Do you have any idea? Thank you P.S. I don't need to receive a reply to the message from the recipient. Just send me a message
  6. I am using this function in js to check if the browser supports the webp images format, if it is compatible, release the image in webp, in png. It works with all browsers but if I try it with mobile safari ios 13 it doesn't work I can't understand where is the problem can you help me? JS var WebpDetect = function() { var onComplete = null; var numFeaturesTested = 0; var features = [ { name: 'lossy', testImage: "UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA" }, { name: 'lossless', testImage: "UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==" }, { name: 'alpha', testImage: "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==" }, { name: 'animation', testImage: "UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA" } ]; var testFeatureSupport = function(feature, callback) { var image = new Image(); image.onload = function () { var isSupported = image.width > 0 && image.height > 0; callback(feature, isSupported); }; image.onerror = function () { callback(feature, false); }; image.src = "data:image/webp;base64," + feature.testImage; } var onFeatureTested = function(feature, isSupported) { var featureClass = (!isSupported ? 'no-' : '') + 'webp-' + feature.name; $('html').addClass(featureClass); var featureAttribute = featureClass + '-src'; $('img[' + featureAttribute + ']').each(function (index, item) { var imageSource = $(item).attr(featureAttribute); $(item).removeAttr(featureAttribute); if (!isSupported) imageSource = imageSource.substring(imageSource.length - 3) + 'png'; $(item).attr('src', imageSource || ""); }); if (onComplete) { numFeaturesTested++; if (numFeaturesTested == features.length) { onComplete(); } } } return { init: function (parameters) { onComplete = parameters && parameters.onComplete; for (var index = 0; index < features.length; ++index) { testFeatureSupport(features[index], onFeatureTested); } } } }(); HTML <img webp-animation-src="/img/test.webp"> <script src="webp-detect.js" type="text/javascript"></script> <script> $('document').ready(function(){ WebpDetect.init(); }); </script>
  7. Ok, but the default iOS and Android app does not damage the ability to access your health data to json, that is, it does not guarantee APIs to be implemented via js / php? Thanks for the reply!
  8. Good morning! I was wondering how can i access the php data to the health data (steps, heart rate etc ..) of devices with android and ios? I don't know maybe by inserting the keys I can access the json with the related data... I tried to search a bit on the internet but I see that I can only do it if I create an app for both systems and then from there I enter the data in my mysql database.. I don't know where to start, do you know something? Thank you
  9. In case using $ _SERVER ["REMOTE_ADDR"]; to get the name of the dns how can I remove all those characters and know only the final part? For example: With that function I get this: mob-3-91-125-82.net.vodafone.it host86-197-dynamic.3-87-r.retail.telecomitalia.it 93-32-55-29.ip32.fastwebnet.it mob-5-90-154-87.net.vodafone.it I would like this instead: net.vodafone.it retail.telecomitalia.it ip32.fastwebnet.it That should be the name of the internet provider I connect to. Thanks
  10. what I need is the name of the device I am using to access a site. for example PC-Fra. Anyway thank you for replying 😊
  11. I don't have any software installed on my pc regarding DropBox, yet it gets my device name. If I connect to their site
  12. Is there no way to get it? For example using JS. That is, how does DropBox, for example, obtain the name of the logged device?
  13. Hi everyone, I'm trying to get the name of the machine in use. If I use this feature locally, it works. function visitor_machine_name(){ $machine_name = gethostbyaddr($_SERVER['REMOTE_ADDR']); return $machine_name; } But as soon as I try it on an online server I get the DNS name back, like this: mob-3-91-125-82.net.vodafone.it What can I do?
  14. thank you so much for all the explanation, I will definitely try. Thanks and merry christmas
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.