Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Conversation

@xharpenParksuhyeon
Copy link

When a JavaScript file is added to the xray bar, we want to add our own custom JavaScript file on our end.

The JavaScript code we want to add is as follows:

$('body').on('click', '.xray-specimen-handle.Specimen', function(e) {
  const $specimen = $(e.target).closest('.xray-specimen.Specimen');
  const title = $specimen.attr('title');

  const apiUrl = `http://localhost:63342/api/file/${title}`;
  window.open(apiUrl);
});

Clicking on the part of the image highlighted below will display the corresponding view file in the IDE.

스크린샷 2023-02-25 오전 4 16 45

Therefore, when a JavaScript file is added to the xray bar, we want to trigger the event shown below.

<?php

// This is the XrayMiddleware class.

protected function injectXrayBar($response)
{
    
    // The existing code.
    event(new InjectedXrayBar($response));
}
<?php

namespace BeyondCode\ViewXray\Events;

use Illuminate\Http\Response;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;

class InjectedXrayBar
{
    use SerializesModels;

    /** @var Response */
    private $response;

    public function __construct(Response $response)
    {
        $this->response = $response;
    }

    /**
     * @return Response
     */
    public function getResponse()
    {
        return $this->response;
    }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant