mirror of
https://github.com/pierre42100/comunic
synced 2025-09-19 05:49:16 +00:00
First commit
This commit is contained in:
26
3rdparty/luminous/languages/javascript.php
vendored
Executable file
26
3rdparty/luminous/languages/javascript.php
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class LuminousJavaScriptScanner extends LuminousECMAScriptScanner {
|
||||
// mostly the same for now
|
||||
|
||||
public static function guess_language($src, $info) {
|
||||
// JavaScript is surprisingly indistinct when you think about it,
|
||||
// so these are a bit of a stretch and it's hard to ever return a
|
||||
// value more than ~40%
|
||||
$p = 0;
|
||||
// var x =
|
||||
// not amazingly distinct, but something
|
||||
if (preg_match('/var\s++\w++\s*+=/', $src)) $p += 0.05;
|
||||
// $, jquery
|
||||
if (preg_match('/\\b$\\( | jQuery/x', $src)) $p += 0.20;
|
||||
// typeof x == undefined
|
||||
if (preg_match('/typeof\s++\w++\s*+[!=]{2,3}+\s*+[\'"]?+undefined/i', $src))
|
||||
$p += 0.10;
|
||||
if (strpos($src, 'document.') !== false) $p += 0.10;
|
||||
if (strpos($src, 'Math.') !== false) $p += 0.05;
|
||||
// Anonymous functions
|
||||
if (preg_match('/function\s*+\\([^)]*+\\)\s*+\\{/', $src))
|
||||
$p += 0.05;
|
||||
return $p;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user