TVJS – Search functionality crashes when trying to show results

I’m working on a TVML application. One of the screens shows a search form for the user to enter a keyword. The text entered is compared to a previously existing JSON file that contains every item in existence. After the available results are filtered, these are used to build XML nodes by using an external XML file, and then they are imported into the search document, specifically into the section with Id “results”. The problem is that if I just type a search term directly, the search takes place. However, if I type letter by letter (allowing for a search after each letter) then the application crashes and I get the following error:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSSingleObjectArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
terminating with uncaught exception of type NSException

(the index number and the range vary with different results)

Here are the files I currently have:

search.tvml

<?xml version="1.0" encoding="UTF-8" ?>
<document>
<head>
    <style>
        .company {
            font-size: 26;
        }
    </style>
</head>
<searchTemplate>
    <searchField />
    <collectionList>
        <grid>
            <header>
                <title>Search Results</title>
            </header>
            <section id="results">
                
            </section>
        </grid>
    </collectionList>
</searchTemplate>
</document>

searchResults.tvml

<lockup template="video.tvml" presentation="push" id="{{id}}">
    <img src="https://path_to_images/{{path}}/{{image}}.jpg" width="380" height="266" alt="{{name}}"/>
    <title>{{name}}</title>
    <subtitle class="company">{{company}}</subtitle>
</lockup>

SearchHandler.js

class SearchHandler {
    constructor(resourceLoader) {
        this._resourceLoader = resourceLoader;
        this.searchDatabase = "";
    }

    enableSearchForDoc(doc) {
        this._addSearchHandlerToDoc(doc);
    }

    _addSearchHandlerToDoc(doc) {
        var searchFields = doc.getElementsByTagName('searchField');
        for (var i = 0; i < searchFields.length; ++i) {
            var searchField = searchFields.item(i);
            var keyboard = searchField.getFeature("Keyboard");
            keyboard.onTextChange = this._handleSearch.bind(this, keyboard, doc);
        }
    }


    _handleSearch(keyboard, doc) {
    
        // Get the text entered
        var searchString = keyboard.text;
    
        // Blank results array
        var results = [];
    
        // Search only if text entered has more than one character
        if (searchString.length > 1) {
            results = this.searchVideosForString(searchString, this.searchDatabase);
        }
    
        // Get the result nodes (lockups) from the results obtained
        var resultNodes = this._renderResults(results);
    
        // Get a reference to the "results" section in search.tvml
        var resultContainer = doc.getElementById("results");
    
        // If such section exists
        if (resultContainer) {
            // remove previous results
            while (resultContainerChildren > 0 ) {
                resultContainer.removeChild(resultContainer.lastChild);
                resultContainerChildren--;
            }
        
            // Add each lockup node to the results section
            if (resultNodes.length > 0) {
                resultNodes.forEach(function(resultNode) {
                    doc.adoptNode(resultNode);
                    resultContainer.appendChild(resultNode);
                });
            }
        }
    }

    _renderResults(results) {
        var resourceLoader = this._resourceLoader;
    
        // Get an XML node (lockup) for each of the results found
        // Results will be used as data for the XML
        var rendered = results.map(function(result) {
            var doc = resourceLoader.getRenderedDocument("searchResults.tvml", result);
            return doc.documentElement;
        });
    
        // Return the array of lockup nodes
        return rendered;
    }

    searchVideosForString(searchString, data) {
        var sourceData = data;
    
        var results = []
    
        results = sourceData.filter(function(v) {
            var title = v.name;
            var show = v.showname;
            var company = v.company;
                                    
            return title.toLowerCase().includes(searchString.toLowerCase()) || show.toLowerCase().includes(searchString.toLowerCase()) || company.toLowerCase().includes(searchString.toLowerCase())
        });

        console.log("SEARCH RESULTS: ", results);

        return results;
    }
}

I have been monitoring the results of the searchVideosForString method using the Safari console, and what I have discovered is, if for example I’m trying to search for “Parry” which exists in the full results, if I type in the word “Par”, the console shows for Search Results an array with 18 objects. If I open the disclosure triangle, it shows each of those 18 objects. If I then add a character in the search to look for “Parr”, then the app crashes. The console shows for Search Results an array with 1 object, but if I open the disclosure triangle, it’s empty, I can’t see what the actual object is.

I have tried deleting sections of the code in the handleSearch method. If I remove everything below

var resultContainer = doc.getElementById("results");

then I can enter any text in the search box without any issues and the console shows the appropriate search results, no matter how many they are.

It seems the problem happens in this line:

doc.adoptNode(resultNode);

but I can’t figure out why nor where that index out of range exception is coming from.

req.user is coming back as undefined with Express and Passport?

When my app redirects to “/” req.user is undefined, but in the twitter callback, req.user gives me the data that I’m looking for. I lose the data on redirect. There is still information in req for “/” but not req.user which I need.

Can anyone help me solve this problem?

This is my index.js

const express = require('express')
const app = express()
const cookieSession = require('cookie-session')
const passport = require('passport');
require('./passport')
const isLoggedIn = require('./Middleware/auth')

app.use(cookieSession({
  name: 'twitter-auth-session',
  keys: ['key1', 'key2']
}))
app.use(passport.initialize());
app.use(passport.session());

app.get('/auth/error', (req, res) => res.send('Unknown Error'))


//, isLoggedIn,

app.get('/', (req,res)=>{
  console.log('HELLOOOOO', req.user)
  res.send(`Hello`)
});

app.get('/logout', (req, res) => {
  req.session = null;
  req.logout();
  res.redirect('/');
})

app.get('/auth/twitter',passport.authenticate('twitter'));
app.get('/auth/twitter/callback',passport.authenticate('twitter', { failureRedirect: '/auth/error' }),
function(req, res) {
  // console.log("REQUEST", req.user)
  res.redirect('/');
});

app.listen(8000,()=>{
  console.log('Server is up and running at the port 8000')
})

This is my passport.js middleware:

const passport = require('passport');
const TwitterStrategy = require('passport-twitter').Strategy;

passport.serializeUser(function(user, done) {
  done(null, user);
});

passport.deserializeUser(function(user, done) {
  done(null, user);
});

passport.use(new TwitterStrategy({
  consumerKey: "xxxxxxxxxxx",
  consumerSecret: "xxxxxxxxxxx",
  callbackURL: "http://www.localhost:8000/auth/twitter/callback",
}, function(accessToken, refreshToken, profile, cb) {
  return cb(null, profile);
}));

await Asyncstorage returns a promise

I am using a helper function to get the token from Asyncstorage and add it to the axios header but instead it gives a promise. My function is like this:

const getToken = async () => {
  const token = await AsyncStorage.getItem("token")
    return token
};

Discord.js something-random-on-discord meme API not working: DiscordAPIError: Cannot send an empty message

I am new to working with APIs in discord.js and I stumbled across a meme API in npm (https://www.npmjs.com/package/something-random-on-discord). I followed the exact steps on the site and got this error:

/home/runner/Penguin69/node_modules/discord.js/src/rest/RequestHandler.js:349
      throw new DiscordAPIError(data, res.status, request);
            ^

DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (/home/runner/Penguin69/node_modules/discord.js/src/rest/RequestHandler.js:349:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (/home/runner/Penguin69/node_modules/discord.js/src/rest/RequestHandler.js:50:14) {
  method: 'post',
  path: '/channels/914839917769658371/messages',
  code: 50006,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: undefined,
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}

my code was:

const random = require("something-random-on-discord").Random
client.on("messageCreate", message => {
 if (message.content.toLowerCase() === "!meme") {
 let data = await random.getMeme()
    message.channel.send(data)
  };
});

Does this have something to do with me using discord.js v13? If so, is there any other meme API/generator that works? Hope someone can help!

Crawling any webpage with HtmlUnit not working with Javascript pages

I am developing a web crawler able to recieve any given domain and crawl the main page, then creating a list with all the sub links of that page and crawl them too.

I programmed the part of retrieving the main content of any given page, for that I used HtmlUnit to get the html, and boilerpipe to identify the main content with pretty accurate results.

Now I’m facing the problem of having to identify all the sub-links of that page, the biggest deal here is the fact that every webpage has it’s own html structure. I’ve tried to accomplish that with the following methods:

  • Searching all the Anchors (a): this was my first idea and worked
    pretty well, the problem came when I tried to crawl pages that
    implement JavaScript, as they wont use Anchor tags but (div) tags
    with onClick properties:
    (onclick=”widgetEvCall(‘handlers.openResult’, event, this,
    ‘/Attraction_Review-g187497-d670716-Reviews-Barcelona_Bus_Turistic-Barcelona_Catalonia.html’)
  • Search all the tags with onCLick attributes: this solution didnt work
    either as not all the webs use that attribute.
  • Get the button.click() response: The problem here was that not all
    the elements that have link redirect on them are buttons, some of
    them are just divs.

I know that JSoup can do that pretty easily but it crashes when finding JavaScript elements. At this point I ran out of ideas, anyone could help me with this task?

Is there a way to identify and resolve this function error? TypeError: user.reserve is not a function

I’m new to backend programming, I’m following a course to test some tests, and I get the following error: Is there a way to identify and resolve this function error? TypeError: user.reserve is not a function

var mongoose = require('mongoose');
var Equinero = require('../../models/equinero');
var Usuario = require('../../models/usuario');
var Reserva = require('../../models/reserva');

describe("Testing Usuarios", function() {

  beforeEach(function(done) {
    mongoose.connection.close().then(() => {
      var mongoDB = 'mongodb://localhost/testdb';
      mongoose.connect(mongoDB, { useNewUrlParser: true, useUnifiedTopology: true });
      
      var db = mongoose.connection;
      db.on('error', console.error.bind(console, 'connection error: '));
      db.once('open', function () {
        console.log('We are connected to test database!');
        done();
      });
    });
  });

  afterEach(function(done) {
    Reserva.deleteMany({}, function(err, success) {
      if (err) console.log(err);
      Usuario.deleteMany({}, function(err, success) {
        if (err) console.log(err);
        Equinero.deleteMany({}, function(err, success) { 
          if (err) console.log(err);
          done();
        });
      });
    });
  });

 
  describe("Cuando un Usuario reserva una bici", () => {
    it("Debe existir la reserva", (done) => {
      const usuario = new Usuario({nombre: 'Ezequiel'});
      usuario.save();
      const equinero = new Equinero({code:1, material: 'cemento', profundidad: '1m', dc: '2m'});
      equinero.save();

      var hoy = new Date();
      var maniana = new Date();
      maniana.setDate(hoy.getDate()+1);
      usuario.reservar(equinero.id, hoy, maniana, function(err, reserva) {
        Reserva.find({}).populate('equinero').populate('usuario').exec(function(err, reservas) {
          console.log(reservas[0]);
          expect(reservas.length).toBe(1);
          expect(reservas[0].diasDeReserva()).toBe(2);
          expect(reservas[0].equinero.code).toBe(1);
          expect(reservas[0].usuario.nombre).toBe(usuario.nombre);
          done();
        });
      });

    });
  });

});

I am using spec, jasmine, node js, express

Function running after data loading still gives an error because data is not loaded

I am getting Binance coin data from Binance npm package. But when I try to run filter or map function it gives the error: TypeError: Cannot read properties of undefined (reading 'filter')

The code:

const client = Binance();

  const [dataLoading, setDataLoaded] = useState(true);
  const [tradesData, setTradesData] = useState();
  const [length, setLength] = useState();

  const tradesDataSet = async () => {
    setTradesData(await client.trades({ symbol: "BTCUSDT" }));

    setDataLoaded(false);
  };

  useEffect(() => {
    tradesDataSet();
  }, []);
  console.log(
    tradesData.filter((trade) => trade.price * trade.qty > 3000).length
  );

How do I troubleshoot?

Add download Button for React Table

I’m trying to add a download button that downloads a dynamic react table on click as a csv File but I’m not sure how to do it..

import React, {Component} from "react";
import DynamicTable from '@atlaskit/dynamic-table';
import styled from 'styled-components';


const Wrapper = styled.div`
min-width: 600px;
th{font-size:13px}
th{font-size:14px} `;


render() {
const { error, isLoaded, shareFilterRows } = this.state;
if (error) {
  return <div>Error: {error.message}</div>;
} else if (!isLoaded) {
  return <div>Loading Shared Filters...</div>;
} else {
  return (<Wrapper>
    <div>
    <DynamicTable
      head={shareFilterHead}
      rows={shareFilterRows}
      rowsPerPage={10}
      defaultPage={1}
      loadingSpinnerSize="large"
      isLoading={false}
      isFixedSize
      defaultSortKey="filterID"
      defaultSortOrder="ASC"
      onSort={() => console.log('onSort')}
      onSetPage={() => console.log('onSetPage')}
      
      />
  </div>
  </Wrapper>
  );
  }
}

}

This is how my table gets displayed img. I would appreciate any hint or help to make that button work. Thank you guys.

Accelerometer data when Android phone screen is off, in a progressive-web-app with service worker

I know that a standard website probably cannot access accelerometer data when the Android phone screen is off. It seems to be the same for a native Android app as explained in How to get sensor data in service when screen is turned off? (I don’t know if this answer is still up-to-date).

But is it possible in the context of a PWA?

Can a progressive-web-app, with a registered service worker, access to the accelerometer data when the screen is off?

Getting a SyntaxError only on my computer

I’m having trouble connecting to an API when I run node server.js on terminal.

My friend is running the same code as me but he is able connect.

Here is the SyntaxError:

SyntaxError: Invalid or unexpected token
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:139:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:236:14)
at async link (node:internal/modules/esm/module_job:67:21)

Appartently the error is in the last line of code:

const OMIE_APP_KEY = ""
const OMIE_APP_SECRET = ""

const api = axios.create({
    baseURL: "https://app.omie.com.br/api/v1/produtos/requisicaocompra/",
  }); 
  

const app = express()
const server = http.createServer(app)
const sockets = new Server(server)
let data = schema.data


mongoose.connect('mongodb://localhost/aluno_teste') //conexão com o banco de dados

mongoose.connection
    .once('open', () => console.log('Conexao com MongoDB (banco de dados) foi estabelecida com sucesso'))
    .on('error', (error) => {
        console.warn('Falha ao se conectar com o banco de dados. Motivo: ', error)
    })

app.use(express.static('public2'))//torna pública a pasta 'public2' para quem tiver acesso ao "port" exposto pelo server

sockets.on('connection', async (socket) => {

    socket.on('IncluirProduto', async (obj) => {
        //let a = await data.findOne({})
        if(0 == 1){
            async function incluirPedido() {
                try {
                  const response = await api.post('/', {call:"IncluirProduto",app_key:OMIE_APP_KEY,app_secret:OMIE_APP_SECRET,param:[{

For more information, here is the Code

Thanks in advance!

Ionic React Overmind Can’t perform a React state update on an unmounted component

I use Overmind with ionic react:

Tab1:

const { count } = useAppState()
const { increaseCount } = useActions()

return
<IonPage>
  <IonContent>
    <IonRouterLink routerLink='/tab1/page1'>1. Go to another page</IonRouterLink> // Go to page 1
    <IonText><p>{count}</p></IonText>
    <IonButton onClick={() => increaseCount()}>4. Increase again</IonButton>
  </IonContent>
</IonPage>

Page2:

const { count } = useAppState()
const { increaseCount } = useActions()

return
<IonPage>
  <IonContent>
    <IonBackButton defaultHref="/" /> // Go back to tab 1
    <IonText><p>{count}</p></IonText>
    <IonButton onClick={() => increaseCount()}>4. Increase again</IonButton>
  </IonContent>
</IonPage>

When I do this:

  1. Go to the other page
  2. Increase the count (modify state)
  3. Go back to main page
  4. Increase the count (modify state)
    ==> Go to console and there is the error
Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function.

I created this minimum reproduction code: https://github.com/dopeshot/ionic-overmind-cant-perform-state-update

I also created an short video of the issue: https://www.youtube.com/watch?v=5w6r1_lxoS8

How can I fix this issue?

Verifiable Random Function implementation in Javascript [closed]

I’m trying to implement the VRF in JavaScript as described in this paper https://tools.ietf.org/pdf/draft-irtf-cfrg-vrf-06.pdf .
I use ed25519 from the elliptic.js library and the bn.js library for big integer
The ‘ecvrf_prove’ and ‘ecvrf_prove_to_hash’ function already work, but the ‘ecvrf_verify’ function can’t verify the proof.
My first idea was to look at the calculation of U and V in steps 5 and 6. But i didn’t find any error or maybe i didn’t understand the whole thing.
Here is some code, maybe can someone can help me fix this or tell me what i’m doing wrong.
Thanks

// 5.3. ECVRF Verifying
/**
 * ECVRF_verify(Y, pi_string, alpha_string)
 * @param {*} y public key, an EC point
 * @param {*} pi_string  VRF proof, octet string of length ptLen+n+qLen
 * @param {*} alpha_string VRF input, octet string
 * @return ("VALID", beta_string), where beta_string is the VRF hash output, octet string
        of length hLen (64) bytes; or ("INVALID", []) upon failure
 */
function ecvrf_verify(y, pi_string, alpha_string) {
    // 1. D = ECVRF_decode_proof(pi_string)
    // 2. If D is "INVALID", output "INVALID" and stop
    const d = _ecvrf_decode_proof(pi_string)
    if (d == 'INVALID') {
        return 'INVALID'
    }

    // 3. (Gamma, c, s) = D
    const gamma = d[0]
    const c = d[1]
    const s = d[2]

    // 4. H = ECVRF_hash_to_curve(suite_string, y, alpha_string)
    const y_point = _string_to_point(y)
    if (y_point == 'INVALID') {
        return 'INVALID'
    }

    const h = _ecvrf_hash_to_try_and_increment(SUITE_STRING, y_point, alpha_string)
    if (h == 'INVALID') {
        return 'INVALID'
    }

    // 5. U = s*B - c*y
    const s_b = BASE.mul(s)
    let c_y = y_point.mul(c)
    // Negate c_y
    c_y = c_y.neg()
    const u = s_b.add(c_y)

    // 6. V = s*H - c*Gamma
    const s_h = h.mul(s)
    let c_g = gamma.mul(s)
    // Negate c_g
    c_g = c_g.neg()
    const v = s_h.add(c_g)

    // 7. c’ = ECVRF_hash_points(H, Gamma, U, V)
    const cp = _ecvrf_hash_points(h, gamma, u, v)

    // 8. If c and c’ are equal, output ("VALID", ECVRF_proof_to_hash(pi_string)); else output "INVALID"
    if (c.eq(cp)) {
        return {
            status: 'VALID',
            pi_string: ecvrf_proof_to_hash(pi_string)
        }
    }
    else{
        return 'INVALID'
    }
}
// section 5.4.3. ECVRF Hash Points
/**
 * ECVRF_hash_points(P1, P2, ..., PM)
 * @param {*} p1 an EC points in G
 * @param {*} p2 an EC points in G
 * @param {*} p3 an EC points in G
 * @param {*} p4 an EC points in G
 * @retrun c hash value, integer between 0 and 2^(8n)-1
 */
function _ecvrf_hash_points(p1, p2, p3, p4) {
    // 1. two_string = 0x02 = int_to_string(2, 1), a single octet with value 2
    const two_string = Buffer.alloc(1, 2)

    // 2. Initialize str = suite_string || two_string
    let string = Buffer.concat([SUITE_STRING, two_string])

    // 3.for PJ in [P1, P2, ... PM]:
    //       str = str || point_to_string(PJ)
    string = Buffer.concat([string, _point_to_string(p1), _point_to_string(p2), _point_to_string(p3), _point_to_string(p4)])

    // 4. c_string = Hash(str)
    const c_string = _hash(string)

    // 5. truncated_c_string = c_string[0]...c_string[n-1]
    const truncated_c_string = c_string.slice(0, 16)

    // 6. c = string_to_int(truncated_c_string)
   const c = _string_to_int(truncated_c_string)

    // 7. Output c
    return c
}

Specify condition in script in laravel

enter image description here

I have pasted the complete code of script:

 <script>
     var SITEURL = "{{ url('/') }}";
      var today = moment();
      $('#calendar').fullCalendar({
                     defaultView: 'week',
      
                      visibleRange: {
                      start: moment('<? echo $dateFrom;?>T00:00:00'),
                      end: moment('<? echo $dateTo;?>T24:00:00')
                    } ,
                    header: {
                        
                        left: '',
                        center: 'title',
                        right: ''
                      },
                    
                    editable: true,
                    eventLimit: true, // allow "more" link when too many events
                    schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
                       views: {
                        week: {
                           
                             type: 'timeline',
                            slotLabelInterval: { hours: 24},
                            slotDuration: { hours: 24},
                        }
                    },                
                    resourceLabelText: 'Time Slot',
                  
                    resources: [
                        
                        { id: '1', title: '08:00 - 08:30' , eventColor: 'green'},
                        { id: '2', title: '08:30 - 09:00', eventColor: 'green' },
                        { id: '3', title: '09:00 - 09:30', eventColor: 'green'  },
                        { id: '4', title: '09:30 - 10:00', eventColor: 'green'},
                        { id: '5', title: '10:30 - 11:00', eventColor: 'green' },
                        { id: '6', title: '11:30 - 12:00', eventColor: 'green'},
                        { id: '7', title: '12:30 - 13:00', eventColor: 'green' },
                        { id: '8', title: '13:30 - 14:00', eventColor: 'green'},
                        { id: '9', title: '14:30 - 15:00', eventColor: 'green' },
                        { id: '10', title: '15:30 - 16:00', eventColor: 'green'},
                        { id: '11', title: '16:30 - 17:00', eventColor: 'green' },
                        { id: '12', title: '17:30 - 18:00', eventColor: 'green'},
                        { id: '13', title: '18:30 - 19:00', eventColor: 'green' },
                        
                        ],
      
                    events: [
                      <?php
         
           foreach ($data as $sl => $valuegm){
             
  
         ?>
                      { id: '<?php echo $valuegm->id; ?>', 
                      resourceId: '<?php echo $valuegm->timeslot_id; ?>',
                      start: '<?php echo $valuegm->date; ?>',
                      end: '<?php echo $valuegm->date;?>', title: '',
                      description: '<?php if(!$valuegm->doctor_id==null)
                      {echo "<b>".$valuegm->get_doctor->name."</b><br/>".$valuegm->get_doctor->get_specialty->name."<br/>
                      Mobile:".$valuegm->get_doctor->mobile."<br/>
                      Address:".$valuegm->get_doctor->address."<br/>";?><? if(!$valuegm->get_doctor->email==null)
                      { echo "Email:".$valuegm->get_doctor->email."<br/>";}?>
                      <? echo "City:".$valuegm->get_doctor->get_city->description."<br/>";?>
                      <? if(!$valuegm->get_doctor->area_id==null){ echo "Area:".$valuegm->get_doctor->get_area->name."<br/>";}?>
                      <?}else{echo "<b>".$valuegm->get_pharmacy->name."</b><br/>Mobile:".$valuegm->get_pharmacy->mobile."<br/>
                      Address:".$valuegm->get_pharmacy->address."<br/>";?>
                      <? if(!$valuegm->get_pharmacy->email==null){ echo "Email:".$valuegm->get_pharmacy->email."<br/>";}?>
                      <? echo "City:".$valuegm->get_pharmacy->get_city->description."<br/>";?>
                      <? if(!$valuegm->get_pharmacy->area_id==null){ echo "Area:".$valuegm->get_pharmacy->get_area->name."<br/>";}?><?}?>
                      
                    
                    
                    
                      
                      <?php $f = $valuegm->rating; if ($f == 1) { echo "Rating: Positive"; } elseif ($f == 2) { echo "Rating: Netural"; }elseif ($f == 3) { echo "Rating: Negative"; }?>
                      
                      
                    
                    
                    
                      
                      <?php echo "<p>".$valuegm->feedback."</p>";?><br/>',url: SITEURL + '/search/<?php echo $valuegm->id;?>/<?php echo $dateFrom;?>/<?php echo $dateTo;?>'},
                      <?php }?>],
                      
                                          
        eventRender: function(event, element) { 
            element.find('.fc-title').append("<br/>" + event.description ); 
            
        } 
      
                });
   </script>
  

Actually i am working with this part : if the doctor review is positive then background color should be green ,if the doctor review is negative then background color should be red. but now we have specifyed as green. Actually i am working with how to specify the background color based on the feedback of the customer in this below code.

resources: [

                    { id: '1', title: '08:00 - 08:30' , eventColor: 'green'},
                    { id: '2', title: '08:30 - 09:00', eventColor: 'green' },
                    { id: '3', title: '09:00 - 09:30', eventColor: 'green'  },
                    { id: '4', title: '09:30 - 10:00', eventColor: 'green'},
                    { id: '5', title: '10:30 - 11:00', eventColor: 'green' },
                    { id: '6', title: '11:30 - 12:00', eventColor: 'green'},
                    { id: '7', title: '12:30 - 13:00', eventColor: 'green' },
                    { id: '8', title: '13:30 - 14:00', eventColor: 'green'},
                    { id: '9', title: '14:30 - 15:00', eventColor: 'green' },
                    { id: '10', title: '15:30 - 16:00', eventColor: 'green'},
                    { id: '11', title: '16:30 - 17:00', eventColor: 'green' },
                    { id: '12', title: '17:30 - 18:00', eventColor: 'green'},
                    { id: '13', title: '18:30 - 19:00', eventColor: 'green' },

                    ],

i have specifyed the particular line for fetching review(please refer the complete code for
better understanding). please try figure out this:

              <?php $f = $valuegm->rating; if ($f == 1) { echo "Rating: Positive"; } elseif ($f == 2) { echo "Rating: Netural"; }elseif ($f == 3) { echo "Rating: Negative"; }?>

How to draw a image instead of a color in canvas for Agar.io

I am currently making a clone of Agar.io based upon this
I am stuck on getting skins to appear instead of the solid random color. With the current code, when you select a skin, making config.skin true, it freezes and I am not able to move, but can still chat. And I still have no image drawn.

config.skin is a base64 encoded image string

graph is the canvas’s 2d context

    if (config.skin) {
      graph.strokeStyle = "hsl(" + userCurrent.hue + ", 100%, 45%)";
      graph.fillStyle = "hsl(" + userCurrent.hue + ", 100%, 50%)";
      graph.lineWidth = playerConfig.border;
      var skin = new Image();//userCurrent.x - 2 * userCurrent.size, userCurrent.y - 2 * userCurrent.size);
      skin.src = config.skin;
      skin.onload = () => { // jshint ignore:line
        graph.beginPath();
        graph.arc(userCurrent.h / 2, userCurrent.w / 2, userCurrent.radius, 0, Math.PI * 2, false);
        graph.clip();
        graph.drawImage(skin, userCurrent.x - 2 * userCurrent.size, userCurrent.y - 2 * userCurrent.size); //, 4 * userCurrent.size, 4 * userCurrent.size);
      };
    } else {
      graph.strokeStyle = "hsl(" + userCurrent.hue + ", 100%, 45%)";
      graph.fillStyle = "hsl(" + userCurrent.hue + ", 100%, 50%)";
      graph.lineWidth = playerConfig.border;
    }

full code at github