mirror of https://gitee.com/zorlan/skycaiji
15 lines
2.8 KiB
JavaScript
15 lines
2.8 KiB
JavaScript
/*
|
|
|--------------------------------------------------------------------------
|
|
| SkyCaiji (蓝天采集器)
|
|
|--------------------------------------------------------------------------
|
|
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|
|
|--------------------------------------------------------------------------
|
|
| 使用协议 https://www.skycaiji.com/licenses
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
'use strict';function StoreClass(){}
|
|
StoreClass.prototype={constructor:StoreClass,init_iframe:function(){var boxHeight=$(window).height()-$('.main-header').height();$('.content').height(boxHeight+'px');$('#iframe_main').on('load',function(){if(!$(this).attr('src')){return}
|
|
$('.iframe-loading').remove();$(this).show();if($(this).attr('data-provider-url')){var body=document.getElementsByTagName('body')[0];var script=document.createElement('script');script.src='//www.skycaiji.com/provider/safe?url='+encodeURIComponent($(this).attr('data-provider-url'));script.type='text/javascript';body.appendChild(script)}})},init_my:function(){$('.store-detail').bind('click',function(){windowStore('详细',$(this).attr('href'));return!1})},init_link:function(){var $_o=this;if(window.site_config.clientinfo){var domain=/([\w\-]+\.)*skycaiji\.com/i;$('[src]').each(function(){if(domain.test($(this).attr('src'))){$_o.set_link('src',$(this))}});$('[href]').each(function(){if(domain.test($(this).attr('href'))){$_o.set_link('href',$(this))}});$('[action]').each(function(){if(domain.test($(this).attr('action'))){$_o.set_link('action',$(this))}});$('[data-is-store-url]').each(function(){var attrs=new Array('href','src','action');for(var i in attrs){var url=$(this).attr(attrs[i]);if(url){$_o.set_link(attrs[i],$(this))}}});$('[data-store-url]').each(function(){var type='data-store-url';if($(this).attr(type)){$_o.set_link(type,$(this));var url=$(this).attr(type);if(url){if($(this).is('iframe')){$(this).attr('src',url)}}}})}},set_link:function(type,obj){var url=obj.attr(type);if(type&&url){var edit=!1;if((/^\w+\:\/\/([\w\-]+\.)*skycaiji\.com/i).test(url)){url=url.replace(/^\w+\:\/\//,'//');edit=!0}
|
|
if(url.indexOf('clientinfo=')<0){url+=(url.indexOf('?')>-1?'&':'?')+'clientinfo='+encodeURIComponent(window.site_config.clientinfo);edit=!0}
|
|
if(edit){obj.attr(type,url)}}},is_login:function(func){var cname='store_islogin';var is_login=getCookie(cname);if(!is_login||is_login!='yes'){$.ajax({url:'//www.skycaiji.com/user/account/is_login',type:'get',dataType:'jsonp',jsonp:'callback',success:function(status){if(status){setCookie(cname,'yes',1);func()}else{setCookie(cname,'no',1);toastr.error('请先登录');windowStore('登录','https://www.skycaiji.com/user/account/login')}}})}else if(is_login=='yes'){func()}}}
|
|
var storeClass=new StoreClass();$(document).ready(function(){storeClass.init_link()}) |