kopia lustrzana https://github.com/c9/core
Upgrade engine.io version
rodzic
080712d8fa
commit
2ed63213eb
|
@ -0,0 +1,158 @@
|
|||
var join = require("path").join;
|
||||
|
||||
module.exports = function(options) {
|
||||
var config = require("./client-default")(options);
|
||||
return module.exports.makeLocal(config, options);
|
||||
};
|
||||
|
||||
module.exports.makeLocal = function(config, options) {
|
||||
var c9Ws = options.remoteWorkspace; // true when opening c9 workspace as local
|
||||
var root = options.workspaceDir;
|
||||
|
||||
var nodeBin = options.nodeBin || ["node"];
|
||||
var settingDir = options.settingDir || options.installPath;
|
||||
|
||||
if (!c9Ws) {
|
||||
// Local version
|
||||
options.local = true;
|
||||
options.projectName = root.substr(root.lastIndexOf("/") + 1);
|
||||
options.debug = 2;
|
||||
options.env = "local";
|
||||
}
|
||||
|
||||
for (var i = config.length - 1; i >= 0; i--) {
|
||||
// if (config[i].packagePath == "plugins/c9.cli.bridge/bridge")
|
||||
// config[i].port = 55556;
|
||||
if (config[i].packagePath == "plugins/c9.ide.welcome/welcome" && !c9Ws) {
|
||||
config[i].intro =
|
||||
"Welcome to your brand new Cloud9. Use this welcome screen "
|
||||
+ "to tweak the look & feel of the Cloud9 user interface. "
|
||||
+ "If you prefer a more advanced IDE experience, you can choose "
|
||||
+ "to change the layout below. "
|
||||
+ "\n\n"
|
||||
+ "On the right you can find videos and documentation for Cloud9 "
|
||||
+ "IDE. Happy Coding!";
|
||||
}
|
||||
// else if (config[i].packagePath == "plugins/c9.ide.login/login") {
|
||||
// config.splice(i, 1);
|
||||
// }
|
||||
else if (config[i].packagePath == "plugins/c9.ide.run/run" && !c9Ws) {
|
||||
config[i].runnerPath = join(settingDir, "/runners");
|
||||
}
|
||||
else if (config[i].packagePath == "plugins/c9.ide.ui/menus") {
|
||||
config[i].autoInit = false;
|
||||
}
|
||||
else if (config[i].packagePath == "plugins/c9.ide.save/autosave") {
|
||||
config[i].slowChangeTimeout = 500;
|
||||
}
|
||||
else if (config[i].packagePath == "plugins/c9.ide.run.build/build" && !c9Ws) {
|
||||
config[i].builderPath = join(settingDir, "/builders");
|
||||
}
|
||||
else if (config[i].packagePath == "plugins/c9.ide.editors/metadata" && !c9Ws) {
|
||||
config[i].path = join(settingDir, "/metadata");
|
||||
config[i].changeCheckInterval = 2000;
|
||||
}
|
||||
else if (config[i].packagePath == "plugins/c9.ide.feedback/feedback") {
|
||||
config[i].screenshotSupport = false;
|
||||
}
|
||||
// else if (config[i].packagePath == "plugins/c9.ide.feedback/feedback") {
|
||||
// config[i] = {
|
||||
// packagePath : "plugins/c9.ide.help/help",
|
||||
// staticPrefix : options.staticPrefix + "/plugins/c9.ide.help"
|
||||
// };
|
||||
// }
|
||||
|
||||
else if (config[i].packagePath == "plugins/c9.core/c9") {
|
||||
config[i].local = true;
|
||||
}
|
||||
else if (config[i].packagePath == "plugins/c9.ide.clipboard/html5")
|
||||
config[i].packagePath = "plugins/c9.ide.local/clipboard";
|
||||
else if (config[i].packagePath == "plugins/c9.ide.configuration/configure")
|
||||
config[i].pathFromFavorite = true;
|
||||
else if (config[i].packagePath == "plugins/c9.core/settings" && !c9Ws) {
|
||||
// todo: Don't show console when opening a file?
|
||||
// config[i].template = ;
|
||||
config[i].projectConfigPath = join(settingDir, "");
|
||||
config[i].userConfigPath = join(settingDir, "");
|
||||
config[i].stateConfigPath = join(settingDir, "");
|
||||
} else if (config[i].packagePath == "plugins/c9.ide.log/log" && !c9Ws) {
|
||||
config[i].source = "desktop";
|
||||
} else if (config[i].packagePath == "plugins/c9.ide.info/info" && c9Ws) {
|
||||
config[i].packagePath = "plugins/c9.ide.local/info";
|
||||
} else if (config[i].packagePath == "plugins/c9.ide.ui/menus" && c9Ws) {
|
||||
config[i].autoInit = false;
|
||||
} else if (config[i].packagePath == "plugins/c9.ide.tree/tree") {
|
||||
config[i].defaultExpanded = !config.hosted;
|
||||
}
|
||||
}
|
||||
|
||||
// Add local modules
|
||||
var includes = [{
|
||||
packagePath: "plugins/c9.ide.local/local",
|
||||
options: options,
|
||||
}, {
|
||||
packagePath: "plugins/c9.ide.local/windowframe",
|
||||
staticPrefix: options.staticPrefix + "/plugins/c9.ide.local"
|
||||
}, {
|
||||
packagePath: "plugins/c9.ide.local/update",
|
||||
host: options.update && options.update.host || "localhost", // "update.c9.io",
|
||||
port: options.update && options.update.port || "8888", // "443"
|
||||
path: options.update && options.update.path,
|
||||
protocol: options.update && options.update.protocol,
|
||||
installPath: options.correctedInstallPath,
|
||||
bashBin: options.bashBin,
|
||||
nodeBin: nodeBin
|
||||
}, {
|
||||
packagePath: "plugins/c9.ide.local/projectmanager"
|
||||
}, {
|
||||
packagePath: "plugins/c9.ide.local/open"
|
||||
}, {
|
||||
packagePath: "plugins/c9.ide.local/nativemenus"
|
||||
}, !c9Ws && {
|
||||
packagePath: "plugins/c9.ide.local/info",
|
||||
installPath: options.correctedInstallPath,
|
||||
settingDir: settingDir,
|
||||
cookie: options.user.cookie,
|
||||
user: {
|
||||
id: options.user.id,
|
||||
name: options.user.name,
|
||||
fullname: options.user.fullname,
|
||||
email: options.user.email,
|
||||
pubkey: options.user.pubkey
|
||||
},
|
||||
project: {
|
||||
id: options.project.id,
|
||||
name: options.project.name,
|
||||
contents: options.project.contents,
|
||||
descr: options.project.descr
|
||||
}
|
||||
}].filter(Boolean);
|
||||
|
||||
var excludes = c9Ws ? {} : {
|
||||
"plugins/c9.ide.newresource/open": true,
|
||||
"plugins/c9.ide.info/info": true,
|
||||
// "plugins/c9.ide.login/login": true,
|
||||
"plugins/c9.ide.collab/connect": true,
|
||||
"plugins/c9.ide.collab/collab": true,
|
||||
"plugins/c9.ide.collab/collabpanel": true,
|
||||
"plugins/c9.ide.collab/workspace": true,
|
||||
"plugins/c9.ide.collab/util": true,
|
||||
"plugins/c9.ide.collab/ot/document": true,
|
||||
"plugins/c9.ide.collab/cursor_layer": true,
|
||||
"plugins/c9.ide.collab/author_layer": true,
|
||||
"plugins/c9.ide.collab/timeslider/timeslider": true,
|
||||
"plugins/c9.ide.notifications/notifications": true,
|
||||
"plugins/c9.ide.collab/members/members_panel": true,
|
||||
"plugins/c9.ide.collab/share/share": true,
|
||||
"plugins/c9.ide.collab/members/members": true,
|
||||
"plugins/c9.ide.collab/chat/chat": true,
|
||||
"plugins/c9.ide.feedback/nps": true,
|
||||
"plugins/c9.ide.download/download": true
|
||||
};
|
||||
|
||||
config = config.concat(includes).filter(function (p) {
|
||||
return !excludes[p] && !excludes[p.packagePath];
|
||||
});
|
||||
|
||||
return config;
|
||||
};
|
|
@ -18,8 +18,8 @@
|
|||
"connect": "~2.12.0",
|
||||
"debug": "~0.7.4",
|
||||
"ejs": "~0.8.3",
|
||||
"engine.io": "~1.3.1",
|
||||
"engine.io-client": "~1.3.1",
|
||||
"engine.io": "~1.5.1",
|
||||
"engine.io-client": "~1.5.1",
|
||||
"eslint": "git://github.com/cloud9ide/eslint.git#e2d052aafd81ea0aa6d1d4fd9f88f3613e386160",
|
||||
"http-error": "~0.0.5",
|
||||
"less": "~1.5.1",
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
.c9-menu-btn.titlebar{
|
||||
position: absolute;
|
||||
z-index: 100000000;
|
||||
right: 24px;
|
||||
top: 1px;
|
||||
height: 19px;
|
||||
}
|
||||
|
||||
.c9-menu-btn.titlebar:not(.c9-menu-btnDown){
|
||||
height: 18px;
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
.fullscreen>.btnName{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.btnName.c9-menu-btnIcon{
|
||||
text-indent: -2000px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.btnName{
|
||||
padding: @menu-name-button-padding;
|
||||
margin-left: @menu-name-button-diff !important;
|
||||
}
|
||||
.btnName.c9-menu-btnmenuDown{
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
.btnName .icon{
|
||||
background-size: @menu-name-button-icon-width @menu-name-button-icon-height !important;
|
||||
top: @menu-name-button-icon-top !important;
|
||||
left: @menu-name-button-icon-left !important;
|
||||
width: @menu-name-button-icon-width;
|
||||
height: @menu-name-button-icon-height;
|
||||
border-radius: @menu-name-button-icon-border-radius;
|
||||
}
|
|
@ -0,0 +1,194 @@
|
|||
define(function(require, exports, module) {
|
||||
main.consumes = [
|
||||
"Plugin", "ui", "menus", "info", "layout", "http", "util",
|
||||
"vfs.endpoint", "auth", "dialog.alert", "c9"
|
||||
];
|
||||
main.provides = ["login"];
|
||||
return main;
|
||||
|
||||
function main(options, imports, register) {
|
||||
var Plugin = imports.Plugin;
|
||||
var ui = imports.ui;
|
||||
var c9 = imports.c9;
|
||||
var menus = imports.menus;
|
||||
var layout = imports.layout;
|
||||
var http = imports.http;
|
||||
var util = imports.util;
|
||||
var info = imports.info;
|
||||
var auth = imports.auth;
|
||||
var alert = imports["dialog.alert"].show;
|
||||
|
||||
var vfsEndpoint = imports["vfs.endpoint"];
|
||||
|
||||
/***** Initialization *****/
|
||||
|
||||
var ideBaseUrl = options.ideBaseUrl;
|
||||
var dashboardUrl = options.dashboardUrl;
|
||||
var accountUrl = options.accountUrl;
|
||||
var lastUser, mnuUser;
|
||||
|
||||
var plugin = new Plugin("Ajax.org", main.consumes);
|
||||
var emit = plugin.getEmitter();
|
||||
|
||||
var loaded = false;
|
||||
function load() {
|
||||
if (loaded) return false;
|
||||
loaded = true;
|
||||
|
||||
info.getUser(function(err, user) {
|
||||
updateButton({user: user});
|
||||
});
|
||||
|
||||
auth.on("relogin", onReLogin);
|
||||
}
|
||||
|
||||
/***** Methods *****/
|
||||
|
||||
function updateButton(e) {
|
||||
var user = e.user;
|
||||
if (lastUser && lastUser.id == user.id)
|
||||
return;
|
||||
plugin.cleanUp();
|
||||
info.on("change", updateButton, plugin);
|
||||
createButton(user);
|
||||
lastUser = user;
|
||||
|
||||
emit.sticky("ready", { name: user.fullname, id: user.id }, plugin);
|
||||
}
|
||||
|
||||
function createButton(user) {
|
||||
var name = "user_" + user.id;
|
||||
|
||||
// todo cleanup seems to not work well
|
||||
// without this menu is empty after logging out and back in
|
||||
if (lastUser)
|
||||
menus.remove("user_" + lastUser.id);
|
||||
menus.remove(name);
|
||||
|
||||
var parent = layout.findParent(plugin);
|
||||
|
||||
// Insert CSS
|
||||
ui.insertCss(require("text!./login.css"), plugin);
|
||||
|
||||
// Create Menu
|
||||
mnuUser = new ui.menu();
|
||||
plugin.addElement(mnuUser);
|
||||
|
||||
// Add named button
|
||||
var icon = util.getGravatarUrl(user.email, 32, "");
|
||||
menus.addItemByPath(name + "/", mnuUser, 110000, plugin);
|
||||
|
||||
// Add Divider
|
||||
ui.insertByIndex(parent, new ui.divider({
|
||||
skin: "c9-divider-double",
|
||||
"class" : "extrasdivider"
|
||||
}), 870, plugin);
|
||||
|
||||
// Add sub menu items
|
||||
var c = 500;
|
||||
menus.addItemByPath(name + "/Dashboard", new ui.item({
|
||||
onclick: function() { window.open(dashboardUrl); }
|
||||
}), c += 100, plugin);
|
||||
menus.addItemByPath(name + "/Account", new ui.item({
|
||||
onclick: function() { window.open(accountUrl); }
|
||||
}), c += 100, plugin);
|
||||
menus.addItemByPath(name + "/Home", new ui.item({
|
||||
onclick: function() { window.open(ideBaseUrl); }
|
||||
}), c += 100, plugin);
|
||||
|
||||
if (!options.noLogout) {
|
||||
menus.addItemByPath(name + "/~", new ui.divider(), c += 100, plugin);
|
||||
menus.addItemByPath(name + "/Log out", new ui.item({
|
||||
onclick: function() {
|
||||
if (!c9.local)
|
||||
return signout();
|
||||
auth.logout(function() {
|
||||
info.login(true);
|
||||
});
|
||||
}
|
||||
}), c += 100, plugin);
|
||||
}
|
||||
|
||||
var button = menus.get(name).item;
|
||||
button.setAttribute("class", "btnName");
|
||||
button.setAttribute("icon", icon);
|
||||
button.setAttribute("iconsize", "16px 16px");
|
||||
button.setAttribute("tooltip", user.fullname);
|
||||
button.setAttribute("caption", user.fullname);
|
||||
ui.insertByIndex(parent, button, 600, plugin);
|
||||
|
||||
if (c9.local) {
|
||||
function minimize(){
|
||||
apf.document.documentElement.appendChild(button);
|
||||
ui.setStyleClass(button.$ext, "titlebar");
|
||||
}
|
||||
function restore(){
|
||||
ui.insertByIndex(parent, button, 870, plugin);
|
||||
ui.setStyleClass(button.$ext, "", ["titlebar"]);
|
||||
}
|
||||
|
||||
menus.on("minimize", minimize, plugin);
|
||||
menus.on("restore", restore, plugin);
|
||||
|
||||
if (menus.minimized)
|
||||
minimize();
|
||||
}
|
||||
}
|
||||
|
||||
function signout() {
|
||||
vfsEndpoint.clearCache();
|
||||
auth.logout(function() { location.href = ideBaseUrl; });
|
||||
}
|
||||
|
||||
function onReLogin() {
|
||||
if (!c9.local) {
|
||||
alert("Logged out",
|
||||
"You have been logged in as a different user",
|
||||
"Please hit OK to reload the IDE.",
|
||||
function() {
|
||||
vfsEndpoint.clearCache();
|
||||
auth.logout(function() {
|
||||
document.location.reload();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/***** Lifecycle *****/
|
||||
|
||||
plugin.on("load", function() {
|
||||
load();
|
||||
});
|
||||
plugin.on("enable", function() {
|
||||
|
||||
});
|
||||
plugin.on("disable", function() {
|
||||
|
||||
});
|
||||
plugin.on("unload", function() {
|
||||
loaded = false;
|
||||
});
|
||||
|
||||
/***** Register and define API *****/
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
plugin.freezePublicAPI({
|
||||
get menu(){ return mnuUser; },
|
||||
|
||||
_events: [
|
||||
/**
|
||||
* @event ready
|
||||
*/
|
||||
"ready"
|
||||
],
|
||||
createButton: createButton,
|
||||
updateButton: updateButton
|
||||
});
|
||||
|
||||
register(null, {
|
||||
login: plugin
|
||||
});
|
||||
}
|
||||
});
|
|
@ -0,0 +1,283 @@
|
|||
(function(global) {
|
||||
"use strict";
|
||||
|
||||
var token = "";
|
||||
|
||||
var auth = global.auth = function(options) {
|
||||
// can only be called once
|
||||
global.auth = null;
|
||||
|
||||
var onLoad = options.onLoad;
|
||||
var preload = options.preload || noop;
|
||||
var authorized = options.authorized || noop;
|
||||
var background = options.background || noop;
|
||||
|
||||
importCssString("html.fulliframe, body.fulliframe {\
|
||||
overflow: hidden;\
|
||||
margin: auto;\
|
||||
height: 100%;\
|
||||
width: 100%;\
|
||||
}");
|
||||
|
||||
function noop(callback) { callback(); }
|
||||
|
||||
if (onLoad) {
|
||||
auth.parallel([
|
||||
background,
|
||||
auth.serial([
|
||||
auth.parallel([
|
||||
preload,
|
||||
login
|
||||
]),
|
||||
authorized,
|
||||
])
|
||||
])(done);
|
||||
}
|
||||
|
||||
function login(callback, errback) {
|
||||
var oauth = new Auth(options.clientId, options.authorizationUrl, options.loginHint);
|
||||
|
||||
oauth.authorize(true, function(err, _token) {
|
||||
if (err)
|
||||
return iframeLogin();
|
||||
|
||||
token = _token.access_token;
|
||||
callback(null, token);
|
||||
});
|
||||
|
||||
function iframeLogin() {
|
||||
errback && errback();
|
||||
oauth.authorize(false, function(err, _token) {
|
||||
if (err) return callback(err);
|
||||
token = _token.access_token;
|
||||
callback(null, token);
|
||||
});
|
||||
}
|
||||
|
||||
return function cancel() {
|
||||
oauth.cancel();
|
||||
};
|
||||
}
|
||||
|
||||
function done(err) {
|
||||
onLoad(err, token);
|
||||
}
|
||||
|
||||
return {
|
||||
login: login
|
||||
};
|
||||
};
|
||||
|
||||
function bindScript(script) {
|
||||
if (typeof script == "function")
|
||||
return script;
|
||||
else
|
||||
return loadScript.bind(null, script, token);
|
||||
}
|
||||
|
||||
auth.serial = function(list) {
|
||||
return function(callback) {
|
||||
serial(list.map(bindScript), callback);
|
||||
};
|
||||
};
|
||||
|
||||
auth.parallel = function(list) {
|
||||
return function(callback) {
|
||||
parallel(list.map(bindScript), callback);
|
||||
};
|
||||
};
|
||||
|
||||
function loadScript(path, token, callback) {
|
||||
var head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
|
||||
var s = document.createElement('script');
|
||||
|
||||
var and = path.indexOf("?") >= 0 ? "&" : "?";
|
||||
s.src = path + (token ? and + "access_token=" + encodeURIComponent(token) : "");
|
||||
head.appendChild(s);
|
||||
|
||||
s.onload = s.onreadystatechange = function(_, isAbort) {
|
||||
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
|
||||
s = s.onload = s.onreadystatechange = null;
|
||||
if (!isAbort)
|
||||
callback();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// copied from ace/lib/dom
|
||||
function importCssString(cssText) {
|
||||
var style;
|
||||
|
||||
if (document.createStyleSheet) {
|
||||
style = document.createStyleSheet();
|
||||
style.cssText = cssText;
|
||||
} else {
|
||||
style = document.createElementNS
|
||||
? document.createElementNS("http://www.w3.org/1999/xhtml", "style")
|
||||
: document.createElement("style");
|
||||
|
||||
style.appendChild(document.createTextNode(cssText));
|
||||
|
||||
(document.head || document.getElementsByTagName("head")[0] || document.documentElement).appendChild(style);
|
||||
}
|
||||
}
|
||||
|
||||
function serial(handlers, callback) {
|
||||
(function loop(i) {
|
||||
if (i >= handlers.length) return callback();
|
||||
|
||||
handlers[i](function(err) {
|
||||
if (err) return callback(err);
|
||||
|
||||
loop(i+1);
|
||||
});
|
||||
})(0);
|
||||
}
|
||||
|
||||
function parallel(handlers, callback) {
|
||||
var hadErr = false;
|
||||
var count = 0;
|
||||
handlers.forEach(function(handler) {
|
||||
handler(function(err) {
|
||||
if (hadErr) return;
|
||||
if (err) {
|
||||
hadErr = true;
|
||||
return callback(err);
|
||||
}
|
||||
count += 1;
|
||||
if (count == handlers.length)
|
||||
return callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// install exactly one global listener
|
||||
var listeners = {};
|
||||
window.addEventListener("message", function(e) {
|
||||
var token = e.data.token;
|
||||
if (token) {
|
||||
for (var url in listeners) {
|
||||
if (url.indexOf(e.origin) === 0) {
|
||||
var callback = listeners[url][token.state];
|
||||
delete listeners[url][token.state];
|
||||
if (callback) callback(null, token);
|
||||
|
||||
// make sure later listeners can't steal the token
|
||||
e.data.token = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, true);
|
||||
|
||||
|
||||
function Auth(clientId, authorizationUrl, loginHint) {
|
||||
this.clientId = clientId;
|
||||
this.authorizationUrl = authorizationUrl;
|
||||
this.loginHint = loginHint;
|
||||
listeners[authorizationUrl] = {};
|
||||
}
|
||||
|
||||
Auth.prototype.authorize = function(immediate, callback) {
|
||||
if (typeof immediate == "function")
|
||||
return this.authorize({}, immediate);
|
||||
|
||||
immediate = immediate || false;
|
||||
|
||||
var that = this;
|
||||
this.state = uid(15);
|
||||
|
||||
var url = this.authorizationUrl +
|
||||
"?response_type=postmessage" +
|
||||
"&client_id=" + encodeURIComponent(this.clientId) +
|
||||
"&state=" + encodeURIComponent(this.state) +
|
||||
"&style=overlay";
|
||||
|
||||
if (this.loginHint)
|
||||
url += "&login_hint=" + encodeURIComponent(this.loginHint || "");
|
||||
|
||||
if (immediate)
|
||||
url += "&immediate=1";
|
||||
|
||||
var frame = this._createFrame(url, immediate);
|
||||
var timeout = immediate ? 3000 : 0;
|
||||
|
||||
if (timeout) {
|
||||
var timer = setTimeout(function() {
|
||||
that._unpoll();
|
||||
callback(new Error("Login timed out"));
|
||||
}, timeout);
|
||||
}
|
||||
|
||||
this._removeFrame = function() {
|
||||
clearTimeout(timer);
|
||||
|
||||
frame.parentNode.removeChild(frame);
|
||||
document.documentElement.className = document.documentElement.className.replace(/\bfulliframe\b/, "");
|
||||
document.body.className = document.body.className.replace(/\bfulliframe\b/, "");
|
||||
that._removeFrame = null;
|
||||
};
|
||||
|
||||
this._poll(function(err, token) {
|
||||
if (that._removeFrame)
|
||||
that._removeFrame();
|
||||
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
if (token.error) {
|
||||
err = new Error(token.error);
|
||||
err.code = token.error_code;
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
that.token = token;
|
||||
return callback(null, token);
|
||||
});
|
||||
};
|
||||
|
||||
Auth.prototype.cancel = function() {
|
||||
this._unpoll();
|
||||
if (this._removeFrame)
|
||||
this._removeFrame();
|
||||
};
|
||||
|
||||
Auth.prototype._createFrame = function(url, hidden) {
|
||||
var frame = document.createElement("iframe");
|
||||
frame.setAttribute("src", url);
|
||||
frame.setAttribute("frameborder", "0");
|
||||
if (hidden) {
|
||||
frame.style.width = "1000px";
|
||||
frame.style.height = "1000px";
|
||||
frame.style.left = "-10000px";
|
||||
}
|
||||
else {
|
||||
frame.style.width = "100%";
|
||||
frame.style.height = "100%";
|
||||
frame.style.zIndex = "300000";
|
||||
document.documentElement.className += " fulliframe";
|
||||
document.body.className += " fulliframe";
|
||||
}
|
||||
frame.style.position = "absolute";
|
||||
document.body.appendChild(frame);
|
||||
return frame;
|
||||
};
|
||||
|
||||
Auth.prototype._poll = function(callback) {
|
||||
listeners[this.authorizationUrl][this.state] = callback;
|
||||
};
|
||||
|
||||
Auth.prototype._unpoll = function() {
|
||||
delete listeners[this.authorizationUrl][this.state];
|
||||
};
|
||||
|
||||
function uid(length) {
|
||||
var buf = new Uint8Array(new ArrayBuffer(length));
|
||||
(window.crypto || window.msCrypto).getRandomValues(buf);
|
||||
|
||||
return btoa(Array.prototype.reduce.call(buf, function(s, c) {
|
||||
return s + String.fromCharCode(c);
|
||||
}, "")).slice(0, length);
|
||||
}
|
||||
|
||||
})(this);
|
Ładowanie…
Reference in New Issue