Skip to content

Commit ecb00f6

Browse files
committed
Bigfixes for changing folders
1 parent d0ecf8b commit ecb00f6

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

ajax/makeurl.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
//$newHost = "https://nowsci.com/s/";
77
$newHost = OCP\Config::getAppValue('shorten', 'host', '');
88

9+
function startsWith($haystack, $needle) {
10+
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE;
11+
}
912

1013
function rand_chars($length) {
1114
$urlString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@@ -45,7 +48,7 @@ function getShortcode($url) {
4548
}
4649

4750
$curUrl = $_POST['curUrl'];
48-
if ($newHost == "") {
51+
if ($newHost == "" || startsWith($curUrl, $newHost)) {
4952
echo $curUrl;
5053
} else {
5154
$shortcode = getShortcode($curUrl);

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<types>
1010
<filesystem/>
1111
</types>
12-
<version>0.0.4</version>
12+
<version>0.0.5</version>
1313
<default_enable/>
1414
</info>

appinfo/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.4
1+
0.0.5

js/script.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,42 @@
11

2+
var ranbefore = false;
3+
24
$(document).ready(function() {
35
if(/(public)\.php/i.exec(window.location.href)!=null) return;
46
setTimeout(addShareListener, 1000);
57
});
68

79
function addShareListener() {
8-
$('.action-share').click(function() {
9-
$('#linkCheckbox').click(function() {
10+
if (!ranbefore) {
11+
addGlobalListener('.nav-files');
12+
addGlobalListener('.nav-sharingin');
13+
addGlobalListener('.nav-sharingout');
14+
addGlobalListener('.nav-sharinglinks');
15+
addGlobalListener('.name');
16+
addGlobalListener('.crumb');
17+
ranbefore = true;
18+
}
19+
$('.action-share').ready(function() {
20+
$('.action-share').click(function() {
21+
addListener('#linkCheckbox');
1022
setTimeout(replaceUrl, 750);
1123
});
12-
setTimeout(replaceUrl, 750);
24+
});
25+
}
26+
27+
function addListener(o) {
28+
$(o).ready(function() {
29+
$(o).click(function() {
30+
setTimeout(replaceUrl, 750);
31+
});
32+
});
33+
}
34+
35+
function addGlobalListener(o) {
36+
$(o).ready(function() {
37+
$(o).click(function() {
38+
setTimeout(addShareListener, 1000);
39+
});
1340
});
1441
}
1542

0 commit comments

Comments
 (0)