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
e876944a
Commit
e876944a
authored
Sep 29, 2020
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CribEnable: Add improvements from ERP5 Developments
parent
551afc64
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
12 deletions
+44
-12
crib-enable.js
crib-enable.js
+44
-12
No files found.
crib-enable.js
View file @
e876944a
/*global window, rJS, jIO, FormData */
/*global window, rJS, jIO, FormData
, navigator, RSVP
*/
/*jslint indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
,
jIO
)
{
"
use strict
"
;
...
...
@@ -30,33 +30,65 @@
.
ready
(
function
(
gadget
)
{
// Initialize the gadget local parameters
var
path
=
""
,
path_list
=
window
.
location
.
pathname
.
split
(
"
/
"
);
if
(
path_list
)
{
if
(
path_list
[
path_list
.
length
-
1
]
!==
""
)
{
if
(
path_list
[
path_list
.
length
-
1
].
endsWith
(
"
.html
"
))
{
path_list
[
path_list
.
length
-
1
]
=
""
;
}
else
{
path_list
.
push
(
""
);
}
}
path
=
path_list
.
join
(
"
/
"
);
}
gadget
.
state_parameter_dict
=
{};
gadget
.
state_parameter_dict
.
default_document
=
window
.
location
.
protocol
+
"
//
"
+
window
.
location
.
host
+
window
.
location
.
pathname
.
substring
(
0
,
window
.
location
.
pathname
.
length
-
"
gadget_jio_crib.html
"
.
length
)
+
"
/
"
;
"
//
"
+
window
.
location
.
host
+
path
;
this
.
state_parameter_dict
.
jio_storage
=
jIO
.
createJIO
({
"
type
"
:
"
indexeddb
"
,
"
database
"
:
"
ojs_source_code
"
});
return
this
.
state_parameter_dict
.
jio_storage
.
put
(
gadget
.
state_parameter_dict
.
default_document
,
{})
return
this
.
state_parameter_dict
.
jio_storage
.
put
(
gadget
.
state_parameter_dict
.
default_document
,
{})
;
})
.
ready
(
function
(
gadget
)
{
var
jio_storage
;
return
RSVP
.
Queue
()
.
push
(
function
()
{
jio_storage
=
jIO
.
createJIO
({
type
:
"
indexeddb
"
,
database
:
"
setting
"
});
return
jio_storage
.
get
(
"
setting
"
);
})
.
push
(
function
(
result
)
{
if
(
result
.
site_editor_gadget_url
)
{
return
;
}
result
.
site_editor_gadget_url
=
window
.
location
.
href
;
return
jio_storage
.
put
(
"
setting
"
,
result
);
},
function
(
error
)
{
if
(
error
.
status_code
===
404
)
{
return
jio_storage
.
put
(
"
setting
"
,
{
site_editor_gadget_url
:
window
.
location
.
href
});
}
});
})
.
ready
(
function
()
{
if
(
'
serviceWorker
'
in
navigator
)
{
// XXX Hack to not add a new service worker when one is already declared
if
(
!
navigator
.
serviceWorker
.
controller
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
navigator
.
serviceWorker
.
register
(
'
/
gadget_cribjs_bootloader_serviceworker.js
'
,
{
scope
:
'
/
'
}
'
gadget_cribjs_bootloader_serviceworker.js
'
,
{
scope
:
'
.
/
'
}
);
})
.
push
(
function
(
registration
)
{
return
waitForServiceWorkerActive
(
registration
);
})
})
;
}
}
else
{
throw
"
Service Worker are not available in your browser
"
;
...
...
@@ -85,9 +117,9 @@
.
declareMethod
(
'
allDocs
'
,
function
()
{
var
storage
=
this
.
state_parameter_dict
.
jio_storage
;
return
storage
.
allAttachments
(
this
.
state_parameter_dict
.
default_document
)
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
return
result
;
})
});
})
.
declareMethod
(
'
remove
'
,
function
(
url
)
{
var
storage
=
this
.
state_parameter_dict
.
jio_storage
;
...
...
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