mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-23 21:15:49 +02:00
Add a function to code.js that checks if an object contains a nested property
This commit is contained in:
parent
d06834617b
commit
5929067a3d
@ -104,6 +104,13 @@ public void Alert(string type, string contents){
|
||||
MessageBox.Show(contents, Program.BrandName+" Browser Message", MessageBoxButtons.OK, icon);
|
||||
}
|
||||
|
||||
public void CrashDebug(string message){
|
||||
#if DEBUG
|
||||
Log(message);
|
||||
System.Diagnostics.Debugger.Break();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Log(string data){
|
||||
System.Diagnostics.Debug.WriteLine(data);
|
||||
}
|
||||
|
@ -62,6 +62,22 @@
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// Function: Returns true if an object has a specified property, otherwise returns false without throwing an error.
|
||||
//
|
||||
var ensurePropertyExists = function(obj, ...chain){
|
||||
for(var index = 0; index < chain.length; index++){
|
||||
if (!obj.hasOwnProperty(chain[index])){
|
||||
$TD.crashDebug("Missing property "+chain[index]+" in chain [obj]."+chain.join("."));
|
||||
return false;
|
||||
}
|
||||
|
||||
obj = obj[chain[index]];
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
//
|
||||
// Function: Retrieves a property of an element with a specified class.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user