diff --git a/application/modules/default/controllers/JsonController.php b/application/modules/default/controllers/JsonController.php index 280432d47..34825bdb8 100755 --- a/application/modules/default/controllers/JsonController.php +++ b/application/modules/default/controllers/JsonController.php @@ -1,672 +1,682 @@ . **/ class JsonController extends Zend_Controller_Action { const chat_avatarUrl = 'https://chat.opendesktop.org/_matrix/media/v1/thumbnail'; const chat_roomPublicUrl = 'https://chat.opendesktop.org/_matrix/client/unstable/publicRooms'; const chat_roomsUrl = 'https://chat.opendesktop.org/_matrix/client/unstable/rooms/'; const chat_roomUrl = 'https://chat.opendesktop.org/#/room/'; const chat_userProfileUrl = 'https://chat.opendesktop.org/_matrix/client/r0/profile/'; const chat_userPresense = 'https://chat.opendesktop.org/_matrix/client/r0/presence/'; protected $_format = 'json'; public function init() { parent::init(); $this->initView(); $this->log = Zend_Registry::get('logger'); } public function initView() { // Disable render view $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); } public function indexAction() { $this->_sendErrorResponse(999, 'unknown request'); } protected function _initResponseHeader() { http_response_code(200); if (!empty($_SERVER['HTTP_ORIGIN'])) { header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN'], true); header('Access-Control-Allow-Credentials: true', true); header('Access-Control-Max-Age: 1728000', true); } if (!empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) { header('Access-Control-Allow-Methods: ' . implode(', ', array_unique([ 'OPTIONS', 'HEAD', 'GET', 'POST', 'PUT', strtoupper($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']) ])), true); } if (!empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) { header('Access-Control-Allow-Headers: ' . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'], true); header('Access-Control-Expose-Headers: Authorization, Content-Type, Accept', true); } if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { exit; } header('Content-Type: application/json; charset=UTF-8', true); } protected function _sendResponse($response, $format = 'json', $xmlRootTag = 'ocs') { header('Content-Type: application/json; charset=UTF-8'); echo json_encode($response); } public function chatAction() { $this->_initResponseHeader(); $config = Zend_Registry::get('config')->settings->client->default; $access_token = $config->riot_access_token; $urlRooms = JsonController::chat_roomPublicUrl . '?access_token=' . $access_token; $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $urlRooms); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); $results = json_decode($data); // https://chat.opendesktop.org/_matrix/client/unstable/publicRooms?access_token= $rooms = array(); foreach ($results->chunk as &$room) { if ($room->guest_can_join) continue; $urlMembers = JsonController::chat_roomsUrl . $room->room_id . '/joined_members?access_token=' . $access_token; //https://chat.opendesktop.org/_matrix/client/unstable/rooms/!LNQABMgCYqWKSysjJK%3Achat.opendesktop.org/joined_members?access_token= $k = curl_init(); curl_setopt($k, CURLOPT_AUTOREFERER, true); curl_setopt($k, CURLOPT_HEADER, 0); curl_setopt($k, CURLOPT_RETURNTRANSFER, 1); curl_setopt($k, CURLOPT_URL, $urlMembers); curl_setopt($k, CURLOPT_FOLLOWLOCATION, true); $t = curl_exec($k); curl_close($k); $r = json_decode($t); $room->members = $r->joined; $rooms[] = $room; } $this->_sendResponse($rooms, $this->_format); } private function curlRiot($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); $results = json_decode($data); return $results; } public function riotAction() { $chatServer='chat.opendesktop.org'; $this->_initResponseHeader(); $config = Zend_Registry::get('config')->settings->client->default; $access_token = $config->riot_access_token; $p_username = $this->getParam('username'); $member_data = $this->getUserData($p_username); $urlProfile = JsonController::chat_userProfileUrl.'@'.$member_data['username'].':'.$chatServer.'?access_token=' . $access_token; //https://chat.opendesktop.org/_matrix/client/r0/profile/@rvs75:chat.opendesktop.org?access_token= $results = $this->curlRiot($urlProfile); $urlPresense = JsonController::chat_userPresense.'@'.$member_data['username'].':'.$chatServer.'/status?access_token=' . $access_token; $status = $this->curlRiot($urlPresense); $resonse=array("user" => $results,"status" => $status); $this->_sendResponse($resonse, $this->_format); } private function curlNextcloud($url) { $config = Zend_Registry::get('config')->settings->server->nextcloud; $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, $config->user_sodo.':'.$config->user_sodo_pw); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('OCS-APIRequest: true')); $data = curl_exec($ch); curl_close($ch); $results = json_decode($data); return $results; } public function plingAction() { $p_username = $this->getParam('username'); $member_data = $this->getUserData($p_username); if(!$member_data) { $this->_sendResponse(null, $this->_format); return; } $helpPrintDate = new Default_View_Helper_PrintDate(); $helperImage = new Default_View_Helper_Image(); $tableProduct = new Default_Model_Project(); $productsRowset = $tableProduct->fetchAllProjectsForMember($member_data['member_id'],5); $products = array(); foreach ($productsRowset as $row) { $products[] = $row; } $parray=array(); foreach ($products as $p) { $tmp= array('project_id'=> $p->project_id , 'image_small'=>$helperImage->Image($p->image_small, array('width' => 200, 'height' => 200)) , 'title' => $p->title ,'laplace_score' =>$p->laplace_score*10 ,'cat_title' =>$p->catTitle ,'updated_at' => $helpPrintDate->printDate(($p->changed_at==null?$p->created_at:$p->changed_at)) ) ; $parray[] = $tmp; } $result = array('user'=>$member_data,'products'=>$parray); $this->_sendResponse($result, $this->_format); } public function nextcloudAction() { $config = Zend_Registry::get('config')->settings->server->nextcloud; $p_username = $this->getParam('username'); $member_data = $this->getUserData($p_username); if(!$member_data) { $this->_sendResponse(null, $this->_format); return; } $url = $config->host."/ocs/v1.php/cloud/users?search=".$member_data['username']."&format=json"; $results = $this->curlNextcloud($url); $status =$results->ocs->meta->status; $usersArray=array(); if($status== 'ok' && sizeof($results->ocs->data->users)>0) { $users = $results->ocs->data->users; foreach ($users as $user) { $urlUser = $config->host."/ocs/v1.php/cloud/users/".$user."?format=json"; $u = $this->curlNextcloud($urlUser); if($u->ocs->meta->status=='ok') { $usersArray[]= $u->ocs->data; } } } $reternUsers = array("users" => $usersArray); $this->_sendResponse($reternUsers, $this->_format); } public function forumAction() { $this->_initResponseHeader(); $url_forum = Zend_Registry::get('config')->settings->client->default->url_forum; $url = $url_forum . '/latest.json'; $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); $results = json_decode($data); $timeago = new Default_View_Helper_PrintDateSince(); foreach ($results->topic_list->topics as &$t) { $strTime = str_replace('T', ' ', substr($t->last_posted_at, 0, 19)); //$t->timeago = $timeago->printDateSince($strTime); $fromFormat = 'Y-m-d H:i:s'; $date = DateTime::createFromFormat($fromFormat, $strTime); // forum/latest.json last_posted_at is 5 hours later as server somehow.. quick workaround $date->sub(new DateInterval('PT4H10M')); $t->timeago = $timeago->printDateSince($date->format('Y-m-d h:s:m')); //$t->timeago = $date->format('Y-m-d H:i:s'); $r = 'Reply'; $counts = $t->posts_count - 1; if ($counts == 0) { $r = 'Replies'; } else if ($counts == 1) { $r = 'Reply'; } else { $r = 'Replies'; } $t->replyMsg = $counts . ' ' . $r; } $this->_sendResponse($results, $this->_format); } protected function getUserData($p_username) { $helperUserRole = new Backend_View_Helper_UserRole(); $userRoleName = $helperUserRole->userRole(); $isAdmin = false; if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { $isAdmin = true; } $member_data = null; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $modelSubSystem = new Default_Model_Ocs_Forum(); if($isAdmin) { if($p_username && $p_username!='null') { $modelMember = new Default_Model_Member(); $memberId = $modelMember->fetchActiveUserByUsername($p_username); if($memberId) { $member = $modelMember->fetchMemberData($memberId); $member_data = array('username'=>$p_username,'member_id' =>$memberId, 'mail'=>$member->mail,'avatar'=>$member->profile_image_url); } }else{ $authMember = $auth->getStorage()->read(); $member_data = array('username'=>$authMember->username,'member_id' =>$authMember->member_id , 'mail'=>$authMember->mail,'avatar'=>$authMember->profile_image_url); } }else { $authMember = $auth->getStorage()->read(); $member_data = array('username'=>$authMember->username,'member_id' =>$authMember->member_id , 'mail'=>$authMember->mail,'avatar'=>$authMember->profile_image_url); } } return $member_data; } public function forumpostsAction() { $this->_initResponseHeader(); $p_username = $this->getParam('username'); $results=null; $member_data = $this->getUserData($p_username); if($member_data) { $modelSubSystem = new Default_Model_Ocs_Forum(); $user = $modelSubSystem->getUserByUsername($member_data['username']); if($user) { $results['user'] = $user; } $posts = $modelSubSystem->getPostsFromUser($member_data); if($posts) { $results['posts'] = $posts['posts']; } } $this->_sendResponse($results, $this->_format); } public function gitlabAction() { $this->_initResponseHeader(); $p_username = $this->getParam('username'); $results=null; $member_data = $this->getUserData($p_username); if ($member_data) { $modelSubSystem = new Default_Model_Ocs_Gitlab(); $user = $modelSubSystem->getUserWithName($member_data['username']); //$this->log->info(">>>>>>>results>>>>".json_encode($user)); if($user) { $results['user'] = $user; $posts = $modelSubSystem->getUserProjects($user['id']); if($posts) { $results['projects'] = $posts; } } //$this->log->info(">>>>>>>results>>>>".json_encode($results)); } $this->_sendResponse($results, $this->_format); } public function gitlabnewprojectsAction() { $this->_initResponseHeader(); $url_git = Zend_Registry::get('config')->settings->server->opencode->host; $url = $url_git . '/api/v4/projects?order_by=created_at&sort=desc&visibility=public&page=1&per_page=5'; $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); $results = json_decode($data); $timeago = new Default_View_Helper_PrintDateSince(); foreach ($results as &$t) { $tmp = str_replace('T', ' ', substr($t->created_at, 0, 19)); $t->timeago = $timeago->printDateSince($tmp); } $this->_sendResponse($results, $this->_format); } public function gitlabfetchuserAction() { $this->_initResponseHeader(); $url_git = Zend_Registry::get('config')->settings->server->opencode->host; $url = $url_git . '/api/v4/users?username=' . $this->getParam('username'); $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); $results = json_decode($data); $this->_sendResponse($results, $this->_format); } public function socialtimelineAction() { $this->_initResponseHeader(); - - $model = new Default_Model_Ocs_Mastodon(); - /*$timelines = $model->getTimelines(); - - $helpPrintDate = new Default_View_Helper_PrintDateSince(); - foreach ($timelines as &$m) { - if($m['created_at']) - { - $m['created_at'] = $helpPrintDate->printDateSince(str_replace('T', ' ', substr($m['created_at'], 0, 19))); - } - } + /** @var Zend_Cache_Backend_Memcached $cache */ + $cache = Zend_Registry::get('cache'); + $cacheName = __FUNCTION__; + if (false === ($timelines = $cache->load($cacheName))) { + + $model = new Default_Model_Ocs_Mastodon(); + $timelines = $model->getTimelines(); + if($timelines) + { + $helpPrintDate = new Default_View_Helper_PrintDateSince(); + foreach ($timelines as &$m) { + if (array_key_exists('created_at', $m) && $m['created_at']) + { + $m['created_at'] = $helpPrintDate->printDateSince(str_replace('T', ' ', substr($m['created_at'], 0, 19))); + } + } + } + else + { + $timelines=array(); + } + $cache->save($timelines, $cacheName, array(), 60 * 60); + } $this->_sendResponse($timelines, $this->_format); - */ - $this->_sendResponse(array(), $this->_format); } public function socialuserstatusesAction() { $this->_initResponseHeader(); $p_username = $this->getParam('username'); $member_data = $this->getUserData($p_username); $result=array(); $model = new Default_Model_Ocs_Mastodon(); $user = $model->getUserByUsername($member_data['username']); if(sizeof($user)>0) { $user=$user[0]; }else{ $user=null; } $result['user'] = $user; $statuses=null; if($user && $user['id']) { $statuses = $model->getUserStatuses($user['id']); } $result['statuses'] = $statuses; $this->_sendResponse($result, $this->_format); } public function newsAction() { $this->_initResponseHeader(); /** @var Zend_Cache_Backend_Memcached $cache */ $cache = Zend_Registry::get('cache'); $cacheName = __FUNCTION__; if (false === ($news = $cache->load($cacheName))) { $url = 'https://blog.opendesktop.org/?json=1'; $ch = curl_init(); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $data = curl_exec($ch); curl_close($ch); $news = json_decode($data); $news->posts = array_slice($news->posts, 0, 3); $cache->save($news, $cacheName, array(), 60 * 60); } $this->_sendResponse($news, $this->_format); } public function cattagsAction() { $this->_initResponseHeader(); $catid = $this->getParam('id'); $results = array(); if ($catid) { $m = new Default_Model_Tags(); $results = $m->getTagsPerCategory($catid); } $this->_sendResponse($results, $this->_format); } public function searchAction() { $this->_initResponseHeader(); $projectSearchText = $this->getParam('p'); if(is_array($projectSearchText)) { $projectSearchText = array_pop(array_values($projectSearchText)); } $store = null; if($this->hasParam('s')){ $store = $this->getParam('s'); } if($store=='Opendesktop') { $store = null; } // $storemodel = new Default_Model_DbTable_ConfigStore(); // $s = $storemodel->fetchDomainObjectsByName($store); // $currentStoreConfig = new Default_Model_ConfigStore($s['host']); // var_dump($currentStoreConfig); // die; $param = array('q' => $projectSearchText,'store'=>$store,'page' => 1 , 'count' => 10); $viewHelperImage = new Default_View_Helper_Image(); $modelSearch = new Default_Model_Solr(); try { $result = $modelSearch->search($param); $products = $result['hits']; $ps=array(); foreach ($products as $p) { $img = $viewHelperImage->Image($p->image_small, array( 'width' => 50, 'height' => 50 )); $ps[] =array('type'=>'project' ,'title' =>$p->title ,'project_id' =>$p->project_id ,'member_id'=>$p->member_id ,'username' => $p->username ,'laplace_score' =>$p->laplace_score ,'score' =>$p->score ,'cat_title' =>$p->cat_title ,'image_small' =>$img); } $model = new Default_Model_Member(); $results = $model->findActiveMemberByName($projectSearchText); $helperImage = new Default_View_Helper_Image(); $ps_user=array(); foreach ($results as $value) { $avatar = $helperImage->image($value['profile_image_url'], array('width' => 100, 'height' => 100, 'crop' => 2)); $ps_user[] =array('type'=>'user' ,'username'=>$value['username'] ,'member_id'=>$value['member_id'] ,'image_small' =>$avatar ); } $searchresult=array(); $searchresult[] = array('title' =>'Products','values' =>$ps); $searchresult[] = array('title' =>'Users','values' =>$ps_user); $this->_sendResponse($searchresult, $this->_format); } catch (Exception $e) { $this->_sendResponse(null, $this->_format); } } public function searchpAction() { $this->_initResponseHeader(); $projectSearchText = $this->getParam('p'); $projectSearchCategory = $this->getParam('c'); $store = null; if($this->hasParam('s')){ $store = $this->getParam('s'); } //$filterCat = 'project_category_id:('.$projectSearchCategory.')'; //$param = array('q' => $projectSearchText,'store'=>$store,'page' => 1 // , 'count' => 10,'fq' => array($filterCat)); $param = array('q' => $projectSearchText,'store'=>$store,'page' => 1, 'count' => 10); $viewHelperImage = new Default_View_Helper_Image(); $modelSearch = new Default_Model_Solr(); try { $result = $modelSearch->search($param); $products = $result['hits']; $ps=array(); foreach ($products as $p) { $img = $viewHelperImage->Image($p->image_small, array( 'width' => 50, 'height' => 50 )); $ps[] =array('type'=>'project' ,'title' =>$p->title ,'project_id' =>$p->project_id ,'member_id'=>$p->member_id ,'username' => $p->username ,'laplace_score' =>$p->laplace_score ,'score' =>$p->score ,'cat_title' =>$p->cat_title ,'image_small' =>$img); } $this->_sendResponse($ps, $this->_format); } catch (Exception $e) { $this->_sendResponse(null, $this->_format); } } public function anonymousdlAction() { $this->_initResponseHeader(); $identity = Zend_Auth::getInstance()->getStorage()->read(); $config = Zend_Registry::get('config'); $cookieName = $config->settings->session->auth->anonymous; $storedInCookie = isset($_COOKIE[$cookieName]) ? $_COOKIE[$cookieName] : NULL; if ($storedInCookie) { $model = new Default_Model_DbTable_MemberDownloadHistory(); if ($identity && $identity->member_id) { $dlsection = $model->getAnonymousDLSection($storedInCookie, $identity->member_id); } else { $dlsection = $model->getAnonymousDLSection($storedInCookie); } $dls = 0; foreach ($dlsection as $value) { $dls = $dls + $value['dls']; } //$dls = $model->countDownloadsAnonymous($storedInCookie); $response = array( 'status' => 'ok', 'section' => $dlsection, 'dls' => $dls ); $this->_sendResponse($response, $this->_format); return; } $response = array( 'status' => 'ok', 'dls' => 0 ); $this->_sendResponse($response, $this->_format); } public function fetchrandomsupporterAction() { $this->_initResponseHeader(); $section_id = $this->getParam('s'); $info = new Default_Model_Info(); $s = $info->getRandomSupporterForSection($section_id); $response = array( 'status' => 'ok', 'supporter' => $s ); $this->_sendResponse($response, $this->_format); } } diff --git a/httpdocs/theme/flatui/js/script.min.js b/httpdocs/theme/flatui/js/script.min.js index d476cfd0b..272168dcd 100644 --- a/httpdocs/theme/flatui/js/script.min.js +++ b/httpdocs/theme/flatui/js/script.min.js @@ -1 +1 @@ -var prefix="ocs_",OcsStorage={set:function(t,e){localStorage[t]=JSON.stringify(e)},get:function(t){return localStorage[t]?JSON.parse(localStorage[t]):null}},OcsStats={props:{},a:0,readIp:function(t,e){$.getJSON(t,function(t){OcsStats.props.ipv4=t.ip,OcsStats.saveProps(1)}).fail(function(){OcsStats.saveProps(1)}),$.getJSON(e,function(t){OcsStats.props.ipv6=t.ip,OcsStats.saveProps(2)}).fail(function(){OcsStats.saveProps(2)})},genId:function(){Fingerprint2.get({},function(t){var e=t.map(function(t){return t.value});OcsStats.props.fp=Fingerprint2.x64hash128(e.join(""),31),OcsStats.saveProps(4)})},saveProps:function(t){OcsStorage.set("ocs",OcsStats.props),OcsStats.a+=t,7==OcsStats.a&&OcsStats.postProps()},postProps:function(){$.post("/l/fp",OcsStats.props)},readStats:function(t,e){window.requestIdleCallback?requestIdleCallback(function(){OcsStats.genId(),OcsStats.readIp(t,e)}):setTimeout(function(){OcsStats.genId(),OcsStats.readIp(t,e)},500)}},newProductPage={setup:function(){function t(){var t=$("#donations-panel").find("#comments").height();t>$("#donations-panel").find("#supporters").height()&&$("#donations-panel").find("#supporters").height(t)}$(document).ready(function(){var e;e=$("#pling-it-box").height(),$(".scrollable-content").height(e),$(".scrollable-content").jScrollPane({mouseWheelSpeed:30}),t(),$('a[data-toggle="tab"]').on("shown.bs.tab",function(e){t()})})}},ImagePreview={hasError:!1,setup:function(){this.initProductPicture(),this.initTitlePicture(),this.initProfilePicture(),this.initProfilePictureBackground()},previewImage:function(t,e){if(t.files&&t.files[0]){var a=new FileReader,i=new Image,n=t.files[0];a.readAsDataURL(t.files[0]),a.onload=function(a){var o=$("#"+e);i.src=a.target.result,i.onload=function(){var e=this.width,i=this.height,r=n.type,s=(n.name,~~(n.size/1024));ImagePreview.hasError=!1,o.parent().parent().find("div.bg-danger").remove(),(e>2e3||e<20||i>2e3||i<20)&&(o.parent().parent().append('
Wrong image dimensions
'),$($(t).closest("form")[0]).trigger("reset"),ImagePreview.hasError=!0),s>2e3&&(o.parent().parent().append('
File too large
'),$($(t).closest("form")[0]).trigger("reset"),ImagePreview.hasError=!0);/(jpg|jpeg|png|gif)$/i.exec(r)||(o.parent().parent().append('
Invalid file type: '+n.type+"
"),$($(t).closest("form")[0]).trigger("reset"),ImagePreview.hasError=!0),0==ImagePreview.hasError&&(ImagePreview.hasError=!1,o.attr("src",a.target.result),o.show())},i.onerror=function(){o.parent().parent().find("div.bg-danger").remove(),o.parent().parent().append('
Invalid file type: '+n.type+"
")},"product-picture-preview"==e?$("button#add-product-picture").text("CHANGE LOGO"):"title-picture-preview"==e?$("button#add-title-picture").text("CHANGE BANNER"):"profile-picture-preview"==e?($("button#add-profile-picture").text("CHANGE PICTURE"),$("input#profile_img_src").val("local")):"profile-picture-bg-preview"==e&&$("button#add-profile-picture-background").text("CHANGE PICTURE")}}},previewImageMember:function(t,e){if(t.files&&t.files[0]){var a=new FileReader,i=new Image;t.files[0];a.readAsDataURL(t.files[0]),a.onload=function(t){var a=$("#"+e);i.src=t.target.result,i.onload=function(){ImagePreview.hasError=!1,a.parent().find(".image-error").remove(),0==ImagePreview.hasError&&(a.attr("src",t.target.result),a.show())},i.onerror=function(){a.parent().append('
Invalid file type
')},"profile-picture-background-preview"==e&&$("button#add-profile-picture-background").text("CHANGE PICTURE")}}},readImage:function(t){var e=new FileReader,a=new Image;e.readAsDataURL(t),e.onload=function(e){a.src=e.target.result,a.onload=function(){var e=this.width,a=this.height,i=t.type,n=t.name,o=~~(t.size/1024)+"KB";$("#uploadPreview").append(' '+e+"x"+a+" "+o+" "+i+" "+n+"
")},a.onerror=function(){alert("Invalid file type: "+t.type)}}},initProductPicture:function(){if(0!=$("#image_small").length&&0!=$("#image_small").attr("value").length){var t=$("#image_small").data("target");$(t).attr("src","https://cn.opendesktop.org/cache/200x200-2/img/"+$("#image_small").attr("value")),$(t).show(),$("button#add-product-picture").text("CHANGE LOGO")}},initTitlePicture:function(){if(0!=$("#image_big").length&&0!=$("#image_big").attr("value").length){var t=$("#image_big").data("target");$(t).attr("src","https://cn.opendesktop.org/cache/200x200-2/img/"+$("#image_big").attr("value")),$(t).show(),$("button#add-title-picture").text("CHANGE BANNER")}},initProfilePicture:function(){if(0!=$("#profile_image_url").length&&0!=$("#profile_image_url").attr("value").length){var t=$("#profile_image_url").data("target");$(t).attr("src",$("#profile_image_url").attr("value")),$("#profile-picture").attr("src",$("#profile_image_url").attr("value")),$(t).show(),$("button#add-profile-picture").text("CHANGE PICTURE")}},initProfilePictureBackground:function(){if(0!=$("#profile_image_url_bg").length&&0!=$("#profile_image_url_bg").attr("value").length){var t=$("#profile_image_url_bg").data("target");$(t).attr("src",$("#profile_image_url_bg").attr("value")),$("#profile-picture-background-preview").attr("src",$("#profile_image_url_bg").attr("value")),$(t).show(),$("button#add-profile-picture-background").text("CHANGE PICTURE")}}},MenuHover={setup:function(){$("body").on("click","a#login-dropdown",function(t){t.stopPropagation(),$(".header-login-container").toggleClass("active")}).on("click",".header-login-container",function(t){t.stopPropagation()}).on("click","a.menu-trigger",function(t){t.stopPropagation();var e="."+$(this).attr("rel");$(e).toggleClass("active")}).on("mouseup",function(t){var e=$("ul.profile-menu");$("li.profile-menu-container a.menu-trigger").is(t.target)||e.is(t.target)||0!==e.has(t.target).length||e.removeClass("active")}).on("mouseup",function(t){container=$("div.header-login-container"),trigger=$("a#login-dropdown"),trigger.is(t.target)||container.is(t.target)||0!==container.has(t.target).length||container.removeClass("active")}).click(function(){$(".header-login-container.active").removeClass("active"),$(".profile-menu.active").removeClass("active")})}},ButtonCode={setup:function(){$("#button-code-heading").click(function(){$(this).hasClass("button-code-active")?($(this).removeClass("button-code-active"),$(this).parent().find(".button-code").slideUp("fast"),$(this).parent().find(".button-code").css("border-bottom","none"),$(this).find(".icon-expand-code").css("background-image","url(img/icon-expand.png)")):($(this).addClass("button-code-active"),$(this).parent().find(".button-code").css("border-bottom","1px solid #bdc3c7"),$(this).parent().find(".button-code").slideDown("fast"),$(this).find(".icon-expand-code").css("background-image","url(img/icon-contract.png)"))})},setupClipboardCopy:function(t){$(t).on("mouseover",function(){$(this).off("mouseover"),$(this).find("[data-clipboard-target]").each(function(){var t=$($(this).attr("data-clipboard-target"));$(this).zclip({path:"/theme/flatui/js/lib/ZeroClipboard.swf",copy:$.trim($(t).text())})})})}},ProductPage={setup:function(){$(".dropdown-toggle").dropdown(),$(".scroll-pane").jScrollPane({mouseWheelSpeed:30,animateScroll:!0}),$(".love-it").on("click",function(){this_img_src=$(this).find("img").attr("src"),$(this).hasClass("no-login")||"/theme/flatui/img/icon-like-color.png"==this_img_src||$(this).prev(".share-it").trigger("click")}),$(".payment-options").find(".options").find("span.option").on("click",function(){var t=$(this).attr("title"),e=$(".payment-options").find('input[type="number"]');e.attr("value",t).val(t),e.focus(),$(".options").find(".selected").removeClass("selected"),$(this).addClass("selected")})},setupPlingButton:function(){$("#pling-amount").on("focus",function(){$("#pling-amount").popover("destroy")}),$("#pling-start").on("click",function(t){return validateElement=$("#pling-amount"),validateValue=validateElement.val(),""==validateValue||isNaN(parseFloat(validateValue))||!isFinite(validateValue)?(t.preventDefault(),$("#pling-amount").popover({placement:"bottom",html:"true",content:'
Donation must be a numeric value.
'}).popover("show"),!1):(minValue=validateElement.attr("min"),parseFloat(validateValue)×
Donation must be equal or greater than '+minValue+".
"}).popover("show"),!1):(maxValue=validateElement.attr("max"),parseFloat(validateValue)>parseFloat(maxValue)?(t.preventDefault(),$("#pling-amount").popover({placement:"bottom",html:"true",content:'
Donation must be smaller or equal than '+maxValue+".
"}).popover("show"),!1):void 0))})}},SlideShowRender={setup:function(){$("#slideshow-container").find("img:first").addClass("active"),$("#slideshow-container").find("#navigation").find("a:first").addClass("active")}},ProductSlideShow={setup:function(){$("#slideshow-container").find("#arrows").find("a").on("click",function(t){var e=$(this).attr("id"),a=$("#slideshow-container #slides"),i=a.find("img.active"),n=i.attr("rel"),o=$("#slideshow-container").find("#navigation").find("a.active");if("prev"==e){var r=parseInt(n)-parseInt(1),s=$("#slideshow-container").find('img[rel="'+r+'"]'),l=$("#slideshow-container").find("#navigation").find('a[rel="'+r+'"]');1==!s.size()&&(s=a.find("img:last"),l=$("#slideshow-container").find("#navigation").find("a:last"))}else if("next"==e){var d=parseInt(n)+parseInt(1);s=$("#slideshow-container").find('img[rel="'+d+'"]'),l=$("#slideshow-container").find("#navigation").find('a[rel="'+d+'"]'),1==!s.size()&&(s=a.find("img:first"),l=$("#slideshow-container").find("#navigation").find("a:first"))}i.removeClass("active"),o.removeClass("active"),s.addClass("active"),l.addClass("active")}),$("#slideshow-container").find("#navigation").find("a").on("click",function(){var t=$(this).attr("rel"),e=$("#slideshow-container").find('img[rel="'+t+'"]');$("#slideshow-container").find("img.active").removeClass("active"),e.addClass("active"),$("#slideshow-container").find("#navigation").find("a.active").removeClass("active"),$(this).addClass("active")})}},SlideShow={setup:function(){slideShowInterval=setTimeout(function(){var t=$("#slideshow-container").find("img.active"),e=t.attr("rel"),a=parseInt(e)+parseInt(1),i=$("#slideshow-container").find('img[rel="'+a+'"]'),n=$("#slideshow-container").find("#navigation").find("a.active");t.removeClass("active"),n.removeClass("active"),1==i.size()?(i.addClass("active"),$("#slideshow-container").find("#navigation").find('a[rel="'+a+'"]').addClass("active")):($("#slideshow-container").find("img:first").addClass("active"),$("#slideshow-container").find("#navigation").find("a:first").addClass("active"))},4e3)}},Popuppanel={setup:function(){$("body").on("click","a.popuppanel",function(t){if("_blank"===$(this).attr("target"))console.log("dont prevent default");else{t.preventDefault();var e=$(this).attr("href");$.fancybox({hideOnContentClick:!0,autoScale:!0,cyclic:"true",transitionIn:"elastic",transitionOut:"elastic",type:"iframe",scrolling:"auto",helpers:{overlay:{locked:!1}},autoSize:!0,href:e,type:"ajax"})}})}},PlingsRedirect={setup:function(){window.location.hash?($link=$(window.location.hash),$link.trigger("click")):document.location.hash&&($link=$(document.location.hash),$link.trigger("click"))}},ShowPopups={setup:function(){window.location.hash&&(alert("Hash"),$('a[href="'+document.location.hash+'"]').trigger("click")),document.location.hash&&(alert("Hash"),$('a[href="'+document.location.hash+'"]').trigger("click"))}};$("body").on("mouseenter",".supporter-thumbnail",function(){$(this).popover("show")}),$("body").on("mouseleave",".supporter-thumbnail",function(){$(this).popover("hide")});var Partials={setup:function(){$("body").on("click","a.partial",function(t){t.preventDefault();var e=this.href,a=$(this).attr("data-target"),i=$(this).data("toggle"),n=$(this).attr("data-fragment");return $(a).load(e+" "+n,function(t,e,n){if("error"==e)if(401==n.status){if(t){var o=jQuery.parseJSON(t).login_url;window.location=o||"/login"}}else $(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.");i&&$(i).modal("show")}),!1})}},Opendownloadfile={setup:function(){$("body").on("click","a.opendownloadfile",function(t){t.preventDefault();var e=$(this).attr("data-file_id"),a=$(this).attr("data-file_type"),i=$(this).attr("data-file_name"),n=$(this).attr("data-file_size"),o=$(this).attr("data-project_id"),r=$(this).attr("data-link_type"),s=$(this).attr("data-is-external-link"),l=$(this).attr("data-has_torrent"),d=null,c="450";return"true"==s&&(d=$(this).attr("data-external_link"),c="500"),$.fancybox({hideOnContentClick:!0,autoScale:!1,scrolling:"no",cyclic:"true",transitionIn:"elastic",transitionOut:"elastic",type:"iframe",width:"600",height:c,iframe:{scrolling:"no"},fitToView:!1,autoSize:!1,id:"opendownloadfilepopup",helpers:{overlay:{locked:!1}},href:"/dl?file_id="+e+"&file_type="+a+"&file_name="+i+"&file_size="+n+"&has_torrent="+l+"&project_id="+o+"&link_type="+r+"&is_external="+s+"&external_link="+d}),!1})}},PartialsButton={setup:function(){$("body").on("click","Button.partialbutton",function(t){t.preventDefault();var e=$(this).attr("data-href"),a=$(this).attr("data-target"),i=$(this).data("toggle"),n=$(this).attr("data-fragment"),o=$('');return $(a).append(o),$(a).load(e+" "+n,function(t,e,n){if("error"==e)if(401==n.status){if(t){var o=jQuery.parseJSON(t).login_url;window.location=o||"/login"}}else $(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.");i&&$(i).modal("show")}),!1})}},PartialsButtonHeartDetail={setup:function(){$("body").on("click",".partialbuttonfollowproject",function(t){t.preventDefault();var e=$(this).attr("data-href"),a=$(this).attr("data-target"),i=$(this).attr("data-auth");if($(this).data("toggle"),$(this).attr("data-fragment"),i){if($("#like-product-modal").find("#loginuser").val()==$("#like-product-modal").find("#productcreator").val())return $("#like-product-modal").find("#votelabel").text("Project owner not allowed"),$("#like-product-modal").find(".modal-body").empty(),void $("#like-product-modal").modal("show");var n=$('');return $(a).prepend(n),$.ajax({url:e,cache:!1}).done(function(t){$(a).find(".spinning").remove(),"error"==t.status?$(a).html(t.msg):"delete"==t.action?($(a).find(".plingtext").html(t.cnt),$(a).find(".plingtext").addClass("heartnumberpurple"),$(a).find(".plingheart").removeClass("heartproject").addClass("heartgrey"),$(a).find(".plingheart").removeClass("fa-heart").addClass("fa-heart-o")):($(a).find(".plingtext").html(t.cnt),$(a).find(".plingtext").removeClass("heartnumberpurple"),$(a).find(".plingheart").removeClass("heartgrey").addClass("heartproject"),$(a).find(".plingheart").removeClass("fa-heart-o").addClass("fa-heart"))}),!1}$("#like-product-modal").modal("show")})}},PartialsButtonPlingProject={setup:function(){$("#plingbtn").hover(function(){$(this).attr("src","/images/system/pling-btn-hover.png")},function(){$(this).attr("src",$(this).attr("data-src"))}),$("body").on("click",".partialbuttonplingproject",function(t){t.preventDefault();var e=$(this).attr("data-href"),a=$(this).attr("data-target"),i=$(this).attr("data-auth"),n=$(this).attr("data-issupporter");if($(this).data("toggle"),$(this).attr("data-fragment"),i)return $("#like-product-modal").find("#loginuser").val()==$("#like-product-modal").find("#productcreator").val()?($("#like-product-modal").find("#votelabel").text("Project owner not allowed"),$("#like-product-modal").find(".modal-body").empty(),void $("#like-product-modal").modal("show")):n?($(a).find(".plingnum").html(''),$.ajax({url:e,cache:!1}).done(function(t){"error"==t.status?$(a).html(t.msg):"delete"==t.action?(0==t.cnt?$(a).find(".plingnum").html("Pling me"):$(a).find(".plingnum").html(t.cnt+" Plings"),$(a).find("#plingbtn").attr("src","/images/system/pling-btn-normal.png"),$(a).find("#plingbtn").attr("data-src","/images/system/pling-btn-normal.png")):($(a).find(".plingnum").html(t.cnt+" Plings"),$(a).find("#plingbtn").attr("src","/images/system/pling-btn-active.png"),$(a).find("#plingbtn").attr("data-src","/images/system/pling-btn-active.png"))}),!1):($("#like-product-modal").find("#votelabel").html('
To pling a product and help the artist please consider becoming a supporter. Thanks!

Become a supporter
'),void $("#like-product-modal").modal("show"));$("#like-product-modal").modal("show")})}},PartialsReview={setup:function(){$("body").on("click","a.partialreview",function(t){if(t.preventDefault(),this.href,$(this).attr("data-target"),$(this).data("toggle"),$(this).attr("data-fragment"),$("#review-product-modal").find("#loginuser").val()==$("#review-product-modal").find("#productcreator").val())return $("#review-product-modal").find("#votelabel").text("Project owner not allowed"),$("#review-product-modal").find(".modal-body").empty(),void $("#review-product-modal").modal("show");var e=$("#review-product-modal").find("#userrate").val();return $(this).hasClass("voteup")?1==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment:'),$("#review-product-modal").find("#commenttext").val($("#review-product-modal").find("#otxt").val()),$("#review-product-modal").find(":submit").text("Remove Rating")):($("#review-product-modal").find("input#voteup").val(1),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 1 char):'),$("#review-product-modal").find("#commenttext").val("+"),$("#review-product-modal").find(":submit").text("Rate Now"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").css("display","block").removeAttr("disabled")):0==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment: '),$("#review-product-modal").find("#commenttext").val($("#review-product-modal").find("#otxt").val()),$("#review-product-modal").find(":submit").text("Remove Rating")):($("#review-product-modal").find("input#voteup").val(2),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 5 char) Please explain the reason for downvote to help the creator to make it better '),$("#review-product-modal").find("#commenttext").val("-"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").removeAttr("disabled").css("display","block"),$("#review-product-modal").find(":submit").text("Rate Now")),$("#review-product-modal").modal("show"),$("#review-product-modal").hasClass("noid")&&setTimeout(function(){$("#review-product-modal").modal("hide")},2e3),!1})}},PartialsReviewDownloadHistory={setup:function(){$("body").on("click","button.partialReviewDownloadHistory",function(t){t.preventDefault();var e=$(this).attr("data-userrate");return $("#review-product-modal").find("#commenttext").val($(this).attr("data-comment")),$("#review-product-modal").find("#form_p").val($(this).attr("data-project")),$(this).hasClass("voteup")?1==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment:'),$("#review-product-modal").find(":submit").attr("disabled","disabled").css("display","none"),$("#review-product-modal").find("#commenttext").attr("disabled","disabled")):($("#review-product-modal").find("input#voteup").val(1),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 1 char):'),$("#review-product-modal").find("#commenttext").val("+"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").css("display","block").removeAttr("disabled")):0==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment: '),$("#review-product-modal").find("#commenttext").attr("disabled","disabled"),$("#review-product-modal").find(":submit").attr("disabled","disabled").css("display","none")):($("#review-product-modal").find("input#voteup").val(2),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 5 chars): '),$("#review-product-modal").find("#commenttext").val("-"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").removeAttr("disabled").css("display","block")),$("#review-product-modal").modal("show"),$("#review-product-modal").hasClass("noid")&&setTimeout(function(){$("#review-product-modal").modal("hide")},2e3),!1})}},CreateScoreRatingPopup={setup:function(){var t,e=0;$("select.rating-select").focus(function(){t=$(this),e=$(this).val()}).change(function(){var t=$(this).find("option:selected"),e=t.val(),a=t.text(),i=($(this).attr("data-userrate"),$(this).attr("data-comment"),$(this).attr("data-creator")),n=$("#score-product-modal").find("#loginuser").val();if(n){if(n==i)return $("#score-product-modal").find("#votelabel").text("Project owner not allowed"),$("#score-product-modal").find(".modal-body").empty(),$("#score-product-modal").find("#modal-btn-onsubmit").remove(),void $("#score-product-modal").modal("show");-1==e?$("#score-product-modal").find("#votelabel").empty().append("Remove Rating "):e<=5?($("#score-product-modal").find("#votelabel").empty().append('Add a review to your rating "'+a+'" (min. 5 chars) Please explain the reason for downvote to help the creator to make it better '),$("#score-product-modal").find("#voteup").val(2)):($("#score-product-modal").find("#votelabel").empty().append('Add a review to your rating "'+a+'" (min. 1 char):'),$("#score-product-modal").find("#voteup").val(1)),$("#score-product-modal").find("#form_p").val($(this).attr("data-project")),$("#score-product-modal").find(":submit").css("display","block").removeAttr("disabled"),$("#score-product-modal").find("#commenttext").removeAttr("disabled"),e>=1&&e<=3?$("#score-product-modal").find("#commenttext").val(""):$("#score-product-modal").find("#commenttext").val(a),$("#score-product-modal").find("#userscorevalue").val(e),"-1"==e?$("#score-product-modal").find(":submit").text("Remove Rating"):$("#score-product-modal").find(":submit").text("Rate Now"),$("#score-product-modal").modal("show")}else $("#score-product-modal").modal("show")}),$("#modal-btn-cancel").on("click",function(){$(t).find("option[value="+e+"]").prop("selected",!0),$("#score-product-modal").modal("hide")});var a=!1;$("#modal-btn-onsubmit").on("click",function(){a=!0}),$("#score-product-modal").on("hidden.bs.modal",function(){a||$(t).find("option[value="+e+"]").prop("selected",!0)})}},PartialForms={setup:function(){$("body").on("submit","form.partial",function(t){t.preventDefault(),t.stopImmediatePropagation(),$(this).find(":submit").attr("disabled","disabled"),$(this).find(":submit").css("white-space","normal");var e=$('');$(this).find(":submit").append(e);var a=$(this).attr("data-target"),i=$(this).attr("data-trigger");return console.log(this),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(){return $(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
"),!1},success:function(t){return $(a).empty().html(t),$(a).find(i).trigger("click"),!1}}),!1})}},PartialJsonClone={setup:function(){$("body").on("submit","form.partialjsonclone",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=($(this).attr("data-trigger"),$(this).attr("data-projectid"));return jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t,e){$("form#product-report-clone").find("#clonePId").val(""),$("form#product-report-clone").find("#report-text").val(""),$("#report-product-clone-"+a).modal("hide");var i=$("#generic-dialog");i.find(".modal-header-text").empty(),i.find(".modal-body").empty().append(t.message),setTimeout(function(){i.modal("show")},900)}}),!1})}},PartialJson={setup:function(){$("body").on("submit","form.partialjson",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=$(this).attr("data-trigger");return jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t,i){t.redirect?window.location=t.redirect:(e&&$(e).empty().html(t.message),a&&$(e).find(a).trigger("click"))}}),!1})}},PartialJsonFraud={setup:function(){$("body").on("submit","form.partialjsonfraud",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=$(this).attr("data-trigger");return $("form.partialjsonfraud").find("#report-text").val().length<5?($("form.partialjsonfraud").find("p.warning").remove(),$("form.partialjsonfraud").find("#report-text").parent().append('

at least 5 chars

'),!1):(jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t,i){t.redirect?window.location=t.redirect:(e&&$(e).empty().html(t.message),a&&$(e).find(a).trigger("click"))}}),!1)})}},PartialPayPal={setup:function(){this.initPayPalForm(),this.initPayPalFee()},initPayPalForm:function(){$("body").on("submit","form.partialpaypal",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=$(this).attr("data-trigger");return jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(t,e,a){$("#modal-dialog").modal("hide");var i=$('');i.html($(t.responseText).filter(".page-container").children()),i.append(''),setTimeout(function(){i.modal("show")},900)},success:function(t){$(e).empty().html(t),$(e).find(a).trigger("click"),$("#modal-dialog").modal("hide")}}),!1})},initPayPalFee:function(){$("body").on("change","#amount_plings",function(t){PartialPayPal.changeFee()})},changeFee:function(){var t=document.getElementById("amount_plings"),e=parseFloat(t.value),a=this.round(.05*e,2),i=.03*(a+e+.3)+.3,n=e+a+(i=this.round(i,2));document.getElementById("pling_fee").value=this.round(a,2).toFixed(2),document.getElementById("paypal_fee").value=this.round(i,2).toFixed(2),document.getElementById("sum").value=this.round(n,2)},round:function(t,e){var a=Math.pow(10,e);return Math.round(t*a)/a}},PartialCommentReviewForm={setup:function(){this.initForm()},initForm:function(){$("body").on("submit","form.product-add-comment-review",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$.trim($("#commenttext").val());if(2==$("#voteup").val()&&e.length<5)0==$("#review-product-modal").find("#votelabel").find(".warning").length&&$("#review-product-modal").find("#votelabel").append("
Please give a comment, thanks!");else{if(!(e.length<1)){$(this).find(":submit").attr("disabled","disabled"),$(this).find(":submit").css("white-space","normal");var a=$('');return $(this).find(":submit").append(a),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(t,e,a){$("#review-product-modal").modal("hide");var i=$("#generic-dialog");i.modal("hide"),i.find(".modal-header-text").empty().append("Please try later."),i.find(".modal-body").empty().append("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
"),setTimeout(function(){i.modal("show")},900)},success:function(t){$("#review-product-modal").modal("hide"),location.reload()}}),!1}0==$("#review-product-modal").find("#votelabel").find(".warning").length&&$("#review-product-modal").find("#votelabel").append("
Please give a comment, thanks!")}})}},PartialCommentReviewFormNew={setup:function(){this.initForm()},initForm:function(){$("body").on("submit","form.product-add-comment-review-new",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$.trim($("#score-product-modal").find("#commenttext").val());if(2==$("#score-product-modal").find("#voteup").val()&&e.length<5)0==$("#score-product-modal").find("#votelabel").find(".warning").length&&$("#score-product-modal").find("#votelabel").append("
Please give a comment, thanks!");else{if(!(e.length<1)){$(this).find(":submit").attr("disabled","disabled"),$(this).find(":submit").css("white-space","normal");var a=$('');return $(this).find(":submit").append(a),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(t,e,a){$("#score-product-modal").modal("hide");var i=$("#generic-dialog");i.modal("hide"),i.find(".modal-header-text").empty().append("Please try later."),i.find(".modal-body").empty().append("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
"),setTimeout(function(){i.modal("show")},900)},success:function(t){$("#score-product-modal").modal("hide"),location.reload()}}),!1}0==$("#score-product-modal").find("#votelabel").find(".warning").length&&$("#score-product-modal").find("#votelabel").append("
Please give a comment, thanks!")}})}},PartialFormsAjax={setup:function(){var t=$("form.partialajax"),e=t.attr("data-target"),a=t.attr("data-trigger");$(t).find(":submit").on("click",function(e){e.preventDefault(),$(t).find(":submit").attr("disabled","disabled"),$(t).find(":submit").css("white-space","normal");var a=$('');$(t).find(":submit").append(a),$(t).submit()}),t.ajaxForm({error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t){$(e).empty().html(t),$(e).find(a).trigger("click")}})}},AjaxFormWithProgress={setup:function(t){var e=$(t),a=e.attr("data-target"),i=e.attr("data-trigger"),n=e.find(".progress-bar"),o=e.find(".progress-percent");$(e).find(":submit").on("click",function(t){t.preventDefault(),$(e).find(":submit").attr("disabled","disabled"),$(e).find(":submit").css("white-space","normal");var a=$('');$(e).find(":submit").append(a),$(e).submit()}),e.ajaxForm({beforeSend:function(){n.parent().removeClass("hidden"),n.width("0%"),o.html("0%")},uploadProgress:function(t,e,a,i){var r=i+"%";n.width(r),o.html(r)},error:function(){$(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t){n.width("100%"),o.html("100%"),$(a).empty().html(t),$(a).find(i).trigger("click")}})}},PartialFormsAjaxMemberBg={setup:function(){var t=$("form.partialajaxbg"),e=t.attr("data-target"),a=t.attr("data-trigger");$(t).find(":submit").on("click",function(e){e.preventDefault(),$(t).find(":submit").attr("disabled","disabled"),$(t).find(":submit").css("white-space","normal");var a=$('');$(t).find(":submit").append(a),$(t).submit()}),t.ajaxForm({error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t){$(e).empty().html(t),$(e).find(a).trigger("click")}})}},AjaxForm={setup:function(t,e){var a=$(e);$("body").on("submit",t,function(t){return t.preventDefault(),t.stopImmediatePropagation(),$(this).find("button").attr("disabled","disabled"),$(this).find(".glyphicon.glyphicon-send").removeClass("glyphicon-send").addClass("glyphicon-refresh spinning"),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(t,e,a){var i=JSON&&JSON.parse(t.responseText)||$.parseJSON(t.responseText),n=$("#generic-dialog");n.modal("hide"),n.find(".modal-header-text").empty().append(i.title),n.find(".modal-body").empty().append(i.message),setTimeout(function(){n.modal("show")},900)},success:function(t){"ok"==t.status&&$(a).empty().html(t.data),"error"==t.status&&(""!=t.message?alert(t.message):alert("Service is temporarily unavailable."))}}),!1})}},WidgetModalAjax={setup:function(){$(".my-product-item").find("a.widget-button").on("click",function(){var t=$(this).attr("rel"),e=t.split("product")[1],a=$(".modal-body#widget-code-"+t);$.ajax({url:"/widget/config/"+e,type:"html",success:function(t){a.prepend(t),angular.bootstrap(a,["widgetApp"])}})})}},LoginContainer={update:function(){Date.now||(Date.now=function(){return(new Date).getTime()});var t="/authorization/htmllogin?"+(Date.now()/1e3|0);$("#login_container").load(t,function(t,e,a){})}},RssNews={setup:function(){if(0==$("#rss-feeds").length)return!1;$.getJSON("/json/news",function(t){var e="";$.each(t.posts,function(t,a){if(t>=3)return!1;var i=moment(a.date);e+='
'+a.title+'
'+i.format("MMM DD YYYY")+''+a.comments.length+" Comment"+(a.comments.length>1?"s":"")+"
"}),$("#rss-feeds").html(e)})}},Mastodon={setup:function(){if(0==$("#mastodon-toots").length)return!1;$.getJSON("/json/socialtimeline",function(t){var e="";$.each(t,function(t,a){e+='
'+a.account.username+""+a.content.replace(/(<([^>]+)>)/gi,"")+''+a.created_at+"
"}),$("#mastodon-toots").html(e)})}},BlogJson={setup:function(){$.ajax("/json/forum").then(function(t){var e=t.topic_list.topics,a="",i=3;e.sort(function(t,e){return new Date(e.last_posted_at)-new Date(t.last_posted_at)}),$.each(e,function(t,e){if(!e.pinned){var n=e.timeago,o="Reply",r=e.posts_count-1;o=0==r?"Replies":1==r?"Reply":"Replies",a+='
'+e.title+'
'+n+''+r+" "+o+"
",i--}if(0==i)return!1}),$("#blogJson").html(a)})}},GitlabNewProjectsJson={setup:function(t){$.ajax("/json/gitlabnewprojects").then(function(e){var a=e,i="";$.each(a,function(e,a){var n=a.timeago;i+='"}),$("#lastgitprojects").html(i)})}};function showGitUserAvatar(t,e,a){var i=t+"/api/v4/users?username="+e;$.ajax(i).then(function(t){var i=t;$.each(i,function(t,i){$img=$("#avatar_"+e+"_"+a),$img.attr("src",i.avatar_url)})})}var ProductDetailCarousel={setup:function(){$(".carousel-inner img").each(function(t){$(this).on("click",function(){$("#product-main-img-container").hasClass("imgfull")?$("#product-main-img-container").prependTo($("#product-main")):$("#product-main-img-container").prependTo($("#product-page-content")),$("#product-main-img-container").toggleClass("imgfull"),$("#product-main-img-container").toggleClass("imgsmall")})})}},AppimagequestionOnClick={setup:function(t){$("body").on("click","i.appimagequestion",function(t){var e=$("#generic-dialog");e.modal("show"),e.find(".modal-header-text").empty().append("AppImage Info"),e.find(".modal-body").empty().append("")})}},ProductDetailBtnGetItClick={setup:function(t){$("body").on("click","button#project_btn_download",function(e){$.fancybox({hideOnContentClick:!0,autoScale:!0,cyclic:"true",transitionIn:"elastic",transitionOut:"elastic",type:"ajax",helpers:{overlay:{locked:!1}},autoSize:!0,href:"/p/"+t+"/ppload"})})}},GhnsExcludedClick={setup:function(t){$("body").on("click","#ghns_excluded-this-checkbox",function(e){e.stopPropagation();var a=1,i="",n="";this.checked?(a=1,i="Please specify why this product should be excluded (min 5 chars) :",n=" ghns exclude"):(a=0,i="Please specify why this product should be included (min 5 chars) :",n=" ghns include");var o=$("#generic-dialog");return o.modal("show"),o.find(".modal-header-text").empty().append("GHNS "),o.find(".modal-body").empty().append(i+'

"),$("body").on("click","#btn-ghns-excluded",function(){var t=$("#ghns-excluded-text").val();if(t.length<5)return alert("min 5 chars"),!1;var e=$(this).attr("data-projectid"),a=$(this).attr("data-status");$.ajax({url:"/backend/project/doghnsexclude",method:"POST",data:{project_id:e,ghns_excluded:a,msg:t},success:function(t){var e=$("#generic-dialog");0==a?(e.find(".modal-body").empty().append("Project is successfully included into GHNS"),$("#ghns_excluded-this-checkbox").prop("checked",!1)):(e.find(".modal-body").empty().append("Project is successfully excluded into GHNS"),$("#ghns_excluded-this-checkbox").prop("checked",!0)),setTimeout(function(){e.modal("hide")},1e3)},error:function(){alert("Service is temporarily unavailable.")}})}),!1})}},AboutMeMyProjectsPaging={setup:function(){$(window).scroll(function(){if($("footer").offset().top-($(window).scrollTop()+$(window).height())<300){if(!$("button#btnshowmoreproducts").length)return;let t='',e=$("button#btnshowmoreproducts").attr("data-page");$("button#btnshowmoreproducts").remove(),$url=window.location.href,target=$(".about-me-details").find("li.active").find("a").attr("href"),"#user-original-products"==target&&($url+="showoriginal");let a=$("

").append(t).load($url,{projectpage:e},function(t,e,a){if("error"==e)if(401==a.status){if(t){var i=jQuery.parseJSON(t).login_url;window.location=i||"/login"}}else $(target).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.")});$(target).append(a)}})}},AboutMeMyProjectsPagingButton={setup:function(){$("body").on("click","button#btnshowmoreproducts",function(t){let e=$(this).attr("data-page");$(this).remove(),$url=window.location.href,target=$(".about-me-details").find("li.active").find("a").attr("href"),"#user-original-products"==target&&($url+="showoriginal");let a=$("
").append('').load($url,{projectpage:e},function(t,e,a){if("error"==e)if(401==a.status){if(t){var i=jQuery.parseJSON(t).login_url;window.location=i||"/login"}}else $(target).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.")});$(target).append(a)})}},ProductDetailCommentTooltip={setup:function(){TooltipUser.setup("tooltipuser","right")}};function generateTooltipster(t,e){$(t).each(function(){$(this).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/member/"+i+"/tooltip/",function(e){var i=e.data,n='
'+i.username+' '+i.countrycity+'
'+i.cntProjects+' products
'+i.totalComments+' comments
Likes '+i.cntLikesGave+' products
Got '+i.cntLikesGot+' Likes
Last time active : '+i.lastactive_at+'
Member since : '+i.created_at+"
";n+="
",t.content(n),a.data("loaded",!0)})}})})}var TooltipUser={setup:function(t,e){$("."+t).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/member/"+i+"/tooltip/",function(e){var i=e.data,n='
'+i.username+' '+i.countrycity+'
'+i.cntProjects+' products
'+i.totalComments+' comments
Likes '+i.cntLikesGave+' products
Got '+i.cntLikesGot+' Likes
Last time active : '+i.lastactive_at+'
Member since : '+i.created_at+"
";n+="
",t.content(n),a.data("loaded",!0)})}})}};function generateTooltipUserPlings(t,e){$(t).each(function(){$(this).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/plings/tooltip/id/"+i,function(e){var i='
';$.each(e.data,function(t,e){if(t>10)return!1;e.profile_image_url.indexOf("http")<0&&(e.profile_image_url="https://cn.opendesktop.org/cache/40x40-2/img/"+e.profile_image_url),e.profile_image_url.indexOf(".gif")>0&&(e.profile_image_url="https://cn.opendesktop.org/img/"+e.profile_image_url),i=i+'
'+e.username+"
"}),i+="
",t.content(i),a.data("loaded",!0)})}})})}var TooltipUserPlings={setup:function(t,e){$("."+t).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/plings/tooltip/id/"+i,function(e){var i='
';$.each(e.data,function(t,e){if(t>10)return!1;e.profile_image_url.indexOf("http")<0&&(e.profile_image_url="https://cn.opendesktop.org/cache/40x40-2/img/"+e.profile_image_url),e.profile_image_url.indexOf(".gif")>0&&(e.profile_image_url="https://cn.opendesktop.org/img/"+e.profile_image_url),i=i+'
'+e.username+"
"}),i+="
",t.content(i),a.data("loaded",!0)})}})}},AboutMePage={setup:function(t){var e=t+"'s Profile "+$(document).prop("title");$(document).prop("title",e)}},InitActiveHashTab={setup:function(){var t=document.location.hash;$('a[href="'+t+'"]')&&$('a[href="'+t+'"]').tab("show")}},AboutmeTab={setup:function(){$("body").on("click","a.aboutmetab",function(t){t.preventDefault();var e=$(this).attr("href"),a=$(this).attr("data-href");0==$(e).find(".product").length&&$(e).append('').load(a,function(){})})}},CommunityTabToplistMemberScrollPaging={setup:function(t,e){$(window).scroll(function(){if($("footer").offset().top-($(window).scrollTop()+$(window).height())<300){if(!$("button#toplistmemberscrollshowmore").length)return;var a=$("button#toplistmemberscrollshowmore").attr("data-page");$("button#toplistmemberscrollshowmore").remove();var i=e+"/nopage/1/page/"+a,n=$('
');$(t).find(".product-list").append(n),$(n).load(i,function(){generateTooltipster($(n).find(".tooltipuser"),"right")})}})}},CommunityTab={setup:function(){$("body").on("click","a.communitytab",function(t){t.preventDefault();var e=$(this).attr("href"),a=$(this).attr("data-href");0==$(e).find(".list").find(".user").length&&$(e).find(".list").append('').load(a,function(){generateTooltipster($(e).find(".tooltipuser"),"right"),$(e).find(".tooltipuserplings").length>0&&generateTooltipUserPlings($(e).find(".tooltipuserplings"),"right"),"#toplistMemberPanel"==e&&CommunityTabToplistMemberScrollPaging.setup(e,a),$(e).find(".opendesktopwidgetpager span").each(function(t){$(this).on("click",function(){$(this).parent().addClass("active").siblings().removeClass("active");var t=a+"/nopage/1/page/"+$(this).html();$(e).find(".product-list").html(""),$(e).find(".product-list").load(t,function(){generateTooltipster($(e).find(".tooltipuser"),"right"),$(e).find(".tooltipuserplings").length>0&&generateTooltipUserPlings($(e).find(".tooltipuserplings"),"right")})})})})});var t=document.location.hash;$('a[href="'+t+'"]').length>0?($('a[href="'+t+'"]').tab("show"),$('a[href="'+t+'"]').trigger("click")):(t="#supportersPanel",$('a[href="'+t+'"]').trigger("click")),$("body").on("mouseenter",".product-thumbnail-startpage",function(){$(this).popover("show")}),$("body").on("mouseleave",".product-thumbnail-startpage",function(){$(this).popover("hide")})}},TagingProduct={setup:function(){$("input[name=tagsuser]").tagify({whitelist:["good","great"],autocomplete:!0}).on("remove",function(t,e){console.log("removed",e)}).on("add",function(t,e){console.log("added",e)})}},TagingProductSelect2={setup:function(){$.fn.select2.amd.require(["select2/selection/search"],function(t){t.prototype.searchRemoveChoice=function(t,e){this.trigger("unselect",{data:e}),this.$search.val(""),this.handleSearch()}},null,!0);var t=$(".taggingSelect2").select2({placeholder:"Add Tags here ...",tags:!0,tokenSeparators:[","," "],minimumInputLength:3,maximumSelectionLength:5,width:"resolve",ajax:{url:"/tag/filter",dataType:"json",type:"GET",delay:500,processResults:function(t){return{results:t.data.tags}}}});t.on("select2:select",function(e){var a=e.params.data;$("#tagsuserselect").attr("data-pid"),t.parent().find("ul.select2-selection__rendered").find("li.select2-selection__choice").length>5?t.find("option[value='"+a.id+"']").remove():(new RegExp("^[0-9A-Za-z_.-]+$").test(a.text)||(t.find("option[value='"+a.id+"']").remove(),alert("Must be letter or number and can include hyphens")),a.text.length>10&&(t.find("option[value='"+a.id+"']").remove(),alert("Max. length 45 chars")))})}},TagingProductDetail={setup:function(){TagingProductDetailSelect2.setup(),$("body").on("click","button.topic-tags-btn",function(t){if($(this).toggleClass("Done"),$(".product_category").find(".usertagslabel").remove(),$(".tagsuserselectpanel").toggle(),"Done"==$(this).text()){$(this).text("Manage tags");var e="",a=$("li.select2-selection__choice");$.each(a,function(t,a){e=e+''+a.title+""}),$(".product_category").find(".topicslink").html(e)}else $(this).text("Done")})}},TagingProductDetailSelect2={setup:function(){$.fn.select2.amd.require(["select2/selection/search"],function(t){t.prototype.searchRemoveChoice=function(t,e){this.trigger("unselect",{data:e}),this.$search.val(""),this.handleSearch()}},null,!0);var t=$("#tagsuserselect").select2({placeholder:"Input tags please...",tags:!0,minimumInputLength:3,closeOnSelect:!0,maximumSelectionLength:5,tokenSeparators:[","," "],ajax:{url:"/tag/filter",dataType:"json",type:"GET",delay:500,processResults:function(t){return{results:t.data.tags}}}});t.on("select2:select",function(e){var a=e.params.data,i=$("#tagsuserselect").attr("data-pid");$.post("/tag/add",{p:i,t:a.id}).done(function(e){"error"==e.status?($("span.topic-tags-saved").css({color:"red"}).html(e.message).show().delay(2e3).fadeOut(),t.find("option[value='"+e.data.tag+"']").last().remove()):$("span.topic-tags-saved").css({color:"green"}).html(' Saved').show().delay(1e3).fadeOut()})}),t.on("select2:unselect",function(t){var e=t.params.data,a=$("#tagsuserselect").attr("data-pid");$.post("/tag/del",{p:a,t:e.id}).done(function(t){console.log(t),$("span.topic-tags-saved").css({color:"green"}).html(''+t.message).show().delay(1e3).fadeOut()})})}},TagingLoopMyProducts={setup:function(){TagingLoopMyProductsSelect2.setup(),$("body").on("click","button.topic-tags-btn",function(t){if($(this).toggleClass("Done"),$(this).parent().find(".topicsuser").html(""),$(this).parent().find(".tagsuserselectpanel").toggle(),"Done"==$(this).text()){$(this).text("Manage tags");var e="",a=$(this).parent().find("li.select2-selection__choice");$.each(a,function(t,a){e=e+''+a.title+""}),$(this).parent().find(".topicsuser").html(e)}else $(this).text("Done")})}},TagingLoopMyProductsSelect2={setup:function(){$.fn.select2.amd.require(["select2/selection/search"],function(t){t.prototype.searchRemoveChoice=function(t,e){this.trigger("unselect",{data:e}),this.$search.val(""),this.handleSearch()}},null,!0);var t=$(".taggingSelect2").select2({placeholder:"Input tags please...",tags:!0,minimumInputLength:3,closeOnSelect:!0,maximumSelectionLength:5,tokenSeparators:[","," "],ajax:{url:"/tag/filter",dataType:"json",type:"GET",delay:500,processResults:function(t){return{results:t.data.tags}}}});t.on("select2:select",function(e){var a=e.params.data,i=$(this).attr("id").replace("tagsuserselect","");$.post("/tag/add",{p:i,t:a.id}).done(function(e){"error"==e.status?($("#topic-tags-saved"+i).css({color:"red"}).html(e.message).show().delay(2e3).fadeOut(),t.find("option[value='"+e.data.tag+"']").last().remove()):"existing"==e.status?$("#topic-tags-saved"+i).css({color:"red"}).html(e.message).show().delay(2e3).fadeOut():$("#topic-tags-saved"+i).css({color:"green"}).html(' Saved').show().delay(1e3).fadeOut()})}),t.on("select2:unselect",function(t){var e=t.params.data,a=$(this).attr("id").replace("tagsuserselect","");$.post("/tag/del",{p:a,t:e.id}).done(function(t){$("#topic-tags-saved"+a).css({color:"green"}).html(''+t.message).show().delay(1e3).fadeOut()})})}},productRatingToggle={setup:function(){$("#showRatingAll").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".productRating-rows-inactive").show()}),$("#showRatingActive").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".productRating-rows-inactive").hide()}),$("#showRatingUpvotes").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".clsDownvotes").hide(),$(".productRating-rows-inactive").hide()}),$("#showRatingDownvotes").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".productRating-rows-inactive").hide(),$(".clsUpvotes").hide()})}},FilterBrowseOriginalFn={setup:function(){$("body").on("click","input#filter_browse_original",function(t){var e=$(this).is(":checked"),a=window.location.href;a.indexOf("browse")<0&&(a+="/browse/"),a.indexOf("filteroriginal")>0&&(a=a.substring(0,a.indexOf("filteroriginal"))),window.location.href=e?a+"filteroriginal/1":a+"filteroriginal/0"})}},FilterBrowseTagGroupFn={setup:function(){$("body").on("change","select.filter_browse_tag_group",function(t){var e=$(this).val(),a=$(this).attr("data_group_id");$.ajax({url:"/explore/savetaggroupfilter?group_id="+a+"&tag_id="+e,cache:!1}).done(function(t){var e=window.location.href;window.location.href=e})})}}; \ No newline at end of file +var prefix="ocs_",OcsStorage={set:function(t,e){localStorage[t]=JSON.stringify(e)},get:function(t){return localStorage[t]?JSON.parse(localStorage[t]):null}},OcsStats={props:{},a:0,readIp:function(t,e){$.getJSON(t,function(t){OcsStats.props.ipv4=t.ip,OcsStats.saveProps(1)}).fail(function(){OcsStats.saveProps(1)}),$.getJSON(e,function(t){OcsStats.props.ipv6=t.ip,OcsStats.saveProps(2)}).fail(function(){OcsStats.saveProps(2)})},genId:function(){Fingerprint2.get({},function(t){var e=t.map(function(t){return t.value});OcsStats.props.fp=Fingerprint2.x64hash128(e.join(""),31),OcsStats.saveProps(4)})},saveProps:function(t){OcsStorage.set("ocs",OcsStats.props),OcsStats.a+=t,7==OcsStats.a&&OcsStats.postProps()},postProps:function(){$.post("/l/fp",OcsStats.props)},readStats:function(t,e){window.requestIdleCallback?requestIdleCallback(function(){OcsStats.genId(),OcsStats.readIp(t,e)}):setTimeout(function(){OcsStats.genId(),OcsStats.readIp(t,e)},500)}},newProductPage={setup:function(){function t(){var t=$("#donations-panel").find("#comments").height();t>$("#donations-panel").find("#supporters").height()&&$("#donations-panel").find("#supporters").height(t)}$(document).ready(function(){var e;e=$("#pling-it-box").height(),$(".scrollable-content").height(e),$(".scrollable-content").jScrollPane({mouseWheelSpeed:30}),t(),$('a[data-toggle="tab"]').on("shown.bs.tab",function(e){t()})})}},ImagePreview={hasError:!1,setup:function(){this.initProductPicture(),this.initTitlePicture(),this.initProfilePicture(),this.initProfilePictureBackground()},previewImage:function(t,e){if(t.files&&t.files[0]){var a=new FileReader,i=new Image,n=t.files[0];a.readAsDataURL(t.files[0]),a.onload=function(a){var o=$("#"+e);i.src=a.target.result,i.onload=function(){var e=this.width,i=this.height,r=n.type,s=(n.name,~~(n.size/1024));ImagePreview.hasError=!1,o.parent().parent().find("div.bg-danger").remove(),(e>2e3||e<20||i>2e3||i<20)&&(o.parent().parent().append('
Wrong image dimensions
'),$($(t).closest("form")[0]).trigger("reset"),ImagePreview.hasError=!0),s>2e3&&(o.parent().parent().append('
File too large
'),$($(t).closest("form")[0]).trigger("reset"),ImagePreview.hasError=!0);/(jpg|jpeg|png|gif)$/i.exec(r)||(o.parent().parent().append('
Invalid file type: '+n.type+"
"),$($(t).closest("form")[0]).trigger("reset"),ImagePreview.hasError=!0),0==ImagePreview.hasError&&(ImagePreview.hasError=!1,o.attr("src",a.target.result),o.show())},i.onerror=function(){o.parent().parent().find("div.bg-danger").remove(),o.parent().parent().append('
Invalid file type: '+n.type+"
")},"product-picture-preview"==e?$("button#add-product-picture").text("CHANGE LOGO"):"title-picture-preview"==e?$("button#add-title-picture").text("CHANGE BANNER"):"profile-picture-preview"==e?($("button#add-profile-picture").text("CHANGE PICTURE"),$("input#profile_img_src").val("local")):"profile-picture-bg-preview"==e&&$("button#add-profile-picture-background").text("CHANGE PICTURE")}}},previewImageMember:function(t,e){if(t.files&&t.files[0]){var a=new FileReader,i=new Image;t.files[0];a.readAsDataURL(t.files[0]),a.onload=function(t){var a=$("#"+e);i.src=t.target.result,i.onload=function(){ImagePreview.hasError=!1,a.parent().find(".image-error").remove(),0==ImagePreview.hasError&&(a.attr("src",t.target.result),a.show())},i.onerror=function(){a.parent().append('
Invalid file type
')},"profile-picture-background-preview"==e&&$("button#add-profile-picture-background").text("CHANGE PICTURE")}}},readImage:function(t){var e=new FileReader,a=new Image;e.readAsDataURL(t),e.onload=function(e){a.src=e.target.result,a.onload=function(){var e=this.width,a=this.height,i=t.type,n=t.name,o=~~(t.size/1024)+"KB";$("#uploadPreview").append(' '+e+"x"+a+" "+o+" "+i+" "+n+"
")},a.onerror=function(){alert("Invalid file type: "+t.type)}}},initProductPicture:function(){if(0!=$("#image_small").length&&0!=$("#image_small").attr("value").length){var t=$("#image_small").data("target");$(t).attr("src","https://cn.opendesktop.org/cache/200x200-2/img/"+$("#image_small").attr("value")),$(t).show(),$("button#add-product-picture").text("CHANGE LOGO")}},initTitlePicture:function(){if(0!=$("#image_big").length&&0!=$("#image_big").attr("value").length){var t=$("#image_big").data("target");$(t).attr("src","https://cn.opendesktop.org/cache/200x200-2/img/"+$("#image_big").attr("value")),$(t).show(),$("button#add-title-picture").text("CHANGE BANNER")}},initProfilePicture:function(){if(0!=$("#profile_image_url").length&&0!=$("#profile_image_url").attr("value").length){var t=$("#profile_image_url").data("target");$(t).attr("src",$("#profile_image_url").attr("value")),$("#profile-picture").attr("src",$("#profile_image_url").attr("value")),$(t).show(),$("button#add-profile-picture").text("CHANGE PICTURE")}},initProfilePictureBackground:function(){if(0!=$("#profile_image_url_bg").length&&0!=$("#profile_image_url_bg").attr("value").length){var t=$("#profile_image_url_bg").data("target");$(t).attr("src",$("#profile_image_url_bg").attr("value")),$("#profile-picture-background-preview").attr("src",$("#profile_image_url_bg").attr("value")),$(t).show(),$("button#add-profile-picture-background").text("CHANGE PICTURE")}}},MenuHover={setup:function(){$("body").on("click","a#login-dropdown",function(t){t.stopPropagation(),$(".header-login-container").toggleClass("active")}).on("click",".header-login-container",function(t){t.stopPropagation()}).on("click","a.menu-trigger",function(t){t.stopPropagation();var e="."+$(this).attr("rel");$(e).toggleClass("active")}).on("mouseup",function(t){var e=$("ul.profile-menu");$("li.profile-menu-container a.menu-trigger").is(t.target)||e.is(t.target)||0!==e.has(t.target).length||e.removeClass("active")}).on("mouseup",function(t){container=$("div.header-login-container"),trigger=$("a#login-dropdown"),trigger.is(t.target)||container.is(t.target)||0!==container.has(t.target).length||container.removeClass("active")}).click(function(){$(".header-login-container.active").removeClass("active"),$(".profile-menu.active").removeClass("active")})}},ButtonCode={setup:function(){$("#button-code-heading").click(function(){$(this).hasClass("button-code-active")?($(this).removeClass("button-code-active"),$(this).parent().find(".button-code").slideUp("fast"),$(this).parent().find(".button-code").css("border-bottom","none"),$(this).find(".icon-expand-code").css("background-image","url(img/icon-expand.png)")):($(this).addClass("button-code-active"),$(this).parent().find(".button-code").css("border-bottom","1px solid #bdc3c7"),$(this).parent().find(".button-code").slideDown("fast"),$(this).find(".icon-expand-code").css("background-image","url(img/icon-contract.png)"))})},setupClipboardCopy:function(t){$(t).on("mouseover",function(){$(this).off("mouseover"),$(this).find("[data-clipboard-target]").each(function(){var t=$($(this).attr("data-clipboard-target"));$(this).zclip({path:"/theme/flatui/js/lib/ZeroClipboard.swf",copy:$.trim($(t).text())})})})}},ProductPage={setup:function(){$(".dropdown-toggle").dropdown(),$(".scroll-pane").jScrollPane({mouseWheelSpeed:30,animateScroll:!0}),$(".love-it").on("click",function(){this_img_src=$(this).find("img").attr("src"),$(this).hasClass("no-login")||"/theme/flatui/img/icon-like-color.png"==this_img_src||$(this).prev(".share-it").trigger("click")}),$(".payment-options").find(".options").find("span.option").on("click",function(){var t=$(this).attr("title"),e=$(".payment-options").find('input[type="number"]');e.attr("value",t).val(t),e.focus(),$(".options").find(".selected").removeClass("selected"),$(this).addClass("selected")})},setupPlingButton:function(){$("#pling-amount").on("focus",function(){$("#pling-amount").popover("destroy")}),$("#pling-start").on("click",function(t){return validateElement=$("#pling-amount"),validateValue=validateElement.val(),""==validateValue||isNaN(parseFloat(validateValue))||!isFinite(validateValue)?(t.preventDefault(),$("#pling-amount").popover({placement:"bottom",html:"true",content:'
Donation must be a numeric value.
'}).popover("show"),!1):(minValue=validateElement.attr("min"),parseFloat(validateValue)×
Donation must be equal or greater than '+minValue+".
"}).popover("show"),!1):(maxValue=validateElement.attr("max"),parseFloat(validateValue)>parseFloat(maxValue)?(t.preventDefault(),$("#pling-amount").popover({placement:"bottom",html:"true",content:'
Donation must be smaller or equal than '+maxValue+".
"}).popover("show"),!1):void 0))})}},SlideShowRender={setup:function(){$("#slideshow-container").find("img:first").addClass("active"),$("#slideshow-container").find("#navigation").find("a:first").addClass("active")}},ProductSlideShow={setup:function(){$("#slideshow-container").find("#arrows").find("a").on("click",function(t){var e=$(this).attr("id"),a=$("#slideshow-container #slides"),i=a.find("img.active"),n=i.attr("rel"),o=$("#slideshow-container").find("#navigation").find("a.active");if("prev"==e){var r=parseInt(n)-parseInt(1),s=$("#slideshow-container").find('img[rel="'+r+'"]'),l=$("#slideshow-container").find("#navigation").find('a[rel="'+r+'"]');1==!s.size()&&(s=a.find("img:last"),l=$("#slideshow-container").find("#navigation").find("a:last"))}else if("next"==e){var d=parseInt(n)+parseInt(1);s=$("#slideshow-container").find('img[rel="'+d+'"]'),l=$("#slideshow-container").find("#navigation").find('a[rel="'+d+'"]'),1==!s.size()&&(s=a.find("img:first"),l=$("#slideshow-container").find("#navigation").find("a:first"))}i.removeClass("active"),o.removeClass("active"),s.addClass("active"),l.addClass("active")}),$("#slideshow-container").find("#navigation").find("a").on("click",function(){var t=$(this).attr("rel"),e=$("#slideshow-container").find('img[rel="'+t+'"]');$("#slideshow-container").find("img.active").removeClass("active"),e.addClass("active"),$("#slideshow-container").find("#navigation").find("a.active").removeClass("active"),$(this).addClass("active")})}},SlideShow={setup:function(){slideShowInterval=setTimeout(function(){var t=$("#slideshow-container").find("img.active"),e=t.attr("rel"),a=parseInt(e)+parseInt(1),i=$("#slideshow-container").find('img[rel="'+a+'"]'),n=$("#slideshow-container").find("#navigation").find("a.active");t.removeClass("active"),n.removeClass("active"),1==i.size()?(i.addClass("active"),$("#slideshow-container").find("#navigation").find('a[rel="'+a+'"]').addClass("active")):($("#slideshow-container").find("img:first").addClass("active"),$("#slideshow-container").find("#navigation").find("a:first").addClass("active"))},4e3)}},Popuppanel={setup:function(){$("body").on("click","a.popuppanel",function(t){if("_blank"===$(this).attr("target"))console.log("dont prevent default");else{t.preventDefault();var e=$(this).attr("href");$.fancybox({hideOnContentClick:!0,autoScale:!0,cyclic:"true",transitionIn:"elastic",transitionOut:"elastic",type:"iframe",scrolling:"auto",helpers:{overlay:{locked:!1}},autoSize:!0,href:e,type:"ajax"})}})}},PlingsRedirect={setup:function(){window.location.hash?($link=$(window.location.hash),$link.trigger("click")):document.location.hash&&($link=$(document.location.hash),$link.trigger("click"))}},ShowPopups={setup:function(){window.location.hash&&(alert("Hash"),$('a[href="'+document.location.hash+'"]').trigger("click")),document.location.hash&&(alert("Hash"),$('a[href="'+document.location.hash+'"]').trigger("click"))}};$("body").on("mouseenter",".supporter-thumbnail",function(){$(this).popover("show")}),$("body").on("mouseleave",".supporter-thumbnail",function(){$(this).popover("hide")});var Partials={setup:function(){$("body").on("click","a.partial",function(t){t.preventDefault();var e=this.href,a=$(this).attr("data-target"),i=$(this).data("toggle"),n=$(this).attr("data-fragment");return $(a).load(e+" "+n,function(t,e,n){if("error"==e)if(401==n.status){if(t){var o=jQuery.parseJSON(t).login_url;window.location=o||"/login"}}else $(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.");i&&$(i).modal("show")}),!1})}},Opendownloadfile={setup:function(){$("body").on("click","a.opendownloadfile",function(t){t.preventDefault();var e=$(this).attr("data-file_id"),a=$(this).attr("data-file_type"),i=$(this).attr("data-file_name"),n=$(this).attr("data-file_size"),o=$(this).attr("data-project_id"),r=$(this).attr("data-link_type"),s=$(this).attr("data-is-external-link"),l=$(this).attr("data-has_torrent"),d=null,c="450";return"true"==s&&(d=$(this).attr("data-external_link"),c="500"),$.fancybox({hideOnContentClick:!0,autoScale:!1,scrolling:"no",cyclic:"true",transitionIn:"elastic",transitionOut:"elastic",type:"iframe",width:"600",height:c,iframe:{scrolling:"no"},fitToView:!1,autoSize:!1,id:"opendownloadfilepopup",helpers:{overlay:{locked:!1}},href:"/dl?file_id="+e+"&file_type="+a+"&file_name="+i+"&file_size="+n+"&has_torrent="+l+"&project_id="+o+"&link_type="+r+"&is_external="+s+"&external_link="+d}),!1})}},PartialsButton={setup:function(){$("body").on("click","Button.partialbutton",function(t){t.preventDefault();var e=$(this).attr("data-href"),a=$(this).attr("data-target"),i=$(this).data("toggle"),n=$(this).attr("data-fragment"),o=$('');return $(a).append(o),$(a).load(e+" "+n,function(t,e,n){if("error"==e)if(401==n.status){if(t){var o=jQuery.parseJSON(t).login_url;window.location=o||"/login"}}else $(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.");i&&$(i).modal("show")}),!1})}},PartialsButtonHeartDetail={setup:function(){$("body").on("click",".partialbuttonfollowproject",function(t){t.preventDefault();var e=$(this).attr("data-href"),a=$(this).attr("data-target"),i=$(this).attr("data-auth");if($(this).data("toggle"),$(this).attr("data-fragment"),i){if($("#like-product-modal").find("#loginuser").val()==$("#like-product-modal").find("#productcreator").val())return $("#like-product-modal").find("#votelabel").text("Project owner not allowed"),$("#like-product-modal").find(".modal-body").empty(),void $("#like-product-modal").modal("show");var n=$('');return $(a).prepend(n),$.ajax({url:e,cache:!1}).done(function(t){$(a).find(".spinning").remove(),"error"==t.status?$(a).html(t.msg):"delete"==t.action?($(a).find(".plingtext").html(t.cnt),$(a).find(".plingtext").addClass("heartnumberpurple"),$(a).find(".plingheart").removeClass("heartproject").addClass("heartgrey"),$(a).find(".plingheart").removeClass("fa-heart").addClass("fa-heart-o")):($(a).find(".plingtext").html(t.cnt),$(a).find(".plingtext").removeClass("heartnumberpurple"),$(a).find(".plingheart").removeClass("heartgrey").addClass("heartproject"),$(a).find(".plingheart").removeClass("fa-heart-o").addClass("fa-heart"))}),!1}$("#like-product-modal").modal("show")})}},PartialsButtonPlingProject={setup:function(){$("#plingbtn").hover(function(){$(this).attr("src","/images/system/pling-btn-hover.png")},function(){$(this).attr("src",$(this).attr("data-src"))}),$("body").on("click",".partialbuttonplingproject",function(t){t.preventDefault();var e=$(this).attr("data-href"),a=$(this).attr("data-target"),i=$(this).attr("data-auth"),n=$(this).attr("data-issupporter");if($(this).data("toggle"),$(this).attr("data-fragment"),i)return $("#like-product-modal").find("#loginuser").val()==$("#like-product-modal").find("#productcreator").val()?($("#like-product-modal").find("#votelabel").text("Project owner not allowed"),$("#like-product-modal").find(".modal-body").empty(),void $("#like-product-modal").modal("show")):n?($(a).find(".plingnum").html(''),$.ajax({url:e,cache:!1}).done(function(t){"error"==t.status?$(a).html(t.msg):"delete"==t.action?(0==t.cnt?$(a).find(".plingnum").html("Pling me"):$(a).find(".plingnum").html(t.cnt+" Plings"),$(a).find("#plingbtn").attr("src","/images/system/pling-btn-normal.png"),$(a).find("#plingbtn").attr("data-src","/images/system/pling-btn-normal.png")):($(a).find(".plingnum").html(t.cnt+" Plings"),$(a).find("#plingbtn").attr("src","/images/system/pling-btn-active.png"),$(a).find("#plingbtn").attr("data-src","/images/system/pling-btn-active.png"))}),!1):($("#like-product-modal").find("#votelabel").html('
To pling a product and help the artist please consider becoming a supporter. Thanks!

Become a supporter
'),void $("#like-product-modal").modal("show"));$("#like-product-modal").modal("show")})}},PartialsReview={setup:function(){$("body").on("click","a.partialreview",function(t){if(t.preventDefault(),this.href,$(this).attr("data-target"),$(this).data("toggle"),$(this).attr("data-fragment"),$("#review-product-modal").find("#loginuser").val()==$("#review-product-modal").find("#productcreator").val())return $("#review-product-modal").find("#votelabel").text("Project owner not allowed"),$("#review-product-modal").find(".modal-body").empty(),void $("#review-product-modal").modal("show");var e=$("#review-product-modal").find("#userrate").val();return $(this).hasClass("voteup")?1==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment:'),$("#review-product-modal").find("#commenttext").val($("#review-product-modal").find("#otxt").val()),$("#review-product-modal").find(":submit").text("Remove Rating")):($("#review-product-modal").find("input#voteup").val(1),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 1 char):'),$("#review-product-modal").find("#commenttext").val("+"),$("#review-product-modal").find(":submit").text("Rate Now"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").css("display","block").removeAttr("disabled")):0==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment: '),$("#review-product-modal").find("#commenttext").val($("#review-product-modal").find("#otxt").val()),$("#review-product-modal").find(":submit").text("Remove Rating")):($("#review-product-modal").find("input#voteup").val(2),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 5 char) Please explain the reason for downvote to help the creator to make it better '),$("#review-product-modal").find("#commenttext").val("-"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").removeAttr("disabled").css("display","block"),$("#review-product-modal").find(":submit").text("Rate Now")),$("#review-product-modal").modal("show"),$("#review-product-modal").hasClass("noid")&&setTimeout(function(){$("#review-product-modal").modal("hide")},2e3),!1})}},PartialsReviewDownloadHistory={setup:function(){$("body").on("click","button.partialReviewDownloadHistory",function(t){t.preventDefault();var e=$(this).attr("data-userrate");return $("#review-product-modal").find("#commenttext").val($(this).attr("data-comment")),$("#review-product-modal").find("#form_p").val($(this).attr("data-project")),$(this).hasClass("voteup")?1==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment:'),$("#review-product-modal").find(":submit").attr("disabled","disabled").css("display","none"),$("#review-product-modal").find("#commenttext").attr("disabled","disabled")):($("#review-product-modal").find("input#voteup").val(1),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 1 char):'),$("#review-product-modal").find("#commenttext").val("+"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").css("display","block").removeAttr("disabled")):0==e?($("#review-product-modal").find("#votelabel").empty().append(' is given already with comment: '),$("#review-product-modal").find("#commenttext").attr("disabled","disabled"),$("#review-product-modal").find(":submit").attr("disabled","disabled").css("display","none")):($("#review-product-modal").find("input#voteup").val(2),$("#review-product-modal").find("#votelabel").empty().append(' Add Comment (min. 5 chars): '),$("#review-product-modal").find("#commenttext").val("-"),$("#review-product-modal").find("#commenttext").removeAttr("disabled"),$("#review-product-modal").find(":submit").removeAttr("disabled").css("display","block")),$("#review-product-modal").modal("show"),$("#review-product-modal").hasClass("noid")&&setTimeout(function(){$("#review-product-modal").modal("hide")},2e3),!1})}},CreateScoreRatingPopup={setup:function(){var t,e=0;$("select.rating-select").focus(function(){t=$(this),e=$(this).val()}).change(function(){var t=$(this).find("option:selected"),e=t.val(),a=t.text(),i=($(this).attr("data-userrate"),$(this).attr("data-comment"),$(this).attr("data-creator")),n=$("#score-product-modal").find("#loginuser").val();if(n){if(n==i)return $("#score-product-modal").find("#votelabel").text("Project owner not allowed"),$("#score-product-modal").find(".modal-body").empty(),$("#score-product-modal").find("#modal-btn-onsubmit").remove(),void $("#score-product-modal").modal("show");-1==e?$("#score-product-modal").find("#votelabel").empty().append("Remove Rating "):e<=5?($("#score-product-modal").find("#votelabel").empty().append('Add a review to your rating "'+a+'" (min. 5 chars) Please explain the reason for downvote to help the creator to make it better '),$("#score-product-modal").find("#voteup").val(2)):($("#score-product-modal").find("#votelabel").empty().append('Add a review to your rating "'+a+'" (min. 1 char):'),$("#score-product-modal").find("#voteup").val(1)),$("#score-product-modal").find("#form_p").val($(this).attr("data-project")),$("#score-product-modal").find(":submit").css("display","block").removeAttr("disabled"),$("#score-product-modal").find("#commenttext").removeAttr("disabled"),e>=1&&e<=3?$("#score-product-modal").find("#commenttext").val(""):$("#score-product-modal").find("#commenttext").val(a),$("#score-product-modal").find("#userscorevalue").val(e),"-1"==e?$("#score-product-modal").find(":submit").text("Remove Rating"):$("#score-product-modal").find(":submit").text("Rate Now"),$("#score-product-modal").modal("show")}else $("#score-product-modal").modal("show")}),$("#modal-btn-cancel").on("click",function(){$(t).find("option[value="+e+"]").prop("selected",!0),$("#score-product-modal").modal("hide")});var a=!1;$("#modal-btn-onsubmit").on("click",function(){a=!0}),$("#score-product-modal").on("hidden.bs.modal",function(){a||$(t).find("option[value="+e+"]").prop("selected",!0)})}},PartialForms={setup:function(){$("body").on("submit","form.partial",function(t){t.preventDefault(),t.stopImmediatePropagation(),$(this).find(":submit").attr("disabled","disabled"),$(this).find(":submit").css("white-space","normal");var e=$('');$(this).find(":submit").append(e);var a=$(this).attr("data-target"),i=$(this).attr("data-trigger");return console.log(this),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(){return $(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
"),!1},success:function(t){return $(a).empty().html(t),$(a).find(i).trigger("click"),!1}}),!1})}},PartialJsonClone={setup:function(){$("body").on("submit","form.partialjsonclone",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=($(this).attr("data-trigger"),$(this).attr("data-projectid"));return jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t,e){$("form#product-report-clone").find("#clonePId").val(""),$("form#product-report-clone").find("#report-text").val(""),$("#report-product-clone-"+a).modal("hide");var i=$("#generic-dialog");i.find(".modal-header-text").empty(),i.find(".modal-body").empty().append(t.message),setTimeout(function(){i.modal("show")},900)}}),!1})}},PartialJson={setup:function(){$("body").on("submit","form.partialjson",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=$(this).attr("data-trigger");return jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t,i){t.redirect?window.location=t.redirect:(e&&$(e).empty().html(t.message),a&&$(e).find(a).trigger("click"))}}),!1})}},PartialJsonFraud={setup:function(){$("body").on("submit","form.partialjsonfraud",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=$(this).attr("data-trigger");return $("form.partialjsonfraud").find("#report-text").val().length<5?($("form.partialjsonfraud").find("p.warning").remove(),$("form.partialjsonfraud").find("#report-text").parent().append('

at least 5 chars

'),!1):(jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t,i){t.redirect?window.location=t.redirect:(e&&$(e).empty().html(t.message),a&&$(e).find(a).trigger("click"))}}),!1)})}},PartialPayPal={setup:function(){this.initPayPalForm(),this.initPayPalFee()},initPayPalForm:function(){$("body").on("submit","form.partialpaypal",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$(this).attr("data-target"),a=$(this).attr("data-trigger");return jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(t,e,a){$("#modal-dialog").modal("hide");var i=$('');i.html($(t.responseText).filter(".page-container").children()),i.append(''),setTimeout(function(){i.modal("show")},900)},success:function(t){$(e).empty().html(t),$(e).find(a).trigger("click"),$("#modal-dialog").modal("hide")}}),!1})},initPayPalFee:function(){$("body").on("change","#amount_plings",function(t){PartialPayPal.changeFee()})},changeFee:function(){var t=document.getElementById("amount_plings"),e=parseFloat(t.value),a=this.round(.05*e,2),i=.03*(a+e+.3)+.3,n=e+a+(i=this.round(i,2));document.getElementById("pling_fee").value=this.round(a,2).toFixed(2),document.getElementById("paypal_fee").value=this.round(i,2).toFixed(2),document.getElementById("sum").value=this.round(n,2)},round:function(t,e){var a=Math.pow(10,e);return Math.round(t*a)/a}},PartialCommentReviewForm={setup:function(){this.initForm()},initForm:function(){$("body").on("submit","form.product-add-comment-review",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$.trim($("#commenttext").val());if(2==$("#voteup").val()&&e.length<5)0==$("#review-product-modal").find("#votelabel").find(".warning").length&&$("#review-product-modal").find("#votelabel").append("
Please give a comment, thanks!");else{if(!(e.length<1)){$(this).find(":submit").attr("disabled","disabled"),$(this).find(":submit").css("white-space","normal");var a=$('');return $(this).find(":submit").append(a),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(t,e,a){$("#review-product-modal").modal("hide");var i=$("#generic-dialog");i.modal("hide"),i.find(".modal-header-text").empty().append("Please try later."),i.find(".modal-body").empty().append("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
"),setTimeout(function(){i.modal("show")},900)},success:function(t){$("#review-product-modal").modal("hide"),location.reload()}}),!1}0==$("#review-product-modal").find("#votelabel").find(".warning").length&&$("#review-product-modal").find("#votelabel").append("
Please give a comment, thanks!")}})}},PartialCommentReviewFormNew={setup:function(){this.initForm()},initForm:function(){$("body").on("submit","form.product-add-comment-review-new",function(t){t.preventDefault(),t.stopImmediatePropagation();var e=$.trim($("#score-product-modal").find("#commenttext").val());if(2==$("#score-product-modal").find("#voteup").val()&&e.length<5)0==$("#score-product-modal").find("#votelabel").find(".warning").length&&$("#score-product-modal").find("#votelabel").append("
Please give a comment, thanks!");else{if(!(e.length<1)){$(this).find(":submit").attr("disabled","disabled"),$(this).find(":submit").css("white-space","normal");var a=$('');return $(this).find(":submit").append(a),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,error:function(t,e,a){$("#score-product-modal").modal("hide");var i=$("#generic-dialog");i.modal("hide"),i.find(".modal-header-text").empty().append("Please try later."),i.find(".modal-body").empty().append("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
"),setTimeout(function(){i.modal("show")},900)},success:function(t){$("#score-product-modal").modal("hide"),location.reload()}}),!1}0==$("#score-product-modal").find("#votelabel").find(".warning").length&&$("#score-product-modal").find("#votelabel").append("
Please give a comment, thanks!")}})}},PartialFormsAjax={setup:function(){var t=$("form.partialajax"),e=t.attr("data-target"),a=t.attr("data-trigger");$(t).find(":submit").on("click",function(e){e.preventDefault(),$(t).find(":submit").attr("disabled","disabled"),$(t).find(":submit").css("white-space","normal");var a=$('');$(t).find(":submit").append(a),$(t).submit()}),t.ajaxForm({error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t){$(e).empty().html(t),$(e).find(a).trigger("click")}})}},AjaxFormWithProgress={setup:function(t){var e=$(t),a=e.attr("data-target"),i=e.attr("data-trigger"),n=e.find(".progress-bar"),o=e.find(".progress-percent");$(e).find(":submit").on("click",function(t){t.preventDefault(),$(e).find(":submit").attr("disabled","disabled"),$(e).find(":submit").css("white-space","normal");var a=$('');$(e).find(":submit").append(a),$(e).submit()}),e.ajaxForm({beforeSend:function(){n.parent().removeClass("hidden"),n.width("0%"),o.html("0%")},uploadProgress:function(t,e,a,i){var r=i+"%";n.width(r),o.html(r)},error:function(){$(a).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t){n.width("100%"),o.html("100%"),$(a).empty().html(t),$(a).find(i).trigger("click")}})}},PartialFormsAjaxMemberBg={setup:function(){var t=$("form.partialajaxbg"),e=t.attr("data-target"),a=t.attr("data-trigger");$(t).find(":submit").on("click",function(e){e.preventDefault(),$(t).find(":submit").attr("disabled","disabled"),$(t).find(":submit").css("white-space","normal");var a=$('');$(t).find(":submit").append(a),$(t).submit()}),t.ajaxForm({error:function(){$(e).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.
")},success:function(t){$(e).empty().html(t),$(e).find(a).trigger("click")}})}},AjaxForm={setup:function(t,e){var a=$(e);$("body").on("submit",t,function(t){return t.preventDefault(),t.stopImmediatePropagation(),$(this).find("button").attr("disabled","disabled"),$(this).find(".glyphicon.glyphicon-send").removeClass("glyphicon-send").addClass("glyphicon-refresh spinning"),jQuery.ajax({data:$(this).serialize(),url:this.action,type:this.method,dataType:"json",error:function(t,e,a){var i=JSON&&JSON.parse(t.responseText)||$.parseJSON(t.responseText),n=$("#generic-dialog");n.modal("hide"),n.find(".modal-header-text").empty().append(i.title),n.find(".modal-body").empty().append(i.message),setTimeout(function(){n.modal("show")},900)},success:function(t){"ok"==t.status&&$(a).empty().html(t.data),"error"==t.status&&(""!=t.message?alert(t.message):alert("Service is temporarily unavailable."))}}),!1})}},WidgetModalAjax={setup:function(){$(".my-product-item").find("a.widget-button").on("click",function(){var t=$(this).attr("rel"),e=t.split("product")[1],a=$(".modal-body#widget-code-"+t);$.ajax({url:"/widget/config/"+e,type:"html",success:function(t){a.prepend(t),angular.bootstrap(a,["widgetApp"])}})})}},LoginContainer={update:function(){Date.now||(Date.now=function(){return(new Date).getTime()});var t="/authorization/htmllogin?"+(Date.now()/1e3|0);$("#login_container").load(t,function(t,e,a){})}},RssNews={setup:function(){if(0==$("#rss-feeds").length)return!1;$.getJSON("/json/news",function(t){var e="";$.each(t.posts,function(t,a){if(t>=3)return!1;var i=moment(a.date);e+='
'+a.title+'
'+i.format("MMM DD YYYY")+''+a.comments.length+" Comment"+(a.comments.length>1?"s":"")+"
"}),$("#rss-feeds").html(e)})}},Mastodon={setup:function(){if(0==$("#mastodon-toots").length)return!1;$.getJSON("/json/socialtimeline",function(t){var e="";$.each(t,function(t,a){e+='
'+a.account.username+""+a.content.replace(/(<([^>]+)>)/gi,"")+''+a.created_at+"
"}),$("#mastodon-toots").html(e)})}},BlogJson={setup:function(){$.ajax("/json/forum").then(function(t){var e=t.topic_list.topics,a="",i=3;e.sort(function(t,e){return new Date(e.last_posted_at)-new Date(t.last_posted_at)}),$.each(e,function(t,e){if(!e.pinned){var n=e.timeago,o="Reply",r=e.posts_count-1;o=0==r?"Replies":1==r?"Reply":"Replies",a+='
'+e.title+'
'+n+''+r+" "+o+"
",i--}if(0==i)return!1}),$("#blogJson").html(a)})}},GitlabNewProjectsJson={setup:function(t){$.ajax("/json/gitlabnewprojects").then(function(e){var a=e,i="";$.each(a,function(e,a){var n=a.timeago;i+='"}),$("#lastgitprojects").html(i)})}};function showGitUserAvatar(t,e,a){var i=t+"/api/v4/users?username="+e;$.ajax(i).then(function(t){var i=t;$.each(i,function(t,i){$img=$("#avatar_"+e+"_"+a),$img.attr("src",i.avatar_url)})})}var ProductDetailCarousel={setup:function(){$(".carousel-inner img").each(function(t){$(this).on("click",function(){$("#product-main-img-container").hasClass("imgfull")?$("#product-main-img-container").prependTo($("#product-main")):$("#product-main-img-container").prependTo($("#product-page-content")),$("#product-main-img-container").toggleClass("imgfull"),$("#product-main-img-container").toggleClass("imgsmall")})})}},AppimagequestionOnClick={setup:function(t){$("body").on("click","i.appimagequestion",function(t){var e=$("#generic-dialog");e.modal("show"),e.find(".modal-header-text").empty().append("AppImage Info"),e.find(".modal-body").empty().append("")})}},ProductDetailBtnGetItClick={setup:function(t){$("body").on("click","button#project_btn_download",function(e){$.fancybox({hideOnContentClick:!0,autoScale:!0,cyclic:"true",transitionIn:"elastic",transitionOut:"elastic",type:"ajax",helpers:{overlay:{locked:!1}},autoSize:!0,href:"/p/"+t+"/ppload"})})}},GhnsExcludedClick={setup:function(t){$("body").on("click","#ghns_excluded-this-checkbox",function(e){e.stopPropagation();var a=1,i="",n="";this.checked?(a=1,i="Please specify why this product should be excluded (min 5 chars) :",n=" ghns exclude"):(a=0,i="Please specify why this product should be included (min 5 chars) :",n=" ghns include");var o=$("#generic-dialog");return o.modal("show"),o.find(".modal-header-text").empty().append("GHNS "),o.find(".modal-body").empty().append(i+'

"),$("body").on("click","#btn-ghns-excluded",function(){var t=$("#ghns-excluded-text").val();if(t.length<5)return alert("min 5 chars"),!1;var e=$(this).attr("data-projectid"),a=$(this).attr("data-status");$.ajax({url:"/backend/project/doghnsexclude",method:"POST",data:{project_id:e,ghns_excluded:a,msg:t},success:function(t){var e=$("#generic-dialog");0==a?(e.find(".modal-body").empty().append("Project is successfully included into GHNS"),$("#ghns_excluded-this-checkbox").prop("checked",!1)):(e.find(".modal-body").empty().append("Project is successfully excluded into GHNS"),$("#ghns_excluded-this-checkbox").prop("checked",!0)),setTimeout(function(){e.modal("hide")},1e3)},error:function(){alert("Service is temporarily unavailable.")}})}),!1})}},AboutMeMyProjectsPaging={setup:function(){$(window).scroll(function(){if($("footer").offset().top-($(window).scrollTop()+$(window).height())<300){if(!$("button#btnshowmoreproducts").length)return;let t='',e=$("button#btnshowmoreproducts").attr("data-page");$("button#btnshowmoreproducts").remove(),$url=window.location.href,target=$(".about-me-details").find("li.active").find("a").attr("href"),"#user-original-products"==target&&($url+="showoriginal");let a=$("

").append(t).load($url,{projectpage:e},function(t,e,a){if("error"==e)if(401==a.status){if(t){var i=jQuery.parseJSON(t).login_url;window.location=i||"/login"}}else $(target).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.")});$(target).append(a)}})}},AboutMeMyProjectsPagingButton={setup:function(){$("body").on("click","button#btnshowmoreproducts",function(t){let e=$(this).attr("data-page");$(this).remove(),$url=window.location.href,target=$(".about-me-details").find("li.active").find("a").attr("href"),"#user-original-products"==target&&($url+="showoriginal");let a=$("
").append('').load($url,{projectpage:e},function(t,e,a){if("error"==e)if(401==a.status){if(t){var i=jQuery.parseJSON(t).login_url;window.location=i||"/login"}}else $(target).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.
Find out why you may have encountered this error.")});$(target).append(a)})}},ProductDetailCommentTooltip={setup:function(){TooltipUser.setup("tooltipuser","right")}};function generateTooltipster(t,e){$(t).each(function(){$(this).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/member/"+i+"/tooltip/",function(e){var i=e.data,n='
'+i.username+' '+i.countrycity+'
'+i.cntProjects+' products
'+i.totalComments+' comments
Likes '+i.cntLikesGave+' products
Got '+i.cntLikesGot+' Likes
Last time active : '+i.lastactive_at+'
Member since : '+i.created_at+"
";n+="
",t.content(n),a.data("loaded",!0)})}})})}var TooltipUser={setup:function(t,e){$("."+t).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/member/"+i+"/tooltip/",function(e){var i=e.data,n='
'+i.username+' '+i.countrycity+'
'+i.cntProjects+' products
'+i.totalComments+' comments
Likes '+i.cntLikesGave+' products
Got '+i.cntLikesGot+' Likes
Last time active : '+i.lastactive_at+'
Member since : '+i.created_at+"
";n+="
",t.content(n),a.data("loaded",!0)})}})}};function generateTooltipUserPlings(t,e){$(t).each(function(){$(this).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/plings/tooltip/id/"+i,function(e){var i='
';$.each(e.data,function(t,e){if(t>10)return!1;e.profile_image_url.indexOf("http")<0&&(e.profile_image_url="https://cn.opendesktop.org/cache/40x40-2/img/"+e.profile_image_url),e.profile_image_url.indexOf(".gif")>0&&(e.profile_image_url="https://cn.opendesktop.org/img/"+e.profile_image_url),i=i+'
'+e.username+"
"}),i+="
",t.content(i),a.data("loaded",!0)})}})})}var TooltipUserPlings={setup:function(t,e){$("."+t).tooltipster({side:e,theme:["tooltipster-light","tooltipster-light-customized"],contentCloning:!0,contentAsHTML:!0,interactive:!0,functionBefore:function(t,e){var a=$(e.origin),i=a.attr("data-user");!0!==a.data("loaded")&&$.get("/plings/tooltip/id/"+i,function(e){var i='
';$.each(e.data,function(t,e){if(t>10)return!1;e.profile_image_url.indexOf("http")<0&&(e.profile_image_url="https://cn.opendesktop.org/cache/40x40-2/img/"+e.profile_image_url),e.profile_image_url.indexOf(".gif")>0&&(e.profile_image_url="https://cn.opendesktop.org/img/"+e.profile_image_url),i=i+'
'+e.username+"
"}),i+="
",t.content(i),a.data("loaded",!0)})}})}},AboutMePage={setup:function(t){var e=t+"'s Profile "+$(document).prop("title");$(document).prop("title",e)}},InitActiveHashTab={setup:function(){var t=document.location.hash;$('a[href="'+t+'"]')&&$('a[href="'+t+'"]').tab("show")}},AboutmeTab={setup:function(){$("body").on("click","a.aboutmetab",function(t){t.preventDefault();var e=$(this).attr("href"),a=$(this).attr("data-href");0==$(e).find(".product").length&&$(e).append('').load(a,function(){})})}},CommunityTabToplistMemberScrollPaging={setup:function(t,e){$(window).scroll(function(){if($("footer").offset().top-($(window).scrollTop()+$(window).height())<300){if(!$("button#toplistmemberscrollshowmore").length)return;var a=$("button#toplistmemberscrollshowmore").attr("data-page");$("button#toplistmemberscrollshowmore").remove();var i=e+"/nopage/1/page/"+a,n=$('
');$(t).find(".product-list").append(n),$(n).load(i,function(){generateTooltipster($(n).find(".tooltipuser"),"right")})}})}},CommunityTab={setup:function(){$("body").on("click","a.communitytab",function(t){t.preventDefault();var e=$(this).attr("href"),a=$(this).attr("data-href");0==$(e).find(".list").find(".user").length&&$(e).find(".list").append('').load(a,function(){generateTooltipster($(e).find(".tooltipuser"),"right"),$(e).find(".tooltipuserplings").length>0&&generateTooltipUserPlings($(e).find(".tooltipuserplings"),"right"),"#toplistMemberPanel"==e&&CommunityTabToplistMemberScrollPaging.setup(e,a),$(e).find(".opendesktopwidgetpager span").each(function(t){$(this).on("click",function(){$(this).parent().addClass("active").siblings().removeClass("active");var t=a+"/nopage/1/page/"+$(this).html();$(e).find(".product-list").html(""),$(e).find(".product-list").load(t,function(){generateTooltipster($(e).find(".tooltipuser"),"right"),$(e).find(".tooltipuserplings").length>0&&generateTooltipUserPlings($(e).find(".tooltipuserplings"),"right")})})})})});var t=document.location.hash;$('a[href="'+t+'"]').length>0?($('a[href="'+t+'"]').tab("show"),$('a[href="'+t+'"]').trigger("click")):(t="#supportersPanel",$('a[href="'+t+'"]').trigger("click")),$("body").on("mouseenter",".product-thumbnail-startpage",function(){$(this).popover("show")}),$("body").on("mouseleave",".product-thumbnail-startpage",function(){$(this).popover("hide")})}},TagingProduct={setup:function(){$("input[name=tagsuser]").tagify({whitelist:["good","great"],autocomplete:!0}).on("remove",function(t,e){console.log("removed",e)}).on("add",function(t,e){console.log("added",e)})}},TagingProductSelect2={setup:function(){$.fn.select2.amd.require(["select2/selection/search"],function(t){t.prototype.searchRemoveChoice=function(t,e){this.trigger("unselect",{data:e}),this.$search.val(""),this.handleSearch()}},null,!0);var t=$(".taggingSelect2").select2({placeholder:"Add Tags here ...",tags:!0,tokenSeparators:[","," "],minimumInputLength:3,maximumSelectionLength:5,width:"resolve",ajax:{url:"/tag/filter",dataType:"json",type:"GET",delay:500,processResults:function(t){return{results:t.data.tags}}}});t.on("select2:select",function(e){var a=e.params.data;$("#tagsuserselect").attr("data-pid"),t.parent().find("ul.select2-selection__rendered").find("li.select2-selection__choice").length>5?t.find("option[value='"+a.id+"']").remove():(new RegExp("^[0-9A-Za-z_.-]+$").test(a.text)||(t.find("option[value='"+a.id+"']").remove(),alert("Must be letter or number and can include hyphens")),a.text.length>10&&(t.find("option[value='"+a.id+"']").remove(),alert("Max. length 45 chars")))})}},TagingProductDetail={setup:function(){TagingProductDetailSelect2.setup(),$("body").on("click","button.topic-tags-btn",function(t){if($(this).toggleClass("Done"),$(".product_category").find(".usertagslabel").remove(),$(".tagsuserselectpanel").toggle(),"Done"==$(this).text()){$(this).text("Manage tags");var e="",a=$("li.select2-selection__choice");$.each(a,function(t,a){e=e+''+a.title+""}),$(".product_category").find(".topicslink").html(e)}else $(this).text("Done")})}},TagingProductDetailSelect2={setup:function(){$.fn.select2.amd.require(["select2/selection/search"],function(t){t.prototype.searchRemoveChoice=function(t,e){this.trigger("unselect",{data:e}),this.$search.val(""),this.handleSearch()}},null,!0);var t=$("#tagsuserselect").select2({placeholder:"Input tags please...",tags:!0,minimumInputLength:3,closeOnSelect:!0,maximumSelectionLength:5,tokenSeparators:[","," "],ajax:{url:"/tag/filter",dataType:"json",type:"GET",delay:500,processResults:function(t){return{results:t.data.tags}}}});t.on("select2:select",function(e){var a=e.params.data,i=$("#tagsuserselect").attr("data-pid");$.post("/tag/add",{p:i,t:a.id}).done(function(e){"error"==e.status?($("span.topic-tags-saved").css({color:"red"}).html(e.message).show().delay(2e3).fadeOut(),t.find("option[value='"+e.data.tag+"']").last().remove()):$("span.topic-tags-saved").css({color:"green"}).html(' Saved').show().delay(1e3).fadeOut()})}),t.on("select2:unselect",function(t){var e=t.params.data,a=$("#tagsuserselect").attr("data-pid");$.post("/tag/del",{p:a,t:e.id}).done(function(t){console.log(t),$("span.topic-tags-saved").css({color:"green"}).html(''+t.message).show().delay(1e3).fadeOut()})})}},TagingLoopMyProducts={setup:function(){TagingLoopMyProductsSelect2.setup(),$("body").on("click","button.topic-tags-btn",function(t){if($(this).toggleClass("Done"),$(this).parent().find(".topicsuser").html(""),$(this).parent().find(".tagsuserselectpanel").toggle(),"Done"==$(this).text()){$(this).text("Manage tags");var e="",a=$(this).parent().find("li.select2-selection__choice");$.each(a,function(t,a){e=e+''+a.title+""}),$(this).parent().find(".topicsuser").html(e)}else $(this).text("Done")})}},TagingLoopMyProductsSelect2={setup:function(){$.fn.select2.amd.require(["select2/selection/search"],function(t){t.prototype.searchRemoveChoice=function(t,e){this.trigger("unselect",{data:e}),this.$search.val(""),this.handleSearch()}},null,!0);var t=$(".taggingSelect2").select2({placeholder:"Input tags please...",tags:!0,minimumInputLength:3,closeOnSelect:!0,maximumSelectionLength:5,tokenSeparators:[","," "],ajax:{url:"/tag/filter",dataType:"json",type:"GET",delay:500,processResults:function(t){return{results:t.data.tags}}}});t.on("select2:select",function(e){var a=e.params.data,i=$(this).attr("id").replace("tagsuserselect","");$.post("/tag/add",{p:i,t:a.id}).done(function(e){"error"==e.status?($("#topic-tags-saved"+i).css({color:"red"}).html(e.message).show().delay(2e3).fadeOut(),t.find("option[value='"+e.data.tag+"']").last().remove()):"existing"==e.status?$("#topic-tags-saved"+i).css({color:"red"}).html(e.message).show().delay(2e3).fadeOut():$("#topic-tags-saved"+i).css({color:"green"}).html(' Saved').show().delay(1e3).fadeOut()})}),t.on("select2:unselect",function(t){var e=t.params.data,a=$(this).attr("id").replace("tagsuserselect","");$.post("/tag/del",{p:a,t:e.id}).done(function(t){$("#topic-tags-saved"+a).css({color:"green"}).html(''+t.message).show().delay(1e3).fadeOut()})})}},productRatingToggle={setup:function(){$("#showRatingAll").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".productRating-rows-inactive").show()}),$("#showRatingActive").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".productRating-rows-inactive").hide()}),$("#showRatingUpvotes").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".clsDownvotes").hide(),$(".productRating-rows-inactive").hide()}),$("#showRatingDownvotes").on("click",function(){$("#ratings-panel").find(".spinning").show(),setTimeout(function(){$("#ratings-panel").find(".spinning").hide()},500),$(".btnRateFilter").removeClass("activeRating"),$(this).addClass("activeRating"),$(".productRating-rows").show(),$(".productRating-rows-inactive").hide(),$(".clsUpvotes").hide()})}},FilterBrowseOriginalFn={setup:function(){$("body").on("click","input#filter_browse_original",function(t){var e=$(this).is(":checked"),a=window.location.href;a.indexOf("browse")<0&&(a+="/browse/"),a.indexOf("filteroriginal")>0&&(a=a.substring(0,a.indexOf("filteroriginal"))),window.location.href=e?a+"filteroriginal/1":a+"filteroriginal/0"})}},FilterBrowseTagGroupFn={setup:function(){$("body").on("change","select.filter_browse_tag_group",function(t){var e=$(this).val(),a=$(this).attr("data_group_id");$.ajax({url:"/explore/savetaggroupfilter?group_id="+a+"&tag_id="+e,cache:!1}).done(function(t){var e=window.location.href;window.location.href=e})})}},PagedetailModeratorDeprecated={setup:function(t){if(0==$("#product-deprecated-checkbox").length)return!1;$("body").on("click","#product-deprecated-checkbox",function(e){e.stopPropagation();var a=$(this).is(":checked"),i=0,n="/backend/project/dodeprecated?project_id="+t+"&product_deprecated="+(i=a?1:0);$.ajax({url:n,success:function(t){0==i?(alert("Project deprecated is successfully removed"),$("#product-deprecated-checkbox").prop("checked",!1)):(alert("Project is successfully marked as deprecated"),$("#product-deprecated-checkbox").prop("checked",!0))},error:function(){alert("Service is temporarily unavailable.")}})})}}; \ No newline at end of file