Skip to content

Commit c5d204d

Browse files
Max BaseMax Base
authored andcommitted
Add setLink() to api.js
1 parent 22d7f07 commit c5d204d

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

example/api.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
11
(function(window, document) {
22
"use strict"
3+
let link=""
4+
35
let keys=""
46

57
let tokens=""
68

79
let count=0
810

911
let list=[]
12+
13+
/**
14+
* @function setLink
15+
*
16+
* @goal : setLink is to set main link for loading thinCaptcha files...
17+
*
18+
* @return bool
19+
**/
20+
21+
const setLink = function(url) {
22+
link=url
23+
return true
24+
}
25+
1026
/**
1127
* @function setKey
1228
*
@@ -78,7 +94,7 @@
7894
}
7995

8096
const verifing = function(index) {
81-
ajax(function(res) { alert(res)}, "index.php", {
97+
ajax(function(res) { alert(res)}, link+"index.php", {
8298
method: "verify",
8399
value: list[index].text.value,
84100
code: list[index].text.value,
@@ -123,7 +139,7 @@
123139
alert("hey")
124140
})
125141
let imageID="thinCaptcha-image"+count
126-
let imageSRC="captcha.php?code="+json.result.code+"&token="+tokens+"&key="+keys
142+
let imageSRC=link+"captcha.php?code="+json.result.code+"&token="+tokens+"&key="+keys
127143
code.innerHTML="<img id=\""+imageID+"\" src=\""+imageSRC+"\">"
128144
let image=code.querySelector("#"+imageID)
129145
// code.innerHTML+="<a onclick=\"document.querySelector('#"+imageID+"').src='"+imageSRC+"'\">reload</a>"
@@ -172,7 +188,7 @@
172188
output: output,
173189
})
174190
count++
175-
}, "index.php", {
191+
}, link+"index.php", {
176192
method: "create",
177193
key: keys,
178194
}, {
@@ -189,6 +205,7 @@
189205
* @return struct
190206
**/
191207
window.thinCaptcha = {
208+
setLink: setLink,
192209
apply: apply,
193210
setKey: setKey,
194211
ajax: ajax,

example/demo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
</div>
6262
<script type="text/javascript">
6363
window.addEventListener("load", function() {
64+
thinCaptcha.setLink("http://localhost/matno3/SampleCaptchaAPI/src/")
6465
thinCaptcha.setKey("x1x1x1x1x1x1", "d4f5g6df4gd5f6ge4r89rf48")
6566
thinCaptcha.apply("#thincaptcha-form1", "#thincaptcha-code1");
6667
})

0 commit comments

Comments
 (0)