Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cribjs-editor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
cribjs-editor
Commits
afae8a6c
Commit
afae8a6c
authored
Jun 15, 2020
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JS Lint tool
parent
b06bd370
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
254 additions
and
1 deletion
+254
-1
gadget/gadget_cribjs_header.html
gadget/gadget_cribjs_header.html
+1
-0
gadget/gadget_cribjs_header.js
gadget/gadget_cribjs_header.js
+1
-1
gadget/gadget_cribjs_page_jslint.html
gadget/gadget_cribjs_page_jslint.html
+43
-0
gadget/gadget_cribjs_page_jslint.js
gadget/gadget_cribjs_page_jslint.js
+140
-0
gadget/gadget_cribjs_page_tools.html
gadget/gadget_cribjs_page_tools.html
+25
-0
gadget/gadget_cribjs_page_tools.js
gadget/gadget_cribjs_page_tools.js
+44
-0
No files found.
gadget/gadget_cribjs_header.html
View file @
afae8a6c
...
...
@@ -56,6 +56,7 @@
<li><a
class=
"url_list"
href=
"#page=url_list"
>
URL List
</a></li>
<li><a
class=
"editor"
href=
"#page=editor"
>
Editor
</a></li>
<li><a
class=
"save_load"
href=
"#page=save_load"
>
Export/Import
</a></li>
<li><a
class=
"tools"
href=
"#page=tools"
>
Tools
</a></li>
<li><a
class=
"mass_remove"
href=
"#page=mass_remove"
>
Remove
</a></li>
</ul>
</div>
...
...
gadget/gadget_cribjs_header.js
View file @
afae8a6c
...
...
@@ -121,7 +121,7 @@
*/
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
,
page_list
=
[
"
cribjs_home
"
,
"
select_site
"
,
"
url_list
"
,
"
editor
"
,
"
save_load
"
,
"
mass_remove
"
],
page_list
=
[
"
cribjs_home
"
,
"
select_site
"
,
"
url_list
"
,
"
editor
"
,
"
save_load
"
,
"
tools
"
,
"
mass_remove
"
],
promise_list
=
[];
gadget
.
stats
.
options
=
options
;
...
...
gadget/gadget_cribjs_page_jslint.html
0 → 100644
View file @
afae8a6c
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no"
/>
<title>
CribJS Header
</title>
<!-- renderjs -->
<script
src=
"../lib/rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.js"
type=
"text/javascript"
></script>
<script
src=
"./gadget_global.js"
type=
"text/javascript"
></script>
<script
type=
"text/javascript"
src=
"../lib/jshint.js"
></script>
<!-- Custom -->
<script
src=
"./gadget_cribjs_page_jslint.js"
type=
"text/javascript"
></script>
</head>
<body>
<div
class=
"nav_content url_list container"
>
<form
class=
"crib-url-list-content"
>
<h3>
URL List
</h3>
<button
type=
"submit"
name=
"list-contents"
class=
"btn btn-default"
>
Refresh
</button>
<table
class=
"table table-striped table-condensed"
>
<thead>
<tr>
<th>
JSLint
</th>
<th>
Url
</th>
<th>
Go
</th>
</tr>
</thead>
<tfoot>
</tfoot>
<tbody>
</tbody>
</table>
<div>
<button
type=
"submit"
name=
"list-contents"
class=
"btn btn-default"
>
Refresh
</button>
</div>
</form>
</div>
</body>
</html>
\ No newline at end of file
gadget/gadget_cribjs_page_jslint.js
0 → 100644
View file @
afae8a6c
/*global window, rJS, JSHINT, RSVP, jIO, document, loopEventListener */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(
function
(
window
,
rJS
,
JSHINT
,
jIO
,
loopEventListener
)
{
"
use strict
"
;
function
getURLContentAsText
(
gadget
,
url
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
crib_sw_get
(
url
);
})
.
push
(
function
(
data
)
{
var
type
;
type
=
data
.
type
;
return
jIO
.
util
.
readBlobAsText
(
data
,
type
);
})
.
push
(
function
(
event
)
{
return
event
.
target
.
result
;
});
}
function
displayURLList
(
gadget
,
event
)
{
var
url_list
=
[];
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
crib_sw_allDocs
();
})
.
push
(
function
(
data
)
{
var
promise_list
=
[],
tmp_url_list
=
[],
url
;
if
(
data
.
hasOwnProperty
(
"
urls
"
))
{
tmp_url_list
=
data
.
urls
;
}
else
{
tmp_url_list
=
data
;
}
for
(
url
in
tmp_url_list
)
{
if
(
tmp_url_list
.
hasOwnProperty
(
url
))
{
if
(
url
.
endsWith
(
"
.js
"
))
{
url_list
.
push
(
url
);
promise_list
.
push
(
RSVP
.
all
([
gadget
.
getUrlFor
({
page
:
'
editor
'
,
url
:
url
}),
getURLContentAsText
(
gadget
,
url
)
]));
}
}
}
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
result_list
)
{
var
contentsElement
=
gadget
.
props
.
element
.
querySelector
(
'
.crib-url-list-content tbody
'
),
footer_element
=
gadget
.
props
.
element
.
querySelector
(
'
.crib-url-list-content tfoot
'
),
url_number
,
error_number
=
0
,
url
,
trElement
,
tdElement
;
// Clear out the existing items from the list.
while
(
contentsElement
.
firstChild
)
{
contentsElement
.
removeChild
(
contentsElement
.
firstChild
);
}
// Add each cached URL to the list, one by one.
for
(
url_number
=
0
;
url_number
<
url_list
.
length
;
url_number
++
)
{
url
=
url_list
[
url_number
];
var
element
;
JSHINT
(
result_list
[
url_number
][
1
]);
trElement
=
document
.
createElement
(
'
tr
'
);
tdElement
=
document
.
createElement
(
'
td
'
);
tdElement
.
innerHTML
=
(
JSHINT
.
data
().
errors
?
"
<span>❌</span>
"
:
""
);
trElement
.
appendChild
(
tdElement
);
tdElement
=
document
.
createElement
(
'
td
'
);
element
=
document
.
createElement
(
'
a
'
);
element
.
setAttribute
(
'
href
'
,
result_list
[
url_number
][
0
]);
element
.
textContent
=
url
;
tdElement
.
appendChild
(
element
);
trElement
.
appendChild
(
tdElement
);
tdElement
=
document
.
createElement
(
'
td
'
);
element
=
document
.
createElement
(
'
a
'
);
element
.
textContent
=
"
Go
"
;
element
.
setAttribute
(
'
href
'
,
url
);
element
.
setAttribute
(
'
target
'
,
"
_blank
"
);
element
.
setAttribute
(
"
class
"
,
"
btn btn-primary btn-xs
"
);
tdElement
.
appendChild
(
element
);
trElement
.
appendChild
(
tdElement
);
contentsElement
.
appendChild
(
trElement
);
error_number
=
JSHINT
.
data
().
errors
?
error_number
+
1
:
error_number
;
}
while
(
footer_element
.
firstChild
)
{
footer_element
.
removeChild
(
footer_element
.
firstChild
);
}
trElement
=
document
.
createElement
(
'
tr
'
);
tdElement
=
document
.
createElement
(
'
td
'
);
tdElement
.
innerHTML
=
"
<span>
"
+
error_number
+
"
❌</span>
"
;
trElement
.
appendChild
(
tdElement
);
tdElement
=
document
.
createElement
(
'
td
'
);
tdElement
.
innerHTML
=
url_number
+
"
URLs
"
;
trElement
.
appendChild
(
tdElement
);
tdElement
=
document
.
createElement
(
'
td
'
);
trElement
.
appendChild
(
tdElement
);
footer_element
.
appendChild
(
trElement
);
});
}
rJS
(
window
)
.
ready
(
function
(
g
)
{
g
.
props
=
{};
return
g
.
getElement
()
.
push
(
function
(
element
)
{
g
.
props
.
element
=
element
;
g
.
props
.
start_deferred
=
RSVP
.
defer
();
});
})
.
declareAcquiredMethod
(
"
crib_sw_allDocs
"
,
"
crib_sw_allDocs
"
)
.
declareAcquiredMethod
(
"
crib_sw_get
"
,
"
crib_sw_get
"
)
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
;
if
(
options
===
undefined
)
options
=
{};
gadget
.
props
.
options
=
options
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
displayURLList
(
gadget
,
undefined
);
})
.
push
(
function
()
{
return
gadget
.
props
.
start_deferred
.
resolve
();
});
})
.
declareService
(
function
()
{
var
gadget
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
gadget
.
props
.
start_deferred
.
promise
;
})
.
push
(
function
()
{
return
loopEventListener
(
gadget
.
props
.
element
.
querySelector
(
"
.crib-url-list-content
"
),
'
submit
'
,
false
,
function
(
event
)
{
displayURLList
(
gadget
,
event
);
}
);
});
});
}(
window
,
rJS
,
JSHINT
,
jIO
,
loopEventListener
));
\ No newline at end of file
gadget/gadget_cribjs_page_tools.html
0 → 100644
View file @
afae8a6c
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv=
"Content-type"
content=
"text/html; charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no"
/>
<!-- renderjs -->
<script
src=
"../lib/rsvp.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.js"
type=
"text/javascript"
></script>
<!-- custom script -->
<script
src=
"./gadget_cribjs_page_tools.js"
type=
"text/javascript"
></script>
<title>
CribJS Header
</title>
</head>
<body>
<div
class=
"nav_content cribjs container"
>
<ul>
<li>
Check
<a
class=
"jslint"
href=
"#page=jslint"
>
JSLint
</a></li>
<li><a
class=
"mass_remove"
href=
"#page=mass_remove"
>
Remove
</a>
uncessary URLs
</li>
</ul>
</div>
</body>
</html>
\ No newline at end of file
gadget/gadget_cribjs_page_tools.js
0 → 100644
View file @
afae8a6c
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS, Handlebars, document, loopEventListener, RSVP */
(
function
(
window
,
rJS
,
document
,
RSVP
)
{
"
use strict
"
;
rJS
(
window
)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
// Assign the element to a variable
.
ready
(
function
(
g
)
{
g
.
props
=
{};
return
g
.
getElement
()
.
push
(
function
(
element
)
{
g
.
props
.
element
=
element
;
});
})
//////////////////////////////////////////////
// acquired methods
//////////////////////////////////////////////
.
declareAcquiredMethod
(
"
getUrlFor
"
,
"
getUrlFor
"
)
.
declareMethod
(
'
render
'
,
function
(
options
)
{
var
gadget
=
this
,
page_list
=
[
"
jslint
"
,
"
mass_remove
"
],
promise_list
=
[];
page_list
.
forEach
(
function
(
page
)
{
promise_list
.
push
(
gadget
.
getUrlFor
({
page
:
page
}));
});
// Handle main title
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
promise_list
);
})
.
push
(
function
(
link_list
)
{
for
(
var
i
=
0
;
i
<
link_list
.
length
;
i
++
)
{
gadget
.
props
.
element
.
querySelector
(
"
.
"
+
page_list
[
i
]).
href
=
link_list
[
i
];
}
});
});
}(
window
,
rJS
,
document
,
RSVP
));
\ No newline at end of file
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