mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
Moved all prototype and helper functions from db/_init to a new db/_runtime_helpers file for better modularity and maintainability. Updated db/_init to include the new helpers script and removed duplicate code. No functional changes to detection logic.
79 lines
No EOL
2.3 KiB
Text
79 lines
No EOL
2.3 KiB
Text
// Detect It Easy: DiE-JS framework file
|
|
// Don't change anything unless you're sure about what you're doing
|
|
|
|
includeScript("_debug");
|
|
|
|
var bDetected,
|
|
sType,
|
|
sName,
|
|
sVersion,
|
|
sOptions,
|
|
sLang,
|
|
sLangVersion;
|
|
|
|
/**
|
|
* Initializes the detection process with the given parameters.
|
|
*
|
|
* @param {string} sType - The type of the item to detect. Defaults to "unknown".
|
|
* @param {string} sName - The name of the item to detect. Defaults to "unknown".
|
|
* @param {string} [sVersion] - The version of the item to detect. Optional.
|
|
* @param {string} [sOptions] - Additional options for detection. Optional.
|
|
* @param {string} [sLang] - The programming language of the item to detect. Optional.
|
|
* @param {string} [sLangVersion] - The version of the programming language. Optional.
|
|
*/
|
|
function meta(sTypeInput, sNameInput) {
|
|
if (!sTypeInput) _error("No input type.");
|
|
|
|
sType = sTypeInput;
|
|
sName = sNameInput;
|
|
|
|
sVersion = arguments[2] ? arguments[2] : "";
|
|
sOptions = arguments[3] ? arguments[3] : "";
|
|
sLang = arguments[4] ? arguments[4] : "";
|
|
sLangVersion = arguments[5] ? arguments[5] : "";
|
|
|
|
bDetected = false;
|
|
}
|
|
|
|
function init() { meta.apply(null, arguments); }
|
|
|
|
|
|
/**
|
|
* Processes the detection result and resets the detection variables.
|
|
*
|
|
* If a detection has been made (bDetected is true), this function sets the result
|
|
* using the _setResult function with the provided type, name, version, and options.
|
|
* After setting the result, it resets the detection flag (bDetected) to false.
|
|
*
|
|
* Regardless of whether a detection was made, it resets the sName, sVersion, and sOptions
|
|
* variables to empty strings.
|
|
*/
|
|
function result() {
|
|
if (bDetected) {
|
|
sVersion = sVersion ? sVersion : String();
|
|
sOptions = sOptions ? sOptions : String();
|
|
|
|
if (sName) {
|
|
_setResult(sType, sName, sVersion, sOptions);
|
|
|
|
if (sLang) {
|
|
if (sLangVersion) {
|
|
_setLang(sLang, sLangVersion);
|
|
} else {
|
|
_setLang(sLang);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
sName = sVersion = sOptions = sLang = sLangVersion = '';
|
|
|
|
var resultValue = bDetected;
|
|
|
|
bDetected = false;
|
|
|
|
return resultValue;
|
|
}
|
|
|
|
includeScript("_runtime_helpers");
|
|
includeScript("language"); |