Created
May 15, 2013 11:32
-
-
Save darles/5583363 to your computer and use it in GitHub Desktop.
Tampermonkey plugin for quick open file in PhpStorm from Symfony 2 exception window using Remote call ( http://plugins.jetbrains.com/plugin?pr=phpStorm&pluginId=6027 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Error handler for Symfony and PHPStorm | |
// @version 0.1 | |
// @description Quickly open files in PhpStorm from Symfony error pages using Remote Call plugin. | |
// @match http://*/* | |
// @author darles | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js | |
// ==/UserScript== | |
var input = $('h1').html(); | |
input = input.replace(/([/A-Za-z]+.php)/gim, '<a class="open_in_phpstorm" href="#">$1</a>'); | |
input = input.replace(/([A-Za-z]+(\\[A-Za-z]+)+[^\s,::"])/gim, '<a class="open_in_phpstorm" href="#">$1</a>'); | |
$('h1').replaceWith('<h1>'+input+'</h1>'); | |
$('h2').each(function(index) { | |
var item = false; | |
item = $(this).html().replace(/([/A-Za-z]+.php)/gim, '<a class="open_in_phpstorm" href="#">$1</a>'); | |
item = item.replace(/([A-Za-z]+(\\[A-Za-z]+)+[^\s,::"])/gim, '<a class="open_in_phpstorm" href="#">$1</a>'); | |
$(this).replaceWith('<h2>'+item+'</h2>'); | |
}); | |
$('.open_in_phpstorm').on('click', function() { | |
var file = $(this).text().replace(/\\/gi, '/').replace('.php', ''); | |
$.ajax({ | |
'url': 'http://localhost:8091/?message='+file+'.php:80' | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment