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
Labels
Merge Requests
17
Merge Requests
17
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
nexedi
slapos.core
Commits
1470dfc0
Commit
1470dfc0
authored
Jun 27, 2012
by
Thomas Lechauve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: search method in routing plugin
parent
bbabfa06
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
5 deletions
+27
-5
jquery.urlJS/src/jquery.urljs.js
jquery.urlJS/src/jquery.urljs.js
+14
-2
jquery.urlJS/test/jquery.urljs_test.js
jquery.urlJS/test/jquery.urljs_test.js
+7
-1
vifib/static/js/jquery.urljs.js
vifib/static/js/jquery.urljs.js
+6
-2
No files found.
jquery.urlJS/src/jquery.urljs.js
View file @
1470dfc0
...
@@ -47,7 +47,7 @@ $.extend({
...
@@ -47,7 +47,7 @@ $.extend({
this
.
list
=
this
.
list
.
slice
(
0
,
0
);
this
.
list
=
this
.
list
.
slice
(
0
,
0
);
},
},
search
:
function
(
hash
,
level
)
{
search
:
function
(
hash
,
level
,
failcallback
,
context
)
{
var
stop
=
false
,
var
stop
=
false
,
i
,
j
,
i
,
j
,
regex
,
regex
,
...
@@ -70,17 +70,29 @@ $.extend({
...
@@ -70,17 +70,29 @@ $.extend({
}
}
this
.
current
=
this
.
list
[
i
][
j
];
this
.
current
=
this
.
list
[
i
][
j
];
this
.
clean
(
this
.
list
[
i
][
j
].
level
+
1
);
this
.
clean
(
this
.
list
[
i
][
j
].
level
+
1
);
console
.
log
(
this
.
list
[
i
][
j
].
route
);
this
.
list
[
i
][
j
].
callback
(
hash
);
this
.
list
[
i
][
j
].
callback
(
hash
);
}
}
j
+=
1
;
j
+=
1
;
}
}
i
-=
1
;
i
-=
1
;
}
}
if
(
stop
===
false
&&
failcallback
!==
undefined
)
{
if
(
context
===
undefined
)
{
failcallback
();
}
else
{
failcallback
.
call
(
context
);
}
}
},
},
isLastLevel
:
function
()
{
isLastLevel
:
function
()
{
return
this
.
current
.
level
===
(
this
.
list
.
length
-
1
);
return
this
.
current
.
level
===
(
this
.
list
.
length
-
1
);
},
isCurrent
:
function
(
hash
)
{
var
extracted
=
$
.
router
.
extractKeys
(
this
.
current
.
route
),
regex
=
new
RegExp
(
'
^
'
+
extracted
.
regex
+
'
$
'
);
return
regex
.
test
(
hash
);
}
}
},
},
...
...
jquery.urlJS/test/jquery.urljs_test.js
View file @
1470dfc0
...
@@ -73,7 +73,6 @@ $(function () {
...
@@ -73,7 +73,6 @@ $(function () {
var
spy
=
sinon
.
spy
(),
var
spy
=
sinon
.
spy
(),
i
=
0
,
i
=
0
,
callback
=
function
(
params
)
{
callback
=
function
(
params
)
{
console
.
log
(
params
)
$
.
router
.
routes
.
add
(
'
/first
'
,
1
,
spy
)
$
.
router
.
routes
.
add
(
'
/first
'
,
1
,
spy
)
$
.
router
.
start
(
params
.
route
);
$
.
router
.
start
(
params
.
route
);
}
}
...
@@ -82,6 +81,13 @@ $(function () {
...
@@ -82,6 +81,13 @@ $(function () {
ok
(
spy
.
calledOnce
);
ok
(
spy
.
calledOnce
);
});
});
test
(
'
no routes found
'
,
function
()
{
var
callback
=
function
()
{
ok
(
true
,
"
should be call
"
);
};
$
.
router
.
routes
.
search
({
'
route
'
:
'
/nonexist
'
},
0
,
callback
,
$
(
this
));
});
module
(
'
router methods tests
'
,
{
module
(
'
router methods tests
'
,
{
});
});
...
...
vifib/static/js/jquery.urljs.js
View file @
1470dfc0
...
@@ -76,8 +76,12 @@ $.extend({
...
@@ -76,8 +76,12 @@ $.extend({
}
}
i
-=
1
;
i
-=
1
;
}
}
if
(
stop
===
false
)
{
if
(
stop
===
false
&&
failcallback
!==
undefined
)
{
failcallback
.
call
(
context
);
if
(
context
===
undefined
)
{
failcallback
();
}
else
{
failcallback
.
call
(
context
);
}
}
}
},
},
...
...
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