mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
Use getclassname to avoid dependency cyle
This commit is contained in:
parent
8a2aef62f4
commit
656c4ef8a9
19 changed files with 53 additions and 47 deletions
|
|
@ -7,7 +7,7 @@ class Button extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassname() {
|
||||
return "Button";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class Container extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "Container";
|
||||
}
|
||||
getlayout(id) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Group extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "Group";
|
||||
}
|
||||
getobject(id) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class GuiObject extends MakiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "GuiObject";
|
||||
}
|
||||
findobject(id) {
|
||||
|
|
@ -52,17 +52,17 @@ class GuiObject extends MakiObject {
|
|||
}
|
||||
|
||||
gettop() {
|
||||
unimplementedWarning('gettop');
|
||||
unimplementedWarning("gettop");
|
||||
return 5;
|
||||
}
|
||||
|
||||
getheight() {
|
||||
unimplementedWarning('getheight');
|
||||
unimplementedWarning("getheight");
|
||||
return 100;
|
||||
}
|
||||
|
||||
getwidth() {
|
||||
unimplementedWarning('getwidth');
|
||||
unimplementedWarning("getwidth");
|
||||
return 100;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class JsElements extends MakiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassname() {
|
||||
return "Elements";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class JsGammaSet extends MakiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "GammaSet";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class JsGroupDef extends MakiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassname() {
|
||||
return "GroupDef";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Layer extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "Layer";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ class Layout extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "Layout";
|
||||
}
|
||||
getcontainer() {
|
||||
return findParentNodeOfType(this, ["container"]);;
|
||||
return findParentNodeOfType(this, ["container"]);
|
||||
}
|
||||
|
||||
resize(x, y, w, h) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class List extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "List";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ class MakiObject {
|
|||
},
|
||||
// ugly but works for now
|
||||
name: this.constructor.name.toLowerCase(),
|
||||
type: 'element'
|
||||
}
|
||||
type: "element",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ class MakiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "Object";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,20 +8,20 @@ class PopupMenu extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "PopupMenu";
|
||||
}
|
||||
addcommand(txt, id, checked, disabled) {
|
||||
unimplementedWarning('addcommand');
|
||||
unimplementedWarning("addcommand");
|
||||
}
|
||||
addseparator() {
|
||||
unimplementedWarning('addseparator');
|
||||
unimplementedWarning("addseparator");
|
||||
}
|
||||
checkcommand(id, check) {
|
||||
unimplementedWarning('checkcommand');
|
||||
unimplementedWarning("checkcommand");
|
||||
}
|
||||
popatmouse() {
|
||||
unimplementedWarning('popatmouse');
|
||||
unimplementedWarning("popatmouse");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Slider extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getClassName() {
|
||||
getclassaname() {
|
||||
return "Slider";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Status extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "Status";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class System extends MakiObject {
|
|||
|
||||
this.scriptGroup = scriptGroup;
|
||||
this.root = scriptGroup;
|
||||
while(this.root.parent) {
|
||||
while (this.root.parent) {
|
||||
this.root = this.root.parent;
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ class System extends MakiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "System";
|
||||
}
|
||||
|
||||
|
|
@ -37,11 +37,11 @@ class System extends MakiObject {
|
|||
return "5.666";
|
||||
}
|
||||
gettoken(str, separator, tokennum) {
|
||||
unimplementedWarning('gettoken');
|
||||
unimplementedWarning("gettoken");
|
||||
return "Some Token String";
|
||||
}
|
||||
getparam() {
|
||||
unimplementedWarning('getparam');
|
||||
unimplementedWarning("getparam");
|
||||
return "Some String";
|
||||
}
|
||||
messagebox(message, msgtitle, flag, notanymoreId) {
|
||||
|
|
@ -51,22 +51,22 @@ class System extends MakiObject {
|
|||
return value.toString();
|
||||
}
|
||||
getprivateint(section, item, defvalue) {
|
||||
unimplementedWarning('getprivateint');
|
||||
unimplementedWarning("getprivateint");
|
||||
return defvalue;
|
||||
}
|
||||
setprivateint(section, item, defvalue) {
|
||||
unimplementedWarning('setprivateint');
|
||||
unimplementedWarning("setprivateint");
|
||||
}
|
||||
getleftvumeter() {
|
||||
unimplementedWarning('getleftvumeter');
|
||||
unimplementedWarning("getleftvumeter");
|
||||
return 0.5;
|
||||
}
|
||||
getrightvumeter() {
|
||||
unimplementedWarning('getrightvumeter');
|
||||
unimplementedWarning("getrightvumeter");
|
||||
return 0.5;
|
||||
}
|
||||
getvolume() {
|
||||
unimplementedWarning('getvolume');
|
||||
unimplementedWarning("getvolume");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class Text extends GuiObject {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "Text";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class ToggleButton extends Button {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "ToggleButton";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class WinampAbstractionLayer extends Group {
|
|||
* Returns the class name for the object.
|
||||
* @ret The class name.
|
||||
*/
|
||||
static getclassname() {
|
||||
getclassaname() {
|
||||
return "WinampAbstractionLayer";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { xml2js } from "xml-js";
|
||||
const JsElements = require("./runtime/JsElements");
|
||||
const JsGroupDef = require("./runtime/JsGroupDef");
|
||||
|
||||
export function getCaseInsensitveFile(zip, filename) {
|
||||
// TODO: Escape `file` for rejex characters
|
||||
|
|
@ -108,8 +106,10 @@ export function findParentNodeOfType(node, type) {
|
|||
let n = node;
|
||||
while (n.parent) {
|
||||
n = n.parent;
|
||||
if ((!Array.isArray(type) && n.xmlNode.name === type) ||
|
||||
(Array.isArray(type) && type.includes(n.xmlNode.name))) {
|
||||
if (
|
||||
(!Array.isArray(type) && n.xmlNode.name === type) ||
|
||||
(Array.isArray(type) && type.includes(n.xmlNode.name))
|
||||
) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
|
@ -121,12 +121,14 @@ export function findDescendantByTypeAndId(node, type, id) {
|
|||
}
|
||||
|
||||
const idLC = id.toLowerCase();
|
||||
for(let i = 0; i < node.children.length; i++) {
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
const child = node.children[i];
|
||||
if ((!type || child.xmlNode.name === type) &&
|
||||
(child.xmlNode.attributes !== undefined &&
|
||||
child.xmlNode.attributes.id !== undefined &&
|
||||
child.xmlNode.attributes.id.toLowerCase() === idLC)) {
|
||||
if (
|
||||
(!type || child.xmlNode.name === type) &&
|
||||
(child.xmlNode.attributes !== undefined &&
|
||||
child.xmlNode.attributes.id !== undefined &&
|
||||
child.xmlNode.attributes.id.toLowerCase() === idLC)
|
||||
) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
|
@ -173,7 +175,7 @@ function findInLexicalScope(node, pred) {
|
|||
// return the first child of an <Elements> that matches id
|
||||
export function findElementById(node, id) {
|
||||
return findInLexicalScope(node, child => {
|
||||
if (child instanceof JsElements) {
|
||||
if (child.getclassname && child.getclassname() === "Elements") {
|
||||
const element = findDirectDescendantById(child, id);
|
||||
if (element) {
|
||||
return element;
|
||||
|
|
@ -185,7 +187,11 @@ export function findElementById(node, id) {
|
|||
// Search up the tree for a <GroupDef> node that is in node's lexical scope and matches id.
|
||||
export function findGroupDefById(node, id) {
|
||||
return findInLexicalScope(node, child => {
|
||||
if (child instanceof JsGroupDef && child.xmlNode.attributes.id === id) {
|
||||
if (
|
||||
child.getclassname &&
|
||||
child.getclassname() === "GroupDef" &&
|
||||
child.xmlNode.attributes.id === id
|
||||
) {
|
||||
return child;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue