Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
soko
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bitsoko services
soko
Commits
f0a16b4a
Commit
f0a16b4a
authored
Jun 12, 2017
by
Gaseema Ndung'u
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added connect.html
parent
1640a2f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
200 additions
and
1 deletion
+200
-1
connect.html
connect.html
+199
-0
style.css
css/style.css
+1
-1
No files found.
connect.html
0 → 100644
View file @
f0a16b4a
<!-- Defines element markup -->
<html>
<head>
<script>
contio
=
location
.
origin
;
</script>
<script
src=
"/socket.io/socket.io.js"
></script>
<script
src=
"bitsAssets/js/broadcastChannel.js"
></script>
<script
src=
"bitsAssets/js/storeManager.js"
></script>
</head>
<body>
<template
class=
"bits-connect"
>
</template>
<script>
// Gets content from
<
template
>
var
bitsConnector
;
var
swReg
;
var
appli
=
''
;
if
(
location
.
origin
.
includes
(
'localhost:8000'
))
{
appli
=
'/s'
;
}
else
if
(
location
.
origin
.
includes
(
'localhost:9000'
))
{
appli
=
'/b'
;
}
else
{
appli
=
location
.
pathname
.
substring
(
0
,
2
);
}
var
conSet
=
{
'forceNew'
:
true
,
'reconnection'
:
true
,
'reconnectionDelay'
:
1000
,
'reconnectionAttempts'
:
100
};
var
constr
;
switch
(
appli
)
{
case
'/s'
:
constr
=
contio
+
'/serviceHandler'
;
meName
=
'service-'
+
localStorage
.
getItem
(
'soko-active-store'
);
break
;
case
'/r'
:
constr
=
contio
+
'/rootHandler'
;
meName
=
'user-'
+
localStorage
.
getItem
(
'bits-user-name'
);
break
;
case
'/c'
:
constr
=
contio
+
'/connectHandler'
;
meName
=
'api'
;
break
;
default
:
constr
=
contio
;
meName
=
'user-'
+
localStorage
.
getItem
(
'bits-user-name'
);
}
try
{
bitsServer
=
io
.
connect
(
constr
,
conSet
);
console
.
log
(
'connected'
);
}
catch
(
err
)
{
console
.
log
(
'NOT connected'
);
}
bitsServer
.
on
(
'connect_error'
,
function
(
err
)
{
// servPage.source.postMessage({status: 'bad',msg:err}, servPage.origin);
reject
({
status
:
'disconnected'
,
msg
:
err
});
});
bitsServer
.
once
(
'disconnect'
,
function
()
{
bitsServer
.
once
(
'connect'
,
function
()
{
console
.
log
(
'Connected for the second time!'
);
});
bitsServer
.
on
(
'connect_error'
,
function
(
err
)
{
// servPage.source.postMessage({status: 'bad',msg:err}, servPage.origin);
reject
({
status
:
'disconnected'
,
msg
:
err
});
});
bitsServer
.
connect
();
});
contio
=
location
.
origin
;
/* */
if
(
'serviceWorker'
in
navigator
)
{
navigator
.
serviceWorker
.
register
(
contio
+
'/sw.js'
,
{
scope
:
contio
}).
then
(
function
(
reg
)
{
// Registration was successful. Now, check to see whether the Service Worker is controlling the page.
if
(
navigator
.
serviceWorker
.
controller
)
{
// If .controller is set, then this page is being actively controlled by the Service Worker.
// Show the interface for sending messages to the service worker.
swReg
=
reg
;
try
{
startmessage
();
}
catch
(
err
)
{
console
.
log
(
'not initialized messaging'
);
}
//console.log('ServiceWorker registration Active');
}
else
{
// If .controller isn't set, then prompt the user to reload the page so that the Service Worker can take
// control. Until that happens, the Service Worker's message handler won't be used.
// window.location.reload();
if
(
window
.
location
.
origin
==
'https://bitsoko.io'
)
{
window
.
location
.
reload
();
}
else
{
console
.
log
(
'RELOAD PAGE TO ACTIVATE SERVICE WORKER!!'
);
}
}
}).
catch
(
function
(
err
)
{
console
.
log
(
'ServiceWorker registration failed: '
,
err
);
});
}
var
doFetch
;
(
function
(
window
,
document
,
undefined
)
{
// Refers to the "importer", which is index.html
document
.
addEventListener
(
'visibilitychange'
,
function
(
event
)
{
if
(
!
document
.
hidden
&&
localStorage
.
getItem
(
'bitsoko-enable-autoreload'
)
!=
'false'
)
{
// The page is visible.
//bitsConnector.querySelector("iframe[bits]").src = bitsConnector.querySelector("iframe[bits]").src;
setTimeout
(
function
()
{
checkNewPay
();
},
1000
);
}
else
{
// The page is hidden.
}
});
})(
window
,
document
);
function
doFetch
(
data
,
e
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
// console.log(bitsConnector);
if
(
!
bitsServer
.
connected
)
{
reject
({
status
:
'disconnected'
,
msg
:
'no connection found'
});
// return;
}
console
.
log
(
'sending '
,
data
,
' to server'
);
bitsServer
.
on
(
data
.
action
,
function
(
dat
)
{
if
(
data
.
action
==
dat
.
action
)
{
resolve
(
dat
);
}
// bitsServer.emit('clientid', { testing: event.data });
}).
emit
(
data
.
action
,
data
);
});
}
//autoReload = false;
</script>
</body>
</html>
css/style.css
View file @
f0a16b4a
...
...
@@ -437,7 +437,7 @@ header .brand-logo img {
font-size
:
36px
;
}
ul
.side-nav.leftside-navigation
{
top
:
56
px
!important
;
top
:
0
px
!important
;
}
}
...
...
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