mirror of https://github.com/calzoneman/sync.git
Fix cross-domain issues
This commit is contained in:
parent
087f612b37
commit
84fb4214d7
4
api.js
4
api.js
|
@ -47,6 +47,7 @@ function handle(path, req, res) {
|
|||
}
|
||||
|
||||
if(parts[0] == "json") {
|
||||
res.callback = params.callback || false;
|
||||
if(!(parts[1] in jsonHandlers)) {
|
||||
res.end(JSON.stringify({
|
||||
error: "Unknown endpoint: " + parts[1]
|
||||
|
@ -63,6 +64,9 @@ exports.handle = handle;
|
|||
|
||||
function sendJSON(res, obj) {
|
||||
var response = JSON.stringify(obj, null, 4);
|
||||
if(res.callback) {
|
||||
response = res.callback + "(" + response + ")";
|
||||
}
|
||||
var len = unescape(encodeURIComponent(response)).length;
|
||||
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const VERSION = "1.3.1";
|
||||
const VERSION = "1.3.2";
|
||||
|
||||
var fs = require("fs");
|
||||
var Logger = require("./logger.js");
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<script src="assets/js/jquery.js" type="text/javascript"></script>
|
||||
<script src="assets/js/iourl.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var q = "";
|
||||
$("#login").click(function() {
|
||||
|
@ -52,7 +53,7 @@
|
|||
});
|
||||
|
||||
function refresh() {
|
||||
$.getJSON("api/json/listloaded?" + q, function(data) {
|
||||
$.getJSON(IO_URL+"/api/json/listloaded?"+q+"&callback=?", function(data) {
|
||||
var host = document.location + "";
|
||||
host = host.substring(0, host.indexOf("/widget.html"));
|
||||
if(data.error) {
|
||||
|
|
|
@ -24,14 +24,13 @@
|
|||
</tbody>
|
||||
</table>
|
||||
<script src="assets/js/jquery.js" type="text/javascript"></script>
|
||||
<script src="assets/js/iourl.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var p = document.location + "";
|
||||
if(p.indexOf("?") != -1) {
|
||||
p = p.substring(p.indexOf("?")+1);
|
||||
}
|
||||
$.getJSON("api/json/channeldata?" + p, function(data) {
|
||||
var host = document.location + "";
|
||||
host = host.substring(0, host.indexOf("/widget.html"));
|
||||
$.getJSON(IO_URL+"/api/json/channeldata?"+p+"&callback=?", function(data) {
|
||||
if(data.error) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
</div>
|
||||
</form>
|
||||
<script src="assets/js/jquery.js" type="text/javascript"></script>
|
||||
<script src="assets/js/iourl.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
var source;
|
||||
var respond = function(e) {
|
||||
|
@ -44,7 +45,7 @@
|
|||
window.addEventListener("message", respond, false);
|
||||
|
||||
$("#login").click(function() {
|
||||
$.getJSON("api/json/login?name="+$("#username").val()+"&pw="+$("#pw").val(), function(data) {
|
||||
$.getJSON(IO_URL+"/api/json/login?name="+$("#username").val()+"&pw="+$("#pw").val()+"&callback=?", function(data) {
|
||||
data.uname = $("#username").val();
|
||||
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
|
||||
});
|
||||
|
@ -58,7 +59,7 @@
|
|||
$("#confirm").addClass("text-error");
|
||||
return;
|
||||
}
|
||||
$.getJSON("api/json/register?name="+$("#username").val()+"&pw="+$("#pw").val(), function(data) {
|
||||
$.getJSON(IO_URL+"/api/json/register?name="+$("#username").val()+"&pw="+$("#pw").val()+"&callback=?", function(data) {
|
||||
console.log(data);
|
||||
data.uname = $("#username").val();
|
||||
source.postMessage("cytube-login:"+JSON.stringify(data), document.location);
|
||||
|
|
Loading…
Reference in New Issue