|
@@ -10,6 +10,8 @@
|
|
|
|
|
|
if (window.Navbar) return;
|
|
|
|
|
|
+ var navbarTpl = __inline("./navbar.tmpl")
|
|
|
+
|
|
|
var scripts = document.getElementsByTagName('script');
|
|
|
|
|
|
var isKa = (/\?type=ka/).test(scripts[scripts.length - 1].src);
|
|
@@ -314,46 +316,56 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
+ var logoutSucc = function(){
|
|
|
+ renderNavbar()
|
|
|
+ initEvent()
|
|
|
+ }
|
|
|
+
|
|
|
+ var initEvent = function(){
|
|
|
+ $gSearch.on("focus", "input[type='text']", function () {
|
|
|
+ $gSearch.find(".g-search-tips").show()
|
|
|
+ }).on("blur", "input[type='text']", function () {
|
|
|
+ setTimeout(function () {
|
|
|
+ $gSearch.find(".g-search-tips").hide()
|
|
|
+ }, 500)
|
|
|
+ })
|
|
|
+
|
|
|
+ if (location.host.indexOf("video.duowan.com") > -1) {
|
|
|
+ $gSearch.attr("action", "http://video.duowan.com/")
|
|
|
+ $gSearch.find("input[type=text]").attr("name", "w")
|
|
|
+ $gSearch.find("input[type=hidden]").attr("name", "r").val("search/index")
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Event.attach(navDom.login, "click", function (e) {
|
|
|
+ Event.preventDefault(e);
|
|
|
+ if (dwUDBProxy.add && !isBBs) {
|
|
|
+ dwUDBProxy.login(plainFunction)
|
|
|
+ } else {
|
|
|
+ dwUDBProxy.login()
|
|
|
+ }
|
|
|
+ }).attach(navDom.reglink, 'click', function (e) {
|
|
|
+ Event.preventDefault(e);
|
|
|
+
|
|
|
+ dwUDBProxy.register(plainFunction)
|
|
|
+ })
|
|
|
+ Event.attach(navDom.logout, "click", function (e) {
|
|
|
+ Event.preventDefault(e);
|
|
|
+ dwUDBProxy.logout(plainFunction); //为空,退出成功后则跳转到当前页面
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
/**兼容旧版 */
|
|
|
if (dwUDBProxy.add) {
|
|
|
dwUDBProxy.add(loginSucc)
|
|
|
+ dwUDBProxy.addLogout(logoutSucc)
|
|
|
} else {
|
|
|
if (dwUDBProxy.isLogin()) {
|
|
|
loginSucc()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $gSearch.on("focus", "input[type='text']", function () {
|
|
|
- $gSearch.find(".g-search-tips").show()
|
|
|
- }).on("blur", "input[type='text']", function () {
|
|
|
- setTimeout(function () {
|
|
|
- $gSearch.find(".g-search-tips").hide()
|
|
|
- }, 500)
|
|
|
- })
|
|
|
-
|
|
|
- if (location.host.indexOf("video.duowan.com") > -1) {
|
|
|
- $gSearch.attr("action", "http://video.duowan.com/")
|
|
|
- $gSearch.find("input[type=text]").attr("name", "w")
|
|
|
- $gSearch.find("input[type=hidden]").attr("name", "r").val("search/index")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- Event.attach(navDom.login, "click", function (e) {
|
|
|
- Event.preventDefault(e);
|
|
|
- if (dwUDBProxy.add && !isBBs) {
|
|
|
- dwUDBProxy.login(plainFunction)
|
|
|
- } else {
|
|
|
- dwUDBProxy.login()
|
|
|
- }
|
|
|
- }).attach(navDom.reglink, 'click', function (e) {
|
|
|
- Event.preventDefault(e);
|
|
|
-
|
|
|
- dwUDBProxy.register(plainFunction)
|
|
|
- })
|
|
|
- Event.attach(navDom.logout, "click", function (e) {
|
|
|
- Event.preventDefault(e);
|
|
|
- dwUDBProxy.logout(''); //为空,退出成功后则跳转到当前页面
|
|
|
- });
|
|
|
+ initEvent()
|
|
|
})
|
|
|
|
|
|
if (window.dwUDBProxy) {
|
|
@@ -369,25 +381,30 @@
|
|
|
var CSS_TEXT = __inline("./style.css");
|
|
|
var dynamicStyle = Util.createStyleSheet(CSS_TEXT);
|
|
|
var navDom = {};
|
|
|
- var rootEl = navDom.el = document.createElement("div");
|
|
|
-
|
|
|
- rootEl.id = "dw-topbar";
|
|
|
- rootEl.innerHTML = __inline("./navbar.tmpl")({
|
|
|
- isKa: isKa
|
|
|
- })
|
|
|
+ var rootEl = null;
|
|
|
+ renderNavbar();
|
|
|
+ function renderNavbar(){
|
|
|
+ if(rootEl){
|
|
|
+ navDom = {}
|
|
|
+ document.body.removeChild(rootEl)
|
|
|
+ }
|
|
|
+ rootEl = navDom.el = document.createElement("div");
|
|
|
+ rootEl.id = "dw-topbar";
|
|
|
+ rootEl.innerHTML = navbarTpl({
|
|
|
+ isKa: isKa
|
|
|
+ })
|
|
|
|
|
|
- Util.hashElements(rootEl, navDom);
|
|
|
+ Util.hashElements(rootEl, navDom);
|
|
|
|
|
|
- document.body.insertBefore(rootEl, document.body.firstChild);
|
|
|
+ document.body.insertBefore(rootEl, document.body.firstChild);
|
|
|
|
|
|
- if (document.domain.toLowerCase().indexOf("sc2.com") > -1) {
|
|
|
- navDom.loginform.action = "https://udb.sc2.com.cn/login.jsp"
|
|
|
+ if (document.domain.toLowerCase().indexOf("sc2.com") > -1) {
|
|
|
+ navDom.loginform.action = "https://udb.sc2.com.cn/login.jsp"
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
var defineNavbar = function () {
|
|
|
-
|
|
|
- var Navbar = window.Navbar = {
|
|
|
- dom: navDom,
|
|
|
+ window.Navbar = {
|
|
|
bbsCallbacks: jQuery.Callbacks('memory'),
|
|
|
unreadCallbacks: jQuery.Callbacks('memory'),
|
|
|
systemCallbacks: jQuery.Callbacks('memory'),
|