コード例 #1
0
ファイル: app.js プロジェクト: siplabs/monster-ui
		triggerLoginMechanism: function() {
			var self = this,
				urlParams = monster.util.getUrlVars(),
				successfulAuth = function(authData) {
					self._afterSuccessfulAuth(authData);
				};

			// First check if there is a custom authentication mechanism
			if('authentication' in monster.config.whitelabel) {
				self.customAuth = monster.config.whitelabel.authentication;

				var options = {
					sourceUrl: self.customAuth.source_url,
					apiUrl: self.customAuth.api_url
				};

				monster.apps.load(self.customAuth.name, function(app) {
					app.render(self.appFlags.mainContainer);
				}, options);
			}
			// otherwise, we handle it ourself, and we check if the authentication cookie exists, try to log in with its information
			else if($.cookie('monster-auth')) {
				var cookieData = $.parseJSON($.cookie('monster-auth'));

				self.authenticateAuthToken(cookieData.accountId, cookieData.authToken, successfulAuth);
			}
			// Otherwise, we check if some GET parameters are defined, and if they're formatted properly
			else if(urlParams.hasOwnProperty('t') && urlParams.hasOwnProperty('a') && urlParams.t.length === 32 && urlParams.a.length === 32) {
				self.authenticateAuthToken(urlParams.a, urlParams.t, successfulAuth);
			}
			// Default case, we didn't find any way to log in automatically, we render the login page
			else {
				self.renderLoginPage(self.appFlags.mainContainer);
			}
		},
コード例 #2
0
ファイル: keen.js プロジェクト: HalcyonChimera/osf.io
 createOrUpdateKeenSession: function() {
     var expDate = new Date();
     var expiresInMinutes = 25;
     expDate.setTime(expDate.getTime() + (expiresInMinutes*60*1000));
     var currentSessionId = $.cookie('keenSessionId') || uuid.v1();
     $.cookie('keenSessionId', currentSessionId, {expires: expDate, path: '/'});
 },
コード例 #3
0
ファイル: keen.js プロジェクト: HalcyonChimera/osf.io
    getOrCreateKeenId: function() {
        if(!$.cookie('keenUserId')){
            $.cookie('keenUserId', uuid.v1(), {expires: 365, path: '/'});
        }

        return $.cookie('keenUserId');
    },
コード例 #4
0
ファイル: dropbox.js プロジェクト: n-studio/afterwriting-labs
			window.addEventListener('message', function (e) {
				if (e.origin !== 'https://ifrost.github.io' && e.origin !== 'http://afterwriting.com' && e.origin !== 'http://localhost:8000') {
					return;
				}

				if (/error=/.test(e.data)) {
					return;
				}

				var token = /access_token=([^\&]*)/.exec(e.data)[1],
					uid = /uid=([^\&]*)/.exec(e.data)[1],
					state_r = /state=([^\&]*)/.exec(e.data)[1];

				if (state !== state_r) {
					return;
				}

				$.cookie('dbt', token);
				$.cookie('dbu', uid);

				client = new Dropbox.Client({
					key: key,
					sandbox: false,
					token: token,
					uid: uid
				});

				popup.close();
				callback();
			});
コード例 #5
0
ファイル: app.js プロジェクト: kiserp/monster-ui
						function() {
							var cookieData = $.parseJSON($.cookie('monster-auth')),
								lang = monster.config.whitelabel.language,
								isoFormattedLang = lang.substr(0, 3).concat(lang.substr(lang.length -2, 2).toUpperCase()),
								currentLang = app.i18n.hasOwnProperty(isoFormattedLang) ? isoFormattedLang : 'en-US',
								appData = {
									api_url: app.api_url,
									icon: self.apiUrl + 'accounts/' + self.accountId + '/apps_store/' + app.id + '/icon?auth_token=' + self.authToken,
									id: app.id,
									label: app.i18n[currentLang].label,
									name: app.name
								};

							// Add source_url only if it defined 
							if(app.hasOwnProperty('source_url')) {
								appData.source_url = app.source_url;
							}

							// Update local installedApps list by adding the new app
							monster.apps.auth.installedApps.push(_.find(appstoreData.apps, function(val, idx) { return val.id === app.id; }));

							// Update installedApps list of the cookie by adding the new app
							cookieData.installedApps.push(appData.id);

							// Update cookie
							$.cookie('monster-auth', JSON.stringify(cookieData));

							$('#appstore_container .app-element[data-id="'+app.id+'"]').addClass('installed');
							$('#appstore_container .app-filter.active').click();

							parent.closest(':ui-dialog').dialog('close');
						});
コード例 #6
0
/* center modal */
function initAppPromos(window) {
  function centerModals() {
    $('.modal').each(function(/* i */) {
      var clone = $(this).clone().css('display', 'block').appendTo('body');
      var top = Math.round((clone.height() - clone.find('.modal-content').height()) / 2);
      top = top > 0 ? top : 0;
      clone.remove();
      $(this).find('.modal-content').css('margin-top', top);
    });
  }

  function hideAppPromo() {
    $.cookie('ap-closed', '1', {expires: 4});
  }

  // Only show the promo if it's the second time the user is using the app
  if ($('#app-install')) {
    var appUsed = $.cookie('ap-used');
    if (appUsed) {
      $('.modal').on('show.bs.modal', centerModals);
      $(window).on('resize', centerModals);

      var appPromoClosed = $.cookie('ap-closed');
      if (!appPromoClosed) {
        $('#app-install').modal({});
      }
    }
    $.cookie('ap-used', '1', {expires: 60});

    $('.onclick-hide-app-promo').on('click', hideAppPromo);
  }
}
コード例 #7
0
CDropboxSettingsFormView.prototype.connect = function (aScopes)
{
	$.removeCookie('oauth-scopes');
	$.cookie('oauth-scopes', aScopes.join('|'));
	$.cookie('oauth-redirect', 'connect');
	this.bRunCallback = false;
	var
		oWin = WindowOpener.open(UrlUtils.getAppPath() + '?oauth=dropbox', 'Dropbox'),
		iIntervalId = setInterval(_.bind(function() {
			if (oWin.closed)
			{
				if (!this.bRunCallback)
				{
					window.location.reload();
				}
				else
				{
					clearInterval(iIntervalId);
					App.broadcastEvent('OAuthAccountChange::after');
					this.updateSavedState();
					Settings.updateScopes(this.connected(), this.scopes());
				}
			}
		}, this), 1000)
	;
};
コード例 #8
0
ファイル: record.js プロジェクト: chiro/automata
 ).done(function(master, scheme, users) {
     var filtered = $.cookie('default-filtered');
     if (typeof filtered === 'undefined' || filtered === 'true') {
         filtered = true;
     } else {
         filtered = false;
     }
     $.cookie('default-filtered', filtered);
     if (this.isMounted()) {
         this.setState({
             user: master.user,
             token: master.token,
             admin: master.admin,
             reload: master.reload,
             interact: master.interact,
             scheme: scheme,
             users: users,
             comments: {},
             filtered: filtered
         });
     }
     this.queryComments(users.map(_.partial(_.result, _, 'token')));
     if (!master.admin && this.getPath() === '/') {
         var report = $.cookie('default-report');
         if (!report) report = scheme[0].id;
         this.replaceWith('user', {
             token: master.token,
             report: report
         });
     }
 }.bind(this));
CLoginView.prototype.changeLanguage = function (sLanguage)
{
	if (sLanguage && this.bAllowChangeLanguage)
	{
		$.cookie('aurora-lang-on-login', sLanguage, { expires: 30 });
		$.cookie('aurora-selected-lang', sLanguage, { expires: 30 });
		window.location.reload();
	}
};
コード例 #10
0
module.exports = function(){
	var cookieData = {};
	if(typeof $.cookie('newVe')!='undefined'){
		cookieData = JSON.parse($.cookie('newVe'));
	}
	Vue.filter('currencyDisplay', {
		 
		read: function(val) {
			if(val=='T'){
				return false
			}else{
				return true
			}
		},
		write: function(val, oldVal) {
		   	if(val){
				return 'F'
			}else{
				return 'T'
			}
		}
	})
	new  Vue({
		el: '#app',
	  	data: cookieData,
	  	ready: function() {
	  		var that = this;
	  		$.ajax({
				url: '/Manager/TaobaoLastroomOptionList',
				type: 'POST',
				contentType: "application/json",
				data:'{"hotelCode":"'+cookieData.hotelCode+'","hotelGroupCode":"'+cookieData.hotelGroupCode+'","rateplanCode":"'+'LASTROOM'+'"}',
			})
			.done(function(data) {
			
				that.$set('ManualTaobaoLastroomOption', data.resultInfos);	 
			})
	  	},
	  	methods:{
	  		
	  		sail:function(){
	  			
	  			sendRoomOption(this)
	  		},
	  		outAll:function(){
	  			
	  			sendRoomOption(this)
	  			
	  			
	  		}
	  	}

	 })


}
コード例 #11
0
            $container.on('tab:toggle', '[data-tab-trigger]', function() {
                var $tab = $(this).closest('[data-tab]');

                mediator.trigger('scrollable-table:reload');
                if ($tab.hasClass('active')) {
                    $.cookie(cookieName, true, {path: window.location.pathname});
                } else {
                    $.cookie(cookieName, null, {path: window.location.pathname});
                }
            });
コード例 #12
0
ファイル: models.js プロジェクト: WiserTogether/chiropractor
               'token returned by the server.', function() {
        expect($.cookie('wttoken')).to.equal(null);

        this.model.fetch();
        this.server.respond();

        expect(this.server.requests.length).to.equal(1);

        expect($.cookie('wttoken')).to.equal(this.token);
      });
コード例 #13
0
ファイル: keen.js プロジェクト: AllisonLBowers/osf.io
 createOrUpdateKeenSession: function() {
     var date = new Date();
     var expiresInMinutes = 25;
     var expDate = date.setTime(date.getTime() + (expiresInMinutes*60*1000));
     if(!$.cookie('keenSessionId')){
         $.cookie('keenSessionId', uuid.v1(), {expires: expDate, path: '/'});
     } else {
         var sessionId = $.cookie('keenSessionId');
         $.cookie('keenSessionId', sessionId, {expires: expDate, path: '/'});
     }
 },
コード例 #14
0
 // kaltura expects a persistent analytic session token for the user
 // this generates a simple session id for analytic purposes
 // no session/authentication is associated with this token
 ensureAnalyticSession() {
   this.kaSession = $.cookie('kaltura_analytic_tracker', undefined, {path: '/'})
   if (!this.kaSession) {
     this.kaSession = (
       Math.random().toString(16) +
       Math.random().toString(16) +
       Math.random().toString(16)
     ).replace(/\./g, '')
     return $.cookie('kaltura_analytic_tracker', this.kaSession, {path: '/'})
   }
 }
コード例 #15
0
ファイル: monster.util.js プロジェクト: digideskio/monster-ui
		setDefaultLanguage: function() {
			var browserLanguage = (navigator.language).replace(/-.*/,function(a){return a.toUpperCase();}),// always capitalize the second part of the navigator language
				cookieLanguage = $.cookie('monster-auth') ? ($.parseJSON($.cookie('monster-auth'))).language : undefined,
				defaultLanguage = browserLanguage || 'en-US';

			monster.config.whitelabel.language = cookieLanguage || monster.config.whitelabel.language || defaultLanguage;

			// Normalize the language to always be capitalized after the hyphen (ex: en-us -> en-US, fr-FR -> fr-FR)
			// Will normalize bad input from the config.js or cookie data coming directly from the database
			monster.config.whitelabel.language = (monster.config.whitelabel.language).replace(/-.*/,function(a){return a.toUpperCase();})
		},
コード例 #16
0
ファイル: common.js プロジェクト: cedk/pootle
    $(document).on('click', '.js-sidebar-toggle', function () {
      var $sidebar = $('.js-sidebar'),
          openClass = 'sidebar-open',
          cookieName = 'pootle-browser-sidebar',
          cookieData = JSON.parse($.cookie(cookieName)) || {};

      $sidebar.toggleClass(openClass);

      cookieData.isOpen = $sidebar.hasClass(openClass);
      $.cookie(cookieName, JSON.stringify(cookieData), {path: '/'});
    });
コード例 #17
0
ファイル: monster.util.js プロジェクト: mas44/monster-ui
		setDefaultLanguage: function() {
			var browserLanguage = (navigator.language).replace(/-.*/,function(a){return a.toUpperCase();}), // always capitalize the second part of the navigator language
				defaultLanguage = browserLanguage || 'en-US';

			monster.config.whitelabel.language = monster.config.whitelabel.language || defaultLanguage;

			if($.cookie('monster-auth')) {
				var authData = $.parseJSON($.cookie('monster-auth'));

				monster.config.whitelabel.language = authData.language;
			};
		},
コード例 #18
0
ファイル: console-layout.js プロジェクト: eleanors/MXPlay
 function(event) {
         var $this = $(this);
         var appId = $this.attr('appid');
         var appname = $this.find('h5').html();
         $.cookie('curAppId', appId, {
                 expires: 7
         });
         $.cookie('curAppName', appname, {
                 expires: 7
         });
         window.location.href = '/appoverview';
 });
コード例 #19
0
ファイル: own.js プロジェクト: zhaoxuesong/onroadbio.com
	function appupdate(){
		var applist = '';
		if($.cookie('appupdate')){
			applist = $.cookie('appupdate').split('|');
		}
		$.each(applist, function(i, item){
			var app = item.split('-');
			if($('#'+app[0]).attr('data-ver') != app[1]){
				$('#'+app[0]).removeClass("hidden");
			}
		});
	}	
コード例 #20
0
ファイル: home.js プロジェクト: mottaquikarim/magnitude
function bootstrap() {
    if ( $.cookie( 'token' ) ) {
        _template( $.cookie('token') );
    }
    else {
        _template();
    }

    var $login = $('.login');
    GitHubOAuthCLI.handleAuthentication( $login );

}
コード例 #21
0
ファイル: pk.js プロジェクト: yiilover/youju
	$.fn.pk=function(length,url){
		var $w=$(window);
		$("body").append('<div id="pkCon"><div class="hided"></div><div class="show"><h4>楼盘对比</h4><ul><li>请先选择需要对比的楼盘,<br>最多可同时对比'+length+'个楼盘</li><li><button class="db"></button><button class="qk"></button></li></ul></div></div>')
		var $pk=$("#pkCon").css("top",$w.scrollTop()+$w.height()/2-99);
		$pk.on("click","div.hided",function(){
			$pk.addClass("on");
		}).on("click","h4",function(){
			$pk.removeClass("on");
		}).on("click","em",function(){
			$(this).parent().remove();
			if($pk.find("li").length==2)
				$pk.find("li").eq(0).show()
			$.cookie("db",$pk.find("ul").html());
		}).on("click","button.qk",function(){
			$pk.find("ul").html('<li>请先选择需要对比的楼盘,<br>最多可同时对比'+length+'个楼盘</li><li><button class="db"></button><button class="qk"></button></li>');
			$.cookie("db","","")
		}).on("click","button.db",function(){
			if($pk.find("li").length>3)
				var href=[];
				$pk.find("a").each(function(){
					href.push($(this).attr("data-val"))
				});
				setTimeout(function(){
					window.location.href=url+"&itemid%5B%5D="+href.join("&itemid%5B%5D=")+"";
				},99)
		});
		if($.cookie("db")){
			$pk.addClass("on").find("ul").html($.cookie("db"));
		}
		$(this).on("click",function(){
			var $t=$(this);
			$pk.addClass("on");
			if($pk.find("li").length<length+2){
				var bl=1;
				$pk.find("a").each(function(){
					if($t.attr("data-val")==$(this).attr("data-val")){
						alertM("请勿选择重复楼盘");
						bl=0;
						return false;
					}
				})
				if(bl){
					$pk.find("li").eq(0).hide().after('<li><em></em><a data-val="'+$t.attr("data-val")+'" href="'+$t.attr("data-url")+'">'+$t.attr("data-name")+'</a></li>');
					$.cookie("db",$pk.find("ul").html());
				}
			}else
				alertM("最多只能选择"+length+"个楼盘")
		})
		$w.scroll(function(){
			$pk.css("top",$w.scrollTop()+$w.height()/2-99);
		})
	}
コード例 #22
0
 Auth.prototype._storeData = function(data) {
   var accessTokenExpiration, refreshTokenExpiration;
   accessTokenExpiration = new Date;
   accessTokenExpiration.setSeconds(accessTokenExpiration.getSeconds + parseInt(data.expires_in));
   refreshTokenExpiration = new Date;
   refreshTokenExpiration.setSeconds(refreshTokenExpiration.getSeconds + this.refreshTokenTtl);
   $.cookie(this.ACCESS_TOKEN_COOKIE_NAME, data.access_token, {
     expires: accessTokenExpiration
   });
   return $.cookie(this.REFRESH_TOKEN_COOKIE_NAME, data.refresh_token, {
     expires: refreshTokenExpiration
   });
 };
コード例 #23
0
ファイル: monster.apps.js プロジェクト: kiserp/monster-ui
								successCallback = function(data, status) {
									monster.apps.auth.currentUser = data.data;
									monster.pub('auth.currentUserUpdated', data.data);

									var cookieData = $.parseJSON($.cookie('monster-auth'));

									// If the language stored in the cookie is not the same as the one we have in the updated data, we update the cookie.
									if(cookieData.language !== data.data.language) {
										cookieData.language = data.data.language;
										$.cookie('monster-auth', JSON.stringify(cookieData));
									}

									params.success && params.success(data, status);
								}
コード例 #24
0
ファイル: console-layout.js プロジェクト: eleanors/MXPlay
                }).done(function(data) {
                        if (data.status == 1) {
                                var phone = data.result.phone || '';
                                if (data.result.icon1) {
                                        $('#my_photo_icon').attr('src', data.result.icon1);
                                        $.cookie('userIcon', data.result.icon1, {
                                                expires: 7
                                        });
                                } else {
                                        $('#my_photo_icon').attr('src', '/img/favicon-30.png');
                                        $.cookie('nickname', data.result.userName, {
                                                expires: 7
                                        });
                                }
                                if (phone) {
                                        /*force add phone*/
                                        $('.main-applist-out #createApp').attr('data-phone', phone);
                                }
                                var email = $.cookie('username') || '';
                                if (data.result.userName) {
                                        $('#userName span').eq(0).html(data.result.userName);
                                        if ($.cookie('remMe')) {
                                                $.cookie('nickname', data.result.userName, {
                                                        expires: 7
                                                });
                                        } else {
                                                $.cookie('nickname', data.result.userName, {
                                                        expires: 1
                                                });
                                        }
                                } else {
                                        $('#userName span').eq(0).html(email);
                                        $.removeCookie('nickname', {
                                                expires: 1
                                        });
                                }
                                if (!data.result.state && $.cookie("VerfyEmail") != $.cookie('username')) {
                                        var $str = $('<div id="errTopMiddle" class="err-top fail">' +
                                        // '   <i class="err-close">'+
                                        // '       <i class="icon-remove"></i>'+
                                        // '   </i>'+
                                        '   <div class="err-out">' + '       <div class="err-switch">' + '           <i class="err-switch-i icon-smile"></i>' + '           <i class="err-switch-i icon-frown"></i>' + '           <span class="err-content">' + i18n.t('appInfo.unActive') + '</span>' + '       </div>' + '   </div>' + '</div>');

                                        $str.appendTo($("body"));
                                        $str.slideDown();
                                        $str.find(".icon-remove").on("click",
                                        function() {
                                                $(this).slideUp(400,
                                                function() {
                                                        $str.remove();
                                                        $.cookie("VerfyEmail", $.cookie('username'), {
                                                                expires: 7
                                                        });
                                                });
                                        });
                                }
                        } else {
                                // console.log(data);
                        }
                }).always(function() {});
コード例 #25
0
 success: function (model, response) {
     var first_name = $.cookie('first_name');
     var last_name = $.cookie('last_name');
     $('.new-comment').before('<div class="row"> \
         <div class="col-sm-1 discussee-box"> \
             ' + first_name + ' ' + last_name + ' \
         </div> \
         <div class="col-sm-11 discussion-box"> \
             ' + marked(model.escape("comment")) + ' \
         <hr> \
         </div> \
     </div>');
     $('form#add-comment textarea').val('');
     that.nComment.clear();
 }
コード例 #26
0
ファイル: app.js プロジェクト: sintezcs/monster-ui
			self.putAuth(loginData, function (data) {
				if($('#remember_me').is(':checked')) {
					var cookieLogin = {
						login: loginUsername,
						accountName: loginAccountName
					};

					$.cookie('monster-login', JSON.stringify(cookieLogin), {expires: 30});
				}
				else {
					$.cookie('monster-login', null);
				}

				self._afterSuccessfulAuth(data);
			});
コード例 #27
0
ファイル: app.js プロジェクト: kiserp/monster-ui
		_afterAuthenticate: function(data) {
			var self = this;

			self.accountId = data.data.account_id;
			self.authToken = data.auth_token;
			self.userId = data.data.owner_id;
			self.isReseller = data.data.is_reseller;
			self.resellerId = data.data.reseller_id;

			if('apps' in data.data) {
				self.installedApps = data.data.apps;
			} else {
				self.installedApps = [];
				toastr.error(self.i18n.active().toastrMessages.appListError);
			}

			if($('#remember_me').is(':checked')) {
				var templateLogin = $('.login-block form');
				    cookieLogin = {
						login: templateLogin.find('#login').val(),
						accountName: templateLogin.find('#account_name').val()
					};

				$.cookie('monster-login', JSON.stringify(cookieLogin), {expires: 30});
			}
			else{
				$.cookie('monster-login', null);
			}

			var cookieAuth = {
				language: data.data.language,
				authToken: self.authToken,
				accountId: self.accountId,
				userId: self.userId,
				isReseller: self.isReseller,
				resellerId: self.resellerId
			};

			cookieAuth.installedApps = _.map(self.installedApps, function(app) { return app.id });

			$.cookie('monster-auth', JSON.stringify(cookieAuth));

			$('#monster-content').addClass('monster-content');
			$('#main .footer-wrapper').append($('#monster-content .powered-by-block .powered-by'));
			$('#monster-content ').empty();

			self.afterLoggedIn();
		},
コード例 #28
0
ファイル: models.js プロジェクト: WiserTogether/chiropractor
               'expiring.', function(done) {
        var spy = this.sandbox.spy();

        this.token = 'Token a::' + this.time + '::' +
                    (this.time + 120 + 1) + '::hmac';

        $.cookie('wttoken', this.token);

        this.model.listenTo(
                    Chiropractor.Events,
                    'authentication:expiration',
                    spy
                );

        setTimeout(function() {
          try {
            expect(spy.callCount).to.equal(0);
            done();
          } catch (e) {
            done(e);
          }
        }, 30);

        this.server.respondWith(
                    this.path,
                    [200, {'Authorization': this.token}, '{"test": 1}']
                );

        this.model.fetch();
        this.server.respond();
      });
コード例 #29
0
ファイル: base-page.js プロジェクト: caneruguz/osf.io
var SlideInViewModel = function (){
    var self = this;
    self.elem = $(sliderSelector);

    var dismissed = false;

    try {
        dismissed = dismissed || window.localStorage.getItem('slide') === '0';
    } catch (e) {}

    dismissed = dismissed || $.cookie('slide') === '0';

    if (this.elem.length > 0 && !dismissed) {
        setTimeout(function () {
            self.elem.slideDown(1000);
        }, 3000);
    }
    self.dismiss = function() {
        self.elem.slideUp(1000);
        try {
            window.localStorage.setItem('slide', '0');
        } catch (e) {
            $.cookie('slide', '0', { expires: 1, path: '/'});
        }
        self.trackClick('Dismiss');
    };
    // Google Analytics click event tracking
    self.trackClick = function(source) {
        window.ga('send', 'event', 'button', 'click', source);
        //in order to make the href redirect work under knockout onclick binding
        return true;
    };
};
コード例 #30
0
ファイル: currency.js プロジェクト: TeachAtTUM/edx-platform
  setCookie(countryCode, l10nData) {
    function pick(curr, arr) {
      const obj = {};
      arr.forEach((key) => {
        obj[key] = curr[key];
      });
      return obj;
    }
    const userCountryData = pick(l10nData, [countryCode]);
    let countryL10nData = userCountryData[countryCode];

    if (countryL10nData) {
      countryL10nData.countryCode = countryCode;
      $.cookie('edx-price-l10n', JSON.stringify(countryL10nData), {
        domain: 'edx.org',
        expires: 1,
      });
    } else {
      countryL10nData = {
        countryCode: 'USA',
        symbol: '$',
        rate: '1',
        code: 'USD',
      };
    }
    this.countryL10nData = countryL10nData;
  }