Tạo mục JS trong ACP >> Module >> Javascript Management Title * : Day and Night Placement : In all the pages
Code:
function startTime() { var today=new Date(); var h=today.getHours(); var m=today.getMinutes(); var s=today.getSeconds(); // add a zero in front of numbers<10 m=checkTime(m); s=checkTime(s); document.getElementById('timeovl').innerHTML="Bây giờ là "+h+" giờ "+m+" phút "+s+" giây"; t=setTimeout(function(){startTime()},500); }
function checkTime(i) { if (i<10) { i="0" + i; } return i; }
Bài viết : 613 Uy tín : 35 Tham gia : 24/04/2012 Phương châm : Con người là số 1
Sort Catalogue của huynh Vống:
Phần một code:
Tạo thêm mục JS nữa Title * : Sort Catalogue Placement : In the homepage
Phần một:
Spoiler:
Code:
function sortcookie() { my_setcookie("sortfmvi", $("#sortfmvi").sortable("toArray")) } function restore() { var list = $("#sortfmvi"); var cookie = my_getcookie("sortfmvi"); if (cookie != null) { var IDs = cookie.split(",") } else { return false } var items = list.sortable("toArray"); var rebuild = new Array(); for (var v = 0, len = items.length; v < len; v++) { rebuild[items[v]] = items[v] } for (var i = 0, n = IDs.length; i < n; i++) { var itemID = IDs[i]; if (itemID in rebuild) { var item = rebuild[itemID]; var child = $(".main.ui-sortable").children("#" + item); var savedOrd = $(".main.ui-sortable").children("#" + itemID); child.remove(); $(".main.ui-sortable").filter(":first").append(savedOrd) } } } path = location.pathname.slice(1, 3);
function collapse(a) { $(a).children().toggle(); var id = $(a).parents(".boxfmvi").attr("id"); $(a).parents(".main-head").next().slideToggle(); if ($(a).find(".collap12").css("display") == "none") { my_setcookie(path + id, "close") } else { document.cookie = path + id + "=; expires=Monday, December 1, 2010 0:0:0 AM;" } } $(function () { $("#sortfmvi .boxfmvi").each(function () { $(this).attr("id", "soft" + $(".boxfmvi").index(this)); $(this).find(".page-title h2").prepend('<span class="collapse" onclick="collapse(this)" style="float:right"><a href="javascript:void(0);" class="collap12"></a><a href="javascript:void(0);" style="display:none" class="collap11"></a></span>'); if (my_getcookie(path + $(this).attr("id")) == "close") { $(this).find(".main-content").hide(); $(this).find(".page-title .collapse a").toggle() } }); $("#sortfmvi").sortable({ cursor: "move", handle: ".fmvimove", items: ".boxfmvi", opacity: 0.80, tolerance: "pointer", revert: true, update: function () { sortcookie() } }); restore() }); (function (e, t) { function i(t, n) { var r, i, o, u = t.nodeName.toLowerCase(); return "area" === u ? (r = t.parentNode, i = r.name, !t.href || !i || r.nodeName.toLowerCase() !== "map" ? !1 : (o = e("img[usemap=#" + i + "]")[0], !! o && s(o))) : (/input|select|textarea|button|object/.test(u) ? !t.disabled : "a" === u ? t.href || n : n) && s(t) } function s(t) { return e.expr.filters.visible(t) && !e(t).parents().andSelf().filter(function () { return e.css(this, "visibility") === "hidden" }).length } var n = 0, r = /^ui-id-\d+$/; e.ui = e.ui || {}; if (e.ui.version) return; e.extend(e.ui, { version: "1.9.2", keyCode: { BACKSPACE: 8, COMMA: 188, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, LEFT: 37, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108, NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SPACE: 32, TAB: 9, UP: 38 } }), e.fn.extend({ _focus: e.fn.focus, focus: function (t, n) { return typeof t == "number" ? this.each(function () { var r = this; setTimeout(function () { e(r).focus(), n && n.call(r) }, t) }) : this._focus.apply(this, arguments) }, scrollParent: function () { var t; return e.ui.ie && /(static|relative)/.test(this.css("position")) || /absolute/.test(this.css("position")) ? t = this.parents().filter(function () { return /(relative|absolute|fixed)/.test(e.css(this, "position")) && /(auto|scroll)/.test(e.css(this, "overflow") + e.css(this, "overflow-y") + e.css(this, "overflow-x")) }).eq(0) : t = this.parents().filter(function () { return /(auto|scroll)/.test(e.css(this, "overflow") + e.css(this, "overflow-y") + e.css(this, "overflow-x")) }).eq(0), /fixed/.test(this.css("position")) || !t.length ? e(document) : t }, zIndex: function (n) { if (n !== t) return this.css("zIndex", n); if (this.length) { var r = e(this[0]), i, s; while (r.length && r[0] !== document) { i = r.css("position"); if (i === "absolute" || i === "relative" || i === "fixed") { s = parseInt(r.css("zIndex"), 10); if (!isNaN(s) && s !== 0) return s } r = r.parent() } } return 0 }, uniqueId: function () { return this.each(function () { this.id || (this.id = "ui-id-" + ++n) }) }, removeUniqueId: function () { return this.each(function () { r.test(this.id) && e(this).removeAttr("id") }) } }), e.extend(e.expr[":"], { data: e.expr.createPseudo ? e.expr.createPseudo(function (t) { return function (n) { return !!e.data(n, t) } }) : function (t, n, r) { return !!e.data(t, r[3]) }, focusable: function (t) { return i(t, !isNaN(e.attr(t, "tabindex"))) }, tabbable: function (t) { var n = e.attr(t, "tabindex"), r = isNaN(n); return (r || n >= 0) && i(t, !r) } }), e(function () { var t = document.body, n = t.appendChild(n = document.createElement("div")); n.offsetHeight, e.extend(n.style, { minHeight: "100px", height: "auto", padding: 0, borderWidth: 0 }), e.support.minHeight = n.offsetHeight === 100, e.support.selectstart = "onselectstart" in n, t.removeChild(n).style.display = "none" }), e("<a>").outerWidth(1).jquery || e.each(["Width", "Height"], function (n, r) { function u(t, n, r, s) { return e.each(i, function () { n -= parseFloat(e.css(t, "padding" + this)) || 0, r && (n -= parseFloat(e.css(t, "border" + this + "Width")) || 0), s && (n -= parseFloat(e.css(t, "margin" + this)) || 0) }), n } var i = r === "Width" ? ["Left", "Right"] : ["Top", "Bottom"], s = r.toLowerCase(), o = { innerWidth: e.fn.innerWidth, innerHeight: e.fn.innerHeight, outerWidth: e.fn.outerWidth, outerHeight: e.fn.outerHeight }; e.fn["inner" + r] = function (n) { return n === t ? o["inner" + r].call(this) : this.each(function () { e(this).css(s, u(this, n) + "px") }) }, e.fn["outer" + r] = function (t, n) { return typeof t != "number" ? o["outer" + r].call(this, t) : this.each(function () { e(this).css(s, u(this, t, !0, n) + "px") }) } }), e("<a>").data("a-b", "a").removeData("a-b").data("a-b") && (e.fn.removeData = function (t) { return function (n) { return arguments.length ? t.call(this, e.camelCase(n)) : t.call(this) } }(e.fn.removeData)), function () { var t = /msie ([\w.]+)/.exec(navigator.userAgent.toLowerCase()) || []; e.ui.ie = t.length ? !0 : !1, e.ui.ie6 = parseFloat(t[1], 10) === 6 }(), e.fn.extend({ disableSelection: function () { return this.bind((e.support.selectstart ? "selectstart" : "mousedown") + ".ui-disableSelection", function (e) { e.preventDefault() }) }, enableSelection: function () { return this.unbind(".ui-disableSelection") } }), e.extend(e.ui, { plugin: { add: function (t, n, r) { var i, s = e.ui[t].prototype; for (i in r) s.plugins[i] = s.plugins[i] || [], s.plugins[i].push([n, r[i]]) }, call: function (e, t, n) { var r, i = e.plugins[t]; if (!i || !e.element[0].parentNode || e.element[0].parentNode.nodeType === 11) return; for (r = 0; r < i.length; r++) e.options[i[r][0]] && i[r][1].apply(e.element, n) } }, contains: e.contains, hasScroll: function (t, n) { if (e(t).css("overflow") === "hidden") return !1; var r = n && n === "left" ? "scrollLeft" : "scrollTop", i = !1; return t[r] > 0 ? !0 : (t[r] = 1, i = t[r] > 0, t[r] = 0, i) }, isOverAxis: function (e, t, n) { return e > t && e < t + n }, isOver: function (t, n, r, i, s, o) { return e.ui.isOverAxis(t, r, s) && e.ui.isOverAxis(n, i, o) } }) })(jQuery); (function (e, t) { var n = 0, r = Array.prototype.slice, i = e.cleanData; e.cleanData = function (t) { for (var n = 0, r; (r = t[n]) != null; n++) try { e(r).triggerHandler("remove") } catch (s) {} i(t) }, e.widget = function (t, n, r) { var i, s, o, u, a = t.split(".")[0]; t = t.split(".")[1], i = a + "-" + t, r || (r = n, n = e.Widget), e.expr[":"][i.toLowerCase()] = function (t) { return !!e.data(t, i) }, e[a] = e[a] || {}, s = e[a][t], o = e[a][t] = function (e, t) { if (!this._createWidget) return new o(e, t); arguments.length && this._createWidget(e, t) }, e.extend(o, s, { version: r.version, _proto: e.extend({}, r), _childConstructors: [] }), u = new n, u.options = e.widget.extend({}, u.options), e.each(r, function (t, i) { e.isFunction(i) && (r[t] = function () { var e = function () { return n.prototype[t].apply(this, arguments) }, r = function (e) { return n.prototype[t].apply(this, e) }; return function () { var t = this._super, n = this._superApply, s; return this._super = e, this._superApply = r, s = i.apply(this, arguments), this._super = t, this._superApply = n, s } }()) }), o.prototype = e.widget.extend(u, { widgetEventPrefix: s ? u.widgetEventPrefix : t }, r, { constructor: o, namespace: a, widgetName: t, widgetBaseClass: i, widgetFullName: i }), s ? (e.each(s._childConstructors, function (t, n) { var r = n.prototype; e.widget(r.namespace + "." + r.widgetName, o, n._proto) }), delete s._childConstructors) : n._childConstructors.push(o), e.widget.bridge(t, o) }, e.widget.extend = function (n) { var i = r.call(arguments, 1), s = 0, o = i.length, u, a; for (; s < o; s++) for (u in i[s]) a = i[s][u], i[s].hasOwnProperty(u) && a !== t && (e.isPlainObject(a) ? n[u] = e.isPlainObject(n[u]) ? e.widget.extend({}, n[u], a) : e.widget.extend({}, a) : n[u] = a); return n }, e.widget.bridge = function (n, i) { var s = i.prototype.widgetFullName || n; e.fn[n] = function (o) { var u = typeof o == "string", a = r.call(arguments, 1), f = this; return o = !u && a.length ? e.widget.extend.apply(null, [o].concat(a)) : o, u ? this.each(function () { var r, i = e.data(this, s); if (!i) return e.error("cannot call methods on " + n + " prior to initialization; " + "attempted to call method '" + o + "'"); if (!e.isFunction(i[o]) || o.charAt(0) === "_") return e.error("no such method '" + o + "' for " + n + " widget instance"); r = i[o].apply(i, a); if (r !== i && r !== t) return f = r && r.jquery ? f.pushStack(r.get()) : r, !1 }) : this.each(function () { var t = e.data(this, s); t ? t.option(o || {})._init() : e.data(this, s, new i(o, this)) }), f } }, e.Widget = function () {}, e.Widget._childConstructors = [], e.Widget.prototype = { widgetName: "widget", widgetEventPrefix: "", defaultElement: "<div>", options: { disabled: !1, create: null }, _createWidget: function (t, r) { r = e(r || this.defaultElement || this)[0], this.element = e(r), this.uuid = n++, this.eventNamespace = "." + this.widgetName + this.uuid, this.options = e.widget.extend({}, this.options, this._getCreateOptions(), t), this.bindings = e(), this.hoverable = e(), this.focusable = e(), r !== this && (e.data(r, this.widgetName, this), e.data(r, this.widgetFullName, this), this._on(!0, this.element, { remove: function (e) { e.target === r && this.destroy() } }), this.document = e(r.style ? r.ownerDocument : r.document || r), this.window = e(this.document[0].defaultView || this.document[0].parentWindow)), this._create(), this._trigger("create", null, this._getCreateEventData()), this._init() }, _getCreateOptions: e.noop, _getCreateEventData: e.noop, _create: e.noop, _init: e.noop, destroy: function () { this._destroy(), this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)), this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName + "-disabled " + "ui-state-disabled"), this.bindings.unbind(this.eventNamespace), this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus") }, _destroy: e.noop, widget: function () { return this.element }, option: function (n, r) { var i = n, s, o, u; if (arguments.length === 0) return e.widget.extend({}, this.options); if (typeof n == "string") { i = {}, s = n.split("."), n = s.shift(); if (s.length) { o = i[n] = e.widget.extend({}, this.options[n]); for (u = 0; u < s.length - 1; u++) o[s[u]] = o[s[u]] || {}, o = o[s[u]]; n = s.pop(); if (r === t) return o[n] === t ? null : o[n]; o[n] = r } else { if (r === t) return this.options[n] === t ? null : this.options[n]; i[n] = r } } return this._setOptions(i), this }, _setOptions: function (e) { var t; for (t in e) this._setOption(t, e[t]); return this }, _setOption: function (e, t) { return this.options[e] = t, e === "disabled" && (this.widget().toggleClass(this.widgetFullName + "-disabled ui-state-disabled", !! t).attr("aria-disabled", t), this.hoverable.removeClass("ui-state-hover"), this.focusable.removeClass("ui-state-focus")), this }, enable: function () { return this._setOption("disabled", !1) }, disable: function () { return this._setOption("disabled", !0) }, _on: function (t, n, r) { var i, s = this; typeof t != "boolean" && (r = n, n = t, t = !1), r ? (n = i = e(n), this.bindings = this.bindings.add(n)) : (r = n, n = this.element, i = this.widget()), e.each(r, function (r, o) { function u() { if (!t && (s.options.disabled === !0 || e(this).hasClass("ui-state-disabled"))) return; return (typeof o == "string" ? s[o] : o).apply(s, arguments) } typeof o != "string" && (u.guid = o.guid = o.guid || u.guid || e.guid++); var a = r.match(/^(\w+)\s*(.*)$/), f = a[1] + s.eventNamespace, l = a[2]; l ? i.delegate(l, f, u) : n.bind(f, u) }) }, _off: function (e, t) { t = (t || "").split(" ").join(this.eventNamespace + " ") + this.eventNamespace, e.unbind(t).undelegate(t) }, _delay: function (e, t) { function n() { return (typeof e == "string" ? r[e] : e).apply(r, arguments) } var r = this; return setTimeout(n, t || 0) }, _hoverable: function (t) { this.hoverable = this.hoverable.add(t), this._on(t, { mouseenter: function (t) { e(t.currentTarget).addClass("ui-state-hover") }, mouseleave: function (t) { e(t.currentTarget).removeClass("ui-state-hover") } }) }, _focusable: function (t) { this.focusable = this.focusable.add(t), this._on(t, { focusin: function (t) { e(t.currentTarget).addClass("ui-state-focus") }, focusout: function (t) { e(t.currentTarget).removeClass("ui-state-focus") } }) }, _trigger: function (t, n, r) { var i, s, o = this.options[t]; r = r || {}, n = e.Event(n), n.type = (t === this.widgetEventPrefix ? t : this.widgetEventPrefix + t).toLowerCase(), n.target = this.element[0], s = n.originalEvent; if (s) for (i in s) i in n || (n[i] = s[i]); return this.element.trigger(n, r), !(e.isFunction(o) && o.apply(this.element[0], [n].concat(r)) === !1 || n.isDefaultPrevented()) } }, e.each({ show: "fadeIn", hide: "fadeOut" }, function (t, n) { e.Widget.prototype["_" + t] = function (r, i, s) { typeof i == "string" && (i = { effect: i }); var o, u = i ? i === !0 || typeof i == "number" ? n : i.effect || n : t; i = i || {}, typeof i == "number" && (i = { duration: i }), o = !e.isEmptyObject(i), i.complete = s, i.delay && r.delay(i.delay), o && e.effects && (e.effects.effect[u] || e.uiBackCompat !== !1 && e.effects[u]) ? r[t](i) : u !== t && r[u] ? r[u](i.duration, i.easing, s) : r.queue(function (n) { e(this)[t](), s && s.call(r[0]), n() }) } }), e.uiBackCompat !== !1 && (e.Widget.prototype._getCreateOptions = function () { return e.metadata && e.metadata.get(this.element[0])[this.widgetName] }) })(jQuery); (function (e, t) { var n = !1; e(document).mouseup(function (e) { n = !1 }), e.widget("ui.mouse", { version: "1.9.2", options: { cancel: "input,textarea,button,select,option", distance: 1, delay: 0 }, _mouseInit: function () { var t = this; this.element.bind("mousedown." + this.widgetName, function (e) { return t._mouseDown(e) }).bind("click." + this.widgetName, function (n) { if (!0 === e.data(n.target, t.widgetName + ".preventClickEvent")) return e.removeData(n.target, t.widgetName + ".preventClickEvent"), n.stopImmediatePropagation(), !1 }), this.started = !1 }, _mouseDestroy: function () { this.element.unbind("." + this.widgetName), this._mouseMoveDelegate && e(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate) }, _mouseDown: function (t) { if (n) return; this._mouseStarted && this._mouseUp(t), this._mouseDownEvent = t; var r = this, i = t.which === 1, s = typeof this.options.cancel == "string" && t.target.nodeName ? e(t.target).closest(this.options.cancel).length : !1; if (!i || s || !this._mouseCapture(t)) return !0; this.mouseDelayMet = !this.options.delay, this.mouseDelayMet || (this._mouseDelayTimer = setTimeout(function () { r.mouseDelayMet = !0 }, this.options.delay)); if (this._mouseDistanceMet(t) && this._mouseDelayMet(t)) { this._mouseStarted = this._mouseStart(t) !== !1; if (!this._mouseStarted) return t.preventDefault(), !0 } return !0 === e.data(t.target, this.widgetName + ".preventClickEvent") && e.removeData(t.target, this.widgetName + ".preventClickEvent"), this._mouseMoveDelegate = function (e) { return r._mouseMove(e) }, this._mouseUpDelegate = function (e) { return r._mouseUp(e) }, e(document).bind("mousemove." + this.widgetName, this._mouseMoveDelegate).bind("mouseup." + this.widgetName, this._mouseUpDelegate), t.preventDefault(), n = !0, !0 }, _mouseMove: function (t) { return !e.ui.ie || document.documentMode >= 9 || !! t.button ? this._mouseStarted ? (this._mouseDrag(t), t.preventDefault()) : (this._mouseDistanceMet(t) && this._mouseDelayMet(t) && (this._mouseStarted = this._mouseStart(this._mouseDownEvent, t) !== !1, this._mouseStarted ? this._mouseDrag(t) : this._mouseUp(t)), !this._mouseStarted) : this._mouseUp(t) }, _mouseUp: function (t) { return e(document).unbind("mousemove." + this.widgetName, this._mouseMoveDelegate).unbind("mouseup." + this.widgetName, this._mouseUpDelegate), this._mouseStarted && (this._mouseStarted = !1, t.target === this._mouseDownEvent.target && e.data(t.target, this.widgetName + ".preventClickEvent", !0), this._mouseStop(t)), !1 }, _mouseDistanceMet: function (e) { return Math.max(Math.abs(this._mouseDownEvent.pageX - e.pageX), Math.abs(this._mouseDownEvent.pageY - e.pageY)) >= this.options.distance }, _mouseDelayMet: function (e) { return this.mouseDelayMet }, _mouseStart: function (e) {}, _mouseDrag: function (e) {}, _mouseStop: function (e) {}, _mouseCapture: function (e) { return !0 } }) })(jQuery);
Ghi chú: Do đoạn code quá dài nên phải chia ra làm 2 phần, các bạn cần thêm đoạn code ở topic tiếp theo (phần hai) vào file JavaScript.