Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
d6faeb86
Commit
d6faeb86
authored
Jun 02, 2014
by
Romain Courteaud
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More unused files.
parent
bdfebd53
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
279 deletions
+0
-279
dream/platform/src/lib/route.js
dream/platform/src/lib/route.js
+0
-152
dream/platform/src/lib/url.js
dream/platform/src/lib/url.js
+0
-127
No files found.
dream/platform/src/lib/route.js
deleted
100644 → 0
View file @
bdfebd53
/*global jQuery */
/*!
* route.js v1.0.0
*
* Copyright 2012, Romain Courteaud
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Date: Mon Jul 16 2012
*/
"
use strict
"
;
(
function
(
$
)
{
$
.
extend
({
StatelessDeferred
:
function
()
{
var
doneList
=
$
.
Callbacks
(
"
memory
"
),
promise
=
{
done
:
doneList
.
add
,
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise
:
function
(
obj
)
{
var
i
,
keys
=
[
'
done
'
,
'
promise
'
];
if
(
obj
===
undefined
)
{
obj
=
promise
;
}
else
{
for
(
i
=
0
;
i
<
keys
.
length
;
i
+=
1
)
{
obj
[
keys
[
i
]]
=
promise
[
keys
[
i
]];
}
}
return
obj
;
}
},
deferred
=
promise
.
promise
({});
deferred
.
resolveWith
=
doneList
.
fireWith
;
// All done!
return
deferred
;
}
});
var
routes
=
[],
current_priority
=
0
,
methods
=
{
add
:
function
(
pattern
,
priority
)
{
var
i
=
0
,
inserted
=
false
,
length
=
routes
.
length
,
dfr
=
$
.
StatelessDeferred
(),
context
=
$
(
this
),
escapepattern
,
matchingpattern
;
if
(
priority
===
undefined
)
{
priority
=
0
;
}
if
(
pattern
!==
undefined
)
{
// http://simonwillison.net/2006/Jan/20/escape/
escapepattern
=
pattern
.
replace
(
/
[\-\[\]
{}()*+?.,
\\\^
$|#
\s]
/g
,
"
\\
$&
"
);
matchingpattern
=
escapepattern
.
replace
(
/<int:
\w
+>/g
,
"
(
\\
d+)
"
)
.
replace
(
/<path:
\w
+>/g
,
"
(.+)
"
)
.
replace
(
/<
\w
+>/g
,
"
([^/]+)
"
);
while
(
!
inserted
)
{
if
((
i
===
length
)
||
(
priority
>=
routes
[
i
][
2
]))
{
routes
.
splice
(
i
,
0
,
[
new
RegExp
(
'
^
'
+
matchingpattern
+
'
$
'
),
dfr
,
priority
,
context
]);
inserted
=
true
;
}
else
{
i
+=
1
;
}
}
}
return
dfr
.
promise
();
},
go
:
function
(
path
,
min_priority
)
{
var
dfr
=
$
.
Deferred
(),
context
=
$
(
this
),
result
;
if
(
min_priority
===
undefined
)
{
min_priority
=
0
;
}
setTimeout
(
function
()
{
var
i
=
0
,
found
=
false
,
slice_index
=
-
1
,
slice_priority
=
-
1
;
for
(
i
=
0
;
i
<
routes
.
length
;
i
+=
1
)
{
if
(
slice_priority
!==
routes
[
i
][
2
])
{
slice_priority
=
routes
[
i
][
2
];
slice_index
=
i
;
}
if
(
routes
[
i
][
2
]
<
min_priority
)
{
break
;
}
else
if
(
routes
[
i
][
0
].
test
(
path
))
{
result
=
routes
[
i
][
0
].
exec
(
path
);
dfr
=
routes
[
i
][
1
];
context
=
routes
[
i
][
3
];
current_priority
=
routes
[
i
][
2
];
found
=
true
;
break
;
}
}
if
(
i
===
routes
.
length
)
{
slice_index
=
i
;
}
if
(
slice_index
>
-
1
)
{
routes
=
routes
.
slice
(
slice_index
);
}
if
(
found
)
{
dfr
.
resolveWith
(
context
,
result
.
slice
(
1
)
);
}
else
{
dfr
.
rejectWith
(
context
);
}
});
return
dfr
.
promise
();
},
};
$
.
routereset
=
function
()
{
routes
=
[];
current_priority
=
0
;
};
$
.
routepriority
=
function
()
{
return
current_priority
;
};
$
.
fn
.
route
=
function
(
method
)
{
var
result
;
if
(
methods
.
hasOwnProperty
(
method
))
{
result
=
methods
[
method
].
apply
(
this
,
Array
.
prototype
.
slice
.
call
(
arguments
,
1
)
);
}
else
{
$
.
error
(
'
Method
'
+
method
+
'
does not exist on jQuery.route
'
);
}
return
result
;
};
}(
jQuery
));
dream/platform/src/lib/url.js
deleted
100644 → 0
View file @
bdfebd53
/*global window, jQuery */
/*!
* url.js v1.0.0
*
* Copyright 2012, Romain Courteaud
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Date: Mon Jul 16 2012
*/
"
use strict
"
;
(
function
(
window
,
$
)
{
var
hashchangeinitialized
=
false
,
previousurl
,
currentcallback
,
getRawHash
=
function
()
{
return
window
.
location
.
toString
().
split
(
'
#
'
)[
1
];
},
callbackwrapper
=
function
()
{
if
(
previousurl
!==
window
.
location
.
hash
)
{
previousurl
=
window
.
location
.
hash
;
if
(
currentcallback
!==
undefined
)
{
currentcallback
();
}
}
},
timeoutwrapper
=
function
()
{
callbackwrapper
();
window
.
setTimeout
(
timeoutwrapper
,
500
);
};
function
UrlHandler
()
{}
UrlHandler
.
prototype
=
{
'
generateUrl
'
:
function
(
path
,
options
)
{
var
pathhash
,
hash
=
'
#
'
,
key
;
if
(
path
!==
undefined
)
{
hash
+=
encodeURIComponent
(
path
);
}
hash
=
hash
.
replace
(
/%2F/g
,
'
/
'
);
pathhash
=
hash
;
for
(
key
in
options
)
{
if
(
options
.
hasOwnProperty
(
key
))
{
if
(
hash
===
pathhash
)
{
hash
=
hash
+
'
?
'
;
}
else
{
hash
=
hash
+
'
&
'
;
}
hash
+=
encodeURIComponent
(
key
)
+
'
=
'
+
encodeURIComponent
(
options
[
key
]);
}
}
return
hash
;
},
'
go
'
:
function
(
path
,
options
)
{
window
.
location
.
hash
=
this
.
generateUrl
(
path
,
options
);
},
'
redirect
'
:
function
(
path
,
options
)
{
var
host
=
window
.
location
.
protocol
+
'
//
'
+
window
.
location
.
host
+
window
.
location
.
pathname
+
window
.
location
.
search
;
window
.
location
.
replace
(
host
+
this
.
generateUrl
(
path
,
options
));
// window.location.replace(window.location.href.replace(/#.*/, ""));
},
'
getPath
'
:
function
()
{
var
hash
=
getRawHash
(),
result
=
''
;
if
(
hash
!==
undefined
)
{
result
=
decodeURIComponent
(
hash
.
split
(
'
?
'
)[
0
]);
}
return
result
;
},
'
getOptions
'
:
function
()
{
var
options
=
{},
hash
=
getRawHash
(),
subhashes
,
subhash
,
index
,
keyvalue
;
if
(
hash
!==
undefined
)
{
hash
=
hash
.
split
(
'
?
'
)[
1
];
if
(
hash
!==
undefined
)
{
subhashes
=
hash
.
split
(
'
&
'
);
for
(
index
in
subhashes
)
{
if
(
subhashes
.
hasOwnProperty
(
index
))
{
subhash
=
subhashes
[
index
];
if
(
subhash
!==
''
)
{
keyvalue
=
subhash
.
split
(
'
=
'
);
if
(
keyvalue
.
length
===
2
)
{
options
[
decodeURIComponent
(
keyvalue
[
0
])]
=
decodeURIComponent
(
keyvalue
[
1
]);
}
}
}
}
}
}
return
options
;
},
'
onhashchange
'
:
function
(
callback
)
{
previousurl
=
undefined
;
currentcallback
=
callback
;
if
(
!
hashchangeinitialized
)
{
if
(
window
.
onhashchange
!==
undefined
)
{
$
(
window
).
bind
(
'
hashchange
'
,
callbackwrapper
);
window
.
setTimeout
(
callbackwrapper
);
}
else
{
timeoutwrapper
();
}
hashchangeinitialized
=
true
;
}
},
};
// Expose to the global object
$
.
url
=
new
UrlHandler
();
}(
window
,
jQuery
));
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