Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Ophélie Gagnard
slapos.core
Commits
b0d3766e
Commit
b0d3766e
authored
Jun 01, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge jquery.urlJS with vifib application
parent
cd8770e2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
324 additions
and
339 deletions
+324
-339
jquery.urlJS/src/jquery.urljs.js
jquery.urlJS/src/jquery.urljs.js
+102
-105
vifib/index.html
vifib/index.html
+194
-194
vifib/static/js/core.js
vifib/static/js/core.js
+26
-40
vifib/static/js/urlHandler.js
vifib/static/js/urlHandler.js
+2
-0
No files found.
jquery.urlJS/src/jquery.urljs.js
View file @
b0d3766e
(
function
(
$
)
{
$
.
extend
({
'
use strict
'
;
$
.
extend
({
router
:
{
router
:
{
routes
:
{
routes
:
{
list
:
[],
list
:
[],
...
@@ -16,7 +14,7 @@
...
@@ -16,7 +14,7 @@
'
level
'
:
level
,
'
level
'
:
level
,
'
callback
'
:
function
(
params
)
{
'
callback
'
:
function
(
params
)
{
if
(
callback
!==
undefined
)
{
if
(
callback
!==
undefined
)
{
if
(
context
!
==
undefined
)
{
if
(
context
=
==
undefined
)
{
callback
(
params
);
callback
(
params
);
}
else
{
}
else
{
callback
.
call
(
context
,
params
);
callback
.
call
(
context
,
params
);
...
@@ -98,7 +96,7 @@
...
@@ -98,7 +96,7 @@
},
},
parseHash
:
function
(
hashTag
)
{
parseHash
:
function
(
hashTag
)
{
var
re
=
new
RegExp
(
/
(?:
^#
([
a-zA-Z0-9
\/
_-
]
+
))(?:\?([
A-Za-z0-9
\/
&=_-
]
+
))?
/g
),
var
re
=
new
RegExp
(
/
(?:
^#
?
([
a-zA-Z0-9
\/
_-
]
+
))(?:\?([
A-Za-z0-9
\/
&=_-
]
+
))?
/g
),
groups
=
re
.
exec
(
hashTag
),
groups
=
re
.
exec
(
hashTag
),
r
,
params
=
{};
r
,
params
=
{};
groups
.
shift
();
groups
.
shift
();
...
@@ -113,12 +111,11 @@
...
@@ -113,12 +111,11 @@
hashHandler
:
function
()
{
hashHandler
:
function
()
{
var
hashTag
=
window
.
location
.
href
.
split
(
'
#
'
)[
1
],
var
hashTag
=
window
.
location
.
href
.
split
(
'
#
'
)[
1
],
hashInfo
=
this
.
parseHash
(
hashTag
);
hashInfo
=
$
.
router
.
parseHash
(
hashTag
);
this
.
routes
.
call
(
hashInfo
)
$
.
router
.
routes
.
search
(
hashInfo
)
},
},
}
}
});
});
$
(
window
).
bind
(
'
hashchange
'
,
$
.
router
.
hashchangeHandler
);
$
(
window
).
bind
(
'
hashchange
'
,
$
.
router
.
hashHandler
);
$
(
window
).
bind
(
'
load
'
,
$
.
router
.
hashchangeHandler
);
$
(
window
).
bind
(
'
load
'
,
$
.
router
.
hashHandler
);
}(
jQuery
));
vifib/index.html
View file @
b0d3766e
...
@@ -341,8 +341,8 @@
...
@@ -341,8 +341,8 @@
<script
type=
"text/javascript"
src=
"static/js/modernizr-2.5.3.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/modernizr-2.5.3.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/sinon-1.3.2.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/sinon-1.3.2.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/jquery.slapos.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/jquery.slapos.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/jquery.urljs.js"
></script>
<!--<script type="text/javascript" src="static/js/fake.js"></script>-->
<!--<script type="text/javascript" src="static/js/fake.js"></script>-->
<script
type=
"text/javascript"
src=
"static/js/urlHandler.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/core.js"
></script>
<script
type=
"text/javascript"
src=
"static/js/core.js"
></script>
</body>
</body>
</html>
</html>
vifib/static/js/core.js
View file @
b0d3766e
...
@@ -5,31 +5,7 @@
...
@@ -5,31 +5,7 @@
*/
*/
(
function
(
$
)
{
(
function
(
$
)
{
'
use strict
'
;
'
use strict
'
;
var
routes
=
{
var
getDate
=
function
()
{
'
/catalog
'
:
'
showCatalog
'
,
'
/catalog/all
'
:
'
showCatalogAll
'
,
'
/instance
'
:
'
requestInstance
'
,
'
/instance/:url
'
:
'
showInstance
'
,
'
/instance/:url/bang
'
:
'
showBangInstance
'
,
'
/computers
'
:
'
listComputers
'
,
'
/instances
'
:
'
listInstances
'
,
'
/invoices
'
:
'
listInvoices
'
,
'
/dashboard
'
:
'
showDashboard
'
},
router
=
function
(
e
,
d
)
{
var
$this
=
$
(
this
);
$
.
each
(
routes
,
function
(
pattern
,
callback
)
{
pattern
=
pattern
.
replace
(
/:
\w
+/g
,
'
([^
\
/]+)
'
);
var
regex
=
new
RegExp
(
'
^
'
+
pattern
+
'
$
'
),
result
=
regex
.
exec
(
d
);
if
(
result
)
{
result
.
shift
();
methods
[
callback
].
apply
(
$this
,
result
);
}
});
},
getDate
=
function
()
{
var
today
=
new
Date
();
var
today
=
new
Date
();
return
[
today
.
getFullYear
(),
today
.
getMonth
(),
today
.
getDay
()].
join
(
'
/
'
)
+
return
[
today
.
getFullYear
(),
today
.
getMonth
(),
today
.
getDay
()].
join
(
'
/
'
)
+
'
'
+
[
today
.
getHours
(),
today
.
getMinutes
(),
today
.
getSeconds
()].
join
(
'
:
'
);
'
'
+
[
today
.
getHours
(),
today
.
getMinutes
(),
today
.
getSeconds
()].
join
(
'
:
'
);
...
@@ -83,23 +59,33 @@
...
@@ -83,23 +59,33 @@
methods
=
{
methods
=
{
init
:
function
()
{
init
:
function
()
{
var
routes
=
[];
routes
[
0
]
=
[
[
'
/catalog
'
,
methods
[
'
showCatalog
'
]],
[
'
/catalog/all
'
,
methods
[
'
showCatalogAll
'
]],
[
'
/instance
'
,
methods
[
'
requestInstance
'
]],
[
'
/instance/:url
'
,
methods
[
'
showInstance
'
]],
[
'
/instance/:url/bang
'
,
methods
[
'
showBangInstance
'
]],
[
'
/computers
'
,
methods
[
'
listComputers
'
]],
[
'
/instances
'
,
methods
[
'
listInstances
'
]],
[
'
/invoices
'
,
methods
[
'
listInvoices
'
]],
[
'
/dashboard
'
,
methods
[
'
showDashboard
'
]]
];
return
this
.
each
(
function
()
{
// Initialize slapos in this context
// Initialize slapos in this context
$
(
this
).
slapos
({
'
host
'
:
'
http://10.8.2.34:12006/erp5/portal_vifib_rest_api_v1
'
});
$
(
this
).
slapos
({
'
host
'
:
'
http://10.8.2.34:12006/erp5/portal_vifib_rest_api_v1
'
});
var
$this
=
$
(
this
);
// Bind Loading content
// Bind Loading content
$
(
'
#loading
'
).
ajaxStart
(
function
()
{
$
(
'
#loading
'
).
ajaxStart
(
function
()
{
$
(
this
).
spin
(
spinOptions
);
$
(
this
).
spin
(
spinOptions
);
}).
ajaxStop
(
function
()
{
}).
ajaxStop
(
function
()
{
$
(
this
).
spin
(
false
);
$
(
this
).
spin
(
false
);
});
});
// Bind to urlChange event
for
(
var
level
=
0
;
level
<
routes
.
length
;
level
+=
1
)
{
return
this
.
each
(
function
()
{
for
(
var
i
=
0
;
i
<
routes
[
level
].
length
;
i
+=
1
)
{
$
.
subscribe
(
'
urlChange
'
,
function
(
e
,
d
)
{
var
r
=
routes
[
level
][
i
];
router
.
call
(
$this
,
e
,
d
);
$
.
router
.
routes
.
add
(
r
[
0
],
level
,
r
[
1
],
$
(
this
));
});
}
$
.
subscribe
(
'
auth
'
,
function
(
e
,
d
)
{
}
$
(
this
).
vifib
(
'
authenticate
'
,
d
);
});
});
});
},
},
...
...
vifib/static/js/urlHandler.js
View file @
b0d3766e
...
@@ -61,5 +61,7 @@ $.redirectHandler = function(e, url){ window.location.hash = $.genHash(url); };
...
@@ -61,5 +61,7 @@ $.redirectHandler = function(e, url){ window.location.hash = $.genHash(url); };
$
.
redirect
=
function
(
url
){
$
.
publish
(
'
redirect
'
,
[
url
]);
};
$
.
redirect
=
function
(
url
){
$
.
publish
(
'
redirect
'
,
[
url
]);
};
$
.
subscribe
(
'
redirect
'
,
$
.
redirectHandler
)
$
.
subscribe
(
'
redirect
'
,
$
.
redirectHandler
)
console
.
log
(
"
plop
"
)
$
(
window
).
bind
(
'
hashchange
'
,
$
.
hashHandler
);
$
(
window
).
bind
(
'
hashchange
'
,
$
.
hashHandler
);
$
(
window
).
bind
(
'
load
'
,
$
.
hashHandler
);
$
(
window
).
bind
(
'
load
'
,
$
.
hashHandler
);
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