Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
29224500
Commit
29224500
authored
Jun 15, 2018
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_gadget_interface_validator] Remove not needed defer
parent
598bb3fe
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
138 deletions
+68
-138
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_js.js
...r/PathTemplateItem/web_page_module/gadget_interface_js.js
+68
-138
No files found.
bt5/erp5_gadget_interface_validator/PathTemplateItem/web_page_module/gadget_interface_js.js
View file @
29224500
...
@@ -85,17 +85,12 @@
...
@@ -85,17 +85,12 @@
}
}
function
fetchAppcacheData
(
appcache_url
)
{
function
fetchAppcacheData
(
appcache_url
)
{
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
appcache_url
);
return
ajax
(
appcache_url
);
})
})
.
push
(
function
(
xhr
)
{
.
push
(
function
(
xhr
)
{
var
filename_list
=
xhr
.
responseText
.
split
(
'
\n
'
);
return
xhr
.
responseText
.
split
(
'
\n
'
);
return
filename_list
;
},
function
(
error
)
{
defer
.
reject
(
error
);
return
defer
.
promise
;
});
});
}
}
...
@@ -136,7 +131,6 @@
...
@@ -136,7 +131,6 @@
}
}
function
getInterfaceListFromURL
(
gadget_url
)
{
function
getInterfaceListFromURL
(
gadget_url
)
{
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
gadget_url
);
return
ajax
(
gadget_url
);
...
@@ -165,16 +159,14 @@
...
@@ -165,16 +159,14 @@
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the gadget data.
\n
"
;
var
message
=
"
Error with loading the gadget data.
\n
"
;
error
.
message
=
message
+
generateErrorMessage
(
error
);
error
.
message
=
message
+
generateErrorMessage
(
error
);
defer
.
reject
(
error
);
throw
error
;
return
defer
.
promise
;
});
});
}
}
function
verifyInterfaceDefinition
(
interface_url
)
{
function
verifyInterfaceDefinition
(
interface_url
)
{
//to verify if interface definition follows the correct template.
//to verify if interface definition follows the correct template.
var
error_message
=
"
Interface definition is incorrect:
"
+
var
error_message
=
"
Interface definition is incorrect:
"
+
"
One or more required tags are missing.
"
,
"
One or more required tags are missing.
"
;
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
interface_url
);
return
ajax
(
interface_url
);
...
@@ -192,7 +184,6 @@
...
@@ -192,7 +184,6 @@
if
(
dl_list
[
0
].
childElementCount
!==
3
*
method_len
)
{
if
(
dl_list
[
0
].
childElementCount
!==
3
*
method_len
)
{
throw
new
Error
(
error_message
);
throw
new
Error
(
error_message
);
}
}
try
{
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
if
((
next_element
===
null
)
||
if
((
next_element
===
null
)
||
(
next_element
.
localName
.
toLowerCase
()
!==
'
dt
'
))
{
(
next_element
.
localName
.
toLowerCase
()
!==
'
dt
'
))
{
...
@@ -226,32 +217,19 @@
...
@@ -226,32 +217,19 @@
}
}
next_element
=
next_element
.
nextElementSibling
;
next_element
=
next_element
.
nextElementSibling
;
}
}
defer
.
resolve
(
"
Success
"
);
}
catch
(
error
)
{
defer
.
reject
(
error
);
}
return
defer
.
promise
;
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the interface data.
\n
"
;
var
message
=
"
Error with loading the interface data.
\n
"
;
error
.
message
=
message
+
generateErrorMessage
(
error
);
error
.
message
=
message
+
generateErrorMessage
(
error
);
defer
.
reject
(
error
);
throw
error
;
return
defer
.
promise
;
});
});
}
}
function
verifyInterfaceDeclaration
(
interface_url
,
declared_interface_list
)
{
function
verifyInterfaceDeclaration
(
interface_url
,
declared_interface_list
)
{
//to verify if gadget declares the interface.
//to verify if gadget declares the interface.
var
defer
=
RSVP
.
defer
();
try
{
if
(
declared_interface_list
.
indexOf
(
interface_url
)
>
-
1
)
{
if
(
declared_interface_list
.
indexOf
(
interface_url
)
>
-
1
)
{
defer
.
resolve
(
"
Success
"
);
return
"
Success
"
;
}
else
{
throw
new
Error
(
"
Interface is not declared.
"
);
}
}
}
catch
(
error
)
{
throw
new
Error
(
"
Interface is not declared.
"
);
defer
.
reject
(
error
);
}
return
defer
.
promise
;
}
}
/*
/*
...
@@ -320,8 +298,7 @@
...
@@ -320,8 +298,7 @@
function
verifyAllMethodDeclared
(
interface_method_list
,
gadget_method_list
)
{
function
verifyAllMethodDeclared
(
interface_method_list
,
gadget_method_list
)
{
//to verify if all the interface methods are declared by the gadget.
//to verify if all the interface methods are declared by the gadget.
var
defer
=
RSVP
.
defer
(),
var
gadget_method_name_list
=
gadget_method_list
,
gadget_method_name_list
=
gadget_method_list
,
interface_method_name_list
=
[],
interface_method_name_list
=
[],
i
,
i
,
j
,
j
,
...
@@ -331,7 +308,6 @@
...
@@ -331,7 +308,6 @@
for
(
i
=
0
;
i
<
interface_method_list
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
interface_method_list
.
length
;
i
+=
1
)
{
interface_method_name_list
.
push
(
interface_method_list
[
i
].
name
);
interface_method_name_list
.
push
(
interface_method_list
[
i
].
name
);
}
}
try
{
for
(
j
=
0
;
j
<
interface_method_name_list
.
length
;
j
+=
1
)
{
for
(
j
=
0
;
j
<
interface_method_name_list
.
length
;
j
+=
1
)
{
if
(
gadget_method_name_list
.
indexOf
(
if
(
gadget_method_name_list
.
indexOf
(
interface_method_name_list
[
j
]
interface_method_name_list
[
j
]
...
@@ -348,21 +324,16 @@
...
@@ -348,21 +324,16 @@
}
}
throw
new
Error
(
error_message
);
throw
new
Error
(
error_message
);
}
}
defer
.
resolve
(
"
Success
"
);
return
"
Success
"
;
}
catch
(
error
)
{
defer
.
reject
(
error
);
}
return
defer
.
promise
;
}
}
function
verifyAllMethod
(
interface_method_list
,
gadget_method_list
)
{
function
verifyAllMethod
(
interface_method_list
,
gadget_method_list
)
{
//to verify all methods of gadget and interface.
//to verify all methods of gadget and interface.
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
verifyAllMethodDeclared
(
interface_method_list
,
return
verifyAllMethodDeclared
(
interface_method_list
,
gadget_method_list
[
0
]);
gadget_method_list
[
0
]);
})
})
;
/* Commented till figure out the way to fetch the argument length of a
/* Commented till figure out the way to fetch the argument length of a
defined function.
defined function.
.push(function() {
.push(function() {
...
@@ -370,55 +341,30 @@
...
@@ -370,55 +341,30 @@
gadget_method_list[1]);
gadget_method_list[1]);
})
})
*/
*/
.
push
(
function
()
{
defer
.
resolve
(
"
Success
"
);
return
defer
.
promise
;
},
function
(
error
)
{
defer
.
reject
(
error
);
return
defer
.
promise
;
});
}
}
rJS
(
window
)
rJS
(
window
)
.
ready
(
function
(
g
)
{
g
.
props
=
{};
})
.
declareMethod
(
"
getVerifyGadget
"
,
function
(
gadget_url
)
{
.
declareMethod
(
"
getVerifyGadget
"
,
function
(
gadget_url
)
{
var
interface_gadget
=
this
,
var
interface_gadget
=
this
;
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
interface_gadget
.
declareGadget
(
gadget_url
,
{
return
interface_gadget
.
declareGadget
(
gadget_url
,
{
scope
:
gadget_url
scope
:
gadget_url
});
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
interface_gadget
.
getDeclaredGadget
(
gadget_url
);
return
interface_gadget
.
getDeclaredGadget
(
gadget_url
);
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the gadget.
\n
"
;
var
message
=
"
Error with loading the gadget.
\n
"
;
error
.
message
=
message
+
error
.
message
;
error
.
message
=
message
+
error
.
message
;
defer
.
reject
(
error
);
throw
error
;
return
defer
.
promise
;
});
});
})
})
.
declareMethod
(
"
getDeclaredGadgetInterfaceList
"
,
function
(
gadget_data
)
{
.
declareMethod
(
"
getDeclaredGadgetInterfaceList
"
,
function
(
gadget_data
)
{
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
if
(
gadget_data
.
constructor
===
String
)
{
if
(
gadget_data
.
constructor
===
String
)
{
return
getInterfaceListFromURL
(
gadget_data
);
return
getInterfaceListFromURL
(
gadget_data
);
}
}
return
gadget_data
.
getInterfaceList
();
return
gadget_data
.
getInterfaceList
();
})
})
.
push
(
function
(
interface_list
)
{
return
interface_list
;
},
function
(
error
)
{
defer
.
reject
(
error
);
return
defer
.
promise
;
});
})
.
declareMethod
(
"
getDeclaredGadgetMethodList
"
,
function
(
gadget
)
{
.
declareMethod
(
"
getDeclaredGadgetMethodList
"
,
function
(
gadget
)
{
var
declared_method_dict
=
{},
var
declared_method_dict
=
{},
...
@@ -443,27 +389,17 @@
...
@@ -443,27 +389,17 @@
})
})
.
declareMethod
(
"
getGadgetListFromAppcache
"
,
function
(
appcache_url
)
{
.
declareMethod
(
"
getGadgetListFromAppcache
"
,
function
(
appcache_url
)
{
var
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
fetchAppcacheData
(
appcache_url
);
return
fetchAppcacheData
(
appcache_url
);
})
})
.
push
(
function
(
filename_list
)
{
.
push
(
function
(
filename_list
)
{
return
filterGadgetList
(
filename_list
);
return
filterGadgetList
(
filename_list
);
})
.
push
(
function
(
filtered_gadget_list
)
{
return
filtered_gadget_list
;
},
function
(
error
)
{
defer
.
reject
(
error
);
return
defer
.
promise
;
});
});
})
})
.
declareMethod
(
"
getAbsoluteURL
"
,
function
(
gadget
,
url
)
{
.
declareMethod
(
"
getAbsoluteURL
"
,
function
(
gadget
,
url
)
{
return
new
RSVP
.
Queue
()
return
gadget
.
getPath
()
.
push
(
function
()
{
return
gadget
.
getPath
();
})
.
push
(
function
(
base_url
)
{
.
push
(
function
(
base_url
)
{
return
rJS
.
getAbsoluteURL
(
url
,
base_url
);
return
rJS
.
getAbsoluteURL
(
url
,
base_url
);
});
});
...
@@ -474,8 +410,7 @@
...
@@ -474,8 +410,7 @@
name
:
""
,
name
:
""
,
description
:
""
,
description
:
""
,
method_list
:
[]
method_list
:
[]
},
};
defer
=
RSVP
.
defer
();
return
new
RSVP
.
Queue
()
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
.
push
(
function
()
{
return
ajax
(
interface_url
);
return
ajax
(
interface_url
);
...
@@ -483,9 +418,9 @@
...
@@ -483,9 +418,9 @@
.
push
(
function
(
xhr
)
{
.
push
(
function
(
xhr
)
{
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
var
doc
=
(
new
DOMParser
()).
parseFromString
(
xhr
.
responseText
,
'
text/html
'
).
body
,
'
text/html
'
).
body
,
dl_list
=
doc
.
getElementsByTagName
(
'
dl
'
),
dl_list
=
doc
.
querySelectorAll
(
'
dl
'
),
dt_list
=
doc
.
getElementsByTagName
(
'
dt
'
),
dt_list
=
doc
.
querySelectorAll
(
'
dt
'
),
dd_list
=
doc
.
getElementsByTagName
(
'
dd
'
),
dd_list
=
doc
.
querySelectorAll
(
'
dd
'
),
method_len
=
dl_list
.
length
-
1
,
method_len
=
dl_list
.
length
-
1
,
dt_count
=
0
,
dt_count
=
0
,
dl_count
=
1
,
dl_count
=
1
,
...
@@ -494,16 +429,16 @@
...
@@ -494,16 +429,16 @@
argument_len
,
argument_len
,
j
,
j
,
argument_item
;
argument_item
;
interface_data
.
name
=
doc
.
getElementsByTagName
(
'
h1
'
)[
0
]
.
innerHTML
;
interface_data
.
name
=
doc
.
querySelector
(
'
h1
'
)
.
innerHTML
;
interface_data
.
description
=
interface_data
.
description
=
doc
.
getElementsByTagName
(
'
h3
'
)[
0
]
.
innerHTML
;
doc
.
querySelector
(
'
h3
'
)
.
innerHTML
;
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
method_len
;
i
+=
1
)
{
method
=
{
method
=
{
name
:
dt_list
[
dt_count
].
innerHTML
,
name
:
dt_list
[
dt_count
].
innerHTML
,
description
:
dd_list
[
dt_count
].
innerHTML
,
description
:
dd_list
[
dt_count
].
innerHTML
,
argument_list
:
[]
argument_list
:
[]
};
};
argument_len
=
dl_list
[
dl_count
].
getElementsByTagName
(
'
dt
'
)
argument_len
=
dl_list
[
dl_count
].
querySelectorAll
(
'
dt
'
)
.
length
;
.
length
;
dt_count
+=
1
;
dt_count
+=
1
;
dl_count
+=
1
;
dl_count
+=
1
;
...
@@ -524,19 +459,14 @@
...
@@ -524,19 +459,14 @@
},
function
(
error
)
{
},
function
(
error
)
{
var
message
=
"
Error with loading the interface data.
\n
"
;
var
message
=
"
Error with loading the interface data.
\n
"
;
error
.
message
=
message
+
generateErrorMessage
(
error
);
error
.
message
=
message
+
generateErrorMessage
(
error
);
defer
.
reject
(
error
);
throw
error
;
return
defer
.
promise
;
});
});
})
})
.
declareMethod
(
"
getDefinedInterfaceMethodList
"
,
function
(
interface_url
)
{
.
declareMethod
(
"
getDefinedInterfaceMethodList
"
,
function
(
interface_url
)
{
var
defer
=
RSVP
.
defer
();
return
this
.
getInterfaceData
(
interface_url
)
return
this
.
getInterfaceData
(
interface_url
)
.
push
(
function
(
interface_data
)
{
.
push
(
function
(
interface_data
)
{
return
interface_data
.
method_list
;
return
interface_data
.
method_list
;
},
function
(
error
)
{
defer
.
reject
(
error
);
return
defer
.
promise
;
});
});
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment