From cf7f7e959a92e602eca070ce1563578fc83ffdcb Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Thu, 4 Jul 2024 12:50:26 +0300 Subject: [PATCH] Update pages --- app/Controllers/Api/Login.php | 90 +++++++++++++ app/Controllers/ApiController.php | 24 +--- app/Core/Routes.php | 2 + composer.json | 3 +- composer.lock | 76 ++++++++++- static/js/core.js | 98 ++++++++++++++ static/js/index.js | 213 ++++++++++++++++++++++++++++++ static/js/jquery-ui.js | 1 + static/js/jquery.js | 5 + views/components/LoadHead.php | 6 +- views/pages/Login.php | 99 ++++++++++++++ views/pages/Main.php | 14 +- 12 files changed, 598 insertions(+), 33 deletions(-) create mode 100644 app/Controllers/Api/Login.php create mode 100644 static/js/core.js create mode 100644 static/js/index.js create mode 100644 static/js/jquery-ui.js create mode 100644 static/js/jquery.js diff --git a/app/Controllers/Api/Login.php b/app/Controllers/Api/Login.php new file mode 100644 index 0000000..81a2741 --- /dev/null +++ b/app/Controllers/Api/Login.php @@ -0,0 +1,90 @@ + $username))) { + $email = DB::query('SELECT email FROM users WHERE email=:username OR username=:username', array(':username'=>$username))[0]['email']; + if (password_verify($password, DB::query('SELECT password FROM users WHERE email=:username', array(':username' => $email))[0]['password'])) { + $cstrong = True; + $token = GenerateRandomStr::gen_uuid(); + $user_id = DB::query('SELECT id FROM users WHERE email=:username', array(':username' => $email))[0]['id']; + + + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { + $ip = $_SERVER['HTTP_CLIENT_IP']; + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; + } else { + $ip = $_SERVER['REMOTE_ADDR']; + } + + $parser = new UserAgentParser(); + + $ua = $parser->parse(); + $ua = $parser(); + + $servicekey = GenerateRandomStr::gen_uuid(); + $url = 'http://ip-api.com/json/'.$ip; + + $response = file_get_contents($url); + + $data = json_decode($response, true); + $loc = $data['country'].', '.$data['city']; + DB::query('INSERT INTO login_tokens VALUES (\'0\', :token, :user_id, :platform, :browser, :browserversion, 0, :ip, :servicekey, :loc)', array( + ':token' => $token, + ':user_id' => $user_id, + ':platform' => $ua->platform(), + ':browser' => $ua->browser(), + ':browserversion' => $ua->browserVersion(), + ':ip' => $ip, + ':servicekey' => $servicekey, + ':loc' => $loc + )); + + setcookie("BIRUXSESS", $token, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); + setcookie("BIRUXSERVICE", $servicekey, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); + setcookie("BIRUXSESS_", '1', time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); + setcookie("BIRUXID", $user_id, time() + 50 * 50 * 54 * 72, '/', NULL, NULL, TRUE); + + echo Json::return ( + array( + 'errorcode' => '0', + 'error' => 0 + ) + ); + + + + } else { + echo Json::return ( + array( + 'errorcode' => '1', + 'error' => 1 + ) + ); + } + + } else { + echo Json::return ( + array( + 'errorcode' => '1', + 'error' => 1 + ) + ); + + } + } +} diff --git a/app/Controllers/ApiController.php b/app/Controllers/ApiController.php index 6cf77fa..d0c6fbd 100644 --- a/app/Controllers/ApiController.php +++ b/app/Controllers/ApiController.php @@ -4,29 +4,13 @@ namespace App\Controllers; use \App\Services\{Router, Auth, DB, Json}; use \App\Controllers\ExceptionRegister; use \App\Core\Page; - -class MainController +use \App\Controllers\Api\Login; +class ApiController { - public function __invoke() - { - - - } - public static function i() - { - - } - - public static function logout() - { - DB::query('DELETE FROM login_tokens WHERE servicekey=:userid', array(':userid'=>$_COOKIE['NGALLERYSERVICE'])); - setcookie('NGALLERYSERVICE', '', 1); - setcookie('NGALLERYSESS', '', 1); - setcookie('NGALLERYSESS_', '', 1); - setcookie('NGALLERYID', '', 1); - header('Location: /'); + public static function login() { + return new Login(); } } \ No newline at end of file diff --git a/app/Core/Routes.php b/app/Core/Routes.php index 7134f92..3e29f00 100644 --- a/app/Core/Routes.php +++ b/app/Core/Routes.php @@ -12,7 +12,9 @@ class Routes public static function init() { Router::get('/', 'MainController@i'); + Router::get('/login', 'LoginController@i'); Router::get('/photo/$id', 'PhotoController@i'); + Router::post('/api/login', 'ApiController@login'); diff --git a/composer.json b/composer.json index 1ae4515..ecf2126 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "require": { "aws/aws-sdk-php": "^3.315", "tracy/tracy": "^2.10", - "symfony/yaml": "^7.1" + "symfony/yaml": "^7.1", + "donatj/phpuseragentparser": "^1.8" } } diff --git a/composer.lock b/composer.lock index 03b4ec2..ce9364c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4cb3046ee61db32e4866c8f8ba6c0f99", + "content-hash": "73b4865b189367ec43d243dbb63808e2", "packages": [ { "name": "aws/aws-crt-php", @@ -155,6 +155,80 @@ }, "time": "2024-07-03T18:12:51+00:00" }, + { + "name": "donatj/phpuseragentparser", + "version": "v1.8.0", + "source": { + "type": "git", + "url": "https://github.com/donatj/PhpUserAgent.git", + "reference": "b8c16fd6e963651c6d86f66cb782ce599d62418e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/b8c16fd6e963651c6d86f66cb782ce599d62418e", + "reference": "b8c16fd6e963651c6d86f66cb782ce599d62418e", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "camspiers/json-pretty": "~1.0", + "donatj/drop": "*", + "ext-json": "*", + "phpunit/phpunit": "~4.8|~9" + }, + "type": "library", + "autoload": { + "files": [ + "src/UserAgentParser.php" + ], + "psr-4": { + "donatj\\UserAgent\\": "src/UserAgent" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jesse G. Donat", + "email": "donatj@gmail.com", + "homepage": "https://donatstudios.com", + "role": "Developer" + } + ], + "description": "Lightning fast, minimalist PHP UserAgent string parser.", + "homepage": "https://donatstudios.com/PHP-Parser-HTTP_USER_AGENT", + "keywords": [ + "browser", + "browser detection", + "parser", + "user agent", + "useragent" + ], + "support": { + "issues": "https://github.com/donatj/PhpUserAgent/issues", + "source": "https://github.com/donatj/PhpUserAgent/tree/v1.8.0" + }, + "funding": [ + { + "url": "https://www.paypal.me/donatj/15", + "type": "custom" + }, + { + "url": "https://github.com/donatj", + "type": "github" + }, + { + "url": "https://ko-fi.com/donatj", + "type": "ko_fi" + } + ], + "time": "2023-10-27T05:22:44+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "7.8.1", diff --git a/static/js/core.js b/static/js/core.js new file mode 100644 index 0000000..fa11c09 --- /dev/null +++ b/static/js/core.js @@ -0,0 +1,98 @@ +var _text = {}; + +function _getID(t) +{ + return document.getElementById(t); +} + +function trim(t) +{ + return t.replace(/^\s+/, '').replace(/\s+$/, ''); +} + +function addTexts(txt) +{ + for (var key in txt) _text[key] = txt[key]; +} + +function switchClass(objNode, strCurrClass, strNewClass) +{ + if (matchClass(objNode, strNewClass)) + replaceClass(objNode, strCurrClass, strNewClass); + else replaceClass(objNode, strNewClass, strCurrClass); +} + +function removeClass(objNode, strCurrClass) +{ + replaceClass(objNode, '', strCurrClass); +} + +function addClass(objNode, strNewClass) +{ + replaceClass(objNode, strNewClass, ''); +} + +function replaceClass(objNode, strNewClass, strCurrClass) +{ + var strOldClass = strNewClass; + if (strCurrClass && strCurrClass.length) + { + strCurrClass = strCurrClass.replace('/\s+(\S)/g', '|$1'); + if (strOldClass.length) strOldClass += '|'; + strOldClass += strCurrClass; + } + objNode.className = objNode.className.replace(new RegExp('(^|\\s+)(' + strOldClass + ')($|\\s+)', 'g'), '$1'); + objNode.className += ((objNode.className.length)? ' ' : '') + strNewClass; +} + +function matchClass(objNode, strCurrClass) +{ + return (objNode && objNode.className.length && objNode.className.match(new RegExp('(^|\\s+)(' + strCurrClass + ')($|\\s+)'))); +} + +function showId(id) +{ + _getID(id).style.display = 'block'; +} + +function hideId(id) +{ + _getID(id).style.display = 'none'; +} + + +$(document).ready(function() +{ + $(this).on('keydown', function(e) + { + if ($(e.target).is('input, textarea')) return; + + if (e.ctrlKey) + { + var link; + + switch (e.which) + { + case 0x24: window.location = '/'; return; + case 0x25: link = 'PrevLink'; break; + case 0x27: link = 'NextLink'; break; + case 0x26: link = 'UpLink'; break; + case 0x28: link = 'DownLink'; break; + } + + if (link) + { + var a = $('#' + link); + if (a.length) window.location = a.attr('href') + } + } + }); + + $('a.self-close').on('click', function() + { + window.open(this.href); + return false; + }); + + $('input, select, textarea', $('.form-field')).on('focus blur', function() { $(this).closest('.form-field').toggleClass('active').prev('.form-label').toggleClass('active'); }) +}); \ No newline at end of file diff --git a/static/js/index.js b/static/js/index.js new file mode 100644 index 0000000..3146a52 --- /dev/null +++ b/static/js/index.js @@ -0,0 +1,213 @@ +ar1 = new Image(); +ar1.src = '/img/ar1.gif'; + + +$(document).ready(function() +{ + $('.ix-country > a[href="#"]').on('click', function(e) + { + var block = $(this).parent().next('div'); + if (block.is(':hidden')) + { + block.slideDown(); + $('.ix-arrow', this).addClass('ix-arrow-expanded'); + } + else + { + block.slideUp(); + $('.ix-arrow', this).removeClass('ix-arrow-expanded'); + } + + return false; + }); + + + $(window).on('load resize', function() + { + var list = $('#idx-regions-list'); + var h = list.closest('table').height() - list.position().top + 40; + list.css('height', h + 'px'); + }); + + + $('#loadmore').on('click', LoadRecentPhotos).click(); + $('#newrand' ).on('click', LoadRandomPhotos).click(); + + updateInterval = setInterval(LoadPubPhotos, 60000); + + + //$('#cname').citySelector('cid', { defaultLabel: _text['IX_ANY'] }); + + + $('#type').on('change', function() { $('#type').attr('class', $('#type option:selected').attr('class')); }).change(); + $('#num').on('change keyup', function() { $('#qsearch').prop('disabled', $('#num').val().trim() == ''); }).on('keypress', function(event) { if (event.keyCode == 13) { searchVehicles(); return false; } }).change(); + $('#searchbtn').on('click', searchVehicles); + + + /*$('#qcity').citySelector(null, { + selectCallback: function(item) { window.open('/city/' + item.value + '/'); }, + clearField: true + });*/ + + + $(document).on('click', function(e) + { + var target = $(e.target); + if (target.closest('#cars_list').length > 0 || + target.closest('#idx-column-menu').length > 0 || + target.is('#mobile-menu') || + target.is('button')) return; + + $('#cars_list').hide().html(''); + + var menu = $('div#idx-column-menu'); + if (menu.is(':visible')) + { + menu.hide(); + $('#backgr').hide(); + } + + e.stopPropagation(); + }); + + + $('#loginbtn').on('click', function() + { + var username = $('#username').val().trim(); + var password = $('#password').val().trim(); + + if (username != '' && username != '') + { + $('#loginbtn').prop('disabled', true).val(_text['IX_LOGGING']); + + $.post('/api.php?action=check-login', { username: username, password: password, remember: $('#remember').is('checked') }, function(r) + { + if (r == 0) + $('#loginform').submit(); + else window.location.reload(); + }) + .fail(function(jx) { if (jx.responseText != '') alert(jx.responseText); }); + } + }); + + + $('#mobile-menu').on('click', function() + { + $('#idx-column-menu, #backgr').toggle(); + return false; + }); + + + $('.ix-plus, .ix-minus').on('click', function() + { + $(this).toggleClass('ix-plus ix-minus'); + + var block = $(this).closest('.ix-region'); + $('.ix-hideable-citylist, .ix-hideable-cname', block).toggle(); + + return false; + }); +}); + + +function searchVehicles() +{ + $('#cars_list').html('').show(); + $.get('/api.php', { action: 'index-qsearch', cid: $('#cid').val(), type: $('#type').val(), num: $('#num').val() }, function (r) { $('#cars_list').html(r); }); + return false; +} + + + +function AddPhotoToBlock(block, arr, prepend) +{ + block[prepend ? 'prepend' : 'append']('
' + arr.links + '
' + arr.pdate + '
' + (arr.ccnt != 0 ? '
' + arr.ccnt + '
' : '') + '
'); +} + + + +function LoadRandomPhotos() +{ + var random = $('#random-photos'); + var width = random.is('.mobile') ? 0 : random.width(); + var newrand = $('#newrand'); + var loader = $('#newrand-loader'); + + newrand.hide(); + loader.show(); + + $.getJSON('/api.php', { action: 'get-random-photos', width: width }, function(data) + { + random.html(''); + + if (data) + for (var i = 0; i < data.length; i++) AddPhotoToBlock(random, data[i]); + else random.append('Load error'); + + newrand.show(); + loader.hide(); + }) + .fail(function(jx) { if (jx.responseText != '') console.log(jx.responseText); }); + + return false; +} + + + +function LoadRecentPhotos() +{ + var recent = $('#recent-photos'); + var lastpid = recent.attr('lastpid'); + var width = recent.width(); + var loadmore = $('#loadmore'); + var hidden = $('.prw-grid-item:hidden', recent); + + if (recent.is('.mobile')) width *= 1.5; + + loadmore.prop('disabled', true).addClass('loader-button').val(' '); + + $.getJSON('/api.php', { action: 'get-recent-photos', width: width, lastpid: lastpid, hidden: hidden.length }, function(data) + { + if (data) + { + if (lastpid == 0) recent.attr('firstpid', data[0].pid); + hidden.show(); + + for (var i = 0; i < data.length; i++) AddPhotoToBlock(recent, data[i]); + recent.attr('lastpid', data[i-1].pid); + } + else recent.append('Load error'); + + loadmore.prop('disabled', false).removeClass('loader-button').val(_text['IX_LOADMORE']); + }) + .fail(function(jx) { if (jx.responseText != '') console.log(jx.responseText); }); +} + + + +function LoadPubPhotos() +{ + var recent = $('#recent-photos'); + var firstpid = recent.attr('firstpid'); + + if (firstpid == 0) return; + + $.getJSON('/api.php', { action: 'get-pub-photos', firstpid: firstpid }, function(data) + { + if (data) + { + if (data.length) + { + for (var i = 0; i < data.length; i++) + { + $('.prw-grid-item:visible', recent).eq(-1).hide(); + AddPhotoToBlock(recent, data[i], true); + } + + recent.attr('firstpid', data[i-1].pid); + } + } + else clearInterval(updateInterval); + }) + .fail(function(jx) { if (jx.responseText != '') console.log(jx.responseText); }); +} \ No newline at end of file diff --git a/static/js/jquery-ui.js b/static/js/jquery-ui.js new file mode 100644 index 0000000..50ba4ca --- /dev/null +++ b/static/js/jquery-ui.js @@ -0,0 +1 @@ +!function(t,e){function i(e,i){var n,o,r,h=e.nodeName.toLowerCase();return"area"===h?(n=e.parentNode,o=n.name,!(!e.href||!o||"map"!==n.nodeName.toLowerCase())&&(!!(r=t("img[usemap=#"+o+"]")[0])&&s(r))):(/input|select|textarea|button|object/.test(h)?!e.disabled:"a"===h?e.href||i:i)&&s(e)}function s(e){return t.expr.filters.visible(e)&&!t(e).parents().addBack().filter(function(){return"hidden"===t.css(this,"visibility")}).length}var n=0,o=/^ui-id-\d+$/;t.ui=t.ui||{},t.extend(t.ui,{version:"1.10.4",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}}),t.fn.extend({focus:function(e){return function(i,s){return"number"==typeof i?this.each(function(){var e=this;setTimeout(function(){t(e).focus(),s&&s.call(e)},i)}):e.apply(this,arguments)}}(t.fn.focus),scrollParent:function(){var e;return e=t.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(t.css(this,"position"))&&/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!e.length?t(document):e},zIndex:function(e){if(void 0!==e)return this.css("zIndex",e);if(this.length)for(var i,s,n=t(this[0]);n.length&&n[0]!==document;){if(("absolute"===(i=n.css("position"))||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++n)})},removeUniqueId:function(){return this.each(function(){o.test(this.id)&&t(this).removeAttr("id")})}}),t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(i){return!!t.data(i,e)}}):function(e,i,s){return!!t.data(e,s[3])},focusable:function(e){return i(e,!isNaN(t.attr(e,"tabindex")))},tabbable:function(e){var s=t.attr(e,"tabindex"),n=isNaN(s);return(n||s>=0)&&i(e,!n)}}),t("").outerWidth(1).jquery||t.each(["Width","Height"],function(e,i){function s(e,i,s,o){return t.each(n,function(){i-=parseFloat(t.css(e,"padding"+this))||0,s&&(i-=parseFloat(t.css(e,"border"+this+"Width"))||0),o&&(i-=parseFloat(t.css(e,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),r={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(e){return void 0===e?r["inner"+i].call(this):this.each(function(){t(this).css(o,s(this,e)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?r["outer"+i].call(this,e):this.each(function(){t(this).css(o,s(this,e,!0,n)+"px")})}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t("").data("a-b","a").removeData("a-b").data("a-b")&&(t.fn.removeData=function(e){return function(i){return arguments.length?e.call(this,t.camelCase(i)):e.call(this)}}(t.fn.removeData)),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),t.support.selectstart="onselectstart"in document.createElement("div"),t.fn.extend({disableSelection:function(){return this.bind((t.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(t){t.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),t.extend(t.ui,{plugin:{add:function(e,i,s){var n,o=t.ui[e].prototype;for(n in s)o.plugins[n]=o.plugins[n]||[],o.plugins[n].push([i,s[n]])},call:function(t,e,i){var s,n=t.plugins[e];if(n&&t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType)for(s=0;s0||(e[s]=1,n=e[s]>0,e[s]=0,n)}})}(jQuery),function(t,e){var i=0,s=Array.prototype.slice,n=t.cleanData;t.cleanData=function(e){for(var i,s=0;null!=(i=e[s]);s++)try{t(i).triggerHandler("remove")}catch(t){}n(e)},t.widget=function(e,i,s){var n,o,r,h,a={},l=e.split(".")[0];e=e.split(".")[1],n=l+"-"+e,s||(s=i,i=t.Widget),t.expr[":"][n.toLowerCase()]=function(e){return!!t.data(e,n)},t[l]=t[l]||{},o=t[l][e],r=t[l][e]=function(t,e){if(!this._createWidget)return new r(t,e);arguments.length&&this._createWidget(t,e)},t.extend(r,o,{version:s.version,_proto:t.extend({},s),_childConstructors:[]}),(h=new i).options=t.widget.extend({},h.options),t.each(s,function(e,s){t.isFunction(s)?a[e]=function(){var t=function(){return i.prototype[e].apply(this,arguments)},n=function(t){return i.prototype[e].apply(this,t)};return function(){var e,i=this._super,o=this._superApply;return this._super=t,this._superApply=n,e=s.apply(this,arguments),this._super=i,this._superApply=o,e}}():a[e]=s}),r.prototype=t.widget.extend(h,{widgetEventPrefix:o?h.widgetEventPrefix||e:e},a,{constructor:r,namespace:l,widgetName:e,widgetFullName:n}),o?(t.each(o._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,r,i._proto)}),delete o._childConstructors):i._childConstructors.push(r),t.widget.bridge(e,r)},t.widget.extend=function(e){for(var i,n,o=s.call(arguments,1),r=0,h=o.length;r",options:{disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=t(),this.hoverable=t(),this.focusable=t(),s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(t.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:t.noop,widget:function(){return this.element},option:function(e,i){var s,n,o,r=e;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof e)if(r={},s=e.split("."),e=s.shift(),s.length){for(n=r[e]=t.widget.extend({},this.options[e]),o=0;o=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(jQuery),function(t,e){function i(t,e,i){return[parseFloat(t[0])*(p.test(t[0])?e/100:1),parseFloat(t[1])*(p.test(t[1])?i/100:1)]}function s(e,i){return parseInt(t.css(e,i),10)||0}function n(e){var i=e[0];return 9===i.nodeType?{width:e.width(),height:e.height(),offset:{top:0,left:0}}:t.isWindow(i)?{width:e.width(),height:e.height(),offset:{top:e.scrollTop(),left:e.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:e.outerWidth(),height:e.outerHeight(),offset:e.offset()}}t.ui=t.ui||{};var o,r=Math.max,h=Math.abs,a=Math.round,l=/left|center|right/,c=/top|center|bottom/,u=/[\+\-]\d+(\.[\d]+)?%?/,d=/^\w+/,p=/%$/,f=t.fn.position;t.position={scrollbarWidth:function(){if(void 0!==o)return o;var e,i,s=t("
"),n=s.children()[0];return t("body").append(s),e=n.offsetWidth,s.css("overflow","scroll"),i=n.offsetWidth,e===i&&(i=s[0].clientWidth),s.remove(),o=e-i},getScrollInfo:function(e){var i=e.isWindow||e.isDocument?"":e.element.css("overflow-x"),s=e.isWindow||e.isDocument?"":e.element.css("overflow-y"),n="scroll"===i||"auto"===i&&e.width0?"right":"center",vertical:o<0?"top":n>0?"bottom":"middle"};pr(h(n),h(o))?a.important="horizontal":a.important="vertical",e.using.call(this,t,a)}),c.offset(t.extend(D,{using:l}))})},t.ui.position={fit:{left:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollLeft:s.offset.left,o=s.width,h=t.left-e.collisionPosition.marginLeft,a=n-h,l=h+e.collisionWidth-o-n;e.collisionWidth>o?a>0&&l<=0?(i=t.left+a+e.collisionWidth-o-n,t.left+=a-i):t.left=l>0&&a<=0?n:a>l?n+o-e.collisionWidth:n:a>0?t.left+=a:l>0?t.left-=l:t.left=r(t.left-h,t.left)},top:function(t,e){var i,s=e.within,n=s.isWindow?s.scrollTop:s.offset.top,o=e.within.height,h=t.top-e.collisionPosition.marginTop,a=n-h,l=h+e.collisionHeight-o-n;e.collisionHeight>o?a>0&&l<=0?(i=t.top+a+e.collisionHeight-o-n,t.top+=a-i):t.top=l>0&&a<=0?n:a>l?n+o-e.collisionHeight:n:a>0?t.top+=a:l>0?t.top-=l:t.top=r(t.top-h,t.top)}},flip:{left:function(t,e){var i,s,n=e.within,o=n.offset.left+n.scrollLeft,r=n.width,a=n.isWindow?n.scrollLeft:n.offset.left,l=t.left-e.collisionPosition.marginLeft,c=l-a,u=l+e.collisionWidth-r-a,d="left"===e.my[0]?-e.elemWidth:"right"===e.my[0]?e.elemWidth:0,p="left"===e.at[0]?e.targetWidth:"right"===e.at[0]?-e.targetWidth:0,f=-2*e.offset[0];c<0?((i=t.left+d+p+f+e.collisionWidth-r-o)<0||i0&&((s=t.left-e.collisionPosition.marginLeft+d+p+f-a)>0||h(s)c&&(s<0||s0&&(i=t.top-e.collisionPosition.marginTop+d+p+f-a,t.top+d+p+f>u&&(i>0||h(i)10&&n<11,e.innerHTML="",i.removeChild(e)}()}(jQuery),function(t,e){function i(t,e,i){return t>e&&t *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var t=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=!!this.items.length&&("x"===t.axis||s(this.items[0].item)),this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_setOption:function(e,i){"disabled"===e?(this.options[e]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):t.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(e,i){var s=null,n=!1,o=this;return!this.reverting&&(!this.options.disabled&&"static"!==this.options.type&&(this._refreshItems(e),t(e.target).parents().each(function(){if(t.data(this,o.widgetName+"-item")===o)return s=t(this),!1}),t.data(e.target,o.widgetName+"-item")===o&&(s=t(e.target)),!!s&&(!(this.options.handle&&!i&&(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(n=!0)}),!n))&&(this.currentItem=s,this._removeCurrentsFromItems(),!0))))},_mouseStart:function(e,i,s){var n,o,r=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,r.cursorAt&&this._adjustOffsetFromHelper(r.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),r.containment&&this._setContainment(),r.cursor&&"auto"!==r.cursor&&(o=this.document.find("body"),this.storedCursor=o.css("cursor"),o.css("cursor",r.cursor),this.storedStylesheet=t("").appendTo(o)),r.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",r.opacity)),r.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",r.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!r.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,n,o,r=this.options,h=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY=0;i--)if(s=this.items[i],n=s.item[0],(o=this._intersectsWithPointer(s))&&s.instance===this.currentContainer&&!(n===this.currentItem[0]||this.placeholder[1===o?"next":"prev"]()[0]===n||t.contains(this.placeholder[0],n)||"semi-dynamic"===this.options.type&&t.contains(this.element[0],n))){if(this.direction=1===o?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,n=this.placeholder.offset(),o=this.options.axis,r={};o&&"x"!==o||(r.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),o&&"y"!==o||(r.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(r,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,o=t.left,r=o+t.width,h=t.top,a=h+t.height,l=this.offset.click.top,c=this.offset.click.left,u="x"===this.options.axis||s+l>h&&s+lo&&e+ct[this.floating?"width":"height"]?p:o0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){var i,s,n,o,r=[],h=[],a=this._connectWith();if(a&&e)for(i=a.length-1;i>=0;i--)for(s=(n=t(a[i])).length-1;s>=0;s--)(o=t.data(n[s],this.widgetFullName))&&o!==this&&!o.options.disabled&&h.push([t.isFunction(o.options.items)?o.options.items.call(o.element):t(o.options.items,o.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),o]);for(h.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),i=h.length-1;i>=0;i--)h[i][0].each(function(){r.push(this)});return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;i=0;i--)for(s=(n=t(d[i])).length-1;s>=0;s--)(o=t.data(n[s],this.widgetFullName))&&o!==this&&!o.options.disabled&&(u.push([t.isFunction(o.options.items)?o.options.items.call(o.element[0],e,{item:this.currentItem}):t(o.options.items,o.element),o]),this.containers.push(o));for(i=u.length-1;i>=0;i--)for(r=u[i][1],s=0,l=(h=u[i][0]).length;s=0;i--)(s=this.items[i]).instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=n.outerWidth(),s.height=n.outerHeight()),o=n.offset(),s.left=o.left,s.top=o.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)o=this.containers[i].element.offset(),this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){var i,s=(e=e||this).options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),n=t("<"+s+">",e.document[0]).addClass(i||e.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===s?e.currentItem.children().each(function(){t(" ",e.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(n)}):"img"===s&&n.attr("src",e.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(t,n){i&&!s.forcePlaceholderSize||(n.height()||n.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_contactContainers:function(e){var n,o,r,h,a,l,c,u,d,p,f=null,m=null;for(n=this.containers.length-1;n>=0;n--)if(!t.contains(this.currentItem[0],this.containers[n].element[0]))if(this._intersectsWith(this.containers[n].containerCache)){if(f&&t.contains(this.containers[n].element[0],f.element[0]))continue;f=this.containers[n],m=n}else this.containers[n].containerCache.over&&(this.containers[n]._trigger("out",e,this._uiHash(this)),this.containers[n].containerCache.over=0);if(f)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",e,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(r=1e4,h=null,a=(p=f.floating||s(this.currentItem))?"left":"top",l=p?"width":"height",c=this.positionAbs[a]+this.offset.click[a],o=this.items.length-1;o>=0;o--)t.contains(this.containers[m].element[0],this.items[o].item[0])&&this.items[o].item[0]!==this.currentItem[0]&&(p&&!i(this.positionAbs.top+this.offset.click.top,this.items[o].top,this.items[o].height)||(u=this.items[o].item.offset()[a],d=!1,Math.abs(u-c)>Math.abs(u+this.items[o][l]-c)&&(d=!0,u+=this.items[o][l]),Math.abs(u-c)this.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(r=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((r-this.originalPageY)/n.grid[1])*n.grid[1],r=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((o-this.originalPageX)/n.grid[0])*n.grid[0],o=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:r-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():a?0:h.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():a?0:h.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){function i(t,e,i){return function(s){i._trigger(t,s,e._uiHash(e))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)"auto"!==this._storedCSS[s]&&"static"!==this._storedCSS[s]||(this._storedCSS[s]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||n.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(n.push(function(t){this._trigger("remove",t,this._uiHash())}),n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)e||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!e){for(this._trigger("beforeStop",t,this._uiHash()),s=0;s",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var e,i,s,n=this.element[0].nodeName.toLowerCase(),o="textarea"===n,r="input"===n;this.isMultiLine=!!o||!r&&this.element.prop("isContentEditable"),this.valueMethod=this.element[o||r?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return e=!0,s=!0,void(i=!0);e=!1,s=!1,i=!1;var o=t.ui.keyCode;switch(n.keyCode){case o.PAGE_UP:e=!0,this._move("previousPage",n);break;case o.PAGE_DOWN:e=!0,this._move("nextPage",n);break;case o.UP:e=!0,this._keyEvent("previous",n);break;case o.DOWN:e=!0,this._keyEvent("next",n);break;case o.ENTER:case o.NUMPAD_ENTER:this.menu.active&&(e=!0,n.preventDefault(),this.menu.select(n));break;case o.TAB:this.menu.active&&this.menu.select(n);break;case o.ESCAPE:this.menu.element.is(":visible")&&(this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(e)return e=!1,void(this.isMultiLine&&!this.menu.element.is(":visible")||s.preventDefault());if(!i){var n=t.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(t){if(s)return s=!1,void t.preventDefault();this._searchTimeout(t)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){this.cancelBlur?delete this.cancelBlur:(clearTimeout(this.searching),this.close(t),this._change(t))}}),this.loader=t('
').insertBefore(this.element),this._initSource(),this.menu=t("