This repository has been archived on 2022-07-01. You can view files and clone it, but cannot push or open issues or pull requests.
-/Download/​​​ A Mathematical Curiosity_files/cmty_core.js

8 lines
655 KiB
JavaScript

AoPS.hasOwnProperty("Community")||(AoPS.Community={}),AoPS.Community.Constants={base_url:"https://"+location.hostname,community_main_color:"#009fad",community_secondary_color:"#dae7f6",privates_main_color:"#009fad",privates_secondary_color:"#dae7f6",time_limits:{watched_times_short:3600,watched_times_long:21600},max_times_to_watch:{watched_times_short:1e3,watched_times_long:1500},very_large_time:6e9,old_topic_age_in_seconds:43200,intervals:{current:{new_item_check_interval:12e4,new_item_check_interval_long:24e4,topic_update_interval:6e4,topic_update_interval_long:3e5,reported_posts_interval:2e4,watchers_updates_check_interval:3e5,fetch_forum_users_interval:3e5,put_community_to_sleep_limit:12e5},active:{new_item_check_interval:12e4,new_item_check_interval_long:24e4,topic_update_interval:6e4,topic_update_interval_long:3e5,reported_posts_interval:2e4,watchers_updates_check_interval:3e5,fetch_forum_users_interval:3e5,put_community_to_sleep_limit:12e5},slow:{new_item_check_interval:24e4,new_item_check_interval_long:48e4,topic_update_interval:12e4,topic_update_interval_long:6e5,reported_posts_interval:12e4,watchers_updates_check_interval:6e5,fetch_forum_users_interval:6e5,put_community_to_sleep_limit:9e5},disabled:{new_item_check_interval:2147483647,topic_update_interval:2147483647,topic_update_interval_long:2147483647,reported_posts_interval:2147483647,watchers_updates_check_interval:2147483647,fetch_forum_users_interval:2147483647}},idle_monitor_interval:1e3,fetch_office_hours_interval:3e4,moment_offset:0,base_delay_internet_issue:10,time_limit_for_calendar_style:172800,time_limit_edit_own:1209600,time_limit_delete_own:1209600,watched_times_short_interval:59800,watched_times_long_interval:1200137,UNUSED_new_item_check_interval:60103,UNUSED_new_item_check_interval_short:60103,UNUSED_new_item_check_interval_long:240103,UNUSED_topic_update_interval:38741,UNUSED_topic_update_interval_long:218741,UNUSED_reported_posts_interval:20341,UNUSED_watchers_updates_check_interval:195091,UNUSED_fetch_forum_users_interval:81137,phone_mode_max_width:768,min_preview_height:320,min_draggable_reply_height:290,min_posts_window_height:50,min_stupid_view_reply_textarea:50,max_conversation_participants:10,max_forums_user_update:50,min_topic_list_initial_length:6,max_num_shown_topics:78,num_topics_to_hide:20,num_topics_to_reveal:10,master_category_id:2,portal_category_id:89,private_messages_id:1,aops_forums_id:11,other_forums_id:9,olympiad_forum_id:6,college_math_forum_id:7,recycle_bin_id:22,blog_recycle_bin_id:104,aops_videos_id:64,aops_wiki_id:65,aops_blogroll_id:88,halp_user_id:10,unsearchable_fora:[50,63],essential_tags_olympiad:["algebra","geometry","combinatorics","number theory","inequalities","imo"],essential_tags_college:["calculus","real analysis","linear algebra","superior algebra","complex analysis","advanced fields","probability and stats","number theory","topology","putnam","college contests"],private_archive_url:"/my-messages-archive/",reply_jump_to_bottom_window:100,move_topic_quick_links:{3:[4,5,6,7],4:[3,5,6,7],5:[3,4,6,7],6:[3,4,5,7],7:[3,4,5,6]},min_topic_title_length:8,max_topic_title_length:80,max_tags_per_topic:7,min_poll_question_length:8,max_poll_question_length:255,min_post_length:8,max_post_length:4e4,max_source_length:128,posting_ajax_timeout:6e4,posting_warn_limit:20,time_hack_nudge:2e4,new_topic_modal_delay:1200,new_reply_modal_delay:1200,message_readability_delay:1200,message_readability_delay_short:1200,num_posts_to_fetch:20,topic_move_length_limit:250,user_path:"/community/user/",max_shout_length:255,itembox_input_width:150,max_categories_to_load:10,category_autocomplete_width:275,tag_autocomplete_width:250,num_users_whois_online:120,profile_field_length_limit:120,min_password_length:4,max_password_length:128,max_avatar_file_size:24,max_attachment_size:512,max_attachments_per_post:3,default_avatar:"//avatar.artofproblemsolving.com/no-avatar.png",attachment_path:AoPS.bootstrap_data.cmty_attachment_path,max_length_feed_list_read_check:100,view_post_max_label_len:12,view_post_max_hide_label_len:255,can_oneclick_ban:[1163,29411,225249,267794],max_category_name_length:50,min_category_name_length:3,max_category_description_length:240,max_blog_comments_text_length:40,cat_admin_save_input_delay:1e3,categories_with_private_roles:["forum","forum_class","blog"],monitor_tags:[{item_id:6,item_text:"/not_monitored"},{item_id:5,item_text:"/closed"},{item_id:4,item_text:"/open"}],monitoring_tag_id_array:[4,5,6],monitored_topic_tag_ids:{open:4,closed:5,not_monitored:6},phone_more_topics_sensitivity:150,phone_more_posts_sensitivity:150,bbCode:{smileys:[[":D","icon_mrgreen.gif"],[":blush:","redface_anim.gif"],[":maybe:","unsure.gif"],[":-D","biggrin.gif"],[":)","smile.gif"],[":(","sad.gif"],[":o","ohmy.gif"],[":mad:","mad.gif"],[":P","tongue.gif"],[":oops:","blush.gif"],[":roll:","rolleyes.gif"],[";)","wink.gif"],[":!:","exclaim.gif"],[":idea:","idea.gif"],[":arrow:","icon2.gif"],[":|","mellow.gif"],[":rotfl:","rotfl.gif"],[":huh:","huh.gif"],[":ninja:","ph34r.gif"],[":no:","sleep.gif"],[":love:","wub.gif"],[":wacko:","wacko.gif"],[":what?:","blink.gif"],[":alien:","alien_grn.gif"],[":cool:","cool.gif"],[":first:","first.gif"],[":dry:","dry.gif"],[":laugh:","laugh.gif"],[":coolspeak:","coolspeak.gif"],[":oops_sign:","oops.gif"],[":whistling:","whistling.gif"],[":yinyang:","yinyang.gif"],[":w00t:","w00t.gif"],[":pilot:","plane.gif"],[":play_ball:","play_ball.gif"],[":police:","police.gif"],[":read:","read.gif"],[":showoff:","showoff.gif"],[":sleep2:","sleep2.gif"],[":sleeping:","sleeping.gif"],[":spam:","spam.gif"],[":spidy:","spidy.gif"],[":starwars:","starwars.gif"],[":stink:","stink.gif"],[":stretcher:","stretcher.gif"],[":cleaning:","suck_kr.gif"],[":surf:","surfing.gif"],[":surrender:","surrender.gif"],[":thumbup:","thumbup.gif"],[":trampoline:","trampoline.gif"],[":w00tb:","w00tbrows.gif"],[":wallbash:","wallbash.gif"],[":wallbash_red:","wallbash_red.gif"],[":weightlift:","weightlift.gif"],[":welcome:","welcome.gif"],[":welcomeani:","welcomeani.gif"],[":winner_first:","winner_first_h4h.gif"],[":winner_second:","winner_second_h4h.gif"],[":winner_third:","winner_third_h4h.gif"],[":wow:","wow.gif"],[":huuh:","wtf.gif"],[":yankchain:","yankchain.gif"],[":yup:","yes3.gif"],[":10:","10.gif"],[":heli:","heli.gif"],[":agent:","agent.gif"],[":bomb:","bomb.gif"],[":bruce:","bruce_h4h.gif"],[":bye:","byebye.gif"],[":censored:","censored.gif"],[":chief:","chieftain.gif"],[":clap:","clap.gif"],[":clap2:","clap2.gif"],[":coool:","cool1.gif"],[":ddr:","ddr.gif"],[":diablo:","diablo.gif"],[":evilgrin:","evilgrin.gif"],[":ewpu:","ewpu.gif"],[":flex:","flex.gif"],[":fool:","fool.gif"],[":football:","football.gif"],[":furious:","furious.gif"],[":gathering:","gathering.gif"],[":gleam:","gleam.gif"],[":harhar:","harhar.gif"],[":help:","helpsmilie.gif"],[":icecream:","icecream.gif"],[":juggle:","juggle[1].gif"],[":jump:","jump.gif"],[":moose:","mf_moose.gif"],[":nhl:","nhl.gif"],[":noo:","no.gif"],[":omighty:","notworthy.gif"],[":yoda:","yoda.gif"]],font_colors:["#f00","#ff9a00","#ff0","#0f0","#0ff","#00f","#9a00ff","#f0f","#600","#783F04","#7f6000","#274E13","#0C343D","#073763","#20124D","#4C1130","#960000","#B45F06","#BF9000","#38761D","#134F5C","#0B5394","#351C75","#741B47","#c00","#E69138","#F1C232","#6AA84F","#45818E","#3D85C6","#674EA7","#A64D79","#E06666","#F6B26B","#FFD966","#93C47D","#76A5AF","#6FA8DC","#8E7CC3","#C27BA0","#EA9999","#F9CB9C","#FFE599","#B6D7A8","#A2C4C9","#9FC5E8","#B4A7D6","#D5A6BD","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#CFE2F3","#D9D2E9","#EAD1DC","#000","#222","#444","#666","#888","#aaa","#ccc","#eee"]},special_collections_id:12,office_hours_ids:[433798],BIG:1e8};
;AoPS.Community.Lang={"Add-Note":"Add Note",Admin:"Admin",Administrators:"Administrators",At:"At","Back-to":"Back to",Banned:"Banned",blog:"blog",Bookmarks:"Bookmarks",Build:"Build",by:"by",By:"By",cancel:"cancel",Cancel:"Cancel",collection:"collection","command-click":"command-click",Community:"Community",Contributors:"Contributors","control-click":"control-click",Conversations:"Conversations",create:"create",Create:"Create",Custom:"Custom","data-saved":"Data saved!","data-saved-reload":"Data saved! You will see your changes when you reload the community",Delete:"Delete",Email:"Email","Enter-username":"Enter username",FAQ:"Help",Flyout:"Flyout",forum:"forum",Forum:"Forum",Full:"Full",in:"in",Info:"Info",information:"information",IP:"IP","logged-out":"You have been signed out. Please sign back in and try again.","Login/Join":"Login / Join",Message:"Message",Messages:"Messages",Mod:"Mod",Modal:"Modal",Moderators:"Moderators",MyAoPS:"My AoPS",no:"No",No:"No",NO:"NO",None:"None",Note:"Note",Notes:"Notes","permanent-link":"Permanent Link",Popup:"Pop-up",Private:"Private","Private-Messages":"Private Messages","Private-Message-Search":"Private Message Search",Profile:"Profile",Public:"Public",Readers:"Readers",Reason:"Reason",Reset:"Reset",Save:"Save",saved:"saved","saving-blocker":"Saving data... Back soon.",SEARCH:"SEARCH","search-no-match":"Nothing matches your input.",Search:"Search","Search-Results":"Search Results",Short:"Short",Submit:"Submit",Subscribe:"Subscribe",Tag:"Tag",Tall:"Tall","unexpected-error-code":"There has been an unexpected error. Please contact tech-support@aops.com and tell them exactly\t\t what you were doing to trigger this, and include this magic code: ","unexpected-logout":"You have been signed out\t\t\t\t\tby nefarious computer gremlins. If you are in the middle\t\t\t\t\tof entering text, you should copy your work before logging back in.",Users:"Users",Unsubscribe:"Unsubscribe",Username:"Username",views:"views",viewing:"viewing",view:"view",Welcome:"Welcome",yes:"Yes",Yes:"Yes",YES:"YES","month-01":"January","month-02":"February","month-03":"March","month-04":"April","month-05":"May","month-06":"June","month-07":"July","month-08":"August","month-09":"September","month-10":"October","month-11":"November","month-12":"December","admin-validation":'<div>Enter magic admin phrase<br><input name="admin-validate" type="password"></input></div>',"admin-validate-failed":"Validation failed","ajax-error-delay":"Error talking to the server. Check your internet connection. We'll try again in {0} seconds.","ajax-error-E_AJAX_UNKNOWN":"An error has occurred that is preventing your computer from connecting to the \t\tAoPS site. Please check your internet connection and then refresh the page. If you are working on something, please save your work \t\tbefore refreshing.","user-item-online":'<span class="cmty-user-online">Online</span>',"invalid-user":"The username <b>{0}</b> is not a valid username.","tag-tooltip-forum":"In forum: ","error-timeout":"The server has timed out while working on your request. Please\t\trefresh the page to see if it finished what it was supposed to do before so\t\tignominiously giving up.","err-no-such-session":"Sorry, your session appears to have changed, so you must refresh \t\tyour browser before continuing to use the site. This can happen when you \t\tare logged in to Art of Problem Solving on multiple tabs of the same browser, and then \t\tsign out on one of those tabs. Please refresh your browser after saving any work you have \t\tin progress.","err-dropzone-fallback":"Sorry, attaching documents in our community is not supported by your browser. Please choose another browser.","err-unknown":"Unknown error occurred. Here's the code they gave me: <b>{0}</b>.","err-no-permission":"Sorry, you do not have permission to perform this action.","editable-length-limit-exceeded-on-paste":"You pasted too much! I'm cutting some out.","user-list-validation-blocker":"Validating username...","err-bookmark-limit-reached":"Bookmark limit reached. This item was not bookmarked.","err-community-disabled":AoPS.bootstrap_data.hasOwnProperty("community_inactive_message")?AoPS.bootstrap_data.community_inactive_message:"Sorry, but the community is currently disabled. Please try again later.","category-deleted":"The page you are viewing has just been deleted. Sorry about that. \t\tI'm going to take you back to the front of the community.","please-wait":"Hold on a sec while I take care of this.","private-search-results":"Private Message Search Results","unwatch-success":"Unwatch successful. You will no longer receive email notifications regarding this {0}. It will miss you. This {0} is \t\tstill bookmarked, but you won't receive email notifications any more.","cmty-itembox-loader":"Loading more...","my-profile-home":"My AoPS","initial-fetch-err-E_SEARCH_SERVER_INACTIVE":"Sorry, the search server is down right now. We're working on it.","initial-fetch-err-E_BAD_SEARCH_QUERY":'Sorry, you sent the search server something that it cannot parse. Please try something different. \t\t<a href="/community/search" data-cmty>Click here</a> to go to the Advanced Search page. ',"initial-fetch-err-E_DONT_KNOW_CHARACTERS":'Sorry, your search term only includes special characters that our search engine ignores. \t\t<a href="/community/search" data-cmty>Click here</a> to go to the Advanced Search page.',"initial-fetch-blog-err-E_SEARCH_SERVER_INACTIVE":"Sorry, the search server is down right now. We're working on it.","initial-fetch-blog-err-E_BAD_SEARCH_QUERY":'Sorry, you sent the search server something that it cannot parse. Please try something different. \t\t<a href="/community/c{0}">Click here</a> to go back to the blog. ',"initial-fetch-blog-err-E_DONT_KNOW_CHARACTERS":'Sorry, your search term only includes special characters that our search engine ignores. \t\t<a href="/community/c{0}">Click here</a> to go back to the blog.',"initial-fetch-blog-err-E_AJAX_TIMEOUT":"Sorry, your request for blog posts is taking too long. Please try again in a bit.","topic-fetch-err-E_SEARCH_SERVER_INACTIVE":"Sorry, the search server is down right now. We're working on it.","initial-fetch-err-E_AJAX_TIMEOUT":"Sorry, your request for community topics is taking too long. Please try again in a bit.","topic-fetch-err-E_AJAX_TIMEOUT":"Sorry, your request for more topics is taking too long. Please try again in a bit.","topic-fetch-err-E_WRONG_TYPE":"Invalid type provided. Must be positive integer.","community-asleep":"The AoPS Community has gone to sleep due to inactivity. \t\tIf you are in the middle of working on something, \t\tthen we recommend that you close this message and save your work on your own computer before \t\trefreshing the page to reactivate the Community.","community-asleep-reminder":"The AoPS Community has gone to sleep due to prior inactivity. Please \t\trefresh the page to reactivate the community.","community-asleep-save":"The AoPS Community has gone to sleep due to inactivity. \t\tIf you are in the middle of working on something, \t\tthen we recommend that you close this message and save your work on your own computer before \t\trefreshing the page to reactivate the Community.","community-asleep-session":"The AoPS Community has gone to sleep due to a session error. \t\tIf you are in the middle of working on something, \t\tthen we recommend that you close this message and save your work on your own computer before \t\trefreshing the page to reactivate the Community.","community-asleep-reminder-session":"The AoPS Community has gone to sleep due to a session error. Please \t\trefresh the page to reactivate the community.","community-asleep-save-session":"The AoPS Community has gone to sleep due to a session error. \t\tIf you are in the middle of working on something, \t\tthen we recommend that you close this message and save your work on your own computer before \t\trefreshing the page to reactivate the Community.","view-pdf-tooltip":"View as PDF","router-err-topic-deleted":"You have requested a topic that has been deleted. I am not into dumpster-diving, so I can't get the topic for you.","router-err-no-topic":"You have requested a topic that does not exist. Perhaps it never existed. Perhaps it was deleted. Perhaps I'm just tired and don't feel like looking for it. These AoPS people work me like a dog.","router-err-no-perms-logged-in":"You have requested a top secret page for which you have not received security clearance. Sorry about that. Perhaps if you do 10 push-ups, I will let you in.","router-err-no-perms-logged-out":'You have requested a top secret page for which you have not received security clearance. Or maybe you have clearance, but you are not signed in. <a class="cmty-login">Click here to sign in</a>.',"router-err-no-such-category":"I looked and looked, and looked some more. I'm afraid that the page you requested does not exist.","router-err-no-such-user":"I looked and looked, and looked some more. I'm afraid that the user you requested does not exist.","router-err-no-perms":"You do not have permission to view this page."+(AoPS.session.logged_in?"":' This may be because you are not signed in! <a class="cmty-login">Click here to sign in</a>.'),"router-err-no-post":"You have requested a post that does not exist. Maybe it was deleted. Maybe it never existed in the first place. At any rate, I cannot find it. Sorry about that.","router-err-not-logged-in":'You are not signed in to AoPS. You cannot access this page unless you are logged in. <a class="cmty-login">Click here to sign in</a>.',"router-err-cat-admin-no-create-type":"You cannot create a category of type ","router-err-not-participant":"You are not a participant of this private conversation.","router-err-unwatch-E_NO_HASH_FOUND":"Sorry, this link has expired. That makes me sad, too.","router-edit-profile-crumb":"Edit Profile and Account","router-edit-settings-crumb":"Edit Community Settings","breadcrumbs-reported-posts":"Reported Posts","breadcrumbs-tag-info":"Tags","breadcrumbs-terms":"Terms->Tags Map","breadcrumbs-tagmap":"Tags->Terms Map","breadcrumbs-log":"Log: Be careful, yo","master-other-forums":"Other Forums and Collections ","master-whois-title":"Who is online?","master-whois-FAQ-link":"Help","master-statistics-title":"Statistics:","master-statistics-data":"Total posts: <b>{0}</b> | Total topics: <b>{1}</b> | Total members: <b>{2}</b>","master-whois-dataline":"There are <b>{0}</b> users online, including the <b>{1}</b> registered members listed below and {2} other hidden registered users.","master-registered-online":"Registered users online: ","master-collections-modal-title":"What Are Collections and Other Forums?","master-whois-memberlist-link":"View Memberlist","master-featured-content":"Featured Content ","portal-featured-help-title":"Feature Olympiad Content","portal-extra-content":"Other Forums and Collections ","portal-extra-help-title":"Other Forums and Collections","portal-extra-note":"","portal-extra-logged-in":' <a data-cmty href="/community/edit-settings">Click here</a> to visit your \t\tCommunity settings page, where you can set your default Community homepage view.',"folder-empty-bookmark_forums":"You have no forums bookmarked. Bookmarked forums will appear on this page.","folder-empty-bookmark_users":"You have no users bookmarked.","folder-empty-folder":"Nothing here yet!","folder-empty-folder_forums":"Nothing here yet!","folder-empty-folder_collections":"Nothing here yet!","folder-empty-blogroll":"No blogs here yet!","folder-empty-my_forums":"No forums here... Yet!","folder-empty-my_blogs":"No blogs here... Yet!","folder-empty-my_collections":"No collections here... Yet!","folder-empty-view_posts":"No posts here yet!","cat-cell-no-perm-start-topic":"You do not have permission to start a topic in this forum.","cat-cell-no-perm-limited-user":'You have a limited account, so you cannot post new topics or replies. \t\tYou can upgrade your account for free <a href="/user/upgrade.php">here</a>.',"cat-cell-new-topic":"New Topic","cat-cell-new-message":"New Message","cat-cell-mark-read":"Mark All Read","cat-cell-topic":"topic","cat-cell-topics":"topics","cat-cell-post":"post","cat-cell-posts":"posts","cat-cell-user":"user","cat-cell-users":"users","cat-cell-num-user-title":"Number of users viewing a topic in this\n forum in the last five minutes.","cat-cell-no-tag-match":"No tags match your search","cat-cell-filter-placeholder":"Filter by tag","cat-cell-mark-read-title":"Mark all topics in this forum read","cat-cell-bookmark-title":"Bookmark this ","cat-cell-new-topic-title":"Post a new topic to this forum","cat-cell-new-pm-title":"Write a new private message","cat-cell-more-options-title":"More options","cat-cell-create-collection":"Create Collection","cat-cell-help-title":"Learn more about this page","cat-cell-no-tags-yet":" No tags here yet!","cat-cell-no-posts-yet":" No posts here yet!","cat-cell-no-items-yet":" Nothing here yet!","cat-cell-search-forum":"Search this forum","cat-cell-search-pm":"Search private messages","cat-cell-forum-locked-title":"This forum is locked.","cat-cell-forum-locked-title-mod":"This forum is locked, but you can post here because you are special.","cat-cell-Locked":"Locked","cat-cell-locked-modal":"This forum is currently locked, so you cannot post new topics here right now.","cat-cell-tag-view-topics":"Topics with these tags","cat-cell-forum-view-topics":"Topics in these forums","cat-cell-forum-topics":"Topics in this forum","cat-cell-tags-title":"Tags in this forum","cat-cell-items-title-tag-view":"Tags in this collection","cat-cell-items-title-tag-bookmark":"Tags that I have bookmarked","cat-cell-items-title-forum-view":"Forums in this collection","cat-cell-items-title-forum-bookmark":"Forums that I have bookmarked","cat-cell-no-users-bookmarked":"You have no users bookmarked yet!","cat-cell-view_tags-help-title":"About Tag Collections","cat-cell-view_topics-help-title":"About Topic Collections","main-crumb-search-placeholder":"Search Community","main-crumb-advanced-search":"Advanced search","cat-search-placeholder-9":"Search Forums","cat-search-placeholder-12":"Search Collections","tagbox-not-logged-in":"You must be signed in to edit a topic's tags.","tagbox-no-permission":"You do not have permission to edit tags of topics in this forum.","tagbox-new-user":"Once you have been a member of the AoPS Community for at least two weeks, you will be able \t\tto edit the tags of existing topics.","bookmark-not-logged-in":"When you are signed in to AoPS, you will be able to bookmark topics, tags, forums, and users.","bookmark-remove":"Remove","bookmark-follow":"Bookmark","bookmark-limited-user":'You have a limited account, so you cannot bookmark items on the site. \t\tYou can upgrade your account for free <a href="/user/upgrade.php">here</a>, and then you \t\twill be able to bookmark items.',"bookmark-modal-topic":', you are bookmarking the topic "<b>{0}</b>" in the forum <b>{1}</b>. ',"bookmark-modal-tag":', you are bookmarking the tag "<b>{0}</b>" in the forum <b>{1}</b>. ',"bookmark-modal-forum":", you are bookmarking the forum <b>{0}</b>. ","bookmark-remove-user-title":"Remove this user from Bookmarked Users","bookmark-user-title":"Add this user to Bookmarked Users","bookmark-modal-title":"Bookmark ","bookmark-modal-title-tag":"Bookmark Tag","bookmark-modal-title-topic":"Bookmark Topic","bookmark-modal-title-forum":"Bookmark Forum","bookmark-modal-info-text":"All of your bookmarks are available on your My AoPS page.\t\tYou may also choose to add bookmarked items to your feed and/or receive email notifications.","bookmark-modal-info-text-academy":" You may choose to add bookmarked items to your feed and/or receive email notifications.","bookmark-modal-feed":"Add this to my feed.","bookmark-modal-email":"Email me when this gets a new ","bookmark-modal-email-tag":"Email me when a new topic gets this tag.","bookmark-modal-email-topic":"Email me when this topic gets a new post.","bookmark-modal-email-forum":"Email me when there is a new post or topic in this forum.","bookmark-modal-cancel":"CANCEL","bookmark-modal-ok":"ADD BOOKMARK","bookmark-no-forums-bookmarked":"You have no forums bookmarked!","bookmark-no-tags-bookmarked":"You have no tags bookmarked!","bookmark-no-topics-bookmarked":"You have no topics bookmarked!","bookmark-tag-tooltip":"Bookmark this tag (subscribe)","remove-bookmarked-tag-tooltip":"Remove tag from bookmarks (unsubscribe)","mod-topic-title":"Moderate Topic","mod-topic-move":"Move Topic","mod-topic-unlock":"Unlock Topic","mod-topic-lock":"Lock Topic","mod-topic-delete":"Delete Topic","mod-topic-hard-delete":"Hard Delete Topic","mod-topic-announce":"Make Announcement","mod-topic-global":"Make Global Announcement","mod-topic-normal":"Make Normal Topic","mod-topic-add-target":"Add Target Url","mod-topic-replace-target":"Replace Target Url","mod-topic-remove-target":"Remove Target Url","mod-topic-add-hidden":"Add Hidden Tag","mod-topic-hidden-tags":"Hidden Tags","mod-topic-log":"View Log","mod-topic-lock-warning":"Are you really sure you want to lock this topic?","mod-topic-soft-delete-warning":"Are you really sure you want to delete this topic?","mod-topic-hard-delete-warning":"Are you really sure you want to hard delete this topic?\t\tThis will completely wipe out all posts. It is irreversible.","mod-topic-lock-title":"Lock Topic","mod-topic-soft-delete-title":"Delete Topic","mod-topic-hard-delete-title":"Hard Delete Topic","mod-topic-lock-pending":"Hold on a sec while I find the key.","mod-topic-delete-pending":"Hold on a sec while I take out the trash.","mod-topic-delete-err-E_NO_PERMISSION":"You do not have permission to delete this topic.","mod-topic-delete-err-E_NOT_LOGGED_IN":"Ack! You are no longer signed in. You'll have to sign in again to delete this topic.","mod-topic-delete-err-E_TOPIC_TOO_LONG":"You do not have permission to move long topics. \t\tIf you wish to move or delete this topic, use the Report Topic functionality to report the \t\ttopic to site admins.","mod-long-topic-admin-warning":"You should not move or delete long topics during class time or \t\twhen the site is very busy. Are you sure you want to move or delete this?","mod-long-topic-admin-OK":"YES I AM SURE","mod-long-topic-admin-no":"No - do nothing","mod-topic-set-announce-through":"Last date of announcement (leave blank for none):","mod-topic-move-title":"Move Topic","mod-topic-move-input-heading":"Move To: ","mod-topic-move-quick":"Quick move: ","mod-topic-move-in-progress":"Moving crew at work, hold on a minute.","mod-topic-move-err-E_NO_PERMISSION":"You do not have permission to move this topic.","mod-topic-move-err-E_NOT_LOGGED_IN":"Ack! You are no longer signed in. You'll have to sign in again to move this topic.","mod-topic-move-err-E_NO_MOVE_TO_LOCKED":"Your target forum is locked. The topic has not been moved.","mod-topic-move-err-E_ALREADY_MOVED":"Someone just beat you to it! They already moved this topic. I won't ruin the suspense and tell you where they moved it. Hit refresh to find out!","mod-topic-move-err-E_MAX_ANNOUNCEMENTS":"Sorry, your target forum already has the maximum number of announcements.","mod-topic-move-err-E_TOPIC_TOO_LONG":"You do not have permission to move or delete long topics. \t\tIf you wish to move or delete this topic, use the Report Topic functionality to report the \t\ttopic to site admins.","mod-topic-announce-err-E_NO_PERMISSION":"You do not have permission to change the announce status of this topic.","mod-topic-announce-err-E_MAX_ANNOUNCEMENTS":"Sorry, this forum already has the maximum number of announcements.","mod-topic-announce-err-E_NOT_LOGGED_IN":"Ack! You are no longer signed in. You'll have to sign in again to change the announcement status of this topic.","mod-topic-remove-target-confirm":"Are you sure you wish to remove the link between this topic \t\t and an object on the site? ","mod-topic-remove-target-extra":"This operation will also remove all hidden tags, so you will have to \t\t re-add any hidden tags you wish to keep.","mod-topic-remove-target-with-text":"Are you sure you wish to remove the link between this topic and {0}? ","mod-topic-remove-target-blocker":"Hold on while I take care of this target for you. Back in a sec.","mod-topic-edit-target-instructions":'Edit the target URL by entering the new target below. When a topic \t\talready has a target, I\'ll give you that URL as a hint. Please make sure you know what you \t\tare doing before using this. Richard will make you do 10 push-ups if you screw up here. Note: \t\ta restricted tag is one that has permissions attached. Think "discussions attached to solutions \t\tto homework problems." <b>Entering a blank URL here will not delete the current target.</b> \t\tThis operation will also remove all hidden tags, so you will have to \t\t re-add any hidden tags you wish to keep.',"mod-topic-edit-target-url":"New Target:","mod-topic-edit-target-text":"New Target Descriptor:","mod-topic-edit-target-is-restricted":"Check if target is restricted:","mod-topic-hidden-tag-instructions":"Enter text below. Make sure you know what you're doing \t\tbefore using this. Or maybe shortly after using this.","mod-topic-hidden-tag-text":"Tag text: ","mod-topic-hidden-tag-is-restricted":"Check if tag is restricted: ","mod-topic-hidden-tag-blocker":"Adding tag; back in a sec...","mod-topic-no-state-tags":"You cannot add state tags here.","mod-topic-announce-blocker":"Setting announcement status of this topic.","topics-list-no-more-items":"No more topics!","topics-list-no-items-at-all":"No topics here!","topics-list-no-more-items-office-hours-default":"","topics-list-no-more-items-office-hours":"No more topics!","topics-list-no-items-at-all-office-hours":"No topics here! Remember to click 'Done Halping' before leaving the page.","topics-list-no-more-privates":"No more private messages.","topics-list-no-privates":"No private messages here!","topics-list-nothing-bookmarked":"Nothing bookmarked!","topic-cell-moved-topic":"THIS TOPIC HAS MOVED; CLICK HERE TO GO TO ITS NEW LOCATION.","topic-cell-recycled-topic":"THIS TOPIC HAS BEED DELETED; CLICK HERE TO VIEW IN RECYCLE BIN.","topic-cell-reading-now":"Reading now: ","topic-cell-reply":"reply","topic-cell-replies":"replies","topic-cell-no-replies":"0 replies","topic-cell-title-close":"Close topic","topic-cell-title-settle":"Settle reports","topic-cell-title-jump-end":"Jump to end of topic","topic-cell-title-unread":"Jump to first unread","topic-cell-source":"Source","topic-cell-Posted-at":'Posted by <a data-cmty title="{2}" href="/community/user/{1}"><b>{0}</b></a> on',"topic-cell-1-reader":"{0} user reading this topic.","topic-cell-not-1-reader":"{0} users reading this topic.","topic-cell-visit-in-forum":"Visit this topic in its forum","topic-cell-view-user-profile":"View user profile","topic-full-bookmark-tooltip":"Bookmark this (subscribe)","topic-full-remove-bookmark-tooltip":"Remove from bookmarks (unsubscribe)","topic-full-locked-tooltip":"Topic locked","topic-full-locked-forum-tooltip":"Topic's forum is locked","topic-full-reply-tooltip":"Reply to this topic","topic-full-expand-tooltip":"Expand/collapse topic","topic-full-close-tooltip":"Close topic","topic-full-moderate-tooltip":"Moderate topic","topic-full-reply":"Reply","topic-full-locked":"Locked","topic-full-post-reply":"Quick Reply","topic-full-message-deleted":"The topic you are viewing has just been deleted.","topic-full-deleted-extra":" Since you are in the middle of writing a new post, I will give you \t\ta chance to copy your work from the textarea below. After you close this dialog box, the page will \t\treload and you will have to restart your new post.<br><br>","topic-full-deleted-loss-permission":"You do not have permission to view this topic anymore.","topic-full-deleted-not-logged-in":"You do not have permission to view this topic anymore. This may be because you are no longer signed in.","topic-full-just-locked":"Sorry! This topic has just been locked!","topic-full-undelete-title":"Undelete Post","topic-full-new-reply-blocker":"Sending reply... Back soon.","topic-full-reply-confirm":"Are you sure you want to quit your reply?","topic-full-reply-confirm-OK":"Yes","topic-full-reply-confirm-cancel":"No","topic-full-edit-confirm":"Are you sure you want to quit editing?","topic-full-edit-confirm-OK":"Yes","topic-full-delete-post-pending":"Hold on a sec while I take out this trash...","topic-full-undelete-message":"Are you sure you want to undelete this message?","topic-full-already-reported":"This post has already been reported. A community administrator will address the report soon.","topic-full-already-reported-title":"Post already reported.","topic-full-report-post-title":"Report post","topic-full-report-report-sent":"Your report has been filed; a moderator will take a look at it soon.","topic-full-report-item-spam":"Spam: Inappropriate conduct, advertising, or some other nonsense.","topic-full-report-item-warez":"Warez: Shares copyrighted content without permission.","topic-full-report-item-cheat":"Possible cheating: posted problem comes from an active contest, homework, etc.","topic-full-report-item-other":"Other: Please include reason below.","topic-full-settle-report-title":"Settle report","topic-full-unregistered-reply":"You must be signed in to make a reply to this topic.","topic-full-reply-to-locked":"Sorry, this topic has just been locked, so you cannot reply.","topic-full-reply-to-forum-locked":"Sorry, this topic's forum has just been locked, so you cannot reply.","topic-full-locked-tooltip-mod":"Topic locked, but you can reply\nby clicking here because you are special.","topic-full-locked-forum-tooltip-mod":"Topic's forum is locked, but you can reply\nby clicking here because you are special.","topic-full-not-logged-in-reply":"You must be signed in to reply to topics.","topic-full-title-tooltip":"Click to view topic in its own forum,\n","topic-full-post-with-target-url":'This topic is linked to <a {2} href="/feed/{1}{0}">{3}</a>.',"topic-full-post-solution-thread":"Only students who have viewed the solution can see this topic.","topic-full-target-text-default":"an item on AoPS","topic-full-remove-target":"Click here to unlink this topic.","topic-full-source":"Source","topic-full-state-tooltip":"Click to Toggle\nCurrent topic state: ","topic-full-undelete-hard":"Yikes; someone already hard deleted that post.","topic-full-click-for-tags":"Reveal topic tags","topic-full-no-post-found":"Well, that's embarrassing. I can't find the post you were looking for. \t\tI suspect someone just deleted it, but you can still check out the rest of the topic.","topic-edit-locked":"Sorry, this topic has just been locked, so you cannot edit this post.","topic-edit-forum-locked":"Sorry, this topic's forum has just been locked, so you cannot edit this post.","snipe-option-never":"Never","snipe-option-close":"Close","snipe-option-flyout":"Flyout","snipe-option-not-this-time":"Not This Time","snipe-title":"You've Been Sniped!","snipe-warning-body":"Another user has just replied to this topic. Their\t\t\t\t\t\t\tcomment has been loaded in your browser; you might want to check it out\t\t\t\t\t\t\tbefore submitting your reply. <br /><br />\t\t\t\t\t\t\t&bull; Click <b>Never</b> to stop the warnings on all topics"+(AoPS.session.logged_in?". You can turn warnings back on in your profile. ":" during this visit. ")+"<br>\t\t\t\t\t\t\t&bull; Click <b>Flyout</b> to change these warnings from pop-ups to flyouts.<br>\t\t\t\t\t\t\t&bull; Click <b>Not This Time</b> to block warnings only for this topic, and only during this site visit.<br>\t\t\t\t\t\t\t&bull; Click <b>Close</b> to close this window but keep the warnings coming.<br /><br />\t\t\t\t\t\t\t<b>Scroll to the bottom of the topic to see the new posts.</b>","snipe-warning-flyout":"Another user has just replied to this topic.","topic-full-edited-1":"This post has been edited ","topic-full-edited-2":" time","topic-full-edited-3":" times","topic-full-edited-4":". Last edited by ","topic-full-target-tooltip":"This topic is about an item on the AoPS site.\nClick here to visit that item.","topic-list-jump-top":"Jump to First Topic","post-direct-link":'The <a href="{0}">direct link to this post</a> is:',"post-direct-click-ip":"Admin: Click For IP","post-direct-loading-ip":"Loading IP","post-number-title":"Get Post URL","post-attachments":"Attachments:","post-unread-tootip":"This post unread prior to this visit.","post-thanked-by":'<span class="aops-font">Y</span> by',"post-thank-this":"Give thumbs up","post-unthank-this":"Remove thumbs up","post-nothank-this":"Give thumbs down","post-unnothank-this":"Remove thumbs down","post-user-tooltip-admin":" is a site admin.\nClick to view user profile.","post-user-tooltip-forum-admin":" is an admin of this forum.\nClick to view user profile.","post-user-tooltip-mod":" is a moderator of this forum.\nClick to view user profile.","post-user-tooltip-regular":"\nClick to view user profile.","edit-post-reason-heading":"Edit Post Reason","edit-post-reason-info":"Enter your reason for editing the post here. This reason will\t\tbe displayed with the post.","edit-post-no-post":"Sorry, I can't find this post. Maybe someone just deleted it!","edit-post-no-permission":"You don't have permission to edit this post.","edit-post-nothing-changed":"I looked very closely, but nothing has changed!","edit-send-blocker":"Sending edits... Back shortly.","edit-post-no-links":"New users are not allowed to post links in the Community.","edit-post-no-images":"New users are not allowed to post images in the Community.","edit-post-logged-out-warning":"You have been signed out. To edit this post, \t\t\t\t\t\tyou should sign back in. Here is the edited text you submitted, so\t\t\t\t\t\tyou can copy/paste it: ","delete-post-no-permission":"You do not have permission to delete this post.","delete-post-not-last-post":"You can only delete your own post if it is the last post in the topic. \t\tSomeone has posted after you, so you cannot delete this post.","delete-post-sniped":"You cannot delete the first post of a topic once someone has responded. \t\tIf you don't see a reply to this post, refresh the browser. The reply probably just came in.","new-topic-subject":"Subject","new-topic-tags":"Tags","new-topic-to":"To","new-topic-preview":"PREVIEW","new-topic-close-preview":"CLOSE PREVIEW","new-topic-post-anon":"Post anonymously (instructors will still know who posted)","new-topic-refresh-preview":"REFRESH","new-topic-not-logged-in":"You must be signed in to AoPS in order to start a new topic.","new-topic-are-sure":"Are you sure you want to quit your new topic?","new-topic-confirm-cancel":"No!","new-topic-confirm-OK":"Yes! Close the window.","new-topic-title-too-short":"Your title is too short; it must be at least "+AoPS.Community.Constants.min_topic_title_length+" characters.","new-topic-title-too-long":"Your title is too long; it must be at most "+AoPS.Community.Constants.max_topic_title_length+" characters.","new-topic-post-too-short":"Your post is too short; it must be at least "+AoPS.Community.Constants.min_post_length+" characters.","new-topic-post-too-long-python":"Your post is too long. Unfortunately, rendering Python \t\tnicely requires adding a bunch of markup to your post; that extra markup is causing your \t\tpost to be too long. Try a shorter program.","new-topic-post-too-long":"Your post is too long; please trim it down a bit.","new-topic-remove-link-confirm":"If you remove this tag, then this topic will not \t\tbe linked to a particular item and will not appear in the page feed on any page. \t\t The topic will still be posted in the forum <b>{0}</b>. Is it still OK to delete the tag?","new-topic-send-blocker":"Sending new topic... Back shortly.","new-pm-send-blocker":"Sending private message. Back soon.","new-blog-post-send-blocker":"Sending new blog post. Back soon.","new-topic-post-as-sheriff":"PM as AoPS Sheriff","new-topic-banned-term":"You have used a banned term. Please edit and resubmit.","new-topic-no-links":"New users are not allowed to post links in the Community.","new-topic-no-images":"New users are not allowed to post images in the Community.","new-topic-invalid-character":"You have used a weird character that I don't understand.\t\tFor example, the AoPS people didn't teach me about those wacky Emoji symbols because \t\tsome browsers can't handle them.","new-topic-no-tags-message":"You have not added any tags to your new topic.\t\tTags help people find your post. Are you sure you want to post a new topic without tags?","new-topic-no-tags-confirm-yes":"Post without tags","new-topic-no-tags-confirm-no":"Add tags","new-topic-category-deleted":"Sorry, this forum has just been deleted!","new-topic-no-permission":"You do not have permission to post new topics in this forum.","new-pm-no-permission":"You do not have permission to send new private messages.","new-pm-no-permission-limited":'You have a limited account, so you cannot send private messages. \t\tYou can upgrade your account for free <a href="/user/upgrade.php">here</a>.',"new-topic-timeout":"Sorry, the call to the server timed out. There's a good chance your post\t\twas saved before I gave up, though. So, here's what I recommend. Close this warning, then\t\tcopy your post. Then refresh the window and navigate to where you expect to see your post. \t\tIf the post is not there, then try posting again.","new-topic-err-E_NEW_USER_NEW_TOPIC_LIMITED":"New users may only post 3 new topics every 24 hours. \t\tThis restriction will be lifted after you have been a member of the AoPS Community for 2 weeks.","new-topic-err-E_NEW_VPN_USER_NEW_TOPIC_LIMITED":"New users registering from a VPN may only post 1 new topic every 24 hours. \t\tThis restriction will be lifted after you have been a member of the AoPS Community for 2 weeks.","new-topic-err-E_MAX_ANNOUNCEMENTS":"This forum already has the maximum number of \t\tallowed announcements. Either post this as a normal topic or remove one of the current \t\tannouncements before posting.","new-topic-no-category":"Uh-oh. Those AoPS programmers goofed again. \t\tContact tech-support@aops.com to let them know that they forgot to preload a category on this page. Give them\t\tthe URL of the page you are on, and tell them which button you clicked to get this message.","new-topic-source-placeholder":"Optional. If posting a problem from a book or contest, enter the source of the problem here","new-topic-pm-archived":"Message sent and archived","new-topic-forum-locked":"This forum has been locked. I'm leaving the new topic window open \t\tfor you to give you a chance to copy your post.","new-topic-preview-bar-attachments":"VIEW ATTACHMENTS","new-topic-college-tag-warning-title":"College Forum Tag Warning","new-topic-olympiad-tag-warning-title":"Olympiad Forum Tag Warning","new-topic-olympiad-tags-warning":"Many people use the tags below to navigate the High School Olympiads forum. \t\tWe strongly recommend that you add at least one of these tags to your topic. Click on a tag to add it to your topic.","new-topic-college-tags-warning":"Many people use the tags below to navigate the College Math forum. \t\tWe strongly recommend that you add at least one of these tags to your topic. Click on a tag to add it to your topic.","new-topic-blacklist-trigger":"Sorry, you can't post right now. If you continue having this \t\tproblem, please send a copy of this note to the site administrator.","new-topic-blacklist-text-trigger":"Sorry, you can't post right now. Perhaps there is something wrong with your \t\tpost. If you continue having this \t\tproblem with other posts, please send a copy of this note to the site administrator.","new-reply-logged-out-warning":"You have been signed out. To post a \t\t\t\t\t\t\treply, you should sign back in. Here is the text you submitted, so\t\t\t\t\t\t\tyou can copy/paste it: ","new-reply-no-permission":"You do not have permission to reply to this topic.","new-reply-no-permission-limited":'You have a limited account, so you cannot post new topics or replies. \t\tYou can upgrade your account for free <a href="/user/upgrade.php">here</a>.',"new-reply-locked":"Sorry, the topic was locked right before you submitted your reply!","new-reply-timeout":"Sorry, the call to the server timed out. There's a good chance your post\t\twas saved before I gave up, though. So, here's what I recommend. Close this warning, then\t\tcopy your post. Then refresh the window. If your post was saved, you should see it when you\t\tgo to the end of the topic.","new-reply-err-E_NEW_USER_LIMITED":"Sorry, but new users may only post 6 times every 24 hours. \t\tThis restriction will be lifted after you have been a member of the AoPS Community for 2 weeks.","new-reply-err-E_NEW_VPN_USER_LIMITED":"Sorry, but new users registering from a VPN may only post 1 time every 24 hours. \t\tThis restriction will be lifted after you have been a member of the AoPS Community for 2 weeks.","new-reply-err-E_NO_LINK_POSTING":"New users are not allowed to post links in the Community.","new-reply-forum-locked":"This forum has just been locked, so you cannot reply to this topic.","posting-quote-depth":"You cannot nest more than three quotes.","posting-hide-depth":"You cannot nest more than three hides.","posting-latex-error":"You have a LaTeX error in your message. I have rendered it in red.","posting-asy-error":"You have an Asymptote error in your message. I have rendered it in red.","posting-youtube-error":"You have supplied an invalid YouTube URL.","posting-no-flooding-error":"You cannot post so soon after your last post. Take a break. Do some push-ups. Solve an interesting math problem.","error-latex-posting-confirm":"You have an error in your {0} code. I have rendered it in red. \t\tYou can <b>POST WITH ERROR</b> \t\tand hope someone will tell you how to fix it, or you can <b>TRY TO FIX</b> the error yourself.","error-latex-i-will-fix":"TRY TO FIX","error-latex-post-anyway":"POST WITH ERROR","generic-ajax-timeout":"Your request timed out.","polymath-new-topic-confirm":"You are trying to post a new topic in the forum for the MIT PRIMES/AoPS CrowdMath Project.","polymath-force-choice":"You must confirm you are a student and indicate that you have read the rules in order to proceed.","polymath-reply-confirm":"You are trying to reply to a topic in the forum for the MIT PRIMES/AoPS CrowdMath Project.","polymath-confirm-blocker":"Registering you for the Polymath Project. Please wait a moment.","polymath-confirm-unknown-error":"Sorry, there has been an error of some sort. If this issue persists, please contact tech-support@aops.com, and tell them you received the following code: {0}.","private-adding-user-blocker":"Adding user to this private message...","private-no-username":"You have not entered a username.","private-from-post":"This message is regarding [url={0}]this post[/url].\n","private-from-post-deleted":"This message is regarding the following post, which has been deleted.\n","private-add-user-confirm-OK":"Add","private-add-participant":"Add a user to this conversation","private-need-recipients-err":"You must specify some recipients. You want to be heard, don't you?","private-already-added-active":"The user <b>{0}</b> is already included on this private message.","private-already-added-self-removed":"The user <b>{0}</b> is already included on this private \t\tmessage, but has chosen not to follow the message anymore. You cannot re-add \t\t<b>{0}</b> to this discussion.","private-no-add-self":'You are automatically included in any\t\t\tprivate message you start. Leave the "To" line blank to talk just to yourself.',"private-validation-blocker":"Validating recipient...","private-unreachable-recipient":"Cannot send message to this recipient.","private-category-name":"My Private Messages","private-archived-category-name":"My Archived Private Messages","private-archive-title":"View archived messages","private-View-Archive-btn":"View Archived Messages","private-Archive-btn":"Archive","private-Unarchive-btn":"Unarchive","private-user-removed":"This user left the conversation and will not receive replies.","private-remove-me":"Remove me from this conversation. Forever. Please.","private-remove-from-archived":"Are you sure you wish to be removed from this conversation? <b>You will\t\tnot be able to access this message in the future, and will receive no replies to the message.</b>","private-remove-from-active":'Are you sure you wish to be removed from this conversation? <b>You will\t\tnot be able to access this message in the future, and will receive no replies to the message.</b>\t\tYou may instead choose to archive this message by first clicking "Cancel", then clicking\t\t"Archive" on the message. This will remove the message from your inbox and place it in your Archive.',"private-remove-me-ok":"Remove Me","private-remove-blocker":"Removing you from the conversation.","private-archive-topic":"Archive this conversation","private-unarchive-topic":"Unarchive this conversation","private-message-archived":"Message archived.","private-message-unarchived":"Message unarchived, moved to inbox.","private-reply-no-listeners":"Everyone else has left this conversation; no one will see your comment unless you add\t\tnew participants.","private-user-excluded":'The user <b>{0}</b> is not accepting new private messages, \t\tso cannot be added to this discussion. The user has been removed from your "To" list. \t\tYou must hit <b>Submit</b> again to send.',"private-user-sheriff":"AoPSSheriff is a system account used to send messages from many \t\tdifferent AoPS administrators. To contact AoPSSheriff about an issue, please email \t\tsheriff@aops.com.","private-user-extensions":"Extensions is a system account used to send messages from many \t\tdifferent AoPS administrators. To contact Extensions about an issue, please email \t\textensions@aops.com.","private-user-excluded-by-system":'The user <b>{0}</b> cannot receive private messages, \t\tso cannot be added to this discussion. The user has been removed from your "To" list. \t\tYou must hit <b>Submit</b> again to send.',"private-new-msg-too-many-participants":"You have listed too many recipients. A private message can have\t\tat most "+AoPS.Community.Constants.max_conversation_participants+" participants, including yourself.","private-cant-add-more":"You have reached the maximum number of message participants. \t\tA private message can have at most "+AoPS.Community.Constants.max_conversation_participants+" participants, including yourself.","pm-notify":"You have received a new private message, <b>{1}</b>, from <b>{0}</b>.","pm-notify-flyout":'You have received a new private message, <b>{1}</b>, from <b>{0}</b>. \t\t<a data-cmty href="/community/c1h{2}">Click here to view</a>',"pm-notify-title":"New Private Message","pm-notify-btn-OK":"VIEW MESSAGE","pm-notify-btn-cancel":"CLOSE","post-attachments-default":"Drag your files here, or <a>click here</a> to select files from your computer. Max three files per post.","post-attachments-title":"Attach Files","post-attachments-spoofed":"I don't trust a file you've attached, so you cannot upload it.","post-attachments-bad-file-type":"Sorry, but the file {0} has a file type that I don't like.","post-attachments-no-permission":"You do not have permission to post attachments on this site.","post-attachments-already-attached":"Existing Attachments","post-attachments-file-too-big":"This file is too large. The maximum file size is "+AoPS.Community.Constants.max_attachment_size+"KB.","post-attachments-done":"DONE","post-attachments-invalid-character":"Sorry, your file name has an invalid character. \t\tThe only characters that are allowed are letters, numbers, spaces, dashes, underscores, and periods.","page-title-my-aops":"My AoPS","page-title-reported-posts":"Reported Posts","page-title-search":"Search","user-profile-title":"User Profile","user-profile-browser-title":" User Profile","user-profile-activity":"Activity","user-profile-joined_at":"Joined","user-profile-email":"Email","user-profile-location":"Location","user-profile-status":"Status","user-profile-occupation":"Occupation","user-profile-school":"School","user-profile-goals":"Goals","user-profile-interests":"Interests","user-profile-signature":"Signature","user-profile-friends":"Friends","user-profile-last-visit":"Last Visited","user-profile-total-posts":"Total Posts","user-profile-blog":"Blog","user-profile-website":"Website","user-profile-INACTIVE":"INACTIVE","user-profile-BANNED":"BANNED","user-profile-LIMITED":"LIMITED","user-profile-add-note":"Adding note; page will reload when finished.","user-profile-COPPA":"COPPA","user-profile-thanks-given":'<span class="aops-font">Y</span> Given',"user-profile-thanks-received":'<span class="aops-font">Y</span> Received',"user-profile-no-such-user":"No such user! You asked for user <b>{0}</b>.","user-profile-friend-toggle-off":"Your friends are on your public profile. \nClick to hide them from your public profile.","user-profile-friend-toggle-on":"Your friends are not on your public profile. \nClick to show them on your public profile.","user-profile-add-friend":"Add Friend","user-profile-friend-request":"Has sent you a friend request.","user-profile-friend-ACCEPT":"ACCEPT","user-profile-friend-DECLINE":"DECLINE","user-profile-no-friends":"No AoPS friends yet.","user-profile-unfriend-confirm":"Are you sure you wish to cancel your friendship with <b>{0}</b>?","user-profile-add-friend-instructions":"Make a friend request by entering the username of your potential new\t\tfriend below, and then click OK.<br><br><b>Warning</b>: All your friends can see your Alcumus profile, including your Alcumus statistics.","user-profile-new-friend":"New friend","user-profile-add-friend-modal-title":"Make Friend Request","user-profile-add-friend-title":"Add Friend","user-profile-no-friend-self":"No friending yourself! Choose someone else...","user-profile-add-friend-none-chosen":"Either choose a username or click CANCEL, please.","user-profile-request-sent":"Friend request sent to <b>{0}</b>.","user-profile-friend-request-pending":"Sending your friend request.","user-profile-err-no-perm-friend":"You do not have permission to make friend requests.","user-profile-err-already-friend":"You are already friends with <b>{0}</b>.","user-profile-err-they-asked-you":"The user <b>{0}</b> has already asked you to be friends, so I went ahead and made the\t\ttwo of you friends. You should see <b>{0}</b> among your friends if you refresh the page.","user-profile-err-already-asked":"You have already asked <b>{0}</b> to be your friend.","user-profile-err-not-taking-requests":"The user <b>{0}</b> has left the friends system and is therefore not receiving friend requests.","user-profile-send-request-check":"Send friend request to user <b>{0}</b>?<br><br><b>Warning</b>: Your friends can access your Alcumus profile, including your Alcumus statistics.","user-profile-err-no-request-available":"Uh-oh, I couldn't find the friend request from <b>{0}</b>. That probably means that \t\t<b>{0}</b> just opted out of the friends system.","user-profile-friend-request-accepted":"Friend request from <b>{0}</b> accepted.","user-profile-friend-request-denied":"Friend request from <b>{0}</b> declined.","user-profile-no-my-forums":'<b>My Forums</b> consists of forums you have created, forums you moderate or administrate, or private forums you can access. \t\t\tYou currently have no such forums. Once you have some, you can manage the <b>My Forums</b> page by clicking \t\t\t<span class="aops-font cmty-text">3</span> again.',"user-profile-no-my-collections":'<b>My Collections</b> consists of collections you have created, collections you moderate or administrate, or private collections you can access. \t\t\tYou currently have no such collections. Once you have some, you can manage the <b>My Collections</b> page by clicking \t\t\t<span class="aops-font cmty-text">3</span> again.',"user-profile-no-my-blogs":'<b>My Blogs</b> consists of blogs you created or contribute to, or private blogs you can access. \t\t\tYou currently have no such blogs. Once you have some, you can manage the <b>My Blogs</b> page by clicking \t\t\t<span class="aops-font cmty-text">3</span> again.',"user-profile-click-for-posts":"Click to view posts","user-profile-no-count-note":"*Not included in total","user-profile-no-search-note":"**Forum not searchable","user-profile-pm-title":"Send a private message to this user","user-cell-visit-profile":"Visit user profile","user-bookmark-err-E_ITEM_NUM_LIMITED":"Sorry, you have reached the limit of the number of users that can be bookmarked.","user-bookmark-err-E_NOT_LOGGED_IN":"Sorry, you have been signed out. Please sign back in and try again.","friends-warning":'<div class="cmty-friends-heading">Friend Requests</div>\t\t<b>Warning</b>: All your friends can view your Alcumus profile, including your Alcumus statistics.',"edit-profile-title":"Edit Profile And Account","edit-profile-profile-info":"Profile Information","edit-profile-edit-avatar":"Edit Avatar","edit-profile-delete-avatar":"Delete Avatar","edit-profile-delete-avatar-confirm":"Are you sure you want to delete {0} avatar?","edit-profile-your":"your","edit-profile-this-user":"this user's","edit-profile-new-user":"Your account is too new, so you cannot edit your profile. \t\tYou can only edit your email and password on this page. You will be able to add additional information to your \t\tprofile, such as a status, once your account is over two weeks old.","edit-profile-limited-user":'You currently have a limited account, so you cannot edit your profile. \t\tYou can only edit your password on this page. You will be able to edit your profile if \t\tyou upgrade your account. You can upgrade your account for free <a href="/user/upgrade.php">here</a>.',"edit-profile-deleting-avatar":"Deleting avatar, back in a sec...","edit-profile-change-password":"Change Password","edit-profile-location-placeholder":"Enter your location.","edit-profile-school-placeholder":"Enter your school.","edit-profile-interests-placeholder":"Enter your interests.","edit-profile-website-placeholder":"Enter your website.","edit-profile-occupation-placeholder":"Enter your occupation.","edit-profile-email-placeholder":"You cannot leave this field blank!","edit-profile-goals-placeholder":"Enter your goals.","edit-profile-status-placeholder":"Enter your status.","edit-profile-inappropriate-term":"Inappropriate language used when setting <b>{0}</b>. \t\tThis field has been reset to its original value.","edit-profile-unknown-error":"Unknown error occurred when setting <b>{0}</b>. \t\tThe error code is <b>{1}</b>.","edit-profile-email-not-available":"The email address <b>{0}</b> is already attached to another\t\tusername. Each email address can be associated with only one user.","edit-profile-current-password":"Current Password","edit-profile-new-password":"New Password","edit-profile-retype-password":"Confirm Password","edit-profile-invalid-common-password":"Sorry, you have selected a new password that is too common. Please select a different one. Your password has not been reset yet.","edit-profile-retype-password-placeholder":"Enter your new password again.","edit-profile-new-password-placeholder":"Enter your desired new password.","edit-profile-current-password-placeholder":"Enter your current password.","edit-profile-passwords-dont-match":"Confirm password does not match new password.","edit-profile-enter-password":"You must enter your current password.","edit-profile-submit-new-password":"Validating new password...","edit-profile-invalid-password":"The current password you entered is not correct. Please try again.","edit-profile-password-changed":"Password changed!","edit-profile-password-too-short":"New password is too short. It must be at least "+AoPS.Community.Constants.min_password_length+" characters.","edit-profile-email-not-valid":"New email is not a valid email address. No change made.","edit-profile-email-not-changed":"New email is the same as the old one. No change needed.","edit-profile-new-email":"A confirmation email has been sent to your requested new address, <b>{0}</b>. \t\tUntil you confirm this new address, the email address associated with this account will remain <b>{1}</b>.","edit-profile-email-change-title":"Change Email","edit-profile-email-change=blocker":"Submitting new email address...","edit-profile-no-perm":"You do not have permission to edit your profile.","edit-profile-not-logged-in":"You are not signed in. You have to sign in to edit your profile.","new-user-my-forums":" New users may create new forums after being members of the AoPS Community for at least two weeks.","new-user-my-blogs":" New users may create new blogs after being members of the AoPS Community for at least two weeks.","new-user-my-collections":" New users may create new collections after being members of the AoPS Community for at least two weeks.","edit-avatar-file-too-big":"This file is too large. The maximum file size is "+AoPS.Community.Constants.max_avatar_file_size+"KB.","edit-avatar-default-message":"Drag your new avatar here, or <a>click here</a> to select a file on your computer.","edit-avatar-dimensions-too-big":"This image's dimensions are too big. The width and height must both be \t\tno more than 100px.","edit-avatar-bad-file-type":"Sorry, we only take JPG and PNG image files.","edit-avatar-bad-file-type-apng":"Sorry, we do not accept animated PNG image files.","edit-avatar-too-many":"Whoa! You should only send one file!!","edit-avatar-no-file":"Um, I think you forgot something. I didn't receive a file.","edit-avatar-no-permission":"You do not have permission to change this avatar.","edit-avatar-title":"Upload Avatar","search-page-title":"Advanced Community Search","search-page-private-title":"Private Message Search","search-results-title-with-text":"for {0}","search-results-edit":"Edit search settings","search-err-no-such-user":"Sorry, I don't know any user with the username <b>{0}</b>.","search-err-no-such-forum":"Sorry, we don't have a forum with the name <b>{0}</b>.","search-validation-blocker":"Validating search parameters...","user-search-posts-category-username":"Posts by {0}","user-search-posts-category-user-id":"Posts by the User with Id {0}","edit-settings-page-title":"Edit Community Settings","edit-settings-general-heading":"General Settings","edit-settings-friends-heading":"Friends","edit-settings-posting-heading":"Posting and Reading","edit-settings-feed-heading":"Feed","edit-settings-pm-heading":"Private Messages","edit-settings-hidden-label":"Hide my online status","edit-settings-hide_feed-label":"Hide the feed","edit-settings-show_tags_on_feed-label":"Show tags in the feed","edit-settings-global_feed_type-label":"Global Feed type","edit-settings-enable_advanced_hotkeys-label":'Enable <a href class="cmty-advanced-hotkeys">Advanced Hotkeys</a>',"edit-settings-friends_show_profile-label":"Show my friends on my public profile","edit-settings-friends_exclude-label":"Exclude me from the friends system (and delete all my existing friendships)","edit-settings-posting_subscribe_new_topic-label":"Email me upon replies to any topic I start","edit-settings-posting_subscribe_reply-label":"Email me upon replies to any topic I reply to","edit-settings-posting_fullscreen_reply-label":"Always use full reply (except in feed)","edit-settings-hide_avatars-label":"Hide user avatars on posts and topics","edit-settings-hide_tags_on_topic-label":"Hide the tags on topics","edit-settings-pm_email-label":"Email me whenever anyone sends me a private message","edit-settings-pm_archive_on_send-label":"Archive new private messages I send (not replies; only new topics)","edit-settings-pm_live_notify-label":"Notification method when I receive a private message when I am logged in to AoPS","edit-settings-pm_exclude_self-label":"Prevent users from sending me new private messages (Admins will still be able to send you messages, and users\t\tcan reply to existing messages)","edit-settings-warn_on_snipes-label":"Warning type when a new reply comes in for a topic while I'm typing a reply to topic.","edit-settings-forum_view-label":"Topic cell view style when browsing topics (page will reload on change)","edit-settings-turn_off_autotagging-label":"Turn off autotagging for new topics I post","edit-settings-archive-pm-btn":"Archive All","edit-settings-remove-from-pm-btn":"Remove All","edit-settings-archive-pm-label":"Archive all private messages","edit-settings-remove-from-pm-label":"Remove self from all existing private messages \t\t (you will not be able to access the messages again)","edit-settings-privates-archived":"All private messages archived","edit-settings-archive-confirm":"Are you sure you want to archive all of your private messages? \t\tYou will still be able to access them in your private messages archive.","edit-settings-remove-confirm":"Are you sure you want to remove yourself from all of your private \t\tmessages? This is irreversible; you will not be able to access the messages in the future, \t\tthough the other participants in each message will still be able to access them. You will \t\tbe removed from the messages in both your inbox and your private message archive.","edit-settings-privates-removed":"You have been removed from all of your private messages.","edit-settings-hotkeys-modal-title":"Advanced Hotkeys","edit-settings-no-friends-confirm":"Are you sure you want to remove yourself from the friends system? \t\tAll of your existing friendships will be deleted. They will be reinstated if you return to the friends system.","edit-settings-no-friends-confirm-title":"Leave Friends System?","edit-settings-main-base-view":"Main","edit-settings-portal-base-view":"Portal","edit-settings-base_view-label":'Home page for community (<a data-cmty href="/community/main">Main</a> \t\tis the primary view of the community, and <a data-cmty href="/community/portal">Portal</a> is the Olympiad &amp; College Portal.)',"edit-settings-please-wait-bkmk":"Hold on a sec... The page will reload when I'm finished \t\tcleaning your bookmarks.","edit-settings-bkmk-all-confirm":"Are you sure you want to delete all {0} from your bookmarks? This \t\twill remove all {0} from your feed and unsubscribe you from all {0}.","edit-settings-bkmk-feed-confirm":"Are you sure you want to delete all bookmarked {0} from your feed? \t\tThese {0} will still be in your bookmarks, and your email subscriptions will not be changed.","edit-settings-bkmk-email-confirm":"Are you sure you want to unsubscribe from all email notifications \t\tabout your currently bookmarked {0}? These {0} \t\twill still be in your bookmarks, and your bookmark feed will be unchanged.","edit-settings-bkmk-heading":"Bookmarked {0}","edit-settings-bkmk-link-all":"Delete All","edit-settings-bkmk-link-feed":"Empty Feed","edit-settings-bkmk-link-email":"Unsubscribe","edit-settings-bkmk-all-label":"Delete all {0} from your bookmarks.","edit-settings-bkmk-feed-label":"Remove all {0} from your feed.","edit-settings-bkmk-email-label":"Unsubscribe from all {0}. (End email notification.)","add-participant-instructions-start":"Enter a username below to add someone to this message.\t\t\tThe new participant will be able to read the entire\t\t\tthread, including posts that occurred before the new participant was\t\t\tadded to the discussion. Also, each private\t\t\tmessage can have no more than","add-participant-instructions-end":"participants.","add-participant":"Add participant","add-participant-add-user":"Add user:","add-participant-placeholder":"Enter username","add-participant-logged-out":"You have been signed out. You will have to sign\t\tback in and try again.","add-participant-no-permission":"You do not have permission to add a participant\t\tto this discussion.","add-participant-removed-user":"This user chose to leave this conversation and cannot\t\t be re-added.","add-participant-to-sheriff":"You cannot add a participant to a private message from the AoPS Sheriff.","add-participant-to-extensions":"You cannot add a participant to a private message from Extensions. If you have an \t\tissue regarding extensions, please email extensions@aops.com.","add-participant-too-late":"You waited too long! It is now past the time limit \t\tto add a user to this discussion.","add-participant-no-more":"Someone beat you to it! This private message now has \t\tthe maximum allowed number of participants.","add-participant-no-self":"You cannot add yourself to a private message!","add-participant-recipient-exclude-self":"The user <b>{0}</b> is not accepting new private messages, \t\tso cannot be added to this discussion.","add-participant-recipient-sheriff":"AoPSSheriff is a system account used to send messages from many \t\tdifferent AoPS administrators. You cannot add the AoPSSheriff to a private message. \t\tTo contact AoPSSheriff about an issue, please email sheriff@aops.com. ","add-participant-recipient-extensions":"Extensions is a system account used to send messages from many \t\tdifferent AoPS administrators. You cannot add Extensions to a private message. \t\tTo contact Extensions about an issue, please email extensions@aops.com. ","add-participant-recipient-exclude-system":"The user <b>{0}</b> cannot receive private messages, \t\tso cannot be added to this discussion.","poll-question":"Poll Question","poll-options":"Poll Options","poll-options-desc":"Place each option on a new line. Enter up to 20 options.","poll-options-per":"Options Per User","poll-length":"Poll Length","poll-unlimited":"Unlimited","poll-len-1-day":"1 day","poll-len-2-days":"2 days","poll-len-3-days":"3 days","poll-len-1-week":"1 week","poll-len-2-weeks":"2 weeks","poll-len-1-month":"1 month","poll-revoting":"Allow Revoting?","poll-cancel":"CANCEL POLL","poll-cancel-title":"Cancel Poll?","poll-cancel-confirm":"Are you sure that you want to cancel this poll?\t\tCanceling the poll only removes the poll options. It does not\t\tcancel the whole topic window.","poll-cancel-no":"DON'T CANCEL","poll-no-question-error":"You must include a Poll Question when posting a poll.","poll-no-inputs-error":"You must include some options for the voters to choose from in your poll.","poll-question-too-short":"Your poll question is not long enough. It must be at least "+AoPS.Community.Constants.min_poll_question_length+" characters.","poll-question-too-long":"Your poll question is too long. It must no more than "+AoPS.Community.Constants.max_poll_question_length+" characters.","poll-display-heading":"Poll:","poll-Vote":" Vote","poll-Votes":" Votes","poll-select-one":"Select <b>{0}</b> option.","poll-select-many":"Select up to <b>{0}</b> options.","poll-revote-btn":"CHANGE VOTE","poll-vote-btn":"VOTE","poll-hide-results":"Hide Results","poll-loading":"Loading poll details...","poll-show-results":"Show Results","poll-not-logged-in":"You must be signed in to vote.","poll-nothing-selected":"Work with me here. You have to choose something to vote!","poll-revote-directions":"You have already voted, but are allowed to change your vote. To change your\t\tvote, make a new selection and click CHANGE VOTE above.","poll-vote-processing":"Recording your vote and tabulating new results. Back in a sec!","poll-err-not-logged-in":"You are not signed in. You must be signed in to vote.","poll-err-closed":"Sorry, but the poll closed while you were voting!","new-item-too-short":"Your entry is too short; it must be at least 2 characters.","new-item-already-added":"You have already added ","new-item-too-many-1":"You can only have ","new-item-too-many-2":"s. You'll have to delete some to add new ones.","post-environ-extra-announce":"Make announcement","post-environ-global-announce":"Make global announcement","post-environ-announce-through":"Announce through:","post-environ-invalid-announce-date":"Invalid announcement end date. The date must be in yyyy-mm-dd format.","post-environ-announce-date-too-early":"The last date of the announcement cannot be in the past! Please try again.","post-environ-announce-date-too-late":"The last date of the announcement cannot be more than 2 years in the future. (Leave date field blank for permanent announcements.)","post-environ-image-error":"Sorry, there is something wrong with one of your img tags. You \t\tmay have entered in an invalid URL, or you might be using the tag incorrectly. Please \t\tread your post closely and try again.","post-environ-tip-error":"Sorry, there is something wrong with one of your tags. The \t\tcontent of tips cannot be empty.","bbcode-title-bold":"Bold text\n[b]text[/b]","bbcode-title-underline":"Underline text\n[u]text[/u]","bbcode-title-italic":"Italic text\n[i]text[/i]","bbcode-title-text-size":"Text size\n[size=NUMBER FROM 50 TO 200]text[/size]","bbcode-title-text-color":"Text color\n[color=#HEX COLOR CODE]text[/color]","bbcode-title-quote":"Quote text\n[quote]quoted text[/quote] -or-\n[quote=<person quoted>]quoted text[/quote]","bbcode-title-list":"List\n[list]Your list here, each item on its own line[/list]","bbcode-title-hide":"Hide text\n[hide]hidden text[/hide] -or-\n[hide=<text for the link>]hidden text[/hide]","bbcode-title-code":"Code formatting\n[code]code[/code] -or-\n[code=<language>]code[/code]","bbcode-title-smiley":"Smileys!","bbcode-title-img":"Image\n[img]image url[/img]","bbcode-title-url":"Link\n[url]<your URL>[/url] -or-\n[url=<your URL>]text for link[/url]","bbcode-title-attachment":"Add an attachment","bbcode-title-has-attachments":"Attachments:","bbcode-title-poll":"Start a poll","view-posts-click-hidden":"Click to reveal hidden content","post-report-admin-reported-by":"Reported by","post-report-admin-reported-date":"When","post-report-admin-details":"Details","post-report-admin-for":"For","post-report-admin-confirm":"Are you sure you want to resolve this post report?\t\tIf so, you can add notes about the report resolution below.","post-report-admin-confirm-title":"Resolve Post Report","post-report-admin-block":"Hold on a sec; sending your resolved post report to the database.","post-report-admin-page-title":"Reported Posts","post-report-admin-loading":"Hold on a sec, I'm going to see if there are any more reports\t\tfor you.","post-report-no-more":"No more reported posts.","post-report-admin-none":"No reported posts found.","post-report-admin-notes":"Notes","post-report-admin-no-permission":"You do not have permission to resolve this post report.","post-report-admin-page-text":"On this page are the reported posts in the forums\t\tyou moderate and the blogs you administrate. If you reached this page by clicking a report notification on a post or topic,\t\tbut you see no report here, then someone else has beaten you to it! When you return to the\t\ttopic, the notification for that post should no longer appear.","post-report-first-post-note":"<b>Note:</b> This post is the first post in its topic, so\t\tyou cannot simply delete this post. \t\tPlease visit the topic by clicking the topic title, to determine whether or not you\t\tshould delete the whole topic.","post-report-admin-pm":"PM","post-report-admin-pm-poster":"Poster","post-report-pm-subject":"Response to Report","post-report-pm-reporter-preamble":"This message is regarding your report of [url={0}]this post[/url].","post-report-admin-pm-reporter":"Reporter","post-report-pm-reporter":"You submitted the following details in your report:","poll-too-many-selected":"You have chosen too many options. You can only choose up to <b>{0}</b> options.","tag-edit-title":"Edit tags","autocomplete-new-tag":"No tags match.<br>Press Enter to create tag.","my-aops-Community-Settings":"Edit Community Settings","my-aops-Edit-Profile":"Edit Profile and Account","my-aops-MyForums":"My Forums","my-aops-MyCollections":"My Collections","my-aops-MyBlogs":"My Blogs","my-aops-MyBooks":"My Books","my-aops-MyClasses":"My Classes","my-aops-phone-PM":"PM","my-aops-phone-Bkmk":"Bkmk","my-aops-phone-Fora":"Fora","my-aops-phone-Coll":"Coll.","my-aops-phone-Blogs":"Blogs","cat-admin-general-info":"General Information","cat-admin-description-heading":"Description","cat-admin-in-global-feed":"In Global Feed","cat-admin-global-feed-help":'(See the Feeds section of <a data-cmty href="/community/faq">Community Help</a> for more information.)',"cat-admin-create-button":"CREATE","cat-admin-soft-delete":"Soft Delete","cat-admin-delete":"Delete","cat-admin-hard-delete":"Hard Delete","cat-admin-reported-posts":"Reported Posts","cat-admin-global-automatic":"(Class forums are always included in the Global Feed.)","cat-admin-global-err-E_ALL_GLOBAL_FORA_REMOVED":"You have removed all forums from \t\tyour global feed, so you will have your global feed reset to the default set of forums.","cat-admin-global-err-E_NOT_VALID_FORUM":"Sorry, this category is not a forum \t\tand cannot be added to the global feed.","cat-admin-global-err-E_CLASS_FORA_ALWAYS_IN_GLOBAL":"All class forums are automatically \t\tadded to the global feed.","cat-admin-global-err-E_NOT_LOGGED_IN":"You are no longer signed in. No change made.","cat-admin-global-err-E_GLOBAL_SET_TO_FULL":"Your global feed is currently set to \t\tthe full feed, so you cannot customize it. Edit your Community Settings in the \t\tMy AoPS page to switch to a custom global feed.","cat-admin-global-err-E_TOO_MANY_FEED_FORA":"Sorry, you have reached the limit \t\tof the number of forums you can have in your global feed. The limit is currently \t\t75 forums.","cat-admin-view-log":"View Category Log","cat-admin-delete-blocker":"Deleting now; you will be redirected to the Community homepage when I am finished.","cat-admin-soft-delete-confirm":"Do you really want to delete <b>{0}</b>? This action \t\tis not reversible!","cat-admin-delete-protected":"This is protected; it cannot be deleted.","cat-admin-delete-not-found":"Someone beat you to it. This has already been deleted.","cat-admin-delete-no-permission":"You do not have permission to delete this.","cat-admin-hard-delete-confirm":"Do you really want to <b>HARD</b> delete <b>{0}</b>? This action \t\tis impossible to revert, as it deletes entries from the database entirely.","cat-admin-cat-name-warning":'NOTE: Forum and collection names must be unique. If you choose a name that \t\tsite admins need later, such as "2023 IMO", then we\'ll ask you to change the name at that time.',"cat-admin-create-public-forum-warning":"You have marked this forum <b>public</b>. Any registered\t\tusers will be able to read, post, and reply in this forum. You cannot\t\tchange this forum to private once you have created it. Are you sure you want to create this\t\tforum as <b>public</b>?","cat-admin-create-private-forum-warning":"You have marked this forum <b>private</b>. Only users\t\twho are granted permission to access this forum, and AoPS administrators, will be able to\t\taccess this forum. You cannot\t\tchange this forum to public once you have created it. Are you sure you want to create this\t\tforum as <b>private</b>?","cat-admin-create-public-collection-warning":"You have marked this collection <b>public</b>. Any registered\t\tusers will be able to access this collection. You cannot\t\tchange this collection to private once you have created it. Are you sure you want to create this\t\tcollection as <b>public</b>?","cat-admin-create-private-collection-warning":"You have marked this collection <b>private</b>. Only\t\tyou and AoPS administrators will be able to\t\taccess this collection. You cannot\t\tchange this collection to public once you have created it. Are you sure you want to create this\t\tcollection as <b>private</b>?","cat-admin-create-public-blog-warning":"You have marked this blog <b>public</b>. Any registered\t\tusers will be able to read, shout, and reply in this blog. Are you sure you want to create this\t\tblog as <b>public</b>?","cat-admin-create-private-blog-warning":"You have marked this blog <b>private</b>. Only users\t\twho are granted permission to access this blog, and AoPS administrators, will be able to\t\taccess this blog. Are you sure you want to create this\t\tblog as <b>private</b>?","cat-admin-forum-name-too-short":"Your Forum Name is too short. It must have at least 3 characters.","cat-admin-blog-name-too-short":"Your Blog Name is too short. It must have at least 3 characters.","cat-admin-collection-name-too-short":"Your Collection Name is too short. It must have at least 3 characters.","cat-admin-create-category-blocker":"Hold on a sec while I build this!","cat-admin-back-to-class":"CLASS","cat-admin-back-to-cmty":"COMMUNITY","cat-admin-label-include_in_count":"Include in Post Count","cat-admin-label-include_in_thank_count":'Include in <span class="aops-font">Y</span> Count',"cat-admin-label-include_in_nothank_count":'Include in <span class="aops-font">_</span> Count',"cat-admin-label-include_in_dynamic_collections":"Include in Dynamic Coll.","cat-admin-admin-item-warning":"Admin-only items; only edit these if you know what you are doing.","cat-admin-forum-name":"Forum Name","cat-admin-forum-name-placeholder":"Name your forum.","cat-admin-forum-desc-placeholder":"Enter a brief description of your forum.","cat-admin-blog-name":"Blog Name","cat-admin-blog-name-placeholder":"Name your blog.","cat-admin-blog-desc-placeholder":"Enter a brief description of your blog.","cat-admin-collection-name":"Collection Name","cat-admin-collection-name-placeholder":"Name your collection.","cat-admin-collection-desc-placeholder":"Enter a brief description of your collection.","cat-admin-permissions-title":"Permissions","cat-admin-permissions-header-forum":"You cannot change the Public/Private setting of a forum once the forum\t\thas been created, so <b>make sure you set it correctly now</b>."+(AoPS.session.a?' Any\t\tadministrators will have this forum added to their "My Forums" automatically.':""),"cat-admin-permissions-header-blog":AoPS.session.a?' Any\t\tadministrators will have this blog added to their "My Blogs" automatically.':"","cat-admin-permissions-header-collection":"You cannot change the Public/Private setting of a collection once the collection\t\thas been created, so <b>make sure you set it correctly now</b>. "+(AoPS.session.a?' Any\t\tadministrators will have this collection added to their "My Collections" automatically.':""),"cat-admin-permissions-public-heading":"Public/Private","cat-admin-permissions-is-locked":"Status","cat-admin-permissions-open":"Open","cat-admin-permissions-locked":"Locked","cat-admin-permissions-has-source":"Has Source","cat-admin-permissions-inherit-head":"Inherit Roles From","cat-admin-permissions-remove-self":"Are you sure you want to remove yourself from the <b>{0}</b> of <b>{1}</b>?","cat-admin-permissions-close-userlist-early":"I hate leaving things half-finished. You started entering\t\ta username, but stopped before you finished. Please either finish entering the username or delete\t\twhat you have entered.","cat-admin-perms-existing-user":"The user <b>{0}</b> is already among the <b>{1}</b>. ","cat-admin-set-role-inherit":"Setting role inheritance and assigning roles from parent...","cat-admin-set-inherit-no-perm":"You do not have permission to set role inheritance.","cat-admin-set-inherit-invalid-parent":"Sorry, you have chosen an invalid parent from which to inherit roles.","cat-admin-no-inherit-from-self":"Nice try. You can't set this to inherit from itself.","cat-admin-inheritance-info":"You can set this {0} to inherit roles from some forum or collection. Any user \t\tthat is given a role on the parent will have the same role here, and any user that loses a role \t\ton the parent will lose that role here.","cat-admin-perms-existing-user-3":"Click OK to switch the user to the list of","cat-admin-perms-help-title":"Permissions Help","cat-admin-is-public-confirm-warning":"Only site admins can toggle public/private status. This should be done <b>very</b> sparingly.","cat-admin-is-public-blocker":"Changing public/private status. Back shortly...","cat-admin-set-blog-public-warning":"Are you sure you want to make this blog public? \t\tAll users will be able to see all posts in your blog.","cat-admin-set-blog-private-warning":"Are you sure you want to make this blog private? \t\tOnly owners and contributors will be able to see the blog, and the blog will \t\tbe removed from all collections it is in.","cat-admin-no-add-admin-start":"The user <b>","cat-admin-no-add-admin-end":"</b> is an AoPS administrator. The AoPS administrators have phenomenal powers, so they need not\t\tbe added to any of your user groups.","cat-admin-lock-blocker":"Calling the locksmith. Hold on for a minute.","cat-admin-permissions-forum-public-helper":"Any user can read this forum. Any registered user can post and edit tags.","cat-admin-permissions-forum-private-helper":"Only users who are given permission to access this forum can read, post, or edit tags.","cat-admin-permissions-forum-locked-helper":"No one can post in a locked forum.","cat-admin-permissions-forum-open-helper":"Forum is unlocked; anyone who can access can post.","cat-admin-permissions-forum-has-source-helper":"Topics have a source field.","cat-admin-permissions-forum-no-source-helper":"Topics do not have a source field.","cat-admin-permissions-blog-public-helper":"Any user can read this blog. Any registered user can reply to posts and shout.","cat-admin-permissions-blog-private-helper":"Only users who are given permission to access this blog can read posts and reply to them.","cat-admin-permissions-blog-locked-helper":"No one can reply to posts or shout; only owners can post.","cat-admin-permissions-blog-open-helper":"Blog is unlocked; anyone can reply or shout.","cat-admin-permissions-collection-public-helper":"Any user can read this collection.","cat-admin-permissions-collection-private-helper":"Only you can access this collection.","cat-admin-permissions-collection-locked-helper":"Only collection administrators and moderators can edit the contents of this collection.","cat-admin-permissions-collection-open-helper":"Experienced users can edit the contents of this collection.","cat-admin-user-types-forum-owner":"Administrators","cat-admin-user-types-forum-mod":"Moderators","cat-admin-user-types-forum-registered_user":"Users","cat-admin-user-types-forum-deny":"Banned","cat-admin-user-types-collection-owner":"Administrators","cat-admin-user-types-collection-mod":"Moderators","cat-admin-user-types-collection-deny":"Banned","cat-admin-user-types-blog-owner":"Administrators","cat-admin-user-types-blog-contributor":"Contributors","cat-admin-user-types-blog-deny":"Banned","cat-admin-user-types-blog-reader":"Readers","cat-admin-error-E_NOT_LOGGED_IN":"You are not currently signed in. You must be signed in to create a new ","cat-admin-error-E_NO_PERMISSION":"You no longer have permission to create a new ","cat-admin-error-E_PROTECTED":"This category is protected. Even with your admin superpowers, you cannot delete it or change its public/private status.","cat-admin-error-E_NAME_NOT_AVAILABLE":"The name you have chosen is not available.","cat-admin-error-E_NO_SUCH_CATEGORY_TYPE":"No such category type : ","cat-admin-error-E_NAUGHTY_TERM_USED":"You have a disallowed term in your name or description.","cat-admin-error-E_NAME_TOO_SHORT":"The name is too short. It must be at least "+AoPS.Community.Constants.min_category_name_length+" characters.","cat-admin-error-E_NAME_TOO_LONG":"The name is too long. It cannot be more than "+AoPS.Community.Constants.max_category_name_length+" characters.","cat-admin-error-E_DESCRIPTION_TOO_LONG":"The description is too long. It cannot be more than "+AoPS.Community.Constants.max_category_description_length+" characters.","cat-admin-gen-info-error-E_NO_PERMISSION":"You do not have permission to make these changes.","cat-admin-error-nothing-saved":"Nothing has been saved!","cat-admin-blog-settings-title":"Blog Settings","cat-admin-blog-label-show_profile_info":"Show Profile","cat-admin-blog-label-is_primary_blog":"Set As Blog In My Profile","cat-admin-blog-label-show_stats":"Show Stats","cat-admin-blog-label-show_shoutbox":"Show Shoutbox","cat-admin-blog-label-show_contributors":"Show Contributors","cat-admin-blog-label-show_tags":"Show Tags","cat-admin-blog-label-show_custom_block":"Show Custom Block","cat-admin-blog-label-blog_post_comment_text":"Post Comment Text","cat-admin-blog-label-blog_comments_text":"Comments Text","cat-admin-blog-label-blog_one_comment_text":"One Comment Text","cat-admin-blog-label-blog_no_comments_text":"No Comments Text","cat-admin-blog-settings-help-title":"Blog Settings Help","cat-admin-blog-css-title":"Blog Custom CSS","cat-admin-blog-css-new-info":"Once you have created a blog, you can edit its CSS here.","cat-admin-blog-css-existing-info":"Edit your blog's CSS in the textarea below.","cat-admin-blog-css-save-sure":"Are you sure you want to save this CSS? This will \t\toverwrite any old CSS you have.","cat-admin-blog-css-save-block":"Hold on a sec while I save this CSS for you...","cat-admin-blog-css-delete-sure":"Are you sure you want to delete this CSS? This blog will then \t\thave the default AoPS Blog CSS.","cat-admin-blog-css-delete-block":"Hold on a sec while I delete this blog's CSS for you...","cat-admin-blog-css-enter":"Enter CSS for this blog here.","cat-admin-blog-css-none":"This blog does not have any custom CSS.","cat-admin-blog-css-no-perm":"This blog's custom CSS is shown below.","cat-admin-blog-css-no-perm-err":"You do not have permission to edit this blog's CSS.","cat-admin-blog-css-help-title":"Blog CSS Help","cat-admin-blog-css-default-css":"/** This sets the background color of your blog posts. Try changing the color and see what happens! **/\ndiv .entrywrap, div .entrywrap-hover {\nbackground-color : #dedede;\n}","cat-admin-private-collection-perms":"This is a private collection; only you may access it.","cat-admin-location-title":"Location","cat-admin-location-add-to":"Add to","cat-admin-location-contained-in":"Contained in","cat-admin-delete-container-1":"Do you really want to remove this from the collection ","cat-admin-location-help-title":"Location Help","cat-admin-add-to-location-placeholder":"Enter collection name","cat-admin-location-exists":"This {0} has already been added to <b>{1}</b>.","cat-admin-no-description":"<i>None</i>","cat-admin-contents-title":"Contents","cat-admin-contents-title-editing":'Contents: <span class="cmty-content-edit">Editing</span>',"cat-admin-contents-help-tooltip":"View Contents Help","cat-admin-add-content-folder-placeholder":"Enter forum, collection, or blogroll name","cat-admin-add-content-my_collections-placeholder":"Enter collection or blogroll name","cat-admin-add-content-my_forums-placeholder":"Enter forum name","cat-admin-add-content-folder_forums-placeholder":"Enter forum name","cat-admin-add-content-bookmark_forums-placeholder":"Enter forum name","cat-admin-add-content-folder_collections-placeholder":"Enter collection or blogroll name","cat-admin-add-content-blogroll-placeholder":"Enter blog name","cat-admin-add-content-my_blogs-placeholder":"Enter blog name","cat-admin-add-content-topic-placeholder":"Enter topic url","cat-admin-contents-building-info":"After creating this collection, you will be redirected to \t\tthis page, and will be able to add items to your collection in this box.","cat-admin-contents-save-blocker":"Saving your changes; back shortly.","cat-admin-contents-save-error":"Sorry, something went wrong while I was trying to save. \t\tI tried to do as much as I could before hitting the error. After you hit OK, the page will \t\treload and you'll see what I finished before crashing.<br><br>","cat-admin-contents-unexpected-error":" The only additional detail I have is an error code: <b>{0}</b>.","cat-admin-contents-save-error-E_ITEM_NUM_LIMITED":"<b>Error details</b>: You have exceeded the number of items allowed in \t\tthis collection.","cat-admin-contents-save-error-E_NO_SUCH_POST":"<b>Error details</b>: You have added \t\ta post that no longer exists; perhaps it was just deleted.","cat-admin-contents-save-error-E_NO_PERMISSION":"<b>Error details</b>: You have attempted to \t\tadd a post that you do not have permission to view.","cat-admin-contents-save-error-E_ONLY_PUBLIC_POSTS_ALLOWED":"<b>Error details</b>: You have tried to add a non-public post to this collection. \t\tHowever, this collection is public, \t\tso you can only add public posts to this collection. ","cat-admin-contents-save-error-E_NON_FORUM_POST":"<b>Error details</b>: Only forum posts are allowed in \t\tthis collection. No private messages or blog material is permitted.","cat-admin-contents-no-adding-to-self":"You cannot add this to itself!!!","cat-admin-contents-already-holds":"<b>{0}</b> is already in this collection.","cat-admin-view_posts-already-holds":"Post ID {0}","cat-admin-contents-help-title":"Contents Help","cat-admin-contents-tag-placeholder":"Enter tag","cat-admin-contents-add-tag-error":"Something went wrong when I tried to add tag <b>{0}</b> of Forum <b>{1}</b>. You may\t\twant to refresh and try again.","cat-admin-contents-remove-tag-error":"Something went wrong when I tried to delete \t\t<b>{0}</b>. You may want to refresh and try again.","cat-admin-add-content-tag-forum-placeholder":"Enter forum whose tags you'd like to add","cat-admin-contents-added-tag-already":"The tag <b>{0}</b> of forum <b>{1}</b> has already\t\tbeen added to this collection.","cat-admin-contents-locked-error":"Sorry, this collection has just been locked, so\t\tyou can no longer edit its contents.","cat-admin-contents-add-category-error":"Something went wrong when I tried to add <b>{0}</b> to this collection. You may\t\twant to refresh and try again. Error code: <b>{1}</b>.","cat-admin-no-empty-collections":"You cannot create an empty collection; please add something to this collection.","cat-admin-contents-limit-exceeded":"Sorry, this collection cannot hold more than <b>{0}</b> items.","cat-admin-one-more-step":"After you click OK, I'll build this collection for you, then \t\tbring you right back to this page so you can add items to it.","cat-admin-contents-subscribe":"Receive email notifications if checked","cat-admin-contents-feed":"Appears in Bookmark Feed if checked","cmty-admin-delete-item":"Remove this item.","cat-admin-site-admins-are-admins":"<i>AoPS site admins</i>","cat-admin-no-users-with-this-role":"<i>None</i>","cat-admin-contents-desc-heading":"Contents Description","cat-admin-contents-desc-folder":"This collection can hold other collections and forums.","cat-admin-contents-desc-view_topics":"This collection can hold only forum topics.","cat-admin-contents-desc-view_posts":"This collection can hold posts and custom text.","cat-admin-contents-desc-blogroll":"This collection can hold only blogs.","cat-admin-contents-desc-view_tags":"This collection can hold only tags.","cat-admin-contents-desc-my_forums":"This collection can hold any forum you own or moderate, as well as \t\tany private forum to which you have access.","cat-admin-contents-desc-my_collections":"This collection can hold any collection you own or moderate, as well as \t\tany private collection to which you have access.","cat-admin-contents-desc-bookmark_forums":"This collection holds all the forums you have \t\tbookmarked.","cat-admin-contents-desc-bookmark_users":"This collection holds all the users you have \t\tbookmarked.","cat-admin-contents-desc-bookmark_tags":"This collection holds all the tags you have \t\tbookmarked.","cat-admin-contents-desc-bookmark_topics":"This collection holds all the topics you have \t\tbookmarked.","cat-admin-category-colors":[{label:"Community",color:"#356cb5"},{label:"School",color:"#009fad"},{label:"Games",color:"#c20078"},{label:"Books",color:"#008345"},{label:"Resources",color:"#1f3d7b"}],"cat-admin-contents-desc-my_blogs":"This collection can hold any blog you own or contribute to, as well as \t\tany private blog to which you have access.","cat-admin-contents-desc-folder_forums":"This collection can hold only forums.","cat-admin-contents-desc-folder_collections":"This collection can hold only collections.","cat-admin-contents-sort-heading":"Sorting","cat-admin-contents-current-state":"Current State","cat-admin-contents-edit-btn":"EDIT CONTENTS","cmty-cat-admin-edit-contents-fetch":"Preparing edit window...","cat-admin-contents-current-tab":"Current Contents","cat-admin-contents-available-tab":"Available Contents","cmty-admin-add-topic-error":"You must enter a valid topic id or a URL to a topic \t\tthat is in a forum.","cmty-admin-add-topic-err-not-forum":"You can only add forum topics to this collection.","cmty-admin-add-topic-err-private":"This collection is public, so you cannot topics in \t\tprivate forums.","cmty-admin-add-topic-err-no-topic":"Sorry, I cannot find this topic.","cmty-admin-add-topic-err-no-permission":"Sorry, you do not have permission to access this topic.","cmty-admin-add-topic-blocker":"Hold on while I fetch this topic for you...","cmty-admin-new-post-error-E_LABEL_TOO_LONG":"Your post label is too long; it cannot be more than "+AoPS.Community.Constants.view_post_max_label_len+" characters","cmty-admin-new-post-error-E_INVALID_POST_ID":"You must enter a valid post id or a URL to a forum \t\tpost. To find a post URL, click the post number indicator at the top right of a post. The post \t\tid is the integer following the p.","cmty-admin-new-post-error-E_HIDE_LABEL_TOO_LONG":'Your "Hide Link Text" is too long. It cannot be more than '+AoPS.Community.Constants.view_post_max_hide_label_len+" characters.","cmty-admin-new-post-error-E_NO_CUSTOM_TEXT_ENTERED":"To enter a row of custom text, you must \t\tenter some custom text!","cmty-admin-new-post-error-E_INVALID_POST_TYPE":"You have sent an invalid post type.","cmty-admin-new-post-error-E_BANNED_TERM":"You have submitted a banned term.","cmty-admin-new-post-error-E_NO_SUCH_POST":"Sorry, that post doesn't appear to exist.","cmty-admin-new-post-error-E_NON_FORUM_POST":"You can only add posts that are in forum topics. No \t\tblog posts, blog comments, or private messages are allowed.","cmty-admin-new-post-error-E_NO_PERMISSION":"You do not have permission to \t\taccess this post.","cmty-admin-new-post-error-E_ONLY_PUBLIC_POSTS_ALLOWED":"This collection is public, so you can \t\tonly add public posts to it.","cmty-admin-new-post-error-E_POST_IS_DELETED":"Sorry, that post has been deleted.","cmty-admin-new-post-error-E_LATEX_ERROR":"Sorry, your custom text has a LaTeX error; please fix it and re-submit.","cat-admin-post-construct-blocker":"Constructing post item for this collection.","cat-admin-sort-type-system-my_blogs":"Last blog post time","cat-admin-sort-type-system-view_topics":"Last post time","cat-admin-sort-type-system-bookmark_topics":"Last post time","cat-admin-sort-type-system-blogroll":"Last blog post time","cat-admin-sort-type-system-default":"Special","cat-admin-sort-type-manual":"Manual","cat-admin-sort-type-abc":"Alphabetical","cat-admin-sort-type-manual_then_abc":"Some manual, rest alphabetical","cat-admin-sort-type-yyyy":"By year (all items should start with a year)","cat-admin-sort-type-system-other_forums":"Recent Usage","cat-admin-add-heading-blogroll":"Add blog:","cat-admin-add-heading-view_tags":"Tag forum:","cat-admin-add-heading-my_blogs":"Add blog:","cat-admin-add-heading-topic":"Add topic:","cat-admin-add-heading-folder":"Add item:","cat-admin-add-heading-my_forums":"Add forum:","cat-admin-add-heading-folder_forums":"Add forum:","cat-admin-add-heading-folder_collections":"Add collection:","cat-admin-add-heading-my_collections":"Add collection:","cat-admin-troll-confirm":"This operation is very difficult to undo. Are you certain you want to ban this user as a troll?","cat-admin-thanks-reset":"This user's thanks have now been reset.","feed-topic-full-message-deleted":"The topic you are viewing in the feed has just been deleted.","feed-no-bookmark-options-checked":"Work with me here. If you aren't going to check any options, then I can't fetch you any topics.","feed-new-private-conversation":"Start new message","feed-close":"Close feed","feed-tab-global-title":"Global feed\nRecent topics in any forum\nSee Community Help to customize","feed-tab-global-custom-title":"Global feed\nRecent topics in select forums\nSee Community Help to customize","feed-tab-my-topics-title":"My Topics feed\nTopics I have posted in","feed-tab-private-title":"Private feed\nMy private messages","feed-tab-bookmark-title":"Bookmark feed\nTopics from bookmarked tags, forums, and topics","feed-tab-page-feed-title":"Page feed\n Topics about items on this page","feed-topic-title-tooltip":"Click to visit this topic in main window.","feed-forum-title-tooltip":"Click to visit this forum in main window.","feed-page-subfeed-header":"Page Feed","feed-bookmarks-subfeed-header":"My Bookmarks","feed-global-subfeed-header":"Global Feed","feed-ego-subfeed-header":"My Topics","feed-messages-subfeed-header":"My Messages","feed-no-forum":"Sorry, this object does not have a forum attached yet, so you cannot create a new topic.","feed-no-read-permission":"Sorry, you don't have permission to read this topic.","feed-no-topic":"Well, that's embarrassing. I can't find the topic attached to this object.","feed-community-disabled":"The community has been disabled.","feed-re-sort":"Re-sort this feed","feed-my-topics-onclick":"With {0} of a topic in your My Topics feed, you \t\tmay either open the topic in another tab or remove the topic from the \t\tMy Topics feed. If you remove the topic from the My Topics feed, it \t\twill reappear in the My Topics feed if you post in the topic again.","feed-my-topics-open-new":"Open in new tab","feed-my-topics-remove":"Remove from My Topics","blog-post-new-entry":"Post New Entry","blog-edit-post":"Edit","blog-delete-post":"Delete","blog-moderate-post":"Moderate","blog-report-post":"Report","blog-post-comment":"Comment","blog-shout":"shout","blog-shout-err-E_LATEX_ERROR":"Sorry, you have a LaTeX error in your message.","blog-shout-err-E_ASY_ERROR":"Sorry, you have an Asymptote error in your message.","blog-shouts":"shouts","blog-Tags":"Tags","blog-Comment":" Comment","blog-Comments":" Comments","blog-default-comments":"%s Comments","blog-default-one-comment":"One Comment","blog-default-no-comments":"No Comments","blog-default-post-comments":"(Post Your Comment)","blog-about-owner":"About Owner","blog-posts":"Posts:","blog-joined":"Joined:","blog-location":"Location:","blog-stats":"Blog Stats","blog-created":"Blog created:","blog-entries":"Total entries:","blog-visits":"Total visits:","blog-comments":"Total comments:","blog-archive-title":"Archives","blog-shoutbox-title":"Shouts","blog-one-char-left":"character left","blog-characters-left":"characters left","blog-no-shoutbox-spamming":"You must wait until someone else shouts to shout again!","blog-Entries":"Entries","blog-Entry":"Entry","blog-no-topics":"No posts in this blog. Yet!","blog-no-results":"No results found.","blog-shout-blocker":"Sending your shout. Back shortly....","blog-contributors-title":"Contributors","blog-search-heading":"Search Blog","blog-search-placeholder":"Enter term","blog-search-button":"Search","blog-search-advanced":"Advanced Search","blog-search-advanced-tooltip":"View advanced search options","blog-subscribed-notify":"You will now receive email notifications when this blog has new posts.","blog-unsubscribed-notify":"You will no longer receive email notifications when this blog has new posts.","blog-subscribe-tooltip":"Click to receive email notifications for new posts in this blog","blog-unsubscribe-tooltip":"Click to stop receiving email notifications for new posts in this blog","change-blog-err-E_NO_PERMISSION":"Sorry, you no longer have permission to change this setting. Your changes have not been saved.","blog-shout-no-permission":"You do not have permission to shout in this blog.","blog-shout-no-permission-limited":'You have a limited account, so you cannot shout in blogs. \t\tYou can upgrade your account for free <a href="/user/upgrade.php">here</a>.',"cmty-tag-term-no-tags":"No tags found; press Enter to add as a new tag.","cmty-tag-info-no-match":"No matches found","cmty-tag-info-no-tag":"No tag found","cmty-tag-info-tag":"Tag: ","cmty-tag-mapper-enter-term":"Enter term to attach to tag (hit enter to add): ","cmty-tag-info-delete":"DELETE FROM ALL FORUMS","cmty-tag-info-delete-in-checked":"DELETE FROM CHECKED CATEGORIES","cmty-tag-info-delete-everywhere":"DELETE EVERYWHERE (RARE)","cmty-tag-edit-capitalization":"New capitalization of tag (enter to submit): ","cmty-tag-info-merge-prompt":"Merge to tag (hit enter to submit): ","cmty-term-add-edit":"Add/edit term","cmty-tag-add-edit":"Add/edit tag","cmty-tag-info-delete-all-fora-confirm":"This will delete the tag <b>{0}</b> \t\tin all forums. It will not delete the tag in private messages, nor in blogs. \t\t<b>NOT EASILY REVERSIBLE, DO NOT SCREW THIS UP.</b> Are you sure you want to \t\tdo this?","cmty-tag-info-recapitalization-fail":"The new tag text must be exactly the same as \t\tthe original text, but with different capitalization. No change will be made until you do it right.","cmty-tag-info-recapitalization-confirm":"Are you sure you want to re-capitalize all tags of the \t\tform <b>{0}</b> as <b>{1}</b> instead?","cmty-tag-info-recapitalization-blocker":"Being the Fed, back shortly.","cmty-tag-term-mapper-warning":"<b>Warning</b>: Changes will not take effect for you until reloading the community in your browser.","cmty-tag-info-delete-some-fora-confirm":"This will delete the tag <b>{0}</b> \t\tin the following categories: <b><i>{1}</i></b>.<br><br> \t\t<b>NOT EASILY REVERSIBLE, DO NOT SCREW THIS UP.</b> Are you sure you want to \t\tdo this?","cmty-tag-info-delete-everywhere-confirm":"<b>YOU SHOULD ONLY DO THIS WITH A TAG YOU \t\tWANT TO PUT ON THE BLACKLIST</b>. If you go ahead with this, this tag will be removed \t\tfrom everything, and you should immediately talk to a webmasterish person about putting \t\tthe term on the blacklist in CmtyTags.","cmty-tag-info-delete-blocker":"Deleting tag, back shortly...","cmty-tag-info-merge-tag-confirm":"Are you sure you want to merge the tag <b>{0}</b> into the tag \t\t<b>{1}</b>? This will only affect tags in forums.<br><br> <b>THIS IS NOT REVERSIBLE</b>, unless you \t\tgo through every single topic hand by hand. Have fun with that. Note: Tag counts for the merged-to \t\ttag will not be updated until another topic gets that tag in a forum. That's because I don't like \t\tcounting things.","cmty-tag-info-merge-tag-forums-confirm":"Are you sure you want to merge the tag <b>{0}</b> into the tag \t\t<b>{1}</b>? This will only affect tags in the following forums: <b><i>{2}</i></b>.<br><br> <b>THIS IS NOT REVERSIBLE</b>, unless you \t\tgo through every single topic hand by hand. Have fun with that. Note: Tag counts for the merged-to \t\ttag will not be updated until another topic gets that tag in a forum. That's because I don't like \t\tcounting things.","cmty-tag-info-merge-note":'<b>Notes on merging</b>: <span style="color:#900"><b>DO NOT USE THIS FOR RESTRICTED/HIDDEN TAGS</b></span>. Also, \t\tthe system will only recompute tag counts if you manually select fora below, and there are fewer than 5 of them. Counting is hard, yo. \t\tOtherwise, tag counts won\'t get reset until something gets tagged with the merged-to tag. Most notably, if the \t\tmerged-to tag did not exist prior to merge, it will only appear in the box after merge if you manually choose few \t\tfora for merging.',"view-posts-view-topic":"view topic","embed-err-no-topic":"Sorry, the topic you seek is not in this forum anymore. Maybe it never was here...","embed-halper-no-topic":"This topic seems to be closed. Try finding it in <a target='_blank' href=':URL:'>its native forum</a>.","memberlist-page-title":"Memberlist","memberlist-user-search":"User Search","memberlist-user-search-placeholder":"Enter a username. Use * as a wildcard.","memberlist-joined":"Joined","memberlist-last-visit":"Last Visit","memberlist-posts":"Posts","memberlist-thanks":"<span>Y</span> Received","memberlist-no-matches":"No users match your search, sorry!","memberlist-posts-tooltip":"Number of posts in the community. \nDoes not include posts in the \npink games-related forums.","memberlist-thanks-tooltip":"Number of times this user has received a thumbs-up.","userlist-edit":"Edit user list","my-bookmarks-long-desc":'Bookmarks allow you to collect content that you would like to access easily from your My AoPS page or your feed.<br>\t\tBookmark a forum, tag, topic, or user by clicking the <span class="aops-font">B</span>Bookmark icon associated with the item.',"log-admin-confirm-revert":"Are you sure you want to revert these {0} action(s)? Make sure you \t\thave chosen the correct action(s) to revert; you can't easily reverse this...","log-admin-nothing-to-revert":"Um, you have to choose something to revert...","log-admin-blocker-revert":"Hold on while I clean up this mess.","log-admin-page-title":"Log Admin","log-admin-time":"The previous query took <b>{0}</b> milliseconds."},AoPS.Community.Constants.bbCode.font_sizes=[{size:50,text:"Too small"},{size:75,text:"Small"},{size:100,text:"Medium"},{size:150,text:"Large"},{size:200,text:"Too large"}],AoPS.isUserLimited()?AoPS.in_academy?AoPS.Community.Constants.bbCode.extra_options=[{property:"disable_bbcode",text:"Disable bbCode",class_id:"cmty-post-extra-disable-bbcode"},{property:"bookmark_feed",text:"Add topic to Bookmarks feed",class_id:"cmty-post-extra-add-feed"}]:AoPS.Community.Constants.bbCode.extra_options=[{property:"disable_bbcode",text:"Disable bbCode",class_id:"cmty-post-extra-disable-bbcode"}]:AoPS.Community.Constants.bbCode.extra_options=[{property:"disable_bbcode",text:"Disable bbCode",class_id:"cmty-post-extra-disable-bbcode"},{property:"notify_email",text:"Subscribe to this topic",class_id:"cmty-post-extra-email"},{property:"bookmark_feed",text:"Add topic to Bookmarks feed",class_id:"cmty-post-extra-add-feed"}];
;function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}AoPS.hasOwnProperty("Community")||(AoPS.Community={}),AoPS.Community.is_active=AoPS.bootstrap_data.hasOwnProperty("is_community_active")&&AoPS.bootstrap_data.is_community_active,AoPS.Community.Utils={ajax_runner:new AoPS.Ajax.ScriptRunner("/m/community/ajax.php"),onclick_latex_activated:!1,activateLatexOnclick:function(){AoPS.Community.Utils.onclick_latex_activated||($(document).on("click","img.latex, img.latexcenter",(function(t){AoPS.bootstrap_data.is_sp2&&$(this).parents(".aops-transporter-main").length||t.metaKey||t.ctrlKey||$(this).attr("alt")&&0===$(this).closest(".aops-modal-body").length&&AoPS.Community.Utils.throwLaTeXOnModal({event:t,latex_image:this})})),$(document).on("click","img.asy-image",(function(t){AoPS.bootstrap_data.is_sp2&&$(this).parents(".aops-transporter-main").length||$(this).parents(".motor-homework-body").length||t.metaKey||t.ctrlKey||$(this).attr("alt")&&0===$(this).closest(".aops-modal-body").length&&AoPS.Community.Utils.throwAsyOnModal({event:t,asy_image:this})})),AoPS.Community.Utils.onclick_latex_activated=!0)},throwLaTeXOnModal:function(t){var e,o=t.latex_image.cloneNode(!1),r=$.trim(_.escape(t.latex_image.alt)).replace(/(?:\r\n|\r|\n)/g,"<br />");(e=$('<div class="latex-modal"></div>').append(o)).append('<div class="latex-modal-bottom">\t\t\t\t\t\t\t<div class="latex-modal-bottom-title"><u>LaTeX code below</u></div>\t\t\t\t\t\t\t<div class="latex-modal-code">'+r+"</div>\t\t\t\t\t\t</div>"),e.showModal&&e.showModal({frame_class:"latex-modal-wrapper",max_width:"500px",scrollable:!0})},formatUrl:function(t){return"http://"===t.substr(0,7)||"https://"===t.substr(0,8)?t:"http://"+t},idler_started:!1,is_cmty_asleep:!1,putCommunityToSleep:function(t){AoPS.Community.Utils.cmty_ajax.ajax_active=!1,AoPS.Community.Utils.is_cmty_asleep=!0,t&&"E_INVALID_SESSION_WRONG"===t.error_type&&(AoPS.Community.Lang["community-asleep"]=AoPS.Community.Lang["community-asleep-session"],AoPS.Community.Lang["community-asleep-save"]=AoPS.Community.Lang["community-asleep-save-session"],AoPS.Community.Lang["community-asleep-reminder"]=AoPS.Community.Lang["community-asleep-reminder-session"]),AoPS.Ui.Modal.showMessage(AoPS.Community.Lang["community-asleep"],{width:"450px"}),_.isUndefined(AoPS.Community.Utils.idle_monitor_interval)||(clearInterval(AoPS.Community.Utils.idle_monitor_interval),this.idler_started=!1),"object"===_typeof(AoPS.Community.MasterModel)&&AoPS.Community.MasterModel.set("cmty_status","disabled")},startIdleMonitor:function(){var t=Date.now();this.idler_started||($(document).on("mousemove touchmove click keypress",(function(e){t=Date.now()})),AoPS.Community.Utils.idle_monitor_interval=setInterval((function(){var e=Date.now(),o=AoPS.Community.Constants.intervals.current.put_community_to_sleep_limit;e-t>=o&&AoPS.Community.Utils.putCommunityToSleep()}),AoPS.Community.Constants.idle_monitor_interval))},throwAsyOnModal:function(t){var e,o=t.asy_image.cloneNode(!1),r=$.trim(_.escape(t.asy_image.alt)).replace(/(?:\r\n|\r|\n)/g,"<br />");(e=$('<div class="latex-modal"></div>').append(o)).append('<div class="latex-modal-bottom">\t\t\t\t\t\t\t<div class="latex-modal-bottom-title"><u>Asymptote code below</u></div>\t\t\t\t\t\t\t<div class="latex-modal-code">'+r+"</div>\t\t\t\t\t\t</div>"),e.showModal({frame_class:"latex-modal-wrapper",max_width:"500px",scrollable:!0})},extractValueFromUrl:function(t,e){var o;return _.isNull(e)?0:(o=e.match(new RegExp(t+"(\\d+)")),_.isNull(o)?0:parseInt(o[1]))},hexToRgb:function(t){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null},cmty_ajax:{queue:[],has_active_call:!1,time_profiling:!0,ajax_active:!0,fail_level:0,add:function(t){var e=_.extend({never_cancel:!1,source:"master",call_cancel_on_timeout:!1},t);this.ajax_active?this.has_active_call?(e.hasOwnProperty("queue_limit")&&this.queue.length>e.queue_limit&&this.queueLimit(e),t.hasOwnProperty("extra_ajax_runner_options")&&t.extra_ajax_runner_options.hasOwnProperty("queue_at_front")&&t.extra_ajax_runner_options.queue_at_front?this.queue.unshift(e):this.queue.push(e)):this.run(e):this.checkWarnCmtyAsleep()},clearCallsOfType:function(t){var e=[];_.each(this.queue,(function(o){o.a!==t&&e.push(o)})),this.queue=e},queueLimit:function(t){this.hasHandler(t,"onQueueLimit")&&t.extra_handlers.onQueueLimit()},onAjaxUnknown:function(t){var e,o=this,r=AoPS.Community.Lang;e=AoPS.Community.Constants.base_delay_internet_issue*Math.pow(2,this.fail_level),this.fail_level<4?(this.queue.unshift(this.active_call),AoPS.Ui.Flyout.display(AoPS.Community.Utils.formatString(r["ajax-error-delay"],[e]),{class:"flyout-atop-modal"}),setTimeout((function(){o.runNext()}),1e3*e),console.log("E_AJAX_UNKNOWN: Try again in "+e+" seconds."),this.fail_level++):(this.ajax_active=!1,AoPS.Community.Views.showErrorAtopAModal(r["ajax-error-E_AJAX_UNKNOWN"]))},prepare:function(t){var e,o=this;return e=function(e,r){if(e||"E_INVALID_SESSION_WRONG"!==r.error_code){if(t.main_handler(e,r),o.time_profiling&&AoPS.session.a&&r.hasOwnProperty("response")&&r.response.hasOwnProperty("time_in_script"),e)o.hasHandler(t,"onFinish")&&t.extra_handlers.onFinish(r.response),"string"==typeof r.response.cmty_status&&"object"===_typeof(AoPS.Community)&&"object"===_typeof(AoPS.Community.MasterModel)&&AoPS.Community.MasterModel.set("cmty_status",r.response.cmty_status);else{if("E_AJAX_TIMEOUT"===r.error_code&&t.call_cancel_on_timeout&&(r.error_code="E_AJAX_CANCEL"),"E_AJAX_UNKNOWN"===r.error_code||"E_AJAX_BADRETURN"===r.error_code)return o.onAjaxUnknown(),void(o.ajax_active||AoPS.Ui.Modal.applyKillPhrase("ajax-error-kill"));"E_AJAX_FILTERED"===r.error_code?(console.log("call filtered"),o.hasHandler(t,"onAjaxFilter")&&t.extra_handlers.onAjaxFilter()):(o.hasHandler(t,"onError")&&"E_COMMUNITY_DEACTIVATED"!==r.error_code&&t.extra_handlers.onError(r),"E_COMMUNITY_DEACTIVATED"===r.error_code&&o.hasHandler(t,"onDeactivated")&&t.extra_handlers.onDeactivated())}o.fail_level=0,o.runNext()}},{a:t.a,params:t.params,handler:e}},run:function(t){var e,o;this.ajax_active,e=this.prepare(t),o=t.hasOwnProperty("extra_ajax_runner_options")?t.extra_ajax_runner_options:{},this.ajax_active?(this.active_call=t,this.has_active_call=!0,AoPS.Community.Utils.ajax_runner.run(e.a,e.params,e.handler,o),this.current_ajax_runner_id=AoPS.Community.Utils.ajax_runner.getRunningQueueId()):this.checkWarnCmtyAsleep()},checkWarnCmtyAsleep:function(){AoPS.Community.Utils.is_cmty_asleep&&AoPS.Ui.Flyout.display(AoPS.Community.Lang["community-asleep-reminder"],{class:"flyout-atop-modal"})},runNext:function(){var t,e=this;if(AoPS.Community.is_active&&this.ajax_active)this.queue.length>0?(t=this.queue.shift(),setTimeout(_.bind((function(){this.run(t)}),this),400)):(this.current_ajax_runner_id=0,this.active_call=null,this.has_active_call=!1);else{var o=this.queue;this.queue=[],_.each(o,(function(t){e.prepare(t).handler(!1,{error_code:"E_COMMUNITY_DEACTIVATED"})}))}},hasHandler:function(t,e){return t.hasOwnProperty("extra_handlers")&&"function"==typeof t.extra_handlers[e]},cancelAll:function(t){var e=this,o=[];_.each(this.queue,(function(r){e.checkCancel(t,r)?e.hasHandler(r,"onError")&&r.extra_handlers.onError({error_code:"E_AJAX_CANCEL"}):o.push(r)})),this.has_active_call&&this.checkCancel(t,this.active_call)&&AoPS.Community.Utils.ajax_runner.cancelQueueId(this.current_ajax_runner_id),this.queue=o},checkCancel:function(t,e){return!e.never_cancel&&("all"===t.cancel_type||"feed"===t.cancel_type&&"feed"===e.source||"master"===t.cancel_type&&"master"===e.source)}},autotagger:function(){var t={};return t.dictionary=AoPS.Community.hasOwnProperty("term_tag_map")?AoPS.Community.term_tag_map:{},t.min_spellcheck_len=6,t.spellcheck=function(e){var o,r,a,n,s,i,l,c="abcdefghijklmnopqrstuvwxyz";for(o=0;o<e.length;o++){if(a=e.slice(0,o),n=e.slice(o+1,e.length),s=e.substr(o,1),i=a+n,t.dictionary.hasOwnProperty(i))return t.dictionary[i];for(r=0;r<26;r++){if((l=c.substr(r,1))!==s&&(i=a+l+n,t.dictionary.hasOwnProperty(i)))return t.dictionary[i];if(i=a+l+s+n,t.dictionary.hasOwnProperty(i))return t.dictionary[i]}if(o>0&&(i=e.slice(0,o-1)+s+e.substr(o-1,1)+n,t.dictionary.hasOwnProperty(i)))return t.dictionary[i]}for(r=0;r<26;r++)if(i=e+c.substr(r,1),t.dictionary.hasOwnProperty(i))return t.dictionary[i];return[]},t.tag=function(e){return t.dictionary.hasOwnProperty(e)?t.dictionary[e]:e.length>=t.min_spellcheck_len?t.spellcheck(e):[]},t}(),buildUsernameAutocomplete:function(t,e){var o,r,a=function(){},n=function(){};r=(e=_.extend({has_search_icon:!1},e)).has_search_icon?"left-21 top+5":"left top+5";var s=_.extend({match_type:"from_start_then_any",ui_class:"cmty-username-autocomplete",delay:250,is_case_sensitive:!1,onOpen:function(){},source:function(o,r){var s=AoPS.Community.Utils.cmty_ajax;s.clearCallsOfType(e.ajax_call),s.add({a:e.ajax_call,params:_.extend({username_stub:o.term},e.hasOwnProperty("additional_ajax_settings")?e.additional_ajax_settings:{}),main_handler:function(e,s){var i,l=t.val().substr(0,t[0].selectionStart);o.term!==l&&r([]),e?(0===(i=_.map(s.response.usernames,(function(t){return _.defaults(t,{label:t.value})}))).length?n():a(),r(i)):r([])}})},_renderItem:function(t,e){var o=$("<li></li>"),r=$("<a>"+e.label+"</a>");return o.append(r),"1"===e.is_admin&&r.addClass("cmty-user-admin"),o.appendTo(t)},num_matches:10,position:{my:r}},e.autocomplete_settings);t.wrap($('<div class="cmty-username-autocomplete-wrapper"></div>')),e.has_search_icon&&(t.before('<span class="aops-font">M</span>'),t.parent().addClass("cmty-search-with-icon")),t.aopsAutocomplete(s),e.hasOwnProperty("show_no_results_msg")&&e.show_no_results_msg&&(o=e.hasOwnProperty("$no_results")?e.$no_results:$('<div class="cmty-no-results-found">'+AoPS.Community.Lang["search-no-match"]+"</div>"),t.before(o),t.on("blur remove",(function(){o.hide()})),a=function(){o.hide()},n=function(){o.show(),o.position({my:"left-1 top+1",at:"left bottom",of:t})})},buildCategoryAutocomplete:function(t,e){var o,r,a=function(){},n=function(){};r=(e=_.extend({include_wrapper:!0,has_search_icon:!1},e)).has_search_icon?"left-21 top+5":"left top+5";var s=_.extend({match_type:"from_start_then_any",delay:250,onOpen:function(){t.autocomplete("widget").width(AoPS.Community.Constants.category_autocomplete_width)},is_case_sensitive:!1,source:function(o,r){var s=AoPS.Community.Utils.cmty_ajax;s.clearCallsOfType(e.ajax_call),s.add({a:e.ajax_call,params:_.extend({category_stub:o.term},e.hasOwnProperty("additional_ajax_settings")?e.additional_ajax_settings:{}),main_handler:function(e,s){var i,l=t.val().substr(0,t[0].selectionStart);o.term!==l&&r([]),e?(0===(i=_.map(s.response.categories,(function(t){return _.defaults(t,{label:t.value})}))).length?n():a(),r(i)):r([])}})},_renderItem:function(t,e){var o=$("<li>").addClass("cmty-category-autocomplete-item-"+e.category_type).css({color:e.main_color}),r=$('<a class="cmty-category-autocomplete">').text(e.label).css({color:e.main_color}).data({"main-color":e.main_color,"secondary-color":e.secondary_color});return o.append(r).appendTo(t)},onFocus:_.bind((function(t,e){this.hasOwnProperty("focus_element")&&!_.isNull(this.focus_element)&&this.focus_element.css({color:this.focus_element.data("main-color"),"background-color":""}),this.focus_element=$(t.originalEvent.target).find("a.ui-state-focus"),this.focus_element.css({color:this.focus_element.data("secondary-color"),"background-color":this.focus_element.data("main-color")})}),this),num_matches:10,position:{my:r},ui_class:"category-autocomplete"},e.autocomplete_settings);e.include_wrapper&&(t.wrap($('<div class="cmty-category-autocomplete-wrapper"></div>')),e.has_search_icon&&(t.before('<span class="aops-font">M</span>'),t.parent().addClass("cmty-search-with-icon"))),t.aopsAutocomplete(s),e.hasOwnProperty("show_no_results_msg")&&e.show_no_results_msg&&(o=e.hasOwnProperty("$no_results")?e.$no_results:$('<div class="cmty-no-results-found">'+AoPS.Community.Lang["search-no-match"]+"</div>"),t.before(o),t.on("blur remove",(function(){o.hide()})),a=function(){o.hide()},n=function(){o.show(),o.position({my:e.has_search_icon?"left-22 top+4":"left-1 top+1",at:"left bottom",of:t})})},fetchUsernameMatches:function(t){this.cmty_ajax.clearCallsOfType("fetch_username_matches"),this.cmty_ajax.add({a:"fetch_username_matches",params:{username_stub:t.request.term},main_handler:_.bind((function(e,o){var r;t.hasOwnProperty("checkSquelch")&&t.checkSquelch()?t.response([]):e?(r=_.map(o.response.usernames,(function(t){return _.defaults(t,{label:t.value})})),t.response(r)):t.response([])}),this)})},checkValidUsername:function(t){this.cmty_ajax.add({a:"check_valid_username",params:{username:t.username},main_handler:function(t,e){},extra_handlers:t})},capitalizeFirstLetter:function(t){return t.charAt(0).toUpperCase()+t.slice(1)},displayCategoryType:function(t){return AoPS.Community.Lang[AoPS.Community.Utils.simplifyCategoryType(t)]},format_str_regexp:new RegExp("{-?[0-9]+}","g"),formatString:function(t,e){return t.replace(AoPS.Community.Utils.format_str_regexp,(function(t){var o=parseInt(t.substring(1,t.length-1));return o>=0?e[o]:-1===o?"{":-2===o?"}":""}))},lastRegexp:/(^Last\s)/,makePrettyTime:function(t){var e,o,r=parseInt(moment().format("X"))-t;return r<AoPS.Community.Constants.time_limits.watched_times_long?((o=(e=moment(String(t),"X").add("milliseconds",-AoPS.Community.Constants.moment_offset-AoPS.Community.Constants.time_hack_nudge)).diff(moment()))>0&&o<12e4&&(e=moment().subtract(2,"seconds")),e.fromNow()):(e=moment(String(t),"X").add("milliseconds",-AoPS.Community.Constants.moment_offset),r<AoPS.Community.Constants.time_limit_for_calendar_style?e.calendar().replace(AoPS.Community.Utils.lastRegexp,""):e.format("MMM D, YYYY, h:mm A"))},makePrettyTimeOldDateOnly:function(t){var e,o,r=parseInt(moment().format("X"))-t;return r<AoPS.Community.Constants.time_limits.watched_times_long?((o=(e=moment(String(t),"X").add("milliseconds",-AoPS.Community.Constants.moment_offset-AoPS.Community.Constants.time_hack_nudge)).diff(moment()))>0&&o<12e4&&(e=moment().subtract(2,"seconds")),e.fromNow()):(e=moment(String(t),"X").add("milliseconds",-AoPS.Community.Constants.moment_offset),r<AoPS.Community.Constants.time_limit_for_calendar_style?e.calendar().replace(AoPS.Community.Utils.lastRegexp,""):e.format("MMM D, YYYY"))},makePrettyTimeStatic:function(t){return moment(String(t),"X").format("MMM D, YYYY, h:mm A")},makePrettyTimeStaticDateOnly:function(t){return moment(String(t),"X").format("MMM D, YYYY")},getLastVisitedText:function(t){return"online"===t.item_subtitle?AoPS.Community.Lang["user-item-online"]:0===t.last_active?"":this.makePrettyTimeStatic(t.last_active)},routerBase:Backbone.Router.extend({errors:{my_aops_not_logged_in:{error_type:"custom",error_msg:"COPY/STYLING NEEDED -- There will be awesome stuff on this My AoPS page when you are logged in!!<br><i>This message brought to you by the errors object near the top of the Community Router object."}},url_parameters:[{letter:"c",property:"category_id"},{letter:"x",property:"priv_id"},{letter:"u",property:"user_id"},{letter:"q",property:"search_id"},{letter:"t",property:"tag_id"},{letter:"f",property:"tag_forum_id"},{letter:"h",property:"topic_id"},{letter:"p",property:"post_id"},{letter:"s",property:"state"}],parsePreloadedData:function(){var t,e=AoPS.bootstrap_data.preload_cmty_data,o=s("category_id"),r=s("topic_id"),a=s("post_id"),n=s("user_id");function s(t){return e.hasOwnProperty(t)?e[t]:0}return e.hasOwnProperty("error")?(this.processError(e.error),!0):(e.hasOwnProperty("topic_data")&&(t=this.models.master.processPotentialNewTopic(e.topic_data),this.preloaded_topic_id=r,t.set("last_posts_update_time",e.topic_data.last_posts_update_time)),e.hasOwnProperty("user")&&this.models.master.get("users").add(new AoPS.Community.Models.User(e.user)),!(!e.hasOwnProperty("rewrite_url")||!e.rewrite_url)&&(this.rebuildPageFromStart({category_id:o,topic_id:r,post_id:a,priv_id:0,user_id:n,search_id:0,tag_id:0,tag_forum_id:0,state:0}),!0))},throwError:function(t){this.myPage.throwError({error_type:"custom",error_msg:t})},throwNoPermissions:function(){AoPS.session.logged_in?this.throwError(AoPS.Community.Lang["router-err-no-perms-logged-in"]):this.throwError(AoPS.Community.Lang["router-err-no-perms-logged-out"])},processError:function(t){switch(t){case"E_NO_SUCH_POST":this.throwError(AoPS.Community.Lang["router-err-no-post"]);break;case"E_NO_SUCH_TOPIC":this.throwError(AoPS.Community.Lang["router-err-no-topic"]);break;case"E_NOT_PARTICIPANT":this.throwError(AoPS.Community.Lang["router-err-not-participant"]);break;case"E_NO_PERMISSION":AoPS.session.logged_in?this.throwError(AoPS.Community.Lang["router-err-no-perms-logged-in"]):this.throwError(AoPS.Community.Lang["router-err-no-perms-logged-out"]);break;case"E_TOPIC_DELETED":this.throwError(AoPS.Community.Lang["router-err-topic-deleted"]);break;case"E_NO_SUCH_CATEGORIES":this.throwError(AoPS.Community.Lang["router-err-no-such-category"])}},rebuildUrl:function(t){var e="";return _.each(this.url_parameters,(function(o){var r,a;e+=(r=o.letter,a=o.property,0!=t[a]?r+t[a]:"")})),0===e.length?(Backbone.history.navigate(e,{trigger:!0,replace:!1}),!1):(Backbone.history.navigate(e,{trigger:!1,replace:!0}),!0)},rebuildPageFromStart:function(t){this.rebuildUrl(t)&&(this.myPage.showBreadcrumbs(),this.startConstructingPage(t))}}),simplifyCategoryType:function(t){switch(t){case"forum":case"forum_class":return"forum";case"blog":return"blog";default:return"collection"}},renderNumberWithCommas:function(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")},mouseOverTip:function(t){var e=t.next(),o=e.next();e.toggle(),o.toggle(),t.toggleClass("cmty-tip-open"),t.addClass("first-time");var r,a=t.offset().top+t.height();e.offset({top:a,left:t.offset().left+t.outerWidth()/2-6});var n=t.offset().left-t.parent().offset().left,s=t.parent().outerWidth()-n-t.outerWidth(),i=o.outerWidth()>t.outerWidth()+2*s;r=i===o.outerWidth()>t.outerWidth()+2*n?t.offset().left+t.outerWidth()/2-o.outerWidth()/2:i?t.offset().left+t.outerWidth()+s-o.outerWidth():t.offset().left-n,o.offset({top:a+7.5,left:r})},mouseOutTip:function(t){t.next().toggle(),t.next().next().toggle(),t.toggleClass("cmty-tip-open")},clickMidlineHide:function(t){return t.next().next().toggle(),t.toggleClass("cmty-hide-open"),!1},clickHide:function(t){return t.next().toggle(),t.toggleClass("cmty-hide-open"),!1},onClickBan:function(t){AoPS.Community.MasterModel.banAsSpammer({user_id:t.currentTarget.getAttribute("user_id")}),$(t.currentTarget).hide()},onClickTroll:function(t){AoPS.Ui.Modal.showConfirm(AoPS.Community.Lang["cat-admin-troll-confirm"],(function(e){e?(AoPS.Community.MasterModel.banAsSpammer({user_id:t.currentTarget.getAttribute("user_id"),is_troll:!0}),$(t.currentTarget).hide(),AoPS.Ui.Modal.closeTopModal()):AoPS.Ui.Modal.closeTopModal()}),{close_on_button_click:!1})},onClickTempBan:function(t){var e=_.omit(t,"success"),o=AoPS.View.compileTemplate("#cmty-user-temp-ban-tpl"),r=$("<div />").append($.parseHTML($.trim(o&&o(e))));e.can_temp_ban&&e.can_access&&r.find(".yeet-box").after($("<div />").css("margin-bottom","15px").append($("<h3 />").text("Reason:")).append(AoPS.Community.Utils.getModerationInputsForType("mod")));var a=AoPS.Ui.Modal[e.can_temp_ban?"showConfirm":"showAlert"](r,(function(o){var n=r.find("input[name='action']:checked").val()||"",s=r.find("input[name='reason']:checked").val()||"";o&&e.can_temp_ban&&n&&AoPS.Community.MasterModel.handleTempBan({user_id:t.user_id,action:n,reason:s,success:t.success}),AoPS.Ui.Modal.removeModal(a)}),{close_on_button_click:!1})},getModerationReasonsForType:function(t){return(_.findWhere((AoPS.bd||{}).all_moderation_reasons||[],{type:t})||{}).reasons||[]},getModerationInputsForType:function(t){return _.reduce(AoPS.Community.Utils.getModerationReasonsForType(t),(function(t,e){return t.append($("<label />").css({display:"block",cursor:"pointer"}).text(e.reason).prepend($("<input />").css("margin-right","4px").attr({type:"radio",name:"reason"}).prop("checked",e.default).val(e.value)))}),$("<div />"))}},AoPS.Community.Utils.ajax_runner.addGlobalHandler((function(t,e){if(e.response.hasOwnProperty("user_session_data")?e.response.user_session_data.logged_in===AoPS.session.logged_in&&e.response.user_session_data.user_id===AoPS.session.user_id||(AoPS.session.username=e.response.user_session_data.username,AoPS.session.user_id=e.response.user_session_data.user_id,AoPS.session.logged_in=e.response.user_session_data.logged_in,AoPS.session.logged_in?Backbone.trigger("logged_in"):Backbone.trigger("logged_out")):console.log("No user session data found in ajax call"),t);else if("E_COMMUNITY_DEACTIVATED"===e.error_code&&(AoPS.Community.is_active=!1,AoPS.Community.Views.inCmtyRouter()?window.location.href="/community":Backbone.trigger("community_disabled")),"E_INVALID_SESSION_WRONG"===e.error_code)return AoPS.Community.Utils.putCommunityToSleep({error_type:"E_INVALID_SESSION_WRONG"}),AoPS.Ui.Modal.showAlertQuick(AoPS.Community.Lang["err-no-such-session"]),void AoPS.Ui.Modal.applyKillPhrase("ajax-error-kill")}));
;function _createForOfIteratorHelper(t,e){var s="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!s){if(Array.isArray(t)||(s=_unsupportedIterableToArray(t))||e&&t&&"number"==typeof t.length){s&&(t=s);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,r=!0,n=!1;return{s:function(){s=s.call(t)},n:function(){var t=s.next();return r=t.done,t},e:function(t){n=!0,a=t},f:function(){try{r||null==s.return||s.return()}finally{if(n)throw a}}}}function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?_arrayLikeToArray(t,e):void 0}}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=new Array(e);s<e;s++)i[s]=t[s];return i}function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}AoPS.Community.Models=function(t){var e,s=AoPS.Community.Lang,i=AoPS.Community.Constants,o=AoPS.Community.Utils;return e=o.cmty_ajax,t.Model=Backbone.Model.extend({setDefault:function(t,e){this.has(t)||this.set(t,e)}}),t.Master=Backbone.Model.extend({defaults:{all_past_reported_posts_fetched:!1,loading_post_reports:!1,topic_data_loaded:!1,fullscreen_mode:!1,topics_loading:!1,focus_topic:null,focus_tag:null,topic_lists:{},ajax_data_queue:[],is_fetching_topics:!1,is_stretch_class:!1,watched_users:[],my_aops:null,my_books:null,my_classes:null,my_forums:null,my_bookmarks:null,my_collections:null,my_blogs:null,monitoring_office_hours:!1,watched_times_short:[],watched_times_long:[],last_reported_posts_fetch_time:0,in_change_focus_topic:!1,private_items_fetched:!1,in_community:!1,is_parsing_bbcode:!1},initialize:function(){var e,s,o,a,r=this,n={};AoPS.Community.MasterModel=this,AoPS.Community.Constants.moment_offset=moment(AoPS.bootstrap_data.server_time).diff(new Date),this.set("topics",new(Backbone.Collection.extend({model:t.Topic}))),this.set("global_announcements",new(Backbone.Collection.extend({model:t.Topic}))),this.listenTo(this.get("global_announcements"),"change:announce_type",this.onGlobalAnnounceDemote),this.get("topics").comparator=function(t){return t.get("topic_id")},this.set("users",new(Backbone.Collection.extend({model:t.User}))),this.get("users").comparator=function(t){return t.get("user_id")},"string"==typeof AoPS.bootstrap_data.cmty_status?this.set("cmty_status",AoPS.bootstrap_data.cmty_status):this.set("cmty_status","normal"),this.listenTo(this,"change:cmty_status",this.setIntervals),this.setIntervals(),this.constructIntervalAjax({method:function(){r.rebuildWatchedTimes("watched_times_short")},interval_property:"watched_times_short_interval"}),this.constructIntervalAjax({method:function(){r.rebuildWatchedTimes("watched_times_long")},interval_property:"watched_times_long_interval"}),this.set("cached_tag_ids",{}),this.set("topic_lists",new(Backbone.Collection.extend({model:t.TopicList}))),this.set("categories",new(Backbone.Collection.extend({model:t.Category}))),this.set("priv_categories",new(Backbone.Collection.extend({model:t.CategoryPriv}))),this.set("user_search_categories",new(Backbone.Collection.extend({model:t.Category}))),this.set("search_categories",new(Backbone.Collection.extend({model:t.CategorySearch}))),this.set("last_topic_fetch_time",parseInt(AoPS.bootstrap_data.init_time));var c="new_item_check_interval";this.hasLongNewItemInterval()&&(c="new_item_check_interval_long"),this.constructIntervalAjax({interval_property:c,method:function(){r.fetchNewTopics()}}),this.set("last_watcher_fetch_time",parseInt(AoPS.bootstrap_data.init_time)),AoPS.bootstrap_data.hasOwnProperty("watcher_hash")?this.set("watcher_hash",AoPS.bootstrap_data.watcher_hash):this.set("watcher_hash",Math.floor(1e7*Math.random())),this.set("permissions",AoPS.bootstrap_data.hasOwnProperty("user_global_cmty_permissions")?AoPS.bootstrap_data.user_global_cmty_permissions:[]),this.set("staff_permissions",AoPS.bootstrap_data.hasOwnProperty("user_staff_perms")?AoPS.bootstrap_data.user_staff_perms:[]),this.constructIntervalAjax({interval_property:"watchers_updates_check_interval",method:function(){r.fetchWatcherUpdates()}}),this.on("change:focus_topic",this.onChangeFocusTopic),AoPS.bootstrap_data.hasOwnProperty("my_profile")?(AoPS.bootstrap_data.my_profile.master=this,e=new AoPS.Community.Models.User(AoPS.bootstrap_data.my_profile),this.get("users").add(e),this.set("current_user",e),this.set("my_avatar",e.get("avatar")),this.listenTo(e,"change:base_view",(function(){r.set("base_view",e.get("base_view"))}))):this.set("current_user",new AoPS.Community.Models.User({user_id:1,username:"Anonymous"})),this.set("ebooks_available",AoPS.bootstrap_data.hasOwnProperty("ebooks_available")?AoPS.bootstrap_data.ebooks_available:[]),this.set("base_view",AoPS.bootstrap_data.hasOwnProperty("base_view")?AoPS.bootstrap_data.base_view:"main"),AoPS.session.logged_in&&(r.set("my_aops",r.constructNewCategory({category_name:"My AoPS",no_more_items:!0,category_type:"folder"})),this.constructBookmarkCategories(),this.set("my_privates",this.constructNewCategory(_.extend({category_type:"my_privates",category_name:AoPS.Community.Lang["private-category-name"]},AoPS.bootstrap_data.my_privates_data))),this.set("my_privates_archive",this.constructNewCategory({category_type:"my_privates",is_archive:!0,special_url:"/my-messages-archive/",add_to_master_collection:!1,category_status:"archived",items:this.get("my_privates").get("items"),category_name:AoPS.Community.Lang["private-archived-category-name"],permissions:this.get("my_privates").get("permissions"),can_mark_all_read:!1})),this.set("reported_posts",new(Backbone.Collection.extend({model:t.PostReport}))),this.get("reported_posts").comparator=function(t){return-t.get("inserted_at")}),AoPS.Community.hasOwnProperty("categories")&&(AoPS.bootstrap_data.hasOwnProperty("toplevel_category_permissions")&&_.each(_.keys(AoPS.bootstrap_data.toplevel_category_permissions),(function(t){n[t]=AoPS.bootstrap_data.toplevel_category_permissions[t]})),_.each(AoPS.Community.categories,(function(t){var e=t.category_id;n.hasOwnProperty(e)&&(t.permissions=n[t.category_id]),r.constructNewCategory(t)})),AoPS.bootstrap_data.hasOwnProperty("cmty_toplevel_data")&&_.each(_.keys(AoPS.bootstrap_data.cmty_toplevel_data),(function(t){r.fetchCategory(parseInt(t)).set(AoPS.bootstrap_data.cmty_toplevel_data[t])})),(a=this.fetchCategory(i.master_category_id)).fetchMoreCategoryItems({start_idx:0}),a.set("all_subcategories_loaded",!0),o=this.fetchCategory(i.portal_category_id),_.isUndefined(o)||(o.fetchMoreCategoryItems({start_idx:0}),o.set("all_subcategories_loaded",!0)),s=this.fetchCategory(i.aops_forums_id),_.isUndefined(s)||(AoPS.bootstrap_data.hasOwnProperty("extra_aops_items_front")&&s.addItemsFront(AoPS.bootstrap_data.extra_aops_items_front),AoPS.bootstrap_data.hasOwnProperty("extra_aops_items")&&s.addItems(AoPS.bootstrap_data.extra_aops_items),AoPS.bootstrap_data.hasOwnProperty("aops_subfolders")&&s.addItemsFront(AoPS.bootstrap_data.aops_subfolders))),AoPS.bootstrap_data.hasOwnProperty("global_announcements")&&_.each(AoPS.bootstrap_data.global_announcements,(function(t){r.processPotentialNewTopic(t,!0)})),AoPS.bootstrap_data.hasOwnProperty("preload_category_data")&&(Array.isArray(AoPS.bootstrap_data.preload_category_data)||(AoPS.bootstrap_data.preload_category_data=[AoPS.bootstrap_data.preload_category_data]),_.each(AoPS.bootstrap_data.preload_category_data,(function(t){r.constructNewCategory(t)}))),AoPS.hasOwnProperty("preload_topics")&&this.fetchPreloadTopicData(),AoPS.bootstrap_data.hasOwnProperty("cmty_whois")&&this.set("whois_data",AoPS.bootstrap_data.cmty_whois),this.listenTo(this,"change:fullscreen_mode",this.onChangeFullscreenMode),AoPS.bootstrap_data.hasOwnProperty("office_hours_people")&&(this.resetOfficeHoursPeople(AoPS.bootstrap_data.office_hours_people),this.set("monitoring_office_hours",!0),setTimeout((function(){r.fetchOfficeHoursData()}),5e3))},setIntervals:function(){var t=this.get("cmty_status");"object"===_typeof(i.intervals[t])&&_.each(_.keys(i.intervals[t]),(function(e){i.intervals.current[e]=i.intervals[t][e]}))},onChangeFullscreenMode:function(){switch(this.get("fullscreen_mode")){case"none":$("body").removeClass("feed-fullscreen fullscreen");break;case"feed":$("body").addClass("feed-fullscreen fullscreen");break;case"master":$("body").addClass("fullscreen")}},fetchPreloadTopicData:function(){var t,e,s,o,a=!1,r=!1,n=!1,c=parseInt(AoPS.bootstrap_data.init_time)-i.time_limit_delete_own,d=this,h=!1;AoPS.bootstrap_data.hasOwnProperty("preload_topics_is_read")&&(a=!0,e=AoPS.bootstrap_data.preload_topics_is_read),AoPS.bootstrap_data.hasOwnProperty("preload_topics_bkmk_data")&&(r=!0,s=AoPS.bootstrap_data.preload_topics_bkmk_data),AoPS.bootstrap_data.hasOwnProperty("preload_watchers")&&(h=!0,o=AoPS.bootstrap_data.preload_watchers),AoPS.bootstrap_data.hasOwnProperty("preload_topics_thanked")&&(n=!0,t=AoPS.bootstrap_data.preload_topics_thanked),_.each(_.keys(AoPS.preload_topics),(function(i){var p,g;(p=d.fetchCategory(i))&&(g=p.get("permissions")),g&&p.getPermission("c_can_read")&&_.each(AoPS.preload_topics[i],(function(i){var _=i.topic_id;i.permissions=g,a&&e.hasOwnProperty(_)&&(i.is_read=e[_].is_read,i.db_mark_time=e[_].db_mark_time),h&&o.hasOwnProperty(_)&&(i.num_watchers=o[_].num_watchers,i.watchers_usernames=o[_].watchers_usernames,i.watchers_avatars=o[_].watchers_avatars,i.num_named_watchers=o[_].num_named_watchers),r&&s.hasOwnProperty(_)?(i.is_bookmarked=!0,i.is_watched=1===s[_].e,i.in_feed=1===s[_].f):(i.is_bookmarked=!1,i.is_watched=!1,i.in_feed=!1),i.num_posts=i.comment_count+(p.getPermission("c_can_undelete")?i.num_deleted:0),n&&i.posts_data&&i.posts_data.length>0&&t.hasOwnProperty(i.posts_data[0].post_id)&&(1==t[i.posts_data[0].post_id]?i.posts_data[0].is_thanked=!0:i.posts_data[0].is_nothanked=!0),i.posts_data&&i.posts_data.length>0&&AoPS.session.logged_in&&(i.posts_data[0].editable=AoPS.session.user_id===i.posts_data[0].poster_id,i.posts_data[0].deletable=AoPS.session.user_id===i.posts_data[0].poster_id&&i.posts_data[0].post_time>c)})),d.processPotentialNewTopics(AoPS.preload_topics[i],!0)}))},constructIntervalAjax:function(t){var e,s,i=this;e="number"==typeof AoPS.Community.Constants.intervals.current[t.interval_property]?AoPS.Community.Constants.intervals.current[t.interval_property]:AoPS.Community.Constants[t.interval_property],s=setTimeout((function(){AoPS.Community.is_active&&(t.method(),i.constructIntervalAjax(t))}),e),t.hasOwnProperty("interval_id_property")&&t.interval_monitor_model.set(t.interval_id_property,s)},onChangeFocusTopic:function(t){var e=arguments.length>2&&arguments[2].hasOwnProperty("suppress_ajax")&&arguments[2].suppress_ajax,s=this.get("focus_topic"),i=this.previous("focus_topic");_.isNull(i)||_.isUndefined(i)||i.set("is_master_focus",!1),_.isNull(s)||_.isUndefined(s)||s.set("is_master_focus",!0),e?_.isNull(s)||_.isUndefined(s)||(s.startRealtimePostMonitor({hash:this.get("watcher_hash"),source:"master"}),s.set("is_read",!0),s.set("is_master_focus",!0)):this.makeChangeFocusTopicAjaxCall({new_focus:s,previous_focus:i,source:"master",suppress_ajax:e,hash:this.get("watcher_hash"),fetch_all:arguments[2].hasOwnProperty("fetch_all")&&arguments[2].fetch_all,tag_id:arguments[2].hasOwnProperty("tag_id")?arguments[2].tag_id:0,tag_forum_id:arguments[2].hasOwnProperty("tag_forum_id")?arguments[2].tag_forum_id:0})},makeChangeFocusTopicAjaxCall:function(t){var s={topic_fetch:"none"},i=this;this.set("in_change_focus_topic",!0),_.isNull(t.new_focus)||_.isUndefined(t.new_focus)?s.new_topic_id=0:(t.new_focus.set("in_onChangeFocus",!0),t.new_focus.startRealtimePostMonitor({hash:t.hash,source:t.source}),t.new_focus.set("is_read",!0),s.new_topic_id=t.new_focus.get("topic_id"),s.new_category_id=t.new_focus.get("category_id"),t.hasOwnProperty("tag_id")&&t.tag_id>0&&(s.focus_tag_id=t.tag_id,s.focus_tag_forum_id=t.tag_forum_id),0===t.new_focus.get("posts").length||1===t.new_focus.get("posts").length&&!t.new_focus.get("all_posts_fetched")||t.new_focus.get("poll_id")>0&&!t.new_focus.has("poll_data")?(s.topic_fetch="initial",s.fetch_first=0===t.new_focus.get("posts").length?1:0,s.fetch_all=t.hasOwnProperty("fetch_all")&&t.fetch_all?1:0):(s.topic_fetch="update",s.last_post_num=t.new_focus.fetchLastLoadedPostNumber(),s.last_update_time=t.new_focus.get("last_posts_update_time")),t.new_focus.set({is_fetching_posts:!0,is_fetching_past_posts:!0})),_.isEmpty(t.previous_focus)?s.old_topic_id=0:(t.previous_focus.stopRealtimePostMonitor({hash:t.hash,source:t.source}),s.old_topic_id=t.previous_focus.get("topic_id")),s.source=t.source,s.hash=t.hash,s.is_office_hours=this.get("monitoring_office_hours")?1:0,e.add({a:"change_focus_topic",params:s,source:s.source,main_handler:function(e,o){var a,r;e?(s.new_topic_id>0?(t.new_focus.set("in_onChangeFocus",!0),o.response.hasOwnProperty("category_mark_time")&&(a=t.new_focus.has("category")?t.new_focus.get("category"):t.new_focus.get("master").fetchCategory(t.new_focus.get("category_id")),_.isUndefined(a)||(t.new_focus.set("category",a),a.set("mark_time",o.response.category_mark_time))),t.new_focus.set("mark_time",o.response.topic_mark_time),o.response.hasOwnProperty("new_topic_settings")&&t.new_focus.set(o.response.new_topic_settings),o.response.hasOwnProperty("old_topic_settings")&&(r=t.new_focus.get("master").fetchTopicById(o.response.old_topic_settings.topic_id),_.isNull(r)||r.set(o.response.old_topic_settings)),"initial"===s.topic_fetch?t.new_focus.processInitialPostFetch(o.response):"update"===s.topic_fetch&&t.new_focus.onFinishTopicUpdateAjax(o.response.topic_update_data),t.new_focus.trigger("topic_updated")):s.old_topic_id>0&&o.response.hasOwnProperty("new_topic_settings")&&t.previous_focus.set(o.response.new_topic_settings),i.set("in_change_focus_topic",!1),i.trigger("change_topic_post_finish"),i.get("monitoring_office_hours")&&o.response.hasOwnProperty("office_hours_people")&&i.resetOfficeHoursPeople(o.response.office_hours_people)):"E_TOPIC_DELETED"!==o.error_code&&"E_NO_SUCH_TOPIC"!==o.error_code&&"E_NO_PERMISSION"!==o.error_code||(t.new_focus.set("deleted",!0,{error_code:o.error_code}),t.new_focus.destroy())},extra_handlers:{onError:function(e){"E_AJAX_CANCEL"===e.error_code&&(_.isNull(t.new_focus)||t.new_focus.set({is_fetching_posts:!1,is_fetching_past_posts:!1}))}}})},fetchNewTopics:function(){var t,s=this,i=!1;t={last_topic_fetch_time:this.get("last_topic_fetch_time"),watched_users:JSON.stringify(this.get("watched_users")),in_community:this.get("in_community")?1:0},"object"===_typeof(AoPS.Stretch)&&"number"==typeof AoPS.Stretch.class_id&&"number"==typeof AoPS.Stretch.forum_id&&"number"==typeof AoPS.Stretch.lesson&&(t.stretch_class_id=AoPS.Stretch.class_id,t.stretch_lesson=AoPS.Stretch.lesson,t.stretch_forum_id=AoPS.Stretch.forum_id,i=!0),this.get("is_fetching_topics")||(this.set("is_fetching_topics",!0),e.add({a:"fetch_new_topics",params:t,queue_limit:1,never_cancel:!0,main_handler:function(t,e){t&&e.response&&(e.response.hasOwnProperty("topic_fetch_time")&&e.response.topic_fetch_time>parseInt(AoPS.bootstrap_data.init_time)&&s.set("last_topic_fetch_time",e.response.topic_fetch_time),e.response.deleted_topics.length>0&&_.each(e.response.deleted_topics,(function(t){var e=s.fetchTopicById(t);_.isNull(e)||(e.set("deleted",!0),e.destroy())})),e.response.moved_topics.length>0&&_.each(e.response.moved_topics,(function(t){var e=s.fetchTopicById(t.topic_id),i=s.fetchCategory(t.category_id);_.isNull(e)||e.parsePotentialMove(t),_.isUndefined(i)||i.set({num_topics:t.category_num_topics,num_posts:t.category_num_posts,num_users:t.category_num_users})})),e.response.posts.length>0&&_.each(e.response.posts,(function(t){var e=s.fetchTopicById(t.topic_id);_.isNull(e)||e.parseEditedPost(t)})),e.response.topics.length>0&&_.each(e.response.topics,(function(t){var e;e=s.fetchCategory(t.category_id),_.isUndefined(e)||e.set({num_topics:t.category_num_topics,num_posts:t.category_num_posts,num_users:t.category_num_users}),s.processPotentialNewTopic(t,!0)})),e.response.category_lock_changes.length>0&&_.each(e.response.category_lock_changes,(function(t){var e=parseInt(t.category_id),i=s.fetchCategory(e),o=1==parseInt(t.is_locked);_.isUndefined(i)||i.set("is_locked",o),s.setTopicsForumLockStatus(e,o)})),e.response.hasOwnProperty("whois_data")&&s.set("whois_data",e.response.whois_data),s.set("is_fetching_topics",!1),e.response.hasOwnProperty("deleted_categories")&&_.each(e.response.deleted_categories,(function(t){s.deleteCategory(t)})),i&&e.response.hasOwnProperty("stretch_data")&&s.trigger("stretch_data_returned",{data:e.response.stretch_data}))}}))},deleteCategory:function(t){var e="forum"===t.category_type||"forum_class"===t.category_type,i=this.fetchCategory(t.category_id);_.isUndefined(i)||(i.set("deleted",!0),i===this.get("focus_category")&&AoPS.Ui.Modal.showAlert(s["category-deleted"],{width:"400px",onClose:function(){window.location.replace("/community")}}),i.destroy()),e&&this.get("topics").each((function(e){e.get("category_id")===t.category_id&&(e.set("deleted",!0),e.destroy())}))},fetchTopicFromDb:function(t){var s=!!t.hasOwnProperty("force_to_active")&&t.force_to_active,i=t.hasOwnProperty("add_to_category_id")?t.add_to_category_id:null;e.add({a:"fetch_topic",params:{topic_id:t.topic_id},main_handler:_.bind((function(e,o){var a;if(e){if(a=this.processPotentialNewTopic(o.response.topic,s),s&&i){var r=this.fetchCategory(i);r&&r.get("active_topics").add(a,{})}this.trigger("single_topic_load",{ok:!0,topic:a,topic_id:t.topic_id}),o.response.topic=a,o.response.topic_id=t.topic_id}else this.trigger("single_topic_load",{ok:!1,error_code:o.error_code,topic_id:t.topic_id})}),this),extra_handlers:t})},fetchTopicFromDbGivenPostId:function(t){e.add({a:"fetch_topic_from_post",params:{post_id:t.post_id},never_cancel:!0,main_hander:_.bind((function(t,e){var s;t&&(s=this.processPotentialNewTopic(e.response.topic,!1),e.response.topic=s)}),this),extra_handlers:t})},hasLongNewItemInterval:function(){return!AoPS.hasOwnProperty("router_root")||"community"!==AoPS.router_root&&"class"!==AoPS.router_root},onGlobalAnnounceDemote:function(t){"global"!==t.get("announce_type")&&this.get("global_announcements").remove(t)},updateCategoryTopics:function(t,e,s){var i,o=this.get("focus_topic_list"),a=_createForOfIteratorHelper(s);try{for(a.s();!(i=a.n()).done;){var r=i.value,n=this.fetchTopicById(r);n&&o.removeTopic(n)}}catch(h){a.e(h)}finally{a.f()}var _,c=_createForOfIteratorHelper(e);try{for(c.s();!(_=c.n()).done;){var d=_.value;this.fetchTopicFromDb({topic_id:d,force_to_active:!0,add_to_category_id:t})}}catch(h){c.e(h)}finally{c.f()}},setTopicSortValue:function(t,e){var s=this.fetchTopicById(t);s&&s.set("sort_value",e)},processPotentialNewTopic:function(e,s){var i=this.fetchTopicById(e.topic_id);return _.isNull(i)?(e.master=this,e=this.checkLoadedTopicPermissions(e),i=new t.Topic(e),this.get("topics").add(i,{force_to_active:s}),"global"===i.get("announce_type")&&this.get("global_announcements").add(i)):i.processTopicUpdate(e),i},checkLoadedTopicPermissions:function(t){var e;return t.hasOwnProperty("permissions")||(e=this.fetchCategory(t.category_id),_.isUndefined(e)?(console.log("uh-ohh; you are parsing a new topic without permissions, and its category has not been loaded yet."),console.log("Category id is "+t.category_id)):t.permissions=e.get("permissions")),t},processPotentialNewTopics:function(t,e){var s=this,i=[];return _.each(t,(function(t){i.push(s.processPotentialNewTopic(t,e))})),i},fetchCategory:function(t){var e=this.get("categories").find((function(e){return e.get("category_id")===parseInt(t)}));return _.isUndefined(e),e},fetchPrivCategory:function(t){var e=this.get("priv_categories").find((function(e){return e.get("user_id")===parseInt(t)}));return _.isUndefined(e),e},buildPrivCategory:function(s){var i,o=this;e.add({a:"fetch_priv_category_data",params:{user_id:s.user_id},main_handler:function(e,s){e&&(s.response.category.visited=!0,s.response.category.master=o,i=new t.CategoryPriv(s.response.category),o.get("priv_categories").add(i),s.response.category=i)},extra_handlers:s})},buildCategory:function(t){var s,i=this;e.add({a:"fetch_category_data",params:{category_id:t.category_id},main_handler:function(t,e){t&&(e.response.category.visited=!0,s=i.constructNewCategory(e.response.category),e.response.category=s)},extra_handlers:t})},buildCategoryAndTag:function(t){var s,i=this;e.add({a:"fetch_category_and_tag_data",params:{category_id:t.category_id,tag_text:t.tag_text},main_handler:function(t,e){t&&(s=i.constructNewCategory(e.response.category),e.response.category=s)},extra_handlers:t})},fetchTagId:function(t){var s=this,i=this.get("cached_tag_ids");i.hasOwnProperty(t.tag_text)?"function"==typeof t.onFinish&&t.onFinish({tag_id:i[t.tag_text]}):e.add({a:"fetch_tag_id",params:{tag_text:t.tag_text},main_handler:function(e,i){e&&(s.get("cached_tag_ids")[t.tag_text]=parseInt(i.response.tag_id))},extra_handlers:t})},fetchCategoryColors:function(t){var e;return null===t||_.isUndefined(e=this.fetchCategory(t))?{main_color:"#000",secondary_color:"#aaa"}:{main_color:e.get("main_color"),secondary_color:e.get("secondary_color")}},fetchFilteredTopicList:function(e){var s,i;return e=_.defaults(e,{tag_ids:[]}),i=this.get("topic_lists").find((function(t){var s,i;if(t.get("category")!=e.category)return!1;if(e.tag_ids.length>0){if((s=t.get("tag_ids")).length!=e.tag_ids.length)return!1;for(i=0;i<s.length;i++)if(s[i].tag_forum_id!=e.tag_ids[i].tag_forum_id||s[i].tag_id!=e.tag_ids[i].tag_id)return!1;return!0}return 0===t.get("tag_ids").length})),_.isUndefined(i)&&(s=this.constructTopicListFilter({category:e.category,tag_ids:e.hasOwnProperty("tag_ids")&&e.tag_ids.length>0?e.tag_ids:[]}),i=new t.TopicList({master:this,filter:s,tag_ids:e.hasOwnProperty("tag_ids")&&e.tag_ids.length>0?e.tag_ids:[],category_id:e.category_id,category:e.category}),this.get("topic_lists").add(i)),i.get("filtered_topic_list")},fetchUser:function(t){var e=!1;return("number"==typeof t||/^\d+$/.test(t))&&(e=!0),e?this.get("users").find((function(e){return e.get("user_id")===parseInt(t)})):this.get("users").find((function(e){return e.get("username").toLowerCase()===t.toLowerCase()}))},buildUser:function(t){var s=this;e.add({a:"fetch_user_profile",params:{user_identifier:t.user_identifier},main_handler:function(e,i){var o;if(e){if(t.user_identifier.indexOf("@")>-1&&(o=s.fetchUser(i.response.user_data.user_id),!_.isUndefined(o)))return void(i.response.user_model=o);i.response.user_data.master=s,i.response.user_model=new AoPS.Community.Models.User(i.response.user_data),s.get("users").add(i.response.user_model)}},extra_handlers:t})},banAsSpammer:function(t){e.add({a:"ban_as_spammer",params:{user_id:parseInt(t.user_id),is_troll:t.is_troll||!1},main_handler:function(t,e){},extra_handlers:t})},handleTempBan:function(t){e.add({a:"handle_temp_ban",params:{user_id:parseInt(t.user_id),action:t.action,reason:t.reason},main_handler:function(e,s){e?_.isFunction(t.success)&&t.success(s.response.temp_ban):s.error_msg&&AoPS.Ui.Modal.showAlert(s.error_msg)}})},checkVPN:function(t){e.add({a:"check_vpn",params:{ip:t.ip},main_handler:function(e,s){parseFloat(s.response.probability)>.95?$("[data-ip='"+t.ip+"']").addClass("is-vpn"):$("[data-ip='"+t.ip+"']").removeClass("is-vpn")},extra_handlers:t})},submitFriendRequest:function(t){e.add({a:"send_friend_request",params:{new_friend:t.new_friend},main_handler:function(t,e){},extra_handlers:t})},fetchTopicById:function(t){var e=this.get("topics");return t=parseInt(t),0===e.length?null:this.fetchTopicByIdBinary(t,0,e.length-1,e.models)},fetchTopicByIdBinary:function(t,e,s,i){var o,a;return s<e?null:t<(a=i[o=Math.floor((e+s)/2)].get("topic_id"))?this.fetchTopicByIdBinary(t,e,o-1,i):t>a?this.fetchTopicByIdBinary(t,o+1,s,i):i[o]},fetchItemName:function(t,e){var s=this.fetchCategory(t),i=s.fetchItem(e);return _.isUndefined(i)&&(i=(s=self.fetchCategory(e.item_forum_id)).fetchItem(e)),i.item_text},fetchPrivateItems:function(t){var e=this.get("my_privates"),s=this,i=this.get("my_privates_archive");e.fetchMoreItems({onFinish:function(){s.set("private_items_fetched",!0),i.set("items",e.get("items")),t.hasOwnProperty("onFinish")&&t.onFinish()}})},checkValidPrivateRecipient:function(t){e.add({a:"check_valid_private_recipient",params:{username:t.username},main_handler:function(t,e){},extra_handlers:t})},constructNewCategory:function(t){var e,s=!0;return t.hasOwnProperty("add_to_master_collection")&&(t.add_to_master_collection||(s=!1),delete t.add_to_master_collection),e=this.constructTemporaryCategory(t),!_.isNull(e)&&s&&this.get("categories").add(e),e},fetchUserSearchCategory:function(t){var e=this.get("user_search_categories").findWhere({user_id:t});return _.isUndefined(e)&&(e=this.constructTemporaryCategory({category_type:"user_search_posts",user_id:t})),this.get("user_search_categories").add(e),e},validateSearchInput:function(t){e.add({a:"validate_search_input",params:{username:t.username,forum:t.forum},main_handler:function(t,e){},extra_handlers:t})},fetchSearchCategory:function(t){return this.get("search_categories").findWhere({search_id:t})},buildSearchCategory:function(t){var e,s={category_type:"search",master:this,search_settings:t};return e=this.constructTemporaryCategory(s),this.get("search_categories").add(e),e},constructTemporaryCategory:function(e){var s;if(e.hasOwnProperty("category_type")){switch(e.category_type){case"view_topics":s=t.CategoryViewTopics;break;case"feed_topics":s=t.CategoryFeedTopics;break;case"bookmark_topics":s=t.CategoryBookmarkTopics;break;case"view_tags":s=t.CategoryViewTags;break;case"bookmark_tags":s=t.CategoryBookmarkTags;break;case"view_forums":s=t.CategoryViewForums;break;case"bookmark_forums":s=t.CategoryBookmarkForums;break;case"forum":case"forum_class":s=t.CategoryForum;break;case"my_privates":case"my_privates_archive":s=t.CategoryPrivates;break;case"user_search_topics":s=t.CategoryUsersTopics;break;case"user_search_posts":s=t.CategoryUsersPosts;break;case"search":s=t.CategorySearch;break;case"blog":s=t.CategoryBlog;break;case"my_forums":s=t.CategoryMyForums;break;case"my_blogs":s=t.CategoryMyBlogs;break;case"my_collections":s=t.CategoryMyCollections;break;case"my_bookmarks":s=t.CategoryMyBookmarks;break;case"view_posts":s=t.CategoryViewPosts;break;case"user":s=t.CategoryUser;break;default:s=t.Category}return new s(_.defaults(e,{master:this}))}return console.log("You tried to build a new category without a category_type."),console.log('Type "HERE COMES AN ERROR" assumed. Your wish is my command.'),console.log(e),null},constructTopicListFilter:function(t){return _.partial((function(t,e){var s,i;if(t.hasOwnProperty("tag_ids")&&(i=t.tag_ids.length)>0&&0!=t.tag_ids[0].tag_id)for(s=0;s<i;s++)if(e.get("category_id")!=t.tag_ids[s].tag_forum_id||!e.hasTag(t.tag_ids[s].tag_id))return!1;return!!t.category.filterTopic(e)}),t)},constructBookmarkCategories:function(){var t=this;AoPS.session.logged_in&&AoPS.bootstrap_data.hasOwnProperty("feed_fora")&&_.each(AoPS.bootstrap_data.feed_fora,(function(e){var s,i=e.category_type;switch(e.no_more_items=!0,s=t.constructNewCategory(e),i){case"bookmark_topics":t.set("bookmarked_topic_category",s);break;case"bookmark_tags":t.set("bookmarked_tag_category",s);break;case"bookmark_forums":t.set("bookmarked_forum_category",s)}}))},processTopicTags:function(t){if(t){var e,s,i,o,a;if(t.get("tags_processed"))return;if(t.set("tags_processed",!0),e=this.fetchCategory(t.get("category_id")),_.isUndefined(e))return;s=e.get("items"),i=e.get("category_id"),_.each(t.get("tags"),(function(t){if(a=s.length,!t.hasOwnProperty("is_visible")||t.is_visible){for(o=0;o<a;o++)if(s[o].item_id===t.tag_id)return;s.push({item_id:t.tag_id,item_text:t.tag_text,item_forum_id:i,item_type:"tag",item_main_color:e.get("main_color"),item_secondary_color:e.get("secondary_color")})}}))}},parseBBCode:function(t){var s=this;this.get("is_parsing_bbcode")||(this.set("is_parsing_bbcode",!0),e.add({a:"parse_post",params:{text:t.text,post_format:t.post_format},main_handler:_.bind((function(t,e){s.set("is_parsing_bbcode",!1)}),this),extra_handlers:t}))},isBookmarked:function(t){var e;switch(t.item_type){case"tag":e="bookmarked_tag_category";break;case"topic":e="bookmarked_topic_category";break;case"forum":case"forum_class":e="bookmarked_forum_category"}return!!this.has(e)&&this.get(e).hasItem(t)},fetchBookmarkStatus:function(t){var e,s;if(!AoPS.session.logged_in)return{is_bookmarked:!1,in_feed:!1,is_watched:!1};switch(t.item_type){case"tag":s="bookmarked_tag_category";break;case"topic":s="bookmarked_topic_category";break;case"forum":case"forum_class":s="bookmarked_forum_category"}return!!this.has(s)&&(e=this.get(s).fetchItem(t),_.isUndefined(e)?{is_bookmarked:!1,in_feed:!1,is_watched:!1}:{is_bookmarked:!0,in_feed:1==e.in_feed,is_watched:1==e.is_watched})},addTagBookmark:function(t){this.has("bookmarked_tag_category")&&(this.get("bookmarked_tag_category").addItem(t.item),this.get("bookmarked_tag_category").addItemDb({item:t.item,add_to_client:!1,onError:t.hasOwnProperty("onError")?t.onError:function(){}}))},removeTagBookmark:function(t){this.has("bookmarked_tag_category")&&(this.get("bookmarked_tag_category").removeItem(t),this.get("bookmarked_tag_category").removeItemDb({item:t,remove_from_client:!1}))},submitNewTopic:function(t){var s=o("bookmark_feed"),i=o("notify_email");function o(e){return t.hasOwnProperty(e)&&t[e]?1:0}e.add({a:"submit_new_topic",params:{category_id:t.category_id,title:t.title,tags:JSON.stringify(t.tags),linked_tag:t.linked_tag,target_url:t.target_url,target_text:t.target_text,source:t.source,post_as_halp:t.post_as_halp?1:0,pm_as_sheriff:t.pm_as_sheriff?1:0,allow_latex_errors:t.allow_latex_errors?1:0,hidden_tags:JSON.stringify(t.hidden_tags),restricted_tags:JSON.stringify(t.restricted_tags),removed_autotags:JSON.stringify(t.removed_autotags),post_text:t.post_text,notify_email:i,attachments:JSON.stringify(t.attachments),has_poll:t.has_poll,poll_data:1===t.has_poll?JSON.stringify(t.poll_data):JSON.stringify({}),recipients:JSON.stringify(t.recipients),disable_bbcode:o("disable_bbcode"),is_local_announcement:o("is_local_announcement"),is_global_announcement:o("is_global_announcement"),announce_through:t.hasOwnProperty("announce_through")?t.announce_through:""},main_handler:_.bind((function(t,e){var o,a;t&&("blog_post"!==(o=this.processPotentialNewTopic(e.response.topic,!0)).get("topic_type")&&(1!==i&&1!==s||o.setBookmarkState({is_bookmarked:!0,in_feed:1===s,is_watched:1===i})),a=this.fetchCategory(o.get("category_id")),_.isUndefined(a)||(_.each(o.get("tags"),(function(t){t.is_visible&&a.addTag(t)})),a.set({num_topics:e.response.topic.category_num_topics,num_posts:e.response.topic.category_num_posts,num_users:e.response.topic.category_num_users}),AoPS.Community.MasterModel.trigger("this_user_posted_in_community",{new_topic:!0,data:e.response,topic_id:o.get("topic_id")})),e.response.topic_model=o)}),this),extra_handlers:t,extra_ajax_runner_options:{timeout:AoPS.Community.Constants.posting_ajax_timeout,queue_at_front:!0}})},submitPost:function(t){var s=a("bookmark_feed"),i=!1,o=a("notify_email");function a(e){return t.hasOwnProperty(e)&&t[e]?1:0}"boolean"!=typeof t.bookmark_feed&&"boolean"!=typeof t.notify_email||s==(t.topic.get("in_feed")?1:0)&&o==(t.topic.get("is_watched")?1:0)||(i=!0),e.add({a:"submit_post",params:{attachments:JSON.stringify(t.attachments),post_text:t.post_text,notify_email:o,topic_id:t.topic_id,allow_latex_errors:t.hasOwnProperty("allow_latex_errors")&&t.allow_latex_errors?1:0,last_post_num:t.topic.fetchLastLoadedPostNumber(),last_update_time:t.topic.get("last_update_time"),disable_bbcode:a("disable_bbcode"),is_announcement:a("is_announcement")},main_handler:_.bind((function(e,a){e&&(a.response.hasOwnProperty("new_data")&&a.response.new_data&&(t.topic.processTopicUpdate(a.response),t.topic.trigger("new_post_processed",{post_id:a.response.posts_data[0].post_id})),AoPS.Community.MasterModel.trigger("this_user_posted_in_community",{new_topic:!1,data:a.response,topic_id:t.topic_id}),i&&t.topic.resetBookmarkState({is_bookmarked:!0,in_feed:1===s,is_watched:1===o}))}),this),extra_handlers:t,extra_ajax_runner_options:{timeout:AoPS.Community.Constants.posting_ajax_timeout,queue_at_front:!0}})},fetchMyAopsCategory:function(t){var s=this;e.add({a:"fetch_my_aops_category",params:{category:t.category},main_handler:function(e,i){var o,a,r=!1;e&&(o=s.constructNewCategory(i.response.category_data.category),s.set(t.category,o),i.response.category_data.hasOwnProperty("items_categories")&&(a=o.get("items"),_.each(i.response.category_data.items_categories,(function(t){var e,i;t.category_id>0?(e=s.fetchCategory(t.category_id),_.isUndefined(e)&&(e=s.constructNewCategory(t),r=!0)):e=s.constructNewCategory(t),i=_.findWhere(a,{item_id:t.category_id}),_.isUndefined(i)||r||(t.hasOwnProperty("topics_data")&&"blog"!==e.get("category_type")&&(e.get("active_topics").add(s.processPotentialNewTopics(t.topics_data,!1)),t.all_topics_loaded&&e.set("all_topics_loaded",t.all_topics_loaded)),i.category=e)}))),i.response.constructed_category=o)},extra_handlers:t})},checkAddToWatchTimes:function(t){var e=parseInt(moment().format("X")),s=t.time_data;return e-s.model.get(s.int_time_field)<AoPS.Community.Constants.time_limits.watched_times_long&&(t.is_already_watched?this.updateLocationOnWatchedTimes(s):this.addToWatchedTimes(s),!0)},addToWatchedTimes:function(t){var e=parseInt(moment().format("X")),s=AoPS.Community.Constants.time_limits.watched_times_short;e-t.model.get(t.int_time_field)<s?this.get("watched_times_short").push(t):this.get("watched_times_long").push(t)},updateLocationOnWatchedTimes:function(t){var e,s,i=parseInt(moment().format("X")),o=AoPS.Community.Constants.time_limits.watched_times_short;i-t.model.get(t.int_time_field)<o?(e="watched_times_short",s="watched_times_long"):(e="watched_times_long",s="watched_times_long"),_.isUndefined(_.findWhere(this.get(e),t))&&(this.get(e).push(t),this.set(s,_.without(this.get(s),t)))},rebuildWatchedTimes:function(t){var e=!1;this.get(t).length>AoPS.Community.Constants.max_times_to_watch[t]&&(e=!0,AoPS.Community.Constants.time_limits[t]=Math.floor(.7*AoPS.Community.Constants.time_limits[t])),_.each(this.get(t),(function(t){t.model.set(t.rendered_time_field,AoPS.Community.Utils.makePrettyTime(t.model.get(t.int_time_field)))})),e&&this.filteredWatchedTimes(t)},filteredWatchedTimes:function(t){var e=parseInt(moment().format("X"))-AoPS.Community.Constants.time_limits[t],s=[];_.each(this.get(t),(function(t){t.model.get(t.int_time_field)<=e-5&&s.push(t)})),this.set(t,_.without(this.get(t),s)),"watched_times_short"===t&&this.set("watched_times_long",this.get("watched_times_long").concat(s))},fetchWatcherUpdates:function(){var t=this;e.add({a:"fetch_watcher_changes",params:{last_watcher_fetch_time:this.get("last_watcher_fetch_time")},main_handler:function(e,s){e&&(t.set("last_watcher_fetch_time",s.response.watch_time),_.each(s.response.watcher_data,(function(e){var s=t.fetchTopicById(e.topic_id);_.isNull(s)||s.set(e)})))},queue_limit:-1})},setBookmarkState:function(t){var e,s,i,o,a=this.get(t.category_string);return t=_.defaults(t,{item_main_color:"",item_secondary_color:"",item_subtitle:""}),!!this.has(t.category_string)&&(t.state.is_bookmarked?(e=t.state,o=t.state):(e={is_watched:t.bookmarked_item.get("is_watched"),in_feed:t.bookmarked_item.get("in_feed")},o={is_bookmarked:!1,in_feed:!1,is_watched:!1}),t.bookmarked_item.set(o),"topic"===t.item_type&&(i=this.fetchTopicById(t.item_id),_.isUndefined(i)||_.isNull(i)||(i!==t.bookmarked_item&&i.set(o),this.get("topics").remove(i,{removed_by:"topic_update"}),this.get("topics").add(i,{added_by:"topic_update"}))),s={item:{item_id:t.item_id,item_forum_id:0,item_type:t.item_type,item_text:t.item_text,in_feed:e.in_feed?1:0,is_watched:e.is_watched?1:0,item_main_color:t.item_main_color,item_secondary_color:t.item_secondary_color,item_subtitle:t.item_subtitle}},t.hasOwnProperty("onError")&&(s.onError=t.onError),t.hasOwnProperty("onFinish")&&(s.onFinish=t.onFinish),a[t.bookmarked_item.get("is_bookmarked")?"addItemDb":"removeItemDb"](s),!0)},setUserBookmarkState:function(t){var o,a,r=this;t.user.set("is_bookmarked",!t.user.get("is_bookmarked")),(a=t.user.get("is_bookmarked"))&&(o={item_id:t.user.get("user_id"),item_forum_id:0,item_type:"user",item_text:t.user.get("username"),in_feed:0,is_watched:0,item_main_color:i.community_main_color,item_secondary_color:i.community_secondary_color,item_subtitle:"",last_active:t.user.get("last_visit"),avatar:t.user.get("avatar")}),e.add({a:"bookmark_user",params:{bookmarked_user_id:t.user.get("user_id"),bookmark_action:t.user.get("is_bookmarked")?1:0},main_handler:function(e,i){var n;e?r.get("current_user").has("bookmark_users")&&r.get("current_user").get("bookmark_users")>0&&(n=r.fetchCategory(r.get("current_user").get("bookmark_users")),_.isUndefined(n)||(a?n.addItem(o):n.removeItem({item_id:t.user.get("user_id"),item_forum_id:0,item_type:"user"}))):("string"==typeof s["user-bookmark-err-"+i.error_code]?AoPS.Community.Views.showError(s["user-bookmark-err-"+i.error_code]):AoPS.Community.Views.showError(s["unexpected-error-code"]+i.error_code),t.user.set("is_bookmarked",!1))}})},addBookmarkForumViaAdmin:function(t){var e,s=t.item;"forum"!==s.item_type&&console.log("You sent the wrong type of item to addBookmarkForum. You\t\t\t\t\tdeserve the error report this user will give you."),e=this.fetchCategory(parseInt(s.item_id)),_.isUndefined(e)&&(e=this.constructTemporaryCategory({category_type:"forum"})),s.bookmarked_item=e,t.hasOwnProperty("onError")&&(s.onError=t.onError),s.category_string="bookmarked_forum_category",this.setBookmarkState(s)},fetchReportedPosts:function(t){var s=this,i=0;if(arguments.length>0?i=t.hasOwnProperty("fetch_before")?t.fetch_before:0:t={},!this.get("loading_post_reports")&&(this.set("loading_post_reports",!0),AoPS.session.logged_in)){var o=!1;e.add({a:"fetch_reported_posts",params:{last_reported_posts_fetch_time:this.get("last_reported_posts_fetch_time"),init_time:parseInt(AoPS.bootstrap_data.init_time),fetch_before:i},main_handler:function(t,e){t&&(_.each(e.response.reported_posts,(function(t){var e;t.hasOwnProperty("topic")&&_.isUndefined(s.get("reported_posts").findWhere({id:t.id}))&&(o=!0,t.topic.master=s,e=new AoPS.Community.Models.Topic(t.topic),t.post_data.topic=e,e.get("posts").add(t.post_data),t.post=e.get("posts").models[0],delete t.topic,s.get("reported_posts").add(t))})),0==i&&s.set("last_reported_posts_fetch_time",e.response.fetch_time),e.response.hasOwnProperty("resolved_reports")&&_.each(e.response.resolved_reports,(function(t){var e=s.get("reported_posts").findWhere({id:t.id});_.isUndefined(e)||e.set("status","resolved"),s.resetTopicReports({topic_id:t.topic_id,post_id:t.post_id,topic_num_reports:-1})}))),s.trigger("post_reports_fetched"),i>0&&!o&&s.set("all_past_reported_posts_fetched",!0),s.set("loading_post_reports",!1)},extra_handlers:t})}},resetTopicReports:function(t){var e,s=this.fetchTopicById(t.topic_id);_.isNull(s)||(e=s.get("posts").findWhere({post_id:t.post_id}),_.isUndefined(e)||e.set("reported",!1),-1==t.topic_num_reports?s.set("num_reports",s.get("num_reports")-1):s.set("num_reports",t.topic_num_reports),t.hasOwnProperty("remove_report")&&t.remove_report&&this.get("reported_posts").remove(t.report))},closePostReports:function(t){var e=this.get("reported_posts").where({post_id:t});_.each(e,(function(t){t.set("status","resolved")})),this.get("reported_posts").remove(e)},fetchPermission:function(t){var e=this.get("permissions");return e.hasOwnProperty(t)&&e[t]},fetchStaffPermission:function(t){var e=this.get("staff_permissions");return e.hasOwnProperty(t)&&e[t]},validateConstructCategory:function(t){var e;function s(e){t.hasOwnProperty("onError")&&t.onError(e)}switch(t.type){case"forum":case"view_tags":case"view_topics":case"view_posts":case"folder":case"blogroll":e="can_create_category";break;case"blog":e="can_create_blog";break;default:return s("E_BAD_TYPE"),!1}return!!this.fetchPermission(e)||(s("E_NO_PERMISSION"),!1)},getDefaultContainers:function(t){return[]},setTopicsForumLockStatus:function(t,e){var s,i=this.get("topics").models,o=i.length;for(s=0;s<o;s++)i[s].get("category_id")===t&&i[s].set("forum_locked",e)},setCategoryLockStatus:function(t,e){var s=this.fetchCategory(t);_.isUndefined(s)||s.setFrontEndLocked(e)},resetCategory:function(t){var e,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=this.fetchCategory(t),o=[];_.isUndefined(i)||(o=(e=i.get("active_topics")).filter((function(t){return"none"!==t.get("announce_type")})),e.reset(),s||e.add(o))},fetchLogResults:function(t){var s=this;e.add({a:"fetch_log",params:t.params,main_handler:function(t,e){t&&(e.response.all_fetched&&s.trigger("all_log_entries_fetched"),s.trigger("log_entry_fetch_time",{time:e.response.fetch_time}))},extra_handlers:t})},revertActions:function(t){e.add({a:"revert_actions",params:{log_ids:JSON.stringify(t.log_ids),table_type:t.table_type},main_handler:function(t,e){t&&e.response.all_fetched&&self.trigger("all_log_entries_fetched")},extra_handlers:t})},validateAdmin:function(t){e.add({a:"validate_admin",params:{pwd:t.pwd},main_handler:function(t,e){},extra_handlers:t})},sendPolymathConfirm:function(t){e.add({a:"send_polymath_confirm",params:{category_id:t.category_id,selected_option:t.selected_option,student_type:t.student_type},main_handler:function(t,e){},extra_handlers:t})},resetOfficeHoursPeople:function(t){var e=this;this.trigger("reset_office_hours_topics"),_.each(t,(function(t){var s,i=parseInt(t.user_id),o=t.username,a=t.avatar,r=parseInt(t.topic_id),n=parseInt(t.is_typing);s=e.fetchTopicById(r),_.isNull(s)||s.trigger("office_hours_person_here",{user_id:i,username:o,avatar:a,is_typing:n})}))},getFocusedTopicIds:function(){var t={master:0,feed:0};return _.isNull(this.get("focus_topic"))||_.isUndefined(this.get("focus_topic"))||(t.master=this.get("focus_topic").get("topic_id")),this.has("feed")&&(_.isNull(this.get("feed").get("focus_topic"))||_.isUndefined(this.get("feed").get("focus_topic"))||(t.feed=this.get("feed").get("focus_topic").get("topic_id"))),t},fetchOfficeHoursData:function(t){var s=this,o=this.getFocusedTopicIds();e.add({a:"fetch_office_hours_locations",params:{master_focus_topic_id:o.master,feed_focus_topic_id:o.feed},main_handler:function(e,o){e&&(o.response.office_hours_active?(s.resetOfficeHoursPeople(o.response.office_hours_people),t||setTimeout((function(){s.fetchOfficeHoursData()}),i.fetch_office_hours_interval)):s.trigger("reset_office_hours_topics"))}})},resetThanks:function(t){var i=this,o=t.currentTarget;o&&e.add({a:"delete-thanks",params:{user_id:o.getAttribute("user_id")},main_handler:function(t,e){e.error_code?(i.trigger("error",{error_code:e.error_code}),AoPS.Ui.Flyout.display(e.error_code)):(i.trigger("posts-resynced",e.response),AoPS.Ui.Flyout.display(s["cat-admin-thanks-reset"]))}})},updateIsTyping:function(t,s){e.add({a:"log_is_typing",params:{topic_id:t.get("topic_id"),is_typing:s?1:0},main_handler:function(t,e){}})}}),t.Feed=Backbone.Model.extend({defaults:{initialized:!1,focus_topic_show_from:"show_from_start",feed_setting:AoPS.bootstrap_data.hasOwnProperty("feed_init_setting")?AoPS.bootstrap_data.feed_init_setting:7,focus_topic:null,global_feed_type:"full",on_initial_feed_fetch:!1},initialize:function(){this.get("master").set("feed",this),this.set("page_subfeed_settings",{}),this.on("change:focus_topic",this.onChangeFocusTopic),this.on("change:feed_setting",this.onChangeFeedSetting),AoPS.bootstrap_data.hasOwnProperty("global_feed_settings")&&(this.set("global_feed_type",AoPS.bootstrap_data.global_feed_settings.global_feed_type),"custom"===this.get("global_feed_type")&&(AoPS.bootstrap_data.global_feed_settings.hasOwnProperty("global_feed_fora")&&AoPS.bootstrap_data.global_feed_settings.global_feed_fora.length>0?this.set("global_feed_fora",AoPS.bootstrap_data.global_feed_settings.global_feed_fora):this.set("global_feed_type","full")))},onChangeFocusTopic:function(t){var s=this.get("focus_topic"),i=this.previous("focus_topic");3===arguments.length&&arguments[2].hasOwnProperty("no_ajax_override")&&arguments[2].no_ajax_override||e.cancelAll({cancel_type:"feed"}),_.isNull(i)||i.set("is_feed_focus",!1),_.isNull(s)||s.set("is_feed_focus",!0),this.get("master").makeChangeFocusTopicAjaxCall({new_focus:s,previous_focus:i,source:"feed",hash:this.get("master").get("watcher_hash")})},onChangeFeedSetting:function(){e.add({a:"change_feed_setting",params:{feed_setting:this.get("feed_setting")},main_handler:function(t,e){}})},fetchInitialSubfeedTopics:function(t){var s,i=_.map(t,(function(t){return t.params.a=t.a,t.params})),o=this,a=t.length;this.set("on_initial_feed_fetch",!0),e.add({a:"run_multiple_ajax_calls",params:{type:"initial_feed_fetch",data:JSON.stringify(i)},never_cancel:!0,main_handler:function(e,i){if(e)for(o.set("initialized",!0),s=0;s<a;s++)t[s].main_handler(!0,{response:i.response.results[s]})},extra_handlers:{onFinish:function(e){for(s=0;s<a;s++)t[s].hasOwnProperty("extra_handlers")&&t[s].extra_handlers.hasOwnProperty("onFinish")&&t[s].extra_handlers.onFinish(e.results[s]);o.set("on_initial_feed_fetch",!1)},onError:function(e){for(s=0;s<a;s++)t[s].hasOwnProperty("extra_handlers")&&t[s].extra_handlers.hasOwnProperty("onError")&&t[s].extra_handlers.onError(e)}},source:"feed"})}}),t.UserList=Backbone.Model.extend({defaults:{all_fetched:!1,is_loading:!1,sort_column:"joined_at",sort_direction:"DESC",start_from:0,stub:""},initialize:function(){this.has("users")||this.set("users",[])},fetchMoreUsers:function(t){var s=this;this.get("all_fetched")||this.get("is_loading")||(this.set("is_loading",!0),e.add({a:"fetch_more_users",params:{stub:this.get("stub"),sort_column:this.get("sort_column"),sort_direction:this.get("sort_direction"),start_from:this.get("start_from")},main_handler:function(t,e){var i,a,r,n=[];if(t)if(0==(i=e.response).num_parsed)s.set("all_fetched",!0);else{if(0==(r=s.get("users").length))n=i.users;else for(a=0;a<r;a++)if(!s.isUserFetched(i.users[a])){n=i.users.slice(a);break}_.each(n,(function(t){t.last_visit>0?t.last_visit=o.makePrettyTime(t.last_visit):t.last_visit="",t.joined_at=o.makePrettyTime(t.joined_at)})),s.get("users").push(n),e.response.new_users=n,s.set("start_from",s.get("start_from")+i.num_parsed)}s.set("is_loading",!1)},extra_handlers:t}))},isUserFetched:function(t){for(var e=this.get("users"),s=e.length,i=Math.max(0,s-15),o=s-1;o>=i;o--)if(e[o].user_id===t.user_id)return!0;return!1}}),t.Category=t.Model.extend({defaults:{all_subcategories_loaded:!1,can_add:!1,can_add_type:"none",can_own_topics:!1,can_mark_all_read:!1,can_post:!1,can_remove_self:!0,can_target:!1,category_id:0,category_name:"",category_type:"",deleted:!1,has_halp:!1,has_source:!1,has_tag_filter:!1,has_topics:!1,hide_desc_on_phone:!1,in_feed:0,is_forum:!1,is_bookmark_category:!1,is_bookmarked:!1,is_locked:!1,is_my_category:!1,is_my_private:!1,is_post_search:!1,is_private:!1,is_public:!0,is_watched:0,last_item_level:0,last_item_score:0,loading_subcategories:!1,main_color:"#000000",no_more_items:!1,reset_on_items_change:!1,secondary_color:"#6c6c6c",short_description:"",special_url:"",subcategories_data_loaded:!1,visited:!1},initialize:function(){this.setDefault("forum_ids",[]),this.setDefault("items",[]),this.setDefault("users",[]),this.setDefault("forums",{})},setFrontEndLocked:function(t){this.set("is_locked",t),this.get("can_own_topics")&&this.get("master").setTopicsForumLockStatus(this.get("category_id"),t)},getPermission:function(t){return this.has("permissions")||console.log("Permission sought before permissions set for category "+this.get("category_name")),_.isUndefined(this.get("permissions")[t])&&console.log("Permissions have not been set for key "+t+" of Category "+this.get("category_name")),this.get("permissions")[t]},fetchItemsByType:function(t){return _.where(this.get("items"),{item_type:t})},fetchItemFromDb:function(t){e.add({a:"fetch_specific_item",params:{category_id:this.get("category_id"),item_id:t.item_id,item_forum_id:t.forum_id,item_type:t.item_type},main_handler:_.bind((function(t,e){t?e.response.success&&this.addItem(e.response.item):this.trigger("item_db_fetch_failed")}),this),extra_handlers:t})},fetchMoreItems:function(t){var s=this,i=0===arguments.length?{}:t;this.get("fetching_items")||(this.set("fetching_items",!0),this.get("no_more_items")||(e.add({a:"fetch_more_items",params:{category_id:this.get("category_id"),last_item_score:this.get("last_item_score"),last_item_level:this.get("last_item_level"),last_item_text:this.get("last_item_text"),log_visit:this.get("visited")?0:1,start_num:this.get("items").length,fetch_all:t.hasOwnProperty("fetch_all")&&t.fetch_all?1:0},main_handler:function(t,e){var i=!1;t&&e.response.hasOwnProperty("items")&&(_.each(e.response.items,(function(t){i=s.addItem(t)||i})),i?e.response.hasOwnProperty("no_more_items")&&s.set("no_more_items",e.response.no_more_items):s.set("no_more_items",!0),s.set("last_item_score",e.response.last_item_score),s.set("last_item_text",e.response.last_item_text)),s.set("fetching_items",!1)},extra_handlers:i}),this.set("visited",!0)))},fetchItemsForEdit:function(t){var s=this;e.add({a:"fetch_items_for_edit",params:{category_id:this.get("category_id")},main_handler:function(t,e){var i=[];t&&(_.each(e.response.items_for_edit,(function(t){t.edit_state="saved"})),s.set("items_for_edit",e.response.items_for_edit),e.response.hasOwnProperty("available_items")&&(_.each(e.response.available_items,(function(t){s.hasItem(t)||i.push(t)})),s.set("available_items",i)))},extra_handlers:t})},canAddEditItems:function(){var t=0;return!this.has("item_limit")||0===this.get("item_limit")||(_.each(this.get("items_for_edit"),(function(e){"deleted"!==e.edit_state&&t++})),t<this.get("item_limit"))},getSortDescription:function(t){return this.get("category_id")===i.other_forums_id?s["cat-admin-sort-type-system-other_forums"]:"system"===t?"string"==typeof s["cat-admin-sort-type-system-"+this.get("category_type")]?s["cat-admin-sort-type-system-"+this.get("category_type")]:s["cat-admin-sort-type-system-default"]:s["cat-admin-sort-type-"+t]},deleteEditItem:function(t){return"saved"===t.edit_state?(t.edit_state="deleted",!1):(t.edit_state="available",this.set("items_for_edit",_.without(this.get("items_for_edit"),t)),!0)},isActiveEditItem:function(t){var e=_.findWhere(this.get("items_for_edit"),{item_id:t.item_id,item_forum_id:t.item_forum_id,item_type:t.item_type});return!_.isUndefined(e)},fetchTopicEditItem:function(t){e.add({a:"fetch_topic_for_view",params:{category_id:this.get("category_id"),topic_id:t.topic_id},main_handler:function(t,e){},extra_handlers:t})},fetchAvailableItem:function(t){return _.findWhere(this.get("available_items"),{item_id:t.item_id,item_forum_id:t.item_forum_id,item_type:t.item_type})},fetchEditItem:function(t){return _.findWhere(this.get("items_for_edit"),{item_id:t.item_id,item_forum_id:t.item_forum_id,item_type:t.item_type})},addToEditItems:function(t){var e=this.fetchEditItem(t);_.isUndefined(e)&&this.get("items_for_edit").push(t)},removeAvailableItem:function(t){var e=this.fetchAvailableItem(t);_.isUndefined(e)||this.set("available_items",_.without(this.get("available_items"),e))},addToAvailableItems:function(t){var e=this.fetchAvailableItem(t);_.isUndefined(e)&&this.get("available_items").push(t)},saveItemEdits:function(t){var s=[];_.each(this.get("items_for_edit"),(function(t){"added"!==t.edit_state?s.push(_.omit(t,"post_data")):s.push(t)})),e.add({a:"save_item_edits",params:{change_sort_type:t.change_sort_type?1:0,sort_type:t.sort_type,edited_items:JSON.stringify(s),category_id:this.get("category_id")},main_handler:function(t,e){},extra_handlers:t})},hasItem:function(t){return!_.isUndefined(this.fetchItem(t))},makeItemOfThis:function(){return{category_id:this.get("category_id"),category_type:this.get("category_type"),is_visible:!0,item_forum_id:0,label:this.get("category_name"),main_color:this.get("main_color"),secondary_color:this.get("category_color"),short_description:this.get("short_description"),value:this.get("category_name")}},fetchMoreCategoryItems:function(t){var s,i,o,a,r,n=t.start_idx,c=this.get("items"),d=[],h=0,p=this,g=this.get("master");if(!this.get("all_subcategories_loaded")&&!this.get("loading_subcategories")){for(i=c.length,s=n;s<i&&h<AoPS.Community.Constants.max_categories_to_load;s++)(o=c[s]).hasOwnProperty("category")||("user"===o.item_type?(d.push(o),h++):(r=g.fetchCategory(o.item_id),_.isUndefined(r)?(d.push(o),h++):o.category=r));if(a={sought_category_ids:JSON.stringify(_.pluck(d,"item_id")),parent_category_id:this.get("category_id"),seek_items:0},h<AoPS.Community.Constants.max_categories_to_load&&!this.get("no_more_items")&&(a.seek_items=1,a.start_num=this.get("items").length),this.get("no_more_items")&&0===h)return this.set("all_subcategories_loaded",!0),void p.trigger("subcategories_loaded");a.log_visit=this.get("visited")?0:1,this.set("visited",!0),this.set("loading_subcategories",!0),e.add({a:"fetch_items_categories",params:a,main_handler:function(t,e){t&&(e.response.hasOwnProperty("categories")&&(_.each(e.response.categories,(function(t){var e=g.constructNewCategory(t),s=_.findWhere(d,{item_id:"bookmark_users"===p.get("category_type")?t.user_id:t.category_id});_.isUndefined(s)||(s.category=e)})),e.response.categories.length<d.length&&_.each(d,(function(t){var s=_.findWhere(e.response.categories,{category_id:t.item_id});_.isUndefined(s)&&p.removeItem(t)}))),e.response.hasOwnProperty("new_items")&&_.each(e.response.new_items,(function(t){if(t&&t.category){var e=g.fetchCategory(t.category.category_id);_.isUndefined(e)?(e=g.constructNewCategory(t.category),t.category=e):t.category=e,p.addItem(t)}})),e.response.hasOwnProperty("no_more_items")&&p.set("no_more_items",e.response.no_more_items),p.set("loading_subcategories",!1),p.trigger("subcategories_loaded"))}})}},fetchUsersData:function(){var t=[],s={};this.has("items")&&0!==this.get("items").length&&(_.each(this.get("items"),(function(e){"forum"===e.item_type&&e.hasOwnProperty("category")&&(t.push(e.item_id),s[e.item_id]=e.category)})),t.length>AoPS.Community.Constants.max_forums_user_update||e.add({a:"fetch_forum_users",params:{forum_ids:t.join(",")},main_handler:function(t,e){t&&_.each(e.response.forum_data,(function(t){s.hasOwnProperty(t.forum_id)&&s[t.forum_id].set("num_users",t.num_users)}))},queue_limit:-1}))},addItem:function(t){var e;if(!(1!==arguments.length&&arguments[1].hasOwnProperty("no_check_existing")&&arguments[1].no_check_existing||(e=this.fetchItem(t),_.isUndefined(e)||_.isNull(e)))){if(e.item_text===t.item_text)return!1;this.set("items",_.without(this.get("items"),e))}return 2===arguments.length&&arguments[1].hasOwnProperty("add_to_front")&&arguments[1].add_to_front?this.get("items").unshift(t):this.get("items").push(t),t.hasOwnProperty("category")||this.set("all_subcategories_loaded",!1),this.trigger("item_added",t),!0},addItems:function(t){var e=this;_.each(t,(function(t){e.addItem(t)}))},addItemsFront:function(t){var e;for(e=t.length-1;e>=0;e--)this.addItem(t[e],{add_to_front:!0})},fetchItem:function(t){return _.find(this.get("items"),(function(e){return e.item_id===t.item_id&&e.item_forum_id===t.item_forum_id&&e.item_type===t.item_type}))},addItemDb:function(t){var i=_.extend({in_feed:!1,is_watched:!1},t.item);(t=_.defaults(t,{add_to_client:!0,add_to_client_immediately:!1})).add_to_client_immediately&&this.addItem(t.item),i.in_feed=i.in_feed?1:0,i.is_watched=i.is_watched?1:0,e.add({a:"add_item_to_category",params:_.extend({category_id:this.get("category_id")},i),main_handler:_.bind((function(e,i){var o;e?t.add_to_client&&!t.add_to_client_immediately&&this.addItem(t.item):"E_ITEM_NUM_LIMITED"===i.error_code&&(AoPS.Ui.Flyout.display(s["err-bookmark-limit-reached"]),"topic"===t.item.item_type?(o=this.get("master").fetchTopicById(parseInt(t.item.item_id)),_.isNull(o)||o.set({is_bookmarked:!1,in_feed:!1,is_watched:!1})):"forum"===t.item.item_type?(o=this.get("master").fetchCategory(parseInt(t.item.item_id)),_.isUndefined(o)||o.set({is_bookmarked:!1,in_feed:!1,is_watched:!1})):"tag"===t.item.item_type&&(o=this.get("master").fetchCategory(parseInt(t.item.item_forum_id)),_.isUndefined(o)||(this.get("master").get("bookmarked_tag_category").removeItem(t.item),o.trigger("reset_tag_bookmark"))))}),this),extra_handlers:t})},removeItem:function(t){var e=this.fetchItem(t);_.isUndefined(e)||_.isNull(e)||(this.set("items",_.without(this.get("items"),e)),this.trigger("item_removed",e))},removeItemDb:function(t){var s=_.extend({remove_from_client:!0,remove_from_client_immediately:!1},t);s.remove_from_client_immediately&&this.removeItem(s.item),s.item.hasOwnProperty("category")&&delete s.item.category,e.add({a:"remove_item_from_category",params:_.extend({category_id:this.get("category_id")},s.item),main_handler:_.bind((function(t,e){t&&s.remove_from_client&&!s.remove_from_client_immediately&&this.removeItem(s.item)}),this),extra_handlers:s})},hasItems:function(){return this.has("items")&&this.get("items").length>0},makeItemAutocompleteCall:function(t,s,i){e.clearCallsOfType(t),e.add({a:t,params:s,main_handler:_.bind((function(t,e){var s;if(t){if(i.hasOwnProperty("checkSquelch")&&i.checkSquelch())return void i.response([]);s=_.map(e.response.items,(function(t){return _.defaults(t,{label:t.value})})),i.hasOwnProperty("checkInputExists")&&i.checkInputExists()&&(i.response(s),0===s.length&&i.hasOwnProperty("onNoMatch")&&i.onNoMatch(),s.length>0&&i.hasOwnProperty("onMatch")&&i.onMatch())}else i.response([])}),this)})},fetchItemAutocompleteMatches:function(t){this.makeItemAutocompleteCall("fetch_item_autocomplete_matches",{tag_stub:t.request.term,category_id:this.get("category_id")},t)},markVisited:function(){this.get("is_forum")&&AoPS.session.logged_in&&(this.get("is_watched")||this.get("is_monitored")&&this.getPermission("c_can_monitor"))&&e.add({a:"mark_category_visited",params:{category_id:this.get("category_id")},main_handler:function(t,e){}})},checkUserRole:function(t){var e=t.toLowerCase(),s=_.find(this.get("users"),(function(t){return t.username.toLowerCase()===e}));return _.isUndefined(s)?{role:"none"}:s},updateUserRole:function(t,s){this.get("category_id")>0&&e.add({a:"update_category_user",params:{category_id:this.get("category_id"),user_id:t.user_id,role:s},main_handler:function(t,e){}}),this.updateUserRoleInModel(t,s)},updateUserRoleInModel:function(t,e){var s=_.findWhere(this.get("users"),{user_id:parseInt(t.user_id)});_.isUndefined(s)||(s.role=e),this.trigger("users_changed")},checkAddedUsername:function(t){e.add({a:"check_username_added_to_category",params:{username:t.username},main_handler:function(t,e){},extra_handlers:t})},addUser:function(t){this.get("category_id")>0&&e.add({a:"add_category_user",params:{category_id:this.get("category_id"),user_id:t.user_id,role:t.role},main_handler:function(t,e){}}),this.addUserToModel(t)},addUserToModel:function(t){var e,s,i=this.get("users"),o=!1,a=t.username.toLowerCase(),r=i.length,n={user_id:parseInt(t.user_id),username:t.username,role:t.role,is_admin:parseInt(t.is_admin)};for(e=r-1;e>=0;e--){if(0===(s=a.localeCompare(i[e].username.toLowerCase())))return!1;if(s>0){i.splice(e+1,0,n),o=!0;break}}o||i.splice(0,0,n),this.trigger("users_changed")},removeUser:function(t){var s,i=this.get("users");s=_.findWhere(i,{user_id:parseInt(t.user_id)}),_.isUndefined(s)||(this.get("category_id")>0&&e.add({a:"remove_category_user",params:{category_id:this.get("category_id"),user_id:s.user_id},main_handler:function(t,e){},extra_handlers:t}),this.removeUserFromModel(s))},removeUserFromModel:function(t){this.set("users",_.without(this.get("users"),t)),this.trigger("users_changed")},removeUsersByRole:function(t){this.set("users",_.reject(this.get("users"),(function(e){return e.role===t})))},setLockedStatus:function(t){var s=this;this.get("category_id")>0?e.add({a:"set_category_lock_status",params:{category_id:this.get("category_id"),is_locked:t.is_locked?1:0},main_handler:function(e,i){e&&s.setFrontEndLocked(t.is_locked)},extra_handlers:t}):this.set("is_locked",t.is_locked)},toggleIsPublic:function(t){this.get("category_id")>0&&e.add({a:"set_is_public",params:{category_id:this.get("category_id"),is_public:this.get("is_public")?0:1},main_handler:function(t,e){},extra_handlers:t})},setHasSource:function(t){e.add({a:"set_has_source",params:{category_id:this.get("category_id"),has_source:t.has_source?1:0},main_handler:function(t,e){}}),this.set("has_source",t.has_source)},getAdminLangType:function(){switch(this.get("category_type")){case"forum":case"forum_class":return"forum";case"blog":return"blog";default:return"collection"}},setAdminItemSetting:function(t){e.add({a:"set_category_admin_item",params:{category_id:this.get("category_id"),setting:t.setting,value:t.value},main_handler:function(t,e){}})},burnNewCategory:function(t){var s,i,o=this;s={category_type:this.get("category_type"),category_name:this.get("category_name"),short_description:this.get("short_description"),role_inheritance_parent:this.has("role_inheritance_parent")&&!_.isNull(this.get("role_inheritance_parent"))?parseInt(this.get("role_inheritance_parent").item_id):0,users:JSON.stringify(this.get("users")),is_public:this.get("is_public")?1:0,is_locked:this.get("is_locked")?1:0,has_items:0,has_source:this.get("has_source")?1:0},"blog"===this.get("category_type")&&(i={},_.each(["show_profile_info","show_stats","show_shoutbox","show_contributors","show_tags","blog_post_comment_text","blog_comments_text","blog_one_comment_text","blog_no_comments_text"],(function(t){var e=o.get(t);"boolean"==typeof e&&(e=e?1:0),i[t]=e})),s.blog_settings=JSON.stringify(i),s.is_primary_blog=o.get("is_primary_blog")?1:0),this.get("items").length>0&&(s.has_items=1,s.items=JSON.stringify(this.get("items"))),e.add({a:"build_new_category",params:s,main_handler:function(t,e){},extra_handlers:t})},saveCoreDataToDb:function(t){e.add({a:"save_core_data",params:{category_id:this.get("category_id"),category_name:this.get("category_name"),short_description:this.get("short_description")},main_handler:function(t,e){},extra_handlers:t})},removeInheritanceParent:function(){e.add({a:"remove_inheritance_parent",params:{category_id:this.get("category_id")},main_handler:function(t,e){}})},setRoleInheritanceParent:function(t){e.add({a:"set_inheritance_parent",params:{category_id:this.get("category_id"),parent_id:t.parent_id},main_handler:function(t,e){},extra_handlers:t})},fetchCategoryAdminData:function(t){var s=this;e.add({a:"fetch_category_admin_data",params:{category_id:this.get("category_id"),get_items:s.get("no_more_items")?0:1,start_item_num:this.get("items").length},main_handler:function(t,e){t&&(s.set("users",e.response.users),e.response.hasOwnProperty("items")&&_.each(e.response.items,(function(t){s.addItem(t)})),e.response.hasOwnProperty("containers")&&s.constructContainersModel(e.response.containers),e.response.hasOwnProperty("role_inheritance_parent")&&s.set("role_inheritance_parent",e.response.role_inheritance_parent),e.response.hasOwnProperty("allowed_item_sort_types")&&s.set("allowed_item_sort_types",e.response.allowed_item_sort_types),e.response.hasOwnProperty("item_limit")&&s.set("item_limit",e.response.item_limit),"forum_class"===s.get("category_type")&&e.response.hasOwnProperty("class_id")&&s.set("class_id",e.response.class_id))},extra_handlers:t})},convertToContainer:function(t){return _.extend({category_id:this.get("category_id"),category_name:this.get("category_name"),short_description:this.get("short_description"),can_remove:0,main_color:this.get("main_color"),secondary_color:this.get("secondary_color")},t)},constructContainersModel:function(e){var s,i=_.map(e,(function(t){return{item_id:t.category_id,item_forum_id:0,item_type:"folder",item_text:t.category_name,item_subtitle:t.short_description,item_can_remove:t.can_remove,item_main_color:t.main_color,item_secondary_color:t.secondary_color}}));s=new t.ContainerHolder({category_id:this.get("category_id"),category_type:this.get("category_type"),category_name:this.get("category_name"),category:this,items:i}),this.set("container_model",s)},canAddItem:function(){return this.get("is_locked")?this.getPermission("c_can_override_lock"):this.getPermission("c_can_add_item")},canRemoveItem:function(){return this.get("is_locked")?this.getPermission("c_can_override_lock"):this.getPermission("c_can_remove_item")},startUsersMonitoring:function(){var t=this;this.get("master").constructIntervalAjax({interval_monitor_model:this,interval_id_property:"forums_users_monitor",interval_property:"fetch_forum_users_interval",method:function(){t.fetchUsersData()}})},stopUsersMonitoring:function(){this.has("forums_users_monitor")&&clearTimeout(this.get("forums_users_monitor"))},updateGlobalFeedSetting:function(t){e.add({a:"change_cat_global_feed",params:{category_id:this.get("category_id"),new_setting:t.new_setting},main_handler:function(t,e){},extra_handlers:t})},delete:function(t){e.add({a:"delete_category",params:{category_id:this.get("category_id"),delete_type:t.delete_type},main_handler:function(t,e){},extra_handlers:t})}}),t.CategoryMyForums=t.Category.extend({defaults:_.defaults({can_add_type:"forum",is_my_category:!0,category_type:"my_forums"},t.Category.prototype.defaults),initialize:function(){t.Category.prototype.initialize.apply(this),this.get("master").get("current_user").get("is_new_user")&&this.set("long_description",this.get("long_description")+s["new-user-my-forums"])}}),t.CategoryMyBlogs=t.Category.extend({defaults:_.defaults({can_add_type:"blog",is_my_category:!0,category_type:"my_blogs"},t.Category.prototype.defaults),initialize:function(){t.Category.prototype.initialize.apply(this),this.get("master").get("current_user").get("is_new_user")&&this.set("long_description",this.get("long_description")+s["new-user-my-blogs"])}}),t.CategoryMyCollections=t.Category.extend({defaults:_.defaults({can_add_type:"collection",is_my_category:!0,category_type:"my_collections"},t.Category.prototype.defaults),initialize:function(){t.Category.prototype.initialize.apply(this),this.get("master").get("current_user").get("is_new_user")&&this.set("long_description",this.get("long_description")+s["new-user-my-collections"])}}),t.CategoryViewPosts=t.Category.extend({defaults:_.defaults({category_type:"view_posts"},t.Category.prototype.defaults),createViewPostItem:function(t){e.add({a:"create_view_posts_item",params:{category_id:this.get("category_id"),post_type:t.post_type,post_label:t.post_label,post_id:t.post_id,hide_label:t.hide_label,custom_text:t.custom_text},main_handler:function(t,e){},extra_handlers:t})}}),t.CategoryWithTopics=t.Category.extend({defaults:_.defaults({all_topics_loaded:!1,are_announcements_fetched:!0,has_topics:!0,show_announcements:!1},t.Category.prototype.defaults),initialize:function(){var e=this.get("master").get("topics");t.Category.prototype.initialize.apply(this),this.buildTopicsCollections(),this.listenTo(e,"add",this.onAddMasterTopic),this.listenTo(e,"remove",this.onRemoveMasterTopic)},onRemoveMasterTopic:function(t,e,s){this.get("active_topics").remove(t,s)},onAddMasterTopic:function(t,e,s){var i=this.get("active_topics");s.hasOwnProperty("fetching_category")&&s.fetching_category==this.get("category_id")||!this.filterTopic(t)||(s.hasOwnProperty("force_to_active")&&s.force_to_active||this.get("all_topics_loaded")||i.length>0&&-this.topicsComparator(t)>=-this.topicsComparator(this.get("active_topics").last()))&&this.get("active_topics").add(t,s)},constructFetchTopicsArguments:function(e){var s=this.get("master").get("topics"),o=e.hasOwnProperty("tag_ids")&&e.tag_ids.length>0,a=[],r=this,n={a:"fetch_topics"};return n.params=_.defaults({category_type:this.get("category_type"),log_visit:this.get("visited")?0:1,required_tag:o?e.tag_ids[0].tag_forum_id+"_"+e.tag_ids[0].tag_id:"",fetch_before:e.fetch_before,user_id:"priv"===this.get("category_type")?this.get("user_id"):0,fetch_by_field:e.fetch_by_field,fetch_archived:this.get("is_private")&&this.get("is_archive")?1:0,fetch_announcements:this.get("are_announcements_fetched")?0:1},this.fetchFetchTopicParameters()),this.set("visited",!0),n.never_cancel="boolean"==typeof e.never_cancel&&e.never_cancel,e.hasOwnProperty("source")&&(n.source=e.source),n.main_handler=function(n,c){var d,h,p=i.very_large_time;h=e.hasOwnProperty("calling_list")?e.calling_list:{},n&&(c=c.response,o&&(d=r.get("active_topics").findWhere({announce_type:"none"}),_.isUndefined(d)||(p=d.get("last_post_time"))),r.set("are_announcements_fetched",!0),r.get("is_private")&&!r.get("is_archive")&&r.get("master").get("feed").get("on_initial_feed_fetch")&&c.topics.reverse(),_.each(c.topics,(function(e){var i,n,c,d=!0;if(r.get("is_post_search")){if(n=e.focus_post_data.post_id,c=r.get("active_topics").findWhere({focus_post_id:n}),!_.isUndefined(c))return;e.master=r.get("master"),(e=r.get("master").checkLoadedTopicPermissions(e)).search_settings=r.get("search_settings"),e.is_search_result=!0,i=new t.Topic(e),r.get("active_topics").add(i,{calling_list:h}),a.push(i)}else _.isNull(i=r.get("master").fetchTopicById(parseInt(e.topic_id)))?(e.category_id===r.get("category_id")&&(e.category=r),e.master=r.get("master"),e=r.get("master").checkLoadedTopicPermissions(e),i=new t.Topic(e),o?"none"===i.get("announce_type")?(a.push(i),i.get("last_post_time")<p&&(d=!1)):h.filter(i)&&a.push(i):a.push(i),d&&r.get("active_topics").add(i,{calling_list:h}),s.add(i,{fetching_category:r.get("category_id")})):("user_search_topics"===r.get("category_type")&&i.addParticipants(e.participants),"none"!==i.get("announce_type")?r.get("active_topics").add(i):o||r.get("active_topics").add(i,{calling_list:h}),i.get("category_id")!==e.category_id&&i.parsePotentialMove({new_category_id:e.category_id,category_name:e.category_name,category_main_color:e.category_main_color,category_secondary_color:e.category_secondary_color,can_read:!0,extra_data:{calling_list:h}}),"none"===i.get("announce_type")&&a.push(i))})),o||c.no_more_topics&&r.set("all_topics_loaded",!0),c.hasOwnProperty("num_search_results")&&r.set("num_posts_fetched",r.get("num_posts_fetched")+c.num_search_results),c.topics_found=c.hasOwnProperty("topics")&&!_.isNull(c.topics)&&c.topics.length>0,c.new_topics=a)},n.extra_handlers=e,n},fetchTopics:function(t){e.add(this.constructFetchTopicsArguments(t))},buildTopicsCollections:function(){var e,s,i=this;this.set("active_topics",new(Backbone.Collection.extend({model:t.Topic}))),this.get("active_topics").comparator=this.topicsComparator,this.has("topics_data")&&(s=this.get("active_topics"),"blog"===i.get("category_type")?(e=this.get("permissions"),_.each(this.get("topics_data"),(function(t){t.master=i.get("master"),t.permissions=e,s.add(t)}))):("forum"!==i.get("category_type")&&"forum_class"!==i.get("category_type")||(e=this.get("permissions"),_.each(this.get("topics_data"),(function(t){t.permissions=e}))),s.add(i.get("master").processPotentialNewTopics(this.get("topics_data"),!1))))},topicsComparator:function(t){return t.get("sort_value")?-t.get("sort_value"):-t.get("last_post_time")},filterTopic:function(t){return!1},fetchFetchTopicParameters:function(){return{}},getCollectionFetchBefore:function(t){var e,s;return 0===t.length?s=0:(e=t.models[t.length-1],s=t.category.get("is_post_search")?e.get("focus_post").get("post_time"):"none"!==e.get("announce_type")&&this.get("show_announcements")?0:e.get("last_post_time")),{value:s}}}),t.CategoryViewForums=t.CategoryWithTopics.extend({initialize:function(){this.buildForumsArray(),this.set({category_type:"view_forums",hide_desc_on_phone:!0,reset_on_items_change:!0}),t.CategoryWithTopics.prototype.initialize.apply(this),this.listenTo(this,"item_added item_removed",this.onItemsChange)},filterTopic:function(t){return _.indexOf(this.get("forums_array"),t.get("category_id"))>-1},fetchFetchTopicParameters:function(){return{forums_string:this.get("forums_array").join(",")}},buildForumsArray:function(){this.set("forums_array",_.map(this.get("items"),(function(t){return t.item_id})))},onItemsChange:function(){this.buildForumsArray(),this.set("all_topics_loaded",!1),this.get("active_topics").reset()},loadForums:function(t){var s,i=[],o=this.get("master").get("categories"),a=arguments.length>0?t:{},r=this;_.each(this.get("forums_array"),(function(t){s=o.find((function(e){return e.get("category_id")===t})),_.isUndefined(s)&&i.push(t)})),i.length>0?e.add({a:"fetch_categories_data",params:{category_ids:JSON.stringify(i)},main_handler:function(t,e){t&&(_.each(e.categories,(function(t){r.get("master").constructNewCategory(t)})),r.trigger("view_forums_loaded"),r.set("forums_loaded",!0))},extra_handlers:a}):(this.trigger("view_forums_loaded"),this.set("forums_loaded",!0),a.hasOwnProperty("onFinish")&&a.onFinish())}}),t.CategoryBookmarkForums=t.CategoryViewForums.extend({initialize:function(){t.CategoryViewForums.prototype.initialize.apply(this),this.set("category_type","bookmark_forums"),this.set("is_bookmark_category",!0)}}),t.CategoryMyBookmarks=t.Category.extend({defaults:_.defaults({no_more_items:!0,category_type:"my_bookmarks",long_description:AoPS.Community.Lang["my-bookmarks-long-desc"]},t.Category.prototype.defaults)}),t.CategoryGlobal=t.CategoryWithTopics.extend({initialize:function(){t.CategoryWithTopics.prototype.initialize.apply(this),this.set({category_type:"global"}),AoPS.Community.MasterModel.has("feed")&&"full"!==AoPS.Community.MasterModel.get("feed").get("global_feed_type")?(this.set("filter_topic_function",this.filterTopicCustomFeed),this.set("global_feed_fora",AoPS.Community.MasterModel.get("feed").get("global_feed_fora"))):this.set("filter_topic_function",this.filterTopicFullFeed)},filterTopic:function(t){return this.get("filter_topic_function").apply(this,[t])},filterTopicFullFeed:function(t){return"forum"===t.get("topic_type")},filterTopicCustomFeed:function(t){return _.indexOf(this.get("global_feed_fora"),t.get("category_id"))>-1}}),t.CategoryUsersTopics=t.CategoryWithTopics.extend({initialize:function(){t.CategoryWithTopics.prototype.initialize.apply(this),this.set({category_type:"user_search_topics"}),this.has("user_id")||console.log("You created a CategoryUsersTopics without specifying a user id. Bad."),this.get("master").get("watched_users").push(this.get("user_id"))},filterTopic:function(t){return t.has("participants")&&"forum"===t.get("topic_type")&&!_.isUndefined(_.findWhere(t.get("participants"),{user_id:this.get("user_id"),removed:!1}))},fetchFetchTopicParameters:function(){return{fetched_user_id:this.get("user_id")}}}),t.CategorySearch=t.CategoryWithTopics.extend({defaults:_.defaults({category_name:s["Search-Results"],num_posts_fetched:0,is_post_search:!0},t.CategoryWithTopics.prototype.defaults),initialize:function(){var e,o=this.get("master");this.has("search_settings")&&(e=this.get("search_settings")).hasOwnProperty("forums")&&1==e.forums.length&&e.forums[0]==i.private_messages_id&&this.set("category_name",s["private-search-results"]),t.CategoryWithTopics.prototype.initialize.apply(this),o.get("search_categories").add(this),this.set("search_id",o.get("search_categories").length),this.listenTo(this.get("active_topics"),"add",this.onAddSearchTopic)},onAddSearchTopic:function(t,e,s){t.set("in_master_topics",!1)},topicsComparator:function(t){return t.get("search_id")},onAddMasterTopic:function(t){},onRemoveMasterTopic:function(t){},fetchFetchTopicParameters:function(){return{search_settings:JSON.stringify(this.get("search_settings")),start_search_id:this.get("num_posts_fetched")}},filterTopic:function(){return!0}}),t.CategoryUsersPosts=t.CategoryWithTopics.extend({initialize:function(){var e;this.set("is_post_search",!0),t.CategoryWithTopics.prototype.initialize.apply(this),this.has("username")||(e=this.get("master").fetchUser(this.get("user_id")),_.isUndefined(e)||this.set("username",e.get("username"))),this.has("username")?this.set("category_name",o.formatString(s["user-search-posts-category-username"],[this.get("username")])):this.set("category_name",o.formatString(s["user-search-posts-category-user-id"],[this.get("user_id")])),this.listenTo(this.get("active_topics"),"add",this.onAddSearchTopic)},onAddSearchTopic:t.CategorySearch.prototype.onAddSearchTopic,topicsComparator:function(t){return-t.get("focus_post").get("post_time")},filterTopic:function(t){return t&&t.has("focus_post")&&t.get("focus_post").get("poster_id")===this.get("user_id")},fetchFetchTopicParameters:function(){return{fetched_user_id:this.get("user_id")}},onAddMasterTopic:function(t){},onRemoveMasterTopic:function(t){}}),t.CategoryConglomeration=t.CategoryWithTopics.extend({initialize:function(){var e=this;t.CategoryWithTopics.prototype.initialize.apply(this),this.set("category_type","conglomeration"),this.listenTo(this.get("active_topics"),"add",this.onAddTopic),_.each(this.get("categories"),(function(t){t.get("reset_on_items_change")&&e.listenTo(t,"item_added item_removed",e.resetTopicsCollection)}))},resetTopicsCollection:function(){this.set("all_topics_loaded",!1),this.get("active_topics").reset()},onAddTopic:function(t){_.each(this.get("categories"),(function(e){e.filterTopic(t)&&e.get("active_topics").add(t)}))},filterTopic:function(t){var e,s=this.get("categories"),i=s.length;for(e=0;e<i;e++)if(s[e].filterTopic(t))return!0;return!1},fetchFetchTopicParameters:function(){var t=[];return _.each(this.get("categories"),(function(e){var s=e.fetchFetchTopicParameters();s.category_type=e.get("category_type"),t.push(s)})),{categories_data:JSON.stringify(t)}},hasItems:function(){var t,e=this.get("categories"),s=e.length;for(t=0;t<s;t++)if(e[t].hasItems())return!0;return!1}}),t.CategoryViewTopics=t.CategoryWithTopics.extend({initialize:function(){t.CategoryWithTopics.prototype.initialize.apply(this),this.set("category_type","view_topics")},filterTopic:function(t){return!_.isUndefined(this.get("active_topics").findWhere({topic_id:t.get("topic_id")}))},fetchFetchTopicParameters:function(){return{category_id:this.get("category_id")}},onItemsChange:function(){}}),t.CategoryBookmarkTopics=t.CategoryViewTopics.extend({initialize:function(){t.CategoryViewTopics.prototype.initialize.apply(this),this.set("category_type","bookmark_topics"),this.set("is_bookmark_category",!0)},filterTopic:function(t){return t.get("is_bookmarked")},onItemsChange:function(){}}),t.CategoryFeedTopics=t.CategoryViewTopics.extend({initialize:function(){t.CategoryViewTopics.prototype.initialize.apply(this),this.set("category_type","feed_topics"),this.set("is_bookmark_category",!0)},filterTopic:function(t){return t.get("in_feed")},hasItems:function(){return!0},onItemsChange:function(){},fetchFetchTopicParameters:function(){return{category_id:this.get("bookmark_topic_category_id")}}}),t.CategoryForum=t.CategoryWithTopics.extend({defaults:_.defaults({all_read:!1,allow_autotag:!0,are_announcements_fetched:!1,can_start_topic:!0,can_own_topics:!0,can_mark_all_read:!0,category_type:"forum",has_tag_filter:!0,mark_time:0,last_post_time:0,is_forum:!0,show_announcements:!0},t.CategoryWithTopics.prototype.defaults),initialize:function(){var e,s=this;t.CategoryWithTopics.prototype.initialize.apply(this),this.set(this.get("master").fetchBookmarkStatus({item_id:this.get("category_id"),item_type:this.get("category_type"),item_forum_id:0})),AoPS.session.logged_in&&(this.on("change:mark_time change:last_post_time change:all_topics_loaded",this.parseMarkTime),this.listenTo(this.get("active_topics"),"add",this.onAddTopic),this.listenTo(this.get("active_topics"),"change:is_read",this.onTopicRead),this.parseMarkTime()),this.get("is_monitored")&&this.getPermission("c_can_monitor")&&this.addMonitorTags(),this.get("master").get("bookmarked_tag_category")&&(e=this.get("master").get("bookmarked_tag_category"),_.each(e.get("items"),(function(t){t.item_forum_id===s.get("category_id")&&-1==_.indexOf(i.monitoring_tag_id_array,t.item_id)&&(s.removeItem(t),s.addItem(t,{no_check_existing:!0,add_to_front:!0}))}))),this.get("show_announcements")&&this.get("active_topics").add(this.get("master").get("global_announcements").models),"forum_class"===this.get("category_type")&&this.set("can_remove_self",!1)},addMonitorTags:function(){var t=this,e=this.get("category_id"),s=this.get("main_color"),o=this.get("secondary_color");_.each(i.monitor_tags,(function(i){t.addItem({item_id:i.item_id,item_type:"tag",item_forum_id:e,item_text:i.item_text,item_subtitle:"",item_main_color:s,item_secondary_color:o},{no_check_existing:!0,add_to_front:!0})}))},getTermTagDictionary:function(){return AoPS.Community.hasOwnProperty("term_tag_map")?AoPS.Community.term_tag_map:{}},topicsComparator:function(t){return-t.get("last_post_time")-1e9*t.get("announce_factor")},onTopicRead:function(){arguments[2].hasOwnProperty("mark_all")&&arguments[2].mark_all||this.parseMarkTime()},parseMarkTime:function(){this.get("mark_time")>=this.get("last_post_time")?this.set("all_read",!0):this.set("all_read",!1)},onAddTopic:function(t){t.get("last_post_time")>this.get("last_post_time")&&this.set("last_post_time",t.get("last_post_time")),!t.get("is_read")&&t.get("last_post_time")<this.get("mark_time")&&this.set("mark_time",t.get("last_post_time")-1)},filterTopic:function(t){return t.get("category_id")===this.get("category_id")||this.get("show_announcements")&&"global"===t.get("announce_type")},fetchFetchTopicParameters:function(){return{category_id:this.get("category_id")}},addTag:function(t){this.addItem({item_id:t.tag_id,item_forum_id:this.get("category_id"),item_text:t.tag_text,item_type:"tag",item_main_color:this.get("main_color"),item_secondary_color:this.get("secondary_color")})},markAllTopicsRead:function(){AoPS.session.logged_in&&e.add({a:"mark_forum_read",params:{category_id:this.get("category_id")},main_handler:_.bind((function(t,e){t&&(this.set("mark_time",e.response.mark_time),this.get("active_topics").each((function(t){t.set("is_read",!0,{mark_all:!0})})))}),this)})},setBookmarkState:function(t){return this.get("master").setBookmarkState({state:t,category_string:"bookmarked_forum_category",bookmarked_item:this,item_id:this.get("category_id"),item_type:this.get("category_type"),item_text:this.get("category_name"),item_main_color:this.get("main_color"),item_secondary_color:this.get("secondary_color"),item_subtitle:this.get("short_description")})}}),t.CategoryPriv=t.CategoryForum.extend({defaults:_.defaults({show_announcements:!1,is_private:!0,category_id:AoPS.Community.Constants.private_messages_id,category_type:"priv",has_tag_filter:!0,are_announcements_fetched:!0,is_archive:!1},t.CategoryForum.prototype.defaults),initialize:function(){this.set("main_color",AoPS.Community.Constants.privates_main_color),this.set("secondary_color",AoPS.Community.Constants.privates_secondary_color),this.set({category_name:this.get("username")+" Private Messages",category_type:"priv"}),t.CategoryForum.prototype.initialize.apply(this)},topicsComparator:function(t){return-t.get("last_post_time")},filterTopic:function(t){var e;return t.get("category_id")===i.private_messages_id&&(e=this.get("user_id"),!_.isUndefined(_.findWhere(t.get("participants"),{user_id:e})))}}),t.CategoryPrivates=t.CategoryForum.extend({defaults:_.defaults({show_announcements:!1,is_private:!0,is_my_private:!0,category_id:AoPS.Community.Constants.private_messages_id,category_status:"active",category_type:"my_privates",has_tag_filter:!0,are_announcements_fetched:!0,is_archive:!1,pm_notification_open:!1},t.CategoryForum.prototype.defaults),initialize:function(){this.set("main_color",AoPS.Community.Constants.privates_main_color),this.set("secondary_color",AoPS.Community.Constants.privates_secondary_color),t.CategoryForum.prototype.initialize.apply(this),this.set("current_user",this.get("master").get("current_user")),this.set("user_id",this.get("current_user").get("user_id")),this.get("is_archive")||(this.setupLiveNotification(),this.listenTo(this.get("current_user"),"change:pm_live_notify",this.setupLiveNotification))},topicsComparator:function(t){return-t.get("last_post_time")},filterTopic:function(t){return t.get("category_id")===this.get("category_id")&&t.get("status")===this.get("category_status")},setupLiveNotification:function(){switch(this.has("new_pm_notification")&&this.stopListening(this.get("active_topics"),"add",this.get("new_pm_notification")),this.get("current_user").get("pm_live_notify")){case"modal":case"flyout":this.set("new_pm_notification",this.listenTo(this.get("active_topics"),"add",this.notifyNewMessage))}},notifyNewMessage:function(){var t=arguments[0],i=this.get("current_user"),a=this;t.get("is_read")||t.get("last_poster_id")===this.get("user_id")||this.get("pm_notification_open")||(!(t.get("last_post_time")<parseInt(AoPS.bootstrap_data.init_time))||this.get("master").get("feed").get("on_initial_feed_fetch")&&i.get("has_new_pm"))&&(this.set("pm_notification_open",!0),i.set("has_new_pm",!1),AoPS.bootstrap_data.hasOwnProperty("in_academy")&&0!=AoPS.bootstrap_data.in_academy||("modal"===i.get("pm_live_notify")?AoPS.Ui.Modal.showConfirm(o.formatString(s["pm-notify"],[t.get("last_poster_name"),t.get("topic_title")]),(function(e){e&&("string"==typeof AoPS.router_root&&"community"===AoPS.router_root?Backbone.history.navigate("/c1h"+t.get("topic_id"),{trigger:!0}):window.location.href="/community/c1h"+t.get("topic_id"))}),{title:s["pm-notify-title"],width:"500px",confirm_button_ok:s["pm-notify-btn-OK"],confirm_button_cancel:s["pm-notify-btn-cancel"],onClose:function(){a.set("pm_notification_open",!1)}}):(AoPS.Ui.Flyout.display(o.formatString(s["pm-notify-flyout"],[t.get("last_poster_name"),t.get("topic_title"),t.get("topic_id")])),setTimeout((function(){a.set("pm_notification_open",!1)}),5e3))),e.add({a:"set_profile_field",params:{user_id:i.get("user_id"),field:"has_new_pm",value:0},main_handler:function(t,e){}}))},fireNewMessageFlyout:function(){},checkValidPrivateRecipient:function(t){e.add({a:"check_valid_private_recipient",params:{username:t.username},main_handler:function(t,e){},extra_handlers:t})}}),t.CategoryBlog=t.CategoryForum.extend({defaults:_.defaults({all_read:!1,allow_autotag:!1,are_announcements_fetched:!1,can_mark_all_read:!0,can_start_topic:!0,category_type:"blog",creator_location:"",last_post_time:0,mark_time:0,show_announcements:!1,show_contributors:!0,show_custom_block:!0,show_profile_info:!0,show_shoutbox:!0,show_stats:!0,show_tags:!0},t.CategoryForum.prototype.defaults),initialize:function(){var e,s=this;t.CategoryForum.prototype.initialize.apply(this),_.each([{field:"blog_post_comment_text",default_field:"blog-default-post-comments"},{field:"blog_comments_text",default_field:"blog-default-comments"},{field:"blog_one_comment_text",default_field:"blog-default-one-comment"},{field:"blog_no_comments_text",default_field:"blog-default-no-comments"}],(function(t){s.has(t.field)&&0!==s.get(t.field).length||s.set(t.field,AoPS.Community.Lang[t.default_field])})),this.has("shout_topic_data")&&((e=this.get("shout_topic_data")).master=this.get("master"),this.set("shoutbox_topic",new AoPS.Community.Models.Shoutbox(e)),this.get("master").get("topics").add(this.get("shoutbox_topic")))},topicsComparator:function(t){return-t.get("first_post_time")},filterTopic:function(t){return"blog_post"===t.get("topic_type")&&t.get("category_id")===this.get("category_id")},getCollectionFetchBefore:function(t){return{value:0===t.length?0:t.models[t.length-1].get("first_post_time")}},setBitBlogSetting:function(t){var s=this;this.set(t.setting,t.value),this.get("category_id")>0&&e.add({a:"set_blog_bit_setting",params:{category_id:this.get("category_id"),setting:t.setting,value:t.value?1:0},main_handler:function(e,i){var o;e&&"is_primary_blog"===t.setting&&((o=s.get("master").get("current_user")).set("primary_blog_id",t.value?s.get("category_id"):0),o.set("primary_blog_name",t.value?s.get("category_name"):""))},extra_handlers:t})},setStringBlogSetting:function(t){this.set(t.setting,t.value),this.get("category_id")>0&&e.add({a:"set_blog_string_setting",params:{category_id:this.get("category_id"),setting:t.setting,value:t.value},main_handler:function(t,e){},extra_handlers:t})},setNewCss:function(t){e.add({a:"set_blog_css",params:{category_id:this.get("category_id"),new_css:t.new_css},main_handler:function(t,e){},extra_handlers:t})},deleteCss:function(t){e.add({a:"delete_blog_css",params:{category_id:this.get("category_id")},main_handler:function(t,e){},extra_handlers:t})}}),t.CategoryViewTags=t.CategoryWithTopics.extend({initialize:function(){this.buildTagsString(),this.set({category_type:"view_tags",has_tag_filter:!0,hide_desc_on_phone:!0,reset_on_items_change:!0}),t.CategoryWithTopics.prototype.initialize.apply(this),this.listenTo(this,"item_added item_removed",this.onItemsChange)},onItemsChange:function(){this.buildTagsString(),this.set("all_topics_loaded",!1),this.get("active_topics").reset()},onTopicTagChange:function(t){this.filterTopic(t)||(this.get("active_topics").remove(t,{removed_by:"topic_update"}),this.trigger("force_remove_topic",{topic:t}))},buildTagsString:function(){this.set("tags_string",_.map(this.get("items"),(function(t){return'"'+t.item_forum_id+"_"+t.item_id+'"'})).toString())},filterTopic:function(t){return t.hasTagInArray(this.get("items"))},fetchFetchTopicParameters:function(){var t={tags_string:this.get("tags_string")};return _.contains(i.office_hours_ids,this.get("category_id"))&&(t.category_id=this.get("category_id")),t}}),t.CategoryBookmarkTags=t.CategoryViewTags.extend({initialize:function(){t.CategoryViewTags.prototype.initialize.apply(this),this.set("category_type","bookmark_tags"),this.set("is_bookmark_category",!0)}}),t.Topic=t.Model.extend({defaults:{all_posts_fetched:!1,announce_factor:0,can_have_source:!1,cat_can_target:!1,deleted:!1,force_add_to_category:null,has_initial_posts_loaded:!1,in_master_topics:!0,is_feed_focus:!1,is_fetching_past_posts:!1,is_fetching_posts:!1,is_last_post_time_watched:!1,is_master_focus:!1,is_search_result:!1,is_restricted_soln:!1,num_named_watchers:0,num_watchers:0,poll_id:0,read_since_loading:!1,source:"",stretch_category:null,tags_processed:!1,watchers_usernames:""},postsComparator:function(t){return parseInt(t.get("post_id"))},initialize:function(){this.setDefault("tags",[]),this.setDefault("participants",[]),_.each(this.get("posts_data"),_.bind((function(t){t.topic=this}),this)),this.has("poll_data")||this.set("poll_data",{}),this.has("focus_post_data")&&(this.set("focus_post",new t.Post(this.get("focus_post_data"))),this.unset("focus_post_data"),this.set("focus_post_id",this.get("focus_post").get("post_id"))),this.set("posts",new(Backbone.Collection.extend({model:t.Post,comparator:this.postsComparator}))(this.get("posts_data"))),this.get("master").get("is_stretch_class")&&this.get("posts").each((function(t){t.set("reported",AoPS.Stretch.Utils.isPostReported(t.get("post_id")))})),this.get("posts").length>0&&this.checkAllPostsLoaded(),this.parseLastPostTime(),this.on("change:last_post_time",this.parseLastPostTime),this.get("master").checkAddToWatchTimes({time_data:{model:this,int_time_field:"first_post_time",rendered_time_field:"first_post_rendered_time"},is_already_watched:!1}),this.set("first_post_rendered_time",AoPS.Community.Utils.makePrettyTimeOldDateOnly(this.get("first_post_time"))),this.hasSolnTag()&&this.set("is_restricted_soln",!0)},isPrivateMessage:function(){return this.get("category_id")===AoPS.Community.Constants.private_messages_id},fetchSearchText:function(t){var e;return this.has("search_settings")?(e=this.get("search_settings")).hasOwnProperty("search_text")?e.search_text:e.hasOwnProperty(t)?e[t]:"":""},parseLastPostTime:function(){this.set("is_last_post_time_watched",this.get("master").checkAddToWatchTimes({time_data:{model:this,int_time_field:"last_post_time",rendered_time_field:"last_post_rendered_time"},is_already_watched:this.get("is_last_post_time_watched")})),this.set("last_post_rendered_time",AoPS.Community.Utils.makePrettyTimeOldDateOnly(this.get("last_post_time")))},getPermission:function(t){return this.has("permissions")?(_.isUndefined(this.get("permissions")[t])&&console.log("Permissions have not been set for key "+t+" of Category "+this.get("category_name")),this.get("permissions")[t]):(console.log("Permission sought before permissions set for category "+this.get("category_name")),!1)},addNewTag:function(t,s){this.has("category")||this.set("category",this.get("master").fetchCategory(this.get("category_id"))),e.add({a:"add_tag_to_topic",params:{topic_id:this.get("topic_id"),tag_id:t,tag_text:s},main_handler:_.bind((function(t,e){var s=e.response;t&&(s=e.response,this.get("tags").push(s.tag),_.isUndefined(this.get("category"))||this.get("category").addTag(s.tag),this.trigger("tag_added",{topic:this}))}),this)})},deleteTagFromTagsArray:function(t,e){var s=this.get("tags");this.set("tags",t>0?_.filter(s,(function(e){return e.tag_id!=t})):_.filter(s,(function(t){return t.tag_text!=e})))},removeTag:function(t,s){var i=this.get("tags");this.deleteTagFromTagsArray(t,s),e.add({a:"remove_tag_from_topic",params:{topic_id:this.get("topic_id"),tag_id:t,tag_text:s},main_handler:_.bind((function(e,o){e?(this.deleteTagFromTagsArray(t,s),this.trigger("tag_removed",{topic:this})):this.set("tags",i,{removed_by:"topic_update"})}),this)})},hasTag:function(t){var e,s=this.get("tags");for(t=parseInt(t),e=s.length-1;e>=0;e-=1)if(s[e].tag_id===t)return!0;return!1},hasSolnTag:function(){var t=/\/class\/[a-zA-Z0-9-]+\/(hw|sol)([0-9]+)/gm;return 2===_.map(this.get("tags"),(function(e){var s=t.exec(e.tag_text);return!!s&&s[1]})).filter((function(t){return t})).length},startRealtimePostMonitor:function(t){var e=this,s=this.get("last_post_time"),o=this.get("master").get("last_topic_fetch_time")-s>i.old_topic_age_in_seconds;this.get("master").constructIntervalAjax({interval_monitor_model:this,interval_id_property:"realtime_monitor"+t.source+t.hash,interval_property:o?"topic_update_interval_long":"topic_update_interval",method:function(){e.checkTopicUpdate(t)}}),o&&this.set("post_monitor_id",this.listenTo(this,"change:last_post_time",(function(){e.resetPostMonitor(t)})))},resetPostMonitor:function(t){this.stopRealtimePostMonitor(t),this.startRealtimePostMonitor(t)},stopRealtimePostMonitor:function(t){clearTimeout(this.get("realtime_monitor"+t.source+t.hash)),this.has("post_monitor_id")&&(this.stopListening(this.get("post_monitor_id")),this.unset("post_monitor_id")),this.unset("realtime_monitor"+t.source+t.hash)},fetchLastLoadedPostNumber:function(){return this.get("posts").last().get("post_number")},checkTopicUpdate:function(t){this.get("is_fetching_posts")||(this.set("is_fetching_posts",!0),e.add({a:"fetch_topic_update",params:{topic_id:this.get("topic_id"),last_post_num:this.fetchLastLoadedPostNumber(),last_update_time:this.get("last_posts_update_time"),hash:t.hash,source:t.source},main_handler:_.bind((function(t,e){t?this.onFinishTopicUpdateAjax(e.response):this.set("is_fetching_posts",!1)}),this),queue_limit:0}))},onFinishTopicUpdateAjax:function(t){t.new_data?(this.processTopicUpdate(t),this.set("last_posts_update_time",t.last_posts_update_time)):(this.set({num_watchers:t.num_watchers,num_named_watchers:t.num_named_watchers,watchers_usernames:t.watchers_usernames,watchers_avatars:t.watchers_avatars,num_views:t.num_views}),t.hasOwnProperty("poll_data")&&this.set("poll_data",t.poll_data)),this.set("is_fetching_posts",!1),this.set("is_fetching_past_posts",!1)},processTopicUpdate:function(t){var e,s=!1,i=!1,o={},a=this;this.set("last_update_time",t.last_update_time),this.get("master").get("focus_topic")===this&&(this.set("read",!0),i=!0),this.get("master").has("feed")&&this.get("master").get("feed").get("focus_topic")===this&&(this.set("read",!0),i=!0),i||this.set("is_read",t.is_read),this.get("last_post_time")==t.last_post_time&&this.get("last_poster_name")==t.last_poster_name||(s=!0),"private"==this.get("topic_type")&&this.set("status",t.status),t.hasOwnProperty("announce_type")&&this.get("announce_type")!=t.announce_type&&(this.set({announce_type:t.announce_type,announce_factor:t.announce_factor}),s=!0),AoPS.bd&&AoPS.bd.mode&&"office_hours"===AoPS.bd.mode&&(s=!1),_.each(["poll_data","topic_title","source","preview","num_posts","last_poster_name","last_post_id","last_poster_id","last_post_time","last_poster_avatar","num_reports","locked","target_url","target_text","state"],(function(e){t.hasOwnProperty(e)&&(o[e]=t[e])})),this.set(o),t.hasOwnProperty("updated_posts")&&t.updated_posts.length>0&&_.each(t.updated_posts,(function(t){a.parseEditedPost(t)})),t.hasOwnProperty("posts_data")&&t.posts_data.length>0&&this.parseNewArrayOfPosts(t.posts_data),t.hasOwnProperty("category_num_posts")&&(e=this.get("master").fetchCategory(this.get("category_id")),_.isUndefined(e)||e.set("num_posts",t.category_num_posts)),t.hasOwnProperty("participants")&&this.addParticipants(t.participants),t.hasOwnProperty("permissions")&&this.set("permissions",t.permissions),t.hasOwnProperty("num_watchers")&&this.set({num_watchers:t.num_watchers,num_named_watchers:t.num_named_watchers,watchers_usernames:t.watchers_usernames,watchers_avatars:t.watchers_avatars,num_views:t.num_views}),t.hasOwnProperty("tags")&&this.checkTagsChanged(t.tags),s&&this.get("in_master_topics")&&(this.get("master").get("topics").remove(this,{removed_by:"topic_update"}),this.get("master").get("topics").add(this,{added_by:"topic_update"})),this.get("all_posts_fetched")&&(this.get("num_posts")>this.get("posts").length||this.get("last_post_id")>this.get("posts").last().get("post_id"))&&this.set("all_posts_fetched",!1)},checkTagsChanged:function(t){var e,s=this.get("tags");e=this.checkArrayForNewTags(t),this.set("tags",t),e&&this.trigger("tag_added",{topic:this}),this.checkArrayForNewTags(s)&&this.trigger("tag_removed",{topic:this})},checkArrayForNewTags:function(t){var e,s=t.length;if(t.length>this.get("tags").length)return!0;for(e=0;e<s;e++)if(t[e].item_forum_id===this.get("category_id")&&!this.hasTag(t[e].item_id))return!0;return!1},hasTagInArray:function(t){var e,s=t.length;for(e=0;e<s;e++)if(t[e].item_forum_id===this.get("category_id")&&this.hasTag(t[e].item_id))return!0;return!1},onReadTopic:function(t){this.set("is_read",!0)},setState:function(t){var s=this;if(t.state!=this.get("state")){this.deleteTagFromTagsArray(0,"/"+this.get("state")),this.get("tags").push({tag_id:i.monitored_topic_tag_ids[t.state],tag_text:"/"+t.state,is_visible:!1}),this.trigger("tag_removed",{topic:this}),this.trigger("tag_added",{topic:this});var o=this.get("state");this.set("state",t.state),this.has("set_state_timeout")&&clearTimeout(this.get("set_state_timeout")),this.set("set_state_timeout",setTimeout((function(){e.add({a:"set_topic_state",params:{topic_id:s.get("topic_id"),state:t.state},main_handler:function(e,i){e||(AoPS.ErrorUtil.log("E_CMTY_SET_STATE_FAILED","Failed to update topic state.",{error_code:i.error_code,old_state:o,new_state:t.state,topic_id:s.get("topic_id")}),s.set("state",o))},never_cancel:!0,extra_ajax_runner_options:{no_filter:!0}})}),600))}},setMyStatus:function(t){var s=this.get("master");e.add({a:"set_participant_status",params:{topic_id:this.get("topic_id"),status:t.status},main_handler:function(t,e){},never_cancel:!0,extra_handlers:t}),this.isPrivateMessage()?(s.get("topics").remove(this),"removed"===t.status?this.destroy():(this.set("status",t.status),s.get("topics").add(this))):_.each(this.get("participants"),(function(e){e.user_id===AoPS.session.user_id&&(e.removed="removed"===t.status)}))},setBookmarkState:function(t){return this.get("master").setBookmarkState({state:t,category_string:"bookmarked_topic_category",bookmarked_item:this,item_id:this.get("topic_id"),item_type:"topic",item_text:""})},resetBookmarkState:function(t){var e=this;this.get("master").setBookmarkState({state:{is_bookmarked:!1,in_feed:!1,is_watched:!1},category_string:"bookmarked_topic_category",bookmarked_item:this,item_id:this.get("topic_id"),item_type:"topic",item_text:"",onFinish:function(){e.setBookmarkState(t)}})},processInitialPostFetch:function(t){var e=this,s=this.get("master").get("is_stretch_class");_.each(t.posts,(function(t){t.topic=e,s&&(t.reported=AoPS.Stretch.Utils.isPostReported(t.post_id))})),this.get("posts").add(t.posts),t.hasOwnProperty("participants")&&this.set("participants",t.participants),t.hasOwnProperty("permissions")&&this.set("permissions",t.permissions),this.set("last_posts_update_time",t.initialization_time),this.checkTagsChanged(t.tags),this.set(t.data_to_set_direct_on_topic),this.checkAllPostsLoaded(),this.set("is_fetching_posts",!1),this.set("is_fetching_past_posts",!1),this.trigger("post_load_complete")},fetchMorePosts:function(t){var s=AoPS.Community.Constants.num_posts_to_fetch,i=_.extend({source:"master"},t);this.get("all_posts_fetched")||(this.set("is_fetching_posts",!0),this.set("is_fetching_past_posts",!0),e.add({a:"fetch_posts_for_topic",params:{topic_id:this.get("topic_id"),direction:i.hasOwnProperty("direction")?i.direction:"forwards",start_post_id:i.hasOwnProperty("start_post_id")?i.start_post_id:-1,start_post_num:i.hasOwnProperty("start_post_num")?i.start_post_num:-1,show_from_time:i.hasOwnProperty("show_from_time")?i.show_from_time:-1,num_to_fetch:s},source:i.source,main_handler:_.bind((function(t,e){if(t){var s,o,a=e.response.posts.length,r=0,n=999999,c=!1,d=!1,h=[];for(this.trigger("post_load_complete"),s=0;s<a;s++)e.response.posts[s][i.show_from_setting]=!0,o=this.parsePotentialNewPost(e.response.posts[s]),h.push(o.post_model),"show_from_middle"===i.show_from_setting&&(!c&&o.post_model.get("show_from_start")&&(c=!0),!d&&o.post_model.get("show_from_end")&&(d=!0),o.post_model.get("post_number")<n&&(n=o.post_model.get("post_number")),o.post_model.get("post_number")>r&&(r=o.post_model.get("post_number")));c&&_.each(h,(function(t){t.set("show_from_start",!0)})),d&&_.each(h,(function(t){t.set("show_from_end",!0)})),this.checkAllPostsLoaded(),this.set("is_fetching_posts",!1),this.set("is_fetching_past_posts",!1),e.response.low_num=n,e.response.high_num=r,e.response.target_post_number=e.response.hasOwnProperty("target_post_number")?e.response.target_post_number:null,this.trigger("topic_updated")}this.set("is_fetching_posts",!1)}),this),extra_handlers:i}))},checkAllPostsLoaded:function(){this.get("num_posts")<=this.get("posts").length?(this.get("posts").each((function(t){t.set("show_from_start",!0),t.set("show_from_end",!0)})),this.set("all_posts_fetched",!0)):this.set("all_posts_fetched",!1)},parseNewArrayOfPosts:function(t){var e=this,s=!1;return _.each(t,(function(t){e.parsePotentialNewPost(t).new_post_found&&(s=!0)})),this.checkAllPostsLoaded(),s},parsePotentialNewPost:function(e){var s=this.checkPostLoaded(e.post_id),i=!1;return _.isNull(s)&&(e.topic=this,this.get("master").get("is_stretch_class")&&(e.reported=AoPS.Stretch.Utils.isPostReported(e.post_id)),s=new t.Post(e),this.get("posts").add(s),i=!0),{new_post_found:i,post_model:s}},checkRemoveLastPost:function(t){"none"!==t.delete_status&&(this.get("last_post_time")<=this.get("db_mark_time")&&this.set("is_read",!0),t.post_time>=this.get("last_post_time")&&this.get("in_master_topics")&&(this.get("master").get("topics").remove(this,{removed_by:"topic_update"}),this.get("master").get("topics").add(this,{added_by:"topic_update"})))},parseEditedPost:function(e){var s,i=this.getPermission("c_can_read_deleted");i&&(e.topic_data.num_posts+=e.topic_data.num_deleted),delete e.topic_data.num_deleted,this.set(e.topic_data),this.checkRemoveLastPost(e),0!==this.get("posts").length&&(s=this.checkPostLoaded(e.post_id),_.isNull(s)?"none"==e.delete_status&&this.get("all_posts_fetched")&&(e.show_from_start=!0,e.show_from_end=!0,e.topic=this,this.get("master").get("is_stretch_class")&&(e.reported=AoPS.Stretch.Utils.isPostReported(e.post_id)),s=new t.Post(e),this.get("posts").add(s)):"hard"==e.delete_status?(s.trigger("hard_delete"),this.get("posts").remove(s)):"soft"==e.delete_status?i?s.set("deleted",!0):(s.trigger("hard_delete"),this.get("posts").remove(s)):s.parseEdits(e))},checkPostLoaded:function(t){var e=this.get("posts");return 0===e.length?null:this.checkPostLoadedBinarySearch(t,0,e.length-1,e.models)},checkPostLoadedBinarySearch:function(t,e,s,i){var o,a;return s<e?null:t<(a=i[o=Math.floor((e+s)/2)].get("post_id"))?this.checkPostLoadedBinarySearch(t,e,o-1,i):t>a?this.checkPostLoadedBinarySearch(t,o+1,s,i):i[o]},submitNewParticipant:function(t){t.user.hasOwnProperty("user_id")||(t.user.user_id=0),e.add({a:"add_topic_participant",params:_.extend({topic_id:this.get("topic_id")},t.user),main_handler:_.bind((function(e,s){e?s.response.hasOwnProperty("participants")&&this.set("participants",s.response.participants):s.response.username=t.user.username}),this),extra_handlers:t})},checkValidPrivateRecipient:function(t){e.add({a:"check_valid_private_recipient",params:{username:t.username},main_handler:function(t,e){},extra_handlers:t})},addParticipants:function(t){var e,s,i,o=t.length;if(0!==o||!this.has("participants"))if(this.has("participants")&&this.get("participants").length===o){for(s=0;s<o;s++)if(i=t[s],e=_.findWhere(this.get("participants"),{user_id:i.user_id}),_.isUndefined(e)||e.removed!==i.removed)return void this.set("participants",t)}else this.set("participants",t)},delete:function(t){e.add({a:"delete_topic",params:{topic_id:this.get("topic_id"),delete_type:t.delete_type,reason:t.reason||""},main_handler:_.bind((function(t,e){t&&(Backbone.trigger("destroy_topic_view",{category_id:this.get("category_id"),topic_id:this.get("topic_id")}),this.set("deleted",!0,{deleted_by_me:!0}),this.destroy())}),this),extra_handlers:t})},move:function(t){var s=this.get("category_id");e.add({a:"move_topic",params:{topic_id:this.get("topic_id"),new_category_id:t.new_category_id,old_category_id:this.get("category_id")},main_handler:_.bind((function(e,i){e&&(this.set(i.response.new_topic_data),Backbone.trigger("destroy_topic_view",{category_id:s,topic_id:this.get("topic_id")}),this.get("master").get("topics").remove(this),this.get("master").get("topics").add(this),this.get("master").trigger("move_to_topic",{category_id:t.new_category_id,topic_id:this.get("topic_id"),replace:!0}))}),this),extra_handlers:t})},lock:function(t){this.setLockStatus(_.extend({lock_status:!0},t))},unlock:function(t){this.setLockStatus(_.extend({lock_status:!1},t))},setLockStatus:function(t){this.set("locked",t.lock_status),e.add({a:"set_lock_status",params:{topic_id:this.get("topic_id"),lock_status:t.lock_status?1:0,reason:t.reason||""},main_handler:function(t,e){}})},setAnnounceType:function(t){var s=this;e.add({a:"set_announce_type",params:{topic_id:this.get("topic_id"),announce_type:t.type,announce_through:t.announce_through},main_handler:function(e,i){var o;if(e){var a=2;"none"===t.type?a=0:"local"===t.type&&(a=1),s.set({announce_type:t.type,announce_factor:a}),s.get("master").get("topics").remove(s),s.get("master").get("topics").add(s),o=s.get("master").fetchCategory(s.get("category_id")),_.isUndefined(o)||0==o.get("active_topics").length&&o.get("active_topics").add(s)}},extra_handlers:t})},parsePotentialMove:function(t){var e;if(this.get("category_id")!=t.new_category_id){if(!t.can_read)return this.set("deleted",!0),void this.destroy();this.set({category_id:t.new_category_id,category_name:t.category_name,category_main_color:t.category_main_color,category_secondary_color:t.category_secondary_color}),e=this.get("master").fetchCategory(t.new_category_id),_.isUndefined(e)||this.set("permissions",e.get("permissions")),this.get("master").get("topics").remove(this,_.extend({removed_by:"topic_move"},"object"===_typeof(t.extra_data)?t.extra_data:{})),this.get("master").get("topics").add(this,_.extend({removed_by:"topic_move"},"object"===_typeof(t.extra_data)?t.extra_data:{}))}},computeDerivedPollData:function(){var t,e,s,i=0,o=!1,a=0;if(this.has("poll_data")){for(t=this.get("poll_data"),s=Object.keys(t.options).length,e=0;e<s;e++)i+=t.options[e].total;if(t.num_votes=i,0==i)for(e=0;e<s;e++)t.options[e].pct=0,t.options[e].bar_scale=0;else{for(e=0;e<s;e++)t.options[e].pct=Math.round(100*t.options[e].total/i),a=Math.max(a,t.options[e].pct),t.options[e].selected&&(o=!0);for(e=0;e<s;e++)t.options[e].bar_scale=Math.round(100*t.options[e].pct/a)}t.has_voted=o,t.can_vote=AoPS.session.logged_in&&!t.poll_closed&&(!o||t.allow_revote)}},castVote:function(t){var s=this;e.add({a:"cast_vote",params:{topic_id:this.get("topic_id"),votes:t.votes.join()},main_handler:function(t,e){t&&s.set("poll_data",e.response.poll_data)},extra_handlers:t})},removeTarget:function(t){var s=this;e.add({a:"remove_target_url",params:{topic_id:this.get("topic_id")},main_handler:function(t,e){t&&(s.deleteTagFromTagsArray(0,s.get("target_url")),s.set("target_url",""))},extra_handlers:t})},changeTargetUrl:function(t){var s,i=this;s=_.last(t.new_target.split(".com"));var o=t.new_target_text;e.add({a:"change_target_url",params:{topic_id:this.get("topic_id"),new_target:s,new_target_text:o,is_restricted:t.is_restricted?1:0},main_handler:function(t,e){t&&(i.deleteTagFromTagsArray(0,i.get("target_url")),i.get("tags").push({tag_id:e.response.new_tag.tag_id,tag_text:e.response.new_tag.tag_text,is_visible:e.response.new_tag.is_visible,is_public:e.response.new_tag.is_public}),i.set({target_url:e.response.new_tag.tag_text,target_text:e.response.new_tag.new_target_text}))},extra_handlers:t})},addHiddenTag:function(t){var s,i=this;s=_.last(t.new_text.split(".com")),e.add({a:"add_hidden_tag",params:{topic_id:this.get("topic_id"),new_text:s,is_restricted:t.is_restricted?1:0},main_handler:function(t,e){t&&(i.hasTag(e.response.new_tag.tag_id)||i.get("tags").push({tag_id:e.response.new_tag.tag_id,tag_text:e.response.new_tag.tag_text,is_visible:e.response.new_tag.is_visible,is_public:e.response.new_tag.is_public}))},extra_handlers:t})},checkShowTargetLink:function(){var t,e;return 0!==this.get("target_url").length&&(!((t=this.get("target_url").split("/")).length>3&&"class"===t[0]&&"ebook"===t[2])||(e=this.get("master").get("ebooks_available"),AoPS.session.logged_in&&_.indexOf(e,parseInt(t[3]))>-1))}}),t.Shoutbox=t.Topic.extend({postsComparator:function(t){return-parseInt(t.get("post_id"))},fetchLastLoadedPostNumber:function(){return this.get("posts").first().get("post_number")},checkPostLoadedBinarySearch:function(t,e,s,i){var o,a;return s<e?null:t>(a=i[o=Math.floor((e+s)/2)].get("post_id"))?this.checkPostLoadedBinarySearch(t,e,o-1,i):t<a?this.checkPostLoadedBinarySearch(t,o+1,s,i):i[o]}}),t.FilteredTopicList=Backbone.Collection.extend({model:t.Topic,initialize:function(t,e){this.topics_loading=!1,e.hasOwnProperty("master")?(e.hasOwnProperty("filter")||console.log("You created a filtered topic list without setting filter. You really deserve what happens next."),$.extend(this,e),this.category=e.category,this.all_topics_fetched=this.category.get("all_topics_loaded"),this.listenTo(this.category.get("active_topics"),"add",this.checkNewTopic),this.listenTo(this.category.get("active_topics"),"reset",this.emptyList),this.fetch_settings=_.pick(e,"category_id","tag_ids"),this.hasOwnProperty("tag_ids")&&this.tag_ids.length>0&&(this.listenTo(this.category.get("active_topics"),"tag_added",this.refilterActiveTopic),this.listenTo(this,"tag_removed",this.refilterActiveTopic)),this.listenTo(this.master.get("topics"),"remove",this.removeTopic),this.listenTo(this.category,"force_remove_topic",this.forceRemoveTopic)):console.log("You created a filtered topic list without setting master. You deserve what happens next.")},forceRemoveTopic:function(t){this.remove(t.topic,{removed_by:"topic_update"})},emptyList:function(){this.all_topics_fetched=!1,this.reset()},refilterActiveTopic:function(t){this.checkNewTopic(t.topic,null,{added_by:"topic_update"})||this.remove(t.topic,{removed_by:"topic_update"})},removeTopic:function(t,e,s){this.remove(t,s)},checkNewTopic:function(t,e,s){return(!s.hasOwnProperty("calling_list")||s.calling_list!==this)&&(!!this.filter(t)&&(this.add(t,s),!0))},constructFetchMoreTopicsParams:function(t){var e,s,i=this,o=this.length;return this.category.get("all_topics_loaded")&&(this.all_topics_fetched=!0,t.hasOwnProperty("onFinish")&&t.onFinish()),s=this.category.getCollectionFetchBefore(this),this.topics_loading=!0,e=_.extend({fetch_before:s.value,calling_list:this,never_cancel:"boolean"==typeof t.never_cancel&&t.never_cancel,onFinish:_.bind((function(e){this.add(e.new_topics,{add_in_bulk:!0,force_add:!!t.hasOwnProperty("force_add")&&t.force_add}),this.topics_loading=!1,(e.no_more_topics||!e.topics_found||0===s.value&&0===e.new_topics.length&&o===this.length)&&(this.all_topics_fetched=!0),this.trigger("bulk_topics_added"),!_.isUndefined(t)&&t.hasOwnProperty("onFinish")&&t.onFinish()}),this),onError:function(e){i.topics_loading=!1,!_.isUndefined(t)&&t.hasOwnProperty("onError")&&t.onError(e)}},this.fetch_settings),arguments.length>0&&t.hasOwnProperty("source")&&(e.source=t.source),e},constructAjaxCall:function(t){return this.category.constructFetchTopicsArguments(this.constructFetchMoreTopicsParams(t))},fetchMoreTopics:function(t){0===arguments.length&&(t={}),this.category.fetchTopics(this.constructFetchMoreTopicsParams(t))},fetchTopicById:function(t){return t=parseInt(t),this.find((function(e){return e.get("topic_id")===t}))}}),t.TopicList=t.Model.extend({defaults:{category_id:0},initialize:function(e){var s;this.setDefault("tag_ids",[]),e.hasOwnProperty("master")||console.log("You created a filtered topic list without setting master. You deserve what happens next."),e.hasOwnProperty("filter")||console.log("You created a filtered topic list without setting filter. You really deserve what happens next."),(s=new t.FilteredTopicList([],{category_id:this.get("category_id"),category:this.get("category"),tag_ids:this.get("tag_ids"),master:e.master,filter:e.filter})).comparator=this.get("category").topicsComparator,s.add(this.get("category").get("active_topics").filter(e.filter),{sort:!1}),s.sort(),this.set("filtered_topic_list",s)}}),t.Post=Backbone.Model.extend({defaults:{can_target:!1,deletable:!1,editable:!1,is_edit_time_watched:!1,is_forum_admin:!1,is_forum_mod:!1,last_edit_time_rendered:"",has_target:!1,real_poster_id:0,real_poster_username:""},initialize:function(){this.has("topic")&&(this.get("topic").get("master").checkAddToWatchTimes({time_data:{model:this,int_time_field:"post_time",rendered_time_field:"date_rendered"},is_already_watched:!1}),1===this.get("post_number")&&this.get("topic").get("cat_can_target")&&(this.set("can_target",!0),this.listenTo(this.get("topic"),"change:target_url",this.onChangeTopicTarget),this.get("topic").get("target_url").length>0&&this.set("has_target",!0))),this.set("date_rendered",AoPS.Community.Utils.makePrettyTime(this.get("post_time"))),this.set("last_edit_time_rendered",AoPS.Community.Utils.makePrettyTime(this.get("last_edit_time"))),this.parseEditData(),this.on("change:last_edit_time_rendered",this.parseEditData),this.get("attachment")||this.set("attachments",[]),this.set("original_attachments",this.get("attachments"))},onChangeTopicTarget:function(){this.set("has_target",this.get("topic").get("target_url").length>0)},parseEditData:function(){this.has("topic")&&this.get("num_edits")>0&&this.set("is_edit_time_watched",this.get("topic").get("master").checkAddToWatchTimes({time_data:{model:this,int_time_field:"last_edit_time",rendered_time_field:"last_edit_time_rendered"},is_already_watched:this.get("is_edit_time_watched")}))},report:function(t,s){e.add({a:"report_post",params:{reason_short:t,details:s,post_id:this.get("post_id")},main_handler:_.bind((function(t,e){t&&this.set("reported",!0)}),this)})},isDeletableByUser:function(){var t=this.get("topic");return!_.isUndefined(t)&&(!(!this.get("deletable")||this.get("post_id")!==t.get("last_post_id")||!t.getPermission("c_can_edit_own_posts"))&&(this.get("poster_id")===i.halp_user_id?!(!this.has("real_poster_id")||this.get("real_poster_id")!==AoPS.session.user_id||!t.getPermission("c_can_edit_own_posts")):this.get("poster_id")===AoPS.session.user_id))},delete:function(t){e.add({a:"delete_post",params:{hard_delete:t.hard_delete?1:0,topic_id:this.get("topic_id"),post_id:this.get("post_id"),reason:t.reason||""},never_cancel:!0,main_handler:_.bind((function(e,s){e?s.response.hasOwnProperty("topic_deleted")&&s.response.topic_deleted?(this.get("topic").set("deleted",!0,{deleted_by_me:!0}),this.get("topic").destroy()):(this.get("topic").get("master").closePostReports(this.get("post_id")),this.set("deleted",!0),this.set("reported",!1),s.response.topic_updated&&this.get("topic").processTopicUpdate(s.response.topic_data),t.hard_delete&&this.trigger("hard_delete")):"E_HARD_DELETE"===s.error_code&&this.trigger("hard_delete")}),this),extra_handlers:t})},undelete:function(t){e.add({a:"undelete_post",params:{topic_id:this.get("topic_id"),post_id:this.get("post_id")},never_cancel:!0,main_handler:_.bind((function(t,e){t?(this.set("deleted",!1),e.response.topic_updated&&this.get("topic").processTopicUpdate(e.response.topic_data)):"E_HARD_DELETE"===e.error_code&&this.trigger("hard_delete")}),this),extra_handlers:t})},setThankStatus:function(t){this.set("is_thanked",1==t.new_status),this.set("is_nothanked",-1==t.new_status),e.add({a:"set_thank_status",params:{post_id:this.get("post_id"),thank_status:t.new_status},main_handler:_.bind((function(t,e){t&&(e.response.hasOwnProperty("post_thank_count")&&this.set("thanks_received",e.response.post_thank_count),e.response.hasOwnProperty("post_nothank_count")&&this.set("nothanks_received",e.response.post_nothank_count),"string"==typeof e.response.thankers&&this.set("thankers",e.response.thankers))}),this)})},edit:function(t){var s=t.hasOwnProperty("disable_bbcode")&&t.disable_bbcode?"none":"bbcode",i=1===this.get("post_number"),o=this.get("attachment")?this.get("original_attachments"):[],a=!1;o.length===t.attachments.length?_.each(t.attachments,(function(t){0===t.existing&&(a=!0)})):a=!0,a||$.trim(t.edited_text)!=this.get("post_canonical")||s!==this.get("format")||i&&this.has("topic")&&(this.get("topic").get("topic_title")!==$.trim(t.topic_title)||this.get("topic").get("source")!==$.trim(t.source))?e.add({a:"edit_post",params:{post_id:this.get("post_id"),edited_text:t.edited_text,source:t.source,attachments:JSON.stringify(t.attachments),topic_title:t.topic_title,edit_reason:t.edit_reason,format:s,allow_latex_errors:t.allow_latex_errors?1:0},never_cancel:!0,main_handler:_.bind((function(e,s){e&&s.response.post_id===this.get("post_id")&&(s.response.show_from_start=this.get("show_from_start"),s.response.show_from_end=this.get("show_from_end"),this.parseEdits(s.response),this.has("topic")&&i&&this.get("topic").set({topic_title:s.response.topic_title,source:t.source}))}),this),extra_handlers:t}):t.hasOwnProperty("onError")&&t.onError({error_code:"E_NO_EDIT_MADE"})},parseEdits:function(t){t.last_edit_time>0&&(t.last_edit_time_rendered=AoPS.Community.Utils.makePrettyTime(t.last_edit_time)),!t.attachment&&this.get("attachment")&&(this.set("original_attachments",[]),t.attachments=[]),t.deletable=this.get("deletable"),t.editable=this.get("editable"),this.set(t)},checkShowTargetLink:function(){return!!this.get("has_target")&&this.get("topic").checkShowTargetLink()},fetchIP:function(t){e.add({a:"fetch_ip",params:{post_id:this.get("post_id")},main_handler:function(t,e){},extra_handlers:t})}}),t.PostReport=Backbone.Model.extend({initialize:function(){},settle:function(t){var s=this;e.add({a:"settle_post_report",params:{id:this.get("id"),topic_id:this.get("topic_id"),post_id:this.get("post_id"),notes:t.hasOwnProperty("notes")?t.notes:""},never_cancel:!0,main_handler:function(t,e){t&&(s.get("post").get("topic").get("master").resetTopicReports({topic_id:s.get("topic_id"),post_id:s.get("post_id"),topic_num_reports:e.response.topic_num_reports}),s.get("post").set("reported",!1),s.get("post").get("topic").get("master").closePostReports(s.get("post_id")))},extra_handlers:t})},decrementNumReports:function(){var t=this.get("topic_id"),e=this.get("post").get("topic").get("master").fetchTopicById(t);!_.isUndefined(e)&&!_.isNull(e)&&e.get("num_reports")>0&&e.set("num_reports",e.get("num_reports")-1)}}),t.ItemsHolder=Backbone.Model.extend({initialize:function(){},fetchMoreItems:function(){}}),t.ContainerHolder=t.ItemsHolder.extend({addItem:function(t){var s=this.fetchItem(t.item);_.isUndefined(s)?(this.get("items").push(t.item),this.trigger("item_added",t.item),this.get("category").get("category_id")>0&&e.add({a:"add_item_to_category",params:{category_id:t.item.item_id,item_id:this.get("category").get("category_id"),item_forum_id:0,item_type:this.get("category").get("category_type")},main_handler:function(t,e){}})):t.hasOwnProperty("onError")&&t.onError({error_code:"E_ALREADY_ADDED"})},fetchItem:function(t){return _.find(this.get("items"),(function(e){return e.item_id===t.item_id&&e.item_forum_id===t.item_forum_id&&e.item_type===t.item_type}))},removeItem:function(t){var s=this.fetchItem(t);_.isUndefined(s)||(this.set("items",_.without(this.get("items"),s)),this.trigger("item_removed"),this.get("category").get("category_id")>0&&e.add({a:"remove_item_from_category",params:{category_id:s.item_id,item_id:this.get("category").get("category_id"),item_forum_id:0,item_type:this.get("category").get("category_type")},main_handler:function(t,e){}}))}}),t.User=Backbone.Model.extend({defaults:{all_friends_loaded:!1,all_requests_loaded:!1,avatar:"",can_pm:!1,email:"",friends_initialized:!1,goals:"",has_classes:!1,has_ebooks:!1,hide_avatars:!1,hide_tags_on_topic:!1,interests:"",is_activated:!0,is_banned:!1,is_bookmarked:!1,is_coppa_blocked:!1,is_limited:!1,is_new_user:!1,is_online:!1,joined_at:0,loading_friends:!1,location:"",num_posts:0,occupation:"",posting_subscribe_reply:!1,school:"",show_last_visit:!0,show_tags_on_feed:!1,status:"",warn_on_snipes:!1,website:""},initialize:function(){this.set("joined_at",moment(this.get("joined_at"),"X").format("MMMM D, YYYY")),this.has("last_visit")&&this.get("last_visit")>0?this.get("is_online")?this.set("last_visit_pretty",AoPS.Community.Lang["user-item-online"]):this.set("last_visit_pretty",AoPS.Community.Utils.makePrettyTimeStatic(this.get("last_visit"))):this.set("last_visit_pretty",this.get("joined_at")),this.has("friends")?this.set("friends_initialized",!0):this.set("friends",[]),this.has("friend_requests")||this.set("friend_requests",[]),this.set("new_friends",[])},emptyFriends:function(){this.set("friends",[]),this.set("friend_requests",[]),this.set("all_friends_loaded",!1),this.set("friends_initialized",!1)},deleteAvatar:function(t){e.add({a:"delete_avatar",params:{user_id:this.get("user_id")},main_handler:function(t,e){},extra_handlers:t})},fetchFriends:function(t){var s,i=this;s="initial"===t.fetch_type?"":_.last(this.get(t.fetch_type)).username,this.set("loading_friends",!0),e.add({a:"fetch_friends",params:{user_id:this.get("user_id"),last_friend:s,fetch_type:t.fetch_type},main_handler:function(t,e){t&&(e.response.hasOwnProperty("all_friends_loaded")&&i.set("all_friends_loaded",e.response.all_friends_loaded),e.response.hasOwnProperty("friends")&&(e.response.loaded_friends=[],i.has("new_friends")&&0===i.get("new_friends").length?e.response.loaded_friends=e.response.friends:_.each(e.response.friends,(function(t){i.wasFriendAddedDuringThisPageLoad(t.user_id)||e.response.loaded_friends.push(t)})),i.set("friends",i.get("friends").concat(e.response.loaded_friends))),e.response.hasOwnProperty("friend_requests")&&i.set("friend_requests",i.get("friend_requests").concat(e.response.friend_requests)),e.response.hasOwnProperty("all_requests_loaded")&&i.set("all_requests_loaded",e.response.all_requests_loaded)),i.set("loading_friends",!1)},extra_handlers:t})},fetchBlockedUsers:function(t){t||(t={});var s=this;e.add({a:"fetch_blocked_users",params:{user_id:this.get("user_id")},main_handler:function(t,e){t&&s.set("blocked_users",e.response.blocked_users)},extra_handlers:t})},blockUser:function(t){t||(t={});var s=this,i=this.get("user_id"),o=t.blocked_user_id,a=t.blocked_username;e.add({a:"block_user",params:{user_id:i,blocked_user_id:o,blocked_username:a},main_handler:function(t){t&&s.fetchBlockedUsers()},extra_handlers:t})},unblockUser:function(t){t||(t={});var s=this,i=this.get("user_id"),o=t.blocked_user_id,a=t.blocked_username;e.add({a:"unblock_user",params:{user_id:i,blocked_user_id:o,blocked_username:a},main_handler:function(t,e){t&&s.fetchBlockedUsers()},extra_handlers:t})},fetchTopFora:function(t){var s=this;e.add({a:"fetch_top_fora",params:{user_id:this.get("user_id")},main_handler:function(t,e){t&&s.set("top_fora",e.response.top_fora)},extra_handlers:t})},wasFriendAddedDuringThisPageLoad:function(t){return!_.isUndefined(_.findWhere(this.get("new_friends"),{user_id:t}))},unFriend:function(t){var s,i=this;s=_.findWhere(i.get("friends"),{user_id:t.user_id}),_.isUndefined(s)||i.set("friends",_.without(i.get("friends"),s)),e.add({a:"unfriend",params:{user_id:t.user_id},main_handler:function(t,e){}})},setUserSetting:function(t){var s,i=this;s="boolean"==typeof this.get(t.field),e.add({a:"set_profile_field",params:{field:t.field,value:t.value,user_id:this.get("user_id")},main_handler:function(e,o){e&&(s&&(t.value=1===parseInt(t.value)),"friends_exclude"===t.field&&t.value&&i.emptyFriends(),"email"!==t.field&&i.set(t.field,t.value),"status"===t.field&&i.trigger("status_changed",{set_from:t.hasOwnProperty("set_from")?t.set_from:""}))},extra_handlers:t})},submitNewPassword:function(t){$.ajax({url:AoPS.protected_url+"m/community/ajax.php",timeout:1e4,type:"post",data:{a:"reset_password",new_password:t.new_password,aops_session_id:AoPS.session.id,old_password:t.old_password},crossDomain:!0,xhrFields:{withCredentials:!0},error:function(t){},success:function(e){e.hasOwnProperty("error_code")?t.hasOwnProperty("onError")&&t.onError(e):t.hasOwnProperty("onFinish")&&t.onFinish(e.response)}})},closeFriendRequest:function(t){var s=this;e.add({a:"close_friend_request",params:{user_id:t.user_id,action:t.action},main_handler:function(e,i){var o;e&&(o=i.response.new_friend_data,"accepted"===t.action&&(s.get("new_friends").push(o),s.get("friends").unshift(o)))},extra_handlers:t}),this.set("friend_requests",_.reject(this.get("friend_requests"),(function(e){return e.user_id===t.user_id})))},archiveAllPrivates:function(){var t,s,i=this.get("master"),o=i.get("my_privates").get("active_topics"),a=o.length;if(i.get("current_user")===this){for(t=a-1;t>=0;t--)(s=o.models[t]).set("status","archived"),i.get("topics").remove(s),i.get("topics").add(s);i.get("my_privates_archive").set("all_topics_loaded",!1),e.add({a:"archive_all_privates",params:{},main_handler:function(t,e){}})}},removeFromAllPrivates:function(){var t,s,i=this.get("master"),o=i.get("my_privates").get("active_topics"),a=i.get("my_privates_archive").get("active_topics"),r=o.length,n=a.length;if(i.get("current_user")===this){for(t=r-1;t>=0;t--)s=o.models[t],i.get("topics").remove(s),s.destroy();for(t=n-1;t>=0;t--)s=a.models[t],i.get("topics").remove(s),s.destroy();e.add({a:"remove_from_all_privates",params:{},main_handler:function(t,e){}})}},clearBookmarks:function(t){e.add({a:"clear_bookmarks",params:{user_id:this.get("user_id"),bookmark_section:t.bookmark_section,clear_type:t.clear_type},main_handler:function(t,e){},extra_handlers:t})},addNote:function(t){e.add({a:"add_user_note",params:{user_id:this.get("user_id"),note_text:t.note_text},main_handler:function(t,e){},extra_handlers:t})},makeItemOfThis:function(){return{is_admin:this.get("is_admin"),is_visible:!0,label:this.get("username"),user_id:this.get("user_id"),value:this.get("username")}},setBlogSubscriptionStatus:function(t){e.add({a:"set_blog_subscription",params:{blog_id:t.blog_id,status:t.status?1:0},main_handler:function(t,e){}})}}),t.CategoryUser=t.User.extend({getPermission:function(t){return"c_can_read"===t}}),t.TagTermManager=t.Model.extend({defaults:{focus_tag:null,focus_term:null},initialize:function(){this.set("tags",new(Backbone.Collection.extend({model:t.Tag}))),this.get("tags").comparator=function(t){return t.get("tag_text").toLowerCase()},this.set("terms",new(Backbone.Collection.extend({model:t.Term}))),this.get("terms").comparator=function(t){return t.get("term_text").toLowerCase()}},fetch_map:function(t){var s=this;e.add({a:"fetch_tag_term_map",params:{},main_handler:function(t,e){t&&(s.get("terms").add(e.response.terms),s.get("tags").add(e.response.tags),_.each(e.response.maps,(function(t){var e,i;e=s.findTagById(t.tag_id),i=s.findTermById(t.term_id),_.isUndefined(e)||_.isUndefined(i)||(e.get("mapped_terms").add(i),i.get("mapped_tags").add(e))})))},extra_handlers:t})},findTagById:function(t){return this.get("tags").findWhere({tag_id:t})},findTermById:function(t){return this.get("terms").findWhere({term_id:t})},deleteMap:function(t){t.term.get("mapped_tags").remove(t.tag),t.tag.get("mapped_terms").remove(t.term),e.add({a:"remove_tag_term_map",params:{tag_id:t.tag.get("tag_id"),term_id:t.term.get("term_id")},main_handler:function(t,e){}})},deleteTerm:function(t){t.term.get("mapped_tags").each((function(e){e.get("mapped_terms").remove(t.term)})),this.get("terms").remove(t.term),e.add({a:"delete_term",params:{term_id:t.term.get("term_id")},main_handler:function(e,s){e&&t.term.destroy()}})},addTagToFocusTerm:function(t){var e=this.get("tags").findWhere({tag_id:t.item_id});_.isUndefined(e)&&(e=new AoPS.Community.Models.Tag({tag_id:t.item_id,tag_text:t.label})),this.get("tags").add(e),this.mapTagTerm(e,this.get("focus_term")),this.saveTagTermMap({tag_id:t.item_id,term_id:this.get("focus_term").get("term_id")})},addTermToFocusTag:function(t){this.mapTagTerm(this.get("focus_tag"),t),this.saveTagTermMap({tag_id:this.get("focus_tag").get("tag_id"),term_id:t.get("term_id")})},addTermTextToFocusTag:function(s){var i=this,o=this.get("terms").findWhere({text_lc:s.term_text.toLowerCase()});_.isUndefined(o)?e.add({a:"add_new_term_text_to_tag",params:{term_text:s.term_text,tag_id:this.get("focus_tag").get("tag_id")},main_handler:function(e,o){var a;e&&(a=new t.Term({term_id:o.response.term_id,term_text:s.term_text}),i.get("terms").add(a),i.mapTagTerm(i.get("focus_tag"),a))},extra_handlers:s}):this.addTermToFocusTag(o)},saveTagTermMap:function(t){e.add({a:"add_tag_term_map",params:{tag_id:t.tag_id,term_id:t.term_id},main_handler:function(t,e){}})},mapTagTerm:function(t,e){t.get("mapped_terms").add(e),e.get("mapped_tags").add(t)},constructTermAutocompleteSource:function(){return this.get("terms").map((function(t){return{value:t.get("term_text"),label:t.get("term_text"),term:t}}))},buildNewTerm:function(s){var i,o=s.term_text.toLowerCase(),a=this;i=this.get("terms").findWhere({text_lc:o}),_.isUndefined(i)||s.hasOwnProperty("onFinish")&&s.onFinish({term:i}),e.add({a:"construct_new_term",params:{term_text:s.term_text},main_handler:function(e,i){var o;e&&(o=new t.Term({term_text:s.term_text,term_id:i.response.term_id}),a.get("terms").add(o),i.response.term=o)},extra_handlers:s})},loadTagById:function(t){var s=this.get("tags").findWhere({tag_id:t.tag_id}),i=this;_.isUndefined(s)?e.add({a:"load_tag_by_id",params:{tag_id:t.tag_id},main_handler:function(t,e){t&&i.get("tags").add({tag_id:e.response.tag_id,tag_text:e.response.tag_text})},extra_handlers:t}):"function"==typeof t.onFinish&&t.onFinish({tag_id:t.tag_id})},deleteFocusTerm:function(){this.deleteTerm({term:this.get("focus_term")}),this.set("focus_term",null)},addNewTagTextToFocusTerm:function(s){var i=this;e.add({a:"add_new_tag_text_to_term",params:{term_id:this.get("focus_term").get("term_id"),tag_text:s.tag_text},main_handler:function(e,o){var a;e&&(a=i.get("tags").findWhere({tag_id:o.response.tag_id}),_.isUndefined(a)&&(a=new t.Tag({tag_id:o.response.tag_id,tag_text:s.tag_text})),i.get("tags").add(a),i.mapTagTerm(a,i.get("focus_term")))},extra_handlers:s})},fetchItemAutocompleteMatches:function(t){this.makeItemAutocompleteCall("fetch_tag_term_autocomplete",{text_stub:t.request.term,fetch_type:t.additional_params.type},t)},fetchTagIdByText:function(t){var s=this;e.add({a:"fetch_tag_by_text",params:{tag_text:t.tag_text,create_new:t.hasOwnProperty("create_new")&&t.create_new?1:0,suppress_clean:t.hasOwnProperty("suppress_clean")&&t.suppress_clean?1:0},main_handler:function(e,i){var o;e&&(o=s.findTagById(i.response.tag_id),_.isUndefined(o)&&(o=new AoPS.Community.Models.Tag({tag_id:i.response.tag_id,tag_text:t.tag_text}),s.get("tags").add(o)),i.response.tag=o)},extra_handlers:t})},makeItemAutocompleteCall:t.Category.prototype.makeItemAutocompleteCall}),t.Tag=t.Model.extend({initialize:function(){this.set("text_lc",this.get("tag_text").toLowerCase()),this.set("mapped_terms",new(Backbone.Collection.extend({model:t.Term}))),this.get("mapped_terms").comparator=function(t){return t.get("text_lc")}},fetchForumData:function(t){var s=this;e.add({a:"fetch_tag_forum_data",params:{tag_id:this.get("tag_id")},main_handler:function(t,e){t&&s.set("forum_data",e.response.forum_data)},extra_handlers:t})},recapitalize:function(t){e.add({a:"recapitalize_tag",params:{tag_id:this.get("tag_id"),new_text:t.new_text},main_handler:function(t,e){},extra_handlers:t})},mergeToTag:function(t){var s=t.hasOwnProperty("affected_categories")?t.affected_categories:[];e.add({a:"merge_tags",params:{merge_from:this.get("tag_id"),merge_to:t.new_tag_id,affected_categories:JSON.stringify(s)},main_handler:function(t,e){},extra_ajax_runner_options:{timeout:24e4},extra_handlers:t})},deleteTag:function(t){var s=t.hasOwnProperty("affected_categories")?t.affected_categories:[];e.add({a:"delete_tag_admin",params:{tag_id:this.get("tag_id"),delete_type:t.delete_type,affected_categories:JSON.stringify(s)},main_handler:function(t,e){},extra_ajax_runner_options:{timeout:24e4},extra_handlers:t})}}),t.Term=t.Model.extend({initialize:function(){this.set("text_lc",this.get("term_text").toLowerCase()),this.set("mapped_tags",new(Backbone.Collection.extend({model:t.Tag}))),this.get("mapped_tags").comparator=function(t){return t.get("text_lc")}}}),t}(AoPS.Community.Models||{});
;function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}AoPS.Community.Views=function(t){var e=AoPS.Community.Lang,i=AoPS.Community.Constants,o=AoPS.Community.Utils,s=AoPS.Ui.Modal,n=AoPS.Ui.Flyout;return t.in_academy=AoPS.in_academy,t.clicking=!1,$(document).on("mousedown.watcher",(function(){t.clicking=!0})).on("mouseup.watcher",(function(){t.clicking=!1})),t.isIOS=navigator.userAgent.match(/iPhone|iPad|iPod/i),t.isIOS&&(i.max_num_shown_topics=170,i.num_topics_to_hide=80,i.num_topics_to_reveal=40),jQuery.fn.extendedHighlightText=function(t,e){var i,o=$(this);i=(e=e.replace(/[^a-zA-Z0-9\' _-]/g," ").replace(/ +(?= )/g,"")).split(" "),_.each(i,(function(e){o.highlightText(t,e)}))},jQuery.fn.cmtyLoadFromFile=function(t){var e=$(this);o.cmty_ajax.add({a:"load_file",params:{filename:t.filename},main_handler:function(t,i){t&&e.html(i.response.file_contents)},extra_handlers:t})},jQuery.fn.highlightText=function(t,e){var i=new RegExp(e.toUpperCase().replace(/\*/,".*"));function o(e,s){var n,a,r,l,c,d=0;if(3===e.nodeType)n=e.data.toUpperCase().match(i),_.isNull(n)||((a=document.createElement("span")).className=t,l=(r=e.splitText(n.index)).cloneNode(!0),a.appendChild(l),r.parentNode.replaceChild(a,r),d=1);else if(1===e.nodeType&&e.childNodes&&!/(script|style)/i.test(e.tagName))for(c=0;c<e.childNodes.length;++c)c+=o(e.childNodes[c],s);return d}return this.length&&e&&e.length?this.each((function(){o(this,e.toUpperCase())})):this},jQuery.fn.stripSpansByClass=function(t){return this.find("span."+t).each((function(){this.parentNode.replaceChild(this.firstChild,this),this.parentNode.normalize()})).end()},t.buildCommunityScrollbar=function(t){if(t){var e={fade_start_class:"aops-scroll-fade-top",fade_end_class:"aops-scroll-fade-bottom",slider_end_tolerance:2,autosize:!0,autosize_nudge:8,stop_scroll_propagation:!0},i=1===arguments.length?e:_.extend(e,arguments[1]),o=t.wrapWithScroll(i);return o.addClass("cmty-scroll-outer"),o}},t.inCmtyRouter=function(){return AoPS.hasOwnProperty("pushState_attr")&&"data-cmty"===AoPS.pushState_attr},t.throwAjaxError=function(t){var i;if("E_NO_PERMISSION"===t.error_code)i=e["err-no-permission"];else i=o.formatString(e["err-unknown"],[t.error_code]);s.showAlert(i,{onClose:function(){s.closeAllModals()}})},t.onPMPage=function(){return"my-message"===Backbone.history.fragment.substring(0,10)},t.setTabTarget=function(t,e){t.on("keydown",(function(i){var o=i.which||i.keyCode;!0!==t.data("suppress_tab")&&(9!==o||i.shiftKey||(e.focus(),i.stopPropagation(),i.preventDefault()))})),e.on("keydown",(function(i){var o=i.which||i.keyCode;!0!==e.data("suppress_tab")&&9===o&&i.shiftKey&&(t.focus(),i.stopPropagation(),i.preventDefault())}))},t.setRouteInfo=function(t,e){var i=function(i,o){return"string"==typeof e[i]?e[i]:"string"==typeof t[i]?t[i]:o};t.url_cmty_path=i("url_cmty_path",""),t.url_router_base=i("url_router_base","/community"),t.push_state_attribute=i("push_state_attribute","data-cmty")},t.launchNewPrivateMessage=function(e){return"boolean"==typeof e.is_admin&&(e.is_admin=e.is_admin?1:0),new t.NewPrivateConversation({category_name:"",category_id:i.private_messages_id,model:AoPS.Community.MasterModel.get("my_privates"),preset_recipients:[{label:e.username,user_id:e.user_id,is_visible:!0,is_admin:e.is_admin}],master:AoPS.Community.MasterModel})},t.buildSelectRow=function(t){var e=$('<div class="cmty-select-row"></div>'),i=$("<select></select>"),o=t.hasOwnProperty("bold")&&t.bold,s=t.hasOwnProperty("selected")?t.selected:"";return _.each(t.options,(function(t){i.append('<option value="'+t.value+'" '+(t.value===s?"selected":"")+">"+t.label+"</option>")})),i.change((function(){t.action(i.val())})),e.append($('<div class="cmty-select-row-select"></div>').append(i)),e.append($('<div class="cmty-select-row-text">'+(o?"<b>":"")+t.text+(o?"</b>":"")+"</div>")),e},t.buildLinkLabelRow=function(t){var e=$('<div class="cmty-link-label-row"></div>'),i=$("<a>"+t.link_text+"</a>"),o=t.hasOwnProperty("bold")&&t.bold;return i.on("click",(function(){t.action()})),e.append($('<div class="cmty-link-label-row-link"></div>').append(i)),e.append($('<div class="cmty-link-label-row-label">'+(o?"<b>":"")+t.link_label+(o?"</b>":"")+"</div>")),e},t.buildEditableRow=function(t){var i,o,s,n,a=!t.hasOwnProperty("submit_on_enter")||t.submit_on_enter,r=AoPS.View.compileTemplate("#cmty-editable-row-tpl"),l=$('<span class="cmty-editable-pencil aops-font">L</span>'),c=t.hasOwnProperty("length_limit")?t.length_limit:0,d=t.hasOwnProperty("content")?t.content:"";return(i={is_active:!1,allow_ctrl_biu:!!t.hasOwnProperty("allow_ctrl_biu")&&t.allow_ctrl_biu,label:t.label,placeholder:t.hasOwnProperty("placeholder")?t.placeholder:"",contents:d,reset:function(){i.$input.text(i.contents),i.$input.append(l)},activate:function(){o.show(),i.$element.addClass("cmty-editable-active-row"),i.is_active=!0},deactivate:function(){o.hide(),i.$element.removeClass("cmty-editable-active-row"),i.is_active=!1},renderUneditable:function(){i.$input.attr("contenteditable",!1),l.detach()},onButtonClick:function(){i.$input.blur(),i.contents.length>0&&i.$input.append(l),i.deactivate()},save:function(){i.burnNewContent()&&t.hasOwnProperty("action")&&t.action(i.contents,i),i.onButtonClick()},burnNewContent:function(){var t=i.fetchInputLines(),e=t.join("\n");return i.$input.text(t.join("<br>")),e!==i.contents&&(i.contents=t.join("\n"),!0)},fetchInputLines:function(){var t=[],e=!1,o=!1;return i.$input.contents().each((function(){if("BR"===this.nodeName)return o=!1,e?void(a||t.push("")):void(e=!0);e=!1,3===this.nodeType?(o?t[t.length-1]=t[t.length-1]+this.textContent:t.push(this.textContent),o=!0):(o=!1,"<br>"!==this.innerHTML?t.push(this.innerHTML):t.push(""))})),t}}).$element=$(r({label:t.label,placeholder:i.placeholder,content:d})),i.$input=i.$element.find('[contenteditable="true"]'),n=(o=i.$element.find(".cmty-editable-buttons")).find(".cmty-editable-cancel"),s=o.find(".cmty-editable-save"),(i.contents.length>0||0===i.placeholder.length)&&i.$input.append(l),n.on("click",(function(){i.$input.text(i.contents),i.onButtonClick()})),s.on("click",(function(){i.save()})),i.$input.on("focus",(function(){setTimeout((function(){l.detach()}),1)})),i.$input.on("paste",(function(t){var o,s=(t.originalEvent||t).clipboardData.getData("text/plain");t.preventDefault(),a&&(s=s.replace(/\r?\n|\r/g,"")),document.execCommand("insertText",!1,s),c>0&&(o=i.$input.text()).length>c&&(i.$input.text(o.substr(0,c)),AoPS.Ui.Flyout.display(e["editable-length-limit-exceeded-on-paste"]))})),i.$input.on("blur",(function(){!i.is_active&&i.contents.length>0&&i.$input.append(l)})),a&&i.$input.on("keydown",(function(t){13===(t.which||t.keyCode)&&(i.save(),t.preventDefault(),t.stopPropagation())})),c>0&&i.$input.on("keydown",(function(t){var e=t.which||t.keyCode,o=i.$input.text();8!==e&&o.length>c&&t.preventDefault()})),i.allow_ctrl_biu||i.$input.on("keydown",(function(t){var e=t.which||t.keyCode;(t.metaKey||t.ctrlKey)&&_.indexOf([66,73,85],e)>-1&&(t.stopPropagation(),t.preventDefault())})),i.$input.on("keyup",(function(){i.$input.text()!==i.contents?i.activate():i.deactivate()})),i},t.setFullReplyStyle=function(){$("body").addClass("full-reply")},t.removeFullReplyStyle=function(){$("body").removeClass("full-reply")},t.buildTagAutocomplete=function(i){var o;i.$input_box.wrap($('<div class="cmty-tag-search"></div>')),(i=_.defaults(i,{show_no_results_msg:!1,no_results_msg_hash:"cat-cell-no-tag-match",has_search_icon:!1})).category=i.model,i.processPostConstruction=t.EditableTagBox.prototype.processTagBoxDropdownArrowing,i.show_no_results_msg&&(o=$('<div class="cmty-no-results-found">'+e[i.no_results_msg_hash]+"</div>"),i.$input_box.before(o),i.$input_box.on("blur",(function(){o.hide()})),i.$input_box.on("remove",(function(){o.remove()})),i.onMatch=function(){o.hide()},i.onNoMatch=function(){o.show()}),i.hasOwnProperty("has_search_icon")&&i.has_search_icon&&(i.$input_box.before('<span class="aops-font">M</span>'),i.$input_box.parent().addClass("cmty-search-with-icon")),i.constructAutocompleteArgs=t.EditableTagBox.prototype.constructAutocompleteArgs,i.getAutocompleteSource=t.EditableTagBox.prototype.getAutocompleteSource,i.constructAutocomplete=t.EditableTagBox.prototype.constructItemAutocomplete,i.constructAutocomplete()},t.buildTagTermTagAutocomplete=function(i){function n(n){if(0!=n.length){var a=i.tag_term_model.get("tags").findWhere({text_lc:n.toLowerCase()});_.isUndefined(a)?(t.throwBlockingMessage(e["please-wait"]),i.tag_term_model.fetchTagIdByText({tag_text:n,create_new:!!i.hasOwnProperty("create_new")&&i.create_new,suppress_clean:!!i.hasOwnProperty("suppress_clean")&&i.suppress_clean,onFinish:function(t){i.onFoundTag(t.tag)},onError:function(t){var i;if("E_NO_SUCH_TAG"===t.error_code)i=e["cmty-tag-info-no-tag"];else i=o.formatString(e["err-unknown"],[t.error_code]);s.showAlert(i,{onClose:function(){s.closeAllModals()}})}})):i.onFoundTag(a),t.buildTagTermTagAutocomplete(i)}}i.view.hasOwnProperty("$tag_input")&&i.view.$tag_input.parent().remove(),i.view.$tag_input=$('<input name="tag" placeholder="Enter tag" maxlength="60">'),i.view.$tag_input.on("keydown",(function(e){t.validateTagCharacter(e)||(e.stopPropagation(),e.preventDefault())})),i.view.$tag_input.on("paste",(function(e){t.onTagPaste(e)})),i.$input_box_target.append(i.view.$tag_input),t.buildTagAutocomplete({model:i.tag_term_model,$input_box:i.view.$tag_input,show_no_results_msg:!0,no_results_msg_hash:"cmty-tag-info-no-match",additional_autocomplete_params:{type:"tag"},submitNewItem:function(e){var o;0!=e.item_id?(o=i.tag_term_model.findTagById(parseInt(e.item_id)),_.isUndefined(o)&&(o=new AoPS.Community.Models.Tag({tag_id:parseInt(e.item_id),tag_text:e.value}),i.tag_term_model.get("tags").add(o)),i.onFoundTag(o),t.buildTagTermTagAutocomplete(i)):n(e.label)}}),i.view.$tag_input.on("keyup",(function(t){13==(t.which||t.keyCode)&&n($.trim(i.view.$tag_input.val()))}))},t.validateTagCharacter=function(t){var e=t.which||t.keyCode;return e>=65&&e<=90||(e>=48&&e<=57?48==e||57==e||!t.shiftKey:37==e||39==e||(190==e||(189==e||(222==e||(8==e||9==e||46==e||32==e)))))},t.onTagPaste=function(t){var e=(t.originalEvent||t).clipboardData.getData("text/plain");e=e.replace(/[^a-zA-Z0-9 \._\(\)\-]/g,""),t.preventDefault(),document.execCommand("insertText",!1,e)},t.constructUsernameAutocompleteExtraArgs=function(){return{ui_class:"cmty-username-autocomplete",_renderItem:function(t,e){var i=$("<li></li>"),o=$("<a>"+e.label+"</a>");return i.append(o),"1"===e.is_admin&&o.addClass("cmty-user-admin"),i.appendTo(t)}}},t.showError=function(t){AoPS.Ui.Modal.showAlertQuick(t,{width:"400px",onClose:function(){s.closeAllModals()}})},t.showErrorAtopAModal=function(t){AoPS.Ui.Modal.showAlertQuick(t,{width:"400px"})},t.constructUrlFromFocus=function(t,e){var o,s,n=t.get("focus_category").get("category_id"),a=2===arguments.length?e:{},r=!a.hasOwnProperty("strip_topic")||!a.strip_topic,l=t.get("focus_topic");return o=n!==i.private_messages_id||!t.get("focus_category").get("is_archive")||r&&!_.isNull(l)?"/c"+n:i.private_archive_url,s=t.get("focus_tag"),_.isNull(s)||(o+="t"+s.tag_id+"f"+s.tag_forum_id),r&&(_.isNull(l)||(o+="h"+l.get("topic_id"))),o},t.leaveRouterOnClick=function(t,e){t.metaKey||t.ctrlKey?window.open("/community"+e,"_blank"):window.location.href="/community"+e,t.stopPropagation(),t.preventDefault()},t.followUrlOnClick=function(t,e){var i,o;arguments.length>2?(i=arguments[2],o=arguments[3]):(i="/community",o=""),t.metaKey||t.ctrlKey?window.open(i+o+e,"_blank"):Backbone.history.navigate(o+e,{trigger:!0}),t.stopPropagation(),t.preventDefault()},t.isStateTag=function(t){return"/open"===(t=t.toLowerCase())||"/closed"===t||"/not_monitored"===t},t.makeBookmark=function(t){return String.fromCharCode(67+(t.is_bookmarked?(t.in_feed?2:0)+(t.is_watched?1:0):-1))},t.convertToUrlFragment=function(t){return t?t.replace(/ /g,"_").replace(/\W/g,"").toLowerCase():""},t.makeLinkUrl=function(t){var e=2==arguments.length?arguments[1]:"/community";return e+t},t.makeBackboneClick=function(e,i){e.on("click.backbone",(function(e){t.followUrlOnClick(e,i)}))},t.throwBlockingMessage=function(t){AoPS.Ui.Modal.showMessageQuick(t,{closeX:!1,force_response:!0,kill_phrase:"ajax-error-kill",width:"400px"})},t.delayModalClearing=function(t){var e={};arguments.length>0&&(e=t),setTimeout((function(){s.closeAllModals(),e.hasOwnProperty("onClose")&&e.onClose()}),i.message_readability_delay)},t.replaceWithLoaderBlockingMessage=function(t){var e='<div class="cmty-quick-message">'+t+"</div>"+AoPS.Page.loader_html;AoPS.Ui.Modal.replaceTopModal({type:"message",body:e,closeX:!1,force_response:!0,kill_phrase:"ajax-error-kill",width:"450px",frame_class:"aops-modal-quick"})},t.throwLoaderBlockingMessage=function(t){var e='<div class="cmty-quick-message">'+t+"</div>"+AoPS.Page.loader_html;AoPS.Ui.Modal.showMessageQuick(e,{closeX:!1,force_response:!0,kill_phrase:"ajax-error-kill",width:"350px"})},t.applyItemColor=function(t,e){t.css({"background-color":e.main_color}).on("mouseenter",(function(i){t.css({"background-color":e.secondary_color,color:e.main_color})})).on("mouseleave",(function(i){t.css({"background-color":e.main_color,color:""})}))},t.$bookmarkModals={},t.constructBookmarkModal=function(i,o){var s="";t.in_academy?AoPS.isUserLimited()||(s=e["bookmark-modal-info-text-academy"]):s=e["bookmark-modal-info-text"];var n=$(AoPS.View.prototype.getTemplate("#cmty-bookmark-modal-tpl",{username:AoPS.session.username,description:o,limited_in_academy:t.in_academy&&AoPS.isUserLimited(),info_text:s,feed_text:e["bookmark-modal-feed"],email_text:e["bookmark-modal-email-"+i]}));return n.find(".cmty-cancel-button").on("click",(function(){})),n},t.fireBookmarkModal=function(i,o,s){var n;(n=t.constructBookmarkModal(i,o)).showModal({type:"confirm",title:e["bookmark-modal-title-"+i],force_response:!0,closeX:!1,confirm_button_cancel:e["bookmark-modal-cancel"],confirm_button_ok:e["bookmark-modal-ok"],width:"450px",onButtonClick:function(t){t&&s({is_bookmarked:!0,is_watched:n.find('input[name="bkmk-watch-me"]').is(":checked"),in_feed:n.find('input[name="bkmk-add-feed"]').is(":checked")}),AoPS.Ui.Modal.closeAllModals()}})},t.fetchTopicsListConstructor=function(e){switch(e){case"my_privates":return t.TopicsListPrivates;case"user_search_posts":case"search":return t.TopicsListSearchPosts;default:return t.TopicsList}},t.fetchCategoryCellConstructor=function(e){switch(e){case"forum":case"forum_class":return t.CategoryCell;case"my_privates":return t.CategoryCellMyPrivates;case"folder":case"folder_forums":case"folder_collections":case"my_forums":case"my_blogs":case"blogroll":case"my_collections":return t.CategoryCellFolder;case"my_books":return t.CategoryCellMyBooks;case"blog":return t.CategoryCellBlog;case"my_classes":return t.CategoryCellMyClasses;case"my_bookmarks":return t.CategoryCellMyBookmarks;case"view_topics":return t.CategoryCellTopicView;case"bookmark_topics":case"feed_topics":return t.CategoryCellTopicBookmarks;case"bookmark_users":return t.CategoryCellBookmarkUsers;case"view_forums":return t.CategoryCellForumView;case"bookmark_forums":return t.CategoryCellForumBookmarks;case"view_tags":return t.CategoryCellTagView;case"view_posts":return t.CategoryCellPostView;case"bookmark_tags":return t.CategoryCellTagBookmarks;case"user":return t.CategoryUserCell}return t.CategoryCell},t.fetchCategoryCellCategoryTopConstructor=function(e){switch(e){case"my_privates":return t.CategoryCellCategoryTopMyPrivates;case"bookmark_forums":case"view_forums":return t.CategoryCellCategoryTopViewForums;case"bookmark_topics":case"feed_topics":case"view_topics":return t.CategoryCellCategoryTopViewTopics;case"bookmark_tags":case"view_tags":return t.CategoryCellCategoryTopViewTags;case"user_search_posts":return t.CategoryCellCategoryTopUserSearchPosts;case"search":return t.CategoryCellCategoryTopSearch;default:return t.CategoryCellCategoryTop}},t.Post=AoPS.View.extend({template_id:"#cmty-post-tpl",className:"cmty-post",show_link_in_post_number_modal:!1,initialize:function(t){this.topic=t.topic,this.is_read=!0,this.watching_edit_time=!1,this.has_poll=this.topic.model.get("poll_id")>0&&1==this.model.get("post_number"),this.render(),this.listenTo(this.model,"change:show_from_start change:show_from_end",_.bind((function(){this.topic.setPostVisibility(this)}),this)),this.listenTo(this.model,"change:deleted",this.onChangeDeleted),this.listenTo(this.model,"change:thanks_received change:nothanks_received",this.renderThankCount),this.listenTo(this.model,"hard_delete",this.removePostFromTopic),this.listenTo(this.model,"change:attachment change:attachments",this.parseAttachments),this.listenTo(this.model,"change:post_rendered",this.render),this.listenTo(this.model,"change:date_rendered",_.bind((function(){this.$el.find(".cmty-post-date").html(this.model.get("date_rendered"))}),this)),this.listenTo(this.model,"change:last_edit_time_rendered",this.parseEditData)},render:function(){var t,i,o,s=this.constructReportTemplateData(),n=this.model.get("admin"),a=this.topic.model.getPermission("c_can_edit"),r=this,l=this.topic.model.get("has_thanks")&&this.topic.model.getPermission("c_can_thank")&&AoPS.session.user_id!=this.model.get("poster_id"),c=this.topic.model.get("has_nothanks")&&this.topic.model.getPermission("c_can_nothank")&&AoPS.session.user_id!=this.model.get("poster_id"),d=this.topic.model.getPermission("c_can_delete")&&this.model.get("post_number")>1,_=this.model.isDeletableByUser();_&&!d&&this.listenTo(this.topic.model,"change:last_post_id",(function(){r.$(".cmty-post-delete").toggle(r.topic.model.get("last_post_id")==r.model.get("post_id"))})),i=n?e["post-user-tooltip-admin"]:this.model.get("is_forum_admin")?e["post-user-tooltip-forum-admin"]:this.model.get("is_forum_mod")?e["post-user-tooltip-mod"]:e["post-user-tooltip-regular"],o={user_id:this.model.get("poster_id"),has_poll:this.has_poll,username:this.model.get("username"),date_rendered:this.model.get("date_rendered"),post_number:this.model.get("post_number"),post_number_title:e["post-number-title"],has_real:this.model.get("real_poster_id")>0&&this.model.get("real_poster_id")!=this.model.get("poster_id"),real_poster_id:this.model.get("real_poster_id"),real_username:this.model.get("real_poster_username"),is_reported:s.is_reported,highlight_report_button:s.highlight_report_button,post_rendered:this.model.get("post_rendered"),avatar:this.model.get("avatar"),user_tooltip_text:i,one_post:1==this.model.get("num_posts"),can_pm:AoPS.session.logged_in,is_admin:n,is_forum_admin:!n&&this.model.get("is_forum_admin"),is_forum_mod:!n&&this.model.get("is_forum_mod"),num_posts:this.model.get("num_posts"),rating:this.model.get("rating"),report_title:s.title,lang_post_unread:e["post-unread-tootip"],can_quote:!this.topic.model.get("locked")&&!this.topic.model.get("forum_locked"),can_report:s.can_report,thankers:this.model.get("thankers"),lang_thankers:e["post-thanked-by"],can_edit:this.topic.model.getPermission("c_can_edit_own_posts")&&(this.topic.model.getPermission("c_can_lock_category")&&a||!this.topic.model.get("locked")&&!this.topic.model.get("forum_locked")&&(a||this.model.get("editable"))),can_delete:d||_,can_undelete:this.topic.model.getPermission("c_can_undelete"),thanking_active:l,nothanking_active:c},this.$el.html(this.getTemplate(this.template_id,o)),l&&(this.$thanks=this.$(".cmty-post-thank"),this.setThanks(),this.listenTo(this.model,"change:is_thanked",this.setThanks)),c&&(this.$nothanks=this.$(".cmty-post-nothank"),this.setNothanks(),this.listenTo(this.model,"change:is_nothanked",this.setNothanks)),this.$post_html=this.$(".cmty-post-html"),this.setTargetBox(),this.model.get("can_target")&&this.listenTo(this.topic.model,"change:target_url change:target_text",this.setTargetBox),this.$attachments=this.$(".cmty-post-attachments"),this.parseAttachments(),this.parseEditData(),this.renderThankCount(),this.listenTo(this.model,"change:thankers",this.setThankersBox),this.setVisibility(),this.has_poll&&this.initializePoll(),s.can_settle_report&&this.listenTo(this.model,"change:reported",this.onReportedChange),this.topic.model.get("is_search_result")&&(t=this.topic.model.fetchSearchText("post_text")).length>0&&(this.$post_html.extendedHighlightText("cmty-highlight",t),this.model.get("post_id")===this.topic.model.get("focus_post").get("post_id")&&this.$(".cmty-hide-heading").trigger("click"))},setThankersBox:function(){this.$(".cmty-post-thankers").html('<span class="cmty-thank-title">'+e["post-thanked-by"]+'</span> <span class="cmty-thankers">'+this.model.get("thankers")+"</span>"),this.model.get("thanks_received")<=0&&this.$el.removeClass("cmty-post-show-thanks")},setThanks:function(){var t,i;this.model.get("is_thanked")?(t=e["post-unthank-this"],i="{"):(t=e["post-thank-this"],i="Y"),this.$thanks[0].title=t,this.$thanks.text(i)},setNothanks:function(){var t,i;this.model.get("is_nothanked")?(t=e["post-unnothank-this"],i="}"):(t=e["post-nothank-this"],i="_"),this.$nothanks[0].title=t,this.$nothanks.text(i)},setTargetBox:function(){var t,i,s;this.$(".cmty-post-target-note").remove(),this.model.checkShowTargetLink()&&(t=new RegExp(document.domain+"/"+AoPS.router_root),s=document.domain+this.topic.model.get("target_url"),i=o.formatString(e["topic-full-post-with-target-url"],[this.topic.model.get("target_url"),this.topic.model.get("topic_id"),t.test(s)?AoPS.pushState_attr:"",this.topic.model.get("target_text").length>0?this.topic.model.get("target_text"):e["topic-full-target-text-default"]]),this.topic.model.get("is_restricted_soln")&&(i=o.formatString(i+"<br>"+e["topic-full-post-solution-thread"])),AoPS.session.user_id!==this.model.get("poster_id")&&AoPS.session.user_id!==this.model.get("real_poster_id")||(i+='<div class="cmty-remove-target"><a class="faux-link">'+e["topic-full-remove-target"]+"</a></div>"),this.$el.find(".cmty-post-body").prepend(this.getTemplate("#cmty-post-to-target-link-tpl",{target_note:i})))},initializePoll:function(){this.$poll=this.$(".cmty-post-poll"),this.listenTo(this.topic.model,"change:poll_data",this.constructPoll),this.$poll_loader=$('<div class="cmty-poll-display-top cmty-poll-display">'+e["poll-loading"]+"</div>"),this.topic.model.has("poll_data")&&!_.isEmpty(this.topic.model.get("poll_data"))?this.constructPoll():this.$poll.append(this.$poll_loader)},constructPoll:function(){var t,i,s,n,a=this;this.$poll_loader.detach(),this.topic.model.computeDerivedPollData(),t=this.topic.model.get("poll_data"),i=o.formatString(e[1==t.num_selections?"poll-select-one":"poll-select-many"],[t.num_selections]),n=t.num_votes+e[1===t.num_votes?"poll-Vote":"poll-Votes"],s=t.has_voted&&t.can_vote,this.$poll.html(this.getTemplate("#cmty-poll-display-tpl",{lang_heading:e["poll-display-heading"],question:t.question,options:t.options,lang_select_options:i,lang_votes:n,input_type:1==t.num_selections?"radio":"checkbox",can_vote:t.can_vote,has_toggle:!t.poll_closed&&!t.has_voted,lang_poll_vote:t.has_voted?e["poll-revote-btn"]:e["poll-vote-btn"],lang_hide_results:e["poll-hide-results"],lang_show_results:e["poll-show-results"],has_helper_text:!AoPS.session.logged_in||s,lang_helper:AoPS.session.logged_in?e["poll-revote-directions"]:e["poll-not-logged-in"]})),this.$poll.toggleClass("cmty-poll-show-results",t.poll_closed||t.has_voted),this.poll_selections=[],t.can_vote&&_.each(t.options,(function(t){t.selected&&a.poll_selections.push(t.id)}))},parseAttachments:function(){var t,o=[],s=[],n=this,a="";this.$el.toggleClass("post-has-attachment",this.model.get("attachment")),this.$attachments.html(""),this.model.get("attachment")&&(_.each(this.model.get("attachments"),(function(t){n.isAttachmentImage(t.mimetype)?o.push(t):s.push(t)})),this.$attachments.append('<div class="cmty-post-attached-title">'+e["post-attachments"]+"</div>"),o.length>0&&(t='<div class="cmty-post-attached-images"><div class="cmty-post-attached-image-content">',_.each(o,(function(e){t+='<a target="_blank" href="'+e.href+'"><img title="'+e.name+'" src="'+i.attachment_path+e.url+'"></a>'})),t+="</div></div>",this.$attachments.append(t)),s.length>0&&(_.each(s,(function(t){a+='<div class="cmty-post-attached-file"><a target="_blank" href="'+t.href+'">'+t.name+" ("+t.size+"kb)</a></div>"})),this.$attachments.append(a)))},isAttachmentImage:function(t){return"image"===t.substr(0,5)},markUnread:function(){this.$el.addClass("cmty-post-unread"),this.is_read=!1},markRead:function(){this.$el.removeClass("cmty-post-unread"),this.is_read=!0},constructReportTemplateData:function(){var t={can_report:this.topic.model.getPermission("c_can_report"),can_settle_report:this.topic.model.getPermission("c_can_settle_report"),is_reported:this.model.get("reported"),title:""};return t.can_report&&(t.is_reported?t.can_settle_report?t.title=e["topic-full-settle-report-title"]:t.title=e["topic-full-already-reported-title"]:t.title=e["topic-full-report-post-title"]),t.highlight_report_button=t.can_settle_report&&t.is_reported,t},onReportedChange:function(){this.topic.model.getPermission("c_can_settle_report")&&this.$el.find(".cmty-post-report").toggleClass("cmty-post-settle-report",this.model.get("reported"))},parseEditData:function(){var t,i=this.model.get("num_edits");this.$el.toggleClass("cmty-post-edited",i>0),i>0&&(this.model.get("edit_time_on_timer")&&!this.watching_edit_time&&(this.watching_edit_time=!0),t=e["topic-full-edited-1"]+i+(i>1?e["topic-full-edited-3"]:e["topic-full-edited-2"])+e["topic-full-edited-4"]+this.model.get("last_editor_username")+", "+this.model.get("last_edit_time_rendered"),this.model.get("last_edit_reason").length>0&&(t+="<br>"+e.Reason+": "+this.model.get("last_edit_reason")),this.$el.find(".cmty-post-edit-info").html(t))},events:{"click .cmty-post-report":"onClickReport","click .cmty-post-settle-report":"onClickSettleReport","click .cmty-post-quote":"onClickQuote","click .cmty-post-delete":"onClickDelete","click .cmty-post-deleted-info":"onClickDeletedInfo","click .cmty-undelete-post":"onClickUndelete","click .cmty-post-thank":"onClickThanks","click .cmty-post-nothank":"onClickNothanks","click .cmty-post-edit":"onClickEdit","click .cmty-post-number":"onClickDirectLink","click .cmty-poll-results-toggle span":"onClickTogglePollResults","click .cmty-poll-vote-row .btn":"onClickPollVote","mousedown .cmty-post-middle":"onClickPostBody","click .cmty-remove-target":"onClickRemoveTarget","click .cmty-post-thank-count":"onClickThankCount","click .cmty-pm-from-post":"onClickMessage"},onClickMessage:function(i){var s,n;this.model.get("real_poster_id")>0?(s=this.model.get("real_poster_id"),n=this.model.get("real_poster_username")):(s=this.model.get("poster_id"),n=this.model.get("username"));var a=t.launchNewPrivateMessage({user_id:s,username:n,is_admin:this.model.get("admin")}),r="private-from-post";this.model.get("deleted")&&(r+="-deleted");var l=this.constructPostUrl(),c=this.topic.model.isPrivateMessage()?"":o.formatString(e[r],[l.url]);if(c+='[quote="'+this.model.get("username")+'"]'+this.model.get("post_canonical")+"[/quote]",a.addContent(c),!_.isUndefined(i))return i.stopPropagation(),i.preventDefault(),!1},onClickThankCount:function(){this.$el.toggleClass("cmty-post-show-thanks")},onClickRemoveTarget:function(){var i,n=this,a=this.model.get("topic");i=a.get("target_text").length>0?o.formatString(e["mod-topic-remove-target-with-text"],[a.get("target_text")]):e["mod-topic-remove-target-confirm"],s.showConfirm(i,(function(i){i?(t.replaceWithLoaderBlockingMessage(e["mod-topic-remove-target-blocker"]),n.model.get("topic").removeTarget({onFinish:function(){setTimeout((function(){s.closeAllModals()}),500)},onError:t.throwAjaxError})):s.closeAllModals()}),{width:"450px",close_on_button_click:!1})},onClickTogglePollResults:function(){this.$poll.toggleClass("cmty-poll-show-results")},onClickPostBody:function(t){t.stopPropagation()},onClickPollVote:function(){var t,s=this.topic.model.get("poll_data").num_selections,n=this;if(1===s){if(t=this.$poll.find('input:radio[name="poll-options"]:checked').val(),_.isUndefined(t))return void AoPS.Ui.Modal.showAlertQuick(e["poll-nothing-selected"]);t=[t]}else{if(t=[],_.each(this.$poll.find('input:checkbox[name="poll-options"]:checked'),(function(e){t.push(e.value)})),0==t.length)return void AoPS.Ui.Modal.showAlertQuick(e["poll-nothing-selected"]);if(t.length>s)return void AoPS.Ui.Modal.showAlertQuick(o.formatString(e["poll-too-many-selected"],[s]))}t.join()!==this.poll_selections.join()&&(AoPS.Community.Views.throwBlockingMessage(e["poll-vote-processing"]),this.topic.model.castVote({votes:t,onFinish:function(){setTimeout((function(){AoPS.Ui.Modal.closeAllModals()}),i.message_readability_delay_short)},onError:function(t){var i,o=t.error_code;"E_NOT_LOGGED_IN"===o?i=e["poll-err-not-logged-in"]:"E_POLL_CLOSED"===o?(n.topic.model.get("poll_data").poll_closed=!0,n.topic.model.trigger("change:poll_data"),i=e["poll-err-closed"]):i=e["unexpected-error-code"]+o,AoPS.Community.Views.showError(i)}}))},constructPostUrl:function(){var t="/community/c"+this.topic.model.get("category_id")+"h"+this.model.get("topic_id")+"p"+this.model.get("post_id");return{url_path:t,url:i.base_url+t}},onClickDirectLink:function(t){var i,s,n,a,r=this.constructPostUrl(),l=AoPS.Community.MasterModel.fetchStaffPermission("ip-lookup"),c=this;i=$('<div class="cmty-post-direct-modal">'+o.formatString(e["post-direct-link"],[r.url_path])+'<br><br>\t\t\t\t\t<input value="'+r.url+'" /></div>'),l&&(s=$('<button class="btn btn-primary">'+e["post-direct-click-ip"]+"</button>"),n=$("<div>"+e["post-direct-loading-ip"]+"</div>"),i.append("<br><br>").append(s),s.on("click",(function(){s.hide(),i.append(n),c.model.fetchIP({onFinish:function(t){n.text(t.ip)},onError:function(t){n.text(t.error_code)}})}))),i.showModal({width:"400px"}),(a=i.find("input"))[0].setSelectionRange(0,a.val().length),t.stopPropagation(),t.preventDefault()},onClickEdit:function(t){var i,o=1===this.model.get("post_number")?"EditFirstPost":"EditPost";t.stopPropagation(),t.preventDefault(),!this.topic.model.get("forum_locked")||this.topic.model.getPermission("c_can_lock_category")?this.topic.model.getPermission("c_can_edit")||!this.topic.model.get("locked")?((i=new AoPS.Community.Views[o]({post_model:this.model,topic_id:this.model.get("topic_id"),category_id:this.topic.model.get("category_id"),topic:this.topic.model,master:this.topic.model.get("master"),input_text:this.model.get("post_canonical")})).$el.showModal({frame_class:"cmty-posting-modal",mask_fade_in_speed:200,scrollable:!1,max_width:"1000px",onClickMask:function(){return!1},onClickX:function(){return i.onClickCancel(),!1}}),i.setHeight()):s.showMessage(e["topic-edit-locked"]):s.showMessage(e["topic-edit-forum-locked"])},onClickThanks:function(t){var e=this.model.get("is_thanked")?0:1;this.model.setThankStatus({new_status:e})},onClickNothanks:function(t){var e=this.model.get("is_nothanked")?0:-1;this.model.setThankStatus({new_status:e})},onClickQuote:function(){AoPS.session.logged_in?this.topic.model.getPermission("c_can_reply")||this.topic.model.getPermission("c_undo_global_ban")||!AoPS.isUserLimited()?this.topic.model.get("locked")?s.showMessage(e["topic-full-reply-to-locked"]):this.topic.model.get("forum_locked")?s.showMessage(e["topic-full-reply-to-forum-locked"]):this.topic.appendToReply("[quote="+this.model.get("username")+"]"+$.trim(this.model.get("post_canonical"))+"[/quote]\n\n"):s.showMessage(e["new-reply-no-permission-limited"],{width:"450px"}):AoPS.Ui.buildLoginConfirm(e["topic-full-unregistered-reply"])},onClickReport:function(i){if(i.stopPropagation(),i.preventDefault(),this.model.get("reported"))return this.topic.model.getPermission("c_can_settle_report")?void 0:void AoPS.Ui.Modal.showMessage(e["topic-full-already-reported"]);new t.ReportPost({model:this.model}).$el.showPlainModal()},onClickSettleReport:function(e){t.inCmtyRouter()?t.followUrlOnClick(e,"/reported-posts/p"+this.model.get("post_id")):window.location.href="/community/reported-posts/p"+this.model.get("post_id"),e.stopPropagation(),e.preventDefault()},onClickDelete:function(e){var i;i=new t.DeletePost({model:this.model,topic:this.model.get("topic")}),AoPS.session.n&&(e.shiftKey||e.metaKey)?i.onFormSubmit(e,{force_soft:!0}):(i.$el.showPlainModal(),i.$el.find('[value="OK"]').focus()),e.stopPropagation(),e.preventDefault()},onClickDeletedInfo:function(){this.$el.toggleClass("cmty-post-deleted-open")},onClickUndelete:function(t){return AoPS.Ui.Modal.showMessage(e["topic-full-undelete-message"],{type:"confirm",title:e["topic-full-undelete-title"],confirm_button_ok:e.yes,confirm_button_cancel:e.no,onButtonClick:_.bind((function(t){t&&this.model.undelete({onError:function(t){"E_HARD_DELETE"===t.error_code&&n.display(e["topic-full-undelete-hard"])}}),AoPS.Ui.Modal.closeAllModals()}),this)}),t.stopPropagation(),t.preventDefault(),!1},onChangeDeleted:function(){this.model.get("deleted")&&!this.topic.model.getPermission("c_can_read_deleted")?this.removePostFromTopic():this.setVisibility()},removePostFromTopic:function(){"function"==typeof this.topic.removePost&&this.topic.removePost(this)},renderThankCount:function(){this.model.get("thanks_received")>0&&this.topic.model.get("has_thanks")?this.$el.find(".cmty-post-thank-count").html($.parseHTML(" &bull; "+this.model.get("thanks_received")+' <span class="aops-font">Y</span>')):this.$el.find(".cmty-post-thank-count").html(""),this.model.get("nothanks_received")>0&&this.topic.model.get("has_nothanks")?this.$el.find(".cmty-post-nothank-count").html($.parseHTML(" &bull; "+this.model.get("nothanks_received")+' <span class="aops-font">_</span>')):this.$el.find(".cmty-post-nothank-count").html("")},setVisibility:function(){this.$el.toggleClass("cmty-post-is-deleted",this.model.get("deleted"))}}),t.ModerateTopic=AoPS.View.extend({template_id:"#cmty-moderate-topic-tpl",initialize:function(o){var s,n=this.model.get("locked"),a=this,r=[],l="private"===this.model.get("topic_type"),c=this.model.get("announce_type");t.setRouteInfo(this,o),this.topic_category_at_initialization=o.topic_category_at_initialization,this.$el.html($(this.getTemplate(this.template_id,{title:this.model.get("topic_title"),username:this.model.get("first_poster_name")}))),this.$buttons_cell=this.$el.find(".cmty-moderate-topic-buttons"),l||(this.buildButton({permission:"c_can_move_topic_out",symbol:"N",text:e["mod-topic-move"],onClick:"onClickMoveTopic"}),this.buildButton({permission:"c_can_lock_topic",symbol:n?"l":"k",text:n?e["mod-topic-unlock"]:e["mod-topic-lock"],onClick:"onLockTopic"})),this.model.get("category_id")!=i.recycle_bin_id&&this.buildButton({permission:"c_can_delete",symbol:"J",text:e["mod-topic-delete"],onClick:"onSoftDeleteTopic"}),this.buildButton({permission:"c_can_hard_delete",symbol:"J",text:e["mod-topic-hard-delete"],onClick:"onHardDeleteTopic"}),l||("none"===c?(this.buildButton({permission:"c_can_announce",symbol:"i",text:e["mod-topic-announce"],onClick:"onMakeLocalAnnouncement"}),this.buildButton({permission:"c_can_global_announce",symbol:"a",text:e["mod-topic-global"],onClick:"onMakeGlobal"})):"local"===c?(this.buildButton({permission:"c_can_announce",symbol:"i",text:e["mod-topic-normal"],onClick:"onMakeNormal"}),this.buildButton({permission:"c_can_global_announce",symbol:"a",text:e["mod-topic-global"],onClick:"onMakeGlobal"})):"global"===c&&this.buildButton({permission:"c_can_global_announce",symbol:"a",text:e["mod-topic-normal"],onClick:"onMakeNormal"})),this.model.get("cat_can_target")&&(s=this.model.get("target_url").length>0,this.buildButton({permission:"c_can_add_target",symbol:"j",text:s?e["mod-topic-replace-target"]:e["mod-topic-add-target"],onClick:"onAddTarget"}),s&&this.buildButton({permission:"c_can_remove_target",symbol:"Jj",text:e["mod-topic-remove-target"],onClick:"onRemoveTarget"}),this.buildButton({permission:"c_can_add_target",symbol:"+",text:e["mod-topic-add-hidden"],onClick:"onAddHiddenTag"}),this.model.getPermission("c_can_remove_target")&&this.model.get("tags").length>0&&(r=this.findRemovableHiddenTags()).length>0&&(this.$el.append('<div class="cmty-mod-topic-hidden-title"><u>'+e["mod-topic-hidden-tags"]+"</u></div>"),_.each(r,(function(t){var e=$('<div class="cmty-mod-topic-hidden-tag"><span class="aops-font">J</span>'+t.tag_text+"</div>");a.$el.append(e),e.find(".aops-font").on("click",(function(){a.model.removeTag(t.tag_id,t.tag_text),e.remove(),0==a.findRemovableHiddenTags().length&&a.$(".cmty-mod-topic-hidden-title").remove()}))})))),this.model.get("master").fetchPermission("can_access_log")&&this.buildButton({symbol:"h",text:e["mod-topic-log"],onClick:"onVisitLog"}),this.$el.showModal({title:e["mod-topic-title"],onClose:function(){a.destroy()}})},onVisitLog:function(e){t.leaveRouterOnClick(e,"/log/topic/"+this.model.get("topic_id"))},onAddTarget:function(){var i,o,n=this.model.get("target_url"),a=this,r=!1;n.length>0&&(o=_.findWhere(this.model.get("tags"),{tag_text:n}),r=!_.isUndefined(o)&&!o.is_public),(i=$(this.getTemplate("#cmty-mod-topic-add-target-tpl",{current_target:n,is_restricted:r,lang_edit_instructions:e["mod-topic-edit-target-instructions"],lang_tag_text:e["mod-topic-edit-target-url"],lang_target_text:e["mod-topic-edit-target-text"],current_target_text:this.model.get("target_text"),lang_restricted:e["mod-topic-edit-target-is-restricted"]}))).find('input[type="text"]').focus(),s.showConfirm(i,(function(o){var s,l,c;if(o){if(s=$.trim(i.find("input.cmty-mod-topic-target").val()),l=$.trim(i.find("input.cmty-mod-topic-target-text").val()),0==s.length)return void a.destroy();if(t.isStateTag(s))return void t.showErrorAtopAModal(e["mod-topic-no-state-tags"]);if(c=i.find('input[type="checkbox"]').is(":checked"),s.toLowerCase()===n.toLowerCase()&&c==r&&l===a.model.get("target_text"))return void a.destroy();t.replaceWithLoaderBlockingMessage(e["mod-topic-remove-target-blocker"]),a.model.changeTargetUrl({new_target:s,new_target_text:l,is_restricted:c,onFinish:function(){setTimeout((function(){a.destroy()}),500)},onError:t.throwAjaxError})}else a.destroy()}),{width:"450px",close_on_button_click:!1})},onAddHiddenTag:function(){var i,o=this;(i=$(this.getTemplate("#cmty-mod-topic-add-target-tpl",{lang_edit_instructions:e["mod-topic-hidden-tag-instructions"],lang_tag_text:e["mod-topic-hidden-tag-text"],lang_restricted:e["mod-topic-hidden-tag-is-restricted"],current_target:"",is_restricted:!1}))).find('input[type="text"]').focus(),s.showConfirm(i,(function(s){var n,a;if(s){if(0==(n=$.trim(i.find('input[type="text"]').val())).length)return void o.destroy();if(t.isStateTag(n))return void t.showErrorAtopAModal(e["mod-topic-no-state-tags"]);a=i.find('input[type="checkbox"]').is(":checked"),t.replaceWithLoaderBlockingMessage(e["mod-topic-hidden-tag-blocker"]),o.model.addHiddenTag({new_text:n,is_restricted:a,onFinish:function(){setTimeout((function(){o.destroy()}),500)},onError:t.throwAjaxError})}else o.destroy()}),{width:"450px",close_on_button_click:!1})},findRemovableHiddenTags:function(){var e=[],i=this;return _.each(this.model.get("tags"),(function(o){o.is_visible||o.tag_text===i.model.get("target_url")||t.isStateTag(o.tag_text)||e.push(o)})),e},onLockTopic:function(){if(this.model.get("locked"))this.model.unlock(),this.destroy();else if(this.model.get("first_poster_id")!==AoPS.session.user_id){var t=this,i=$("<div />").append($.parseHTML(e["mod-topic-lock-warning"])).append($("<h3 />").text("Reason:")).append(o.getModerationInputsForType("topic"));AoPS.Ui.Modal.showConfirm(i,(function(o){if(o){var s=i.find("input[name='reason']:checked").val()||"";AoPS.Community.Views.throwBlockingMessage(e["mod-topic-lock-pending"]),t.model.lock({reason:s}),t.destroy()}else AoPS.Ui.Modal.closeTopModal()}),{title:e["mod-topic-lock-title"],close_on_button_click:!1})}else this.model.lock(),this.destroy()},onRemoveTarget:function(){var i=this;s.showConfirm(e["mod-topic-remove-target-confirm"]+e["mod-topic-remove-target-extra"],(function(o){o?(t.replaceWithLoaderBlockingMessage(e["mod-topic-remove-target-blocker"]),i.model.removeTarget({onFinish:function(){setTimeout((function(){i.destroy()}),500)},onError:t.throwAjaxError})):i.destroy()}),{width:"450px",close_on_button_click:!1})},hasTopicMoved:function(){return this.topic_category_at_initialization!=this.model.get("category_id")&&(AoPS.Ui.Modal.showMessage(e["mod-topic-move-err-E_ALREADY_MOVED"]),!0)},onClickMoveTopic:function(){var t=this;this.checkTopicLength({onOK:function(){t.onMoveTopic()}})},onMoveTopic:function(){if(!this.hasTopicMoved()){var t,s=i.move_topic_quick_links,n=AoPS.session.logged_in&&s.hasOwnProperty(this.model.get("category_id").toString()),a=this.model.get("master").fetchCategory(this.model.get("category_id")),r=$(this.getTemplate("#cmty-mod-topic-move-tpl",{has_current_category:!_.isUndefined(a),topic_title:this.model.get("topic_title"),quick_link_title:e["mod-topic-move-quick"],first_poster_name:this.model.get("first_poster_name"),input_heading:e["mod-topic-move-input-heading"],has_quick_links:n})),l=this.model.get("topic_id"),c=this;_.isUndefined(a)||r.find(".cmty-item-forum").first().html(a.get("category_name")).css({color:a.get("main_color")}),n&&(t=r.find(".cmty-mod-topic-move-quick"),_.each(s[this.model.get("category_id").toString()],(function(i){var o,s=c.model.get("master").fetchCategory(i);_.isUndefined(s)||((o=$("<div/>",{class:"cmty-item-forum",html:s.get("category_name")}).on("click",(function(){var t=s.get("category_id");AoPS.Community.Views.throwBlockingMessage(e["mod-topic-move-in-progress"]),c.model.move({new_category_id:t,onFinish:h(t,l),onError:d()})}))).css({color:s.get("main_color")}).on("mouseenter",(function(t){o.css({color:s.get("secondary_color"),"background-color":s.get("main_color")})})).on("mouseleave click",(function(t){o.css({color:s.get("main_color"),"background-color":"#fff"})})),t.append(o))}))),o.buildCategoryAutocomplete(r.find("input").first(),{ajax_call:"fetch_forum_autocomplete",autocomplete_settings:{onSelect:function(t,i){var o=parseInt(i.item.category_id);AoPS.Community.Views.throwBlockingMessage(e["mod-topic-move-in-progress"]),c.model.move({new_category_id:o,onFinish:h(o,l),onError:d()})},onOpen:function(){}}}),r.showModal({title:e["mod-topic-move-title"],frame_class:"cmty-move-topic-modal aops-modal-standard",scrollable:!1,max_width:"400px",onClose:function(){r.remove()}})}function d(){return function(t){var i,o=t.error_code;i=e.hasOwnProperty("mod-topic-move-err-"+o)?e["mod-topic-move-err-"+o]:e["unexpected-error-code"]+o,AoPS.Ui.Modal.showAlert(i,{onClose:function(){c.destroy()},width:"450px"})}}function h(t,e){return function(){var i="/c"+t+"h"+e;"/community"===c.url_router_base?(Backbone.trigger("close_feed_topic"),Backbone.history.navigate(i,{trigger:!0}),c.close()):window.location.href="/community"+i}}},onSoftDeleteTopic:function(){var t=this;this.checkTopicLength({onOK:function(){t.onDeleteTopic("soft")}})},onHardDeleteTopic:function(){var t=this;this.checkTopicLength({onOK:function(){t.onDeleteTopic("hard")}})},checkTopicLength:function(t){this.model.get("num_posts")>i.topic_move_length_limit?AoPS.Community.MasterModel.fetchStaffPermission("can-delete-long-topic")?(AoPS.Ui.Modal.showConfirm(e["mod-long-topic-admin-warning"],(function(e){AoPS.Ui.Modal.closeTopModal(),e&&t.onOK()}),{confirm_button_ok:e["mod-long-topic-admin-OK"],confirm_button_cancel:e["mod-long-topic-admin-no"],width:"450px",close_on_button_click:!1}),$(":focus").blur()):AoPS.Ui.Modal.showAlert(e["mod-topic-delete-err-E_TOPIC_TOO_LONG"],{onClose:function(){self.destroy()},width:"400px"}):t.onOK()},setAnnouncementType:function(t,i){var o=this;this.model.setAnnounceType({type:t,announce_through:i,onFinish:function(){var t;t=o.url_cmty_path+"/c"+o.model.get("category_id")+"h"+o.model.get("topic_id"),Backbone.history.fragment=null,Backbone.history.navigate(t,{trigger:!0}),o.destroy()},onError:function(t){var i,s=t.error_code;i=e.hasOwnProperty("mod-topic-announce-err-"+s)?e["mod-topic-announce-err-"+s]:e["unexpected-error-code"]+s,AoPS.Ui.Modal.showAlert(i,{onClose:function(){o.destroy()}})}})},onMakeNormal:function(){this.setAnnouncementType("none","")},onMakeLocalAnnouncement:function(){this.fetchAnnouncementDate("local")},onMakeGlobal:function(){this.fetchAnnouncementDate("global")},fetchAnnouncementDate:function(i){var o=$("<div>"+e["mod-topic-set-announce-through"]+'<br><input type="text" class="cmty-posting-announce-through" placeholder="yyyy-mm-dd"></div>'),n=o.find("input"),a=this;t.makeAnnounceDateInput(n),s.showConfirm(o,(function(o){o&&(t.replaceWithLoaderBlockingMessage(e["mod-topic-announce-blocker"]),setTimeout((function(){a.setAnnouncementType(i,n.val())}),500))}),{close_on_button_click:!1})},onDeleteTopic:function(t){var i=this,s=(this.model.get("topic_type"),$("<div />").append($.parseHTML(e["mod-topic-"+t+"-delete-warning"])));i.model.get("first_poster_id")!==AoPS.session.user_id&&s.append($("<h3 />").text("Reason:")).append(o.getModerationInputsForType("topic")),AoPS.Ui.Modal.showConfirm(s,(function(o){if(o){var n=s.find("input[name='reason']:checked").val()||"";AoPS.Community.Views.throwBlockingMessage(e["mod-topic-delete-pending"]),i.model.delete({delete_type:t,reason:n,onFinish:function(){Backbone.trigger("close_feed_topic"),i.destroy()},onError:function(t){var o,s;s=t.error_code,o=e.hasOwnProperty("mod-topic-delete-err-"+s)?e["mod-topic-delete-err-"+s]:e["unexpected-error-code"]+s,AoPS.Ui.Modal.showAlert(o,{onClose:function(){i.destroy()},width:"400px"})}})}else AoPS.Ui.Modal.closeTopModal()}),{title:e["mod-topic-"+t+"-delete-title"],close_on_button_click:!1})},destroy:function(){AoPS.Ui.Modal.closeAllModals(),this.close()},buildButton:function(t){var e=this;t.hasOwnProperty("permission")&&!this.model.getPermission(t.permission)||this.$buttons_cell.append($("<button/>",{class:"btn btn-primary",html:'<span class="aops-font">'+t.symbol+"</span> "+t.text}).on("click",(function(i){e[t.onClick](i)}))).append("<br>")}}),t.makeAnnounceDateInput=function(i){i.on("blur",(function(o){var s=i.val();0!==s.length&&(moment(s,"YYYY-MM-DD").isValid()?moment().diff(moment(s,"YYYY-MM-DD"),"days")>0?(t.showErrorAtopAModal(e["post-environ-announce-date-too-early"]),i.val("")):moment().diff(moment(s,"YYYY-MM-DD"),"years")<=-2&&(t.showErrorAtopAModal(e["post-environ-announce-date-too-late"]),i.val("")):(t.showErrorAtopAModal(e["post-environ-invalid-announce-date"]),i.val("")))}))},t.Itembox=AoPS.View.extend({className:"cmty-itembox",push_state_attribute:"data-cmty",check_can_remove:!1,can_remove_all:!1,scrollbarCreator:t.buildCommunityScrollbar,initialize:function(i){var o=this;this.url_cmty_path="",this.url_router_base="/community",_.defaults(this,i),this.hasOwnProperty("scrollbar_arguments")||(this.scrollbar_arguments={}),i.hasOwnProperty("check_can_remove")&&(this.check_can_remove=i.check_can_remove),i.hasOwnProperty("can_remove_all")&&(this.can_remove_all=i.can_remove_all),t.setRouteInfo(this,i),this.render_tooltips_on_items="forum"!=this.model.get("category_type")&&!this.model.get("is_private"),this.render(),this.$loader=$('<div class="cmty-itembox-loader">'+e["cmty-itembox-loader"]+"</div>"),this.listenTo(this.model,"item_removed",this.render),this.listenTo(this.model,"item_added",this.addItem),this.$el.find(".aops-scroll-bar").on("slider_at_end",(function(){o.model.get("no_more_items")||($(document).trigger("mouseup"),o.$itembox.append(o.$loader),o.$scrollable.scrollTop(o.$scrollable[0].scrollHeight),o.model.fetchMoreItems({onFinish:function(t){if(o.$loader.detach(),!o.model.get("no_more_items")){var e=o.$itembox.parent();o.$itembox.height-(e.scrollTop()+e.height())<10&&o.$el.find(".aops-scroll-bar").trigger("slider_at_end")}},onError:function(){o.$loader.detach()}}))}))},render:function(){var t,e,i,o=this.model.get("items").length;if(this.$itembox=$("<div/>",{class:"cmty-itembox-inner-box"}),this.category_id=this.hasOwnProperty("category_id")?this.category_id:this.model.get("category_id"),this.category_type=this.model.get("category_type"),this.item_cells=[],o>0){for(t=0;t<o;t++)e=this.model.get("items")[t],i=this.constructItem(e),this.item_cells.push(i);this.$itembox.append(this.item_cells)}else this.hasOwnProperty("placeholder_text")&&(this.$placeholder=$("<div/>",{class:"cmty-itembox-placeholder"}).append(this.placeholder_text),this.$itembox.append(this.$placeholder));this.$el.html(this.scrollbarCreator(this.$itembox,this.scrollbar_arguments)),this.$scrollable=this.$el.find(".aops-scroll-inner")},constructItem:function(i){var s,n,a,r,l,c,d,_,h,m,p=this,u=!0;switch(l={main_color:i.item_main_color,secondary_color:i.item_secondary_color},"tag"===i.item_type?s=(this.model.get("special_url").length>0?this.model.get("special_url"):this.url_cmty_path+"/c"+this.category_id)+"t"+i.item_id+"f"+i.item_forum_id+"_"+t.convertToUrlFragment(i.item_text):"blog"===i.item_type||"blogroll"===i.item_type||"folder_collections"===i.item_type||"folder_forums"===i.item_type||"folder"===i.item_type||"forum_class"===i.item_type||"forum"===i.item_type||"view"===i.item_type.substr(0,4)||"bookmark"===i.item_type.substr(0,8)?s=this.url_cmty_path+"/c"+i.item_id+"_"+t.convertToUrlFragment(i.item_text):"user"===i.item_type&&(s=this.url_cmty_path+"/user/"+i.item_id),"blog"===i.item_type&&(u=!1),c="<a "+(u?this.push_state_attribute:"")+' href="'+t.makeLinkUrl(s,this.url_router_base)+'">',m=(_=this.check_can_remove&&(this.can_remove_all||i.hasOwnProperty("item_can_remove")&&i.item_can_remove))?'<span class="cmty-delete-item aops-font">J</span>':"",i.item_type){case"forum":case"forum_class":case"folder":case"folder_forums":case"folder_collections":case"blogroll":case"blog":case"view_tags":case"view_topics":case"view_posts":c+='<div class="cmty-item-'+i.item_type+'" style="color:'+l.main_color+'"><div class="cmty-item-text">'+i.item_text+'<br><span class="cmty-item-subtitle">'+i.item_subtitle+"</span></div>"+m+"</div>";break;case"user":d=o.getLastVisitedText(i),c+='<div class="cmty-item-'+i.item_type+'"><img src="'+i.avatar+'"><div class="cmty-item-text">'+i.item_text+'<br><span class="cmty-item-subtitle">'+d+"</span></div>"+m+"</div>";break;case"bookmark_tags":case"bookmark_topics":case"feed_topics":case"bookmark_forums":c+='<div class="cmty-item-'+i.item_type+'" style="color:'+l.main_color+'"><div class="cmty-item-text-w-extra">'+i.item_text+"</div>"+m+"</div>";break;default:h="<div",this.render_tooltips_on_items&&i.hasOwnProperty("item_category_name")&&(h+=' title="'+e["tag-tooltip-forum"]+" "+i.item_category_name+'"'),h+=' style="background-color:'+l.main_color+'" ',c+=h+=' class="cmty-item-'+i.item_type+'">'+i.item_text+m+"</div>"}return c+="</a>",n=$(c),_&&n.find(".cmty-delete-item").on("click",(function(t){p.onClickDelete(i,n),t.stopPropagation(),t.preventDefault()})),a=n.find(".cmty-item-"+i.item_type),"tag"===i.item_type?a.on("mouseenter",(function(t){a.css({"background-color":l.secondary_color,color:l.main_color})})).on("mouseleave",(function(t){a.css({"background-color":l.main_color,color:""})})).on("click",(function(t){a.css({"background-color":l.main_color,color:""})})):(r=a.find(".cmty-item-subtitle"),a.on("mouseenter",(function(t){a.css({color:l.secondary_color,"background-color":l.main_color}),r.addClass("cmty-item-subtitle-on-hover")})).on("mouseleave",(function(t){a.css({color:l.main_color,"background-color":""}),r.removeClass("cmty-item-subtitle-on-hover")})).on("click",(function(t){a.css({color:l.main_color,"background-color":""}),r.removeClass("cmty-item-subtitle-on-hover")}))),n},onClickDelete:function(t,e){this.hasOwnProperty("onDeleteItem")&&this.onDeleteItem(t)},addItem:function(t){var e;this.hasOwnProperty("$placeholder")&&this.$placeholder.detach(),e=this.constructItem(t),this.item_cells.push(e),this.$itembox.append(e)},events:{},onClose:function(){}}),t.ItemboxPosts=t.Itembox.extend({post_views:[],constructItem:function(e){var i;return this.hasOwnProperty("has_label_column")||(this.has_label_column=t.ViewPosts.prototype.hasLabel.apply(this)),i=new t.ViewPostsItem({model:this.model,item:e,has_label_column:this.has_label_column}),this.post_views.push(i),i.$el},onClose:function(){t.Itembox.prototype.onClose.apply(this),_.each(this.post_views,(function(t){t.close()}))}}),t.TopicCell=AoPS.View.extend({template_id:"#cmty-topic-cell-tpl",className:"cmty-topic-cell",marked_for_deletion:!1,is_hidden_until_page_add:!1,full_topics_popup:!1,has_subtitle:!0,is_focus:!1,watch_focus:!0,show_focus_post:!1,show_forum:!1,in_feed:!1,initialize:function(e){this.master=e.master,this.route_category_id=e.route_category_id,this.topic_list=e.topic_list,t.setRouteInfo(this,e),this.focus_tag=e.hasOwnProperty("focus_tag")?e.focus_tag:null,this.buildRoutes(),"/community"===this.url_router_base&&"blog_post"===this.model.get("topic_type")&&this.model.get("category_id")!==i.blog_recycle_bin_id&&(this.push_state_attribute=""),this.setAnnouncementStatus(),this.buildTopic(),this.setColor(),this.setReadStatus(),this.skip_onClickTopic=!1,this.listenTo(this.model,"change:is_read",this.setReadStatus),this.listenTo(this.model,"change:num_posts",this.onChangeNumPosts),this.listenTo(this.model,"change:last_post_id",this.onChangeLastPost),this.watch_focus&&this.setFocusWatchBehavior(),this.listenTo(this.model,"change:watchers_usernames change:num_watchers change:num_views",this.constructWatchersLine),this.listenTo(this.model,"change:last_post_rendered_time",this.onChangeLastPostTime),this.listenTo(this.model,"change:first_post_rendered_time",this.onChangeFirstPostTime),this.listenTo(this.model,"change:locked change:forum_locked",this.setTitleLine),this.listenTo(this.model,"change:deleted",this.onDelete),this.listenTo(this.model,"change:preview",this.onChangePreview),this.listenTo(this.model,"change:topic_title",this.setTitleLine),this.model.getPermission("c_can_monitor")&&this.listenTo(this.model,"change:state",this.setColor),this.master.get("monitoring_office_hours")&&"none"!=this.model.get("state")&&(this.listenTo(this.master,"reset_office_hours_topics",this.onResetOfficeHours),this.listenTo(this.model,"office_hours_person_here",this.onOfficeHoursPersonHere))},onResetOfficeHours:function(){this.$el.removeClass("cmty-office-hours-person-here")},onOfficeHoursPersonHere:function(t){AoPS.session.user_id!=t.user_id&&this.$el.addClass("cmty-office-hours-person-here")},onChangePreview:function(){this.$post_preview.html(this.model.get("preview"))},events:{"click a.cmty-topics-list-jump-bottom-link":"onClickJumpToBottom","click .cmty-topic-cell-close-topic":"onClickClose","click .cmty-post-settle-report":"onClickSettleReport","click .cmty-topic-cell-forum-view-last-poster":"onClickJumpToBottom","click a.cmty-topics-list-goto-unread-link":"onClickGotoUnread"},setFocusWatchBehavior:function(){this.listenTo(this.model,"change:is_master_focus",this.checkFocusTopic),this.checkFocusTopic()},onClickJumpToBottom:function(t){},onClickGotoUnread:function(t){},setColor:function(){var t,e,i=this,s=this.model.getPermission("c_can_monitor"),n=this.model.get("category_main_color"),a="",r=this.model.get("category_secondary_color");t=this.is_focus?r:n,this.$el.find(".cmty-color-main").css({color:t}),this.$el.find(".cmty-topic-cell-top").css({"background-color":n}),s&&this.colorMonitoredTopic(r,n),e=o.hexToRgb(r),_.isNull(e)||(a="rgba("+parseInt((255+e.r)/2)+","+parseInt((255+e.g)/2)+","+parseInt((255+e.b)/2)+", 1.0)"),this.$el.on("mouseenter",(function(t){i.is_focus||i.$el.add(i.$topic_watchers).css({"background-color":a})})).on("mouseleave click",(function(t){s?i.colorMonitoredTopic(r,n):i.$el.add(i.$topic_watchers).css({"background-color":""})}))},colorMonitoredTopic:function(t,e){var i="open"===this.model.get("state"),o=i&&!this.is_focus?t:"";this.$el.css({"background-color":o,"border-left":i?"3px "+e+" solid":"auto"}),this.$topic_watchers.css({"background-color":o})},setAnnouncementStatus:function(){this.topic_list.collection.category.get("show_announcements")?this.announce_type=this.model.get("announce_type"):this.announce_type="none"},buildTopic:function(){var t,i=this.url_router_base+this.url_cmty_path;this.$el.html(this.getTemplate(this.template_id,{route:AoPS.Community.Views.makeLinkUrl(this.route,i),route_bottom:AoPS.Community.Views.makeLinkUrl(this.route_bottom,i),route_back:AoPS.Community.Views.makeLinkUrl(this.route_back,i),route_unread:AoPS.Community.Views.makeLinkUrl(this.route_unread,i),push_state_attribute:this.push_state_attribute,category_id:this.model.get("category_id"),topic_id:this.model.get("topic_id"),lang_visit_in_forum:e["topic-cell-visit-in-forum"],full_topics_popup:this.full_topics_popup,first_poster_username:this.model.get("first_poster_name"),has_subtitle:this.has_subtitle,has_replies:this.model.get("num_posts")>1,last_poster_username:this.model.get("last_poster_name"),last_post_time:this.model.get("last_post_rendered_time"),topic_title:this.model.get("topic_title"),post_text:this.show_focus_post?this.model.get("focus_post").get("post_rendered"):this.model.get("preview"),first_poster_avatar:this.model.get("first_poster_avatar"),first_post_time:this.model.get("first_post_rendered_time"),is_logged_in:AoPS.session.logged_in,title_jump_end:e["topic-cell-title-jump-end"],title_settle:e["topic-cell-title-settle"],title_close:e["topic-cell-title-close"],title_unread:e["topic-cell-title-unread"],can_have_source:this.model.get("can_have_source"),has_source:this.model.get("source").length>0,source:this.model.get("source"),lang_source_title:e["topic-cell-source"],show_forum:this.show_forum,lang_Posted_at:this.show_focus_post?o.formatString(e["topic-cell-Posted-at"],[this.model.get("focus_post").get("username"),this.model.get("focus_post").get("poster_id"),e["topic-cell-view-user-profile"]]):"",show_focus_post_date:this.show_focus_post,focus_post_number:this.show_focus_post?this.model.get("focus_post").get("post_number"):0,focus_post_date:this.show_focus_post?o.makePrettyTimeStatic(this.model.get("focus_post").get("post_time")):0,category_name:this.model.get("category_name")})),this.has_subtitle&&(this.$subtitle=this.$el.find(".cmty-topic-cell-subtitle")),this.$watchers_line=this.$el.find(".cmty-topic-cell-watchers"),this.$watchers_line_forum_view=this.$el.find(".cmty-topic-cell-data-watchers"),this.$subject_line=this.$el.find(".cmty-topic-cell-subject"),this.$topic_cell_time=this.$el.find(".cmty-topic-cell-time"),this.$topic_watchers=this.$(".cmty-topic-watchers"),this.$post_preview=this.$el.find(".cmty-topic-cell-post"),this.$forum_view_last_poster=this.$el.find(".cmty-topic-cell-forum-view-last-poster"),this.$replies_line=this.$el.find(".cmty-topic-cell-replies"),this.$data_posts=this.$el.find(".cmty-topic-cell-data-posts"),this.setTitleLine(),this.onChangeNumPosts(),this.onChangeLastPost(),this.constructWatchersLine(),"local"===this.announce_type?this.$el.addClass("cmty-topics-list-local-announcement"):"global"===this.announce_type&&this.$el.addClass("cmty-topics-list-global-announcement"),this.model.getPermission("c_can_settle_report")&&(this.onChangeNumReports(),this.listenTo(this.model,"change:num_reports",this.onChangeNumReports)),this.model.get("can_have_source")&&this.listenTo(this.model,"change:source",this.onChangeSource),this.model.get("is_search_result")&&(this.model.get("focus_post").get("deleted")&&this.$el.addClass("cmty-search-target-deleted"),(t=this.model.fetchSearchText("post_text")).length>0&&this.$post_preview.extendedHighlightText("cmty-highlight",t),(t=this.model.fetchSearchText("title")).length>0&&this.$subject_line.extendedHighlightText("cmty-highlight",t),this.model.get("source").length>0&&(t=this.model.fetchSearchText("source")).length>0&&this.$(".cmty-topic-cell-source").extendedHighlightText("cmty-highlight",t))},constructSubtitle:function(){this.has_subtitle&&this.$subtitle.html(this.getTemplate("#cmty-topic-cell-subtitle-tpl",{has_replies:this.model.get("num_posts")>1,last_poster_username:this.model.get("last_poster_name"),last_post_time:this.model.get("last_post_rendered_time")}))},constructWatchersLine:function(){var t,i,s=this.model.get("num_watchers"),n=!1,a=0,r="",l=this.model.get("num_views"),c=_.unescape(this.model.get("topic_title"));return this.in_feed&&"private"!==this.model.get("topic_type")&&(c+="\n"+_.unescape(this.model.get("category_name"))),0===s?this.$topic_watchers.hide():(c+="\n",c+=0===(t=this.model.get("num_named_watchers"))?o.formatString(e["topic-cell-"+(1===s?"":"not-")+"1-reader"],[s]):e["topic-cell-reading-now"]+this.model.get("watchers_usernames")+(s>t?" +"+(s-t):""),i=this.model.get("watchers_avatars"),!this.model.get("master").get("current_user").get("hide_avatars")&&!_.isUndefined(i)&&i.length>0&&(n=!0,(i=i.split(" ")).length>0&&(i.length>6&&(i=_.first(i,6)),_.each(i,(function(t){t=$.trim(t),!_.isUndefined(t)&&t.length>0&&(r+='<img class="cmty-avatar" src="'+t+'" width="15" height="15">',a+=1)})))),n?i.length<s&&(r+=" <span>+"+(s-a)+'</span> <span class="aops-font">w</span>'):r=s+" "+e.viewing,this.$topic_watchers.html(r),this.$topic_watchers.show()),c+="\n"+this.model.get("num_views")+" "+(1===l?e.view:e.views),"none"!==this.model.get("announce_type")&&this.model.get("announce_through").length>0&&(c+="\nAnnouncement ends "+moment(this.model.get("announce_through"),"YYYY-MM-DD").format("MMM Do, YYYY")+"."),this.el.title=c,c},setTitleLine:function(){var t="";t+=this.model.get("locked")||this.model.get("forum_locked")?'<span class="aops-font">k</span>&nbsp;':"",t+="local"===this.model.get("announce_type")?'<span class="aops-font">i</span>&nbsp;':"",t+=this.model.get("poll_id")>0?'<span class="aops-font">9</span>&nbsp;':"",t+="global"===this.model.get("announce_type")?'<span class="aops-font">a</span>&nbsp;':"",t+=this.model.get("topic_title"),this.$subject_line.html(t)},onChangeNumReports:function(){var t;this.model.getPermission("c_can_settle_report")&&(0===(t=this.$el.find(".cmty-topic-cell-topic-reported")).length&&this.model.get("num_reports")>0?(t=this.getTemplate("#cmty-topic-cell-reported-topic-tpl",{topic_id:this.model.get("topic_id")}),this.$el.find(".cmty-topic-cell-left").append(t)):t.toggle(this.model.get("num_reports")>0))},onChangeNumPosts:function(){this.$replies_line.html(this.model.get("num_posts")-1),this.$data_posts.html(this.model.get("num_posts")-1+' <span class="cmty-no-tablet">'+(2==this.model.get("num_posts")?e["topic-cell-reply"]:e["topic-cell-replies"])+"</span>"),this.constructSubtitle()},buildForumViewLastPoster:function(){var t=this.url_router_base+this.url_cmty_path;this.$forum_view_last_poster.html(this.getTemplate("#cmty-topic-cell-forum-view-last-poster-tpl",{has_replies:this.model.get("num_posts")>1,last_poster_username:this.model.get("last_poster_name"),route_bottom:AoPS.Community.Views.makeLinkUrl(this.route_bottom,t),last_poster_avatar:this.model.get("last_poster_avatar"),last_post_time:this.model.get("last_post_rendered_time"),no_replies_message:e["topic-cell-no-replies"],push_state_attribute:this.push_state_attribute}))},onChangeLastPost:function(){this.constructSubtitle(),this.buildForumViewLastPoster()},onChangeLastPostTime:function(){this.$el.find(".cmty-reply-time").html(this.model.get("last_post_rendered_time")),this.buildForumViewLastPoster()},onChangeFirstPostTime:function(){this.$topic_cell_time.html(this.model.get("first_post_rendered_time"))},onChangeSource:function(){var t;this.model.get("can_have_source")&&((t=this.model.get("source")).length>0?this.$(".cmty-topic-cell-source").html('<span class="cmty-source-title">'+e["topic-cell-source"]+"</span>: "+t):this.$(".cmty-topic-cell-source").html(""))},onDelete:function(){this.close()},markMoved:function(){this.route_category_id=this.model.get("category_id"),this.$post_preview.html(this.route_category_id===i.recycle_bin_id?e["topic-cell-recycled-topic"]:e["topic-cell-moved-topic"]),this.buildRoutes(),this.$el.find("a.cmty-full-cell-link").attr("href","/community"+this.route).removeAttr(this.push_state_attribute).attr("data-cmty",!0),this.$el.find("a.cmty-topics-list-jump-bottom-link").attr("href","/community"+this.route_bottom).removeAttr(this.push_state_attribute).attr("data-cmty",!0),this.$el.find("a.cmty-topics-list-goto-unread-link").attr("href","/community"+this.route_unread).removeAttr(this.push_state_attribute).attr("data-cmty",!0)},buildRoutes:function(){var e,i,o=t.convertToUrlFragment(this.model.get("topic_title"));e="priv"===this.topic_list.collection.category.get("category_type")?"/x"+this.topic_list.collection.category.get("user_id"):"/c"+this.route_category_id,_.isNull(this.focus_tag)||(e+="t"+this.focus_tag.item_id+"f"+this.focus_tag.item_forum_id),i=e+"h"+this.model.get("topic_id"),this.route=i+"_"+o,this.route_bottom=i+"s1_"+o,this.route_back=e,this.route_unread=i+"s2_"+o,"private"===this.model.get("topic_type")&&"archived"===this.model.get("status")&&(this.route_back="/my-messages-archive",null!=this.focus_tag&&(this.route_back+="/t"+this.focus_tag.item_id+"f"+this.focus_tag.item_forum_id))},checkFocusTopic:function(){this.is_focus=this.model.get("is_master_focus"),this.processFocusTopicStatusChange()},processFocusTopicStatusChange:function(){this.$el.toggleClass("focus-topic",this.is_focus),this.setColor()},setReadStatus:function(){this.$el.toggleClass("topic-unread",!this.model.get("is_read"))}}),t.TopicCellPopout=t.TopicCell.extend({parent:t.TopicCell,buildTopic:function(){this.parent.prototype.buildTopic.apply(this),this.createStuntDouble()},createStuntDouble:function(){var t=this.url_router_base+this.url_cmty_path;return this.$stunt_double=$(this.getTemplate("#cmty-topic-cell-stunt-double-tpl",{wrapper_class:"cmty-topic-cell-double focus-topic "+this.className,push_state_attribute:this.push_state_attribute,full_topics_popup:this.full_topics_popup,route:AoPS.Community.Views.makeLinkUrl(this.route,t),route_bottom:AoPS.Community.Views.makeLinkUrl(this.route_bottom,t),route_back:AoPS.Community.Views.makeLinkUrl(this.route_back,t),title_settle:e["topic-cell-title-settle"],has_settleable_reports:this.model.get("num_reports")>0&&this.model.getPermission("c_can_settle_report")})),"global"!==this.model.get("announce_type")&&"local"!==this.model.get("announce_type")||this.$stunt_double.addClass("cmty-stunt-double-announcement"),this.constructWatchersLine(),this.$stunt_double},constructWatchersLine:function(){var t=this.parent.prototype.constructWatchersLine.apply(this);this.hasOwnProperty("$stunt_double")&&(this.$stunt_double[0].title=t)},onClose:function(){this.$stunt_double.remove()}}),t.search_post_topic_cell_arguments={className:t.TopicCell.prototype.className+" cmty-topic-cell-search-post",show_focus_post:!0,show_forum:!0,buildRoutes:function(){var t,e,i,o,s=this.model.get("focus_post").get("post_id"),n=this.topic_list.collection.category;"user_search_posts"===n.get("category_type")?(t="u",e=n.get("user_id")):"search"===n.get("category_type")?(t="q",e=n.get("search_id")):console.log("Uh-oh, building a Search Posts type topic cell without \t\t\t\t\tuser_search_posts or search type category"),o=(i="/"+t+e)+"h"+this.model.get("topic_id")+"p"+s,this.route=o,this.route_bottom=o+"s1",this.route_back=i+(n.has("encoded_search_text")?"_"+n.get("encoded_search_text"):""),this.route_unread=o+"s2"}},t.TopicCellSearchPost=t.TopicCell.extend(t.search_post_topic_cell_arguments),t.TopicCellSearchPopout=t.TopicCellPopout.extend(t.search_post_topic_cell_arguments),t.CategoryCellTopicCell=t.TopicCell.extend({has_subtitle:!1,watch_focus:!0}),t.TopicsList=AoPS.View.extend({template_id:"#cmty-category-cell-topics-tpl",list_location:"master",no_more_items_message:e["topics-list-no-more-items"],no_items_at_all_message:e["topics-list-no-items-at-all"],className:"cmty-topics-list",focus_tag:null,popout_focus_cell:null,focus_topic_cell:null,fetch_topics_on_build:!0,on_page:!1,use_topic_category:!1,topicView:t.TopicCell,popoutView:t.TopicCellPopout,initialize:function(i){var o=this;this.view_start_id=0,this.view_end_id=-1,this.suppress_scroll=!1,AoPS.bd&&AoPS.bd.mode&&"office_hours"===AoPS.bd.mode&&(this.no_more_items_message=e["topics-list-no-more-items-office-hours-default"],this.no_items_at_all_message=e["topics-list-no-items-at-all-office-hours"]),t.setRouteInfo(this,i),this.$loader=AoPS.Page.buildLoader(),this.$no_more_topics=$('<div class="cmty-no-more-topics">'+this.no_more_items_message+"</div>"),this.listenTo(this.collection,"bulk_topics_added",this.addBulkLoadedTopics),this.suppress_initial_fetch=!!i.hasOwnProperty("suppress_initial_fetch")&&i.suppress_initial_fetch,this.can_toggle_scroll_style="boolean"==typeof i.can_toggle_scroll_style&&i.can_toggle_scroll_style,this.on_initial_topic_fetch=!1,this.scroll_inner_listener_set=!1,i.hasOwnProperty("use_topic_category")&&(this.use_topic_category=i.use_topic_category),0!==this.collection.length||this.suppress_initial_fetch?this.constructTopicsList(i):this.onEmptyCollection(i),0===this.collection.length&&this.suppress_initial_fetch&&this.appendNoMoreTopicsMessage(),this.topics_hidden_until_next_add=[],this.updated_topics=[],this.topics_marked_for_deletion=!1,this.listenTo(this.collection,"reset",this.onCollectionReset),this.listenTo(this.collection.category,"check_for_more_topics",(function(){o.collection.length<10&&(o.suppress_scroll=!0,o.fetchMoreTopics())}))},isFixedHeight:function(){return"feed"===this.list_location||(!this.can_toggle_scroll_style||$(window).width()>i.phone_mode_max_width)&&this.$scrollbar.is(":visible")},onCollectionReset:function(){_.each(this.topic_boxes,(function(t){t.close()})),this.topic_boxes=[],this.view_start_id=0,this.view_end_id=-1,this.topics_hidden_until_next_add=[],this.topics_marked_for_deletion=!1,this.updated_topics=[],this.$no_more_topics.detach(),this.on_page&&this.onSliderAtBottom()},onEmptyCollection:function(t){this.constructTopicsList(t)},onAddToPage:function(){var t=this;this.$scroll_area.scrollTop(this.scroll_loc),!_.isNull(this.getFocusTopic())&&this.$el.is(":visible")&&this.shiftToTopic(this.getFocusTopic()),this.on_page=!0,this.checkQueuedUpTopicBoxes(),this.parseFocusTopic(),this.setFocusListener(),$("#cmty-topic-view-top .cmty-cat-cell-jump-top").on("click.cat-jump-to-top-"+this.cid,(function(){t.onClickJumpToTop()})),$(window).on("scroll.topics_list-"+this.cid+" touchmove.topics_list-"+this.cid,_.bind((function(){var t=$(document).scrollTop();_.isUndefined(this.$scrollbar)||this.$el.is(":visible")&&!this.$scrollbar.is(":visible")&&(document.documentElement.clientHeight+t>=document.body.offsetHeight-i.phone_more_topics_sensitivity&&this.onSliderAtBottom(),t<$("#header-wrapper").outerHeight()+parseInt($("#main-content").css("padding-top"))+$("#cmty-topic-view-top").height()&&this.onSliderAtTop())}),this)),this.checkIfEnoughCells()},onClose:function(){var t,e=this.topic_boxes.length;for(t=0;t<e;t++)this.topic_boxes[t].hasOwnProperty("is_placeholder")&&this.topic_boxes[t].is_placeholder||this.topic_boxes[t].close();this.hasOwnProperty("popout_focus_cell")&&!_.isNull(this.popout_focus_cell)&&this.popout_focus_cell.close()},parseFocusTopicList:function(){this.master.get("focus_topic_list")!=this.collection&&(this.processUpdatedTopicVisibility(),this.stopListening(this.master,"change:focus_topic_list"))},processUpdatedTopicVisibility:function(){var t,e,i=this,o=[],s=null;if(this.hasOwnProperty("topic_boxes")){if(this.topics_marked_for_deletion){for(t=(e=this.topic_boxes.length)-1;t>=0;t--)this.topic_boxes[t].marked_for_deletion?(this.updateViewLimitIdOnDelete(t),this.topic_boxes[t].close()):o.unshift(this.topic_boxes[t]);this.topic_boxes=o,this.updated_topics=[],this.topics_marked_for_deletion=!1}_.each(this.topics_hidden_until_next_add,(function(t){i.addTopic(t,{})})),this.topics_hidden_until_next_add=[]}for(e=this.topic_boxes.length,t=0;t<e;t++)"none"!==this.topic_boxes[t].announce_type?(this.topic_boxes[t].$el.removeClass("cmty-last-announcement"),s=this.topic_boxes[t]):t=e;_.isNull(s)||s.$el.addClass("cmty-last-announcement")},onRemoveFromPage:function(){this.on_page=!1,this.stopListening(this.master,"change:focus_topic"),this.stopListening(this.master,"change:fullscreen_mode"),$("#cmty-topic-view-top .cmty-cat-cell-jump-top").off("click.cat-jump-to-top-"+this.cid),$(window).off("scroll.topics_list-"+this.cid+" touchmove.topics_list-"+this.cid)},shiftToTopic:function(t){var e,i,o,s=_.find(this.topic_boxes,(function(e){return e.model===t&&!e.is_hidden_until_page_add})),n=this.$topics_window.height(),a=this.$topics_box.height();n>a||s&&(this.isFixedHeight()?((e=(o=s.$el.position().top)-this.$scroll_area.scrollTop())<0||e+s.$el.height()>n)&&this.$scroll_area.scrollTop(-Math.max(-o,n-a)):(o=s.$el.offset().top,((i=$(window).scrollTop())>o||i+$(window).height()>o+s.$el.height())&&window.scrollTo(0,o)))},checkIfEnoughCells:function(){var t,e;if(this.$topics_box.is(":visible")&&this.$topics_window.is(":visible")){if(t=this.$topics_box.height(),$(window).width()<=i.phone_mode_max_width&&t>$(window).height())return;e=this.$topics_window.height(),t>0&&e>0&&t<=e&&this.fetchMoreTopics()}},constructFetchMoreTopicsOptions:function(){var i=this,o=1===arguments.length&&"boolean"==typeof arguments[0].never_cancel&&arguments[0].never_cancel;return{source:this.list_location,never_cancel:o,onFinish:function(){i.parseFocusTopic(),i.$loader.detach(),i.collection.all_topics_fetched&&i.appendNoMoreTopicsMessage(),i.on_initial_topic_fetch=!1,i.suppress_scroll=!1,i.checkIfEnoughCells(),t.isIOS&&i.$scroll_area.css({"-webkit-overflow-scrolling":"touch"})},onError:function(o){var s;i.$loader.detach(),"E_AJAX_CANCEL"!==o.error_code&&(s="string"==typeof e["topic-fetch-err-"+o.error_code]?e["topic-fetch-err-"+o.error_code]:e["unexpected-error-code"]+o.error_code,"E_AJAX_TIMEOUT"!=o.error_code&&(i.collection.all_topics_fetched=!0),t.showError(s),t.isIOS&&i.$scroll_area.css({"-webkit-overflow-scrolling":"touch"}))}}},fetchMoreTopics:function(){var e=1===arguments.length?arguments[0]:{};this.collection.topics_loading||(0===this.collection.length&&(this.on_initial_topic_fetch=!0,this.suppress_scroll=!0),this.collection.all_topics_fetched?(this.suppress_scroll=!1,this.appendNoMoreTopicsMessage()):(this.$topics_box.append(this.$loader),t.isIOS&&(this.$scroll_area.css({"-webkit-overflow-scrolling":"auto"}),this.$scroll_area.scrollTop(this.$scroll_area[0].scrollHeight)),this.collection.fetchMoreTopics(this.constructFetchMoreTopicsOptions(e))))},constructTopicsList:function(t){var o,s,n=this.collection.length,a=[];if(_.extend(this,_.pick(t,"master","focus_tag","main_color","secondary_color")),this.category_id=t.category_id,this.$topics_box=$("<div/>",{class:"cmty-topics-list-inner-box"}),this.$title_bar=$(this.getTemplate("#cmty-topic-list-heading-tpl",{topic:"Topic",first:"First Poster",last:"Last Poster"})),this.$topics_box.append(this.$title_bar),this.topic_boxes=[],n>0){for(o=Math.min(i.max_num_shown_topics,n)-1,s=0;s<=o;s++)this.addTopic(this.collection.models[s],{add_in_bulk:!0});for(s=0;s<=o;s++)a.push(this.topic_boxes[s].$el);if(o<n-1)for(s=o;s<n;s++)this.topic_boxes.push({model:this.collection.models[s],is_placeholder:!0});this.$title_bar.after(a),this.view_end_id=o}this.min_add_bulk_idx=i.BIG,this.$scrollwrapped_list=AoPS.Community.Views.buildCommunityScrollbar(this.$topics_box,{onScroll:_.bind((function(){this.onScroll()}),this)}),this.$el.append(this.$scrollwrapped_list),this.$topics_window=this.$topics_box.parent(),this.$scroll_inner_window=this.$el.find(".aops-scroll-inner"),this.$scrollbar=this.$el.find(".aops-scroll-bar"),this.$scrollbar.before('<div title="'+e["topic-list-jump-top"]+'" class="cmty-topic-list-jump-top clickable">G</div>'),this.$scroll_slider=this.$scrollbar.find(".aops-scroll-slider"),this.$scrollbar.on("slider_at_end",_.bind((function(){this.onSliderAtBottom()}),this)),this.$scrollbar.on("slider_at_start",_.bind((function(){this.onSliderAtTop()}),this)),this.listenTo(this.collection,"add",this.addTopicAfterLoad),this.listenTo(this.collection,"remove",this.removeTopic),this.scroll_loc=0,this.$scroll_area=this.$topics_box.parent(),this.$scroll_area.on("scroll",_.bind((function(){this.scroll_loc=this.$scroll_area.scrollTop()}),this)),this.collection.all_topics_fetched?this.appendNoMoreTopicsMessage():this.fetch_topics_on_build&&!this.suppress_initial_fetch&&this.checkMoreTopicsNeeded(),this.$scroll_area.scrollTop(0),"condensed"===this.master.get("current_user").get("forum_view")&&this.$el.addClass("cmty-condensed-topic-list")},events:{"click .cmty-topic-list-jump-top":"onClickJumpToTop"},setFocusListener:function(){this.listenTo(this.master,"change:focus_topic",this.onChangeFocusTopic),this.listenTo(this.master,"change:focus_topic_list",this.parseFocusTopicList),this.listenTo(this.master,"change:fullscreen_mode",this.onChangeFullscreen)},onChangeFullscreen:function(){var t=this;setTimeout((function(){t.setPopoutVisibility()}),10)},getFocusTopic:function(){return this.master.get("focus_topic")},onScroll:function(){_.isNull(this.getFocusTopic())||this.setPopoutVisibility()},revealFocusCell:function(t){var e="top"===t,i=this.getFocusTopic(),o=this;this.hasOwnProperty("popout_focus_cell")&&!_.isNull(this.popout_focus_cell)&&(this.popout_focus_cell.$el.show(),this.$stunt_double.show(),this.focus_cell_location=t,this.scroll_inner_listener_set||(this.$scroll_inner_window.on("scroll.stunt",(function(){o.locateStuntDouble(t)})),this.scroll_inner_listener_set=!0),this.$el.toggleClass("top-focus-popup",e),this.$el.toggleClass("bottom-focus-popup",!e),this.$el.toggleClass("announcement-popup",!("none"===i.get("announce_type"))),this.stunt_double_height=this.$stunt_double.outerHeight(),o.locateStuntDouble(t))},locateStuntDouble:function(t){var e=this.$scroll_inner_window.scrollTop();"top"===t?this.$stunt_double.css("top",e+"px"):this.$stunt_double.css("top",e+this.$scroll_inner_window.height()-this.stunt_double_height+"px")},setPopoutVisibility:function(){var t=this.getFocusTopic(),e=-1,i=this.topic_boxes.length,o=null;if(this.on_page){for(var s=0;s<i;s++)if(this.topic_boxes[s].model===t){e=s,o=this.topic_boxes[s];break}if(_.isNull(o))return _.isNull(t)?void 0:void(this.collection.filter(t)?this.revealFocusCell("bottom"):this.destroyPopoutCell());if(e<this.view_start_id)this.revealFocusCell("top");else if(e>this.view_end_id)this.revealFocusCell("bottom");else{var n=-this.$scroll_inner_window.scrollTop()+o.$el.position().top;n<.5?this.revealFocusCell("top"):n>this.$el.height()-o.$el.outerHeight()?this.revealFocusCell("bottom"):(this.$el.removeClass("top-focus-popup bottom-focus-popup"),this.hasOwnProperty("popout_focus_cell")&&!_.isNull(this.popout_focus_cell)&&this.popout_focus_cell.$el.hide(),this.$stunt_double&&this.$stunt_double.hide(),this.$scroll_inner_window.off("scroll.stunt"))}}},destroyPopoutCell:function(){_.isNull(this.popout_focus_cell)||(this.stopListening(this.popout_focus_cell.model,"change:announce_type"),this.popout_focus_cell.close(),this.$stunt_double.remove(),this.$scroll_inner_window.off("scroll.stunt"),this.scroll_inner_listener_set=!1,this.popout_focus_cell=null,this.$el.removeClass("top-focus-popup bottom-focus-popup"))},onChangeFocusTopic:function(){var t=this;$(window).width()<=i.phone_mode_max_width&&(_.isNull(this.master.get("focus_topic"))?_.isUndefined(this.stored_window_top)||setTimeout((function(){window.scrollTo(0,t.stored_window_top)}),10):this.stored_window_top=$(window).scrollTop()),this.parseFocusTopic()},parseFocusTopic:function(){var t;this.on_page&&(t=this.getFocusTopic())?(this.popout_focus_cell&&this.popout_focus_cell.model===t||(this.popout_focus_cell&&this.popout_focus_cell.close(),this.popout_focus_cell=new this.popoutView({model:t,topic_list:this,master:this.master,focus_tag:this.focus_tag,push_state_attribute:this.push_state_attribute,url_cmty_path:this.url_cmty_path,url_router_base:this.url_router_base,route_category_id:this.category_id}),this.listenTo(t,"change:announce_type",this.destroyPopoutCell),this.popout_focus_cell.$el.addClass("cmty-topic-list-popout"),this.$stunt_double=this.popout_focus_cell.$stunt_double,this.$scroll_inner_window.append(this.$stunt_double),this.popout_focus_cell&&this.$el.find(".aops-scroll-outer").append(this.popout_focus_cell.$el)),this.setPopoutVisibility()):this.destroyPopoutCell()},checkMoreTopicsNeeded:function(){this.collection.all_topics_fetched?(this.topic_boxes.length<=i.num_topics_to_reveal&&(this.view_start_id=0,this.view_end_id=this.topic_boxes.length-1),this.appendNoMoreTopicsMessage()):this.topic_boxes.length<10&&(this.suppress_scroll=!0,this.onSliderAtBottom({never_cancel:!0}))},buildTopicCell:function(t){return new this.topicView({model:t,url_cmty_path:this.url_cmty_path,url_router_base:this.url_router_base,push_state_attribute:this.push_state_attribute,topic_list:this,master:this.master,focus_tag:this.focus_tag,route_category_id:this.use_topic_category?t.get("category_id"):this.category_id})},includeTopicWhenLocatingNew:function(t){return!t.marked_for_deletion||!!this.collection.category.get("is_forum")&&"none"!==t.model.get("announce_type")},addTopic:function(t,e){var i,o,s,n=this.buildTopicCell(t),a=-this.collection.comparator(t),r=e.hasOwnProperty("add_in_bulk")&&e.add_in_bulk&&"none"===t.get("announce_type"),l=!1,c=this.topic_boxes.length;for(n.is_hidden_until_page_add=!1,i=c-1;i>=0;i--)s=this.topic_boxes[i],this.includeTopicWhenLocatingNew(s)&&-this.collection.comparator(s.model)>a&&(r?this.min_add_bulk_idx>i+1&&(this.min_add_bulk_idx=i+1):s.$el.after(n.$el),this.topic_boxes.splice(i+1,0,n),o=i+1,i=-1,l=!0);if(l||(r?this.min_add_bulk_idx=0:this.$title_bar.after(n.$el),this.topic_boxes.splice(0,0,n),o=0),this.updateViewLimitIdOnAdd(o)||n.$el.detach(),"none"!==n.announce_type&&(o===c||"none"===this.topic_boxes[o+1].model.get("announce_type"))){for(i=0;i<o;i++)this.topic_boxes[i].$el.removeClass("cmty-last-announcement");n.$el.addClass("cmty-last-announcement")}return this.$no_more_topics.text(this.no_more_items_message),n},addTopicAfterLoad:function(t,e,i){var o,s,n=!1,a=!1;this.on_page&&"topic_update"===i.added_by&&(n=this.topics_marked_for_deletion&&_.indexOf(this.updated_topics,t)>-1),this.on_page&&(n||"topic_move"===i.added_by)&&this.collection.category!==t.get("force_add_to_category")?(-1===_.indexOf(this.topics_hidden_until_next_add,t)&&this.topics_hidden_until_next_add.push(t),a=!0):o=this.addTopic(t,i),i.add_in_bulk||(this.$loader.detach(),this.on_initial_topic_fetch||a||(this.isFixedHeight()?(s=this.$scroll_area.scrollTop(),o.$el.position().top<=s&&(this.$scroll_area.scrollTop(s+o.$el.outerHeight()),this.setPopoutVisibility())):this.on_page&&(s=$(window).scrollTop(),o.$el.position().top<=s&&window.scrollTo(0,s+o.$el.outerHeight()))))},removeTopic:function(t,e,i){var o,s,n=null,a=this,r=[],l=this.topic_boxes.length;for(_.each(this.topics_hidden_until_next_add,(function(e){e!==t&&r.push(e)})),this.topics_hidden_until_next_add=r,o=0;o<l;o++)if(this.topic_boxes[o].model===t){s=o,n=this.topic_boxes[o];break}_.isNull(n)||_.isUndefined(n)||(this.on_page&&i.hasOwnProperty("removed_by")?("topic_update"===i.removed_by?(n.marked_for_deletion=!0,this.updated_topics.push(t),this.topics_marked_for_deletion=!0):"topic_move"===i.removed_by&&(n.marked_for_deletion=!0,this.topics_marked_for_deletion=!0,this.collection.filter(t)?(this.removeTopicBox(n,s,t),this.on_page&&this.getFocusTopic()===t&&setTimeout((function(){a.parseFocusTopic()}),10)):n.markMoved()),Backbone.trigger("topic_cell_marked_for_deletion",{topics_list:this})):this.removeTopicBox(n,s,t)),!_.isNull(this.master.get("focus_topic"))&&this.on_page&&this.shiftToTopic(this.master.get("focus_topic")),0===this.collection.length&&this.$no_more_topics.text(this.no_items_at_all_message)},removeTopicBox:function(t,e,i){_.isNull(this.popout_focus_cell)||this.popout_focus_cell.model!==i||(this.popout_focus_cell.close(),this.popout_focus_cell=null,this.$el.removeClass("top-focus-popup bottom-focus-popup")),t.close(),this.topic_boxes=_.without(this.topic_boxes,t),this.updateViewLimitIdOnDelete(e)},addBulkLoadedTopics:function(){var t,e,o=[],s=this;if(this.min_add_bulk_idx<i.BIG&&(this.view_end_id===this.topic_boxes.length-1||this.view_end_id<=0)){for(e=this.topic_boxes.length-1,t=this.min_add_bulk_idx;t<=e;t++)o.push(this.topic_boxes[t].$el);this.$topics_box.append(o),this.checkRevealedTopics(),this.on_initial_topic_fetch||!this.on_page||this.suppress_scroll||(this.isFixedHeight()?0!=s.$scroll_area.scrollTop()&&s.$scroll_area.scrollTop(s.topic_boxes[s.min_add_bulk_idx].$el.position().top-s.$topics_window.height()):window.scrollTo(0,this.topic_boxes[this.min_add_bulk_idx].$el.offset().top-$(window).height()+20))}this.min_add_bulk_idx=i.BIG,this.$scrollwrapped_list.hasOwnProperty("aopsScroll")&&this.$scrollwrapped_list.aopsScroll.adjustSlider()},updateViewLimitIdOnAdd:function(t){return t<this.view_start_id?(this.view_start_id++,this.view_end_id++,!1):t>=this.view_start_id&&t<=this.view_end_id||t==this.view_end_id+1&&1==this.on_page?(this.view_end_id++,!0):!(t>=this.view_end_id+1)&&void 0},updateViewLimitIdOnDelete:function(t){t<this.view_start_id&&this.view_start_id--,t<=this.view_end_id&&this.view_end_id>=0&&this.view_end_id--},onClickJumpToTop:function(){var t,e,o=this.topic_boxes.length,s=[];for(this.view_end_id=Math.min(this.view_end_id,i.max_num_shown_topics-1),e=Math.min(this.view_start_id-1,this.view_end_id),this.view_start_id=0,t=this.view_start_id;t<=e;t++)s.push(this.topic_boxes[t].$el);for(t=this.view_end_id+1;t<o;t++)this.topic_boxes[t].$el.detach();this.$title_bar.after(s),this.isFixedHeight()?this.$scroll_area.scrollTop(0):window.scrollTo(0,0),this.markIfAtTop()},checkRevealedTopics:function(){var t,e,o,s,n;if(this.view_end_id-this.view_start_id<=i.max_num_shown_topics)this.markIfAtTop();else if(this.on_page){for((t=this.$scroll_slider.position().top)/(n=this.$scrollbar.height())<.2?(o=this.view_end_id-i.num_topics_to_hide+1,s=this.view_end_id,this.view_end_id=o-1):t/n>.7&&(s=this.view_start_id+i.num_topics_to_hide-1,o=this.view_start_id,this.view_start_id=s+1),e=o;e<=s;e++)this.topic_boxes[e].$el.detach();this.markIfAtTop()}},markIfAtTop:function(){var t=0==this.view_start_id;this.$el.toggleClass("cmty-not-at-top",!t),$("body").toggleClass("cmty-hide-header",!t)},checkQueuedUpTopicBoxes:function(){var t,e=[];if(-1===this.view_end_id){t=Math.min(this.topic_boxes.length,i.max_num_shown_topics);for(var o=0;o<t;o++)e.push(this.topic_boxes[o].$el);this.$title_bar.after(e),this.view_end_id=t-1,this.view_start_id=0}else this.view_end_id!==this.topic_boxes.length-1&&this.addQueuedTopics({fetch_more_if_at_end:!1})},addQueuedTopics:function(e){var o,s,n=[];s=Math.min(this.topic_boxes.length-1,this.view_end_id+i.num_topics_to_reveal),t.isIOS&&this.$scroll_area.css({"-webkit-overflow-scrolling":"auto"});for(var a=this.view_end_id+1;a<=s;a++)this.topic_boxes[a].hasOwnProperty("is_placeholder")&&this.topic_boxes[a].is_placeholder&&(this.topic_boxes[a]=this.buildTopicCell(this.topic_boxes[a].model)),n.push(this.topic_boxes[a].$el);this.topic_boxes[this.view_end_id].$el.after(n),o=this.view_end_id,this.view_end_id=s,this.checkRevealedTopics(),this.suppress_scroll||(this.isFixedHeight()?this.$scroll_area.scrollTop(this.topic_boxes[o+1].$el.position().top-this.$topics_window.height()):window.scrollTo(0,this.topic_boxes[o+1].$el.offset().top-$(window).height()+50)),o===s?o--:this.$scrollbar.trigger("reset_end_watchers"),t.isIOS&&this.$scroll_area.css({"-webkit-overflow-scrolling":"touch"}),e.fetch_more_if_at_end&&s==this.topic_boxes.length-1?this.fetchMoreTopics():this.suppress_scroll=!1},onSliderAtBottom:function(){var t=1===arguments.length?arguments[0]:{};$(document).trigger("mouseup"),this.view_end_id===this.topic_boxes.length-1?this.fetchMoreTopics(t):this.addQueuedTopics({fetch_more_if_at_end:!0})},onSliderAtTop:function(){var e,o,s,n=[];if(0!==this.view_start_id){this.$scrollbar.trigger("reset_end_watchers"),t.isIOS&&this.$scroll_area.css({"-webkit-overflow-scrolling":"auto"});for(var a=e=Math.max(0,this.view_start_id-i.num_topics_to_reveal);a<this.view_start_id;a++)n.push(this.topic_boxes[a].$el);this.topic_boxes[this.view_start_id].$el.before(n),s=this.view_start_id,this.view_start_id=e,this.checkRevealedTopics(),this.suppress_scroll||(this.isFixedHeight()?(o=this.topic_boxes[s].$el.position().top,this.$scroll_area.scrollTop(o)):(o=this.topic_boxes[s].$el.offset().top,window.scrollTo(0,o-40))),t.isIOS&&this.$scroll_area.css({"-webkit-overflow-scrolling":"touch"})}},appendNoMoreTopicsMessage:function(){this.$loader.detach(),0==this.collection.length&&this.$no_more_topics.text(this.no_items_at_all_message),this.$topics_box.append(this.$no_more_topics)}}),t.CategoryCellTopics=t.TopicsList.extend({template_id:"#cmty-category-cell-topics-tpl",className:"cmty-itembox",topicView:t.CategoryCellTopicCell}),t.CategoryCellPrivatesTopics=t.CategoryCellTopics.extend({no_more_items_message:e["topics-list-no-more-privates"],no_items_at_all_message:e["topics-list-no-privates"]}),t.TopicsListPrivates=t.TopicsList.extend({no_more_items_message:e["topics-list-no-more-privates"],no_items_at_all_message:e["topics-list-no-privates"]}),t.TopicsListSearchPosts=t.TopicsList.extend({topicView:t.TopicCellSearchPost,popoutView:t.TopicCellSearchPopout}),t.TopicTagbox=t.Itembox.extend({always_show_edit:!0,initialize:function(o){var s,n,a=o.hasOwnProperty("render_titles")&&o.render_titles,r=this;t.setRouteInfo(this,o),this.category_id=this.model.get("category_id"),this.secondary_color=this.model.get("category_secondary_color"),this.main_color=this.model.get("category_main_color"),_.each(this.model.get("tags"),(function(o){var s,l,c;o.hasOwnProperty("is_visible")&&!o.is_visible||(r.category_id===i.private_messages_id&&"archived"===r.model.get("status")?(n="/my-messages-archive/",c=r.model.get("master").get("my_privates_archive").get("category_name")):(n="/c"+r.category_id,c=r.model.get("category_name")),s=n+"t"+o.tag_id+"f"+r.category_id+"_"+t.convertToUrlFragment(o.tag_text),l=$($.parseHTML("<a "+r.push_state_attribute+' href="'+t.makeLinkUrl(s,r.url_router_base+r.url_cmty_path)+'"><div '+(a?'title="'+e["tag-tooltip-forum"]+_.unescape(c)+'"':"")+' class="cmty-item-tag">'+o.tag_text+"</div></a>")),r.$el.append(l))})),(this.always_show_edit||this.model.getPermission("c_can_edit_tags"))&&(s=$($.parseHTML('<div title="'+e["tag-edit-title"]+'" class="cmty-item-tag cmty-edit-tag aops-font">L</div>')),this.$el.append(s)),this.$el.find(".cmty-item-tag").css({"background-color":this.main_color})},events:{"mouseenter .cmty-item-tag":"onHoverTag","mouseleave .cmty-item-tag":"onLeaveTag","click .cmty-item-tag":"onClickTag"},onClickTag:function(t){var i;return $(t.target).hasClass("cmty-edit-tag")?AoPS.session.logged_in?this.model.getPermission("c_can_edit_tags")?void 0:(i=this.model.get("master").get("current_user").get("is_new_user")?"tagbox-new-user":"tagbox-no-permission",AoPS.Ui.Modal.showMessage(e[i],{width:"450px"}),t.stopPropagation(),t.preventDefault(),!1):(AoPS.Ui.buildLoginConfirm(e["tagbox-not-logged-in"]),t.stopPropagation(),t.preventDefault(),!1):(this.onLeaveTag(t),!0)},onHoverTag:function(t){t.target.style.backgroundColor=this.secondary_color,t.target.style.color=this.main_color},onLeaveTag:function(t){t.target.style.color="#fff",t.target.style.backgroundColor=this.main_color}}),t.ModalToAddParticipant=AoPS.View.extend({template_id:"#cmty-private-add-participant-tpl",initialize:function(){this.$el.html(this.getTemplate("#cmty-private-add-participant-tpl",{instructions_start:e["add-participant-instructions-start"],instructions_end:e["add-participant-instructions-end"],add_user:e["add-participant-add-user"],placeholder:e["add-participant-placeholder"],max_number:i.max_conversation_participants})),this.$input=this.$el.find("input"),o.buildUsernameAutocomplete(this.$input,{ajax_call:"fetch_username_matches",autocomplete_settings:{onSelect:_.bind((function(t,i){var s,n=_.findWhere(this.model.get("participants"),{user_id:parseInt(i.item.user_id)});return _.isUndefined(n)?this.chooseUser(i.item):(s=n.removed?"private-already-added-self-removed":"private-already-added-active",AoPS.Ui.Modal.showMessage(o.formatString(e[s],[i.item.label]),{width:"450px"}),this.$input.val("")),t.stopPropagation(),t.preventDefault(),!1}),this)}}),this.$new_participant=this.$el.find(".cmty-chosen-new-participant"),this.$el.showModal({type:"buttons",buttons:[{text:e["private-add-user-confirm-OK"],value:1},{text:e.Cancel,value:0}],close_on_button_click:!1,max_width:"450px",onButtonClick:_.bind((function(t){if(1==t){if(!this.hasOwnProperty("user")&&0==this.$input.val().length)return void AoPS.Ui.Modal.showMessage(e["private-no-username"]);for(var i=this.model.get("participants"),s=!1,n=0;n<i.length;n++)if(i[n].username.toLowerCase()==this.$input.val().toLowerCase()){s=!0;break}s?AoPS.Ui.Modal.showMessage(o.formatString(e["private-already-added-active"],[this.$input.val()]),{width:"450px"}):this.addUserToParticipants()}else this.close()}),this)}),this.$el.find("input").focus()},addUserToParticipants:function(){var t=this,i={onFinish:_.bind((function(t){this.onFinishAdding(t)}),this),onError:_.bind((function(t){var i,s=t.error_code;"E_NO_USER"===s?(AoPS.Ui.Modal.closeTopModal(),AoPS.Ui.Modal.showAlert(o.formatString(e["invalid-user"],[t.response.username]),{onClose:_.bind((function(){this.$input.focus()}),this)}),this.$new_participant.html(""),this.$input.show(),this.$input.val("")):(i="E_NOT_LOGGED_IN"===s?e["add-participant-logged-out"]:"E_NO_PERMISSION"===s?e["add-participant-no-permission"]:"E_PAST_TIME_LIMIT"===s?e["add-participant-too-late"]:"E_NO_MORE_PARTICIPANTS"===s?e["add-participant-no-more"]:"E_NO_ADDING_TO_SHERIFF"===s?e["add-participant-to-sheriff"]:"E_NO_ADDING_TO_EXTENSIONS"===s?e["add-participant-to-extensions"]:"E_USER_REMOVED_SELF"===s?e["add-participant-removed-user"]:"E_USER_EXCLUDED_FROM_PM"===s?o.formatString(e["add-participant-recipient-exclude-system"],[t.response.username]):"E_PM_SHERIFF"===s?o.formatString(e["add-participant-recipient-sheriff"],[t.response.username]):"E_PM_EXTENSIONS"===s?o.formatString(e["add-participant-recipient-extensions"],[t.response.username]):"E_USER_DOESNT_RECEIVE_PM"===s?o.formatString(e["add-participant-recipient-exclude-self"],[t.response.username]):"E_NO_ADDING_SELF"===s?e["add-participant-no-self"]:e["unexpected-error-code"]+s,AoPS.Community.Views.showError(i))}),this)};return AoPS.Ui.Modal.showMessage(e["private-adding-user-blocker"],{force_response:!0}),i=_.extend(i,{user:this.hasOwnProperty("user")?this.user:{username:this.$input.val()}}),this.model.checkValidPrivateRecipient({username:i.user.username,onFinish:function(o){o.is_unreachable?(AoPS.Ui.Modal.closeTopModal(),AoPS.Ui.Modal.showMessage(e["private-unreachable-recipient"],{force_response:!0})):t.model.submitNewParticipant(i)}}),!1},onFinishAdding:function(t){var e=this;AoPS.Community.Views.delayModalClearing({onClose:function(){e.close()}})},chooseUser:function(t){this.user={username:t.value,user_id:parseInt(t.user_id)},this.$new_participant.html(t.value),1==parseInt(t.is_admin)&&this.$new_participant.addClass("cmty-user-admin"),this.$input.hide()},onClose:function(){AoPS.Ui.Modal.closeAllModals()}}),t.EditableItemList=AoPS.View.extend({item_class:"aops-editable-item-list-item",item_limit:100,item_name:"item",has_close:!1,className:"cmty-items-input-box",num_matches:0,submitted_item:"",submit_on_special_keys:!0,item_selected:!1,initialize:function(t){var e=this;$.extend(this,t),this.has_close&&(this.$close_me=$($.parseHTML('<div class="cmty-editable-item-close">q</div>')),this.$el.append(this.$close_me)),this.counter=1,this.sending_to_rebuild=!1,this.constructInput(),this.suppress_autofocus=!1,this.$items=[],_.each(this.items,(function(t){e.putItemInBox(t)}))},events:{"click .cmty-delete-item":"onClickDeleteItem","click .cmty-editable-item-close":"onClickClose"},prepareAutocomplete:function(){this.constructItemAutocomplete()},getAutocompleteSource:function(){},getAutocompleteOnOpen:function(){return _.bind((function(t){}),this)},constructAutocompleteArgs:function(){return{}},constructItemAutocomplete:function(){var t=_.extend({match_type:"from_start_then_any",delay:250,is_case_sensitive:!1,source:this.getAutocompleteSource(),num_matches:this.num_matches,blockResponse:_.bind((function(){return this.item_submitted}),this),position:{my:"left top+5"},onSelect:_.bind((function(t,e){13===t.keyCode&&this.$input_box.val().toLowerCase()!==e.item.value.toLowerCase()&&(this.submitNewItem({label:this.$input_box.val(),item_id:0}),this.item_submitted=!0,this.item_selected=!0),this.item_submitted||(this.item_selected=!0,this.item_submitted=!0,this.submitNewItem(e.item),this.submitted_item=e.item.value),t.stopPropagation(),t.preventDefault()}),this)},this.constructAutocompleteArgs());this.$input_box.aopsAutocomplete(t),"function"==typeof this.onClose&&this.$input_box.blur(this.onClose),this.processPostConstruction()},onPaste:function(t){},processPostConstruction:function(){var t=this;this.$input_box.on("paste",(function(e){t.onPaste(e)})),this.$input_box.on("keydown",_.bind((function(t){var e,o=t.which||t.keyCode,s=this.$input_box.val();this.item_submitted=!1,13!==o&&188!==o&&9!==o||((188===o||9===o&&s.length>0)&&(t.preventDefault(),t.stopPropagation()),s.length>1&&this.submitted_item.toLowerCase()!==s.toLowerCase()&&!this.item_selected&&this.submit_on_special_keys&&this.submitNewItem({label:s,item_id:0})),0===s.length&&(8===o?this.$input_box.prev().hasClass(this.item_class)?this.tryToRemoveItem(this.$input_box.prev()):(e=this.$input_box.prevUntil("."+this.item_class).last().prev()).length>0&&this.tryToRemoveItem(e):46===o?this.tryToRemoveItem(this.$input_box.next()):this.$input_box.width(i.itembox_input_width),this.$input_box.focus()),this.item_selected=!1,this.validateCharacter(t)||(t.stopPropagation(),t.preventDefault())}),this)),this.$input_box.parent().on("click",(function(e){t.$input_box.focus(),e.stopPropagation()}))},validateCharacter:function(t){return!0},removeItem:function(t){var e,i;if(t instanceof jQuery)e=t,i=t.data("item");else if(i=t,e=_.find(this.$items,(function(t){return t.data("item")===i})),_.isUndefined(e))return;this.processRemovedItem(i),this.items=_.without(this.items,i),this.$items=_.without(this.$items,e),e.remove(),this.hasOwnProperty("onRemoveItem")&&this.onRemoveItem(i)},onClickDeleteItem:function(t){this.tryToRemoveItem($(t.target).parent())},tryToRemoveItem:function(t){this.removeItem(t)},processRemovedItem:function(t){},showError:function(t){AoPS.Ui.Modal.showAlert(t,{onClose:_.bind(this.resetInput,this)})},performCustomValidation:function(t){return!0},submitNewItem:function(t){return t.label=t.label.trim(),this.item_submitted=!0,this.countItems()>=this.item_limit?(this.showError(e["new-item-too-many-1"]+this.item_limit+" "+this.item_name+e["new-item-too-many-2"]),!1):t.label.length<2?(this.showError(e["new-item-too-short"]),!1):this.checkItemExists(t)?(this.showError(e["new-item-already-added"]+"<b>"+t.label+"</b>."),!1):void(this.performCustomValidation(t)&&this.buildNewItem(t))},countItems:function(){return this.items.length},checkItemExists:function(t){return!_.isUndefined(_.find(this.items,(function(e){return e.label.toLowerCase()===t.label.toLowerCase()})))},buildNewItem:function(t){var e;t.hasOwnProperty("is_visible")||(t.is_visible=!0),this.items.push(t),this.processNewItem(t),e=this.putItemInBox(t),this.hasOwnProperty("onAddItem")&&this.onAddItem(t,e),this.resetInput()},applyCssToNewItem:function(t,e){},submitItemSilent:function(t){this.countItems()>=this.item_limit||this.checkItemExists(t)||(this.suppress_autofocus=!0,this.buildNewItem(t),this.suppress_autofocus=!1)},putItemInBox:function(t){var e;if(!t.hasOwnProperty("is_visible")||t.is_visible)return"string"!=typeof t.label&&"string"==typeof t.value&&(t.label=t.value),"string"!=typeof t.value&&"string"==typeof t.label&&(t.value=t.label),e=$($.parseHTML('<div class="'+this.item_class+'">'+t.label+' <span class="cmty-delete-item aops-font">J</span></div>')),"boolean"==typeof t.is_special&&t.is_special&&e.addClass("cmty-special-item"),this.applyCssToNewItem(e,t),e.data("item",t),e.data("item_label",t.label),this.$items.push(e),this.$input_box.before(e),e},processNewItem:function(t){},resetInput:function(){var t=this;this.$input_box.val(""),this.counter+=1,this.$input_box.data("suppress_tab",!0),setTimeout(_.partial((function(e){t.rebuildInput(e)}),this.suppress_autofocus),10)},constructInput:function(){var t=this;this.$input_box=$($.parseHTML('<input type="text" class="cmty-items-input" maxlength="30"></input>')),this.$el.append(this.$input_box),"function"==typeof this.onInputBoxBlur&&this.$input_box.on("blur",(function(){t.onInputBoxBlur()})),this.prepareAutocomplete()},rebuildInput:function(t){this.$input_box.remove(),this.hasOwnProperty("$no_results")&&this.$no_results.hide(),this.constructInput(),0!=arguments.length&&t||this.$input_box.focus()},onClickClose:function(){this.$input_box.val().length>1&&this.submitNewItem({label:this.$input_box.val()}),this.close()}}),t.EditableTagBox=t.EditableItemList.extend({item_class:"cmty-item-tag",item_limit:i.max_tags_per_topic,has_search_icon:!1,item_name:"tag",num_matches:15,initialize:function(i){this.category=i.hasOwnProperty("category")?i.category:this.model.get("master").fetchCategory(this.model.get("category_id")),this.setTagColors(),t.EditableItemList.prototype.initialize.apply(this,[i]),this.$no_results=$('<div class="cmty-no-results-found">'+e["autocomplete-new-tag"]+"</div>"),this.$input_box.before(this.$no_results),this.input_on_blur=i.hasOwnProperty("input_on_blur")&&i.input_on_blur},onInputBoxBlur:function(){t.clicking&&this.$input_box.val().length>0&&this.input_on_blur&&(this.suppress_autofocus=!0,this.submitNewItem({label:this.$input_box.val(),item_id:0}),this.suppress_autofocus=!1),this.$no_results.hide()},onMatch:function(t){this.$no_results.hide()},onNoMatch:function(t){t===this.counter&&(this.$no_results.show(),this.$no_results.position({my:"left-1 top+1",at:"left bottom",of:this.$input_box}))},countItems:function(){return _.where(this.items,{is_visible:!0}).length},setTagColors:function(){this.tag_colors={main_color:this.category.get("main_color"),secondary_color:this.category.get("secondary_color")}},getAutocompleteSource:function(){var t=this,e=this.counter,i=this.$input_box;if(!_.isUndefined(this.category))return _.bind((function(o,s){this.category.fetchItemAutocompleteMatches({request:o,response:s,checkSquelch:function(){return o.term!==i.val().substr(0,i[0].selectionStart)&&o.term!==i.val()},checkInputExists:function(){return t.counter===e},onMatch:function(){"function"==typeof t.onMatch&&t.onMatch(t.counter)},onNoMatch:function(){"function"==typeof t.onNoMatch&&t.onNoMatch(t.counter)},additional_params:t.hasOwnProperty("additional_autocomplete_params")?t.additional_autocomplete_params:{}})}),this)},getAutocompleteOnOpen:function(){return _.bind((function(t){$(t).data("ui-autocomplete").menu.element.find("a").css({"background-color":this.tag_colors.main_color}).addClass(this.item_class)}),this)},applyCssToNewItem:function(t,e){t.css({"background-color":this.tag_colors.main_color})},constructAutocompleteArgs:function(){var t;return t=this.has_search_icon?"left-21 top+5":"left-1 top+5",{onFocus:_.bind((function(t,e){this.hasOwnProperty("focus_element")&&!_.isNull(this.focus_element)&&this.focus_element.css({color:"white","background-color":this.focus_element.data("main-color")}),this.focus_element=$(t.originalEvent.target).find("a.ui-state-focus"),this.focus_element.css({color:this.focus_element.data("main-color"),"background-color":this.focus_element.data("secondary-color")})}),this),onOpen:_.bind((function(){this.$input_box.autocomplete("widget").width(i.tag_autocomplete_width)}),this),_renderItem:function(t,e){var i=$("<a>").text(e.label).css({"background-color":e.main_color}).data({"main-color":e.main_color,"secondary-color":e.secondary_color});return $("<li>").append(i).appendTo(t)},position:{my:t,at:"left bottom",of:this.$input_box}}},processPostConstruction:function(){t.EditableItemList.prototype.processPostConstruction.apply(this),this.processTagBoxDropdownArrowing()},onPaste:t.onTagPaste,validateCharacter:t.validateTagCharacter,processTagBoxDropdownArrowing:function(){this.$input_box.on("keydown.post_construction",_.bind((function(t){var e=t.keyCode||t.which;38!==e&&40!==e||0===this.$input_box.data("ui-autocomplete").menu.element.find(".ui-state-focus").length&&_.each(this.$input_box.data("ui-autocomplete").menu.element.find("a"),(function(t){$(t).css({"background-color":$(t).data("main-color"),color:"#fff"})}))}),this))}}),t.EditableUserList=t.EditableItemList.extend({item_class:"cmty-itemlist-username",item_limit:1e3,item_name:"user",initialize:function(e){this.is_checking_username=!1,t.EditableItemList.prototype.initialize.apply(this,[e])},getAutocompleteSource:function(){var t=this.$input_box;return _.bind((function(e,i){o.fetchUsernameMatches({request:e,response:i,checkSquelch:function(){return e.term!==t.val().substr(0,t[0].selectionStart)&&e.term!==t.val()}})}),this)},constructAutocompleteArgs:function(){return{ui_class:"cmty-username-autocomplete",_renderItem:function(t,e){var i=$("<li></li>"),o=$("<a>"+e.label+"</a>");return i.append(o),"1"===e.is_admin&&o.addClass("cmty-user-admin"),i.appendTo(t)}}},applyCssToNewItem:function(t,e){"1"!==e.is_admin&&1!==e.is_admin||t.addClass("cmty-user-admin")},processUsernameCheckDelay:function(t,e,o){var s=(new Date).getTime()-o,n=this;s>=i.message_readability_delay?this.processUsernameCheck(t,e):setTimeout((function(){n.processUsernameCheck(t,e)}),i.message_readability_delay-s)},processUsernameCheck:function(t,i){this.is_checking_username=!1,this.isUsernameOK(t,i)?(t.user_id=i.user_id,t.is_admin=i.is_admin,this.buildNewItem(t),AoPS.Ui.Modal.closeTopModal()):AoPS.Ui.Modal.replaceTopModal({type:"alert",body:o.formatString(e["invalid-user"],[t.label]),frame_class:"aops-modal-quick"})},isUsernameOK:function(t,e){return e.user_id>0}}),t.EditableUserListCategoryAdmin=t.EditableUserList.extend({has_close:!0,initialize:function(e){this.role=e.role,t.EditableUserList.prototype.initialize.apply(this,[e])},processNewItem:function(t){t.hasOwnProperty("suppress_add_to_model")?delete t.suppress_add_to_model:this.model.addUser({role:this.role,username:t.value,user_id:parseInt(t.user_id),is_admin:parseInt(t.is_admin)})},processRemovedItem:function(t){this.model.removeUser({user_id:parseInt(t.user_id)})},getAutocompleteSource:function(){var t=this.$input_box;return _.bind((function(e,i){o.fetchUsernameMatches({request:e,response:i,checkSquelch:function(){return e.term!==t.val().substr(0,t[0].selectionStart)&&e.term!==t.val()}})}),this)},performCustomValidation:function(i){var s,n,a,r=this;return!this.isNewUserAdmin(i)&&("none"!==(s=this.model.checkUserRole(i.label)).role?(this.is_checking_username=!0,n=o.formatString(e["cat-admin-perms-existing-user"],[i.label,e["cat-admin-user-types-"+this.model.getAdminLangType()+"-"+s.role]]),this.model.getPermission("c_can_edit_"+s.role)?AoPS.Ui.Modal.showConfirm(n+e["cat-admin-perms-existing-user-3"]+" <b>"+e["cat-admin-user-types-"+this.model.getAdminLangType()+"-"+this.role]+"</b>.",(function(t){t&&(i.user_id=parseInt(s.user_id),i.suppress_add_to_model=!0,r.model.updateUserRole(i,r.role),r.buildNewItem(i)),r.reset()}),{width:"450px"}):AoPS.Ui.Modal.showAlert(n,{width:"450px",onClose:function(){r.reset()}}),!1):i.hasOwnProperty("user_id")?(i.item_id=parseInt(i.user_id),!0):(t.throwBlockingMessage(e["user-list-validation-blocker"]),a=(new Date).getTime(),this.is_checking_username=!0,this.model.checkAddedUsername({username:i.label,onFinish:function(t){r.processUsernameCheckDelay(i,t,a)}}),!1))},processUsernameCheck:function(t,i){var s=this;return 0===parseInt(i.user_id)?(AoPS.Ui.Modal.replaceTopModal({type:"alert",body:o.formatString(e["invalid-user"],[t.label]),frame_class:"aops-modal-quick",onClose:function(){s.resetInput(),s.is_checking_username=!1}}),!1):(t.user_id=i.user_id,t.label=i.username,t.value=i.username,t.is_admin=i.is_admin,!!this.performCustomValidation(t)&&(this.buildNewItem(t),AoPS.Ui.Modal.closeAllModals(),this.is_checking_username=!1,!0))},isNewUserAdmin:function(t){var i=this;return 1===parseInt(t.is_admin)&&("owner"!==this.role||AoPS.session.user_id!=t.user_id)&&(this.is_checking_username=!0,AoPS.Ui.Modal.showAlert(e["cat-admin-no-add-admin-start"]+t.label+e["cat-admin-no-add-admin-end"],{width:"450px",onClose:function(){i.reset()}}),!0)},reset:function(){AoPS.Ui.Modal.closeAllModals(),this.$input_box.focus(),this.is_checking_username=!1},onClickClose:function(){var i,o,s=this;this.$input_box.val().length>1?(this.is_checking_username=!0,o=this.$input_box.val(),i={label:o,value:o},t.throwBlockingMessage(e["user-list-validation-blocker"]),this.is_checking_username=!0,this.model.checkAddedUsername({username:i.label,onFinish:function(t){setTimeout((function(){s.processUsernameCheck(i,t,undefined)&&s.close()}),500)}})):this.close()}}),t.StaticUserList=AoPS.View.extend({className:"cmty-static-user-list",no_users_message:"",initialize:function(i){var o,s=this,n="function"==typeof i.onMatchLoggedInUser;i.hasOwnProperty("no_users_message")&&(this.no_users_message=i.no_users_message),i.user_list.length>0?_.each(i.user_list,(function(e){var o,a,r;a="cmty-itemlist-username"+(1===parseInt(e.is_admin)?" cmty-user-admin":""),o="/user/"+e.user_id,r=$('<a data-cmty href="'+t.makeLinkUrl(o)+'"><span class="'+a+'">'+e.username+"</span></a>"),n&&e.user_id==AoPS.session.user_id&&i.onMatchLoggedInUser(r,e),s.$el.append(r),s.$el.append(" ")})):this.$el.append(this.no_users_message),i.is_editable&&(o=$('<div title="'+e["userlist-edit"]+'" class="cmty-edit-user-list aops-font">L</div>'),this.$el.append(o))}}),t.ToggleableUserList=AoPS.View.extend({editableUserlistView:t.EditableUserList,staticUserlistView:t.StaticUserList,no_users_message:e.None,initialize:function(t){this.user_list=t.user_list,this.constructStaticUserlist()},events:{"click .cmty-edit-user-list":"toggleUserlist"},toggleUserlist:function(){this.is_static?(this.static_userlist.close(),this.constructEditableUserlist()):(location.reload(),this.editable_userlist.close(),this.constructStaticUserlist())},constructStaticUserlist:function(){this.static_userlist=new AoPS.Community.Views.StaticUserList({user_list:this.getUserList(),is_editable:!0,no_users_message:this.no_users_message}),this.is_static=!0,this.$el.html(this.static_userlist.$el)},constructEditableUserlist:function(){var t=this;this.editable_userlist=new this.editableUserlistView(_.extend({items:this.getEditableUserList(),model:this.model,onClose:function(){setTimeout((function(){t.editable_userlist.$el.find("input")[0]!==document.activeElement&&(t.is_static||t.editable_userlist.is_checking_username||t.toggleUserlist())}),200)}},this.getAdditionalEditableOptions())),this.is_static=!1,this.$el.html(this.editable_userlist.$el),this.editable_userlist.$input_box.focus()},onClose:function(){this.is_static?this.static_userlist.close():this.editable_userlist.close()},getAdditionalEditableOptions:function(){return{}},getUserList:function(){return this.user_list},getEditableUserList:function(){return this.user_list}}),t.ToggleableUserListCategoryAdmin=t.ToggleableUserList.extend({editableUserlistView:t.EditableUserListCategoryAdmin,initialize:function(t){this.user_list=_.filter(this.model.get("users"),(function(e){return e.role===t.role})),this.role=t.role,"owner"===t.role&&(this.no_users_message=e["cat-admin-site-admins-are-admins"]),this.constructStaticUserlist(),this.listenTo(this.model,"users_changed",this.onUsersChange)},onUsersChange:function(){this.is_static&&(this.static_userlist.close(),this.constructStaticUserlist())},getAdditionalEditableOptions:function(){return{role:this.role}},getUserList:function(){var t=this;return this.user_list=_.filter(this.model.get("users"),(function(e){return e.role===t.role})),this.user_list},getEditableUserList:function(){var t=this.getUserList();return _.map(t,(function(t){return{user_id:t.user_id,label:t.username,is_admin:t.is_admin}}))}}),t.EditableRecipientBox=t.EditableUserList.extend({performCustomValidation:function(i){var o,s=this;return this.is_checking_username=!0,i.label.toLowerCase()===AoPS.session.username.toLowerCase()?(this.showError(e["private-no-add-self"]),this.is_checking_username=!1,!1):this.items.length>=AoPS.Community.Constants.max_conversation_participants-1?(this.showError(e["private-cant-add-more"]),!1):(t.throwBlockingMessage(e["private-validation-blocker"]),o=(new Date).getTime(),setTimeout((function(){$(window).trigger("resize")}),0),this.model.checkValidPrivateRecipient({username:i.label,onFinish:function(t){t.is_unreachable?AoPS.Ui.Modal.replaceTopModal({type:"alert",body:e["private-unreachable-recipient"],frame_class:"aops-modal-quick",onClose:_.bind(s.resetInput,s)}):s.processUsernameCheckDelay(i,t,o)}}),!1)},isUsernameOK:function(t,e){return e.is_valid_recipient}}),t.EditableValidatedUserList=t.EditableUserList.extend({performCustomValidation:function(i){var s=this;if(!i.hasOwnProperty("user_id")){t.throwBlockingMessage(e["user-list-validation-blocker"]);var n=(new Date).getTime();return o.checkValidUsername({username:i.label,onFinish:function(t){s.processUsernameCheckDelay(i,t,n)}}),!1}return!0},isUsernameOK:function(t,e){return e.is_valid}}),t.EditableTagBoxExistingTopic=t.EditableTagBox.extend({has_close:!0,setTagColors:function(){this.tag_colors={main_color:this.model.get("category_main_color"),secondary_color:this.model.get("category_secondary_color")}},processNewItem:function(t){this.topic.addNewTag(t.tag_id,t.label)},processRemovedItem:function(t){this.topic.removeTag(t.tag_id,t.label)}}),t.EditableForumList=t.EditableItemList.extend({item_class:"cmty-item-forum",submit_on_special_keys:!1,initialize:function(i){this.ajax_call=i.hasOwnProperty("ajax_call")?i.ajax_call:"fetch_forum_autocomplete",this.$no_results=$('<div class="cmty-no-results-found">'+e["search-no-match"]+"</div>"),t.EditableItemList.prototype.initialize.apply(this,[i]),this.$input_box.before(this.$no_results)},onInputBoxBlur:function(){this.$no_results.hide()},prepareAutocomplete:function(){var t=this;o.buildCategoryAutocomplete(this.$input_box,{ajax_call:this.ajax_call,autocomplete_settings:{blockResponse:_.bind((function(){return this.item_submitted}),this),onSelect:function(e,i){t.item_submitted||(t.item_selected=!0,t.item_submitted=!0,t.submitNewItem(i.item),t.submitted_item=i.item.value),e.stopPropagation(),e.preventDefault()}},$no_results:this.$no_results,include_wrapper:!1,show_no_results_msg:!0}),this.processPostConstruction()},applyCssToNewItem:function(t,e){t.css({color:e.main_color})}}),t.TopicFull=AoPS.View.extend({template_id:"#cmty-topic-full-tpl",viewing_source:"master",className:"cmty-topic-full",reply_open:!1,postView:t.Post,has_source:!1,staticTagboxView:t.TopicTagbox,editableTagboxView:t.EditableTagBoxExistingTopic,scrollbar_settings:{autosize_exclusions:[{min:841,max:1e5}]},initialize:function(e){t.setRouteInfo(this,e),this.reply_box=null,this.$loader=AoPS.Page.buildLoader(),this.spoofing_scrollbar=!1,this.reveal_type=e.reveal_type,this.waitInitialization(e)},waitInitialization:function(t){var e=this;this.model?e.continueInitialization(t):setTimeout((function(){e.waitInitialization(t)}),100)},continueInitialization:function(t){if(this.model){var e=this;this.topic_category_at_initialization=this.model.get("category_id"),this.topic_id=this.model.get("topic_id"),this.loaded_from_post_id=0,this.fullscreen_triggered_by_reply=!1,this.from_middle={init:!1},this.unread_posts=[],this.posts=[],this.mark_time_at_add=this.model.get("db_mark_time"),this.start_post_id=-1,this.is_initialized=!1,this.is_on_page=!1,this.is_full_reply=!1,0===this.model.get("posts").length||"show_from_start"!=this.reveal_type&&1===this.model.get("posts").length&&!this.model.get("all_posts_fetched")?(this.$el.append(this.$loader),this.fetchTopicInitialPosts((function(){e.completeInitialization(t)}))):this.completeInitialization(t),this.snipe_warning_open=!1,this.snipe_warning_type=this.model.get("master").get("current_user").get("warn_on_snipes"),this.listenTo(this.model.get("master").get("current_user"),"change:warn_on_snipes",(function(){e.snipe_warning_type=e.model.get("master").get("warn_on_snipes")})),this.listenTo(this.model,"change:deleted",this.onDelete),this.listenTo(this.model,"change:state",this.renderState),this.listenTo(this.model,"change:target_url",this.onChangeTargetUrl),this.listenTo(this.model,"office_hours_person_here",this.onOfficeHoursPersonHere)}},canModerate:function(){return this.model.getPermission("c_can_move_topic_out")||this.model.getPermission("c_can_delete")||this.model.getPermission("c_can_lock_topic")||this.model.getPermission("c_can_announce")||this.model.getPermission("c_can_hard_delete")},onChangeTargetUrl:function(){0==this.model.get("target_url").length&&this.$(".cmty-target-url").parent().remove()},checkIsPrivate:function(){return"private"===this.model.get("topic_type")&&("feed"===this.viewing_source||!_.isNull(this.master.get("focus_category"))&&!_.isUndefined(this.master.get("focus_category"))&&"priv"!==this.master.get("focus_category").get("category_type"))},completeInitialization:function(t){var i,o,s,n,a,r,l,c=this,d="",_=this.model.checkShowTargetLink(),h=this.canModerate();i=this.model.getPermission("c_can_monitor")&&"none"!==this.model.get("state"),this.master=this.model.get("master"),this.is_private=this.checkIsPrivate(),this.route_category_id=t.hasOwnProperty("route_category_id")?t.route_category_id:this.model.get("category_id"),this.model.get("target_url").length>0&&(o=new RegExp(document.domain+"/"+AoPS.router_root),s=document.domain+this.model.get("target_url"),d=o.test(s)?AoPS.pushState_attr:""),this.$el.html(this.getTemplate(this.template_id,{topic_title:this.model.get("topic_title"),category_name:this.model.get("category_name"),category_id:this.model.get("category_id"),topic_id:this.model.get("topic_id"),can_reply:!0,has_target_url:_,target_attr:d,target_url:this.model.get("target_url"),tooltip_target:e["topic-full-target-tooltip"],viewed_in_own_forum:this.route_category_id===this.model.get("category_id"),lang_topic_tooltip:e["topic-full-title-tooltip"],lang_tag_tooltip:e["tag-tooltip-forum"],can_moderate:!this.is_private&&h,has_participants:this.is_private,can_unlock:this.model.getPermission("c_can_lock_topic"),can_unlock_forum:this.model.getPermission("c_can_lock_category"),tooltip_expand:e["topic-full-expand-tooltip"],tooltip_close:e["topic-full-close-tooltip"],tooltip_moderate:e["topic-full-moderate-tooltip"],tooltip_locked:this.model.getPermission("c_can_lock_topic")?e["topic-full-locked-tooltip-mod"]:e["topic-full-locked-tooltip"],tooltip_forum_locked:this.model.getPermission("c_can_lock_category")?e["topic-full-locked-forum-tooltip-mod"]:e["topic-full-locked-forum-tooltip"],tooltip_reply:e["topic-full-reply-tooltip"],locked:e["topic-full-locked"],forum_locked:e["topic-full-locked"],reply:e["topic-full-reply"],lang_Mod:e.Mod,has_topic_state:i,tooltip_state:e["topic-full-state-tooltip"]+this.model.get("state"),topic_state:this.fetchStateSymbol(),tooltip_feed_topic_title:e["feed-topic-title-tooltip"],tooltip_feed_forum_title:e["feed-forum-title-tooltip"],lang_click_for_tags:e["topic-full-click-for-tags"]})),this.$top_panel=this.$el.find(".cmty-topic-full-top"),this.$top_panel_placeholder=this.$el.find(".cmty-topic-full-top-placeholder"),this.$bottom_panel=this.$el.find(".cmty-topic-full-bottom"),this.is_private&&(this.$participants=this.$el.find(".cmty-topic-participants"),this.addParticipants(),this.listenTo(this.model,"change:participants",this.addParticipants)),(_||i)&&this.$top_panel.addClass("too-many-icons"),this.$posts_box=$("<div/>",{class:"cmty-postbox-inner-box"}),this.model.get("can_have_source")&&(this.has_source=!0,this.$source=$('<div class="cmty-topic-source-display"></div>'),this.renderSource(),this.$posts_box.append(this.$source),this.listenTo(this.model,"change:source",this.renderSource)),this.$who_is_typing=$('<div class="cmty-who-is-typing"></div>'),this.$quick_reply=$($.parseHTML('<div class="cmty-topic-posts-bottom"><div class="cmty-topic-mini-reply"><span class="aops-font">N</span> '+e["topic-full-post-reply"]+"</div></div>")),this.parseLockedVisibility(),this.$posts_outer_wrapper=this.$el.find(".cmty-topic-posts-outer-wrapper"),this.$reply_window=this.$el.find(".cmty-reply-window"),this.$reply_divider=this.$(".cmty-reply-divider"),this.$drag_wrapper=this.$(".cmty-topic-full-drag-wrapper"),this.$reply_divider.draggable({axis:"y",containment:this.$drag_wrapper,start:function(t,e){a=c.$posts_outer_wrapper.height(),r=e.offset.top,l=c.$reply_window.find("textarea").height()},helper:"clone",drag:function(t,e){var i=e.offset.top-r;c.$(".ui-draggable-dragging").css({left:"0px"}),c.$reply_window.find("textarea").height(l-i),c.$posts_outer_wrapper.height(a+i)}}),this.$who_is_typing.css("background",this.model.get("category_secondary_color")),this.$bookmark=this.$el.find(".cmty-topic-bookmark"),"private"===this.model.get("topic_type")?this.setArchiveStatus():this.setBookmarkStatus(),this.$posts_outer_wrapper.prepend(AoPS.Community.Views.buildCommunityScrollbar(this.$posts_box,this.scrollbar_settings)),this.$scrollbar=this.$posts_outer_wrapper.find(".aops-scroll-bar"),this.$posts_inner_wrapper=this.$posts_box.parent(),this.$posts_inner_wrapper.parent().append(this.$el.find(".cmty-topic-jump")),this.setPostFilter(),this.model.get("posts").each((function(t){c.addPost(t)})),this.initializeTagbox(),this.doExtraInitialization(),this.listenTo(this.model,"goto_last_post",this.goToLastPost),this.listenTo(this.model.get("posts"),"add",this.addPostAfterPageConstruction),this.listenTo(this.model,"change:is_bookmarked change:in_feed change:is_watched",this.setBookmarkStatus),this.listenTo(this.model,"post_load_complete",this.removeLoader),this.listenTo(this.model,"tag_removed tag_added",this.setHeight),this.listenTo(this.model,"change:locked change:forum_locked",this.parseLockedVisibility),this.listenTo(this.model,"change:topic_title",this.onChangeTopicTitle),i&&this.master.get("monitoring_office_hours")&&this.listenTo(this.master,"reset_office_hours_topics",this.onResetOfficeHours),this.$posts_box.append(this.$who_is_typing),0===this.posts.length||this.$posts_box.append(this.$quick_reply),this.setHeight(),1!==this.model.get("posts").length||this.model.get("all_posts_fetched")?this.onEndInitialization():(this.$posts_box.append(this.$loader),this.fetchTopicInitialPosts((function(){c.onEndInitialization()}))),this.model.get("is_search_result")&&(n=this.model.fetchSearchText("title")).length>0&&this.$(".cmty-topic-subject").extendedHighlightText("cmty-highlight",n),this.model.get("num_posts")>3&&1===this.model.get("posts").length&&(this.$posts_inner_wrapper.parent().addClass("aops-spoof-scrollbar-visible"),this.spoofing_scrollbar=!0)},isFixedHeight:function(){return"feed"===this.viewing_source||$(window).width()>i.phone_mode_max_width},fetchStateSymbol:function(){switch(this.model.get("state")){case"open":return"O";case"closed":return"C";case"not_monitored":return"N";default:return""}},renderState:function(){var t=this.$(".cmty-topic-state");t.length>0&&(t.html(this.fetchStateSymbol()),t[0].title=e["topic-full-state-tooltip"]+this.model.get("state"))},onClickState:function(){var t;switch(this.model.get("state")){case"open":t="closed";break;case"closed":t="not_monitored";break;case"not_monitored":t="open";break;default:t=this.model.get("state")}this.model.setState({state:t})},renderSource:function(){if(this.model.get("source").length>0?(this.$source.html('<span class="cmty-source-title">'+e["topic-full-source"]+"</span>: "+this.model.get("source")),this.$source.css({display:"block"})):this.$source.css({display:"none"}),this.model.get("is_search_result")){var t=this.model.fetchSearchText("source");t.length>0&&this.$source.extendedHighlightText("cmty-highlight",t)}},onChangeTopicTitle:function(){this.$(".cmty-topic-subject").html(this.model.get("topic_title"))},fetchTopicInitialPosts:function(t){this.listenToOnce(this.model,"post_load_complete",(function(){t()}))},onEndInitialization:function(){this.is_initialized=!0,this.is_on_page&&this.finishOnAddToPage(this.add_to_page_settings)},addParticipants:function(){this.$participants.html(this.getTemplate("#cmty-private-participants-tpl",{participants:this.is_private?this.buildParticipants():[],lang_removed:e["private-user-removed"],lang_remove_me:e["private-remove-me"],lang_add_participant:e["private-add-participant"],can_add_more:!(!this.is_private||this.model.get("category_id")!=i.private_messages_id||!this.model.getPermission("p_can_add_participant"))&&this.model.get("participants").length<i.max_conversation_participants})),this.setHeight()},buildParticipants:function(){return _.map(this.model.get("participants"),(function(t){return _.defaults({is_me:AoPS.session.user_id===t.user_id},t)}))},setInitialPostBoxLocation:function(){"show_from_end"===this.reveal_type?this.goToLastPost():"show_from_start"===this.reveal_type&&this.goToFirstPost()},doExtraInitialization:function(){},initializeTagbox:function(){var t;this.is_private||((t=this.model.get("master").get("current_user")).get("hide_tags_on_topic")&&this.$el.addClass("cmty-hide-topic-tags"),this.listenTo(t,"change:hide_tags_on_topic",(function(){this.$el.toggleClass("cmty-hide-topic-tags",t.get("hide_tags_on_topic"))}))),this.constructStaticTagbox(),this.listenTo(this.model,"change:tags tag_added",this.onTagsChanged)},setBookmarkStatus:function(){var i=this.$bookmark.find(".bkmk-icon"),o=this.$bookmark.find(".bkmk-text");this.$bookmark.prop("title",this.model.get("is_bookmarked")?e["topic-full-remove-bookmark-tooltip"]:e["topic-full-bookmark-tooltip"]),o.html(this.model.get("is_bookmarked")?e["bookmark-remove"]:e["bookmark-follow"]),i.html(t.makeBookmark({is_bookmarked:this.model.get("is_bookmarked"),in_feed:this.model.get("in_feed"),is_watched:this.model.get("is_watched")}))},setArchiveStatus:function(){this.hasOwnProperty(this.$archive_status)||(this.$archive_status=$('<span class="cmty-topic-archive cmty-icon-w-text clickable"></span>'),this.$(".cmty-topic-bookmark").replaceWith(this.$archive_status)),"active"===this.model.get("status")?(this.$archive_status.append('<span class="aops-icon">(</span>'+e["private-Archive-btn"]),this.$archive_status[0].title=e["private-archive-topic"]):(this.$archive_status.append('<span class="aops-icon">)</span>'+e["private-Unarchive-btn"]),this.$archive_status[0].title=e["private-unarchive-topic"])},onResetOfficeHours:function(){var t=this.model.get("is_feed_focus")?this.feed&&this.feed.get("focus_topic"):this.master&&this.master.get("focus_topic");t&&t.get("topic_id")===this.model.get("topic_id")&&(this.$who_is_typing.html(""),this.$el.removeClass("cmty-office-hours-person-here"),this.setHeight())},onOfficeHoursPersonHere:function(t){var e=this.model.get("category");if(!e||"my_privates"!==e.get("category_type")){var i=this.model.get("topic_id");if(i){var o=this.master.getFocusedTopicIds();if(i===o.master||i===o.feed){if(AoPS.session.user_id===parseInt(t.user_id)&&parseInt(t.is_typing)&&!this.reply_open&&(this.master.updateIsTyping(this.model,0),t.is_typing=!1),parseInt(t.is_typing))this.$who_is_typing.find('[data-user-id="'+t.user_id+'"]').length||this.$who_is_typing.append(this.getTemplate("#cmty-user-is-typing",t));AoPS.session.user_id!=t.user_id&&this.$el.addClass("cmty-office-hours-person-here"),this.setHeight();var s=this.$posts_outer_wrapper.find(".aops-scroll-inner"),n=s.prop("scrollHeight"),a=s.outerHeight(),r=!this.$posts_outer_wrapper.find(".aops-scroll-outer > .aops-scroll-fade-bottom").is(":visible");if(this.reply_open&&r){var l=n-a;s.scrollTop(l)}}}}},events:{"click .cmty-topic-mini-reply":"onClickReply","click .cmty-itembox .cmty-edit-tag":"toggleTagbox","click .cmty-topic-bookmark":"onClickBookmark","click .cmty-topic-jump-bottom":"goToLastPost","click .cmty-topic-jump-top":"goToFirstPost","click .cmty-topic-close":"onClickClose","click .cmty-add-participant":"onClickAddParticipant","click .cmty-full-screen":"onClickFullScreen","click .cmty-topic-moderate":"onClickModerate","click .cmty-topic-can-unlock, .cmty-topic-reply":"onClickFullReply","click .cmty-remove-me":"onClickRemoveMe","click .cmty-topic-archive":"onClickArchiveToggle","click .cmty-click-for-tags":"onClickForTags","click .cmty-topic-state":"onClickState"},onClickForTags:function(t){this.$el.removeClass("cmty-hide-topic-tags"),t.stopPropagation(),t.preventDefault()},onClickArchiveToggle:function(){var t=this.model.get("master");"active"===this.model.get("status")?(this.model.setMyStatus({status:"archived"}),"feed"!==this.viewing_source?t.get("my_privates").trigger("check_for_more_topics"):"feed"===this.model.get("master").get("fullscreen_mode")&&this.performFullScreenEvents(!1),this.completeParticipantStatusChange("/c"+i.private_messages_id),AoPS.Ui.Flyout.display(e["private-message-archived"])):(this.model.setMyStatus({status:"active"}),this.completeParticipantStatusChange("/h"+this.model.get("topic_id")),AoPS.Ui.Flyout.display(e["private-message-unarchived"]))},onClickFullScreen:function(t){this.performFullScreenEvents(!1)},onChangeFullscreenMode:function(){"feed"===this.model.get("master").get("fullscreen_mode")&&"master"===this.viewing_source&&(this.is_full_reply=!1)},performFullScreenEvents:function(t){var e=!1,o="none"===this.model.get("master").get("fullscreen_mode")?"master":"none";this.$posts_box.height()-this.$posts_inner_wrapper.scrollTop()-this.$posts_inner_wrapper.height()<i.reply_jump_to_bottom_window&&(e=!0),this.model.get("master").set("fullscreen_mode",o),$(window).trigger("resize"),e&&this.goToLastPost()},onClickRemoveMe:function(){var i,o,s=this;"archived"===this.model.get("status")?(i=e["private-remove-from-archived"],o="my_privates_archive"):(i=e["private-remove-from-active"],o="my_privates"),AoPS.Ui.Modal.showConfirm(i,(function(e){var i,n=s.model,a=n.get("master");e&&(i="feed"===s.viewing_source?"":t.constructUrlFromFocus(n.get("master"),{strip_topic:!0}),s.completeParticipantStatusChange(i),n.setMyStatus({status:"removed"}),a.get(o).trigger("check_for_more_topics"))}),{confirm_button_ok:e["private-remove-me-ok"],width:"450px"})},completeParticipantStatusChange:function(t){Backbone.history.navigate(t,{trigger:!0})},onClickModerate:function(){new AoPS.Community.Views.ModerateTopic({model:this.model,topic_category_at_initialization:this.topic_category_at_initialization,url_cmty_path:this.url_cmty_path,url_router_base:this.url_router_base,push_state_attribute:this.push_state_attribute})},onClickAddParticipant:function(){new AoPS.Community.Views.ModalToAddParticipant({model:this.model})},onTagsChanged:function(){"static"===this.tagbox_state&&(this.tagbox.close(),this.constructStaticTagbox())},onClickClose:function(e){var i,o=this.model.get("master").get("focus_tag"),s=this.master.get("focus_category"),n=s.get("category_type");this.model.get("master").set("fullscreen_mode","none"),$(window).trigger("resize"),"user_search_posts"===n?i="/u"+s.get("user_id"):"search"===n?i="/q"+s.get("search_id")+(s.has("encoded_search_text")?"_"+s.get("encoded_search_text"):""):"my_privates"===n&&"archived"===s.get("category_status")?(i="/my-messages-archive",_.isNull(o)||(i+="/t"+o.item_id+"f"+o.item_forum_id)):i="priv"===n?"/x"+s.get("user_id"):"/c"+this.route_category_id+(_.isNull(o)?"":"t"+o.item_id+"f"+o.item_forum_id),t.followUrlOnClick(e,i,this.url_router_base,this.url_cmty_path),this.fullscreen_triggered_by_reply=!1},onClickBookmark:function(){AoPS.session.logged_in?!t.in_academy&&AoPS.isUserLimited()?s.showMessage(e["bookmark-limited-user"],{width:"450px"}):this.model.get("is_bookmarked")?this.model.setBookmarkState({is_bookmarked:!1,in_feed:!1,is_watched:!1}):t.fireBookmarkModal("topic",o.formatString(e["bookmark-modal-topic"],[this.model.get("topic_title"),this.model.get("category_name")]),_.bind(this.model.setBookmarkState,this.model)):AoPS.Ui.buildLoginConfirm(e["bookmark-not-logged-in"])},onAddToPage:function(t){var e=this;function i(){e.finishOnAddToPage(t),e.is_on_page=!0}if(this.is_full_reply&&this.setFullReplyStyle(),this.model&&this.listenTo(this.model.get("master"),"change:fullscreen_mode",this.onChangeFullscreenMode),"master"===this.viewing_source&&Backbone.trigger("squelch_scroll_to_top"),this.is_on_page=!0,this.setFocusListener(),this.is_initialized&&this.model){if(this.model.get("all_posts_fetched"))return void i();this.model.get("master").get("in_change_focus_topic")?("show_from_start"===t.reveal_type?this.goToFirstPost():"show_from_middle"===t.reveal_type?this.goToPostId(t.post_id):this.goToLastPost(),this.setHeight(),this.$posts_box.append(this.$loader),this.$quick_reply.hide(),this.listenToOnce(this.model.get("master"),"change_topic_post_finish",(function(){e.$loader.detach(),i()}))):i()}else this.hasOwnProperty("$posts_outer_wrapper")&&this.setHeight(),this.add_to_page_settings=t},finishOnAddToPage:function(t){var e,i=this,o=!1;if(this.mark_time_at_add=this.model.get("db_mark_time"),this.reveal_type=t.reveal_type,t.hasOwnProperty("post_id")&&(this.start_post_id=t.post_id),"show_unread"===this.reveal_type&&(o=!0),this.setHeight(),this.setInitialPostBoxLocation(),this.model.get("all_posts_fetched"))if("show_from_start"!==this.reveal_type&&"show_from_end"!==this.reveal_type&&(this.reveal_type="show_from_start",this.setPostFilter(),this.applyPostFilter()),this.start_post_id>0)this.goToPostId(this.start_post_id);else if(o){var s=this.locateFirstUnreadPostBox();_.isUndefined(s)?this.goToLastPost():(e=Math.min(this.$posts_box.height()-this.$posts_inner_wrapper.height(),s.$el.position().top),this.$posts_inner_wrapper.scrollTop(e))}if("show_from_middle"===this.reveal_type||"show_unread"===this.reveal_type)if(this.reveal_type="show_from_middle",this.from_middle={init:!1},_.isUndefined(t.post_id)&&(t.post_id=0),this.model.get("read_since_loading")&&o){var n=this.locateFirstUnreadPostBox();this.reveal_type="show_from_end",this.setQuickReplyVisibility(),this.reveal_type="show_from_middle",e=Math.min(this.$posts_box.height()-this.$posts_inner_wrapper.height(),n.$el.position().top),this.$posts_inner_wrapper.scrollTop(e)}else 0!==t.post_id&&0!==this.loaded_from_post_id||(this.maskLoading(),this.fetchMorePosts("both"));this.model.set("is_read",!0),$(window).bind("resize.cmty-topic-"+this.cid,(function(){i.setHeight()})),this.setUpOnPageListeners(),this.model.get("read_since_loading")&&o||this.setQuickReplyVisibility(),this.model.set("read_since_loading",!0),this.loaded_from_post_id=t.post_id},setUpOnPageListeners:function(){this.listenTo(this.model,"topic_updated",this.setQuickReplyVisibility)},setFocusListener:function(){this.listenTo(this.model,"change:is_master_focus",this.onChangeFocusTopic)},maskLoading:function(){this.model.get("all_posts_fetched")||this.model.get("is_fetching_posts")||(this.setQuickReplyVisibility(),_.each(this.posts,(function(t){t.$el.hide()})))},onChangeFocusTopic:function(){this.fetchFocusTopic()!==this.model&&(this.$el.detach(),this.onRemoveFromPage())},fetchFocusTopic:function(){return this.model.get("master").get("focus_topic")},onDelete:function(){var t=this,i="topic-full-message-deleted",o=arguments.length>1&&arguments[2].hasOwnProperty("deleted_by_me")&&arguments[2].deleted_by_me,s=arguments.length>1&&arguments[2].hasOwnProperty("error_code")&&"E_NO_PERMISSION"===arguments[2].error_code;if(s&&(i=AoPS.session.logged_in?"topic-full-deleted-loss-permission":"topic-full-deleted-not-logged-in"),this.model.get("deleted")&&this.model.get("master").get("focus_topic")==this.model){if(!o){var n=$(".cmty-new-topic-popup"),a="";if(n.length>0){var r=n.first().find(".cmty-post-textarea").val();r.length>0&&(a+=e["topic-full-deleted-extra"]+"<textarea>"+r+"</textarea>")}AoPS.Ui.Modal.showAlert(e[i]+a,{onClose:function(){t.navigateAfterDelete()},frame_class:a.length>0?"aops-modal-standard cmty-deleted-topic-w-extra":"aops-modal-standard"})}this.close(),o&&this.navigateAfterDelete()}},navigateAfterDelete:function(){var t,e,i=this.model.get("master");s.closeAllModals(),(t=i.get("focus_category")).get("is_post_search")?"user_search_posts"===t.get("category_type")?Backbone.history.navigate("/u"+t.get("user_id"),{trigger:!0}):Backbone.history.navigate("/q"+t.get("search_id"),{trigger:!0}):"priv"===t.get("category_type")?Backbone.history.navigate("/x"+t.get("user_id"),{trigger:!0}):(e=t.get("category_id"),Backbone.history.navigate(this.url_cmty_path+"/c"+e,{trigger:!0}))},parseLockedVisibility:function(){this.model.get("locked")||this.model.get("forum_locked")?(this.reply_open&&(this.$el.is(":visible")&&AoPS.Ui.Modal.showMessage(e["topic-full-just-locked"]),this.closeNewReply()),this.$quick_reply.hide(),this.$(".cmty-topic-reply").addClass("force-hidden"),this.$(this.model.get("forum_locked")?".cmty-topic-forum-locked":".cmty-topic-locked").removeClass("force-hidden"),this.$(this.model.get("forum_locked")?".cmty-topic-locked":".cmty-topic-forum-locked").addClass("force-hidden")):(this.setQuickReplyVisibility(),this.$(".cmty-topic-locked").addClass("force-hidden"),this.$(".cmty-topic-forum-locked").addClass("force-hidden"),this.$(".cmty-topic-reply").removeClass("force-hidden"))},setHeight:function(){var t,e,o,s,n,a,r,l,c=0;if(this.hasOwnProperty("$top_panel")&&this.hasOwnProperty("$posts_outer_wrapper")){if(this.is_full_reply&&this.reply_open&&this.reply_box.is_previewing&&(this.removeFullReplyStyle(),this.setFullReplyStyle()),t=this.$top_panel.outerHeight(),this.$top_panel_placeholder.outerHeight(t),this.reply_open&&(a=this.$(".cmty-topic-full-drag-wrapper"),r=t+i.min_posts_window_height,a.css({top:r}),this.isFixedHeight()?this.is_full_reply?a.height(this.$el.height()-r-100):a.css({height:""}):a.height(this.$posts_inner_wrapper.height())),this.isFixedHeight()){if(0===t)return;return e=this.$posts_outer_wrapper.parent().height()-t,this.$el.toggleClass("cmty-no-preview",e<i.min_preview_height),this.$el.toggleClass("cmty-tiny-viewport",this.reply_open&&e<i.min_draggable_reply_height),this.reply_open&&(l=0,this.reply_box.is_previewing&&!this.is_full_reply&&(s=this.$reply_window.find(".cmty-post-preview")).is(":visible")&&(l=this.$reply_window.find(".cmty-posting-preview-bar").outerHeight()+s.outerHeight()),n=this.$reply_window.find(".cmty-reply-divider"),o=e-i.min_posts_window_height-(n.is(":visible")?this.$reply_window.find(".cmty-reply-divider").outerHeight():0)-this.$reply_window.find(".cmty-posting-button-row").outerHeight()-l,this.$reply_window.find("textarea").outerHeight()>o&&this.$reply_window.find("textarea").outerHeight(Math.max(o,i.min_stupid_view_reply_textarea)),c=this.$bottom_panel.outerHeight()),void this.$posts_outer_wrapper.outerHeight(Math.max(e-c,i.min_posts_window_height))}this.$posts_outer_wrapper.height("")}},removeFocusListener:function(){this.stopListening(this.model.get("master"),"change:focus_topic")},onRemoveFromPage:function(){var t;this.removeListeners(),this.$el.removeClass("cmty-not-at-top"),this.is_full_reply&&this.removeFullReplyStyle(),$("body").removeClass("cmty-hide-header"),$(window).unbind("resize.cmty-topic-"+this.cid),this.stored_window_top=0,$("#community-all").removeClass("reply-focused"),$(window).unbind("scroll.topic_full_from_start-"+this.cid),$(window).unbind("scroll.topic_full_from_end-"+this.cid),$(window).unbind("touchmove.topic_full_from_start-"+this.cid),$(window).unbind("touchmove.topic_full_from_end-"+this.cid),this.snipe_warning_type=this.model.get("master").get("current_user").get("warn_on_snipes"),AoPS.session.logged_in&&(_.each(this.unread_posts,(function(t){t.markRead()})),this.unread_posts.length>0&&(t=this.unread_posts[this.unread_posts.length-1].model,this.model.set("db_mark_time",t.get("post_time"))),this.unread_posts=[]),this.is_on_page=!1,this.start_post_id=-1,this.endReplyTriggeredFullscreen()},removeListeners:function(){this.stopListening(this.model,"topic_updated"),this.removeFocusListener(),this.stopListening(this.model.get("master"),"change:fullscreen_mode")},constructStaticTagbox:function(){var t,e="feed"===this.viewing_source,i=this.hasOwnProperty("route_category_id")&&this.route_category_id!==this.model.get("route_category_id");this.tagbox=new this.staticTagboxView({render_titles:i,model:this.model,url_cmty_path:e?"":this.url_cmty_path,url_router_base:e?"/community":this.url_router_base,push_state_attribute:e?"data-cmty":this.push_state_attribute}),this.$el.find(".cmty-tags-itembox-wrapper").append(this.tagbox.$el),this.tagbox_state="static",this.model.get("is_search_result")&&(t=this.model.fetchSearchText("tags")).length>0&&this.tagbox.$el.extendedHighlightText("cmty-highlight",t)},constructEditableTagbox:function(){this.closing=!1,this.editable_tagbox=new this.editableTagboxView({topic:this.model,model:this.model,items:_.map(this.model.get("tags"),(function(t){return{label:t.tag_text,item_id:t.tag_id,is_visible:t.is_visible}})),onClose:_.bind((function(t){setTimeout(_.bind((function(){this.editable_tagbox.$el.find("input")[0]!==document.activeElement&&"static"!==this.tagbox_state&&this.toggleTagbox()}),this),200)}),this)}),this.$el.find(".cmty-tags-itembox-wrapper").append(this.editable_tagbox.$el),this.tagbox_state="editing",this.editable_tagbox.$input_box.focus()},toggleTagbox:function(){"static"===this.tagbox_state?(this.tagbox.close(),this.constructEditableTagbox()):(this.editable_tagbox.close(),this.constructStaticTagbox()),this.setHeight()},goToLastPost:function(){var t,e,i;this.reveal_type="show_from_end",this.setPostFilter(),this.applyPostFilter(),0!==this.posts.length&&(this.setHeight(),t=this.$posts_outer_wrapper.outerHeight(),e=this.$posts_box.height(),i=this.posts[this.posts.length-1].$el.position().top,t>e||(this.isFixedHeight()?this.$posts_inner_wrapper.scrollTop(Math.min(i,-t+e)):window.scrollTo(0,document.body.scrollHeight),this.setPageHeaderVisibility()))},goToFirstPost:function(){this.reveal_type="show_from_start",this.setPostFilter(),this.applyPostFilter(),this.$posts_inner_wrapper.scrollTop(0),this.isFixedHeight()||window.scrollTo(0,0),this.setPageHeaderVisibility()},goToPostId:function(t){var e;e=_.find(this.posts,(function(e){return e.model.get("post_id")===t})),_.isUndefined(e)?this.onNoPostFound():this.setPostsBox(e.$el,0,0)},goToPostNumber:function(t){var e;e=_.find(this.posts,(function(e){return e.model.get("post_number")===t})),_.isUndefined(e)?this.onNoPostFound():this.setPostsBox(e.$el,0,0)},onNoPostFound:function(){t.showError(e["topic-full-no-post-found"]),this.goToFirstPost()},setPostFilter:function(){var t=this;"show_from_start"===this.reveal_type||"show_from_end"===this.reveal_type?this.filterPost=_.bind((function(t){return t.get(this.reveal_type)}),this):this.filterPost=_.bind((function(t){var e=t.get("post_number");return e>=this.from_middle.first_shown_post_num&&e<=this.from_middle.last_shown_post_num}),this),this.$scrollbar.off("slider_at_start.topic_full"),this.$scrollbar.off("slider_at_end.topic_full"),"show_from_start"!==this.reveal_type&&"show_from_middle"!==this.reveal_type||(this.$scrollbar.on("slider_at_end.topic_full",_.bind((function(){this.fetchMorePosts("forwards")}),this)),"master"===this.viewing_source&&($(window).on("scroll.topic_full_from_start-"+this.cid+" touchmove.topic_full_from_start-"+this.cid,(function(){t.$el.is(":visible")&&!t.$scrollbar.is(":visible")&&document.documentElement.clientHeight+$(document).scrollTop()+i.phone_more_posts_sensitivity>=document.body.offsetHeight&&t.fetchMorePosts("forwards")})),$(window).unbind("scroll.topic_full_from_end-"+this.cid),$(window).unbind("touchmove.topic_full_from_end-"+this.cid))),"show_from_end"!==this.reveal_type&&"show_from_middle"!==this.reveal_type||(this.$scrollbar.on("slider_at_start.topic_full",_.bind((function(){this.fetchMorePosts("backwards")}),this)),"master"===this.viewing_source&&($(window).on("scroll.topic_full_from_end-"+this.cid+" touchmove.topic_full_from_end-"+this.cid,(function(){t.$el.is(":visible")&&!t.$scrollbar.is(":visible")&&$(document).scrollTop()<$("#header-wrapper").outerHeight()+parseInt($("#main-content").css("padding-top"))+$("#cmty-topic-view-top").height()&&t.fetchMorePosts("backwards")})),$(window).unbind("scroll.topic_full_from_start-"+this.cid),$(window).unbind("touchmove.topic_full_from_start-"+this.cid)))},setQuickReplyVisibility:function(){this.reply_open||this.model.get("locked")||this.model.get("forum_locked")||"show_from_end"!==this.reveal_type&&!this.model.get("all_posts_fetched")?this.$quick_reply.css({display:"none"}):this.$quick_reply.css({display:"block"})},applyPostFilter:function(){var t=this;this.setQuickReplyVisibility(),_.each(this.posts,(function(e){t.setPostVisibility(e)}))},setPostVisibility:function(t){t.$el.toggle(this.filterPost(t.model))},setPostsBox:function(t,e,i){_.isUndefined(t)||_.isNull(t)||(this.isFixedHeight()?this.$posts_inner_wrapper.scrollTop(-(e-t.position().top+this.$posts_box.position().top-i)):window.scrollTo(0,t.position().top),this.setPageHeaderVisibility())},setPageHeaderVisibility:function(){!this.is_on_page||this.isFixedHeight()||1!==this.posts[0].model.get("post_number")||this.posts[0].$el.is(":visible")?$("body").removeClass("cmty-hide-header"):$("body").addClass("cmty-hide-header"),$(window).trigger("resize")},fetchMorePosts:function(t){var e,i,o,s,n,a,r,l="append",c=this.posts.length,d=this;if(!this.model.get("all_posts_fetched")&&!this.model.get("is_fetching_posts")&&($(document).trigger("mouseup"),this.is_initialized)){switch(this.reveal_type){case"show_from_start":r={onFinish:_.bind((function(){this.applyPostFilter()}),this),start_post_num:_.last(_.filter(this.posts,_.bind((function(t){return this.filterPost(t.model)}),this))).model.get("post_number")};break;case"show_from_end":r={start_post_num:_.find(this.posts,_.bind((function(t){return this.filterPost(t.model)}),this)).model.get("post_number"),onFinish:_.bind((function(){this.setPostsBox(s,n,a),this.applyPostFilter()}),this)};break;case"show_from_middle":(r=this.from_middle.init?{start_post_num:"forwards"===t?this.from_middle.last_shown_post_num:this.from_middle.first_shown_post_num}:{start_post_id:this.start_post_id,show_from_time:this.mark_time_at_add}).onFinish=_.bind((function(e){var i=-1;(!this.from_middle.init||e.low_num<this.from_middle.first_shown_post_num)&&(this.from_middle.first_shown_post_num=e.low_num),(!this.from_middle.init||e.high_num>this.from_middle.last_shown_post_num)&&(this.from_middle.last_shown_post_num=e.high_num),this.from_middle.init||(i=e.hasOwnProperty("target_post_number")&&!_.isNull(e.target_post_number)?e.target_post_number:-1),this.from_middle.init=!0,this.model.get("posts").findWhere({post_number:e.low_num}).get("show_from_start")&&(this.model.get("posts").each((function(t){t.get("post_number")<=d.from_middle.last_shown_post_num&&t.set("show_from_start",!0)})),this.reveal_type="show_from_start"),this.model.get("posts").findWhere({post_number:e.high_num}).get("show_from_end")&&(this.model.get("posts").each((function(t){t.get("post_number")>=d.from_middle.first_shown_post_num&&t.set("show_from_end",!0)})),this.reveal_type="show_from_end"),this.setPostFilter(),this.applyPostFilter(),"backwards"===t&&this.setPostsBox(s,n,a),i>-1&&this.goToPostNumber(i)}),this);break;default:console.log("Uhoh. fetchMorePosts called without reveal_type set properly")}if(r.direction=t,r.show_from_setting=this.reveal_type,"backwards"===t&&(l="prepend"),this.$posts_box[l](this.$loader),"backwards"===t)for(a=-this.$posts_inner_wrapper.scrollTop(),e=0;e<c;e++)(i=this.posts[e].$el).is(":visible")&&(o=i.position().top,a+o+i.height()>0&&(s=i,n=o+a,e=c));"forwards"===t&&this.$posts_inner_wrapper.scrollTop(this.$posts_box.height()-this.$posts_inner_wrapper.height()),"backwards"===t&&this.$posts_inner_wrapper.scrollTop(0),r.onError=function(t){"E_AJAX_CANCEL"===t.error_code&&d.$loader.detach()},r.source=this.viewing_source,this.model.fetchMorePosts(r)}},removeLoader:function(){this.$loader.detach()},addPost:function(t){var e,i,o=new this.postView({model:t,topic:this}),s=t.get("post_number"),n=this,a=this.posts.length,r=!1;for(this.spoofing_scrollbar&&(this.spoofing_scrollbar=!1,setTimeout((function(){n.$posts_inner_wrapper.parent().removeClass("aops-spoof-scrollbar-visible")}),330)),o.$el.css({display:"none"}),e=a-1;e>=0;e--)(i=this.posts[e]).model.get("post_number")<s&&(i.$el.after(o.$el),this.posts.splice(e+1,0,o),this.filterPost(t)&&o.$el.css({display:"block"}),r=!0,e=0);r||(this.posts.splice(0,0,o),this.has_source?this.$source.after(o.$el):this.$posts_box.prepend(o.$el),this.filterPost(t)&&o.$el.css({display:"block"})),AoPS.session.logged_in&&o.model.get("post_time")>this.mark_time_at_add&&o.model.get("poster_id")!==AoPS.session.user_id&&(o.markUnread(),this.unread_posts.push(o))},removePost:function(t){this.posts=_.without(this.posts,t),t.close()},locateFirstUnreadPostBox:function(){var t=this.posts.length;if(this.posts[t-1].is_read)return this.posts[t-1];for(var e=t-2;e>0;e--)if(this.posts[e].is_read)return this.posts[e+1];return this.posts[0]},addPostAfterPageConstruction:function(t){this.addPost(t),!this.model.get("is_fetching_past_posts")&&this.$el.is(":visible")&&(AoPS.session.a&&"feed"!==this.viewing_source&&(t.get("poster_id")!==AoPS.session.user_id?document.title="(new) "+_.unescape(this.model.get("topic_title")):document.title=_.unescape(this.model.get("topic_title"))),!this.reply_open||_.isNull(this.reply_box)||this.reply_box.sending_to_database||"none"===this.snipe_warning_type||this.max_post_num_at_reply_start<t.get("post_number")&&t.get("poster_id")!==AoPS.session.user_id&&t.get("poster_id")!==i.halp_user_id&&this.warnAboutSniping())},warnAboutSniping:function(){var t,i=this;this.snipe_warning_open||(this.snipe_warning_open=!0,t=[{text:e["snipe-option-never"],value:"none"},{text:e["snipe-option-not-this-time"],value:"now"},{text:e["snipe-option-flyout"],value:"flyout"},{text:e["snipe-option-close"],value:"close"}],"modal"===this.snipe_warning_type?(AoPS.Ui.Modal.showMessage(e["snipe-warning-body"],{type:"buttons",title:e["snipe-title"],buttons:t,width:"450px",close_on_button_click:!1,onButtonClick:_.bind((function(t){return"now"===t&&(this.snipe_warning_type="none"),"none"!==t&&"flyout"!==t||(this.model.get("master").get("current_user").setUserSetting({field:"warn_on_snipes",value:t}),this.snipe_warning_type=t),AoPS.Ui.Modal.closeAllModals(),!1}),this),onClose:_.bind((function(){this.snipe_warning_open=!1}),this)}),$("textarea.cmty-post-textarea").last().focus()):(n.display(e["snipe-warning-flyout"]),setTimeout((function(){i.snipe_warning_open=!1}),2e3)))},setFullReplyStyle:function(){t.setFullReplyStyle()},removeFullReplyStyle:function(){t.removeFullReplyStyle()},onClickFullReply:function(){this.completeReplyClick("feed"===this.viewing_source?"quick":"full")},checkReplyAvailable:function(){return AoPS.session.logged_in?!(!this.model.getPermission("c_can_reply")&&!this.model.getPermission("c_undo_global_ban"))||(t=AoPS.isUserLimited()?e["new-reply-no-permission-limited"]:e["new-reply-no-permission"],AoPS.Ui.Modal.showMessage(t,{width:"450px"}),!1):(AoPS.Ui.buildLoginConfirm(e["topic-full-not-logged-in-reply"]),!1);var t},onClickReply:function(){var t="quick";this.model.get("master").get("current_user").get("posting_fullscreen_reply")&&"feed"!=this.viewing_source&&(t="full"),this.completeReplyClick(t)},completeReplyClick:function(t){var e,i=!1;this.checkReplyAvailable()&&((e="full"===t)&&(this.setFullReplyStyle(),this.is_full_reply=!0,this.reply_open&&this.reply_box.is_previewing&&(i=!0,this.reply_box.onClickClosePreview())),this.reply_open?(_.isNull(this.reply_box)||this.reply_box.$post_box.focus(),this.isFixedHeight()||this.goToLastPost()):this.openNewReply(),e&&($(window).trigger("resize"),i&&this.reply_box.previewPost()))},openNewReply:function(){var e,o=!1,s=this;this.max_post_num_at_reply_start=this.model.get("posts").last().get("post_number"),e={notify_email:this.model.get("is_watched")||this.model.get("master").get("current_user").get("posting_subscribe_reply"),bookmark_feed:this.model.get("in_feed")||this.model.get("master").get("current_user").get("posting_subscribe_reply")},this.reply_box=new t.NewReply({topic_id:this.model.get("topic_id"),category_id:this.model.get("category_id"),topic:this.model,master:this.master,onPreview:function(){s.$el.addClass("cmty-open-preview"),s.setHeight()},onRevealPreview:function(){s.is_full_reply&&window.scrollTo(0,s.$(".cmty-posting-preview-bar").offset().top-20)},onClosePreview:_.bind((function(){this.$el.removeClass("cmty-open-preview"),this.setHeight()}),this),onSubmit:_.bind((function(){this.listenToOnce(this.model,"new_post_processed",this.onSubmittedPostProcessed)}),this),onCancel:_.bind((function(){this.closeNewReply()}),this),preset_extra_options:e}),this.reply_box.$post_box.on("focus",(function(){$("#community-all").addClass("reply-focused")})).on("blur",(function(){setTimeout((function(){$("#community-all").removeClass("reply-focused")}),10)})),this.$posts_box.height()-this.$posts_inner_wrapper.scrollTop()-this.$posts_inner_wrapper.height()<i.reply_jump_to_bottom_window&&(o=!0),this.$quick_reply.hide(),this.$reply_window.show(),this.$reply_window.append(this.reply_box.$el),this.reply_open=!0,this.$el.addClass("reply-open"),this.master.get("monitoring_office_hours")&&(this.master.updateIsTyping(this.model,1),this.$who_is_typing.append(this.getTemplate("#cmty-user-is-typing",AoPS.session)),this.master.fetchOfficeHoursData(!0)),this.setHeight(),this.reply_box.$el.find("textarea").focus(),o&&this.goToLastPost()},appendToReply:function(t){this.reply_open||this.openNewReply(),this.reply_box.addContent(t)},onSubmittedPostProcessed:function(){this.closeNewReply(),this.goToLastPost(),setTimeout((function(){AoPS.Ui.Modal.closeAllModals()}),i.new_reply_modal_delay)},closeNewReply:function(){this.reply_open=!1,this.$el.removeClass("reply-open"),this.master.updateIsTyping(this.model,0),this.$who_is_typing.find('[data-user-id="'+AoPS.session.user_id+'"]').remove(),this.setQuickReplyVisibility(),_.isNull(this.reply_box)||this.reply_box.close(),this.reply_box=null,this.$reply_window.hide(),this.setHeight(),this.is_full_reply&&(this.is_full_reply=!1,this.removeFullReplyStyle())},endReplyTriggeredFullscreen:function(){this.fullscreen_triggered_by_reply&&(this.fullscreen_triggered_by_reply=!1,this.model.get("master").set("fullscreen_mode","none"),$(window).trigger("resize"))},onClose:function(){this.hasOwnProperty("reply_box")&&!_.isNull(this.reply_box)&&"function"==typeof this.reply_box.close&&this.reply_box.close(),_.each(this.posts,(function(t){t.close()})),Backbone.trigger("destroy_topic_view",{category_id:this.topic_category_at_initialization,topic_id:this.topic_id})}}),t.CategoryCell=AoPS.View.extend({template_id:"#cmty-category-cell-tpl",className:"cmty-category-cell",can_bookmark:!1,has_own_url:!1,has_search:!1,has_small_header:!1,forums_not_tags:!1,default_to_tags:!0,force_to_tags:!1,has_topics:!0,fetch_topics_immediately:!1,has_numbers:!0,has_items:!0,has_help:!1,has_search_link:!1,has_bottom:!0,has_jump_to_top:!1,placeholder_text:e["cat-cell-no-tags-yet"],use_own_color:!0,topics_box_constructor:t.CategoryCellTopics,items_box_constructor:t.Itembox,topic_box_constructed:!1,tags_topics_in_topbar:!1,topics_title:e["cat-cell-forum-topics"],items_title:e["cat-cell-tags-title"],show_description:!1,initialize:function(s){var n,a=o.displayCategoryType(this.model.get("category_type")),r=this.model.get("category_id")>1,l="none"!==this.model.get("can_add_type")&&this.model.get("master").fetchPermission("can_create_category"),c=this.model.getPermission("c_can_lock_category"),d=l?e.Create+" new "+this.model.get("can_add_type"):"";(s.hasOwnProperty("default_to_topics")&&s.default_to_topics||!this.force_to_tags&&this.model.has("active_topics")&&(this.model.get("all_topics_loaded")||this.model.get("active_topics").length>3))&&(this.default_to_tags=!1),t.setRouteInfo(this,s),this.constructUrls(r),n={has_small_header:this.has_small_header,category_name:this.model.get("category_name"),short_description:this.model.get("short_description"),long_description:this.model.get("short_description"),url:AoPS.Community.Views.makeLinkUrl(this.url,this.url_router_base+this.url_cmty_path),push_state_stay:this.push_state_attribute,can_post:this.model.get("can_start_topic")&&!this.model.get("is_locked"),is_locked:this.model.get("can_own_topics")&&this.model.get("is_locked"),lang_category_locked_title:c?e["cat-cell-forum-locked-title-mod"]:e["cat-cell-forum-locked-title"],Locked:e["cat-cell-Locked"],can_unlock:c,can_add:l,can_add_title:d,hide_desc_phone:this.model.get("hide_desc_on_phone"),has_numbers:this.has_numbers,has_items:this.has_items,has_jump_to_top:this.has_jump_to_top,show_description:!(this.has_numbers||this.has_topics)||this.show_description,has_bottom:this.has_bottom,can_bookmark:this.can_bookmark,mark_read:e["cat-cell-mark-read"],new_post:this.model.get("is_private")?e["cat-cell-new-message"]:e["cat-cell-new-topic"],category_id:this.model.get("category_id"),can_mark_all_read:AoPS.session.logged_in&&this.model.get("can_mark_all_read"),has_info:r,has_search_link:this.has_search_link&&-1==_.indexOf(i.unsearchable_fora,this.model.get("category_id")),lang_search:this.model.get("is_private")?e["cat-cell-search-pm"]:e["cat-cell-search-forum"],lang_information:o.capitalizeFirstLetter(a)+" "+e.information,lang_mark_read_title:e["cat-cell-mark-read-title"],lang_bookmark_title:e["cat-cell-bookmark-title"]+a,lang_new_topic_title:this.model.get("is_private")?e["cat-cell-new-pm-title"]:e["cat-cell-new-topic-title"],lang_additional_options:e["cat-cell-more-options-title"],has_help:this.has_help,has_search:this.has_search,lang_help_title:e["cat-cell-help-title"]},this.$el.html(this.getTemplate(this.template_id,n)),this.forums_not_tags&&this.$el.addClass("cmty-forums-not-tags"),this.model.get("can_own_topics")&&this.listenTo(this.model,"change:is_locked",this.parseLockStatus),this.$category_heading=this.$el.find(".cmty-category-cell-heading"),this.$new_topic=this.$category_heading.find(".cmty-new-topic-button"),this.$locked=this.$category_heading.find(".cmty-category-locked-button"),this.$category_description=this.$el.find(".cmty-category-description"),this.$menu=this.$el.find(".cmty-cat-cell-menu"),(this.has_items||this.has_topics)&&(this.$itembox_container=this.$el.find(".cmty-category-itembox-wrapper")),this.has_items&&(this.$itembox_bar=this.$el.find(".cmty-category-cell-poptags"),this.$active_triangle=this.$el.find(".cmty-category-cell-sublink-triangle"),this.$itembox_bar.length>0&&(this.$itembox_bar[0].title=this.items_title),this.default_to_tags&&this.onClickPopularTags()),this.has_numbers&&(this.$num_topics=this.$el.find(".cmty-category-cell-num-topics"),this.$num_users=this.$el.find(".cmty-category-cell-num-users"),this.setNumTopics(),this.setNumUsers(),this.listenTo(this.model,"change:num_topics",this.onChangeNumTopics),this.listenTo(this.model,"change:num_posts",this.setNumPosts),this.listenTo(this.model,"change:num_users",this.onChangeNumUsers)),this.has_search&&this.buildCategorySearch(),this.applyColor(),this.has_topics&&(this.$topic_bar=this.$el.find(".cmty-category-cell-topics"),this.default_to_tags||this.onClickTopics(),this.$topic_bar.length>0&&(this.$topic_bar[0].title=this.topics_title)),this.model.get("can_mark_all_read")&&AoPS.session.logged_in&&(this.parseAllRead(),this.listenTo(this.model,"change:all_read",this.parseAllRead)),this.tags_topics_in_topbar&&(this.$(".cmty-category-cell-right").append(this.$topic_bar),this.$(".cmty-category-cell-right").append(this.$itembox_bar)),this.listenTo(this.model,"change:deleted",this.onDeleteCategory)},parseLockStatus:function(){this.model.get("can_own_topics")&&(this.$new_topic.toggleClass("force-hidden",this.model.get("is_locked")),this.$locked.toggleClass("force-hidden",!this.model.get("is_locked")))},constructUrls:function(e){this.url=this.has_own_url?this.own_url:"/c"+this.model.get("category_id")+"_"+t.convertToUrlFragment(this.model.get("category_name")),this.url_info=e?"/category-admin/"+this.model.get("category_id"):""},events:{"mouseenter .cmty-full-cell-link":"onHoverHeading","mouseleave .cmty-full-cell-link":"onUnhoverHeading","click .cmty-category-cell-poptags":"onClickPopularTags","click .cmty-category-cell-topics":"onClickTopics","click .cmty-new-topic-button":"launchNewTopic","click .cmty-category-cell-heading":"onClickHeading","click .cmty-mark-all-read":"onClickMarkAllRead","click .cmty-cat-cell-cat-info":"onClickInfo","click .cmty-add-new-category":"onClickAddNew","click .cmty-cat-admin-help-wrap":"onClickHelp","click .cmty-category-locked-button":"onClickLocked","click .cmty-cat-cell-search":"onClickSearch"},onDeleteCategory:function(){this.model.get("deleted")&&this.close()},onClickLocked:function(i){this.model.getPermission("c_can_lock_category")?this.launchNewTopic(i):(t.showError(e["cat-cell-locked-modal"]),i.stopPropagation(),i.preventDefault())},onClickAddNew:function(i){"forum"===this.model.get("can_add_type")&&t.followUrlOnClick(i,"/category-admin/forum"),"collection"===this.model.get("can_add_type")&&AoPS.Ui.Modal.showAlert(this.getTemplate("#cmty-create-collection-modal-body-tpl",{}),{title:e["cat-cell-create-collection"],alert_button_ok:e.Cancel,width:"600px"}),"blog"===this.model.get("can_add_type")&&t.followUrlOnClick(i,"/category-admin/blog"),i.preventDefault(),i.stopPropagation()},onClickSearch:function(e){var i=1==this.model.get("category_id")?"/search-private":"/search-forum/"+this.model.get("category_id");"/community"===this.url_router_base?t.followUrlOnClick(e,i):t.leaveRouterOnClick(e,i)},onClickInfo:function(e){"/community"===this.url_router_base?t.followUrlOnClick(e,this.url_info):t.leaveRouterOnClick(e,this.url_info)},onClickMarkAllRead:function(t){return this.model.markAllTopicsRead(),t.preventDefault(),t.stopPropagation(),!1},onClickHelp:function(t){var i=this.getTemplate(this.help_template,{is_logged_in:AoPS.session.logged_in});0===this.help_template.length&&console.log("oh no; there is a help box on a category with no help_template set."),AoPS.Ui.Modal.showAlert(i,{title:e[this.help_template_title_setting],width:"450px",scrollable:!0}),t.preventDefault(),t.stopPropagation()},onAddToPage:function(){this.hasOwnProperty("topic_box")&&(this.topic_box.on_page=!0,this.checkNeedLoadTopics())},onRemoveFromPage:function(){this.hasOwnProperty("topic_box")&&(this.topic_box.on_page=!1)},onHoverHeading:function(t){this.use_own_color&&this.$category_heading.find(".cmty-category-cell-left").css({color:"#fff"})},onUnhoverHeading:function(t){this.use_own_color&&this.$category_heading.find(".cmty-category-cell-left").css({color:this.model.get("secondary_color")})},onClickPopularTags:function(t){this.hasOwnProperty("itembox")||this.constructItembox(),this.itembox.$el.show(),this.topic_box_constructed&&this.topic_box.$el.hide(),this.topic_box_revealed=!1,this.setBars(this.$itembox_bar,this.$topic_bar),arguments.length>0&&t.stopPropagation()},onClickTopics:function(t){this.topic_box_constructed||this.constructTopicBox(),this.hasOwnProperty("itembox")&&this.itembox.$el.hide(),this.topic_box.$el.show(),this.topic_box.on_page=!0,this.topic_box_revealed=!0,this.checkNeedLoadTopics(),this.setBars(this.$topic_bar,this.$itembox_bar),arguments.length>0&&t.stopPropagation()},checkNeedLoadTopics:function(){this.topic_box_revealed&&0===this.topic_box.collection.length&&this.topic_box.checkMoreTopicsNeeded()},parseAllRead:function(){this.$el.toggleClass("cmty-all-read",this.model.get("all_read"))},buildCategorySearch:function(){var i=$('<input type="search" class="cmty-tag-search-input" placeholder="'+e["cat-search-placeholder-"+this.model.get("category_id")]+'"></input>');o.buildCategoryAutocomplete(i,{ajax_call:this.category_search_autocomplete,has_search_icon:!0,autocomplete_settings:{onSelect:function(e,o){i.val(""),i.autocomplete("close"),Backbone.history.navigate("/c"+o.item.category_id+"_"+t.convertToUrlFragment(o.item.label),{trigger:!0}),e.stopPropagation(),e.preventDefault()}},show_no_results_msg:!0}),i.parent().on("click touchstart",(function(t){i.focus(),t.stopPropagation(),t.preventDefault()})),this.$el.find(".cmty-category-cell-right").append(i.parent())},onChangeNumTopics:function(){var t=this,e=this.$num_topics.find(".cmty-category-cell-number");e.fadeOut(300,(function(){t.setNumTopics(),e.show()}))},setNumTopics:function(){var t=this.model.has("num_topics")?o.renderNumberWithCommas(this.model.get("num_topics")):"1,729",i=1===t?e["cat-cell-topic"]:e["cat-cell-topics"];this.$num_topics.html(this.getTemplate("#cmty-category-cell-num-topics-tpl",{num_topics:t+" "+i,url:AoPS.Community.Views.makeLinkUrl(this.url)}));var s=this.$num_topics.find("a");s.length&&(s[0].style.color=this.model.get("main_color"))},setNumPosts:function(){var t=this.model.has("num_posts")?this.model.get("num_posts"):1030401,i=1===t?e["cat-cell-post"]:e["cat-cell-posts"];this.$num_topics[0].title=t+" "+i},onChangeNumUsers:function(){var t=this,e=this.$num_users.find(".cmty-category-cell-number");e.fadeOut(300,(function(){t.setNumUsers(),e.show()}))},setNumUsers:function(){var t=this.model.has("num_users")?this.model.get("num_users"):31,i=1===t?e["cat-cell-user"]:e["cat-cell-users"];this.$num_users.html(this.getTemplate("#cmty-category-cell-num-users-tpl",{num_users:t+" "+i})),this.$num_users[0]&&(this.$num_users[0].title=e["cat-cell-num-user-title"])},setBars:function(t,e){t.addClass("active-sublink").append(this.$active_triangle),_.isUndefined(e)||e.removeClass("active-sublink")},constructItembox:function(){this.itembox=new this.items_box_constructor({model:this.model,placeholder_text:this.placeholder_text,url_router_base:this.url_router_base,url_cmty_path:this.url_cmty_path,scrollbar_arguments:{autosize_exclusions:[{min:841,max:1e5}]},push_state_attribute:this.push_state_attribute}),this.$itembox_container.append(this.itembox.$el)},constructTopicBox:function(){var t=this.model.get("master").fetchFilteredTopicList({category:this.model,category_id:this.model.get("category_id"),tag_ids:[]});this.topic_box=new this.topics_box_constructor({collection:t,main_color:this.model.get("main_color"),secondary_color:this.model.get("secondary_color"),master:this.model.get("master"),category_id:this.model.get("category_id"),suppress_initial_fetch:!(this.default_to_tags||this.fetch_topics_immediately),use_topic_category:this.forums_not_tags}),this.$itembox_container.append(this.topic_box.$el),this.topic_box_constructed=!0,this.model.get("is_forum")&&this.model.has("num_topics")&&this.model.get("num_topics")<6&&this.$el.addClass("cmty-short-forum")},applyColor:function(){var t=this.model.get("main_color"),e=this.model.get("secondary_color");this.use_own_color&&(this.$category_heading.css({"background-color":t,color:e}),this.$el.find(".cmty-category-cell-numbers").css({color:t}))},onClose:function(){this.hasOwnProperty("itembox")&&this.itembox.close(),this.hasOwnProperty("topic_box")&&this.topic_box.close(),this.hasOwnProperty("tag_filter")&&this.tag_filter.close()},launchNewTopic:function(i){var o;return AoPS.session.logged_in?this.model.getPermission("c_can_start_topic")||this.model.getPermission("c_undo_global_ban")?(o={model:this.model,master:this.model.get("master"),url_cmty_path:this.url_cmty_path},arguments.length>1&&(o.tags=arguments[1].tags),_.isNull(this.model.get("master").get("focus_tag"))||(o.tags=[this.model.get("master").get("focus_tag").item_text]),new t.NewTopic(o)):AoPS.Ui.Modal.showMessage(e[AoPS.isUserLimited()?"cat-cell-no-perm-limited-user":"cat-cell-no-perm-start-topic"],{width:"450px"}):AoPS.Ui.buildLoginConfirm(e["new-topic-not-logged-in"]),i.preventDefault(),i.stopPropagation(),!1}}),t.CategoryCellBlog=t.CategoryCell.extend({className:t.CategoryCell.prototype.className+" cmty-category-cell-blog cmty-category-cell-folder ",template_id:"#cmty-category-cell-blog-tpl",has_items:!1,default_to_tags:!1,has_numbers:!1,use_own_color:!1,initialize:function(i){var o=this.model.get("num_topics"),s=o+" ";t.CategoryCell.prototype.initialize.apply(this,[i]),this.$(".cmty-blog-cell-avatar").append('<img src="'+this.model.get("creator_avatar")+'" width="52" height="52">'),s+=1===o?e["blog-Entry"]:e["blog-Entries"],this.$(".cmty-blog-cell-entry-count").html(s)}}),t.CategoryCellMyBooks=t.CategoryCell.extend({has_topics:!1,has_numbers:!1,placeholder_text:"BOOKS WILL BE HERE",can_bookmark:!1,has_own_url:!0,own_url:"MYBOOKSURL",onClickHeading:function(){}}),t.CategoryCellMyClasses=t.CategoryCell.extend({has_topics:!1,can_bookmark:!1,has_numbers:!1,placeholder_text:"CLASSES WILL BE HERE",has_own_url:!0,own_url:"MYCLASSESURL",onClickHeading:function(){}}),t.CategoryCellFolder=t.CategoryCell.extend({className:t.CategoryCell.prototype.className+" cmty-category-cell-folder cmty-category-cell-no-numrow",has_topics:!1,placeholder_text:e["cat-cell-no-items-yet"],can_bookmark:!1,has_numbers:!1,use_own_color:!1,applyColor:function(){var t=this.model.get("main_color");this.$category_heading.css({"border-top":"5px solid "+t}),this.$el.find(".cmty-category-cell-title").css({color:t})}}),t.CategoryCellBookmarkUsers=t.CategoryCellFolder.extend({placeholder_text:e["cat-cell-no-users-bookmarked"]}),t.CategoryCellMyBookmarks=t.CategoryCellFolder.extend({has_own_url:!0,has_numbers:!1,own_url:"/my-bookmarks",onClickHeading:function(e){t.followUrlOnClick(e,"/my-bookmarks")}}),t.CategoryCellForumView=t.CategoryCell.extend({className:t.CategoryCell.prototype.className+" cmty-category-cell-folder",can_bookmark:!1,has_numbers:!1,show_description:!1,use_own_color:!1,tags_topics_in_topbar:!0,topics_title:e["cat-cell-forum-view-topics"],items_title:e["cat-cell-items-title-forum-view"],forums_not_tags:!0}),t.CategoryCellForumBookmarks=t.CategoryCellForumView.extend({placeholder_text:e["bookmark-no-forums-bookmarked"],items_title:e["cat-cell-items-title-forum-bookmark"]}),t.CategoryCellTagView=t.CategoryCell.extend({className:t.CategoryCell.prototype.className+" cmty-category-cell-view-tags cmty-category-cell-folder",can_bookmark:!1,has_numbers:!1,show_description:!1,use_own_color:!1,topics_title:e["cat-cell-tag-view-topics"],items_title:e["cat-cell-items-title-tag-view"],tags_topics_in_topbar:!0,applyColor:t.CategoryCellFolder.prototype.applyColor}),t.CategoryCellPostView=t.CategoryCell.extend({className:t.CategoryCell.prototype.className+" cmty-category-cell-folder",can_bookmark:!1,placeholder_text:e["cat-cell-no-posts-yet"],has_numbers:!1,use_own_color:!1,has_topics:!1,items_box_constructor:t.ItemboxPosts,applyColor:function(){var t=this.model.get("main_color");this.$category_heading.css({"border-top":"5px solid "+t}),this.$el.find(".cmty-category-cell-title").css({color:t})}}),t.CategoryCellTagBookmarks=t.CategoryCellTagView.extend({placeholder_text:e["bookmark-no-tags-bookmarked"],items_title:e["cat-cell-items-title-tag-bookmark"]}),t.CategoryCellTopicView=t.CategoryCell.extend({can_bookmark:!1,className:t.CategoryCell.prototype.className+" cmty-category-cell-folder",has_items:!1,use_own_color:!1,has_numbers:!1,default_to_tags:!1,fetch_topics_immediately:!1}),t.CategoryCellTopicBookmarks=t.CategoryCellTopicView.extend({placeholder_text:e["bookmark-no-topics-bookmarked"]}),t.CategoryCellMyPrivates=t.CategoryCell.extend({can_bookmark:!1,default_to_tags:!1,has_numbers:!1,topics_box_constructor:t.CategoryCellPrivatesTopics,launchNewTopic:function(o){if(this.model.getPermission("c_can_start_topic")||this.model.getPermission("c_undo_global_ban")?new t.NewPrivateConversation({category_name:"",category_id:i.private_messages_id,model:this.model,master:this.model.get("master")}):AoPS.Ui.Modal.showMessage(e[AoPS.isUserLimited()?"new-pm-no-permission-limited":"new-pm-no-permission"],{width:"450px"}),!_.isUndefined(o))return o.stopPropagation(),o.preventDefault(),!1}}),t.CategoryCellOtherForums=t.CategoryCellFolder.extend({category_search_autocomplete:"fetch_forum_autocomplete",has_search:!0,className:t.CategoryCell.prototype.className+" cmty-category-cell-no-numrow cmty-category-cell-folder",help_template:"#cmty-other-forums-help-modal-tpl"}),t.CategoryCellSpecialCollections=t.CategoryCellFolder.extend({category_search_autocomplete:"fetch_folder_collections_contents_autocomplete",has_search:!0,className:t.CategoryCell.prototype.className+" cmty-category-cell-no-numrow cmty-category-cell-folder",help_template:"#cmty-special-collections-help-modal-tpl"}),t.category_cell_category_top_new_properties={num_matches:15,default_to_tags:!0,has_small_header:!0,force_to_tags:!0,has_jump_to_top:!0,initialize:function(e){this.model.get("is_forum")&&(this.model.get("is_private")||(this.can_bookmark=!0),this.has_search_link=!0),this.model.get("special_url").length>0&&(this.url=this.model.get("special_url"),this.constructUrls=function(){}),t.CategoryCell.prototype.initialize.apply(this,[e]),"forum"!==this.model.get("category_type")&&"my_privates"!==this.model.get("category_type")||this.$category_heading.find(".cmty-category-cell-left").css({color:"#fff"}),this.model.get("has_tag_filter")&&(this.tag_filter=new t.CategoryTagFilter(e),this.$itembox_container.before(this.tag_filter.$el)),this.can_bookmark&&(this.$bookmark=this.$el.find(".cmty-category-cell-bookmark"),this.setForumBookmarkStatus(),this.listenTo(this.model,"change:is_bookmarked change:is_watched change:in_feed",this.setForumBookmarkStatus)),this.model.get("is_private")&&!this.model.get("is_archive")&&this.setArchivedButton(),this.listenTo(this.model,"reset_tag_bookmark",this.setTagBookmarkStatus)},setArchivedButton:function(){this.$category_heading.find(".cmty-category-cell-right").prepend('<span title="'+e["private-archive-title"]+'"\t\t\t\t class="cmty-category-cell-archive cmty-icon-w-text clickable"><span class="cmty-cat-cell-aops-font-icon">(</span>\t\t\t\t <span class="cmty-cat-cell-symbol-tag">'+e["private-View-Archive-btn"]+"</span></span>&nbsp;")},events:_.extend({"click .cmty-category-cell-bookmark":"onClickForumBookmark","click .cmty-category-cell-archive":"onClickArchive"},t.CategoryCell.prototype.events),onAddToPage:function(){this.model.get("has_tag_filter")&&this.tag_filter.onAddToPage(),this.has_topics&&this.model.has("master")&&this.insertFocusTag()},onRemoveFromPage:function(){this.has_topics&&this.model.has("master")&&this.removeFocusTag()},insertFocusTag:function(){var t,e,i,o,s;if(!_.isNull(this.model.get("master").get("focus_tag"))){(s=_.clone(this.model.get("master").get("focus_tag"))).item_can_remove=!0;var n=(t=this.itembox.constructItem(s)).find(".cmty-item-tag");n.css({"background-color":s.item_secondary_color,color:s.item_main_color,border:"1px solid "+s.item_main_color}).on("mouseleave",(function(t){n.css({"background-color":s.item_secondary_color,color:s.item_main_color})})),t.addClass("cmty-cat-cell-focus-shadow cmty-tablet-inline"),this.itembox.$itembox.prepend(t),i=(e=t.attr("href")).match(/t\d+f\d+/),_.isNull(i)||(o=e.split(i)[0],t.attr("href",o)),this.$focus_tag=t}},removeFocusTag:function(){this.hasOwnProperty("$focus_tag")&&this.$focus_tag.remove()},onClickArchive:function(e){t.followUrlOnClick(e,"/my-messages-archive")},onClickForumBookmark:function(i){i.preventDefault(),i.stopPropagation(),AoPS.session.logged_in?!t.in_academy&&AoPS.isUserLimited()?s.showMessage(e["bookmark-limited-user"],{width:"450px"}):this.model.get("is_bookmarked")?this.model.setBookmarkState({is_bookmarked:!1}):t.fireBookmarkModal("forum",o.formatString(e["bookmark-modal-forum"],[this.model.get("category_name")]),_.bind(this.model.setBookmarkState,this.model)):AoPS.Ui.buildLoginConfirm(e["bookmark-not-logged-in"])},setForumBookmarkStatus:t.TopicFull.prototype.setBookmarkStatus,submitNewItem:function(t){var e=this;this.model.addItem({item_id:parseInt(t.item_id),item_type:"tag",item_forum_id:this.model.get("category_id"),item_text:t.value,item_main_color:t.main_color,item_secondary_color:t.secondary_color}),setTimeout((function(){e.$input_box.autocomplete("disable"),e.$input_box.autocomplete("enable"),Backbone.history.navigate(e.url_cmty_path+"/c"+e.model.get("category_id")+"t"+t.item_id+"f"+t.item_forum_id,{trigger:!0})}),100),this.$input_box.val("")},onUnhoverHeading:function(t){this.use_own_color&&this.$category_heading.find(".cmty-category-cell-left").css({color:"#fff"})},onHoverHeading:function(t){this.use_own_color&&this.$category_heading.find(".cmty-category-cell-left").css({color:this.model.get("secondary_color")})}},t.CategoryTagFilter=AoPS.View.extend({template_id:"#cmty-category-cell-focus-tpl",has_own_url:!1,className:"cmty-tag-filter",initialize:function(e){this.focus_tag=e.focus_tag,this.model.get("special_url").length>0?this.url=this.model.get("special_url"):this.url="/c"+this.model.get("category_id")+"_"+t.convertToUrlFragment(this.model.get("category_name")),t.setRouteInfo(this,e),this.render(),this.$focus_tag_line=this.$el.find(".cmty-focus-tag-line"),this.$focus_tag_box=this.$focus_tag_line.parent(),this.listenTo(this.model.get("master"),"change:focus_tag",this.onChangeFocusTag),this.listenTo(this.model,"tag_bookmarked",this.setTagBookmarkStatus)},render:function(){this.$el.html(this.getTemplate(this.template_id,{filter_placeholder:e["cat-cell-filter-placeholder"]}))},events:{"click .cmty-focus-tag-line .bkmk-icon":"onClickTagBookmark"},constructUrls:t.CategoryCell.prototype.constructUrls,onAddToPage:function(){this.buildInputAutocomplete(),this.setTagBookmarkStatus()},onChangeFocusTag:function(){this.model.get("master").get("focus_category")===this.model&&(this.focus_tag=this.model.get("master").get("focus_tag"),this.setFocusTag())},buildInputAutocomplete:function(){var t=$('<input type="search" class="cmty-tag-search-input" placeholder="'+e["cat-cell-filter-placeholder"]+'"></input>'),i=this;this.hasOwnProperty("$input_box")?this.$input_box.parent().replaceWith(t):this.$focus_tag_box.append(t),this.$input_box=t,AoPS.Community.Views.buildTagAutocomplete({$input_box:this.$input_box,model:this.model,show_no_results_msg:!0,submitNewItem:function(t){i.submitNewItem(t)},has_search_icon:!0}),this.setFocusTag()},setTagBookmarkStatus:function(){var i;_.isNull(this.focus_tag)||this.model.get("is_private")||(this.tag_bookmark_state=this.model.get("master").fetchBookmarkStatus(this.focus_tag),(i=this.$focus_tag_line.find(".bkmk-icon")).html(t.makeBookmark(this.tag_bookmark_state)),i[0].title=this.tag_bookmark_state.is_bookmarked?e["remove-bookmarked-tag-tooltip"]:e["bookmark-tag-tooltip"])},onClickTagBookmark:function(){AoPS.session.logged_in?!t.in_academy&&AoPS.isUserLimited()?s.showMessage(e["bookmark-limited-user"],{width:"450px"}):this.tag_bookmark_state.is_bookmarked?(this.model.get("master").removeTagBookmark(_.defaults(this.tag_bookmark_state,this.focus_tag)),this.model.trigger("tag_bookmarked"),this.setTagBookmarkStatus()):t.fireBookmarkModal("tag",o.formatString(e["bookmark-modal-tag"],[this.focus_tag.item_text,this.model.get("category_name")]),_.bind((function(t){"forum"===this.model.get("category_type")&&(this.focus_tag.item_category_name=this.model.get("category_name")),this.model.get("master").addTagBookmark({item:_.defaults(t,this.focus_tag)}),this.model.trigger("tag_bookmarked")}),this)):AoPS.Ui.buildLoginConfirm(e["bookmark-not-logged-in"])},setFocusTag:function(){var e;this.$el.find(".cmty-focus-tag-line").empty(),null!=this.focus_tag?(this.tag_colors={main_color:this.focus_tag.item_main_color,secondary_color:this.focus_tag.item_secondary_color},e="<a "+this.push_state_attribute+' href="'+t.makeLinkUrl(this.url,this.url_router_base+this.url_cmty_path)+'"><div class="cmty-item-tag focused">'+this.focus_tag.item_text+' </div></a><div class="bkmk-icon clickable"></div>'):e="",this.$focus_tag_line.append($($.parseHTML(e))),this.setTagBookmarkStatus(),null!=this.focus_tag&&(this.$focus_tag_line.find(".cmty-item-tag").css({border:"1px solid "+this.tag_colors.main_color,"background-color":this.tag_colors.secondary_color,color:this.tag_colors.main_color}),this.$focus_tag_line.find(".bkmk-icon").css({color:this.tag_colors.main_color}))},submitNewItem:function(t){var e=this;this.model.addItem({item_id:parseInt(t.item_id),item_type:"tag",item_forum_id:this.model.get("category_id"),item_text:t.value,item_main_color:t.main_color,item_secondary_color:t.secondary_color}),setTimeout((function(){e.$input_box.autocomplete("disable"),e.$input_box.autocomplete("enable"),Backbone.history.navigate(e.url_cmty_path+"/c"+e.model.get("category_id")+"t"+t.item_id+"f"+t.item_forum_id,{trigger:!0})}),100),this.$input_box.val("")}}),t.category_cell_category_top_new_properties_view_forums=_.defaults({className:t.CategoryCellForumView.prototype.className+" cmty-view-folder-top cmty-category-cell-view-forums",use_own_color:!1,can_bookmark:!1},t.category_cell_category_top_new_properties),t.category_cell_category_top_new_properties_view_topics=_.defaults({has_bottom:!1,className:t.CategoryCell.prototype.className+" cmty-folder-top cmty-flat-top ",use_own_color:!1,has_help:!0,help_template:"#cmty-view_topics-help-tpl",help_template_title_setting:"cat-cell-view_topics-help-title",can_bookmark:!1,onAddToPage:function(){$("#community-all").addClass("cmty-view-topics-page")},onRemoveFromPage:function(){$("#community-all").removeClass("cmty-view-topics-page")}},t.category_cell_category_top_new_properties),t.category_cell_category_top_new_properties_view_tags=_.defaults({className:t.CategoryCell.prototype.className+" cmty-folder-top cmty-flat-top",help_template:"#cmty-view_tags-help-tpl",help_template_title_setting:"cat-cell-view_tags-help-title",has_help:!0,use_own_color:!1},t.category_cell_category_top_new_properties),t.CategoryCellCategoryTop=t.CategoryCell.extend(t.category_cell_category_top_new_properties),t.CategoryCellCategoryTopViewTags=t.CategoryCell.extend(t.category_cell_category_top_new_properties_view_tags),t.CategoryCellCategoryTopMyPrivates=t.CategoryCellMyPrivates.extend(t.category_cell_category_top_new_properties),t.CategoryCellCategoryTopViewForums=t.CategoryCell.extend(t.category_cell_category_top_new_properties_view_forums),t.CategoryCellCategoryTopViewTopics=t.CategoryCellTopicView.extend(t.category_cell_category_top_new_properties_view_topics),t.CategoryCellCategoryTopUserSearchPosts=AoPS.View.extend({template_id:"#cmty-user-search-posts-top-tpl",className:"cmty-folder-top",initialize:function(){this.$el.html(this.getTemplate(this.template_id,{category_name:this.model.get("category_name"),url:"/community/u"+this.model.get("user_id")}))}}),t.CategoryCellCategoryTopSearch=AoPS.View.extend({template_id:"#cmty-search-results-top-tpl",className:"cmty-folder-top cmty-search-results",initialize:function(){var t=this.model.get("search_settings").hasOwnProperty("search_text"),i=t?this.model.get("search_settings").search_text:"",s=t?encodeURIComponent(i):"",n=this.model.has("search_page_id"),a=n?"/community/edit-search/"+this.model.get("search_id"):"";this.$el.html(this.getTemplate(this.template_id,{category_name:this.model.get("category_name"),search_text:o.formatString(e["search-results-title-with-text"],[i]),has_search_text:t,url:"/community/q"+this.model.get("search_id"),encoded_search_text:s,can_edit:n,edit_url:a,lang_edit_search:e["search-results-edit"],lang_search_placeholder:e["main-crumb-search-placeholder"]}))},events:{"keydown input":"onKeyDownSearch","click .cmty-search-bar-icon":"onClickSearchIcon"},onClickSearchIcon:function(t){var e=$.trim(this.$("input").val());Backbone.history.navigate("/search/"+encodeURIComponent(e),{trigger:!0}),this.$("input").val("")},onKeyDownSearch:function(t){13===(t.which||t.keyCode)&&t.currentTarget.value.length>0&&(Backbone.history.navigate("/search/"+encodeURIComponent(t.currentTarget.value),{trigger:!0}),t.currentTarget.value="")}}),t.Folder=AoPS.View.extend({template_id:"#cmty-folder-top-tpl",className:"cmty-folder-top",has_header:!0,has_subheader:!1,own_url:"",has_own_url:!1,has_info:!0,initialize:function(){var i=this.model.get("category_id")>0,s="none"!==this.model.get("can_add_type")&&this.model.get("master").fetchPermission("can_create_category");this.url=this.has_own_url?this.own_url:"/c"+this.model.get("category_id")+"_"+t.convertToUrlFragment(this.model.get("category_name")),this.url_info=i?"/category-admin/"+this.model.get("category_id"):"",this.$nothing_here=$('<div class="cmty-folder-empty">'+e["folder-empty-"+this.model.get("category_type")]+"</div>"),this.$el.html(this.getTemplate(this.template_id,{can_add:s,can_add_title:s?e.Create+" new "+this.model.get("can_add_type"):"",has_header:this.has_header,has_pdf:!1,lang_pdf:e["view-pdf-tooltip"],category_id:this.model.get("category_id"),has_subheader:this.has_subheader,url:t.makeLinkUrl(this.url),category_name:this.model.get("category_name"),short_description:this.model.get("short_description"),subheader:this.model.get("long_description"),long_description:this.model.get("long_description"),has_info:this.has_info,has_jump_to_top:!0,lang_information:o.capitalizeFirstLetter(e.information)})),this.$category_heading=this.$el.find(".cmty-category-cell-heading"),this.has_header&&this.applyColor(),this.cat_box_holder=this.$el.find(".cmty-folder-grid-container"),this.cat_boxes=[],this.start_item_index=0,this.$loader=AoPS.Page.buildLoader(),this.constructItems(),this.onFinishConstructingItems(),this.start_item_index<8&&!this.model.get("all_subcategories_loaded")&&this.fetchMoreCategories(),this.setScrollListener(),0===this.model.get("items").length&&this.$el.append(this.$nothing_here),this.listenTo(this.model,"item_removed",this.onRemoveItem),"bookmark_forums"===this.model.get("category_type")&&this.listenTo(this.model,"item_added",this.onAddItem)},events:{"click .cmty-cat-cell-cat-info":"onClickInfo","click .cmty-add-new-category":"onClickAddNew","click .cmty-cat-cell-jump-top":"onClickJumpTop","click .cmty-small-category-heading":"onClickHeading"},onClickJumpTop:function(t){window.scrollTo(0,0),t.stopPropagation(),t.preventDefault()},onClickHeading:function(t){$(window).width()<=i.phone_mode_max_width&&this.onClickJumpTop(t)},onClickAddNew:t.CategoryCell.prototype.onClickAddNew,setScrollListener:function(){var t=this;this.model.get("all_subcategories_loaded")||$(window).on("scroll."+this.model.cid+" touchmove."+this.model.cid,(function(e){window.innerHeight+window.pageYOffset+10>=document.body.offsetHeight&&(t.model.get("loading_subcategories")||t.model.get("all_subcategories_loaded")||t.fetchMoreCategories())}))},stopScrollListener:function(){$(window).off("scroll."+this.model.cid+" touchmove."+this.model.cid)},onRemoveItem:function(t){var e,i=null,o=this.cat_boxes.length;if(t.hasOwnProperty("category")){for(e=0;e<o;e++)if(this.cat_boxes[e].model===t.category){i=this.cat_boxes[e];break}_.isNull(i)||(this.cat_boxes=_.without(this.cat_boxes,i),i.close(),this.start_item_index--),0===this.cat_boxes.length&&this.$el.append(this.$nothing_here)}},onAddItem:function(t){var e;e=this.model.get("master").fetchCategory(t.item_id),_.isUndefined(e)||this.addCategoryBox(e)},constructItems:function(){var t,e,i,o=this.model.get("items"),s=o.length;for(s>0&&this.$nothing_here.detach(),t=this.start_item_index;t<s&&(e=o[t]).hasOwnProperty("category");t++)i=e.category,this.addCategoryBox(i)},onFinishConstructingItems:function(){},addCategoryBox:function(e){var i;this.start_item_index++,e.getPermission("c_can_read")&&(i=new(t.fetchCategoryCellConstructor(e.get("category_type")))({model:e}),this.cat_boxes.push(i),this.cat_box_holder.append(i.$el))},fetchMoreCategories:function(){var t=this;this.cat_box_holder.append(this.$loader),this.listenToOnce(this.model,"subcategories_loaded",(function(){var e=$(window).scrollTop();t.$loader.detach(),t.constructItems(),window.scrollTo(0,e)})),this.model.fetchMoreCategoryItems({start_idx:this.start_item_index})},onClose:function(){_.each(this.cat_boxes,(function(t){t.close()}))},onAddToPage:function(){_.each(this.cat_boxes,(function(t){"function"==typeof t.onAddToPage&&t.onAddToPage()})),this.cat_boxes.length<i.max_forums_user_update&&!_.isUndefined(_.findWhere(this.model.get("items"),{item_type:"forum"}))&&this.model.startUsersMonitoring(),this.setScrollListener()},onClickInfo:function(e){t.followUrlOnClick(e,this.url_info)},onRemoveFromPage:function(){this.model.stopUsersMonitoring(),this.stopScrollListener(),_.each(this.cat_boxes,(function(t){"function"==typeof t.onRemoveFromPage&&t.onRemoveFromPage()}))},applyColor:function(){var t=this.model.get("main_color");this.$el.find(".cmty-category-cell-heading").css({color:t}),this.$el.find(".cmty-category-cell-title").css({color:t})}}),t.HeadlessFolder=t.Folder.extend({has_header:!1}),t.FolderMyBookmarks=t.Folder.extend({has_own_url:!0,has_subheader:!0,own_url:"/my-bookmarks",has_info:!1}),t.FolderMyForums=t.Folder.extend({has_own_url:!0,has_subheader:!0,own_url:"/my-forums",onClickInfo:function(i){0!==this.model.get("category_id")?t.Folder.prototype.onClickInfo.apply(this,[i]):AoPS.Ui.Modal.showAlert(e["user-profile-no-my-forums"],{width:"450px"})}}),t.FolderMyCollections=t.Folder.extend({has_own_url:!0,has_subheader:!0,own_url:"/my-collections",onClickInfo:function(i){0!==this.model.get("category_id")?t.Folder.prototype.onClickInfo.apply(this,[i]):AoPS.Ui.Modal.showAlert(e["user-profile-no-my-collections"],{width:"450px"})}}),t.FolderMyBlogs=t.Folder.extend({has_own_url:!0,has_subheader:!0,own_url:"/my-blogs",onClickInfo:function(i){0!==this.model.get("category_id")?t.Folder.prototype.onClickInfo.apply(this,[i]):AoPS.Ui.Modal.showAlert(e["user-profile-no-my-blogs"],{width:"450px"})}}),t.MyAoPSTop=AoPS.View.extend({template_id:"#cmty-my-aops-top-tpl",id:"cmty-my-aops-top",initialize:function(){var e=this;this.render(),_.each([{class_stub:"profile",url:"/my-aops"},{class_stub:"bookmarks",url:"/my-bookmarks"},{class_stub:"messages",url:"/my-messages"},{class_stub:"my-forums",url:"/my-forums"},{class_stub:"my-collections",url:"/my-collections"},{class_stub:"my-blogs",url:"/my-blogs"}],(function(i){e.$(".cmty-my-aops-"+i.class_stub+"-btn").on("click",(function(e){t.followUrlOnClick(e,i.url)}))})),this.listenTo(this.model.get("current_user"),"change:location",this.onChangeLocation)},events:{},render:function(){var t,i=this.model.get("current_user");this.$el.html(this.getTemplate(this.template_id,{has_books:i.get("has_ebooks"),has_classes:i.get("has_classes"),location:i.get("location"),avatar:this.model.get("my_avatar"),username:AoPS.session.username,email:i.get("email"),lang_Edit_Settings:e["my-aops-Community-Settings"],lang_Edit_Profile:e["my-aops-Edit-Profile"],lang_Profile:e.Profile,lang_My_AoPS:e.MyAoPS,lang_Bookmarks:e.Bookmarks,lang_Messages:e.Messages,lang_My_Forums:e["my-aops-MyForums"],lang_My_Collections:e["my-aops-MyCollections"],lang_My_Blogs:e["my-aops-MyBlogs"],lang_My_Books:e["my-aops-MyBooks"],lang_My_Classes:e["my-aops-MyClasses"],lang_phone_PM:e["my-aops-phone-PM"],lang_phone_Bkmk:e["my-aops-phone-Bkmk"],lang_phone_Fora:e["my-aops-phone-Fora"],lang_phone_Coll:e["my-aops-phone-Coll"],lang_phone_Blogs:e["my-aops-phone-Blogs"]})),this.$messages_btn=this.$(".cmty-my-aops-messages-btn"),(t=this.model.fetchCategory(1))&&(this.private_messages_topics=t.get("active_topics"),this.listenTo(this.private_messages_topics,"change:is_read add remove",this.markMessagesReadStatus),this.markMessagesReadStatus())},onChangeLocation:function(){this.$(".cmty-my-aops-top-data-left > .cmty-my-aops-data-middle").text(this.model.get("current_user").get("location"))},markMessagesReadStatus:function(){this.$messages_btn.toggleClass("cmty-messages-btn-unread",!_.isUndefined(this.private_messages_topics.findWhere({is_read:!1})))}}),t.AoPSCollectionTop=AoPS.View.extend({template_id:"#cmty-header-box-logged-in-tpl",className:"header-box community-background-color",initialize:function(){this.$el.append(this.getTemplate(this.template_id,{username:AoPS.session.username,is_logged_in:AoPS.session.logged_in,avatar:this.model.get("my_avatar"),user_id:AoPS.session.user_id,lang_Community:e.Community,lang_Welcome:e.Welcome,lang_MyAoPS:e.MyAoPS,lang_Bookmarks:e.Bookmarks,lang_Conversations:e.Messages,lang_search_placeholder:e["main-crumb-search-placeholder"],lang_advanced_search:e["main-crumb-advanced-search"]}))},events:{"keydown input":"onKeyDownSearch","click .cmty-search-bar-icon":"onClickSearchIcon"},onClickSearchIcon:t.CategoryCellCategoryTopSearch.prototype.onClickSearchIcon,onKeyDownSearch:t.CategoryCellCategoryTopSearch.prototype.onKeyDownSearch}),t.LimitedUserMessage=AoPS.View.extend({initialize:function(){this.$el.html(this.getTemplate("#cmty-limited-user-msg-tpl",{username:AoPS.session.username}))}}),t.Announcement=AoPS.View.extend({className:"cmty-home-announce",initialize:function(t){this.$el.html(this.getTemplate("#cmty-announcement-tpl",{content:t.content}))}}),t.AoPSMasterCollection=t.HeadlessFolder.extend({has_extra_box:!0,on_page:!1,events:_.extend({"click .cmty-whois-user-toggle":"onClickUserEllipsis"},t.Folder.prototype.events),onAddToPage:function(){t.Folder.prototype.onAddToPage.apply(this),this.reset_whois&&this.fillWhoIsOnline(),this.on_page=!0},onRemoveFromPage:function(){t.Folder.prototype.onRemoveFromPage.apply(this),this.on_page=!1},constructItems:function(){var i,o,s,n,a=this.model.get("items"),r=AoPS.hasOwnProperty("preload_topics"),l=a.length,c=this;for(this.$extra_box=$('<div class="cmty-master-collection-extra-fora"></div>'),this.$extra_box.append('<div class="cmty-master-heading">'+e["master-other-forums"]+'<div class="cmty-help cmty-no-phone">?</div></div>'),this.$el.find(".cmty-folder-grid").append(this.$extra_box),o=this.start_item_index;o<l;o++)(s=a[o]).hasOwnProperty("category")&&(this.start_item_index++,(n=s.category).getPermission("c_can_read")&&(9===n.get("category_id")?(i=new t.CategoryCellOtherForums({model:n}),c.$extra_box.append(i.$el)):12===n.get("category_id")?(i=new t.CategoryCellSpecialCollections({model:n}),c.$extra_box.append(i.$el)):(i=new(t.fetchCategoryCellConstructor(n.get("category_type")))({model:n,default_to_topics:r&&11!==n.get("category_id")&&13!==n.get("category_id")}),11===n.get("category_id")||13===n.get("category_id")?c.$extra_box.append(i.$el):c.cat_box_holder.append(i.$el)),c.cat_boxes.push(i)));this.$ad_banner=$('<div class="cmty-ad-banner"></div>'),this.$ad_banner.append('<a href="/school"><img src="/assets/images/internalads/horizontal-banner.gif" class="ready-for-next"></img></a>'),this.$el.find(".cmty-folder-grid").append(this.$ad_banner),this.$extra_box.find(".cmty-help").on("click",(function(){c.onClickExtraHelp()})),this.extra_help=this.getTemplate("#cmty-toplevel-extras-help-modal-tpl",{can_create_forums:this.model.get("master").fetchPermission("can_create_category")})},onFinishConstructingItems:function(){this.model.get("master").has("whois_data")&&(this.buildWhoIs(),AoPS.session.user_id>1&&this.listenTo(this.model.get("master").get("current_user"),"change:hidden",this.onChangeWhoisData))},buildWhoIs:function(){this.$whois_online=$('<div class="cmty-whois"></div>'),this.fillWhoIsOnline(),this.$el.find(".cmty-folder-grid").append(this.$whois_online),this.listenTo(this.model.get("master"),"change:whois_data",this.onChangeWhoisData),this.constructExtraNote()},constructExtraNote:function(){},onChangeWhoisData:function(){this.on_page?this.fillWhoIsOnline():this.reset_whois=!0},buildUser:function(t){var e="";return t.c%2==1&&(e="cmty-user-admin"),t.c>1&&(e+=" cmty-hidden-user"),e.length>0?'<a data-cmty class="'+e+'" href="/community/user/'+t.b+'">'+t.a+"</a>":'<a data-cmty href="/community/user/'+t.b+'">'+t.a+"</a>"},fillWhoIsOnline:function(){var t,i,s,n,a=this.model.get("master").get("whois_data"),r=a.user_data.shown_users.length,l=!1,c=[];for(AoPS.session.logged_in&&(!this.model.get("master").get("current_user").get("hidden")||AoPS.session.a||AoPS.session.n)&&c.push(this.buildUser({a:AoPS.session.username,b:AoPS.session.user_id,c:(AoPS.session.a||AoPS.session.n?1:0)+(this.model.get("master").get("current_user").get("hidden")?2:0)})),i=0;i<r;i++)s=a.user_data.shown_users[i],AoPS.session.user_id!==s.b?(n=this.buildUser(s),c.push(n)):AoPS.session.logged_in&&(l=!0);AoPS.session.logged_in&&!l&&(a.user_data.num_total=parseInt(a.user_data.num_total)+1,a.user_data.num_registered=parseInt(a.user_data.num_registered)+1),this.$whois_online.html(this.getTemplate("#cmty-whois-content-tpl",{whois_heading:e["master-whois-title"],whois_users:e["master-registered-online"],memberlist_link:e["master-whois-memberlist-link"],FAQ_link:e["master-whois-FAQ-link"],whois_top_data:o.formatString(e["master-whois-dataline"],[o.renderNumberWithCommas(a.user_data.num_total),o.renderNumberWithCommas(a.user_data.num_registered),o.renderNumberWithCommas(a.user_data.num_hidden)]),stats_heading:e["master-statistics-title"],stats_data:o.formatString(e["master-statistics-data"],[o.renderNumberWithCommas(a.num_posts),o.renderNumberWithCommas(a.num_topics),o.renderNumberWithCommas(a.num_users)])})),t=this.$whois_online.find(".cmty-whois-users"),this.$hidden_users=t.find(".cmty-whois-hidden-users"),t.append(c.join(", ")),this.$hidden_users.append([].join(", ")),t.append(this.$hidden_users),this.reset_whois=!1},onClickUserEllipsis:function(t){this.$whois_online.find("a.cmty-whois-user-toggle").hide(),this.$hidden_users.show()},onClickExtraHelp:function(t){s.showMessage(this.extra_help,{title:e["master-collections-modal-title"],width:"450px",scrollable:!0})},attachCategories:function(){var e,i=this;this.$extra_box=$('<div class="cmty-master-collection-extra-fora"></div>'),this.$extra_box.append("<br>"),this.$el.find(".cmty-folder-grid").append(this.$extra_box),_.each(this.model.get("items"),(function(o){var s;o.hasOwnProperty("category")&&(s=o.category).getPermission("c_can_read")&&(e=new(t.fetchCategoryCellConstructor(s.get("category_type")))({model:s}),s.get("category_id")<=8?i.cat_box_holder.append(e.$el):i.$extra_box.append(e.$el),i.cat_boxes.push(e))}))}}),t.AoPSPortal=t.AoPSMasterCollection.extend({has_header:!0,has_info:!1,constructItems:function(){var i,o,s,n,a=this.model.get("items"),r=AoPS.hasOwnProperty("preload_topics"),l=a.length,c=this;for(this.$featured_content=$('<div class="cmty-master-collection-extra-fora cmty-portal-featured"></div>'),this.$featured_content.append('<div class="cmty-master-heading">'+e["master-featured-content"]+'<div class="cmty-help">?</div></div>'),this.$el.find(".cmty-folder-grid").append(this.$featured_content),this.$extra_box=$('<div class="cmty-master-collection-extra-fora"></div>'),this.$extra_box.append('<div class="cmty-master-heading">'+e["portal-extra-content"]+'<div class="cmty-help">?</div></div>'),this.$el.find(".cmty-folder-grid").append(this.$extra_box),o=this.start_item_index;o<l;o++)(s=a[o]).hasOwnProperty("category")&&(this.start_item_index++,(n=s.category).getPermission("c_can_read")&&(9===n.get("category_id")?(i=new t.CategoryCellOtherForums({model:n}),c.$extra_box.append(i.$el)):12===n.get("category_id")?(i=new t.CategoryCellSpecialCollections({model:n}),c.$extra_box.append(i.$el)):i=new(t.fetchCategoryCellConstructor(n.get("category_type")))({model:n,default_to_topics:r&&(6===n.get("category_id")||7===n.get("category_id"))}),90===n.get("category_id")||91===n.get("category_id")?this.$featured_content.append(i.$el):6===n.get("category_id")||7===n.get("category_id")?c.cat_box_holder.append(i.$el):this.$extra_box.append(i.$el),c.cat_boxes.push(i)));this.$featured_content.find(".cmty-help").on("click",(function(){c.onClickFeaturedHelp()})),this.featured_content_help=this.getTemplate("#cmty-featured-content-help-tpl"),this.$extra_box.find(".cmty-help").on("click",(function(){c.onClickExtraHelp()})),this.extra_help=this.getTemplate("#cmty-portal-special-views-help-tpl")},onClickFeaturedHelp:function(){s.showMessage(this.featured_content_help,{title:e["portal-featured-help-title"],width:"450px"})},onClickExtraHelp:function(){s.showMessage(this.extra_help,{title:e["portal-extra-help-title"],width:"450px"})},constructExtraNote:function(){this.$el.append('<div class="cmty-portal-extra">'+e["portal-extra-note"]+(AoPS.session.logged_in?e["portal-extra-logged-in"]:"")+"</div>")}}),t.ViewPosts=AoPS.View.extend({template_id:"#cmty-folder-top-tpl",className:"cmty-folder-top",initialize:function(){var i=this,s=this.model.get("short_description").length>0;this.url=this.has_own_url?this.own_url:"/c"+this.model.get("category_id")+"_"+t.convertToUrlFragment(this.model.get("category_name")),this.has_label_column=this.hasLabel(),this.url_info="/category-admin/"+this.model.get("category_id"),this.$el.html(this.getTemplate(this.template_id,{has_header:!0,category_name:this.model.get("category_name"),can_add:!1,category_id:this.model.get("category_id"),has_info:!0,has_pdf:!0,lang_pdf:e["view-pdf-tooltip"],has_subheader:s,subheader:this.model.get("short_description"),url:t.makeLinkUrl(this.url),lang_information:o.capitalizeFirstLetter(e.information)})),this.item_views=[],this.$posts_box=this.$(".cmty-folder-grid-container"),_.each(this.model.get("items"),(function(t){i.addItem(t)})),0===this.model.get("items").length&&this.$el.append('<div class="cmty-folder-empty">'+e["folder-empty-view_posts"]+"</div>"),this.applyColor()},events:{"click .cmty-cat-cell-cat-info":"onClickInfo"},applyColor:function(){var t=this.model.get("main_color");console.log(t),this.$el.find(".cmty-category-cell-heading").css({color:t}),this.$el.find(".cmty-category-cell-title").css({color:t})},onClickInfo:t.Folder.prototype.onClickInfo,addItem:function(t){var e=new AoPS.Community.Views.ViewPostsItem({item:t,model:this.model,has_label_column:this.has_label_column});this.item_views.push(e),this.$posts_box.append(e.$el)},hasLabel:function(){var t=_.find(this.model.get("items"),(function(t){return"post"===t.item_type&&t.item_text.length>0}));return!_.isUndefined(t)},onClose:function(){_.each(this.item_views,(function(t){t.close()}))}}),t.ViewPostsItem=AoPS.View.extend({template_id:"#cmty-view-posts-item-tpl",hidden_template_id:"#cmty-view-posts-item-hidden-tpl",className:"cmty-view-posts-item",initialize:function(t){var i=t.item,o="post_hidden"===i.item_type,s=o?this.hidden_template_id:this.template_id,n="view_posts_text"!==i.post_data.post_type,a=o&&t.has_label_column||i.item_text.length>0;o&&0===i.item_text.length&&(i.item_text=e["view-posts-click-hidden"]),this.url=n?"/c"+i.post_data.category_id+"h"+i.post_data.topic_id+"p"+i.item_id:"",this.$el.html(this.getTemplate(s,{has_label:a,label:i.item_text,has_poster:n,poster_avatar:i.post_data.poster_avatar,poster_username:i.post_data.username,post:i.post_data.post_rendered,view_topic_text:e["view-posts-view-topic"],url:this.url})),a&&!o&&this.$el.addClass("cmty-view-post-item-w-label"),o&&(this.$hidden_content=this.$(".cmty-post-item-hidden-content"),this.$(".cmty-hide-heading").remove(),this.$(".cmty-hide-content").css({display:"inline-block"}).removeClass("cmty-hide-content")),a?n?this.$el.addClass("cmty-vp-both"):this.$el.addClass("cmty-vp-left"):n&&this.$el.addClass("cmty-vp-right")},events:{"click .cmty-post-item-hidden-bar":"onClickHiddenBar","click .cmty-view-post-poster":"onClickPost"},onClickHiddenBar:function(){this.$el.toggleClass("cmty-view-posts-item-reveal")},onClickPost:function(e){this.url.length>0&&t.followUrlOnClick(e,this.url)}}),t.BasicCategoryTitleBar=AoPS.View.extend({template_id:"#cmty-category-basic-title-tpl",className:"cmty-category-cell",initialize:function(){var e=this.model.get("main_color");this.url=this.has_own_url?this.own_url:"/c"+this.model.get("category_id")+"_"+t.convertToUrlFragment(this.model.get("category_name")),this.$el.html(this.getTemplate(this.template_id,{category_name:this.model.get("category_name"),short_description:this.model.get("short_description"),url:AoPS.Community.Views.makeLinkUrl(this.url)})),this.$category_heading=this.$el.find(".cmty-category-cell-heading"),this.$category_heading.css({"background-color":e,color:"#fff"})},events:{"mouseenter .cmty-full-cell-link":"onHoverHeading","mouseleave .cmty-full-cell-link":"onUnhoverHeading","click .cmty-category-cell-heading":"onClickHeading"},onClickHeading:t.Folder.prototype.onClickHeading,onHoverHeading:t.category_cell_category_top_new_properties.onHoverHeading,onUnhoverHeading:t.category_cell_category_top_new_properties.onUnhoverHeading}),t.PostingEnviron=AoPS.View.extend({template_id:"#cmty-posting-frame-tpl",className:"cmty-posting-environ",has_bbcode_buttons:!0,is_new_pm:!1,has_email_subscribe:!0,has_add_to_feed:!0,sending_blocker:e["new-topic-send-blocker"],initialize:function(t){var e=this;this.settings=t,this.is_bbcode_enabled=!0,this.settings.hasOwnProperty("has_add_to_feed")&&(this.has_add_to_feed=this.settings.has_add_to_feed),this.settings.hasOwnProperty("has_email_subscribe")&&(this.has_email_subscribe=this.settings.has_email_subscribe),_.extend(this,{submenus:{},is_building_subwindow:!1,is_previewing:!1,is_preview_processing:!1,extra_options:{}}),this.has_poll=!1,this.attachments=[],this.render(),this.allow_latex_errors=!1,this.$posting_buttons=this.$el.find(".cmty-bbcode-buttons"),this.$post_box=this.$el.find(".cmty-post-textarea"),this.$title_box=this.$el.find(".cmty-subject-input"),this.$preview_box=this.$el.find(".cmty-post-preview"),this.$preview_text=this.$el.find(".cmty-post-preview-text"),this.$preview_button=this.$el.find(".cmty-preview-button"),this.$submit_button=this.$el.find(".cmty-submit-button"),this.$el.find(".cmty-post-preview").append(AoPS.Community.Views.buildCommunityScrollbar(this.$preview_text)),this.$loader=AoPS.Page.buildLoader(),this.has_bbcode_buttons&&(this.constructBbCodeButtons(),this.styleAttachmentsButton()),this.$active_submenu_button=null,this.$el.on("keydown",(function(t){13===(t.which||t.keyCode)&&(t.ctrlKey||t.metaKey)&&e.submitPost()})),this.settings.hasOwnProperty("preset_extra_options")&&_.each(_.keys(this.settings.preset_extra_options),(function(t){(e.has_email_subscribe||"notify_email"!==t)&&(e.has_add_to_feed||"bookmark_feed"!==t)&&(e.extra_options[t]=e.settings.preset_extra_options[t])})),this.setPreviewButton(),"string"==typeof t.content&&t.content.length>0&&this.addContent(t.content)},isLatexError:function(t){return"E_LATEX_ERROR"===t||"E_ASY_ERROR"===t},throwLatexErrorMessage:function(t){var i=this;s.showConfirm(o.formatString(e["error-latex-posting-confirm"],["E_LATEX_ERROR"===t?"LaTeX":"Asymptote"]),(function(t){t?(i.allow_latex_errors=!0,s.closeTopModal(),i.submitPost()):(s.closeTopModal(),s.closeTopModal(),i.$post_box.focus())}),{confirm_button_cancel:e["error-latex-i-will-fix"],confirm_button_ok:e["error-latex-post-anyway"],width:"450px",closeX:!1,force_response:!0,close_on_button_click:!1})},constructBbCodeButtons:function(){var t=this,i=[{button_class:"cmty-bbcode-other",onClick:function(e){t.showSubMenu(e,"extra_options")},is_bbcode:!1},{button_class:"cmty-bbcode-bold",title:e["bbcode-title-bold"],stub:"b"},{button_class:"cmty-bbcode-underline",stub:"u",title:e["bbcode-title-underline"]},{button_class:"cmty-bbcode-italic",stub:"i",title:e["bbcode-title-italic"]},{button_class:"cmty-bbcode-text-size",stub:"size",title:e["bbcode-title-text-size"],onClick:function(e){t.showSubMenu(e,"font_size")}},{button_class:"cmty-bbcode-text-color",stub:"color",title:e["bbcode-title-text-color"],onClick:function(e){t.showSubMenu(e,"font_color")}},{button_class:"cmty-bbcode-quote",title:e["bbcode-title-quote"],stub:"quote"},{button_class:"cmty-bbcode-hide",title:e["bbcode-title-hide"],stub:"hide"},{button_class:"cmty-bbcode-code",title:e["bbcode-title-code"],stub:"code"},{button_class:"cmty-bbcode-smiley",title:e["bbcode-title-smiley"],onClick:function(e){t.showSubMenu(e,"smiley")}},{has_permission:this.settings.master.fetchPermission("can_post_images"),button_class:"cmty-bbcode-img",title:e["bbcode-title-img"],stub:"img"},{button_class:"cmty-bbcode-url",title:e["bbcode-title-url"],stub:"url"},{has_permission:this.settings.master.fetchPermission("can_attach_files"),button_class:"cmty-bbcode-attachment",title:e["bbcode-title-attachment"],is_bbcode:!1,onClick:function(){t.openAttachmentPanel()}},{button_class:"cmty-bbcode-poll",title:e["bbcode-title-poll"],onClick:function(){t.togglePoll()},is_bbcode:!1}];_.each(i,(function(e){var i;e.hasOwnProperty("has_permission")&&!e.has_permission||(("boolean"!=typeof e.is_bbcode||e.is_bbcode)&&(e.button_class+=" cmty-is-bbcode"),(i=$("<div/>",{class:e.button_class+" clickable cmty-bbcode-btn",title:e.hasOwnProperty("title")?e.title:""})).data("button_settings",e),i.on("click",(function(o){("boolean"==typeof e.is_bbcode&&!e.is_bbcode||t.is_bbcode_enabled)&&(e.hasOwnProperty("onClick")?e.onClick(i):e.hasOwnProperty("stub")&&t.applyBbCode(e))})),t.$posting_buttons.append(i))}))},events:{"click .cmty-posting-preview-bar":"previewPost","click .cmty-submit-button":"submitPost","keyup .cmty-post-textarea":"onPostKeypress","click .cmty-cancel-button,.cmty-cancel-posting-x":"onClickCancel","click .cmty-refresh-preview":"generatePreview",click:"onAnyClick","keydown .cmty-subject-input":"onSubjectKeypress",'change [name="cmty-post-extra-disable-bbcode"]':"onClickDisableBbCode","click .cmty-poll-cancel-btn":"onClickCancelPoll","click .cmty-preview-bar-attachments":"onClickPreviewBarAttachments"},onClickDisableBbCode:function(t){this.$el.toggleClass("cmty-bbcode-disabled",t.currentTarget.checked),this.is_bbcode_enabled=!t.currentTarget.checked},onAnyClick:function(){this.hasOwnProperty("$submenu")&&!this.is_building_subwindow&&(this.$submenu.detach(),this.$active_submenu_button=null),this.is_building_subwindow=!1},onSubjectKeypress:function(){},onPostKeypress:function(){},setPreviewButton:function(){this.$preview_button.toggle(this.$post_box.val().length>8)},onClickClosePreview:function(){this.settings.hasOwnProperty("onClosePreview")&&this.settings.onClosePreview(),this.setHeight()},onClickPreviewBarAttachments:function(t){t.stopPropagation(),t.preventDefault(),this.openAttachmentPanel()},openAttachmentPanel:function(){this.hasOwnProperty("attachments_view")||(this.attachments_view=new t.PostingAttachments({model:this.settings.master,parent_view:this})),this.attachments_view.show()},processAttachments:function(t){var e=t.dropzone,i=t.existing_attachments,o=this;this.attachments=[],_.each(i,(function(t){o.attachments.push({url:t.url,existing:1,name:t.name})})),_.each(e.files,(function(t){o.attachments.push({tmp_name:t.tmp_name,existing:0,name:t.name})})),this.styleAttachmentsButton()},styleAttachmentsButton:function(){var t,i=this.$(".cmty-bbcode-attachment");0!=i.length&&(0==this.attachments.length?(t=e["bbcode-title-attachment"],this.$el.removeClass("cmty-posting-with-attachments")):(t=e["bbcode-title-has-attachments"],this.$el.addClass("cmty-posting-with-attachments"),_.each(this.attachments,(function(e){t+="\n "+e.name}))),i[0].title=t)},setHeight:function(){},applyBbCode:function(t){var e,i,o;i=this.$post_box.scrollTop(),e="["+t.stub,t.hasOwnProperty("secondary")&&(e+="="+t.secondary),e+="]",o="[/"+t.stub+"]",this.wrapTextareaSelection(e,o),this.$post_box.scrollTop(i)},showSubMenu:function(t,e){var i=this.$post_box[0].selectionStart,o=this.$post_box[0].selectionEnd;this.is_building_subwindow=!1,this.$post_box[0].setSelectionRange(i,o),t!==this.$active_submenu_button?(this.onAnyClick(),this.is_building_subwindow=!0,this.submenus.hasOwnProperty(e)||(this.submenus[e]=this.createSubMenu(t,e)),this.$posting_buttons.append(this.submenus[e]),this.$submenu=this.submenus[e],this.$active_submenu_button=t):this.onAnyClick()},addContent:function(t){this.wrapTextareaSelection(t,"")},setTitle:function(t){this.$title_box.length&&this.$title_box.val(t)},createSubMenu:function(o,s){var n,a,r=$('<div class="cmty-posting-submenu"></div>'),l=o.position(),c=this,d=!1;switch(s){case"font_color":r.addClass("cmty-posting-submenu-font-color"),_.each(i.bbCode.font_colors,(function(t){var e;e=$('<div class="cmty-posting-font-color-swatch"></div>').css({"background-color":t}).on("click",(function(){c.applyBbCode(_.extend(o.data("button_settings"),{secondary:t}))})),r.append(e)}));break;case"smiley":r.addClass("cmty-posting-submenu-smileys"),a=$('<div class="cmty-posting-smiley-holder"></div>'),_.each(i.bbCode.smileys,(function(t){var e;(e=$('<img src="/assets/images/smilies/'+t[1]+'" alt="'+t[0]+'" title="'+t[0]+'" class="bbcode_smiley">')).on("click",(function(){c.replaceTextareaSelection(" "+t[0]+" ")})),a.append(e)})),r.append(AoPS.Community.Views.buildCommunityScrollbar(a));break;case"font_size":r.addClass("cmty-posting-submenu-sizes"),_.each(i.bbCode.font_sizes,(function(t){var e=$('<div class="cmty-posting-font-size" style="font-size:'+t.size+'%">'+t.text+"</div>").on("click",(function(){c.applyBbCode(_.extend(o.data("button_settings"),{secondary:t.size}))}));r.append(e)}));break;case"extra_options":r.addClass("cmty-posting-submenu-extras"),n=i.bbCode.extra_options,this.canSetAnnounce()&&(n=n.concat([{property:"is_local_announcement",text:e["post-environ-extra-announce"],class_id:"cmty-post-extra-local-announce"}]),d=!0),this.canSetGlobalAnnounce()&&(n=n.concat([{property:"is_global_announcement",text:e["post-environ-global-announce"],class_id:"cmty-post-extra-global-announce"}]),d=!0),_.each(n,(function(t){var e;if((c.has_email_subscribe||"notify_email"!==t.property)&&(c.has_add_to_feed||"bookmark_feed"!==t.property)){e=c.extra_options.hasOwnProperty(t.property)&&c.extra_options[t.property];var i=$('<label><input name="'+t.class_id+'" type="checkbox"'+(e?" checked":"")+"> "+t.text+"</label><br>").on("click",(function(e){c.is_building_subwindow=!0,c.extra_options[t.property]=e.target.checked}));r.append(i)}})),d&&(this.$announce_through=$('<div class="cmty-posting-announce-extra">'+e["post-environ-announce-through"]+'<br><input type="text" class="cmty-posting-announce-through" placeholder="yyyy-mm-dd"></div>'),r.append(c.$announce_through),this.$announce_through.on("click",(function(t){t.stopPropagation()})),t.makeAnnounceDateInput(c.$announce_through.find("input")))}return r.css({left:l.left+parseInt(o.css("margin-left")),top:l.top+o.height()}),r},togglePoll:function(){this.has_poll?this.onClickCancelPoll():this.showPoll()},showPoll:function(){this.hasOwnProperty("$poll")||this.createPoll(),this.$el.addClass("cmty-posting-with-poll"),this.has_poll=!0,this.setHeight(),this.$poll_question.focus()},hidePoll:function(){this.$el.removeClass("cmty-posting-with-poll"),this.has_poll=!1,this.setHeight()},createPoll:function(){var t;t={lang_poll_question:e["poll-question"],lang_poll_options:e["poll-options"],lang_poll_options_desc:e["poll-options-desc"],lang_options_per:e["poll-options-per"],lang_poll_length:e["poll-length"],lang_len_unlimited:e["poll-unlimited"],lang_len_1_day:e["poll-len-1-day"],lang_len_2_days:e["poll-len-2-days"],lang_len_3_days:e["poll-len-3-days"],lang_len_1_week:e["poll-len-1-week"],lang_len_2_weeks:e["poll-len-2-weeks"],lang_len_1_month:e["poll-len-1-month"],lang_revoting:e["poll-revoting"],No:e.No,Yes:e.Yes,lang_cancel_poll:e["poll-cancel"]},this.$poll=$(this.getTemplate("#cmty-poll-build-tpl",t)),this.$poll_question=this.$poll.find("input.cmty-poll-question"),this.$poll_inputs=this.$poll.find("textarea.cmty-poll-inputs"),this.$el.find(".cmty-posting-box-container").before(this.$poll),this.has_poll_built=!0},onClickCancelPoll:function(){var t=this;this.$poll_question.val().length>0||this.$poll_inputs.val().length>0?AoPS.Ui.Modal.showConfirm(e["poll-cancel-confirm"],(function(e){e&&t.hidePoll()}),{title:e["poll-cancel-title"],confirm_button_ok:e["poll-cancel"],confirm_button_cancel:e["poll-cancel-no"],width:"450px"}):this.hidePoll()},canSetAnnounce:function(){return!1},canSetGlobalAnnounce:function(){return!1},wrapTextareaSelection:function(t,e){var i,o=this.$post_box.val(),s=this.$post_box[0].selectionStart,n=this.$post_box[0].selectionEnd;i=o.slice(0,s)+t+o.slice(s,n)+e+o.slice(n),this.$post_box.val(i),this.$post_box.focus(),this.$post_box[0].setSelectionRange(s+t.length,n+t.length)},replaceTextareaSelection:function(t){var e,i=this.$post_box.val(),o=this.$post_box[0].selectionStart,s=this.$post_box[0].selectionEnd;e=i.slice(0,o)+t+i.slice(s),this.$post_box.val(e),this.$post_box.focus(),this.$post_box[0].setSelectionRange(o+t.length,o+t.length)},previewPost:function(){if(!this.is_preview_processing){if(this.is_previewing)return this.$el.removeClass("cmty-posting-previewing"),this.is_previewing=!1,clearInterval(this.preview_interval),void this.onClickClosePreview();this.openPreviewWindow(),this.generatePreview()}},openPreviewWindow:function(){this.is_previewing=!0,this.$el.addClass("cmty-posting-previewing"),this.setHeight(),this.settings.hasOwnProperty("onPreview")&&this.settings.onPreview()},generatePreview:function(i){var s,n=this;arguments.length>0&&i.stopPropagation(),this.is_preview_processing||(o.cmty_ajax.ajax_active?(this.is_preview_processing=!0,0===this.$post_box.val().length||this.extra_options.hasOwnProperty("disable_bbcode")&&this.extra_options.disable_bbcode?this.revealPreview(this.$post_box.val().replace(/\r?\n/g,"<br />")):(s=this.$preview_text.html(),this.$preview_text.html(""),this.$preview_text.append(this.$loader),this.settings.master.parseBBCode({text:this.$post_box.val(),post_format:"bbcode",onFinish:function(t){n.revealPreview(t.rendered_text)},onAjaxFilter:function(){n.revealPreview(s)},onError:function(t){var e;e=n.checkCommonErrors(t.error_code),AoPS.Ui.Modal.showAlertQuick(e.message,{width:"400px"}),"close"===e.action?(n.revealPreview(""),n.onClickClosePreview()):"reveal_rendered"===e.action&&(n.revealPreview(t.response.error_data),n.onClickClosePreview())}}))):t.showErrorAtopAModal(o.is_cmty_asleep?e["community-asleep-save"]:e["ajax-error-E_AJAX_UNKNOWN"]))},checkCommonErrors:function(t){var i="",o="";switch(t){case"E_QUOTE_DEPTH":i=e["posting-quote-depth"],o="close";break;case"E_HIDE_DEPTH":i=e["posting-hide-depth"],o="close";break;case"E_NAUGHTY_TERM_USED":i=e["new-topic-banned-term"],o="close";break;case"E_NO_LINK_POSTING":i=e["new-topic-no-links"],o="close";break;case"E_NO_IMAGE_POSTING":i=e["new-topic-no-images"],o="close";break;case"E_INVALID_CHARACTER":i=e["new-topic-invalid-character"],o="close";break;case"E_LATEX_ERROR":i=e["posting-latex-error"],o="reveal_rendered";break;case"E_ASY_ERROR":i=e["posting-asy-error"],o="reveal_rendered";break;case"E_YOUTUBE_ERROR":i=e["posting-youtube-error"],o="close";break;case"E_POST_TOO_SHORT":i=e["new-topic-post-too-short"],o="close";break;case"E_POST_TOO_LONG":i=e["new-topic-post-too-long"],o="close";break;case"E_POST_TOO_LONG_PYTHON":i=e["new-topic-post-too-long-python"],o="close";break;case"E_TOPIC_TITLE_TOO_SHORT":i=e["new-topic-title-too-short"],o="close";break;case"E_TOPIC_TITLE_TOO_LONG":i=e["new-topic-title-too-long"],o="close";break;case"E_NO_FLOODING":i=e["posting-no-flooding-error"],o="close";break;case"E_NO_SUCH_CATEGORIES":i=e["new-topic-category-deleted"],o="close";break;case"E_BLACKLISTED":i=e["new-topic-blacklist-trigger"],o="close";break;case"E_NEW_USER_TEXT_BLACKLIST":i=e["new-topic-blacklist-text-trigger"],o="close";break;case"E_INVALID_ANNOUNCE_DATE":i=e["post-environ-invalid-announce-date"],o="close";break;case"E_IMG_ERROR":i=e["post-environ-image-error"],o="close";break;case"E_TIP_ERROR":i=e["post-environ-tip-error"],o="close";break;case"E_ANNOUNCE_DATE_IN_PAST":i=e["post-environ-announce-date-too-early"],o="close";break;case"E_NEW_USER_LIMITED":i=e["new-reply-err-E_NEW_USER_LIMITED"],o="close";break;case"E_NEW_VPN_USER_LIMITED":i=e["new-reply-err-E_NEW_VPN_USER_LIMITED"],o="close";break;case"E_AJAX_TIMEOUT":i=e["generic-ajax-timeout"],o="close";break;default:i="An unknown error occured.",o="no_error_match"}return{action:o,message:i}},revealPreview:function(t){if(this.$loader.detach(),this.$preview_text.html(t),this.setHeight(),this.is_preview_processing=!1,this.$preview_text.length>0&&"undefined"!=typeof Prism){Prism.plugins.autoloader.languages_path="https://cdnjs.cloudflare.com/ajax/libs/prism/1.17.1/components/";for(var e=this.$preview_text[0].querySelectorAll("pre code"),i=0;i<e.length;i++)Prism.highlightElement(e[i])}"function"==typeof this.settings.onRevealPreview&&this.settings.onRevealPreview()},submitPost:function(){},fetchPostContent:function(){return this.$post_box.val()},checkPost:function(){var s,n=$.trim(this.fetchPostContent()).length;if(!o.cmty_ajax.ajax_active)return t.showErrorAtopAModal(o.is_cmty_asleep?e["community-asleep-save"]:e["ajax-error-E_AJAX_UNKNOWN"]),!1;if(n<i.min_post_length)return this.showError(e["new-topic-post-too-short"]),!1;if(n>i.max_post_length)return this.showError(e["new-topic-post-too-long"]),!1;if(this.has_poll&&(this.$poll_question.val().length>0||this.$poll_inputs.val().length>0)){if(0==(s=$.trim(this.$poll_question.val()).length))return this.showError(e["poll-no-question-error"]),!1;if(s<i.min_poll_question_length)return this.showError(e["poll-question-too-short"]),!1;if(s>i.max_poll_question_length)return this.showError(e["poll-question-too-long"]),!1;if(0==$.trim(this.$poll_inputs.val()))return this.showError(e["poll-no-inputs-error"]),!1}return!0},showError:function(t){AoPS.Ui.Modal.showAlert(t)},checkTitle:function(){return!($.trim(this.$title_box.val()).length<i.min_topic_title_length)||(this.showError(e["new-topic-title-too-short"]),!1)},onClose:function(){this.hasOwnProperty("preview_interval")&&clearInterval(this.preview_interval),this.hasOwnProperty("attachments_view")&&this.attachments_view.close()}}),t.PostingAttachments=AoPS.View.extend({template_id:"#cmty-posting-attachments-tpl",className:"cmty-posting-attachments",initialize:function(s){var n=this,a=AoPS.Utils.getKeyChain(s.parent_view,"settings","post_model");this.parent_view=s.parent_view,_.isUndefined(a)?this.existing_attachments=[]:this.existing_attachments=a.get("attachments"),this.$el.html(this.getTemplate(this.template_id,{lang_upload:e["post-attachments-default"],has_existing_attachments:this.existing_attachments.length>0,attachments:this.existing_attachments,lang_attach_done:e["post-attachments-done"],lang_already_attached:e["post-attachments-already-attached"]})),this.$post_attachments=this.$("#post-attachments"),this.$post_attachments.dropzone({url:"/m/community/ajax.php",maxFiles:i.max_attachments_per_post-this.existing_attachments.length,addRemoveLinks:!0,sending:function(t,e,i){i.append("a","upload_post_attachment"),i.append("aops_session_id",AoPS.session.id)},removedfile:function(t){var e;return n.parent_view.processAttachments(n),null!=(e=t.previewElement)&&e.parentNode.removeChild(t.previewElement),this._updateMaxFilesReachedClass()},accept:function(t,e){/[^a-zA-Z0-9\.\ \_\-]/.test(t.name)?e("err-invalid-character"):e()},fallback:function(){AoPS.Ui.Modal.showAlert(e["err-dropzone-fallback"],{width:"450px"}),setTimeout((function(){AoPS.Ui.Modal.closeTopModal()}),100)},maxFilesize:AoPS.Community.Constants.max_attachment_size/1e3,success:function(i,s){var a;if(s.hasOwnProperty("error_code")){switch(s.error_code){case"E_TOO_MANY_FILES":a=e["edit-avatar-too-many"];break;case"E_NO_FILE_SENT":a=e["edit-avatar-no-file"];break;case"E_FILE_TOO_LARGE":a=e["post-attachments-file-too-big"];break;case"E_NO_PERMISSION":a=e["post-attachments-no-permission"];break;case"E_BAD_FILE_TYPE":a=o.formatString(e["post-attachments-bad-file-type"],[i.name]);break;case"E_SPOOFED_FILE":a=e["post-attachments-spoofed"];break;default:a=e["unexpected-error-code"]+s.error_code}t.showErrorAtopAModal(a),this.removeFile(i)}else i.tmp_name=s.response.tmp_name,$(i.previewElement).addClass("dz-success"),n.parent_view.processAttachments(n)},error:function(i,s){"err-invalid-character"===s?t.showErrorAtopAModal(e["post-attachments-invalid-character"]):"File is too big"===s.substr(0,15)?t.showErrorAtopAModal(e["post-attachments-file-too-big"]):"You can't upload files of this type"===s.substr(0,35)&&t.showErrorAtopAModal(o.formatString(e["post-attachments-bad-file-type"],[i.name])),this.removeFile(i)}}),this.dropzone=this.$post_attachments[0].dropzone},events:{"click .post-attachment-existing-row .aops-font":"removeExistingAttachment","click .cmty-attach-done":"onClickDone"},removeExistingAttachment:function(t){var e,o,s=t.currentTarget;o=$(s.parentNode).find("input").val(),e=_.findWhere(this.existing_attachments,{url:o}),this.existing_attachments=_.without(this.existing_attachments,e),this.dropzone.options.maxFiles=i.max_attachments_per_post-this.existing_attachments.length,0==this.existing_attachments.length?this.$(".post-attachments-existing").remove():s.parentNode.parentNode.removeChild(s.parentNode),this.parent_view.processAttachments(this)},onClickDone:function(){s.closeTopModal()},show:function(){var t=this;this.$el.showModal({title:e["post-attachments-title"],width:"400px",frame_class:"aops-modal-standard cmty-upload-modal",onClose:function(){t.parent_view.$post_box.focus()}})}}),t.throwPolymathConfirm=function(i){var n;(n=new t.PolymathConfirmation(i)).$el.showModal({type:"confirm",width:"450px",close_on_button_click:!1,scrollable:!0,onButtonClick:function(a){a?n.$('input[name="agree"]')[0].checked&&(n.$('input[name="is_student"]')[0].checked||n.$('input[name="is_student"]')[1].checked)?(t.throwLoaderBlockingMessage(e["polymath-confirm-blocker"]),AoPS.Community.MasterModel.sendPolymathConfirm({category_id:i.category_id,student_type:n.$('input[name="is_student"]:checked').val(),onFinish:function(){s.closeTopModal(),s.closeTopModal()},onError:function(t){s.showAlert(o.formatString(e["polymath-confirm-unknown-error"],[t.error_code]),{width:"400px",onClose:function(){s.closeTopModal(),s.closeTopModal()}})}})):t.showErrorAtopAModal(e["polymath-force-choice"]):s.closeTopModal()},onClose:function(){n.close()}})},t.PolymathConfirmation=AoPS.View.extend({template_id:"#cmty-polymath-confirm-tpl",initialize:function(t){this.$el.html(this.getTemplate(this.template_id,{error_message:t.error}))}}),t.NewTopic=t.PostingEnviron.extend({className:t.PostingEnviron.prototype.className+" cmty-new-topic-popup",topic_type:"forum",render:function(){var t=this;this.model.get("master").get("current_user").get("posting_subscribe_new_topic")&&(this.extra_options.notify_email=!0,this.extra_options.bookmark_feed=!0),this.$el.append(this.getTemplate(this.template_id,{category_name:this.model.get("category_name"),has_subject:!0,has_forum:!0,has_halp:this.model.get("has_halp")&&this.model.get("master").fetchPermission("can_post_as_halp"),has_tags:!0,has_recipients:!1,is_new_pm:this.is_new_pm,lang_view_attachments:e["new-topic-preview-bar-attachments"],lang_subject:e["new-topic-subject"],lang_tags:e["new-topic-tags"],lang_recipients:e["new-topic-to"],lang_post_anonymous:e["new-topic-post-anon"],lang_preview:e["new-topic-preview"],lang_close_preview:e["new-topic-close-preview"],lang_refresh:e["new-topic-refresh-preview"],max_post_length:i.max_post_length,max_title_length:i.max_topic_title_length,has_source:this.model.get("has_source"),lang_source:e["topic-cell-source"],max_source_length:i.max_source_length,source_placeholder:e["new-topic-source-placeholder"]})),this.$source=this.$("input.cmty-source-input"),this.$el.find(".cmty-posting-forum-name").css({"background-color":this.model.get("main_color")}),this.in_autotag_delete=!1,this.removed_autotags=[],o.autotagger.dictionary=this.model.getTermTagDictionary(),this.model.get("allow_autotag")&&this.model.get("has_source")&&this.$source.on("keyup",(function(e){t.onSourceKeypress(e)})),this.tag_warning_issued=!1,this.finishRender(),this.autotagging_disabled=this.model.get("master").get("current_user").get("turn_off_autotagging")},finishRender:function(){var e=this;this.appendTagBox(),$(window).on("resize.new-topic-"+this.cid,(function(){e.setHeight()})),this.$el.showModal({frame_class:"cmty-posting-modal",mask_fade_in_speed:200,scrollable:!1,draggable:!0,draggable_options:{containment:"window"},max_width:"1000px",onClickMask:function(t){return!1},onClickX:function(){return e.onClickCancel(),!1}}),this.$el.find(".cmty-private-recipients")?this.$el.find(".cmty-private-recipients input").focus():this.$el.find(".cmty-subject-input").focus(),this.setHeight(),this.listenTo(Backbone,"community_disabled",this.onDeactivated),t.setTabTarget(this.$("textarea"),this.$(".cmty-submit-button")),t.setTabTarget(this.$(".cmty-cancel-button"),this.$(".cmty-subject-input")),t.setTabTarget(this.$(".cmty-submit-button"),this.$(".cmty-cancel-button")),t.setTabTarget(this.$('input[type="text"]').last(),this.$("textarea"))},onSubjectKeypress:function(t){var e=t.which||t.keyCode;this.model.get("allow_autotag")&&32===e&&this.processTextForAutotagging(t.currentTarget.value.substr(0,t.currentTarget.selectionStart))},onSourceKeypress:function(t){var e=t.which||t.keyCode;this.model.get("allow_autotag")&&32===e&&this.processTextForAutotagging(t.currentTarget.value.substr(0,t.currentTarget.selectionStart))},onPostKeypress:function(t){var e=t.which||t.keyCode,i=this.$post_box.val();this.model.get("allow_autotag")&&(32!==e&&13!==e||(i=i.substr(0,t.currentTarget.selectionStart),this.processTextForAutotagging(i)))},processTextForAutotagging:function(t){var e,i,s,n=[],a=this;this.autotagging_disabled||_.isUndefined(t)||0===t.length||(s=(e=_.last(t.replace(/(;|:|\.|,|\r\n|\n|\r)/gm," ").replace(/\s{2,}/g," ").trim().split(" "),3))[e.length-1].toLowerCase(),e.length>1&&(i=e[e.length-2].toLowerCase()+" "+s,n=n.concat(o.autotagger.tag(i)),3===e.length&&(n=n.concat(o.autotagger.tag(e[0].toLowerCase()+" "+i)))),n=n.concat(o.autotagger.tag(s)),_.each(n,(function(t){_.isUndefined(_.findWhere(a.removed_autotags,{item_id:t.id}))&&a.editable_tagbox.submitItemSilent({item_id:t.id,label:t.text,term_text:t.term_text,term_id:t.term_id,item_forum_id:a.model.get("category_id"),is_visible:!0,main_color:a.model.get("main_color"),secondary_color:a.model.get("secondary_color"),tag_source:"auto"})})))},removeAllAutoTags:function(){var t=this.editable_tagbox.$items,e=this;this.in_autotag_delete=!0,_.each(t,(function(t){t.data("item").hasOwnProperty("tag_source")&&"auto"===t.data("item").tag_source&&e.editable_tagbox.removeItem(t)})),this.in_autotag_delete=!1},onClickCancel:function(){this.fetchPostContent().length>i.posting_warn_limit?AoPS.Ui.Modal.showConfirm(e["new-topic-are-sure"],_.bind((function(t){t?(AoPS.Ui.Modal.closeAllModals(),this.close()):AoPS.Ui.Modal.closeTopModal()}),this),{confirm_button_cancel:e["new-topic-confirm-cancel"],confirm_button_ok:e["new-topic-confirm-OK"],close_on_button_click:!1}):AoPS.Ui.Modal.closeAllModals()},canSetAnnounce:function(){return this.model.getPermission("c_can_announce")},canSetGlobalAnnounce:function(){return this.model.getPermission("c_can_global_announce")},validatePost:function(t){t(this.checkPost()&&this.checkTitle())},parseSubmittedTags:function(){var t=this;return this.settings.hasOwnProperty("tags")?_.map(this.settings.tags,(function(e){return{item_id:0,value:e,item_forum_id:t.model.get("category_id"),main_color:t.model.get("main_color"),secondary_color:t.model.get("secondary_color"),label:e,is_visible:!0,is_special:t.settings.hasOwnProperty("special_item")&&t.settings.special_item.toLowerCase()===e.toLowerCase()}})):[]},appendTagBox:function(){var i=this.parseSubmittedTags(),n=this;this.editable_tagbox=new t.EditableTagBox({category:this.model,items:i,input_on_blur:!0,onAddItem:function(t,e){n.checkSpecialItem(t,e),n.setHeight()},tryToRemoveItem:function(t){var i,a=$(":focus"),r=a===n.editable_tagbox.$input_box;i=t instanceof jQuery?t.data("item"):t,n.fetchSpecialItemText().toLowerCase()===i.label.toLowerCase()?s.showConfirm(o.formatString(e["new-topic-remove-link-confirm"],[n.model.get("category_name")]),(function(e){e&&n.editable_tagbox.removeItem(t),r?n.editable_tagbox.$input_box.focus():a.focus()}),{width:"450px"}):n.editable_tagbox.removeItem(t)},onRemoveItem:function(t){!n.in_autotag_delete&&t.hasOwnProperty("tag_source")&&"auto"===t.tag_source&&n.removed_autotags.push(t),n.setHeight()}}),this.$el.find(".cmty-tags-line").append(this.editable_tagbox.$el)},checkSpecialItem:function(t,e){this.fetchSpecialItemText().toLowerCase()===t.label.toLowerCase()&&e.addClass("cmty-special-item")},fetchSpecialItemText:function(){return"string"==typeof this.settings.special_item?this.settings.special_item:""},setHeight:function(){var t=(this.has_poll?this.$poll.outerHeight():0)+this.$el.find(".cmty-posting-top").outerHeight()+this.$el.find(".cmty-posting-button-row").outerHeight()+this.$el.find(".cmty-posting-preview-bar").outerHeight(),e=this.$el.height();this.is_previewing?(this.$el.find(".cmty-posting-box-container").height((e-t)/2),this.$(".cmty-post-preview").height((e-t)/2)):this.$el.find(".cmty-posting-box-container").height(e-t)},submitPost:function(){var t,o,n,a,r=this,l=!1;this.validatePost((function(c){c&&(r.model.get("allow_autotag")&&(r.processTextForAutotagging(r.$title_box.val()),r.model.get("has_source")&&r.processTextForAutotagging(r.$source.val())),r.model.get("category_id")===i.olympiad_forum_id?r.tag_warning_issued||0!==r.editable_tagbox.items.length&&r.doesEssentialTagExist(i.essential_tags_olympiad)||(l=!0,t=e["new-topic-olympiad-tags-warning"],n=e["new-topic-olympiad-tag-warning-title"],o="#cmty-olympiad-tag-modal-tpl",r.tag_warning_issued=!0):r.model.get("category_id")===i.college_math_forum_id&&(r.tag_warning_issued||0!==r.editable_tagbox.items.length&&r.doesEssentialTagExist(i.essential_tags_college)||(l=!0,t=e["new-topic-college-tags-warning"],n=e["new-topic-college-tag-warning-title"],o="#cmty-college-tag-modal-tpl",r.tag_warning_issued=!0)),l?((a=$(r.getTemplate(o,{message:t}))).showModal({title:n,width:"460px"}),a.find(".cmty-item-tag").on("click",(function(t){var e=r.editable_tagbox.items.length;e===i.max_tags_per_topic&&r.editable_tagbox.removeItem(r.editable_tagbox.items[e-1]),r.editable_tagbox.buildNewItem({item_id:parseInt(t.currentTarget.getAttribute("tag_id")),value:t.currentTarget.innerHTML,item_forum_id:r.model.get("category_id"),main_color:r.model.get("main_color"),secondary_color:r.model.get("secondary_color"),label:t.currentTarget.innerHTML,is_special:!1}),s.closeTopModal()}))):0===r.editable_tagbox.items.length&&"forum"===r.topic_type?AoPS.Ui.Modal.showConfirm(e["new-topic-no-tags-message"],(function(t){t?r.finishSubmitPost(!0):AoPS.Ui.Modal.closeTopModal()}),{confirm_button_ok:e["new-topic-no-tags-confirm-yes"],confirm_button_cancel:e["new-topic-no-tags-confirm-no"],width:"400px",close_on_button_click:!1}):r.finishSubmitPost(!1))}))},doesEssentialTagExist:function(t){var e,i,o=t.length;for(e=_.map(this.editable_tagbox.items,(function(t){return t.value.toLowerCase()})),i=0;i<o;i++)if(_.indexOf(e,t[i])>-1)return!0;return!1},isPostingAsSheriff:function(){return this.is_new_pm&&this.model.get("master").fetchPermission("can_pm_as_sheriff")&&this.$(".cmty-posting-sheriff input")[0].checked},isPostingAsHalp:function(){return this.model.get("has_halp")&&this.model.get("master").fetchPermission("can_post_as_halp")&&this.$(".cmty-posting-halp input")[0].checked},finishSubmitPost:function(s){var n,a=this,r=this.$title_box.val();this.prepareToSubmitPost(s),(n=_.extend({category_id:this.model.get("category_id"),topic_type:this.topic_type,title:r,has_poll:0,allow_latex_errors:this.allow_latex_errors,target_url:this.settings.hasOwnProperty("target_url")?this.settings.target_url:"",target_text:this.settings.hasOwnProperty("target_text")?this.settings.target_text:"",post_text:this.fetchPostContent(),post_as_halp:this.isPostingAsHalp(),attachments:this.attachments,pm_as_sheriff:this.isPostingAsSheriff(),tags:this.editable_tagbox.items,linked_tag:"string"==typeof this.settings.special_item?this.settings.special_item:"",removed_autotags:this.hasOwnProperty("removed_autotags")?this.removed_autotags:[],hidden_tags:this.settings.hasOwnProperty("hidden_tags")?this.settings.hidden_tags:[],restricted_tags:this.settings.hasOwnProperty("restricted_tags")?this.settings.restricted_tags:[],source:_.isUndefined(this.$source)?"":this.$source.val(),onFinish:function(e){var i=e.topic_id;t.delayModalClearing({onClose:function(){a.onPostedNewTopic({topic:e.topic_model,topic_id:i,title:r}),a.close()}})},onDeactivated:function(){a.onDeactivated()},onError:function(s){var n,r;if("string"==typeof e["new-topic-err-"+s.error_code])n=e["new-topic-err-"+s.error_code];else if("E_TOPIC_FORUM_LOCKED"===s.error_code)n=e["new-topic-forum-locked"],a.model.setFrontEndLocked(!0);else if("E_NO_PERMISSION"===s.error_code)n=a.model.get("category_id")===i.private_messages_id?AoPS.isUserLimited()?e["new-pm-no-permission-limited"]:e["new-pm-no-permission"]:e["new-topic-no-permission"];else if("E_AJAX_TIMEOUT"===s.error_code)n=e["new-topic-timeout"];else if("E_USER_EXCLUDE_SELF"===s.error_code)r=a.removeParticipant(s.response.error_data),n=o.formatString(e["private-user-excluded"],[r]);else if("E_PM_SHERIFF"===s.error_code)r=a.removeParticipant(s.response.error_data),n=o.formatString(e["private-user-sheriff"],[r]);else if("E_PM_EXTENSIONS"===s.error_code)r=a.removeParticipant(s.response.error_data),n=o.formatString(e["private-user-extensions"],[r]);else if("E_USER_EXCLUDED_FROM_PM"===s.error_code)r=a.removeParticipant(s.response.error_data),n=o.formatString(e["private-user-excluded-by-system"],[r]);else if("E_TOO_MANY_PARTICIPANTS"===s.error_code)n=e["private-new-msg-too-many-participants"];else if("E_POLYMATH_NOT_OPTED_IN"===s.error_code);else{var l=a.checkCommonErrors(s.error_code);"reveal_rendered"===l.action&&(a.openPreviewWindow(),a.revealPreview(s.response.error_data)),n=l.message,"no_error_match"===l.action&&(n=e["unexpected-error-code"]+s.error_code)}"E_LATEX_ERROR"===s.error_code||"E_ASY_ERROR"===s.error_code?a.throwLatexErrorMessage(s.error_code):"E_POLYMATH_NOT_OPTED_IN"===s.error_code?(AoPS.Ui.Modal.closeTopModal(),t.throwPolymathConfirm({category_id:a.model.get("category_id"),error:e["polymath-new-topic-confirm"]})):AoPS.Ui.Modal.showAlertQuick(n,{width:"400px",onClose:function(){AoPS.Ui.Modal.closeTopModal()}})},recipients:this.hasOwnProperty("editable_recipient_box")?_.map(this.editable_recipient_box.items,(function(t){return t.user_id})):[]},this.extra_options)).announce_through=this.hasOwnProperty("$announce_through")?this.$announce_through.find("input").val():"",this.has_poll&&(n.has_poll=1,n.poll_data={question:this.$poll_question.val(),allow_revote:this.$poll.find('select[name="poll-revoting"]').val(),num_selections:this.$poll.find('select[name="poll-num-options"]').val(),options:this.$poll_inputs.val(),length:this.$poll.find('select[name="poll-length"]').val()}),this.settings.master.submitNewTopic(n)},onDeactivated:function(){s.closeAllModals(),this.close()},prepareToSubmitPost:function(e){this.title=this.$title_box.val(),e?t.replaceWithLoaderBlockingMessage(this.sending_blocker):t.throwLoaderBlockingMessage(this.sending_blocker),this.listenTo(this.settings.master.get("topics"),"add",this.checkAddedTopic)},onPostedNewTopic:function(e){var i=this.settings.hasOwnProperty("url_cmty_path")?this.settings.url_cmty_path:"";"private"===e.topic.get("topic_type")&&this.model.get("master").get("current_user").get("pm_archive_on_send")||(this.model.get("is_private")&&!t.onPMPage()||Backbone.history.navigate(i+"/c"+this.model.get("category_id")+"h"+e.topic_id+"_"+t.convertToUrlFragment(e.title),{trigger:!0}),"function"==typeof this.settings.onSuccess&&this.settings.onSuccess(e))},onClose:function(){this.editable_tagbox.close(),$(window).off("resize.new-topic-"+this.cid)}}),t.NewReply=t.PostingEnviron.extend({has_subject:!1,has_forum:!1,has_source:!1,no_permission_lang_property:"new-reply-no-permission",no_permission_limited_lang_property:"new-reply-no-permission-limited",render:function(){this.sending_to_database=!1,this.$el.append(this.getTemplate(this.template_id,_.defaults(this.settings,{has_subject:this.has_subject,has_forum:this.has_forum,category_name:this.has_forum&&this.settings.topic.get("category_name"),has_tags:!1,has_halp:!1,is_new_pm:this.is_new_pm,has_source:this.has_source,lang_view_attachments:e["new-topic-preview-bar-attachments"],lang_subject:e["new-topic-subject"],lang_preview:e["new-topic-preview"],lang_close_preview:e["new-topic-close-preview"],lang_refresh:e["new-topic-refresh-preview"],max_post_length:i.max_post_length,max_title_length:i.max_topic_title_length,lang_source:e["topic-cell-source"],max_source_length:i.max_source_length,source_placeholder:e["new-topic-source-placeholder"]}))),this.has_forum&&this.$el.find(".cmty-posting-forum-name").css({"background-color":this.settings.topic.get("category_main_color")}),t.setTabTarget(this.$("textarea"),this.$(".cmty-submit-button")),t.setTabTarget(this.$(".cmty-submit-button"),this.$("textarea"))},submitPost:function(){var i=this.$post_box.val(),o=this;return!!this.checkPost()&&("private"===this.settings.topic.get("topic_type")&&this.checkParticipants(),this.throwBlockingMessage(),this.sending_to_database=!0,this.settings.master.submitPost(_.extend({category_id:this.settings.category_id,post_text:i,topic_id:this.settings.topic_id,attachments:this.attachments,topic:this.settings.topic,allow_latex_errors:this.allow_latex_errors,onDeactivated:function(){s.closeAllModals()},onError:function(s){var n,a=s.error_code,r=s.response.error_data;if(o.sending_to_database=!1,"E_TOPIC_FORUM_LOCKED"===s.error_code)n=e["new-reply-forum-locked"],o.settings.master.setCategoryLockStatus(o.settings.topic.get("category_id"),!0);else if("E_NOT_LOGGED_IN"===a)n=e["new-reply-logged-out-warning"]+'<br/><div style="text-align:center">\t\t\t\t\t\t\t<textarea rows="4" style="width:80%">'+i+"</textarea>";else if("E_NO_PERMISSION"===a)n=AoPS.isUserLimited()?e[o.no_permission_limited_lang_property]:e[o.no_permission_lang_property];else if("E_TOPIC_LOCKED"===a)n=e["new-reply-locked"];else if("E_NEW_USER_LIMITED"===a)n=e["new-reply-err-E_NEW_USER_LIMITED"];else if("E_NEW_VPN_USER_LIMITED"===a)n=e["new-reply-err-E_NEW_VPN_USER_LIMITED"];else if("E_AJAX_TIMEOUT"===a)n=e["new-reply-timeout"];else if("E_POLYMATH_NOT_OPTED_IN"===a);else{var l=o.checkCommonErrors(a);"no_error_match"===l.action?n=e["unexpected-error-code"]+a:("reveal_rendered"===l.action&&"function"==typeof o.openPreviewWindow&&(o.openPreviewWindow(),o.revealPreview(r)),n=l.message)}"E_LATEX_ERROR"===a||"E_ASY_ERROR"===a?o.throwLatexErrorMessage(a):"E_POLYMATH_NOT_OPTED_IN"===a?(AoPS.Ui.Modal.closeTopModal(),t.throwPolymathConfirm({category_id:o.settings.category_id,error:e["polymath-reply-confirm"]})):(AoPS.Ui.Modal.closeTopModal(),AoPS.Community.Views.showError(n))}},this.extra_options)),this.settings.hasOwnProperty("onSubmit")&&this.settings.onSubmit(),this.onFinishSubmit(),!1)},throwBlockingMessage:function(){t.throwLoaderBlockingMessage(e["topic-full-new-reply-blocker"])},checkParticipants:function(){var t=this.settings.topic;1!==t.get("participants").length&&1==_.filter(t.get("participants"),(function(t){return!t.removed})).length&&AoPS.Ui.Flyout.display(e["private-reply-no-listeners"])},onErrorInPosting:function(){},onFinishSubmit:function(){},onClickCancel:function(){this.fetchPostContent().length>i.posting_warn_limit?AoPS.Ui.Modal.showConfirm(e["topic-full-reply-confirm"],_.bind((function(t){t&&this.closeReply()}),this),{confirm_button_cancel:e["topic-full-reply-confirm-cancel"],confirm_button_ok:e["topic-full-reply-confirm-OK"]}):this.closeReply()},closeReply:function(){this.settings.hasOwnProperty("onCancel")&&this.settings.onCancel(),$("#community-all").removeClass("reply-focused"),$(window).trigger("resize"),this.close()}}),t.EditPost=t.PostingEnviron.extend({has_email_subscribe:!1,has_add_to_feed:!1,className:t.PostingEnviron.prototype.className+" cmty-new-topic-popup cmty-edit-post",render:function(){this.has_source=this.has_source&&this.settings.topic.get("can_have_source"),this.settings.post_model.get("attachment")&&(this.attachments=_.map(this.settings.post_model.get("attachments"),(function(t){return{href:t.href,existing:!0,name:t.name,url:t.url}}))),AoPS.Community.Views.NewReply.prototype.render.apply(this),"bbcode"!==this.settings.post_model.get("post_format")&&(this.extra_options.disable_bbcode=!0,this.is_bbcode_enabled=!1,this.$el.addClass("cmty-bbcode-disabled")),this.settings.hasOwnProperty("input_text")&&this.$el.find("textarea").val(this.settings.input_text),$(window).on("resize.edit-post-"+this.cid,_.bind((function(){this.setHeight()}),this)),this.has_source&&(this.$source=this.$("input.cmty-source-input"),this.$source.val(_.unescape(this.settings.topic.get("source")))),this.has_subject&&this.$(".cmty-subject-input").val(_.unescape(this.settings.topic.get("topic_title")))},setHeight:t.NewTopic.prototype.setHeight,submitPost:function(){return!!this.checkPost()&&(!(this.has_subject&&!this.checkTitle())&&void this.requestReason())},requestReason:function(){var t=this,i=$(this.getTemplate("#cmty-edit-post-reason-tpl",{lang_instructions:e["edit-post-reason-info"]}));i.showAlert({title:e["edit-post-reason-heading"],width:"400px",focus_on_alert:!1,frame_class:"cmty-edit-reason-modal aops-modal-standard",onButtonClick:function(){var e=i.find("textarea").val().substr(0,255);t.sendEdit(e)},close_on_button_click:!1}),i.find("textarea").focus(),i.on("keydown",(function(e){13===(e.which||e.keyCode)&&(e.metaKey||e.ctrlKey)&&(t.sendEdit(i.find("textarea").val().substr(0,255)),e.stopPropagation(),e.preventDefault())}))},sendEdit:function(o){var s=this,n=this.$post_box.val();t.replaceWithLoaderBlockingMessage(e["edit-send-blocker"]),this.settings.post_model.edit(_.extend({edited_text:this.$post_box.val(),edit_reason:o,allow_latex_errors:this.allow_latex_errors,source:this.has_source?this.$source.val():"",attachments:this.attachments,topic_title:this.has_subject?this.$title_box.val():"",onError:function(t){var i,o=t.error_code;if("E_TOPIC_FORUM_LOCKED"===o)i=e["new-topic-forum-locked"],s.settings.topic.get("master").setCategoryLockStatus(s.settings.topic.get("category_id"),!0);else if("E_NOT_LOGGED_IN"===o)i=e["edit-post-logged-out-warning"]+'<br/><div style="text-align:center">\t\t\t\t\t\t\t<textarea rows="4" style="width:80%">'+n+"</textarea>";else if("E_NO_PERMISSION"===o)i=e["edit-post-no-permission"];else if("E_NO_SUCH_POST"===o)i=e["edit-post-no-post"];else if("E_NO_LINK_POSTING"===o)i=e["edit-post-no-links"];else if("E_NO_IMAGE_POSTING"===o)i=e["edit-post-no-images"];else if("E_INVALID_CHARACTER"===o)i=e["new-topic-invalid-character"];else if("E_NO_EDIT_MADE"===o)i=e["edit-post-nothing-changed"];else if("E_AJAX_TIMEOUT"===o)i=e["error-timeout"];else{var a=s.checkCommonErrors(o);"reveal_rendered"===a.action&&(s.openPreviewWindow(),s.revealPreview(t.response.error_data)),i=a.message}"E_LATEX_ERROR"===o||"E_ASY_ERROR"===o?s.throwLatexErrorMessage(o):AoPS.Ui.Modal.showAlertQuick(i,{width:"400px",onClose:function(){AoPS.Ui.Modal.closeTopModal()}})},onFinish:function(){setTimeout((function(){s.close(),AoPS.Ui.Modal.closeAllModals()}),i.new_topic_modal_delay)}},this.extra_options))},onClickCancel:function(){AoPS.Ui.Modal.showConfirm(e["topic-full-edit-confirm"],_.bind((function(t){t&&(this.settings.hasOwnProperty("onCancel")&&this.settings.onCancel(),AoPS.Ui.Modal.closeAllModals(),this.close())}),this),{confirm_button_cancel:e["topic-full-reply-confirm-cancel"],confirm_button_ok:e["topic-full-edit-confirm-OK"]})},onClose:function(){$(window).off("resize.edit-post-"+this.cid)}}),t.EditFirstPost=t.EditPost.extend({has_subject:!0,has_forum:!0,has_source:!0}),t.NewPrivateConversation=t.NewTopic.extend({topic_type:"private",has_email_subscribe:!1,has_add_to_feed:!1,is_new_pm:!0,autotagging_disabled:!0,sending_blocker:e["new-pm-send-blocker"],render:function(){var o=[];this.$el.append(this.getTemplate(this.template_id,_.defaults(this.settings,{has_subject:!0,has_tags:!0,has_recipients:!0,has_halp:!1,is_private:this.is_new_pm,can_pm_as_sheriff:this.model.get("master").fetchPermission("can_pm_as_sheriff"),has_forum:!1,lang_post_as_sheriff:e["new-topic-post-as-sheriff"],lang_view_attachments:e["new-topic-preview-bar-attachments"],max_post_length:i.max_post_length,max_title_length:i.max_topic_title_length,lang_subject:e["new-topic-subject"],lang_tags:e["new-topic-tags"],lang_recipients:e["new-topic-to"],lang_preview:e["new-topic-preview"],lang_close_preview:e["new-topic-close-preview"],lang_refresh:e["new-topic-refresh-preview"],has_source:!1}))),this.$el.addClass("cmty-new-private-conversation"),this.tag_warning_issued=!1,this.settings.hasOwnProperty("preset_recipients")&&(o=this.settings.preset_recipients),this.editable_recipient_box=new t.EditableRecipientBox({model:this.settings.master,items:o,onAddItem:_.bind((function(){this.setHeight()}),this),onRemoveItem:_.bind((function(){this.setHeight()}),this)}),this.$el.find(".cmty-private-recipients").append(this.editable_recipient_box.$el),this.finishRender()},checkRecipients:function(t){0!==this.editable_recipient_box.items.length||this.editable_recipient_box.$input_box.val()?this.editable_recipient_box.$input_box.val()?this.model.checkValidPrivateRecipient({username:this.editable_recipient_box.$input_box.val(),onFinish:function(i){if(i.is_unreachable){var o={type:"alert",body:e["private-unreachable-recipient"],frame_class:"aops-modal-quick"};AoPS.Ui.Modal.showMessage(this,o),t(!1)}else t(!0)}}):t(!0):(this.showError(e["private-need-recipients-err"]),t(!1))},removeParticipant:function(t){var e,i=_.find(this.editable_recipient_box.items,(function(e){return parseInt(e.user_id)===t}));return _.isUndefined(i)?"":(e="string"==typeof i.value?i.value:i.label,this.editable_recipient_box.removeItem(i),e)},validatePost:function(t){var e=this;this.checkRecipients((function(i){var o=e.checkPost()&&e.checkTitle()&&i;t(o)}))},canSetAnnounce:function(){return!1},canSetGlobalAnnounce:function(){return!1}}),t.ReportPost=AoPS.View.extend({template_id:"#cmty-report-post-tpl",className:"cmty-report-post cmty-modal-form aops-modal-standard",initialize:function(){this.$el.append(this.getTemplate(this.template_id,{username:this.model.get("username"),spam_text:e["topic-full-report-item-spam"],warez_text:e["topic-full-report-item-warez"],cheat_text:e["topic-full-report-item-cheat"],other_text:e["topic-full-report-item-other"]}))},events:{"submit form":"onFormSubmit","click input[type=button]":"onClickCancel"},onClickCancel:function(){AoPS.Ui.Modal.closeAllModals(),this.close()},onFormSubmit:function(t){var i=this.$el.find("select").val(),o=this.$el.find("textarea").val();return this.model.report(i,o),AoPS.Ui.Modal.showAlert(e["topic-full-report-report-sent"],{onClose:function(){AoPS.Ui.Modal.closeAllModals()}}),this.close(),t.preventDefault(),t.stopPropagation(),!1}}),t.DeletePost=AoPS.View.extend({template_id:"#cmty-delete-post-tpl",className:"cmty-delete-post cmty-modal-form aops-modal-standard",initialize:function(t){this.topic=t.topic,this.$el.append(this.getTemplate(this.template_id,{username:this.model.get("username"),can_hard_delete:this.topic.getPermission("c_can_hard_delete"),is_first_post:1===this.model.get("post_number")})),this.model.get("poster_id")!==AoPS.session.user_id&&this.$(".aops-modal-body").append($("<h3 />").text("Reason:")).append(o.getModerationInputsForType("topic"))},events:{"submit form":"onFormSubmit","click input[type=button]":"onClickCancel"},onClickCancel:function(){AoPS.Ui.Modal.closeAllModals(),this.close()},onFormSubmit:function(t,i){var o=!1,s=this,n=!_.isUndefined(i)&&!_.isUndefined(i.force_soft)&&i.force_soft,a=this.$("input[name='reason']:checked").val()||"";return!n&&this.topic.getPermission("c_can_hard_delete")&&(o="hard"===this.$("input[name=delete_option]:checked").val()),AoPS.Community.Views.throwBlockingMessage(e["topic-full-delete-post-pending"]),this.model.delete({hard_delete:o,reason:a,onFinish:function(t){t.hasOwnProperty("topic_deleted")&&t.topic_deleted||AoPS.Community.Views.delayModalClearing({onClose:function(){s.close()}})},onError:function(t){var i,o=t.error_code;i="E_NO_PERMISSION"===o?e["delete-post-no-permission"]:"E_NOT_LAST_POST"===o?e["delete-post-not-last-post"]:"E_HARD_DELETE"===o?e["topic-full-undelete-hard"]:"E_NO_DELETING_FIRST_POST"===o?e["delete-post-sniped"]:e["unexpected-error-code"]+o,AoPS.Community.Views.showError(i)}}),t.preventDefault(),t.stopPropagation(),!1}}),t.PostReports=AoPS.View.extend({template_id:"#cmty-post-reports-tpl",initialize:function(){this.listenTo(this.model.get("reported_posts"),"add",this.addReportedPost),this.listenTo(this.model.get("reported_posts"),"remove",this.onPostReportFetchFinished),this.reported_post_views=[],this.$loader=AoPS.Page.buildLoader(),this.$el.html(this.getTemplate(this.template_id,{page_title:e["post-report-admin-page-title"],top_text:e["post-report-admin-page-text"],loader:e["post-report-admin-loading"],none_found:e["post-report-admin-none"],is_admin:AoPS.session.a})),this.$initial_loading=this.$el.find(".cmty-post-reports-loader"),this.$none=this.$el.find(".cmty-post-reports-none-found"),this.$reported_posts=this.$el.find(".cmty-post-reports-container"),this.listenTo(this.model,"post_reports_fetched",this.onPostReportFetchFinished)},addReportedPost:function(e){if("unresolved"===e.get("status")){var i=new t.PostReport({model:e});this.reported_post_views.push(i),this.$reported_posts.append(i.$el)}},onAddToPage:function(t){var o=this;this.$initial_loading.show(),this.$none.hide(),this.focus=t,this.model.fetchReportedPosts(),this.goToFocus(),this.interval=setInterval((function(){o.model.fetchReportedPosts()}),i.intervals.current.reported_posts_interval),this.model.get("all_past_reported_posts_fetched")||$(window).on("scroll."+this.model.cid,(function(t){window.innerHeight+window.pageYOffset+10>=document.body.offsetHeight&&!o.model.get("loading_post_reports")&&o.model.get("reported_posts").length>0&&!o.model.get("all_past_reported_posts_fetched")&&(o.$el.append(o.$loader),o.model.fetchReportedPosts({fetch_before:o.model.get("reported_posts").last().get("inserted_at"),onFinish:function(){o.$loader.detach(),o.model.get("all_past_reported_posts_fetched")&&o.$el.append('<div class="cmty-no-more-reports">'+e["post-report-no-more"]+"</div>")}}))}))},goToFocus:function(){var t,e;this.focus.hasOwnProperty("post_id")?(e=this.focus.post_id,t=_.find(this.reported_post_views,(function(t){return t.model.get("post_id")===e}))):this.focus.hasOwnProperty("topic_id")&&(e=this.focus.topic_id,t=_.find(this.reported_post_views,(function(t){return t.model.get("topic_id")===e}))),_.isUndefined(t)||this.goToTargetReport(t)},goToTargetReport:function(t){this.focus={},window.scrollTo(0,t.$el.offset().top)},onRemoveFromPage:function(){clearInterval(this.interval),$(window).off("scroll."+this.model.cid+" touchmove."+this.model.cid)},onPostReportFetchFinished:function(){this.$initial_loading.hide(),this.$none.toggle(_.isUndefined(this.model.get("reported_posts").findWhere({status:"unresolved"}))),this.goToFocus(),this.focus={}},onClose:function(){_.each(this.reported_post_views,(function(t){t.close()}))}}),t.PostReportPostWindow=t.Post.extend({removePostFromTopic:function(){}}),t.PostReport=AoPS.View.extend({template_id:"#cmty-post-report-tpl",className:"cmty-admin-post-report",initialize:function(){this.post_view=new t.PostReportPostWindow({model:this.model.get("post"),topic:{model:this.model.get("post").get("topic")}}),this.render(),this.listenTo(this.model,"change:status",this.onChangeStatus),this.listenTo(this.model.get("post"),"change:deleted",this.onPostDeleted),this.listenTo(this.model.get("post").get("topic"),"change:deleted",this.onTopicDeleted)},events:{"click .cmty-post-report-admin-btn .btn":"onClickResolved","click .cmty-pm-reporter":"onClickPMReporter","click .cmty-pm-poster":"onClickPMPoster"},render:function(){var t,s,n,a,r=this.model.get("post").get("topic");this.model.get("category_id")===i.private_messages_id?(t="/x"+this.model.get("post").get("poster_id"),s=this.model.get("post").get("username")+" "+e["Private-Messages"]):(t="/c"+this.model.get("category_id"),s=this.model.get("category_name")),a=t+"h"+r.get("topic_id"),n="blog"!=this.model.get("category_type"),this.$el.html(this.getTemplate(this.template_id,{category_name:s,category_url:AoPS.Community.Views.makeLinkUrl(t),mark_for_push_state:n,topic_title:r.get("topic_title"),topic_url:AoPS.Community.Views.makeLinkUrl(a),reported_by_text:e["post-report-admin-reported-by"],reported_date_text:e["post-report-admin-reported-date"],user_link:"/community/user/"+this.model.get("reporter_user_id"),details_text:e["post-report-admin-details"],details:this.model.get("details").length>0?this.model.get("details"):"None given",reported_by:this.model.get("username"),for_text:e["post-report-admin-for"],short_reason:e["topic-full-report-item-"+this.model.get("reason_short")],reported_date:o.makePrettyTime(this.model.get("inserted_at")),show_first_post_note:1===this.model.get("post").get("post_number"),first_post_note:e["post-report-first-post-note"],lang_pm_poster:e["post-report-admin-pm-poster"],lang_pm_reporter:e["post-report-admin-pm-reporter"],lang_send_pm:e["post-report-admin-pm"]})),this.$el.find(".feed-topic-forum").css({"background-color":this.model.get("main_color"),color:this.model.get("secondary_color")}),this.$el.find(".cmty-post-report-post").append(this.post_view.$el)},onClose:function(){this.post_view.close()},onClickPMReporter:function(s){var n=t.launchNewPrivateMessage({user_id:parseInt(this.model.get("reporter_user_id")),username:this.model.get("username"),is_admin:!1}),a=e["post-report-pm-subject"],r=o.formatString(e["post-report-pm-reporter-preamble"],[i.base_url+"/community/p"+this.model.get("post").get("post_id")]);this.model.get("details").length>0&&(r+=" "+e["post-report-pm-reporter"]+'[quote="'+this.model.get("username")+'"]'+this.model.get("details")+"[/quote]"),n.setTitle(a),n.addContent(r)},onClickPMPoster:function(e){var i,o,s=this.model.get("post_data");s.hasOwnProperty("real_poster_id")&&s.real_poster_id>0?(i=parseInt(s.real_poster_id),o=s.real_poster_username):(i=parseInt(s.poster_id),o=s.username),t.launchNewPrivateMessage({user_id:i,username:o,is_admin:this.model.get("post_data").admin})},onClickResolved:function(){var t=this;AoPS.Ui.Modal.showConfirm(this.getTemplate("#cmty-post-report-settle-confirm-tpl",{message:e["post-report-admin-confirm"],notes:e["post-report-admin-notes"]}),(function(i){i?(AoPS.Community.Views.throwBlockingMessage(e["post-report-admin-block"]),t.model.settle({onFinish:function(){AoPS.Community.Views.delayModalClearing()},notes:$(".cmty-post-report-settle-note").val(),onError:function(t){var i;"E_NOT_LOGGED_IN"===t.error_code?i=e["logged-out"]:"E_NO_PERMISSION"===t.error_code&&(i=e["post-report-admin-no-permission"]),AoPS.Community.Views.showError(i)}})):AoPS.Ui.Modal.closeAllModals()}),{title:e["post-report-admin-confirm-title"],close_on_button_click:!1,max_width:"400px"})},onChangeStatus:function(){"resolved"===this.model.get("status")&&this.$el.fadeTo(500,0,_.bind((function(){this.close()}),this))},onPostDeleted:function(){this.model.decrementNumReports(),this.model.set("status","resolved")},onTopicDeleted:function(){this.model.set("status","resolved")}}),t.SearchPage=AoPS.View.extend({template_id:"#cmty-search-page-tpl",className:"cmty-search-page",initialize:function(t){this.init_options=t,this.init_options.is_private=t.preset_settings.hasOwnProperty("is_private")&&t.preset_settings.is_private,this.render(),this.init_options.is_private&&this.$el.addClass("cmty-private-search")},render:function(){this.$el.html(this.getTemplate(this.template_id,{lang_Search_Page_Title:this.init_options.is_private?e["search-page-private-title"]:e["search-page-title"]})),this.search_form=new t.SearchForm(this.init_options),this.$(".form").append(this.search_form.$el)},onAddToPage:function(){this.search_form.$("input").first().focus()}}),t.SearchForm=AoPS.View.extend({template_id:"#cmty-search-form-tpl",className:"cmty-search-form",supported_presets:["forums"],initialize:function(t){var e=this;this.search_page_id=t.search_page_id,this.master=this.model,this.include_users=[],this.forums=[],this.is_private=t.hasOwnProperty("is_private")&&t.is_private,t.hasOwnProperty("preset_settings")&&_.each(this.supported_presets,(function(i){t.preset_settings.hasOwnProperty(i)&&(e[i]=t.preset_settings[i])})),this.search_expanded=!1,this.render()},render:function(){var e=this;this.$el.html(this.getTemplate(this.template_id,{})),this.$search_term=this.$('[name="search-term"]'),this.include_user_list=new t.EditableValidatedUserList({model:this.master,items:this.include_users}),this.forum_list=new t.EditableForumList({model:this.master,items:this.forums,ajax_call:"fetch_search_forum_autocomplete"}),this.$(".cmty-search-posters-include").append(this.include_user_list.$el),this.$(".cmty-search-forums-include").prepend(this.forum_list.$el),this.$dates_options=this.$(".cmty-search-dates-select > select"),this.$dates_range=this.$(".cmty-search-dates-range"),this.$dates_range_from=this.$dates_range.find("input.cmty-search-from"),this.$dates_range_to=this.$dates_range.find("input.cmty-search-to"),this.$dates_range_from.datepicker({defaultDate:"+1w",changeMonth:!0,changeYear:!0,numberOfMonths:1,yearRange:"2003:c",minDate:new Date(2003,0,1),maxDate:0,beforeShow:function(){$("#ui-datepicker-div").addClass("cmty-search-datepicker")},onClose:function(t){$("#ui-datepicker-div").removeClass("cmty-search-datepicker"),e.$dates_range_to.datepicker("option","minDate",t)}}),this.$dates_range_to.datepicker({defaultDate:"+1w",changeMonth:!0,changeYear:!0,numberOfMonths:1,yearRange:"2003:c",minDate:new Date(2003,0,1),maxDate:0,beforeShow:function(){$("#ui-datepicker-div").addClass("cmty-search-datepicker")},onClose:function(t){$("#ui-datepicker-div").removeClass("cmty-search-datepicker"),e.$dates_range_from.datepicker("option","maxDate",t)}}),this.$("input.enter-to-search").on("keydown",(function(t){13===(t.which||t.keyCode)&&e.onClickSearch()}))},events:{"click a.cmty-search-expand-link":"onClickTextToggle","click .cmty-search-clear":"onClickClear","click .cmty-search-go":"onClickSearch","change .cmty-search-dates-select > select":"onSelectDateOption"},onClickTextToggle:function(t){this.$el.toggleClass("cmty-search-expanded"),this.search_expanded=!this.search_expanded,t.stopPropagation(),t.preventDefault()},onClickClear:function(t){this.include_user_list.close(),this.forum_list.close(),this.include_users=[],this.forums=[],this.render()},onSelectDateOption:function(t){var e=parseInt(this.$dates_options.val());this.$dates_range.toggle(-1===e)},onClickSearch:function(t){var e,i,o,s,n,a,r={},l="";this.include_user_list.$input_box.val().length>0||this.forum_list.$input_box.val().length>0?this.validateInput():(this.search_expanded?((i=this.$('[name="title"]').val()).length>0&&(r.title=i),(i=this.$('[name="source"]').val()).length>0&&(r.source=i),(i=this.$('[name="post-text"]').val()).length>0&&(r.post_text=i),(i=this.$('[name="tags"]').val()).length>0&&(r.tags=i),r.first_post=this.$('[name="first-post"]').is(":checked")?1:0):(e=this.$search_term.val()).length>0&&(r.search_text=e,l="_"+encodeURIComponent(e)),this.include_user_list.items.length>0&&(r.include_users=_.pluck(this.include_user_list.items,"user_id")),this.forum_list.items.length>0&&(r.forums=_.pluck(this.forum_list.items,"category_id"),r.forums_action=this.$('input[name="forum_option"]:checked').val()),r.sort_by=this.$('input[name="sort_by"]:checked').val(),this.is_private&&(r.forums_action="include",r.forums=[1]),-1===(o=parseInt(this.$dates_options.val()))?(s=(s=moment(this.$dates_range_from.val())).isValid()?s.format("X"):0,n=(n=moment(this.$dates_range_to.val())).isValid()?n.add("days",1).format("X"):0):o>0&&(s=(n=moment().format("X"))-o),s>0&&(r.start_date=s),n>0&&(r.end_date=n),_.keys(r).length>0&&((a=this.master.buildSearchCategory(r)).set("search_page_id",this.search_page_id),Backbone.history.navigate("q"+a.get("search_id")+l,{trigger:!0,replace:!1})))},validateInput:function(){var i,s=this,n=this.include_user_list.$input_box.val(),a=this.forum_list.$input_box.val();t.throwBlockingMessage(e["search-validation-blocker"]),this.master.validateSearchInput({username:n,forum:a,onFinish:function(r){var l,c=!1;r.hasOwnProperty("user")&&(r.user.is_valid?(l={user_id:r.user.user_id,item_id:r.user.user_id,label:r.user.username,value:r.user.username,is_admin:r.user.is_admin},s.include_user_list.buildNewItem(l)):(c=!0,i=o.formatString(e["search-err-no-such-user"],[n]))),!c&&r.hasOwnProperty("forum_found")&&(r.forum_found?(r.forum_data.label=r.forum_data.value,s.forum_list.buildNewItem(r.forum_data)):(c=!0,i=o.formatString(e["search-err-no-such-forum"],[a]))),c?t.showError(i):setTimeout((function(){s.onClickSearch()}),500)},onError:function(t){}})}}),t.UserProfile=AoPS.View.extend({template_id:"#cmty-user-profile-tpl",className:"cmty-user-profile cmty-folder-top",location:"user_profile",friend_click_path:"/user/",router_base:"/community",main_profile_plain_settings:["joined_at","status","goals","interests","website","school","location","occupation"],activity_settings:[{attribute:"last_visit_pretty",title_lang_attr:"user-profile-last-visit",is_html:!0},{attribute:"num_posts",title_lang_attr:"user-profile-total-posts"},{attribute:"primary_blog_id",title_lang_attr:"user-profile-blog",nowrap:!0},{attribute:"thanks_given",title_lang_attr:"user-profile-thanks-given"},{attribute:"thanks_received",title_lang_attr:"user-profile-thanks-received"}],initialize:function(t){var i="",o=this;this.is_session_user=this.model.get("user_id")===AoPS.session.user_id,this.$no_friends=$('<div class="cmty-no-friends">'+e["user-profile-no-friends"]+"</div>"),this.compress_top_fora="boolean"==typeof t.compress_top_fora&&t.compress_top_fora,this.render(),this.is_session_user&&(_.each(this.main_profile_plain_settings,(function(t){i+=" change:"+t})),this.listenTo(this.model,i,this.fillMainProfile),this.listenTo(this.model,"change:friends_exclude",(function(){o.model.set("show_friends",!o.model.get("friends_exclude")),o.render()})))},events:{"click #about-num-posts":"onClickAboutNumPosts","click .cmty-user-profile-pm":"onClickMessage","click .cmty-user-add-new-friend":"onClickAddNewFriend","click .cmty-user-add-this-friend":"onClickAddThisFriend","click .cmty-toggle-user-bookmark":"onClickBookmark","click .cmty-user-add-note":"onClickAddNote","click .cmty-ban-link":"onClickBan","click .cmty-reset-thanks-link":"onClickResetThanks","click .cmty-troll-link":"onClickTroll","click .cmty-vpn-check":"onClickCheckVPN","click .cmty-temp-ban-link":"onClickTempBan"},render:function(){var i,o=this.model,s=this,n=this.model.get("master");i=o.get("show_friends")&&(this.is_session_user||o.get("friends").length>0);var a=!!n&&n.fetchPermission("can_edit_other_profiles");this.$el.html(this.getTemplate(this.template_id,{username:o.get("username"),user_id:o.get("user_id"),can_pm:o.get("can_pm"),is_admin:AoPS.session.a,is_national:AoPS.session.n,can_access_user_general:!!n&&n.fetchStaffPermission("user-general"),can_access_log:!!n&&n.fetchStaffPermission("can-access-log"),can_edit_cmty_perms:!!n&&n.fetchStaffPermission("perms-cmty"),can_oneclick_ban:!o.get("is_banned")&&!!n&&n.fetchStaffPermission("one-click-ban"),temp_ban:o.get("temp_ban"),is_this_user_admin:o.get("is_admin"),is_limited:AoPS.session.n&&o.get("is_limited"),is_session_user:this.is_session_user,is_inactive:AoPS.session.n&&!o.get("is_activated")&&!o.get("is_banned"),is_banned:AoPS.session.n&&o.get("is_banned"),is_coppa_blocked:AoPS.session.n&&o.get("is_coppa_blocked"),avatar:o.get("avatar"),is_bookmarked:o.get("is_bookmarked"),lang_Message:e.Message,has_notes:!this.is_session_user&&o.has("user_notes")&&o.get("user_notes").length>0,notes:o.has("user_notes")?o.get("user_notes"):[],can_add_notes:o.has("can_add_notes")&&o.get("can_add_notes"),lang_User_Profile:e["user-profile-title"],lang_INACTIVE:e["user-profile-INACTIVE"],lang_LIMITED:e["user-profile-LIMITED"],lang_BANNED:e["user-profile-BANNED"],lang_COPPA:e["user-profile-COPPA"],lang_Activity:e["user-profile-activity"],lang_Notes:e.Notes,lang_AddNote:e["Add-Note"],lang_By:e.By,lang_At:e.At,lang_Note:e.Note,show_friends:i,can_edit_other_profiles:a,can_edit:this.is_session_user||a,lang_edit_profile:e["edit-profile-title"],lang_Friends:e["user-profile-friends"],can_befriend:o.get("can_befriend"),lang_Add_Friend:e["user-profile-add-friend"],title_add_friend:e["user-profile-add-friend-title"],title_pm:e["user-profile-pm-title"],can_add_friends:this.is_session_user&&o.get("can_request_friend"),can_troll_ban:o.get("can_troll_ban")})),this.is_session_user&&AoPS.isUserLimited()&&(this.limited_user_note=new t.LimitedUserMessage({}),this.$(".cmty-category-cell-heading").after(this.limited_user_note.$el)),this.$main_profile=this.$(".cmty-user-profile-main-info"),this.$activity=this.$(".cmty-user-profile-activity > .cmty-user-profile-data"),this.fillMainProfile(),o.has("top_fora")?this.buildActivityBox():(this.$activity_loader=AoPS.Page.buildLoader(),o.fetchTopFora({onFinish:function(){s.$activity_loader.detach(),s.buildActivityBox()},onError:function(){s.$activity_loader.detach()}})),this.is_session_user&&!this.model.get("friends_exclude")&&(this.$friends_public_toggle=this.$(".cmty-user-profile-friends-toggle"),this.setFriendsPublicToggle(),this.listenTo(o,"change:friends_show_profile",this.setFriendsPublicToggle),this.$friends_public_toggle.on("click",(function(){o.set("friends_show_profile",!o.get("friends_show_profile")),o.setUserSetting({value:o.get("friends_show_profile")?1:0,field:"friends_show_profile"})}))),i&&(this.$friends_box=this.$(".cmty-friends-box"),this.$loader=AoPS.Page.buildLoader(),o.get("friends_initialized")?(this.buildFriends(),this.startListeners()):(this.$friends_box.append(this.$loader),o.fetchFriends({fetch_type:"initial",onFinish:function(t){s.buildFriends(),s.startListeners()}})));var r=this.$el.find(".cmty-user-profile-blocked-users-list");r.length&&(o.fetchBlockedUsers(),this.listenTo(o,"change:blocked_users",(function(){r.html(""),r.append(t.buildBlockedUsersWidget(o))})),this.$el.find(".cmty-user-profile-blocked-users-wrapper a").click(t.showBlockUserModal.bind(this,o)));this.setBookmark(),this.listenTo(this.model,"change:is_bookmarked",this.setBookmark)},setBookmark:function(){var t,i,o,s;this.is_session_user||(t=this.$(".cmty-toggle-user-bookmark"),this.model.get("is_bookmarked")?(i="C",s=e["bookmark-remove"],o=e["bookmark-remove-user-title"]):(i="B",s=e["bookmark-follow"],o=e["bookmark-user-title"]),t.find(".aops-font").text(i),t.find(".cmty-user-bookmark-tagline").text(s),t[0].title=o)},setFriendsPublicToggle:function(){var t=this.model.get("friends_show_profile");this.$friends_public_toggle.text(t?"h":"#"),this.$friends_public_toggle[0].title=e[t?"user-profile-friend-toggle-off":"user-profile-friend-toggle-on"]},onAddToPage:function(){this.startListeners()},onRemoveFromPage:function(){this.stopListeners()},buildActivityBox:function(){var t=this,i=this.model;_.each(this.activity_settings,(function(o){var s,n,a=o.attribute;if(("last_visit_pretty"!==o.attribute||i.get("show_last_visit"))&&i.has(a)&&("number"==typeof i.get(a)||i.get(a).length>0)){if("primary_blog_id"==a){if(!(i.get(a)>0))return;n={is_html:!0,nowrap:t.compress_top_fora,has_fora:!1,content:'<a href="/community/c'+i.get(a)+'">'+i.get("primary_blog_name")+"</a>"}}else if("num_posts"===a&&(i.get("num_posts")>0||i.has("top_fora")&&i.get("top_fora").length>0)){var r=i.has("top_fora")?i.get("top_fora"):[];s=!_.isUndefined(_.findWhere(r,{in_count:!1}));var l=!_.isUndefined(_.findWhere(r,{has_search:!1}));if(t.compress_top_fora){var c=7-(i.get("show_last_visit")?1:0)-(i.get("primary_blog_id")>0?1:0)-(s||l);r=_.first(r,c)}n={is_html:!0,content:i.get(a)+' (<a data-cmty href="/community/u'+i.get("user_id")+'">'+e["user-profile-click-for-posts"]+"</a>)",has_fora:!0,user_id:i.get("user_id"),top_fora:r,nowrap:!1,has_count_note:s,lang_count_note:e["user-profile-no-count-note"],has_search_note:l,lang_search_note:e["user-profile-no-search-note"]};var d=0;_.each(r,(function(t){var e=t.total.toString().length;e>d&&(d=e)})),d<5&&t.$el.addClass("cmty-profile-"+d+"-digits")}else n={is_html:"boolean"==typeof o.is_html&&o.is_html,has_fora:!1,nowarp:!1,content:i.get(a)};n.title=e[o.title_lang_attr],AoPS.session.a&&("thanks_given"===o.attribute&&i.has("nothanks_given")&&(n.is_html=!0,n.content+=" ("+i.get("nothanks_given")+' <span class="aops-font">_</span>)'),"thanks_received"===o.attribute&&i.has("nothanks_received")&&(n.is_html=!0,n.content+=" ("+i.get("nothanks_received")+' <span class="aops-font">_</span>)')),"num_posts"===a&&(n.title="<span id='about-num-posts' class='faux-link aops-font'>?</span> "+n.title),t.$activity.append(t.getTemplate("#cmty-user-profile-data-row-tpl",n))}}))},fillMainProfile:function(){var i=this,s=this.model;this.$main_profile.empty(),_.each(this.main_profile_plain_settings,(function(n){var a;if("status"===n&&i.is_session_user&&!s.get("is_new_user"))a=t.buildEditableRow(i.constructEditableRowSettings(n)),i.model.get("master").fetchPermission("can_edit_profile")||a.renderUneditable(),i.$main_profile.append(a.$element);else if("primary_blog_id"===n){if(!(s.get(n)>0))return;i.$main_profile.append(i.getTemplate("#cmty-user-profile-data-row-tpl",{is_html:!1,has_fora:!1,nowrap:!1,title:e["user-profile-blog"],content:'<a href="/community/c'+s.get(n)+'">'+s.get("primary_blog_name")+"</a>"}))}else s.has(n)&&s.get(n).length>0&&i.$main_profile.append(i.getTemplate("#cmty-user-profile-data-row-tpl",{is_url:"website"===n,is_html:!1,nowrap:!1,url:"website"===n?o.formatUrl(s.get(n)):"",content:s.get(n),title:e["user-profile-"+n]}))}))},constructEditableRowSettings:function(s){var n=this;return{label:e["user-profile-"+s],placeholder:e["edit-profile-"+s+"-placeholder"],submit_on_enter:!0,content:n.model.get(s),length_limit:i.profile_field_length_limit,action:_.partial((function(i,s,a){"email"===i&&t.throwLoaderBlockingMessage(e["edit-profile-email-change=blocker"]),n.model.setUserSetting({field:i,value:s,set_from:n.location,onFinish:function(t){"email"===i&&(a.contents=n.model.get(i),a.reset(),AoPS.Ui.Modal.showAlert(o.formatString(e["edit-profile-new-email"],[s,n.model.get("email")]),{title:e["edit-profile-email-change-title"],width:"450px",onClose:function(){AoPS.Ui.Modal.closeAllModals()}}))},onCancel:function(){},onError:function(t){var r,l="flyout";switch(t.error_code){case"E_NAUGHTY_TERM_USED":r=o.formatString(e["edit-profile-inappropriate-term"],[a.label]);break;case"E_NO_PERMISSION":r=e["edit-profile-no-perm"];break;case"E_NOT_LOGGED_IN":r=e["edit-profile-not-logged-in"];break;case"E_EMAIL_NOT_AVAILABLE":r=o.formatString(e["edit-profile-email-not-available"],[s]),l="modal";break;case"E_INVALID_EMAIL":r=o.formatString(e["edit-profile-email-not-valid"],[s]),l="modal";break;case"E_EMAIL_NOT_CHANGED":r=o.formatString(e["edit-profile-email-not-valid"],[s]);break;case"E_AJAX_CANCEL":return void("email"===i?(a.contents=n.model.get(i),a.reset()):n.model.set(i,s));default:r=o.formatString(e["edit-profile-unknown-error"],[a.label,t.error_code])}a.contents=n.model.get(i),a.reset(),"flyout"===l?AoPS.Ui.Flyout.display(r):AoPS.Ui.Modal.showAlertQuick(r,{width:"450px",onClose:function(){AoPS.Ui.Modal.closeAllModals()}})}})}),s)}},buildFriends:function(){var i=this.model,o=this;this.$loader.detach(),0===i.get("friends").length?this.$friends_box.append(this.$no_friends):_.each(i.get("friends"),(function(t){o.$friends_box.append(o.buildFriendBox(t,!1))})),this.is_session_user&&i.get("friend_requests").length>0&&(this.$friend_requests_box=$('<div class="cmty-friend-requests-box"></div>'),this.$friend_requests_box.append('<div class="cmty-friend-requests-warning">'+e["friends-warning"]+"</div>"),this.$friend_requests_wrapper=t.buildCommunityScrollbar(this.$friend_requests_box),this.$friends_box.before(this.$friend_requests_wrapper),this.$friend_requests_wrapper.find(".aops-scroll-bar").on("slider_at_end",(function(){o.fetchMoreFriendRequests()})),_.each(i.get("friend_requests"),(function(t){o.$friend_requests_box.append(o.buildFriendBox(t,!0))})),this.setFriendRequestsStyle())},fetchMoreFriendRequests:function(){var t=this,e=this.model;e.get("loading_friends")||e.get("all_requests_loaded")||(t.$friend_requests_box.append(t.$loader),e.fetchFriends({fetch_type:"friend_requests",onFinish:function(i){t.$loader.detach(),_.each(i.friend_requests,(function(e){t.$friend_requests_box.append(t.buildFriendBox(e,!0))})),e.get("all_requests_loaded")&&t.$el.find(".aops-scroll-bar").off("slider_at_end")}}))},startListeners:function(){var t=this.model,e=this;!t.get("all_friends_loaded")&&t.get("friends").length>0&&$(window).on("scroll.user"+t.get("user_id")+" touchmove.user"+t.get("user_id"),(function(i){window.innerHeight+window.pageYOffset+50>=document.body.offsetHeight&&(t.get("loading_friends")||t.get("all_friends_loaded")||(e.$friends_box.append(e.$loader),t.fetchFriends({fetch_type:"friends",onFinish:function(i){e.$loader.detach(),_.each(i.loaded_friends,(function(t){e.$friends_box.append(e.buildFriendBox(t,!1))})),t.get("all_friends_loaded")&&$(window).off("scroll.user"+t.get("user_id")+" touchmove.user"+t.get("user_id"))}})))}))},stopListeners:function(){$(window).off("scroll.user"+this.model.get("user_id"))},buildFriendBox:function(i,o){var s=this,n=$(this.getTemplate("#cmty-friend-box-tpl",{avatar:i.avatar,username:i.username,is_admin:i.is_admin,is_request:o,message:o?e["user-profile-friend-request"]:i.status,lang_DECLINE:e["user-profile-friend-DECLINE"],lang_ACCEPT:e["user-profile-friend-ACCEPT"]}));return this.is_session_user&&!o&&n.find(".cmty-unfriend").on("click",(function(t){s.unFriend(i,n),t.stopPropagation()})),o&&(n.find(".cmty-friend-decline").on("click",(function(t){s.closeFriendRequest(i,n,"denied"),t.stopPropagation()})),n.find(".cmty-friend-accept").on("click",(function(t){s.closeFriendRequest(i,n,"accepted"),t.stopPropagation()}))),n.on("click.backbone",(function(e){t.followUrlOnClick(e,s.friend_click_path+i.user_id,s.router_base,"")})),n},closeFriendRequest:function(t,i,s){var a=this;this.model.closeFriendRequest({user_id:t.user_id,action:s,onFinish:function(i){"accepted"===s&&(a.$friends_box.prepend(a.buildFriendBox(i.new_friend_data,!1)),a.$no_friends.detach()),n.display(o.formatString(e["user-profile-friend-request-"+s],[t.username]))},onError:function(i){var s;s="E_NO_REQUEST_AVAILABLE"===i.error_code?o.formatString(e["user-profile-err-no-request-available"],[t.username]):o.formatString(e["err-unknown"],[i.error_code]),n.display(s)}}),i.fadeOut(500,(function(){i.remove()})),this.model.get("friend_requests").length<6&&!this.model.get("all_requests_loaded")&&this.fetchMoreFriendRequests(),this.setFriendRequestsStyle()},setFriendRequestsStyle:function(){var t=this.model.get("friend_requests").length;0===t&&this.model.get("all_requests_loaded")&&this.$friend_requests_wrapper.detach(),this.$friend_requests_wrapper.toggleClass("cmty-three-requests",3===t),this.$friend_requests_wrapper.toggleClass("cmty-many-requests",t>3)},onClickAboutNumPosts:function(t){alert("Only the user's top 8 forums are displayed. If one or more of this user's top forums is a private forum that you can't access, it will not be displayed to you.<br><br>Only posts in select forums count towards the \"Total Posts\" count. If one of a user's top forums is a forum where posts don't count towards the total, that forum will be marked with an asterisk (*) here.")},onClickMessage:function(e){if(t.launchNewPrivateMessage({user_id:this.model.get("user_id"),username:this.model.get("username"),is_admin:this.model.get("is_admin")}),!_.isUndefined(e))return e.stopPropagation(),e.preventDefault(),!1},onClickBan:AoPS.Community.Utils.onClickBan,onClickTroll:AoPS.Community.Utils.onClickTroll,onClickTempBan:function(t){var e=this;AoPS.Community.Utils.onClickTempBan(_.extend({user_id:this.model.get("user_id"),username:this.model.get("username"),success:function(i){$(t.target).text(i.can_access?"TEMP RESTRICT":"UNRESTRICT"),e.model.set("temp_ban",i)}},this.model.get("temp_ban")))},onClickResetThanks:function(t){AoPS.Community.MasterModel.resetThanks(t)},onClickCheckVPN:function(t){var e=t.currentTarget.getAttribute("ip");AoPS.Community.MasterModel.checkVPN({ip:e}),$(t.currentTarget).hide()},onClickAddNote:function(){var t=this.$('textarea[name="cmty-user-note-input"]').val(),i=this;t.length<5||(AoPS.Community.Views.throwBlockingMessage(e["user-profile-add-note"]),setTimeout((function(){i.model.addNote({note_text:t,onFinish:function(){location.reload()}})}),1e3))},onClickAddNewFriend:function(){var t,i,s,n=0,a=this;t=$(this.getTemplate("#cmty-add-friend-tpl",{lang_instructions:e["user-profile-add-friend-instructions"],lang_new_friend:e["user-profile-new-friend"],placeholder:e["Enter-username"]})),s=t.find("input"),o.buildUsernameAutocomplete(s,{ajax_call:"fetch_username_matches",autocomplete_settings:{onSelect:function(o,a){var r=t.find(".cmty-chosen-new-friend");parseInt(a.item.user_id)===AoPS.session.user_id?AoPS.Ui.Modal.showAlertQuick(e["user-profile-no-friend-self"],{onButtonClick:function(){s.val(""),s.focus()}}):(n=a.item.user_id,i=a.item.label,s.hide(),r.html(a.item.label),1==parseInt(a.item.is_admin)&&r.addClass("cmty-user-admin")),o.stopPropagation(),o.preventDefault()}}}),t.showModal({type:"confirm",title:e["user-profile-add-friend-modal-title"],width:"450px",close_on_button_click:!1,force_response:!0,onButtonClick:function(t){if(t){if(0===n){if(0===(n=s.val()).length)return AoPS.Ui.Modal.showAlert(e["user-profile-add-friend-none-chosen"]),void(n=0);i=n}a.sendFriendRequest(n,i)}else AoPS.Ui.Modal.closeAllModals()}}),s.focus()},onClickAddThisFriend:function(){var t=this;AoPS.Ui.Modal.showConfirm(o.formatString(e["user-profile-send-request-check"],[this.model.get("username")]),(function(e){e?t.sendFriendRequest(t.model.get("user_id"),t.model.get("username")):AoPS.Ui.Modal.closeAllModals()}),{close_on_button_click:!1,force_response:!0})},onClickBookmark:function(t){t.preventDefault(),t.stopPropagation(),AoPS.session.logged_in?AoPS.isUserLimited()?s.showMessage(e["bookmark-limited-user"],{width:"450px"}):this.model.get("master").setUserBookmarkState({user:this.model,new_state:!this.model.get("is_bookmarked")}):AoPS.Ui.buildLoginConfirm(e["bookmark-not-logged-in"])},sendFriendRequest:function(t,s){var n=this;AoPS.Community.Views.throwBlockingMessage(e["user-profile-friend-request-pending"]),this.model.get("master").submitFriendRequest({new_friend:t,onFinish:function(t){setTimeout((function(){AoPS.Ui.Modal.closeAllModals(),n.$el.find(".cmty-user-add-this-friend").remove()}),i.message_readability_delay)},onError:function(t){var n;switch(t.error_code){case"E_NO_PERMISSION_TO_REQUEST_FRIEND":n=e["user-profile-err-no-perm-friend"];break;case"E_ALREADY_FRIENDS":n=o.formatString(e["user-profile-err-already-friend"],[s]);break;case"E_NO_FRIEND_SELF":n=e["user-profile-no-friend-self"];break;case"E_REQUEST_FROM_POTENTIAL_EXISTS":n=o.formatString(e["user-profile-err-they-asked-you"],[s]);break;case"E_YOU_ALREADY_REQUESTED":n=o.formatString(e["user-profile-err-already-asked"],[s]);break;case"E_NOT_TAKING_FRIEND_REQUESTS":n=o.formatString(e["user-profile-err-not-taking-requests"],[s]);break;default:n=o.formatString(e["err-unknown"],[t.error_code])}setTimeout((function(){AoPS.Ui.Modal.showAlert(n,{onClose:function(){AoPS.Ui.Modal.closeAllModals()},width:"450px"})}),i.message_readability_delay)}})},unFriend:function(t,i){var s=this.model,n=this;AoPS.Ui.Modal.showConfirm(o.formatString(e["user-profile-unfriend-confirm"],[t.username]),(function(e){e&&(s.unFriend({user_id:t.user_id}),i.fadeOut(400,(function(){i.remove()})),0===s.get("friends").length&&n.$friends_box.append(n.$no_friends)),AoPS.Ui.Modal.closeAllModals()}),{confirm_button_ok:e.YES,confirm_button_cancel:e.NO})},onClose:function(){this.hasOwnProperty("limited_user_note")&&this.limited_user_note.close()}}),t.CategoryUserCell=AoPS.View.extend({template_id:"#cmty-bookmarked-user-cell-tpl",className:"cmty-category-cell cmty-category-cell-user",initialize:function(){this.render()},render:function(){this.$el.html(this.getTemplate(this.template_id,{username:this.model.get("username"),user_id:this.model.get("user_id"),can_befriend:this.model.get("can_befriend"),user_tooltip:e["user-cell-visit-profile"],lang_Add_Friend:e["user-profile-add-friend"],title_add_friend:e["user-profile-add-friend-title"],title_pm:e["user-profile-pm-title"],lang_Message:e.Message,can_pm:this.model.get("can_pm"),status:this.model.get("status")})),this.user_profile=new t.UserProfile({model:this.model,compress_top_fora:!0}),this.$(".cmty-category-cell-bottom").append(this.user_profile.$el)},events:{"click .cmty-user-cell-pm":"onClickMessage","click .cmty-add-cell-friend":"onClickAddNewFriend"},onClickMessage:t.UserProfile.prototype.onClickMessage,onClickAddNewFriend:t.UserProfile.prototype.onClickAddNewFriend}),t.EditUserProfile=AoPS.View.extend({template_id:"#cmty-edit-profile-tpl",className:t.UserProfile.prototype.className,location:"edit_user_profile",profile_fields:["email"].concat(_.without(t.UserProfile.prototype.main_profile_plain_settings,"joined_at")),initialize:function(){this.is_current_user=this.model===this.model.get("master").get("current_user"),this.render(),this.listenTo(this.model,"status_changed",this.onStatusChange)},render:function(){var o,s,n,a=this,r=this.model.get("is_new_user"),l=this.profile_fields.length,c=[];if(s=this.is_current_user?this.model.get("master").fetchPermission("can_edit_profile"):this.model.get("master").fetchPermission("can_edit_other_profiles"),this.$el.html(this.getTemplate(this.template_id,{is_current_user:this.is_current_user,user_id:this.model.get("user_id"),username:this.model.get("username"),is_limited_user:AoPS.isUserLimited(),lang_limited_user:e["edit-profile-limited-user"],is_new_user:AoPS.isUserNew(),lang_new_user:e["edit-profile-new-user"],lang_Edit_Profile:e["edit-profile-title"],lang_Profile_Info:e["edit-profile-profile-info"],lang_Edit_Avatar:e["edit-profile-edit-avatar"],lang_Delete_Avatar:e["edit-profile-delete-avatar"],lang_Change_Password:e["edit-profile-change-password"],lang_Current_Password:e["edit-profile-current-password"],lang_New_Password:e["edit-profile-new-password"],lang_Retype_Password:e["edit-profile-retype-password"],can_add_avatar:this.model.get("master").fetchPermission(this.is_current_user?"can_add_avatar":"can_edit_other_profiles"),has_avatar:this.model.get("avatar")!==i.default_avatar,retype_password_placeholder:e["edit-profile-retype-password-placeholder"],new_password_placeholder:e["edit-profile-new-password-placeholder"],current_password_placeholder:e["edit-profile-current-password-placeholder"],avatar:this.model.get("avatar"),password_length:i.max_password_length,lang_SUBMIT:e.Submit.toUpperCase()})),this.$profile=this.$(".cmty-user-profile-main-info"),this.$current_password=this.$('input[name="current-password"]'),this.$new_password=this.$('input[name="new-password"]'),this.$confirm_password=this.$('input[name="confirm-password"]'),this.$password_buttons=this.$(".cmty-password-buttons"),this.$password_warning=this.$(".cmty-password-warning"),this.$(":password").on("input",(function(){a.checkPasswordFields()})).on("keydown",(function(t){13===(t.which||t.keyCode)&&a.onClickSubmitPassword()})),!AoPS.isUserLimited())for(o=0;o<l;o++)if(n=this.profile_fields[o],!r||"email"===n){var d=t.buildEditableRow(t.UserProfile.prototype.constructEditableRowSettings.apply(this,[n]));s||"email"===n||d.renderUneditable(),c.push(d),("email"!==n||this.is_current_user)&&(c[o].$input.on("keydown",_.partial((function(t,e){13===(e.which||e.keyCode)&&c[(t+1)%l].$input.focus()}),o)),a.$profile.append(d.$element))}},events:{"click .cmty-password-submit":"onClickSubmitPassword","click .cmty-user-edit-avatar":"onClickEditAvatar","click .cmty-user-delete-avatar":"onClickDeleteAvatar"},emptyAllPasswordFields:function(){this.$current_password.val(""),this.$new_password.val(""),this.$confirm_password.val("")},checkPasswordFields:function(){var t=this.$current_password.val(),o=this.$new_password.val(),s=this.$confirm_password.val();return this.$password_buttons.hide(),this.$password_warning.hide(),0!==o.length&&0!==s.length&&(o!==s?(this.$password_warning.text(e["edit-profile-passwords-dont-match"]),this.$password_warning.show(),!1):0===t.length?(this.$password_warning.text(e["edit-profile-enter-password"]),this.$password_warning.show(),!1):s.length<i.min_password_length?(this.$password_warning.text(e["edit-profile-password-too-short"]),this.$password_warning.show(),!1):(this.$password_buttons.show(),!0))},onClickSubmitPassword:function(){var s=this,n=this.$current_password.val(),a=this.$new_password.val();this.$password_buttons.hide(),this.checkPasswordFields()&&(t.throwBlockingMessage(e["edit-profile-submit-new-password"]),s.emptyAllPasswordFields(),this.model.submitNewPassword({new_password:a,old_password:n,onFinish:function(i){t.delayModalClearing({onClose:function(){AoPS.Ui.Flyout.display(e["edit-profile-password-changed"])}})},onError:function(t){var n;switch(t.error_code){case"E_INVALID_PASSWORD":n=e["edit-profile-invalid-password"];break;case"E_INVALID_COMMON_PASSWORD":n=e["edit-profile-invalid-common-password"];break;default:n=o.formatString(e["edit-profile-unknown-error"],["password",t.error_code])}setTimeout((function(){AoPS.Ui.Modal.showAlertQuick(n,{width:"450px",onClose:function(){AoPS.Ui.Modal.closeAllModals(),s.$current_password.focus()}})}),i.message_readability_delay)}}))},onClickEditAvatar:function(){new t.EditAvatar({model:this.model})},onClickDeleteAvatar:function(){var t=this;s.showConfirm(o.formatString(e["edit-profile-delete-avatar-confirm"],[this.is_current_user?e["edit-profile-your"]:e["edit-profile-this-user"]]),(function(i){i?(s.replaceTopModal({type:"message",body:e["edit-profile-deleting-avatar"],closeX:!1,force_response:!0,frame_class:"aops-modal-quick"}),t.model.deleteAvatar({onError:function(t){},onFinish:function(t){location.reload()}})):s.closeAllModals()}),{title:e["edit-profile-delete-avatar"],close_on_button_click:!1})},onStatusChange:function(t){"edit_user_profile"!==t.set_from&&this.render()}}),t.EditAvatar=AoPS.View.extend({template_id:"#cmty-edit-avatar-tpl",className:"cmty-edit-avatar",initialize:function(){var i=this;this.$el.html(this.getTemplate(this.template_id,{lang_upload:e["edit-avatar-default-message"]})),this.$("#edit-avatar").dropzone({url:"/m/community/ajax.php",maxFiles:1,sending:function(t,e,o){o.append("a","upload_avatar"),o.append("aops_session_id",AoPS.session.id),o.append("user_id",i.model.get("user_id"))},thumbnailWidth:30,thumbnailHeight:30,resizeWidth:100,resizeHeight:100,accept:function(t,e){/[^a-zA-Z0-9\.\ \_\-]/.test(t.name)?e("err-invalid-character"):e()},fallback:function(){AoPS.Ui.Modal.showAlert(e["err-dropzone-fallback"],{width:"450px"}),setTimeout((function(){AoPS.Ui.Modal.closeTopModal()}),100)},maxFilesize:AoPS.Community.Constants.max_avatar_file_size/1e3,success:function(i,o){if(o.hasOwnProperty("error_code")){var s;switch(o.error_code){case"E_INVALID_SESSION_WRONG":s=e["err-no-such-session"];break;case"E_TOO_MANY_FILES":s=e["edit-avatar-too-many"];break;case"E_NO_FILE_SENT":s=e["edit-avatar-no-file"];break;case"E_IMAGE_DIMENSIONS_TOO_LARGE":s=e["edit-avatar-dimensions-too-big"];break;case"E_FILE_TOO_LARGE":s=e["edit-avatar-file-too-big"];break;case"E_NO_PERMISSION":s=e["edit-avatar-no-permission"];break;case"E_IMPROPER_AVATAR_FILE_TYPE":s=e["edit-avatar-bad-file-type"];break;case"E_IMPROPER_AVATAR_FILE_TYPE_APNG":s=e["edit-avatar-bad-file-type-apng"];break;default:s=e["unexpected-error-code"]+o.error_code}t.showErrorAtopAModal(s),this.removeFile(i)}else $(i.previewElement).addClass("dz-success"),location.reload()},error:function(i,o){"err-invalid-character"===o?t.showErrorAtopAModal(e["post-attachments-invalid-character"]):"File is too big"===o.substr(0,15)?t.showErrorAtopAModal(e["edit-avatar-file-too-big"]):"You can't upload files of this type"===o.substr(0,35)&&t.showErrorAtopAModal(e["edit-avatar-bad-file-type"]),this.removeFile(i)},acceptedFiles:"image/*"}),this.$el.showModal({title:e["edit-avatar-title"],width:"250px",frame_class:"aops-modal-standard cmty-upload-avatar-modal"})}}),t.edit_community_yn_options=[{value:"1",label:e.Yes},{value:"0",label:e.No}],t.EditCommunitySettings=AoPS.View.extend({className:"cmty-folder-top",template_id:"#cmty-edit-cmty-settings-tpl",sections:[{heading:e["edit-settings-general-heading"],settings:[{model_field:"hidden"},{model_field:"base_view",options:[{value:"main",label:e["edit-settings-main-base-view"]},{value:"portal",label:e["edit-settings-portal-base-view"]}]}]},{heading:e["edit-settings-friends-heading"],settings:[{model_field:"friends_show_profile"},{model_field:"friends_exclude",action:function(t,i,o){0===parseInt(t)?(i.model.setUserSetting({value:t,field:"friends_exclude"}),i.flashRow(o)):s.showConfirm(e["edit-settings-no-friends-confirm"],(function(e){e?(i.model.setUserSetting({value:t,field:"friends_exclude"}),i.flashRow(o)):o.find("select")[0].value="0"}),{width:"450px",title:e["edit-settings-no-friends-confirm-title"]})}}]},{heading:e["edit-settings-posting-heading"],settings:[{model_field:"posting_subscribe_new_topic"},{model_field:"posting_subscribe_reply"},{model_field:"posting_fullscreen_reply"},{model_field:"warn_on_snipes",options:[{value:"none",label:e.None},{value:"flyout",label:e.Flyout},{value:"modal",label:e.Popup}]},{model_field:"forum_view",options:[{value:"full",label:e.Tall},{value:"condensed",label:e.Short}],refresh_page:!0},{model_field:"turn_off_autotagging"},{model_field:"hide_avatars"},{model_field:"hide_tags_on_topic"}]},{heading:e["edit-settings-pm-heading"],settings:[{model_field:"pm_email"},{model_field:"pm_archive_on_send"},{model_field:"pm_live_notify",options:[{value:"none",label:e.None},{value:"flyout",label:e.Flyout},{value:"modal",label:e.Popup}]},{model_field:"pm_exclude_self"},{type:"link_w_label",action:function(t){s.showConfirm(e["edit-settings-archive-confirm"],(function(i){i&&(t.archiveAllPrivates(),AoPS.Ui.Flyout.display(e["edit-settings-privates-archived"]))}),{width:"450px"})},link_text:e["edit-settings-archive-pm-btn"],link_label:e["edit-settings-archive-pm-label"]},{type:"link_w_label",action:function(t){s.showConfirm(e["edit-settings-remove-confirm"],(function(i){i&&(t.removeFromAllPrivates(),AoPS.Ui.Flyout.display(e["edit-settings-privates-removed"]))}),{width:"450px"})},link_text:e["edit-settings-remove-from-pm-btn"],link_label:e["edit-settings-remove-from-pm-label"]}]},{heading:e["edit-settings-feed-heading"],settings:[{model_field:"hide_feed"},{model_field:"show_tags_on_feed"},{model_field:"global_feed_type",options:[{value:"full",label:e.Full},{value:"custom",label:e.Custom}],refresh_page:!0}]}],initialize:function(){this.appendBookmarkSections(),this.appendBlockedUsersSection(),this.render(),this.listenTo(this.model,"change:friends_show_profile",this.render),this.listenTo(this.model,"change:blocked_users",this.render)},appendBookmarkSections:function(){var i=this;_.each(["topics","forums","tags"],(function(n){var a={};a.heading=o.formatString(e["edit-settings-bkmk-heading"],[n]),a.settings=[],_.each(["all","feed","email"],(function(i){var r;r={type:"link_w_label",link_text:e["edit-settings-bkmk-link-"+i],link_label:o.formatString(e["edit-settings-bkmk-"+i+"-label"],[n]),action:function(a){s.showConfirm(o.formatString(e["edit-settings-bkmk-"+i+"-confirm"],[n]),(function(o){o?(t.throwBlockingMessage(e["edit-settings-please-wait-bkmk"]),a.clearBookmarks({bookmark_section:n,clear_type:i,onFinish:function(){setTimeout((function(){location.reload()}),1e3)}})):s.closeAllModals()}),{width:"450px",close_on_button_click:!1})}},a.settings.push(r)})),i.sections.push(a)}))},appendBlockedUsersSection:function(){var e={heading:"Blocked users",settings:[{type:"link_w_label",link_text:"Add User",link_label:"Add a user to your list of blocked users. (Blocks private messages.)",action:t.showBlockUserModal},{type:"blocked_users_list"}]};this.model&&this.model.fetchBlockedUsers&&this.model.fetchBlockedUsers(),this.sections.push(e)},render:function(){var i,o=this,s=0;this.$el.html(this.getTemplate(this.template_id,{lang_Page_Title:e["edit-settings-page-title"]})),_.each(this.sections,(function(n){var a=$(o.getTemplate("#cmty-user-profile-card-tpl",{title:n.heading})),r=a.find(".cmty-user-profile-data");s%2==0&&(i=$('<div class="cmty-user-profile-row"></div>'),o.$el.append(i)),i.append(a),s++,_.each(n.settings,(function(i){var s,n,a,l;l=_.extend({type:"select",bold:!1,refresh_page:!1},i),a=i.hasOwnProperty("action")?function(t){i.action(t,o,n)}:function(t){o.model.setUserSetting({value:t,field:l.model_field,onFinish:function(){l.refresh_page&&location.reload()}}),o.flashRow(n)},"select"===l.type?(s=o.model.get(l.model_field),n=t.buildSelectRow({options:l.hasOwnProperty("options")?l.options:t.edit_community_yn_options,bold:l.bold,selected:"boolean"==typeof s?String(Number(s)):s,action:a,text:e["edit-settings-"+l.model_field+"-label"]})):"link_w_label"===l.type?n=t.buildLinkLabelRow({bold:l.bold,link_text:l.link_text,link_label:l.link_label,action:function(){l.action(o.model)}}):"blocked_users_list"===l.type&&(n=t.buildBlockedUsersWidget(o.model)),r.append(n)}))}))},events:{"click a.cmty-advanced-hotkeys":"onClickHotkeys"},onClickHotkeys:function(t){this.hasOwnProperty("hotkeys_modal")||(this.hotkeys_modal=this.getTemplate("#cmty-advanced-hotkeys-modal-tpl",{})),s.showMessage(this.hotkeys_modal,{title:e["edit-settings-hotkeys-modal-title"],width:"600px"}),t.stopPropagation(),t.preventDefault()},flashRow:function(t){t.addClass("cmty-select-row-flash").removeClass("cmty-select-row-flash",1e3)}}),t.buildBlockedUsersWidget=function(t){var e=t.get("blocked_users")||[];return $("<ul class='cmty-user-profile-blocked-users'></ul>").append(e.map((function(e){var i=$("<span class='cmty-user-profile-blocked-user-username'></span>").text(e.username),o=$("<span class='aops-font cmty-user-profile-blocked-user-unblock'>J</span>").click((function(){t.unblockUser({blocked_user_id:e.user_id,blocked_username:e.username}),s.hide()})),s=$("<li class='cmty-user-profile-blocked-user-row'></li>").append(i).append(o);return s})))},t.buildBlockUserForm=function(){var t=$("<div class='cmty-user-profile-block-user-form'></div>"),e=$("<input class='cmty-user-profile-block-user-input' type='text'></input>");return t.append($("<p>Enter the user you would like to block. You will no longer see PMs from this user.</p>")).append($("<p>If you are in any group PMs with this user, you will lose access to those PMs.</p>")).append($("<span>Username: </span>")).append(e),o.buildUsernameAutocomplete(e,{ajax_call:"fetch_username_matches",autocomplete_settings:{onSelect:function(t,i){var o=i.item.user_id;e.attr("data-user-id",o)}}}),t},t.showBlockUserModal=function(e){var i=s.showButtonsQuick(t.buildBlockUserForm(),[{text:"Block",value:1},{text:"Cancel",value:0}],(function(t){if(t){var o=i.$obj.find(".cmty-user-profile-block-user-input").attr("data-user-id"),n=i.$obj.find(".cmty-user-profile-block-user-input").val();(o||n)&&e.blockUser({blocked_user_id:o,blocked_username:n,onError:function(t){var e="An error occurred while trying to block this user.";"E_CANNOT_BLOCK_SELF"===t.error_code?e="You cannot block yourself!":"E_CANNOT_BLOCK_STAFF"===t.error_code?e="You cannot block admins or staff.":"E_TOO_MANY_BLOCKS"===t.erro_code&&(e="You have reached the maximum number of blocked users."),s.showAlertQuick(e)}})}}),{title:"Block User"})},t.FAQ=AoPS.View.extend({className:"cmty-faq-panel",initialize:function(){this.$loader=AoPS.Page.buildLoader(),this.$el.append(this.$loader),this.render()},render:function(){var t=this;this.$el.cmtyLoadFromFile({filename:AoPS.bootstrap_data.datastore_path+"cms/community/lang_en/help.html",onFinish:function(){t.$loader.detach(),t.$(".grey-panel .header").add(".grey-panel .toggle").on("click",(function(t){$(this).parent().toggleClass("closed")}))}})}}),t.Memberlist=AoPS.View.extend({template_id:"#cmty-memberlist-master-tpl",className:"cmty-memberlist",initialize:function(t){this.render(),this.stub=t.stub,this.user_list=new AoPS.Community.Models.UserList({stub:this.stub}),this.all_users={},this.$loader=AoPS.Page.buildLoader(),this.$no_matches=$('<div class="cmty-memberlist-none">'+e["memberlist-no-matches"]+"</div>"),this.startMemberlist(),this.$input.val(this.stub),this.setArrows()},render:function(){var t=this,i=AoPS.Community.MasterModel.fetchStaffPermission("see-full-memberlist"),o=AoPS.Community.MasterModel.fetchPermission("can_temp_ban");this.$el.html(this.getTemplate(this.template_id,{lang_page_title:e["memberlist-page-title"],lang_user_search:e["memberlist-user-search"],lang_Username:e.Username,lang_placeholder:e["memberlist-user-search-placeholder"],lang_search_button:e.SEARCH,has_email:i||o,has_IP:i,has_VPN_check:i,lang_Joined:e["memberlist-joined"],lang_Last_Visit:e["memberlist-last-visit"],lang_Email:e.Email,lang_IP:e.IP,lang_Posts:e["memberlist-posts"],lang_Thanks:e["memberlist-thanks"],tooltip_posts:e["memberlist-posts-tooltip"],tooltip_thanks:e["memberlist-thanks-tooltip"]})),this.$input=this.$("input"),this.$table=this.$("table > tbody"),this.$input.on("keydown",(function(e){13===(e.which||e.keyCode)&&t.buildFromInput()}))},events:{"click .cmty-user-search-row .btn":"buildFromInput","click th.clickable":"onClickTableHead","click span.cmty-ban-link":"onClickBan","click span.cmty-troll-link":"onClickTroll","click span.cmty-temp-ban-link":"onClickTempBan","click .cmty-vpn-check":"onClickCheckVPN"},startMemberlist:function(){0===this.user_list.get("users").length?this.fetchMoreUsers():this.addUsers(this.user_list)},addUsers:function(t){var e=this,i=AoPS.Community.MasterModel.fetchStaffPermission("see-full-memberlist"),o=AoPS.Community.MasterModel.fetchPermission("can_temp_ban");_.each(t,(function(t){e.all_users[t.user_id]=t})),this.$table.append(this.getTemplate("#cmty-memberlist-rows-tpl",{users:t,has_email:i||o,has_IP:i,has_VPN_check:i}))},onAddToPage:function(){var t=this;this.$input.focus(),$(window).on("scroll",(function(){document.documentElement.clientHeight+$(document).scrollTop()>=document.body.offsetHeight-80&&t.fetchMoreUsers()}))},onRemoveFromPage:function(){$(window).off("scroll")},onClickTableHead:function(t){var e,i=t.currentTarget.getAttribute("sort-on");e=i!==this.user_list.get("sort_column")?this.getDefaultDirection(i):"ASC"===this.user_list.get("sort_direction")?"DESC":"ASC",this.rebuildList({sort_column:i,sort_direction:e})},getDefaultDirection:function(t){return"username"===t||"joined_at"===t?"ASC":"DESC"},fetchMoreUsers:function(){var t=this;this.user_list.get("all_fetched")||this.user_list.get("is_loading")||(this.$el.append(this.$loader),this.user_list.fetchMoreUsers({onFinish:function(e){t.$loader.detach(),e.hasOwnProperty("new_users")&&e.new_users.length>0&&t.addUsers(e.new_users),0==t.user_list.get("users").length&&t.$el.append(t.$no_matches)}}))},buildFromInput:function(){var t=this.user_list.get("sort_column");this.rebuildList({sort_column:t,sort_direction:this.user_list.get("sort_direction")})},rebuildList:function(t){t.stub=this.$input.val(),this.$no_matches.detach(),t.stub===this.user_list.get("stub")&&t.sort_direction===this.user_list.get("sort_direction")&&t.sort_column===this.user_list.get("sort_column")||(this.$table.empty(),this.user_list.destroy(),this.user_list=new AoPS.Community.Models.UserList(t),this.fetchMoreUsers(),this.setArrows())},setArrows:function(){var t=this.user_list.get("sort_direction"),e=this.user_list.get("sort_column");this.$table.parent().find("th .aops-font").remove(),this.$table.parent().find('[sort-on="'+e+'"]').append('<span class="aops-font">'+("DESC"===t?" S":" T"))},onClickBan:AoPS.Community.Utils.onClickBan,onClickTroll:AoPS.Community.Utils.onClickTroll,onClickTempBan:function(t){var e=t.currentTarget.getAttribute("user_id"),i=this.all_users[e];i&&AoPS.Community.Utils.onClickTempBan(_.extend({user_id:i.user_id,username:i.username,success:function(e){$(t.target).text(e.can_access?"RESTRICT":"UNRESTRICT"),i.temp_ban=e}},i.temp_ban))},onClickCheckVPN:function(t){var e=t.currentTarget.getAttribute("ip");AoPS.Community.MasterModel.checkVPN({ip:e}),$(t.currentTarget).hide()}}),t.getCategoryAdminCatType=function(t){if("forum_class"===t)t="forum";return t},t.fetchCategoryAdminBlocks=function(t){var e=[];switch(t){case"forum":case"forum_class":e=["GeneralInfo","Permissions"];break;case"blog":e=["GeneralInfo","Permissions","BlogSettings","BlogCss"];break;case"view_tags":e=["GeneralInfo","Permissions","ContentsViewTags"];break;case"view_posts":e=["GeneralInfo","Permissions","ContentsViewPosts"];break;case"view_topics":e=["GeneralInfo","Permissions","ContentsViewTopics"];break;case"blogroll":e=["GeneralInfo","Permissions","ContentsBlogroll"];break;case"folder":e=["GeneralInfo","Permissions","ContentsFolder"];break;case"folder_forums":e=["GeneralInfo","Permissions","ContentsFolderForums"];break;case"folder_collections":e=["GeneralInfo","Permissions","ContentsFolderCollections"];break;case"my_forums":case"my_blogs":case"my_collections":e=["GeneralInfo","ContentsFolder"];break;case"bookmark_topics":e=["GeneralInfo","ContentsViewTopics"];break;case"bookmark_users":e=["GeneralInfo","ContentsBookmarkUsers"];break;case"bookmark_tags":e=["GeneralInfo","ContentsViewTags"];break;case"bookmark_forums":e=["GeneralInfo","ContentsFolderForums"]}return e=_.map(e,(function(t){return"CategoryAdminBlock"+t}))},t.CategoryAdmin=AoPS.View.extend({className:"cmty-category-admin",initialize:function(t){this.model.get("category_type"),this.is_building_new=0===this.model.get("category_id"),this.is_creating=!1,this.render()},render:function(){var i,o=this;this.constructTitle(),(i=t.fetchCategoryAdminBlocks(t.getCategoryAdminCatType(this.model.get("category_type")))).length,o.block_views=[],_.each(i,(function(e){var i=new t[e]({model:o.model});o.$el.append(i.$el),o.block_views.push(i)})),this.is_building_new&&this.$el.append('<div class="buttons"><button class="cmty-create-category btn btn-primary">'+e["cat-admin-create-button"]+"</button></div>")},events:{"click .cmty-create-category":"onClickCreate"},onClickCreate:function(){var t,i=this.block_views.length,o=this;if(!this.is_creating){for(this.is_creating=!0,t=0;t<i;t++)if(!this.block_views[t].validateNewCategorySettings())return void(this.is_creating=!1);AoPS.Ui.Modal.showConfirm(e["cat-admin-create-"+(this.model.get("is_public")?"public":"private")+"-"+this.model.getAdminLangType()+"-warning"],(function(t){t?o.createNewCategory():(o.is_creating=!1,AoPS.Ui.Modal.closeAllModals())}),{width:"450px",confirm_button_cancel:"NO!",confirm_button_ok:"YES!",close_on_button_click:!1})}},createNewCategory:function(){var i=this;AoPS.Ui.Modal.replaceTopModal({type:"message",body:e["cat-admin-create-category-blocker"],frame_class:"aops-modal-quick",force_response:!0,closeX:!1}),this.is_creating=!1,this.model.burnNewCategory({onFinish:function(e){var o;o=i.checkIfOneMoreStep()?"/community/category-admin/"+e.category_id:"/community/c"+e.category_id+"_"+t.convertToUrlFragment(i.model.get("category_name")),window.location.replace(o)},onError:function(t){var s;if(_.isUndefined(e["cat-admin-error-"+t.error_code]))s=e["unexpected-error-code"]+t.error_code;else switch(s=e["cat-admin-error-"+t.error_code],t.error_code){case"E_NOT_LOGGED_IN":case"E_NO_PERMISSION":s=s+o.displayCategoryType(i.model.get("category_type"))+".";break;case"E_NO_SUCH_CATEGORY_TYPE":s+=i.model.get("category_type")}AoPS.Ui.Modal.showAlertQuick(s,{width:"450px",onClose:function(){AoPS.Ui.Modal.closeAllModals()}})}})},checkIfOneMoreStep:function(){return-1===_.indexOf(["forum","forum_class","blog"],this.model.get("category_type"))},constructTitle:function(){},onClose:function(){_.each(this.block_views,(function(t){t.close()}))}}),t.CategoryAdminTitleBar=AoPS.View.extend({initialize:function(){var t=0===this.model.get("category_id"),i=o.displayCategoryType(this.model.get("category_type")),s=!1,n=0;this.model.has("class_id")&&(s=!0,n=this.model.get("class_id")),t?this.$el.html(this.getTemplate("#cmty-build-new-cat-heading-tpl",{lang_Type:o.capitalizeFirstLetter(e[i]),lang_Create:e.Create})):this.$el.html(this.getTemplate("#cmty-cat-info-page-heading-tpl",{lang_Type:o.capitalizeFirstLetter(e[i]),lang_TYPE:e[i].toUpperCase(),has_push_state_attr:"blog"!==this.model.get("category_type"),lang_Info:e.Info,category_id:this.model.get("category_id"),return_target:this.getUrlEnd(),name:this.model.get("category_name"),lang_BACK_TO:e["Back-to"].toUpperCase(),lang_button_class:e["cat-admin-back-to-class"],lang_button_cmty:e["cat-admin-back-to-cmty"],class_id:n,has_class:s}))},getUrlEnd:function(){switch(this.model.get("category_type")){case"my_collections":return"my-collections";case"my_forums":return"my-forums";case"my_blogs":return"my-blogs";default:return"c"+this.model.get("category_id")}}}),t.CategoryAdminBlockGeneralInfo=AoPS.View.extend({template_id:"#cmty-category-admin-general-info-tpl",className:"aops-panel cmty-cat-admin-gen-info",initialize:function(){var t,o=this.model.getAdminLangType(),s=0===this.model.get("category_id"),n=this.model.getPermission("c_can_edit_core_data"),a=!s&&this.model.getPermission("c_can_delete_category"),r=!s&&this.model.getPermission("c_can_hard_delete_cat"),l=!s&&this.model.getPermission("c_can_settle_report"),c=!s&&this.model.get("master").fetchPermission("can_access_log"),d=a||r||c||l,h=this,m="";a&&r?m=e["cat-admin-soft-delete"]:a&&(m=e["cat-admin-delete"]),t=!s&&("forum"===this.model.get("category_type")||"forum_class"===this.model.get("category_type"))&&AoPS.session.logged_in&&"custom"===this.model.get("master").get("feed").get("global_feed_type");var p="";this.model.get("short_description").length>0?p=this.model.get("short_description"):n||(p=e["cat-admin-no-description"]),this.$el.html(this.getTemplate(this.template_id,{title:e["cat-admin-general-info"],description_heading:e["cat-admin-description-heading"],can_edit_core_data:n,lang_view_log:e["cat-admin-view-log"],category_id:this.model.get("category_id"),lang_name_warning:e["cat-admin-cat-name-warning"],category_name:this.model.get("category_name"),category_description:p,has_admin_row:d,can_settle_reports:l,lang_reported_posts:e["cat-admin-reported-posts"],can_soft_delete:a,lang_soft_delete:m,lang_hard_delete:e["cat-admin-hard-delete"],can_hard_delete:r,can_access_log:c,has_buttons:n&&!s,name_heading:e["cat-admin-"+o+"-name"],name_placeholder:e["cat-admin-"+o+"-name-placeholder"],description_placeholder:e["cat-admin-"+o+"-desc-placeholder"],max_name_length:i.max_category_name_length,max_description_length:i.max_category_description_length,Save:e.Save,Reset:e.Reset,can_edit_global_feed:t,global_feed_heading:e["cat-admin-in-global-feed"],lang_Yes:e.Yes,lang_No:e.No,is_class_forum:"forum_class"===this.model.get("category_type"),lang_automatically_included:e["cat-admin-global-automatic"],lang_see_faq:e["cat-admin-global-feed-help"],is_in_global_feed:t&&_.indexOf(this.model.get("master").get("feed").get("global_feed_fora"),this.model.get("category_id"))>-1})),n&&(this.$category_name=this.$el.find('input[name="collection-name"]'),this.$category_description=this.$el.find('input[name="collection-description"]'),s||(this.$footer=this.$el.find(".footer"),this.$category_name.add(this.$category_description).on("input",(function(){h.activateSaveButton()}))),this.cacheData()),!s&&this.model.get("is_forum")&&this.model.getPermission("c_can_edit_admin_items")&&(this.$el.append('<div class="cmty-admin-only-line">'+e["cat-admin-admin-item-warning"]+"</div>"),_.each(["include_in_count","include_in_thank_count","include_in_nothank_count","include_in_dynamic_collections"],(function(t){h.buildEditableBitSetting(t)})))},hasSystemColor:function(){var t=_.pluck(e["cat-admin-category-colors"],"color");return _.indexOf(t,this.model.get("main_color").toLowerCase())>-1},prepareColors:function(){var t=_.clone(e["cat-admin-category-colors"]),i=this.model.get("main_color").toLowerCase();return _.each(t,(function(t){t.checked=i===t.color})),t},buildSettingGroup:function(t){return $('<div class="form-group"><div><label>'+e["cat-admin-label-"+t]+"</label></div>")},buildStaticSetting:function(t){var i=this.buildSettingGroup(t),o=this.model.get(t);"boolean"==typeof o&&(o=o?e.Yes:e.No),i.append("<div>"+o+"</div>"),this.$el.append(i)},buildEditableBitSetting:function(i){var o=this,s=this.buildSettingGroup(i),n=$(this.getTemplate("#yes-no-select-tpl",{value:this.model.get(i),Yes:e.Yes,No:e.No}));n.on("change",(function(e){t.EditCommunitySettings.prototype.flashRow(n.parent().parent()),o.updateBitSetting(i,e.target.options[e.target.selectedIndex].value)})),s.append($("<div></div>").append(n)),this.$el.append(s)},updateBitSetting:function(t,e){this.model.setAdminItemSetting({setting:t,value:parseInt(e)}),this.model.set(t,1==parseInt(e))},events:{"click .cmty-cat-admin-gen-save":"onClickSave","click .cmty-cat-admin-gen-reset":"onClickReset","click .cmty-soft-delete-cat":"onClickSoftDelete","click .cmty-hard-delete-cat":"onClickHardDelete",'change select[name="cmty-cat-admin-global-feed-setting"]':"onChangeGlobalFeedSetting"},onClickReset:function(){this.resetToCachedData(),this.$footer.hide()},onChangeGlobalFeedSetting:function(){var t;t=this.$('select[name="cmty-cat-admin-global-feed-setting"]').val(),this.model.updateGlobalFeedSetting({new_setting:t,onFinish:function(){location.reload()},onError:function(t){var i;i=e.hasOwnProperty("cat-admin-global-err-"+t.error_code)?e["cat-admin-global-err-"+t.error_code]:e["err-unknown"],AoPS.Ui.Modal.showAlert(i,{width:"450px",onClose:function(){location.reload()}})}})},onClickSoftDelete:function(){this.onClickDelete("soft")},onClickHardDelete:function(){this.onClickDelete("hard")},onClickDelete:function(i){var n=this;s.showConfirm(o.formatString(e["cat-admin-"+i+"-delete-confirm"],[this.model.get("category_name")]),(function(o){o?(t.throwLoaderBlockingMessage(e["cat-admin-delete-blocker"]),setTimeout((function(){n.model.delete({delete_type:i,onFinish:function(t){window.location.href="/community"},onError:function(i){var o;switch(i.error_code){case"E_PROTECTED":o=e["cat-admin-delete-protected"];break;case"E_CATEGORY_NOT_FOUND":o=e["cat-admin-delete-not-found"];break;case"E_NO_PERMISSION":o=e["cat-admin-delete-no-permission"];break;default:o=e["unexpected-error-code"]+i.error_code}t.showError(o)}})}),1e3)):s.closeAllModals()}),{width:"450px",close_on_button_click:!1})},cacheData:function(){this.cached_name=this.$category_name.val(),this.cached_description=this.$category_description.val()},resetToCachedData:function(){this.$category_name.val(this.cached_name),this.$category_description.val(this.cached_description)},activateSaveButton:function(){this.$footer.show()},onClickSave:function(){var o=this;this.validateNewCategorySettings()&&(t.throwLoaderBlockingMessage(e["saving-blocker"]),this.$footer.hide(),this.model.saveCoreDataToDb({onFinish:function(){setTimeout((function(){AoPS.Ui.Modal.closeAllModals(),o.cacheData(),AoPS.Ui.Flyout.display(e["data-saved-reload"])}),i.message_readability_delay_short)},onError:function(t){var i;i="E_NO_PERMISSION"===t.error_code?e["cat-admin-gen-info-error-E_NO_PERMISSION"]:e["cat-admin-error-"+t.error_code],i+="<br><br>"+e["cat-admin-error-nothing-saved"],AoPS.Ui.Modal.showAlert(i,{width:"450px",onClose:function(){AoPS.Ui.Modal.closeAllModals(),o.activateSaveButton()}})}}))},validateNewCategorySettings:function(){return this.$category_name.val().length<i.min_category_name_length?(AoPS.Ui.Modal.showAlertQuick(e["cat-admin-"+o.simplifyCategoryType(this.model.get("category_type"))+"-name-too-short"]),!1):(this.model.set("category_name",this.$category_name.val()),this.model.set("short_description",this.$category_description.val()),!0)}}),t.CategoryAdminBlockPermissions=AoPS.View.extend({template_id:"#cmty-category-admin-permissions-tpl",className:"aops-panel cmty-cat-admin-perm-panel",initialize:function(){this.is_new=0===this.model.get("category_id"),this.is_new&&this.model.get("users").push({user_id:AoPS.session.user_id,username:AoPS.session.username,is_admin:AoPS.session.a,role:"owner"}),this.isUserPermissionAvailable()||AoPS.session.a?(this.user_box_views=[],this.render(),this.listenTo(this.model,"change:is_public change:is_locked change:has_source",this.setHelpers),this.buildHelper()):this.$el.html(this.getTemplate("#cmty-category-admin-permissions-private-coll-tpl",{title:e["cat-admin-permissions-title"],explanation:e["cat-admin-private-collection-perms"]}))},buildHelper:function(){var t=this.category_type_specific_settings.help_template_id;this.$help=$(this.getTemplate(t,{}))},render:function(){var t,i=this.model.getPermission("c_can_lock_category");t="forum"===this.model.get("category_type")?"forum":"blog"===this.model.get("category_type")?"blog":"collection",this.category_type_specific_settings=this.fetchRenderData(),this.$el.html(this.getTemplate(this.template_id,{is_new:this.is_new,header_text:e["cat-admin-permissions-header-"+t],title:e["cat-admin-permissions-title"],lang_private:e.Private,can_edit_public:this.is_new||this.model.getPermission("c_can_change_is_public"),lang_public:e.Public,public_private_heading:e["cat-admin-permissions-public-heading"],is_locked_heading:e["cat-admin-permissions-is-locked"],can_lock:i,lang_open:e["cat-admin-permissions-open"],lang_locked:e["cat-admin-permissions-locked"],is_public:this.model.get("is_public"),is_locked:this.model.get("is_locked"),has_source_toggle:!this.is_new&&"forum"==this.model.get("category_type")&&this.model.getPermission("c_can_edit_core_data"),has_source_heading:e["cat-admin-permissions-has-source"],inheritance_heading:e["cat-admin-permissions-inherit-head"],lang_No:e.No,lang_Yes:e.Yes,has_source:this.model.get("has_source"),can_set_inheritance:!this.is_new&&this.model.getPermission("c_can_set_role_inherit")})),this.$is_locked=this.$el.find('select[name="cmty-category-admin-is-locked"]'),"forum"===this.model.get("category_type")&&(this.$has_source=this.$el.find('select[name="cmty-category-admin-has-source"]')),this.is_new&&(this.$is_public=this.$el.find('select[name="cmty-category-admin-is-public"]')),this.addUserBoxes(),this.setHelpers(),this.model.getPermission("c_can_set_role_inherit")&&(this.$role_inheritance=this.$(".cmty-category-admin-role-inherit"),this.listenTo(this.model,"change:role_inheritance_parent",this.constructRoleInheritance),this.constructRoleInheritance())},events:{'change select[name="cmty-category-admin-is-public"]':"onChangeIsPublic",'change select[name="cmty-category-admin-is-locked"]':"onChangeIsLocked",'change select[name="cmty-category-admin-has-source"]':"onChangeSource","click .cmty-cat-admin-help":"onClickHelp"},onClickHelp:function(){this.$help.showModal({frame_class:"cmty-cat-admin-helper-modal aops-modal-standard",title:e["cat-admin-perms-help-title"],width:"600px",scrollable:!0})},onChangeIsPublic:function(){var i,o=this;i="blog"===this.model.get("category_type")?this.model.get("is_public")?"cat-admin-set-blog-private-warning":"cat-admin-set-blog-public-warning":"cat-admin-is-public-confirm-warning",this.is_new?(this.model.set("is_public",1===parseInt(this.$is_public.val())),this.addUserBoxes()):s.showConfirm(e[i],(function(i){i?(t.throwBlockingMessage(e["cat-admin-is-public-blocker"]),o.model.toggleIsPublic({onFinish:function(t){location.reload()},onError:function(t){var i;i="E_NO_PERMISSION"===t.error_code?e["cat-admin-gen-info-error-E_NO_PERMISSION"]:e["cat-admin-error-"+t.error_code],i+="<br><br>"+e["cat-admin-error-nothing-saved"],AoPS.Ui.Modal.showAlert(i,{width:"450px",onClose:function(){AoPS.Ui.Modal.closeAllModals(),o.resetIsPublic()}})}})):s.closeAllModals()}),{close_on_button_click:!1,width:"550px",onClose:function(){o.resetIsPublic()}})},constructRoleInheritance:function(){this.model.has("role_inheritance_parent")&&!_.isNull(this.model.get("role_inheritance_parent"))?this.renderInheritanceParent():this.renderInheritanceInput(),this.$role_inheritance.append('<div class="cmty-cat-admin-inherit-info"><span class="cmty-category-admin-helper">'+o.formatString(e["cat-admin-inheritance-info"],[o.simplifyCategoryType(this.model.getAdminLangType())])+"</span></div>")},check_can_remove:!0,can_remove_all:!1,url_cmty_path:"",push_state_attribute:"data-cmty",url_router_base:"/community",constructItem:t.Itembox.prototype.constructItem,renderInheritanceParent:function(){var t=$('<span class="aops-font clickable">J</span>'),e=this;this.$role_inheritance.empty(),this.$role_inheritance.append(this.constructItem(this.model.get("role_inheritance_parent"))),this.$role_inheritance.prepend(t),t.on("click",(function(){e.removeInheritanceParent()})).css({color:this.model.get("role_inheritance_parent").item_main_color})},removeInheritanceParent:function(){this.model.set("role_inheritance_parent",null),this.model.get("category_id")>0&&this.model.removeInheritanceParent()},renderInheritanceInput:function(){var i=this;this.$role_inheritance.empty(),this.$role_inheritance_input=$('<input type="text">'),this.$role_inheritance.append(this.$role_inheritance_input),o.buildCategoryAutocomplete(this.$role_inheritance_input,{ajax_call:"fetch_inherits_from_autocomplete",additional_ajax_settings:{category_id:this.model.get("category_id"),category_type:this.model.get("category_type")},autocomplete_settings:{onSelect:function(o,s){0===i.model.get("category_id")?i.model.set("role_inheritance_parent",{item_id:s.item.category_id,item_text:s.item.label,item_type:s.item.category_type,item_forum_id:s.item.item_forum_id,item_main_color:s.item.main_color,item_secondary_color:s.item.secondary_color,item_can_remove:!1,item_subtitle:s.item.short_description}):(t.throwLoaderBlockingMessage(e["cat-admin-set-role-inherit"]),i.model.setRoleInheritanceParent({parent_id:s.item.category_id,onFinish:function(t){window.location.href="/community/category-admin/"+i.model.get("category_id")},onError:function(t){var i;switch(t.error_code){case"E_NO_PERMISSION":i=e["cat-admin-set-inherit-no-perm"];break;case"E_INVALID_PARENT_TYPE":i=e["cat-admin-set-inherit-invalid-parent"];break;case"E_CANT_INHERIT_FROM_SELF":i=e["cat-admin-no-inherit-from-self"];break;default:i=e["unexpected-error-code"]+t.error_code}AoPS.Community.Views.showError(i)}})),o.stopPropagation(),o.preventDefault()}},show_no_results_msg:!0})},resetIsPublic:function(){this.$('select[name="cmty-category-admin-is-public"]').val(this.model.get("is_public")?1:0)},onChangeIsLocked:function(){this.model.setLockedStatus({is_locked:1===parseInt(this.$is_locked.val())})},onChangeSource:function(){this.model.setHasSource({has_source:1===parseInt(this.$has_source.val())})},addUserBoxes:function(){var i=this,n=this.model.get("is_public"),a=this.$el.find(".cmty-category-admin-users");if(a.empty(),this.closeUserBoxes(),!n){if(this.is_new&&"folder"===this.model.get("category_type"))return;if(!this.is_new&&!AoPS.session.a&&_.indexOf(["folder","folder_forums","folder_collections"],this.model.get("category_type"))>-1)return}_.each(this.category_type_specific_settings.user_boxes,(function(r){var l=$('<div class="form-group"></div>'),c=null;n&&r.show_if_category_public||!n&&r.show_if_category_private?(l.append("<div><label>"+r.title+"</label></div>"),i.model.getPermission("c_can_edit_"+r.role)?c=new t.ToggleableUserListCategoryAdmin({role:r.role,model:i.model}):r.show_only_if_can_edit||(c=new t.StaticUserList({is_editable:!1,no_users_message:"owner"===r.role?e["cat-admin-site-admins-are-admins"]:e["cat-admin-no-users-with-this-role"],user_list:_.filter(i.model.get("users"),(function(t){return t.role===r.role})),onMatchLoggedInUser:function(n,a){var l;i.model.get("can_remove_self")&&(l=$(' <span class="cmty-delete-item aops-font">J</span>'),n.find("span").append(l),l.on("click",(function(n){s.showConfirm(o.formatString(e["cat-admin-permissions-remove-self"],[r.title,i.model.get("category_name")]),(function(o){o?(t.throwBlockingMessage(e["please-wait"]),i.model.removeUser({user_id:a.user_id,onFinish:function(){setTimeout((function(){location.reload()}),500)},onError:function(i){t.showError(e["unexpected-error-code"]+i.error_code)}})):s.closeAllModals()}),{width:"450px",close_on_button_click:!1}),n.stopPropagation(),n.preventDefault()})))}})),_.isNull(c)||(i.user_box_views.push(c),l.append(c.$el),a.append(l))):i.model.removeUsersByRole(r.role)})),this.isUserPermissionAvailable()?(this.$(".cmty-cat-admin-perm-is-locked").show(),this.$(".cmty-category-admin-users").show(),this.$(".cmty-cat-admin-perm-set-inheritance").show()):(this.$(".cmty-cat-admin-perm-is-locked").hide(),this.$(".cmty-category-admin-users").hide(),this.$(".cmty-cat-admin-perm-set-inheritance").hide())},isUserPermissionAvailable:function(){return this.model.get("is_public")||_.indexOf(i.categories_with_private_roles,this.model.get("category_type"))>-1},closeUserBoxes:function(){_.each(self.user_box_views,(function(t){t.close()}))},fetchRenderData:function(){var t={show_if_category_public:!0,show_if_category_private:!0,show_only_if_can_edit:!1};switch(this.model.get("category_type")){case"forum":case"forum_class":return{public_helper:e["cat-admin-permissions-forum-public-helper"],private_helper:e["cat-admin-permissions-forum-private-helper"],locked_helper:e["cat-admin-permissions-forum-locked-helper"],open_helper:e["cat-admin-permissions-forum-open-helper"],has_source_helper:e["cat-admin-permissions-forum-has-source-helper"],no_source_helper:e["cat-admin-permissions-forum-no-source-helper"],user_boxes:[_.defaults({title:e.Administrators,role:"owner",box_class:"cmty-cat-admin-administrators"},t),_.defaults({title:e.Moderators,role:"mod",box_class:"cmty-cat-admin-moderators"},t),_.defaults({title:e.Users,role:"registered_user",box_class:"cmty-cat-admin-users",show_if_category_public:!1},t),_.defaults({title:e.Banned,role:"deny",box_class:"cmty-cat-admin-banned-users",show_if_category_private:!1,show_only_if_can_edit:!0},t)],help_template_id:"#cmty-cat-admin-perm-forum-help-tpl"};case"blog":return{public_helper:e["cat-admin-permissions-blog-public-helper"],private_helper:e["cat-admin-permissions-blog-private-helper"],locked_helper:e["cat-admin-permissions-blog-locked-helper"],open_helper:e["cat-admin-permissions-blog-open-helper"],help_template_id:"#cmty-cat-admin-perm-blog-help-tpl",user_boxes:[_.defaults({title:e.Administrators,role:"owner",box_class:"cmty-cat-admin-administrators"},t),_.defaults({title:e.Contributors,role:"contributor",box_class:"cmty-cat-admin-contributors"},t),_.defaults({title:e.Readers,role:"reader",box_class:"cmty-cat-admin-readers",show_if_category_public:!1},t),_.defaults({title:e.Banned,role:"deny",box_class:"cmty-cat-admin-banned-users",show_if_category_private:!1,show_only_if_can_edit:!0},t)]};case"my_forums":case"my_collections":return{public_helper:e["cat-admin-permissions-collection-public-helper"],private_helper:e["cat-admin-permissions-collection-private-helper"],locked_helper:e["cat-admin-permissions-collection-locked-helper"],open_helper:e["cat-admin-permissions-collection-open-helper"],help_template_id:"#cmty-cat-admin-perm-collection-help-tpl",user_boxes:[_.defaults({title:e.Administrators,role:"owner",box_class:"cmty-cat-admin-administrators"},t)]};default:return{public_helper:e["cat-admin-permissions-collection-public-helper"],private_helper:e["cat-admin-permissions-collection-private-helper"],locked_helper:e["cat-admin-permissions-collection-locked-helper"],open_helper:e["cat-admin-permissions-collection-open-helper"],help_template_id:"#cmty-cat-admin-perm-collection-help-tpl",user_boxes:[_.defaults({title:e.Administrators,role:"owner",box_class:"cmty-cat-admin-administrators"},t),_.defaults({title:e.Moderators,role:"mod",box_class:"cmty-cat-admin-moderators"},t),_.defaults({title:e.Users,role:"registered_user",box_class:"cmty-cat-admin-users",show_if_category_public:!1},t),_.defaults({title:e.Banned,role:"deny",box_class:"cmty-cat-admin-banned-users",show_if_category_private:!1,show_only_if_can_edit:!0},t)]}}},setHelpers:function(){var t=this.model.get("is_public")?this.category_type_specific_settings.public_helper:this.category_type_specific_settings.private_helper,i=this.model.get("is_locked")?this.category_type_specific_settings.locked_helper:this.category_type_specific_settings.open_helper,o=this.model.get("is_locked")?"k":"2";this.$el.find(".cmty-category-admin-is-public-helper").html(t),this.$el.find(".cmty-category-admin-is-locked-helper").html(i),this.$el.find(".cmty-category-lock-status").html(o),this.$(".cmty-cat-admin-locked-label").html(this.model.get("is_locked")?e["cat-admin-permissions-locked"]:e["cat-admin-permissions-open"]),"forum"===this.model.get("category_type")&&this.$(".cmty-category-admin-has-source-helper").html(this.model.get("has_source")?this.category_type_specific_settings.has_source_helper:this.category_type_specific_settings.no_source_helper)},onClose:function(){this.closeUserBoxes()},validateNewCategorySettings:function(){return!0}}),t.CategoryAdminBlockContents=AoPS.View.extend({template_id:"#cmty-category-admin-contents-new-tpl",className:"aops-panel cmty-cat-admin-contents",can_additems_in_admin:!0,initialize:function(){_.indexOf(["bookmark_topics","bookmark_forums","bookmark_tags","my_forums","my_collections","my_blogs","view_posts","view_topics","view_tags"],this.model.get("category_type"))>-1?this.has_help=!0:this.has_help=!1,this.has_help&&(this.$help=$(this.getTemplate("#cmty-cat-admin-contents-"+this.model.get("category_type")+"-help-tpl",{}))),this.is_bookmark=this.model.get("is_bookmark_category"),0===this.model.get("category_id")?this.renderConstructingCollection():(this.$loader=AoPS.Page.buildLoader(),this.edit_window_created=!1,this.render()),this.listenTo(this.model,"item_added",this.onClickCancel)},renderConstructingCollection:function(){this.$el.html(this.getTemplate("#cmty-category-admin-contents-info-tpl",{title:e["cat-admin-contents-title"],info:e["cat-admin-contents-building-info"]}))},render:function(){var i=this.model.canAddItem(),o=this.model.canRemoveItem();this.$el.html(this.getTemplate(this.template_id,{can_edit_items:i||o,title:e["cat-admin-contents-title"],has_help:this.has_help,lang_help:e["cat-admin-contents-help-tooltip"],title_editing:e["cat-admin-contents-title-editing"],lang_description:e["cat-admin-contents-desc-heading"],lang_contents_desc:e["cat-admin-contents-desc-"+this.model.get("category_type")],show_sort_type:i||o,lang_current_state:e["cat-admin-contents-current-state"],lang_sort_heading:e["cat-admin-contents-sort-heading"],lang_sort_type:this.model.getSortDescription(this.model.get("item_sort_type")),lang_edit_contents:e["cat-admin-contents-edit-btn"]})),this.$contents=this.$(".cmty-cat-admin-contents-current-state"),this.$edit_contents=this.$(".cmty-cat-admin-edit-window"),this.cat_cell=new(t.fetchCategoryCellConstructor(this.model.get("category_type")))({model:this.model}),this.$contents.append(this.cat_cell.$el)},events:{"click .cmty-admin-edit-contents-btn":"onClickEdit","click .cmty-cat-admin-help":"onClickHelp","click .cmty-cat-admin-edit-cancel":"onClickCancel","click .cmty-cat-admin-edit-save":"onClickSave","click .cmty-cat-admin-available-tab":"onClickAvailableTab","click .cmty-cat-admin-edit-tab":"onClickEditTab"},onClickHelp:function(){this.$help.showModal({frame_class:"cmty-cat-admin-helper-modal aops-modal-standard",title:e["cat-admin-contents-help-title"],width:"600px",scrollable:!0})},onClickEdit:function(){this.edit_window_created||(t.throwBlockingMessage(e["cmty-cat-admin-edit-contents-fetch"]),this.constructEditContents()),this.$edit_contents.show(),this.$el.addClass("cmty-editing-contents"),this.setFocus()},setFocus:function(){var t=this.$('input[type="text"]');t.length>0&&t.first().focus()},onClickCancel:function(){this.hasOwnProperty("$edit_contents")&&(this.$edit_contents.empty(),this.$edit_contents.hide()),this.$el.removeClass("cmty-editing-contents"),this.model.unset("items_for_edit"),this.edit_window_created=!1},onClickSave:function(){var i=this.model.getPermission("c_can_change_sort_type"),s=this,n=this.getSortType();"manual"===n&&this.resortModelItemEdits(),t.throwLoaderBlockingMessage(e["cat-admin-contents-save-blocker"]),this.model.saveItemEdits({change_sort_type:i&&this.$sort_type.val()!==this.model.get("item_sort_type"),sort_type:n,onError:function(t){var i;if("E_CATEGORY_LOCKED"===t.error_code)return AoPS.Ui.Modal.showAlert(e["cat-admin-contents-locked-error"]),s.model.set("is_locked",!0),void s.onClickCancel();i=e["cat-admin-contents-save-error"],"string"==typeof e["cat-admin-contents-save-error-"+t.error_code]?i+=e["cat-admin-contents-save-error-"+t.error_code]:i+=o.formatString(e["cat-admin-contents-unexpected-error"],[t.error_code]),AoPS.Ui.Modal.showAlert(i,{width:"450px",onButtonClick:function(){}})},onFinish:function(){location.reload()}})},resortModelItemEdits:function(){var t=[];this.$edit_items.find(".cmty-admin-contents-edit-row").each((function(e){t.push($(this).data("row_obj").item)})),this.model.set("items_for_edit",t)},constructEditContents:function(){var t=this.model.canAddItem(),i=this;this.$edit_contents.html(this.getTemplate("#cmty-category-admin-edit-contents-tpl",{can_add_items:t,lang_sort_heading:e["cat-admin-contents-sort-heading"],can_change_sort:this.model.getPermission("c_can_change_sort_type"),lang_save:e.Save.toUpperCase(),lang_cancel:e.Cancel.toUpperCase(),category_title:this.model.get("category_name"),category_desc:this.model.get("short_description"),is_my_category:this.model.get("is_my_category"),lang_current_items:e["cat-admin-contents-current-tab"],lang_available_items:e["cat-admin-contents-available-tab"]})),this.model.getPermission("c_can_change_sort_type")&&(this.$sort_type=this.$edit_contents.find('select[name="cmty-item-sort-type"]'),_.each(this.model.get("allowed_item_sort_types"),(function(t){var e=i.model.getSortDescription(t),o='<option value="'+t+'" '+(i.model.get("item_sort_type")===t?"selected":"")+">"+e+"</option>";i.$sort_type.append(o)})),this.$sort_type.on("change",(function(){i.onSortTypeChange()}))),this.$edit_items_header=this.$edit_contents.find(".cmty-cat-admin-content-items-header"),this.$edit_items=this.$edit_contents.find(".cmty-cat-admin-contents-edit-list"),this.edit_window_created=!0,this.model.get("is_my_category")&&t&&(this.$available_items=this.$edit_contents.find(".cmty-cat-admin-available-item-list")),this.constructEditableItems(),this.setSortableStatus(),this.can_additems_in_admin&&t&&!this.model.get("is_my_category")&&!this.is_bookmark&&(this.$items_input=this.$edit_contents.find(".cmty-cat-admin-add-item"),this.constructItemsInput())},onSortTypeChange:function(){this.sortRows(),this.setSortableStatus()},setSortableStatus:function(){"manual"===this.getSortType()?this.$edit_items.sortable():this.$edit_items.is(":ui-sortable")&&this.$edit_items.sortable("destroy")},getSortType:function(){return this.model.getPermission("c_can_change_sort_type")?this.$sort_type.val():this.model.get("item_sort_type")},sortRows:function(){var t=this.$edit_items.find(".cmty-admin-contents-edit-row"),e=this.getSortType(),i=this,o=function(t){return 0};"abc"===e?o=function(t){return $(t).data("row_obj").item.item_text.toLowerCase()}:"system"===e?o=function(t){return parseInt(-$(t).data("row_obj").item.item_score)}:"manual"===e&&(o=function(t){return parseInt(-$(t).data("row_obj").item.item_level)});var s=_.sortBy(t,o);_.each(s,(function(t){i.$edit_items.append($(t))}))},sortAvailableRows:function(){var t=this.$available_items.find(".cmty-admin-contents-edit-row"),e=this,i=_.sortBy(t,(function(t){return $(t).data("row_obj").item.item_text.toLowerCase()}));_.each(i,(function(t){e.$available_items.append($(t))}))},constructEditableItems:function(){var t=this;this.$edit_items.append(this.$loader),this.model.fetchItemsForEdit({onFinish:function(){t.$loader.detach(),t.renderItems(),$(window).scrollTop(t.$el.offset().top),setTimeout((function(){s.closeAllModals()}),700)},onError:function(){}})},constructAvailableItems:function(){var t=this;_.each(this.model.get("available_items"),(function(e){var i;i=t.constructAvailableRow(e),t.$available_items.append(i.$row)}))},onClickAvailableTab:function(){this.$edit_items.hide(),this.$available_items.show(),this.$edit_contents.find(".cmty-cat-admin-available-tab").addClass("active-tab"),this.$edit_contents.find(".cmty-cat-admin-edit-tab").removeClass("active-tab")},onClickEditTab:function(){this.$edit_items.show(),this.$available_items.hide(),this.$edit_contents.find(".cmty-cat-admin-edit-tab").addClass("active-tab"),this.$edit_contents.find(".cmty-cat-admin-available-tab").removeClass("active-tab")},renderItems:function(){var t=this;_.each(this.model.get("items_for_edit"),(function(e){var i;i=t.constructRow(e),t.$edit_items.append(i.$row)})),this.model.get("is_my_category")&&this.constructAvailableItems()},constructRow:function(t){var i,o,s,n=this.constructItem(t),a={item:t,$item:n},r=this;return a.$row=$('<div class="cmty-admin-contents-edit-row"></div>'),this.model.canRemoveItem()&&((i=$('<div title="'+e["cmty-admin-delete-item"]+'" class="cmty-delete-item aops-font">J</div>')).on("click",(function(e){r.deleteItem(t)})),a.$row.append(i)),this.model.get("is_bookmark_category")&&((o=$('<div class="cmty-edit-bookmark"><label title="'+e["cat-admin-contents-subscribe"]+'"><input type="checkbox" '+(t.is_watched?"checked":"")+'><span class="aops-font">D</span></label></div>')).find("input").on("change",(function(e){t.edit_state="edited",t.is_watched=this.checked?1:0})),(s=$('<div class="cmty-edit-bookmark"><label title="'+e["cat-admin-contents-feed"]+'"><input type="checkbox" '+(t.in_feed?"checked":"")+'><span class="aops-font">E</span></label></div>')).find("input").on("change",(function(e){t.edit_state="edited",t.in_feed=this.checked?1:0})),a.$row.append(o),a.$row.append(s)),a.$row.data("row_obj",a),a.$row.append(a.$item),a},fetchRowByItem:function(t,e){var i,o,s=t.find(".cmty-admin-contents-edit-row"),n=s.length;for(i=0;i<n;i++)if(o=$(s[i]).data("row_obj").item,e.item_id===o.item_id&&e.item_forum_id===o.item_forum_id&&e.item_type===o.item_type)return $(s[i]).data("row_obj");return null},addItem:function(t){var i,n,a,r=this;if(!this.model.canAddEditItems())return setTimeout((function(){s.showAlert(o.formatString(e["cat-admin-contents-limit-exceeded"],[r.model.get("item_limit")]))}),10),!0;if(0===t.item_id||_.isUndefined(i=this.model.fetchEditItem(t)))this.model.get("is_my_category")&&this.removeFromAvailableItems(t),"view_posts"===this.model.get("category_type")?this.addNewItem(t):(a=this.fetchRowByItem(this.$edit_items,t),t.edit_state="added",_.isNull(a)?this.addNewItem(t):(this.model.addToEditItems(t),a.$row.show()));else{if("deleted"!==i.edit_state)return n="view_posts"===this.model.get("category_type")?o.formatString(e["cat-admin-view_posts-already-holds"],[t.item_id]):t.item_text,AoPS.Ui.Modal.showAlertQuick(o.formatString(e["cat-admin-contents-already-holds"],[n]),{onClose:function(){s.closeAllModals()}}),!1;"view_posts"===this.model.get("category_type")?this.addNewItem(t):(i.edit_state="saved",a=this.fetchRowByItem(this.$edit_items,t),_.isNull(a)?this.addNewItem(a):a.$row.show()),this.model.get("is_my_category")&&this.removeFromAvailableItems(t)}return!0},addNewItem:function(t){var e=this.constructRow(t);this.model.addToEditItems(t),this.addNewRow(e)},addNewRow:function(t){this.$edit_items.append(t.$row),"manual"!==this.getSortType()&&this.sortRows(),this.resortModelItemEdits()},deleteItem:function(t){var e=this.fetchRowByItem(this.$edit_items,t);"deleted"!==t.edit_state&&(this.model.deleteEditItem(t),"added"===t.edit_state?_.isNull(e)||e.$row.remove():e.$row.fadeOut(200),this.model.get("is_my_category")&&this.addToAvailableItems(t))},addToAvailableItems:function(t){var e=this.fetchRowByItem(this.$available_items,t);this.model.addToAvailableItems(t),_.isNull(e)&&(e=this.constructAvailableRow(t)),this.$available_items.append(e.$row),this.sortAvailableRows()},removeFromAvailableItems:function(t){var e=this.fetchRowByItem(this.$available_items,t);_.isNull(e)||e.$row.remove(),this.model.removeAvailableItem(t)},constructItem:t.Itembox.prototype.constructItem,constructItemsInput:function(){},url_router_base:"/community",push_state_attribute:"data-cmty",url_cmty_path:"",check_can_remove:!1,validateNewCategorySettings:function(){return!0}}),t.CategoryAdminBlockContentsViewTopics=t.CategoryAdminBlockContents.extend({constructItem:function(t){var i;return(i=$('<div class="cmty-cat-admin-topic-item"><div class="cmty-cat-admin-topic-title"><a data-cmty href="/community/h'+t.item_id+'">'+t.item_text+'</a></div><span class="cmty-cat-admin-in"> '+e.in+' </span><div class="cmty-cat-admin-topic-forum">'+t.item_category_name+"</div></div>")).css({color:t.item_main_color}),i.find("a").css({color:t.item_main_color}),i},constructItemsInput:function(){var t=this;this.$items_input.empty(),this.$items_input.append('<div class="cmty-admin-new-contents-add-head">'+e["cat-admin-add-heading-topic"]+'</div><input type="text" class="cmty-admin-new-contents-view_topics cmty-admin-new-contents-category"\t\t\t\t\tplaceholder="'+e["cat-admin-add-content-topic-placeholder"]+'"><button class="btn btn-primary">'+e.Submit+"</button>"),this.$items_input.find("input").on("keydown",(function(e){13==(e.which||e.keyCode)&&t.onSubmitTopic()})),this.$items_input.find("button").on("click",(function(e){t.onSubmitTopic()}))},onSubmitTopic:function(){var i,o=this.$items_input.find("input").val(),n=this,a=0;/^[1-9]\d*$/.test(o)?a=parseInt(o):(i=o.split("/"),o=(o=i[i.length-1]).match(/(?:h\d+)/),_.isNull(o)||(a=parseInt(o[0].substring(1)))),0===a?(this.$items_input.find("input").val(""),s.showAlert(e["cmty-admin-add-topic-error"],{width:"450px"})):(this.$items_input.find("input").val(""),t.throwLoaderBlockingMessage(e["cmty-admin-add-topic-blocker"]),this.model.fetchTopicEditItem({topic_id:a,onFinish:function(t){n.addItem(t.topic_item)&&s.closeAllModals()},onError:function(i){var o;switch(i.error_code){case"E_TOPIC_PRIVATE":o=e["cmty-admin-add-topic-err-private"];break;case"E_NOT_FORUM_TOPIC":o=e["cmty-admin-add-topic-err-not-forum"];break;case"E_NO_SUCH_TOPIC":o=e["cmty-admin-add-topic-err-no-topic"];break;case"E_NO_PERMISSION":o=e["cmty-admin-add-topic-err-no-permission"];break;default:o=e["unexpected-error-code"]+i.error_code}t.showError(o)}}))}}),t.CategoryAdminBlockContentsViewPosts=t.CategoryAdminBlockContents.extend({post_views:[],post_types:{forum_post:{has_label:!0,has_post:!0,has_hide:!1,has_custom:!1},forum_hidden_post:{has_label:!1,has_post:!0,has_hide:!0,has_custom:!1},custom_text:{has_label:!0,has_post:!1,has_hide:!1,has_custom:!0},custom_hidden_text:{has_label:!1,has_post:!1,has_hide:!0,has_custom:!0}},constructItem:function(e){var i,o=$('<div class="cmty-cat-admin-edit-post-view"></div>');return i=t.ItemboxPosts.prototype.constructItem.apply(this,[e]),o.append(i),o},constructItemsInput:function(){var t,e=this;t=$(this.getTemplate("#cmty-category-admin-add-post-tpl",{max_label_length:i.view_post_max_label_len,max_hide_label_length:i.view_post_max_hide_label_len})),this.$items_input.empty(),this.$items_input.removeClass("cmty-cat-admin-edit-row"),this.$items_input.append(t),this.$items_input.find("select").on("change",(function(t){e.setupPostType(this.value)})),this.setupPostType("forum_post"),this.$items_input.find("button").on("click",(function(t){e.processItemInput()}))},setFocus:function(){this.setupPostType("forum_post")},setupPostType:function(t){var e=this.$(".cmty-admin-new-"+t);this.$(".cmty-admin-new-post-option").hide(),e.show(),e.find("input").first().focus()},processItemInput:function(){var o,n,a=this.$('select[name="cmty-cat-admin-post-type"]').val(),r=this.$(".cmty-admin-new-"+a),l=this,c="",d=0,h="",m="",p="",u=this.post_types[a];u.has_label&&(c=r.find('input[name="cmty-admin-new-contents-post-label"]').val()).length>i.view_post_max_label_len&&(p="E_LABEL_TOO_LONG"),u.has_post&&(o=r.find('input[name="cmty-admin-new-contents-post"]').val(),/^[1-9]\d*$/.test(o)?d=parseInt(o):(n=o.split("/"),o=(o=n[n.length-1]).match(/(?:p\d+)/),_.isNull(o)||(d=parseInt(o[0].substring(1))),0===d&&(p="E_INVALID_POST_ID"))),u.has_hide&&(h=r.find('input[name="cmty-admin-new-contents-hidden-text"]').val()).length>i.view_post_max_hide_label_len&&(p="E_HIDE_LABEL_TOO_LONG"),u.has_custom&&0===(m=r.find('textarea[name="cmty-admin-new-contents-custom-text"]').val()).length&&(p="E_NO_CUSTOM_TEXT_ENTERED"),""===p?(t.throwLoaderBlockingMessage(e["cat-admin-post-construct-blocker"]),this.model.createViewPostItem({post_type:a,post_label:c,post_id:d,hide_label:h,custom_text:m,onFinish:function(t){l.addItem(t.new_item)&&s.closeAllModals(),l.$('input[type="text"]').val(""),l.$("textarea").val("")},onError:function(t){l.processError(t.error_code)}})):this.processError(p)},processError:function(i){var o;o="string"==typeof e["cmty-admin-new-post-error-"+i]?e["cmty-admin-new-post-error-"+i]:e["unexpected-error-code"]+i,t.showError(o)}}),t.CategoryAdminBlockContentsViewTags=t.CategoryAdminBlockContents.extend({constructItem:function(i){this.category_id=i.item_forum_id;var o=t.Itembox.prototype.constructItem.apply(this,[i]),s=$('<div class="cmty-cat-admin-view_tags-tag"><span class="cmty-cat-admin-in">'+e.in+' </span><span class="cmty-cat-admin-view_tags-forum">'+i.item_category_name+"</span></div>");return s.css({color:i.item_main_color}),s.prepend(o),this.category_id=this.model.get("category_id"),s},constructItemsInput:function(){var t=this,i={};this.$items_input.empty(),this.$items_input.append('<div class="cmty-admin-new-contents-add-head">'+e["cat-admin-add-heading-"+this.model.get("category_type")]+'</div><input type="text" class="cmty-admin-new-contents-category"\t\t\t\t\tplaceholder="'+e["cat-admin-add-content-tag-forum-placeholder"]+'">'),this.model.get("is_public")&&(i.is_public_setting=1),o.buildCategoryAutocomplete(this.$items_input.find("input"),{ajax_call:"fetch_forum_autocomplete",additional_ajax_settings:i,autocomplete_settings:{onSelect:function(e,i){t.buildTagInput({item_id:i.item.category_id,item_text:i.item.label,item_type:i.item.category_type,item_forum_id:i.item.item_forum_id,item_main_color:i.item.main_color,item_secondary_color:i.item.secondary_color,item_can_remove:i.item.can_remove,item_subtitle:i.item.short_description}),e.stopPropagation(),e.preventDefault()}},show_no_results_msg:!0})},buildTagInput:function(t){var i,o=this;this.$items_input.empty(),this.$items_input.html(this.getTemplate("#cmty-cat-admin-add-content-tags-tpl",{lang_Forum:e.Forum,lang_Tag:e.Tag,tag_placeholder:e["cat-admin-contents-tag-placeholder"]})),this.current_forum=t,this.category=this.model.get("master").fetchCategory(t.item_id),_.isUndefined(this.category)&&(this.category=this.model.get("master").constructTemporaryCategory({category_type:t.item_type,category_id:t.item_id,main_color:t.item_main_color,secondary_color:t.item_secondary_color,category_name:t.item_text})),i=AoPS.Community.Views.Itembox.prototype.constructItem.apply({push_state_attribute:"data-cmty",check_can_remove:!0,can_remove_all:!0,url_router_base:"/community",url_cmty_path:"",onClickDelete:function(){o.onClickCloseForum()}},[t]),this.$items_input.find(".cmty-cat-admin-contents-add-tag-forum").append(i),this.$input_box=this.$items_input.find("input"),AoPS.Community.Views.buildTagAutocomplete({$input_box:this.$input_box,show_no_results_msg:!0,model:this.category,submitNewItem:function(e){var i;if("/open"===e.label.substr(0,5)&&(e.label=t.item_text),e.item_id>0){var s={in_feed:0,is_watched:0,item_category_name:t.item_text,item_forum_id:parseInt(e.item_forum_id),item_id:parseInt(e.item_id),item_level:0,item_main_color:e.main_color,item_secondary_color:e.secondary_color,item_text:e.label,item_type:"tag"};o.addItem(s),o.buildTagInput(t)}else i=o.$input_box.val(),o.buildTagInput(t),o.$input_box.val(i)}}),this.$input_box.focus()},onClickCloseForum:function(t){this.constructItemsInput(),this.$items_input.find("input").focus()}}),t.CategoryAdminBlockContentsFolder=t.CategoryAdminBlockContents.extend({new_contents_autocomplete_ajax:"fetch_add_contents_categories_autocomplete",constructAvailableRow:function(t){var e,i=this.constructItem(t),o={item:t,$item:i},s=this;return o.$row=$('<div class="cmty-admin-contents-edit-row"></div>'),this.model.getPermission("c_can_add_item")&&((e=$('<div class="cmty-add-available-item aops-font">+</div>')).on("click",(function(e){s.addItem(t)})),o.$row.append(e)),o.$row.data("row_obj",o),o.$row.append(o.$item),o},constructItemsInput:function(){var t=this,i={};this.$items_input.append('<div class="cmty-admin-new-contents-add-head">'+e["cat-admin-add-heading-"+this.model.get("category_type")]+'</div><input type="text" class="cmty-admin-new-contents-category"\t\t\t\tplaceholder="'+e["cat-admin-add-content-"+this.model.get("category_type")+"-placeholder"]+'">'),this.$new_item_input=this.$items_input.find("input"),this.model.get("is_public")&&(i.is_public_setting=1),o.buildCategoryAutocomplete(this.$new_item_input,{ajax_call:this.new_contents_autocomplete_ajax,additional_ajax_settings:i,autocomplete_settings:{onSelect:function(e,i){t.parsePotentialNewContents({item_id:i.item.category_id,item_text:i.item.label,item_type:i.item.category_type,item_forum_id:i.item.item_forum_id,item_main_color:i.item.main_color,item_secondary_color:i.item.secondary_color,item_can_remove:i.item.can_remove,item_level:0,item_score:i.item.last_post_time,item_subtitle:i.item.short_description,item_is_public:i.item.is_public,edit_state:"added",id:0}),e.stopPropagation(),e.preventDefault()}},show_no_results_msg:!0})},parsePotentialNewContents:function(t){t.item_id===this.model.get("category_id")?AoPS.Ui.Modal.showAlertQuick(e["cat-admin-contents-no-adding-to-self"]):this.addItem(t),this.$new_item_input.val(""),this.$new_item_input.focus()},onAddItemError:function(t,i){"E_CATEGORY_LOCKED"===t.error_code?(AoPS.Ui.Modal.showAlert(e["cat-admin-contents-locked-error"]),this.model.set("is_locked",!0),this.render()):AoPS.Ui.Flyout.display(o.formatString(e["cat-admin-contents-add-category-error"],[i.item_text,t.error_code])),this.model.removeItem(i)},onClickDeleteItem:function(t){var i=this;this.model.removeItemDb({item:t,remove_from_client_immediately:!0,onError:function(s){"E_CATEGORY_LOCKED"===s.error_code?(AoPS.Ui.Modal.showAlert(e["cat-admin-contents-locked-error"]),i.model.addItem(t),i.model.set("is_locked",!0),i.render()):AoPS.Ui.Flyout.display(o.formatString(e["cat-admin-contents-remove-tag-error"],[t.item_text])),i.model.addItem(t)}})},addItemToExistingCategory:function(t){var e=this;this.model.addItemDb({item:t,add_to_client_immediately:!0,onError:function(i){e.onAddItemError(i,t)}})},onClose:function(){this.itembox_view&&this.itembox_view.close()}}),t.CategoryAdminBlockContentsBookmarkUsers=t.CategoryAdminBlockContentsFolder.extend({can_additems_in_admin:!1}),t.CategoryAdminBlockContentsBlogroll=t.CategoryAdminBlockContentsFolder.extend({new_contents_autocomplete_ajax:"fetch_blogs_autocomplete"}),t.CategoryAdminBlockContentsFolderForums=t.CategoryAdminBlockContentsFolder.extend({new_contents_autocomplete_ajax:"fetch_forum_autocomplete"}),t.CategoryAdminBlockContentsFolderCollections=t.CategoryAdminBlockContentsFolder.extend({new_contents_autocomplete_ajax:"fetch_folder_collections_contents_autocomplete"}),t.CategoryAdminBlockContentsFolderOld=AoPS.View.extend({template_id:"#cmty-category-admin-contents-tpl",className:"aops-panel cmty-cat-admin-contents",new_contents_autocomplete_ajax:"fetch_add_contents_categories_autocomplete",initialize:function(){this.$help=$(this.getTemplate("#cmty-cat-admin-contents-"+t.getCategoryAdminCatType(this.model.get("category_type"))+"-help-tpl",{})),this.render()},events:{"click .cmty-cat-admin-help":"onClickHelp"},onClickHelp:function(){this.$help.showModal({frame_class:"cmty-cat-admin-helper-modal aops-modal-standard",title:e["cat-admin-contents-help-title"],width:"600px",scrollable:!0})},render:function(){var i=this.model.canAddItem(),o=this.model.canRemoveItem(),s=this;this.$el.html(this.getTemplate(this.template_id,{can_add_item:i,title:e["cat-admin-contents-title"],lang_add:e["cat-admin-contents-add-item"],lang_contents:e["cat-admin-contents-items-header"]})),this.$contents=this.$el.find(".cmty-admin-location-containers"),this.itembox_view=new t.Itembox({model:this.model,check_can_remove:o,can_remove_all:!0,onDeleteItem:function(t){s.onClickDeleteItem(t)}}),this.$contents.append(this.itembox_view.$el),i&&(this.$content_add=this.$el.find(".cmty-cat-admin-content-add"),this.constructContentsInput())},onClickDeleteItem:function(t){var i=this;this.model.removeItemDb({item:t,remove_from_client_immediately:!0,onError:function(s){"E_CATEGORY_LOCKED"===s.error_code?(AoPS.Ui.Modal.showAlert(e["cat-admin-contents-locked-error"]),i.model.addItem(t),i.model.set("is_locked",!0),i.render()):AoPS.Ui.Flyout.display(o.formatString(e["cat-admin-contents-remove-tag-error"],[t.item_text])),i.model.addItem(t)}})},constructContentsInput:function(){var t=this,i={};this.$content_add.append('<input class="cmty-admin-new-contents-category"\t\t\t\tplaceholder="'+e["cat-admin-add-content-"+this.model.get("category_type")+"-placeholder"]+'">'),this.$new_item_input=this.$content_add.find("input"),this.model.get("is_public")&&(i.is_public_setting=1),o.buildCategoryAutocomplete(this.$new_item_input,{ajax_call:this.new_contents_autocomplete_ajax,additional_ajax_settings:i,autocomplete_settings:{onSelect:function(e,i){t.parsePotentialNewContents({item_id:i.item.category_id,item_text:i.item.label,item_type:i.item.category_type,item_forum_id:i.item.item_forum_id,item_main_color:i.item.main_color,item_secondary_color:i.item.secondary_color,item_can_remove:i.item.can_remove,item_subtitle:i.item.short_description}),e.stopPropagation(),e.preventDefault()}},show_no_results_msg:!0})},parsePotentialNewContents:function(t){t.item_id===this.model.get("category_id")?AoPS.Ui.Modal.showAlertQuick(e["cat-admin-contents-no-adding-to-self"]):_.isUndefined(this.model.fetchItem(t))?this.model.get("category_id")>0?this.addItemToExistingCategory(t):this.model.addItem(t):AoPS.Ui.Modal.showAlertQuick(o.formatString(e["cat-admin-contents-already-holds"],[t.item_text])),this.$new_item_input.val(""),this.$new_item_input.focus()},onAddItemError:function(t,i){"E_CATEGORY_LOCKED"===t.error_code?(AoPS.Ui.Modal.showAlert(e["cat-admin-contents-locked-error"]),this.model.removeItem(i),this.model.set("is_locked",!0),this.render()):AoPS.Ui.Flyout.display(o.formatString(e["cat-admin-contents-add-category-error"],[i.item_text,t.error_code])),this.model.removeItem(i)},addItemToExistingCategory:function(t){var e=this;this.model.addItemDb({item:t,add_to_client_immediately:!0,onError:function(i){e.onAddItemError(i,t)}})},onClose:function(){this.itembox_view.close()},validateNewCategorySettings:function(){return 0!==this.model.get("items").length||(AoPS.Ui.Modal.showAlertQuick(e["cat-admin-no-empty-collections"]),!1)}}),t.CategoryAdminBlockContentsBookmarkForums=t.CategoryAdminBlockContentsFolder.extend({new_contents_autocomplete_ajax:"fetch_forum_autocomplete",addItemToExistingCategory:function(e){var i=this;t.fireBookmarkModal("forum",_.bind((function(t){var o=_.defaults({state:t},e);this.model.get("master").addBookmarkForumViaAdmin({item:o,onError:function(t){i.onAddItemError(t,e)}})}),this))}}),t.CategoryAdminBlockContentsMyForums=t.CategoryAdminBlockContentsFolder.extend({new_contents_autocomplete_ajax:"fetch_add_contents_my_forums_autocomplete"}),t.CategoryAdminBlockContentsMyCollections=t.CategoryAdminBlockContentsFolder.extend({new_contents_autocomplete_ajax:"fetch_add_contents_my_collections_autocomplete"}),t.CategoryAdminBlockContentsViewTagsOld=t.CategoryAdminBlockContentsFolder.extend({onClickCloseForum:function(t){this.constructContentsInput(),this.$content_add.find("input").focus()},constructContentsInput:function(){var t=this;this.$content_add.empty(),this.$content_add.append('<input class="cmty-admin-new-contents-category"\t\t\t\t\tplaceholder="'+e["cat-admin-add-content-tag-forum-placeholder"]+'">'),o.buildCategoryAutocomplete(this.$content_add.find("input"),{ajax_call:"fetch_forum_autocomplete",autocomplete_settings:{onSelect:function(e,i){t.buildTagInput({item_id:i.item.category_id,item_text:i.item.label,item_type:i.item.category_type,item_forum_id:i.item.item_forum_id,item_main_color:i.item.main_color,item_secondary_color:i.item.secondary_color,item_can_remove:i.item.can_remove,item_subtitle:i.item.short_description}),e.stopPropagation(),e.preventDefault()}},show_no_results_msg:!0})},buildTagInput:function(t){var i,o=this;this.$content_add.empty(),this.$content_add.html(this.getTemplate("#cmty-cat-admin-add-content-tags-tpl",{lang_Forum:e.Forum,lang_Tag:e.Tag,tag_placeholder:e["cat-admin-contents-tag-placeholder"]})),this.current_forum=t,this.category=this.model.get("master").fetchCategory(t.item_id),_.isUndefined(this.category)&&(this.category=this.model.get("master").constructTemporaryCategory({category_type:t.item_type,category_id:t.item_id,main_color:t.item_main_color,secondary_color:t.item_secondary_color,category_name:t.item_text})),i=AoPS.Community.Views.Itembox.prototype.constructItem.apply({push_state_attribute:"data-cmty",check_can_remove:!0,can_remove_all:!0,onClickDelete:function(){o.onClickCloseForum()}},[t]),this.$content_add.find(".cmty-cat-admin-contents-add-tag-forum").append(i),this.$input_box=this.$content_add.find("input"),AoPS.Community.Views.buildTagAutocomplete({$input_box:this.$input_box,show_no_results_msg:!0,model:this.category,submitNewItem:function(t){o.addItem(t)}}),this.$input_box.focus()},addItem:function(t){var i={item_id:parseInt(t.item_id),item_type:"tag",item_forum_id:parseInt(t.item_forum_id),item_text:t.value,item_main_color:t.main_color,item_secondary_color:t.secondary_color};_.isUndefined(this.model.fetchItem(i))?this.model.get("category_id")>0?this.addItemToExistingCategory(i):this.model.addItem(i):AoPS.Ui.Flyout.display(o.formatString(e["cat-admin-contents-added-tag-already"],[i.item_text,this.current_forum.item_text])),this.buildTagInput(this.current_forum)},addItemToExistingCategory:function(t){var i=this;this.model.addItemDb({item:t,add_to_client_immediately:!0,onError:function(s){"E_CATEGORY_LOCKED"===s.error_code?(AoPS.Ui.Modal.showAlert(e["cat-admin-contents-locked-error"]),i.model.removeItem(t),i.model.set("is_locked",!0),i.render()):AoPS.Ui.Flyout.display(o.formatString(e["cat-admin-contents-add-tag-error"],[t.item_text,i.current_forum.item_text])),i.model.removeItem(t)}})}}),t.CategoryAdminBlockContentsBookmarkTags=t.CategoryAdminBlockContentsViewTags.extend({addItemToExistingCategory:function(e){var i=this;t.fireBookmarkModal("tag",_.bind((function(t){this.model.get("master").addTagBookmark({item:_.defaults(t,e),onError:function(t){i.onAddItemError(t,e)}})}),this))}}),t.CategoryAdminBlockLocation=AoPS.View.extend({template_id:"#cmty-category-admin-location-tpl",className:"aops-panel cmty-cat-admin-location",initialize:function(){this.display_type=o.displayCategoryType(this.model.get("category_type")),this.render(),this.$help=$(this.getTemplate("#cmty-cat-admin-location-help-tpl",{type:this.display_type,lang_contained_in:e["cat-admin-location-contained-in"]}))},events:{"click .cmty-cat-admin-help":"onClickHelp"},buildHelper:function(){var t=this.category_type_specific_settings.help_template_id;this.$help=$(this.getTemplate(t,{}))},render:function(){var i=this;this.$el.html(this.getTemplate(this.template_id,{can_add_to_folders:AoPS.session.logged_in,placeholder:e["cat-admin-add-to-location-placeholder"],title:e["cat-admin-location-title"],lang_add_to:e["cat-admin-location-add-to"],lang_contained_in:e["cat-admin-location-contained-in"]})),this.$contained_in=this.$el.find(".cmty-admin-location-containers"),AoPS.session.logged_in&&(this.$input_box=this.$el.find("input"),o.buildCategoryAutocomplete(this.$input_box,{ajax_call:"fetch_containers_autocomplete",additional_ajax_settings:{item_type:this.model.get("category_type")},autocomplete_settings:{onSelect:function(t,e){i.parsePotentialNewContainer({item_id:e.item.category_id,item_text:e.item.label,item_type:"folder",item_forum_id:0,item_main_color:e.item.main_color,item_secondary_color:e.item.secondary_color,item_can_remove:e.item.can_remove,item_subtitle:e.item.short_description}),t.stopPropagation(),t.preventDefault()}},show_no_results_msg:!0})),this.itembox_view=new t.Itembox({model:this.model.get("container_model"),check_can_remove:!0,can_remove_all:!1,onDeleteItem:function(t){i.onClickDeleteContainer(t)}}),this.$contained_in.append(this.itembox_view.$el)},parsePotentialNewContainer:function(t){var i=this;t.item_id===this.model.get("category_id")?AoPS.Ui.Modal.showAlertQuick(e["cat-admin-contents-no-adding-to-self"]):this.model.get("container_model").addItem({item:t,onError:function(s){"E_ALREADY_ADDED"===s.error_code&&AoPS.Ui.Modal.showAlert(o.formatString(e["cat-admin-location-exists"],[i.display_type,t.item_text]))}}),this.$input_box.val(""),this.$input_box.focus()},onClickDeleteContainer:function(t){var i=this;this.model.get("category_id")>0?AoPS.Ui.Modal.showConfirm(e["cat-admin-delete-container-1"]+" <b>"+t.item_text+"</b>?",(function(e){e&&i.model.get("container_model").removeItem(t),AoPS.Ui.Modal.closeAllModals()}),{width:"450px"}):i.model.get("container_model").removeItem(t)},onClickHelp:function(){this.$help.showModal({frame_class:"cmty-cat-admin-helper-modal aops-modal-standard",title:e["cat-admin-location-help-title"],width:"600px",scrollable:!0})},validateNewCategorySettings:function(){return!0},onClose:function(){this.itembox_view.close()}}),t.CategoryAdminBlockBlogSettings=AoPS.View.extend({template_id:"#cmty-category-admin-blog-extras-tpl",className:"aops-panel",initialize:function(){var t=["show_profile_info","show_stats","show_shoutbox","show_contributors","show_tags"],i=this,o=this.model.getPermission("c_can_edit_core_data");o&&(t.push("is_primary_blog"),this.model.set("is_primary_blog",this.model.get("category_id")===this.model.get("master").get("current_user").get("primary_blog_id"))),this.$el.html(this.getTemplate(this.template_id,{title:e["cat-admin-blog-settings-title"]})),_.each(["blog_post_comment_text","blog_comments_text","blog_one_comment_text","blog_no_comments_text"],(function(t){o?i.buildEditableInputSetting(t):i.buildStaticSetting(t)})),this.intervals={},_.each(t,(function(t){o?i.buildEditableBitSetting(t):i.buildStaticSetting(t)})),this.$help=$(this.getTemplate("#cmty-cat-admin-blog-settings-help-tpl",{}))},events:{"click .cmty-cat-admin-help":"onClickHelp"},onClickHelp:function(){this.$help.showModal({frame_class:"cmty-cat-admin-helper-modal aops-modal-standard",title:e["cat-admin-blog-settings-help-title"],width:"600px",scrollable:!0})},buildSettingGroup:function(t){return $('<div class="form-group"><div><label>'+e["cat-admin-blog-label-"+t]+"</label></div>")},buildStaticSetting:t.CategoryAdminBlockGeneralInfo.prototype.buildStaticSetting,buildEditableBitSetting:t.CategoryAdminBlockGeneralInfo.prototype.buildEditableBitSetting,updateBitSetting:function(i,o){this.model.setBitBlogSetting({setting:i,value:1==parseInt(o),onError:function(i){_typeof(e["change-blog-err-"+i.error_code])&&t.showError(e["change-blog-err-"+i.error_code])}})},buildEditableInputSetting:function(t){var e=this,o=this.buildSettingGroup(t),s=$('<input class="form-control" type="text" maxlength="'+i.max_blog_comments_text_length+'" value="'+this.model.get(t)+'">');s.on("input",(function(i){e.prepareSaveInput(s,t)})),o.append($("<div></div>").append(s)),this.$el.append(o)},prepareSaveInput:function(t,e){var o=this,s=t.val();this.intervals.hasOwnProperty(e)&&clearTimeout(this.intervals[e]),this.intervals[e]=setTimeout((function(){o.saveInput(e,s)}),i.cat_admin_save_input_delay)},saveInput:function(i,o){this.model.setStringBlogSetting({setting:i,value:o,onFinish:function(t){AoPS.Ui.Flyout.close(),AoPS.Ui.Flyout.display(e["cat-admin-blog-label-"+i]+" "+e.saved+".")},onError:function(i){_typeof(e["change-blog-err-"+i.error_code])&&t.showError(e["change-blog-err-"+i.error_code])}})},validateNewCategorySettings:function(){return!0}}),t.CategoryAdminBlockBlogCss=AoPS.View.extend({template_id:"#cmty-cat-admin-blog-css-tpl",className:"aops-panel",initialize:function(){var t,i=this,o=this.model.get("category_id")>0,s=o&&this.model.getPermission("c_can_edit_core_data");t=o?s?e["cat-admin-blog-css-existing-info"]:this.model.has("css")&&this.model.get("css").length>0?e["cat-admin-blog-css-no-perm"]:"":e["cat-admin-blog-css-new-info"],this.$el.html(this.getTemplate(this.template_id,{title:e["cat-admin-blog-css-title"],blog_exists:o,blog_message:t,Save:e.Save,Reset:e.Reset,Delete:e.Delete,content:this.model.has("css")?this.model.get("css"):e["cat-admin-blog-css-default-css"],can_edit:s,placeholder:s?e["cat-admin-blog-css-enter"]:e["cat-admin-blog-css-none"]})),this.$css=this.$("textarea"),s&&(this.$css.on("keyup",(function(){i.onKeyPress()})),this.$save=this.$(".cmty-cat-admin-blog-css-save"),this.$reset=this.$(".cmty-cat-admin-blog-css-reset"),this.$delete=this.$(".cmty-cat-admin-blog-css-delete"),this.resetButtonVisibility()),this.$help=$(this.getTemplate("#cmty-cat-admin-blog-css-help-tpl",{}))},validateNewCategorySettings:function(){return!0},events:{"click .cmty-cat-admin-blog-css-save":"onClickSave","click .cmty-cat-admin-blog-css-reset":"onClickReset","click .cmty-cat-admin-blog-css-delete":"onClickDelete","click .cmty-cat-admin-help":"onClickHelp"},onClickHelp:function(){this.$help.showModal({frame_class:"cmty-cat-admin-helper-modal aops-modal-standard",title:e["cat-admin-blog-css-help-title"],width:"600px",scrollable:!0})},onKeyPress:function(){this.$save.show(),this.$reset.show()},resetButtonVisibility:function(){this.$reset.hide(),this.$save.hide(),this.$delete.toggle(this.model.has("css")&&this.model.get("css").length>0)},onClickReset:function(){var t=this.model.has("css")?this.model.get("css"):"";this.$css.val(t),this.resetButtonVisibility()},onClickSave:function(){var i=this,o=i.$css.val();s.showConfirm(e["cat-admin-blog-css-save-sure"],(function(n){n?(t.throwBlockingMessage(e["cat-admin-blog-css-save-block"]),i.model.setNewCss({new_css:i.$css.val(),onFinish:function(){i.model.set("css",o),i.resetButtonVisibility(),setTimeout((function(){s.closeAllModals()}),500)},onError:function(t){i.throwEditError(t)}})):s.closeAllModals()}),{close_on_button_click:!1,width:"450px"})},throwEditError:function(t){var i;i="E_NO_PERMISSION"===t.error_code?e["cat-admin-blog-css-no-perm-err"]:e["unexpected-error-code"]+t.error_code,AoPS.Community.Views.showError(i)},onClickDelete:function(){var i=this;s.showConfirm(e["cat-admin-blog-css-delete-sure"],(function(o){o?(t.throwBlockingMessage(e["cat-admin-blog-css-delete-block"]),i.model.deleteCss({onFinish:function(){i.$css.val(""),i.model.unset("css"),i.resetButtonVisibility(),setTimeout((function(){s.closeAllModals()}),500)},onError:function(t){i.throwEditError(t)}})):s.closeAllModals()}),{close_on_button_click:!1,width:"450px"})}}),t}(AoPS.Community.Views||{});
;function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}AoPS.Feed=function(e){var t=AoPS.Community.Lang;return e.preloaded_topic=null,e.preload_feed_tag_id=0,e.preload_feed_tag_text="",e.constructFeed=function(){var e,t;if(AoPS.Community.is_active)return"object"===_typeof(this.community_master)||(AoPS.Community.hasOwnProperty("MasterModel")||(AoPS.Community.MasterModel=new AoPS.Community.Models.Master({in_community:!1})),this.community_master=AoPS.Community.MasterModel,this.feed_master=new AoPS.Community.Models.Feed({master:this.community_master}),this.feed_view=new AoPS.Feed.Views.FeedMaster({model:this.feed_master}),AoPS.Feed.Master=this.feed_master,AoPS.bootstrap_data.hasOwnProperty("preload_feed_focus_topic")&&(AoPS.Feed.preloaded_topic=this.community_master.processPotentialNewTopic(AoPS.bootstrap_data.preload_feed_focus_topic)),AoPS.bootstrap_data.hasOwnProperty("preload_feed_tag_id")&&(AoPS.Feed.preload_feed_tag_id=parseInt(AoPS.bootstrap_data.preload_feed_tag_id)),AoPS.bootstrap_data.hasOwnProperty("preload_feed_tag_text")&&(AoPS.Feed.preload_feed_tag_text=AoPS.bootstrap_data.preload_feed_tag_text),_.isNull(AoPS.Feed.preloaded_topic)||(e=AoPS.Feed.preloaded_topic.get("category_id"),this.feed_view.$el.addClass("feed-preloaded-topic")),$("body").append(this.feed_view.$el),_.isNull(AoPS.Feed.preloaded_topic)||(t="string"==typeof AoPS.bootstrap_data.page_feed_preload_title?AoPS.bootstrap_data.page_feed_preload_title:"Linked Item Topics",this.openPageFeed({category_id:e,tag_id:AoPS.Feed.preload_feed_tag_id,tag_text:AoPS.Feed.preload_feed_tag_text,subtitle:t}),this.feed_master.set("focus_topic",AoPS.Feed.preloaded_topic))),{community_master:this.community_master,feed_master:this.feed_master,feed_view:this.feed_view}},e.setPageFeedSubtitle=function(e){var t;AoPS.Community.is_active&&(t=this.feed_view.page_subfeed.view.$el.find(".feed-subtitle"),this.feed_master.get("page_subfeed_settings").subtitle=e,0===e.length?this.feed_view.page_subfeed.view.$el.find(".feed-subtitle").remove():t.length>0?t.html(e):(t='<div class="feed-subtitle">'+e+"</div>",this.feed_view.page_subfeed.view.$el.find(".feed-subfeed-header").after(t)))},e.setPageFeed=function(e){var t,o=!1;if(AoPS.Community.is_active){if(t=this.feed_master.get("page_subfeed_settings"),this.feed_view.$el.removeClass("feed-hide-page-feed"),"number"==typeof arguments[0]){if(0===e)return;e={category_id:arguments[0]},1===arguments.length?e.tag_id=0:("number"==typeof arguments[1]?e.tag_id=arguments[1]:e.tag_text=arguments[1],3===arguments.length&&(e.subtitle=arguments[2]))}else e=_.extend({tag_id:0,subtitle:""},e);return t.hasOwnProperty("category_id")&&e.hasOwnProperty("category_id")&&t.category_id===e.category_id?e.hasOwnProperty("tag_id")&&e.tag_id>0?t.hasOwnProperty("tag_id")&&parseInt(t.tag_id)===e.tag_id||(o=!0):e.hasOwnProperty("tag_text")&&e.tag_text.length>0?t.hasOwnProperty("tag_text")&&t.tag_text===e.tag_text||(o=!0):t.hasOwnProperty("tag_id")&&parseInt(t.tag_id)>0&&(o=!0):o=!0,o&&this.feed_master.set("page_subfeed_settings",e),o}},e.hidePageFeed=function(){AoPS.Community.is_active&&(this.feed_view.$el.addClass("feed-hide-page-feed"),this.feed_view.page_subfeed===this.feed_view.active_subfeed&&this.feed_view.closeFeed())},e.closePageFeed=function(){AoPS.Community.is_active&&this.feed_view.page_subfeed===this.feed_view.active_subfeed&&(AoPS.Feed.feed_master.set("focus_topic",null),this.feed_view.closeFeed())},e.openPageFeed=function(e){if(AoPS.Community.is_active){if("number"==typeof arguments[0]){if(0===e)return;e={category_id:arguments[0],subtitle:""},1===arguments.length?e.tag_id=0:"number"==typeof arguments[1]?e.tag_id=arguments[1]:(e.tag_id=0,e.tag_text=arguments[1]),3===arguments.length&&(e.subtitle=arguments[2])}else e=_.extend({tag_id:0},e);this.setPageFeed(e)||!AoPS.Feed.feed_view.isPageSubfeedOpen()||e.hasOwnProperty("force_open")&&e.force_open?this.activatePageSubfeed():this.closePageFeed()}else AoPS.Ui.Modal.showAlert(t["err-community-disabled"])},e.activatePageSubfeed=function(){this.feed_view.activatePageSubfeed(),this.feed_view.showFeed()},e.activateGlobalSubfeed=function(){"object"===_typeof(this.feed_view.global_subfeed)&&this.feed_view.openFeed(this.feed_view.global_subfeed,0)},e.startNewTopic=function(e){if(AoPS.Community.is_active)if(0!==e.category_id){var o=this.community_master.fetchCategory(e.category_id),i=_.extend({tags:[],target_url:"",target_text:"",subtitle:"",content:"",linked_tag:"",filter_tag:"",hidden_tags:[],restricted_tags:[],onSuccess:function(){}},e);AoPS.session.logged_in?AoPS.isUserLimited()&&!AoPS.in_academy?AoPS.Ui.Modal.showMessage(t["cat-cell-no-perm-limited-user"],{width:"450px"}):_.isUndefined(o)?AoPS.Ui.Modal.showMessage(t["new-topic-no-category"]):o.getPermission("c_can_start_topic")||o.getPermission("c_undo_global_ban")?(""!==i.linked_tag&&(i.tags=_.without(i.tags,i.linked_tag),i.tags.push(i.linked_tag)),i.special_item=i.linked_tag,delete i.linked_tag,i.model=o,i.filter_tag=i.filter_tag.length>0?i.filter_tag:i.target_url,i.master=this.community_master,new AoPS.Feed.Views.NewTopic(i)):AoPS.Ui.Modal.showMessage(t["cat-cell-no-perm-start-topic"]):AoPS.Ui.buildLoginConfirm(t["new-topic-not-logged-in"])}else AoPS.Community.Views.showError(t["feed-no-forum"]);else AoPS.Ui.Modal.showAlert(t["err-community-disabled"])},e.buildNewTopicButton=function(e){var t=$('<div class="new-topic-btn" title="Start topic about this">V</div>');return this.activateNewTopicButton(_.extend({$button:t},e))},e.activateNewTopicButton=function(e){return e.$button.on("click",(function(){AoPS.Feed.startNewTopic(e)})),e.$button},e.buildOpenFeedButton=function(e){var t=$('<div class="open-feed-btn" title="View discussions about this">t</div>');return this.activateOpenFeedButton(_.extend({$button:t},e))},e.activateOpenFeedButton=function(e){return e.$button.on("click",(function(){AoPS.Feed.openPageFeed(e)})),e.$button},e.onFeedRoute=function(t){_.isNull(t)&&(t=""),"/"===t.substr(0,1)&&(t=t.substr(1)),AoPS.Community.hasOwnProperty("MasterModel")||e.constructFeed(),Backbone.history.navigate(t,{trigger:!0,replace:!0});var o=AoPS.Community.MasterModel.get("focus_topic");_.isNull(o)||(AoPS.Feed.activatePageSubfeed(),AoPS.Feed.feed_master.set("focus_topic",o)),AoPS.Community.MasterModel.set("focus_topic",null)},e.openTopic=function(e){if(AoPS.Community.is_active){var t=AoPS.Community.MasterModel.fetchTopicById(e),o=this,i=AoPS.Feed.feed_master.get("focus_topic");(_.isNull(i)||e!==i.get("topic_id"))&&AoPS.Feed.feed_view.past_topic_id!==e||!AoPS.Feed.feed_view.isPageSubfeedOpen()?_.isNull(t)||_.isUndefined(t)?(AoPS.Feed.activatePageSubfeed(),this.feed_view.throwTopicBlocker(),t=AoPS.Community.MasterModel.fetchTopicFromDb({topic_id:e,onFinish:function(e){AoPS.Feed.feed_master.set("focus_topic",e.topic,{no_ajax_override:!0})},onError:function(e){o.onTopicError(e)}})):(AoPS.Feed.activatePageSubfeed(),AoPS.Feed.feed_master.set("focus_topic",t,{no_ajax_override:!0})):this.closePageFeed()}},e.onTopicError=function(e){var o;switch(e.error_code){case"E_NO_SUCH_TOPIC":o=t["feed-no-topic"];break;case"E_NO_PERMISSION":o=t["feed-no-read-permission"];break;default:o=AoPS.Community.Utils.formatString(t["err-unknown"],[e.error_code])}AoPS.Feed.feed_view.cleanTopicWindow(),AoPS.Community.Views.showError(o)},e.openTopicSetFeed=function(e){if(AoPS.Community.is_active)if($("body").width()<=700){var t=AoPS.bd.grid_data.class.forum_id,o=arguments[0];window.open("/community/c"+t+"h"+o,"_blank")}else{var i,d=arguments[0],a=!1,s=this,n=AoPS.Feed.feed_view.isPageSubfeedOpen(),r=Array.prototype.slice.apply(arguments).slice(1),c=AoPS.Feed.feed_master.get("focus_topic");i=this.setPageFeed.apply(this,r),(_.isNull(c)||c.get("topic_id")!==d)&&AoPS.Feed.feed_view.past_topic_id!==d||!n||i?(AoPS.Feed.feed_view.feed_open||(this.openPageFeed.apply(this,r),a=!0),this.activatePageSubfeed(),a?setTimeout((function(){s.openTopic(d)}),1.1*AoPS.Feed.feed_view.animate_speed):this.openTopic(d)):this.closePageFeed()}},e}(AoPS.Feed||{});
;AoPS.Feed=AoPS.Feed||{},AoPS.Feed.Views=function(e){var t=AoPS.Community.Lang,i=AoPS.Community.Utils,s=AoPS.Ui.Flyout;return e.processFeedTopicIsReadChange=function(t){t.topic.get("is_read")&&t.$button.hasClass("feed-subfeed-new-topic")&&e.checkSubfeedUnread(t)},e.checkSubfeedUnread=function(e){if(!(e.list.length>AoPS.Community.Constants.max_length_feed_list_read_check)){var t=e.list.findWhere({is_read:!1});_.isUndefined(t)?e.$button.removeClass("feed-subfeed-new-topic"):e.list.length>0&&e.$button.addClass("feed-subfeed-new-topic")}},e.FeedMaster=AoPS.View.extend({template_id:"#feed-master-tpl",feed_open:!1,animate_speed:200,active_subfeed:null,active_topic_view:null,id:"feed-wrapper",topic_views:[],subfeeds:[],has_page_feed:!1,cached_page_subfeed_views:{},initialize:function(){var e=this;this.$el.html(this.getTemplate(this.template_id,{})),this.$tabs=this.$el.find("#feed-tabs"),this.$topics_list=this.$el.find("#feed-topic-list"),this.$topic=this.$el.find("#feed-topic"),this.$topic_loader=AoPS.Page.buildLoader(),this.$el.on("mousedown",(function(e){e.stopPropagation()})),e.past_topic_id=0,$("body").on("click.feed",(function(t){e.past_topic_id=0})),this.feed_animated=!1,this.community_master=this.model.get("master"),this.model=this.community_master.get("feed"),this.constructSubfeeds(),this.listenTo(this.model,"change:focus_topic",this.buildTopic),this.listenTo(this.community_master.get("current_user"),"change:show_tags_on_feed",this.processShowTags),this.processShowTags(),this.listenTo(this.model,"change:page_subfeed_settings",this.onNewPageSubfeed),this.listenTo(this.community_master,"change:fullscreen_mode",(function(t){"feed"===e.community_master.previous("fullscreen_mode")?e.offFullscreen():"feed"===e.community_master.get("fullscreen_mode")&&e.onFullscreen()})),this.setVisibility(),AoPS.session.logged_in&&this.listenTo(this.community_master.get("current_user"),"change:hide_feed",this.setVisibility),this.community_master.get("current_user").get("hide_avatars")&&this.$el.addClass("cmty-hide-avatars"),this.listenTo(this.community_master.get("current_user"),"change:hide_avatars",(function(){e.$el.toggleClass("cmty-hide-avatars",e.community_master.get("current_user"))})),this.listenTo(Backbone,"community_disabled",this.onCommunityDisabled),this.listenTo(Backbone,"close_feed_topic",this.onTriggerCloseFeedTopic),i.startIdleMonitor(),i.activateLatexOnclick()},events:{"click .feed-subfeed-header":"closeFeed","click .feed-resort":"onClickResort"},onCommunityDisabled:function(){s.display(t["feed-community-disabled"]),this.hideFeed()},onFullscreen:function(){this.$topic.left_css=this.$topic.is_dragged?this.$topic.css("left"):"",this.$topic.top_css=this.$topic.is_dragged?this.$topic.css("top"):"",this.$topic.css({left:"",top:""}),this.$topic.draggable("disable")},offFullscreen:function(){this.$topic.css({left:this.$topic.left_css,top:this.$topic.top_css}),this.$topic.draggable("enable")},setVisibility:function(){AoPS.session.logged_in&&1===Number(this.community_master.get("current_user").get("hide_feed"))?this.hideFeed():this.showFeed()},processShowTags:function(){this.$el.toggleClass("cmty-show-feed-tags",this.community_master.get("current_user").get("show_tags_on_feed"))},hideFeed:function(){this.$el.addClass("feed-hidden")},showFeed:function(){AoPS.Community.is_active&&this.$el.removeClass("feed-hidden")},onTriggerCloseFeedTopic:function(){this.model.set("focus_topic",null),"feed"===this.community_master.get("fullscreen_mode")&&(this.community_master.set("fullscreen_mode","none"),$(window).trigger("resize"))},constructSubfeeds:function(){var e,i,s,o=[];for(this.global_subfeed=this.addSubfeed({header_text:t["feed-global-subfeed-header"],id:"feed-global-tab",title:"full"===this.model.get("global_feed_type")?t["feed-tab-global-title"]:t["feed-tab-global-custom-title"],icon_letter:"a",category:new AoPS.Community.Models.CategoryGlobal({master:this.community_master})}),AoPS.session.logged_in&&(this.addSubfeed({header_text:t["feed-ego-subfeed-header"],id:"feed-egosearch-tab",title:t["feed-tab-my-topics-title"],icon_letter:"w",category:new AoPS.Community.Models.CategoryUsersTopics({master:this.community_master,user_id:AoPS.session.user_id})}),e=this.community_master.fetchCategory(1),this.addSubfeed({header_text:t["feed-messages-subfeed-header"],id:"feed-privates-tab",title:t["feed-tab-private-title"],icon_letter:"m",can_post:!0,can_post_title:t["feed-new-private-conversation"],category:e,onClickNewTopic:_.bind((function(){e.getPermission("c_can_start_topic")||e.getPermission("c_undo_global_ban")?this.launchNewPrivate():AoPS.Ui.Modal.showMessage(t[AoPS.isUserLimited()?"new-pm-no-permission-limited":"new-pm-no-permission"],{width:"450px"})}),this)}),this.constructBookmarksSubfeed()),s=0;s<this.subfeeds.length;s++)i=this.subfeeds[s].view.topics_list_view,o.push(i.collection.constructAjaxCall(i.constructFetchMoreTopicsOptions()));this.hasOwnProperty("bookmark_subfeed")&&(i=this.bookmark_subfeed.view.active_subfeed.topics_list_view,o.push(i.collection.constructAjaxCall(i.constructFetchMoreTopicsOptions()))),this.model.fetchInitialSubfeedTopics(o)},launchNewPrivate:function(){var t=this.community_master.fetchCategory(1);new e.NewPrivateConversation({category_name:"",category_id:1,model:t,master:this.community_master})},removeSubfeedListeners:function(e){e.view.stopListening(e.view.filtered_list)},addSubfeedListeners:function(e){var t=this;e.view.hasOwnProperty("filtered_list")&&(e.view.listenTo(e.view.filtered_list,"add",(function(i){t.active_subfeed!==e&&(i.get("is_read")||e.$button.addClass("feed-subfeed-new-topic"))})),e.view.listenTo(e.view.filtered_list,"change:is_read",(function(t){AoPS.Feed.Views.processFeedTopicIsReadChange({topic:t,list:e.view.filtered_list,$button:e.$button})})))},addSubfeed:function(t){var i={$button:$("<div>",{id:t.id,class:"feed-tab aops-font",text:t.icon_letter,title:t.title}),view:{}},s=this;return this.$tabs.append(i.$button),i.view=new e.Subfeed(_.defaults({model:t.category},t)),i.$button.on("click",(function(){s.onButtonClick(i)})),this.addSubfeedListeners(i),this.subfeeds.push(i),i},onButtonClick:function(e){this.model.get("initialized")&&(this.feed_animated||(this.feed_open?this.active_subfeed===e?this.closeFeed():(this.closeSubfeed(this.active_subfeed),this.activateSubfeed(e,0)):this.openFeed(e)))},closeSubfeed:function(e){e&&(this.stopListening(Backbone,"topic_cell_marked_for_deletion"),e.view.$el.detach(),e.view.hasOwnProperty("topics_list_view")&&("function"==typeof e.view.topics_list_view.processUpdatedTopicVisibility&&e.view.topics_list_view.processUpdatedTopicVisibility(),e.view.topics_list_view.on_page=!1),e.view.$(".feed-resort").hide(),this.model.set("focus_topic",null),_.isNull(this.active_topic_view)||(this.active_topic_view.onRemoveFromFeed(),this.active_topic_view=null),e.$button.removeClass("feed-subfeed-button-selected"))},activateSubfeed:function(e,t){if(e&&e!==this.active_subfeed){var i=this;_.isUndefined(e.view.topics_list_view)||_.isUndefined(e.view.topics_list_view.collection)||!_.isUndefined(e.view.topics_list_view.collection.topics_loading)&&e.view.topics_list_view.collection.topics_loading||AoPS.Community.Utils.cmty_ajax.cancelAll({cancel_type:"feed"}),this.revealSubfeedView(e),_.isNull(this.active_subfeed)?e.$button.addClass("feed-subfeed-button-selected"):this.active_subfeed.$button!==e.$button&&(this.active_subfeed.$button.removeClass("feed-subfeed-new-topic"),e.$button.addClass("feed-subfeed-button-selected")),this.active_subfeed=e,this.topic_cell_delete_listener=this.listenTo(Backbone,"topic_cell_marked_for_deletion",(function(e){i.active_subfeed.view.topics_list_view===e.topics_list&&i.active_subfeed.view.$(".feed-resort").show()}))}},revealSubfeedView:function(e){this.$topics_list.append(e.view.$el),e.view.hasOwnProperty("topics_list_view")&&"function"==typeof e.view.topics_list_view.onAddToFeed&&e.view.topics_list_view.onAddToFeed()},openFeed:function(e){var t=this;this.feed_animated||(this.activateSubfeed(e,this.animate_speed),this.feed_animated=!0,t.feed_open=!0,this.$el.addClass("feed-open",{duration:this.animate_speed,complete:function(){t.feed_animated=!1}}))},closeFeed:function(){var e=this;this.feed_animated||(AoPS.Community.Utils.cmty_ajax.cancelAll({cancel_type:"feed"}),_.isNull(this.active_subfeed)||this.active_subfeed.$button.removeClass("feed-subfeed-button-selected"),this.feed_animated=!0,this.$el.removeClass("feed-open",this.animate_speed,"swing",_.bind((function(){_.isNull(this.active_subfeed)||(this.closeSubfeed(this.active_subfeed),this.active_subfeed=null,e.feed_animated=!1)}),this)),this.model.set("focus_topic",null),this.feed_open=!1)},onClickResort:function(e){this.resortActiveSubfeed(),$(e.currentTarget).hide(),e.stopPropagation(),e.preventDefault()},resortActiveSubfeed:function(){_.isNull(this.active_subfeed)||(this.active_subfeed.view.topics_list_view.processUpdatedTopicVisibility(),this.active_subfeed.view.topics_list_view.setPopoutVisibility())},constructBookmarksSubfeed:function(){var i={$button:$("<div>",{id:"feed-bookmark-tab",text:"E",title:t["feed-tab-bookmark-title"],class:"feed-tab aops-font"}),name:"bookmarks",view:{}};i.view=new e.Bookmarks({model:this.model,feed_view:this,parent_subfeed_object:i}),this.$tabs.append(i.$button),i.$button.on("click",_.bind((function(){this.onButtonClick(i)}),this)),this.bookmark_subfeed=i},closeActiveTopicView:function(){this.active_topic_view.onRemoveFromFeed(),this.active_topic_view.$el.detach(),this.active_topic_view=null},cleanTopicWindow:function(){var e=!_.isNull(this.active_topic_view),t=this.model.get("focus_topic");this.$topic_loader.detach(),e&&this.closeActiveTopicView(),this.$topic.empty(),_.isNull(t)&&(this.$topic.hide(),$("body").off("mousedown.feed"))},throwTopicBlocker:function(){this.cleanTopicWindow(),this.openTopicWindow(),this.$topic.append(this.$topic_loader)},openTopicWindow:function(){var e=this;this.$topic.show(),this.$topic.data("draggable")||(this.$topic.is_dragged=!1,this.$topic.draggable({containment:"window",drag:function(){e.$topic.is_dragged=!0}}))},buildTopic:function(){var t,i,s=this,o=!1,c=!_.isNull(this.active_topic_view),n=this.model.get("focus_topic");this.cleanTopicWindow(),_.isNull(n)||(t=_.find(this.topic_views,(function(e){return e.model===n})),i={model:n,route_category_id:n.get("category_id"),reveal_type:this.model.get("focus_topic_show_from")},_.isUndefined(t)||t.route_category_id!==n.get("category_id")&&(this.topic_views=_.without(this.topic_views,t),t.close(),o=!0),(_.isUndefined(t)||o)&&(t=new e.TopicFull(i),this.topic_views.push(t)),this.active_topic_view=t,this.openTopicWindow(),c||$("body").on("mousedown.feed",(function(){AoPS.Ui.Modal.isModalVisible()||(_.isNull(s.model.get("focus_topic"))||(s.past_topic_id=s.model.get("focus_topic").get("topic_id")),s.model.set("focus_topic",null))})),this.$topic.append(this.active_topic_view.$el),this.active_topic_view.onAddToFeed(i))},onNewPageSubfeed:function(){this.has_page_feed||this.constructPageSubfeed(),this.setPageSubfeed(),this.page_subfeed.$button.removeClass("feed-subfeed-new-topic"),this.page_subfeed.view.hasOwnProperty("topics_list_view")&&(_.isUndefined(this.page_subfeed.view.topics_list_view.collection.findWhere({is_read:!1}))||this.page_subfeed.$button.addClass("feed-subfeed-new-topic"))},constructPageSubfeed:function(){var e=this;this.page_subfeed={$button:$("<div>",{id:"feed-page-tab",class:"feed-tab aops-font",text:"p",title:t["feed-tab-page-feed-title"]})},this.page_subfeed.$button.on("click",(function(){e.onButtonClick(e.page_subfeed)})),this.$tabs.find(".feed-tab").first().after(this.page_subfeed.$button),this.subfeeds.push(this.page_subfeed),this.page_subfeed_settings={category_id:0,tag_id:0,tag_text:""},this.page_subfeed_loader=this.constructPageSubfeedView(null,this.page_subfeed_settings),this.page_subfeed.view=this.page_subfeed_loader,this.has_page_feed=!0},constructPageSubfeedView:function(i,s){var o,c,n={header_text:t["feed-page-subfeed-header"],can_post:!1,can_post_title:"",re_sort_feed:t["feed-resort"],close_feed:t["feed-close"],has_settings:!1};return _.isNull(i)?((o=$('<div class="cmty-subfeed"></div>').append(this.getTemplate("#feed-subfeed-header-tpl",n))).append(AoPS.Page.buildLoader()),c={$el:o,stopListening:function(){}}):((c=new e.Subfeed(_.defaults({model:i,tag_id:s.tag_id,subtitle:s.hasOwnProperty("subtitle")?s.subtitle:""},n))).filtered_list.topics_loading||0!==c.topics_list_view.collection.length||c.topics_list_view.fetchMoreTopics(),this.cachePageSubfeedView(c,s)),c},cachePageSubfeedView:function(e,t){var i=AoPS.Community.Views.convertToUrlFragment(t.tag_text);this.cached_page_subfeed_views[t.category_id+"-"+t.tag_id+"-"+i]=e,i.length>0&&t.tag_id>0&&(this.cached_page_subfeed_views[t.category_id+"-0-"+i]=e,this.cached_page_subfeed_views[t.category_id+t.tag_id+"-"]=e)},setPageSubfeed:function(){var e,t,i,s=this;this.isNewPageSubfeed()&&(this.removeSubfeedListeners(this.page_subfeed),this.page_subfeed.view.hasOwnProperty("$el")&&this.page_subfeed.view.$el.detach(),i=this.cleanPageSubfeedSettings(this.model.get("page_subfeed_settings")),t=this.fetchCachedPageSubfeed(i),_.isNull(t)?(e=this.community_master.fetchCategory(i.category_id),_.isUndefined(e)?(this.page_subfeed.view=this.page_subfeed_loader,i.tag_id>0||""===i.tag_text?this.community_master.buildCategory({category_id:i.category_id,onFinish:function(){s.setPageSubfeed()}}):this.community_master.buildCategoryAndTag({category_id:i.category_id,tag_text:i.tag_text,onFinish:function(e){i.tag_id=e.tag_id,s.model.set("page_subfeed_settings",i)}})):0===i.tag_id&&""!==i.tag_text?this.community_master.fetchTagId({tag_text:i.tag_text,onFinish:function(e){i.tag_id=e.tag_id,s.model.set("page_subfeed_settings",i)}}):this.page_subfeed.view=this.constructPageSubfeedView(e,i)):(this.page_subfeed.view=t,AoPS.Feed.setPageFeedSubtitle(i.hasOwnProperty("subtitle")?i.subtitle:"")),this.addSubfeedListeners(this.page_subfeed),this.active_subfeed===this.page_subfeed&&this.revealSubfeedView(this.page_subfeed))},isPageSubfeedOpen:function(){return this.feed_open&&this.isPageSubfeedActive()},isPageSubfeedActive:function(){return this.active_subfeed===this.page_subfeed},activatePageSubfeed:function(){this.feed_open?(this.isPageSubfeedActive()||_.isNull(this.active_subfeed)||this.closeSubfeed(this.active_subfeed),this.activateSubfeed(this.page_subfeed,0)):this.openFeed(this.page_subfeed)},isNewPageSubfeed:function(){var e=this.cleanPageSubfeedSettings(this.model.get("page_subfeed_settings")),t=this.cleanPageSubfeedSettings(this.page_subfeed_settings);return e.category_id!==t.category_id||(0===e.tag_id&&t.tag_id>0&&e.tag_text===t.tag_text&&(this.model.get("page_subfeed_settings").tag_id=t.tag_id),0===e.tag_id||t.tag_id?e.tag_text!==t.tag_text:e.tag_id!==t.tag_id)},cleanPageSubfeedSettings:function(e){return _.extend({category_id:0,tag_id:0,tag_text:""},e)},fetchCachedPageSubfeed:function(e){var t=AoPS.Community.Views.convertToUrlFragment(e.tag_text),i=e.category_id+"-"+e.tag_id+"-";if(0!==e.tag_id){if(this.cached_page_subfeed_views.hasOwnProperty(i))return this.cached_page_subfeed_views[i];if(i+=t,this.cached_page_subfeed_views.hasOwnProperty(i))return this.cached_page_subfeed_views[i]}return i=e.category_id+"-0-"+t,this.cached_page_subfeed_views.hasOwnProperty(i)?this.cached_page_subfeed_views[i]:null},onClose:function(){_.each(this.subfeeds,(function(e){e.view.close()})),_.each(_.properties(this.cached_page_subfeed_views),(function(e){e.close()}))}}),e.Subfeed=AoPS.View.extend({className:"cmty-subfeed",initialize:function(i){var s,o=i.hasOwnProperty("subtitle")&&i.subtitle.length>0,c=i.hasOwnProperty("tag_id")&&i.tag_id>0?[{tag_forum_id:this.model.get("category_id"),tag_id:i.tag_id}]:[];if(this.settings=i,this.community_master=this.model.get("master"),c.length>0){var n=(s=new AoPS.Community.Models.CategoryViewTags({category_id:0,master:this.community_master,permissions:this.model.get("permissions"),category_type:"view_tags",items:[{item_forum_id:c[0].tag_forum_id,item_id:c[0].tag_id}]})).get("active_topics");if(this.model.get("active_topics").each((function(e){e.hasTag(i.tag_id)&&n.add(e)})),AoPS.Feed.preload_feed_tag_id>0&&AoPS.Feed.preload_feed_tag_id===i.tag_id&&!_.isNull(AoPS.Feed.preloaded_topic)){var a=this.community_master.processPotentialNewTopics(AoPS.bootstrap_data.page_feed_preload_topics,!1);n.add(a),s.set("all_topics_loaded",AoPS.bootstrap_data.page_feed_all_topics_fetched)}this.filtered_list=this.community_master.fetchFilteredTopicList({category:s,category_id:0})}else this.filtered_list=this.community_master.fetchFilteredTopicList({category:this.model,category_id:this.model.get("category_id"),tag_ids:c});this.topics_list_view=new e.TopicsList({collection:this.filtered_list,main_color:this.model.get("main_color"),secondary_color:this.model.get("secondary_color"),category_id:0,master:this.community_master}),this.$el.append(this.getTemplate("#feed-subfeed-header-tpl",{header_text:i.header_text,can_post:!!i.hasOwnProperty("can_post")&&i.can_post,can_post_title:i.hasOwnProperty("can_post_title")?i.can_post_title:"",has_settings:!1,has_subtitle:o,close_feed:t["feed-close"],re_sort_feed:t["feed-re-sort"],subtitle:i.hasOwnProperty("subtitle")?i.subtitle:""})),o&&this.$el.addClass("cmty-subfeed-w-subtitle"),this.$el.append(this.topics_list_view.$el)},events:{"click .feed-new-topic":"onClickNewTopic"},onClickNewTopic:function(e){return this.settings.hasOwnProperty("onClickNewTopic")&&this.settings.onClickNewTopic(),e.stopPropagation(),e.preventDefault(),!1},onClose:function(){this.topics_list_view.close()}}),e.Bookmarks=AoPS.View.extend({subfeed_array:[],template_id:"#feed-bookmarks-tpl",className:"cmty-subfeed cmty-subfeed-w-subtitle",initialize:function(e){var i,s,o=this;for(this.parent_subfeed_object=e.parent_subfeed_object,this.feed_view=e.feed_view,this.feed_bookmark_categories=[],this.$el.html(this.getTemplate("#feed-subfeed-header-tpl",{header_text:t["feed-bookmarks-subfeed-header"],has_settings:!1})),this.$el.append(this.getTemplate(this.template_id,{forums_checked:1&this.model.get("feed_setting"),tags_checked:2&this.model.get("feed_setting"),topics_checked:4&this.model.get("feed_setting")})),this.$checkboxes=this.$el.find(":checkbox"),this.community_master=this.model.get("master"),this.feed_bookmark_categories[1]=this.buildFeedCategory("tag"),this.feed_bookmark_categories[2]=this.buildFeedCategory("topic"),this.feed_bookmark_categories[4]=this.buildFeedCategory("forum"),i=3;i<=7;i++)4!==i&&(s=[],_.each([1,2,4],(function(e){e&i&&s.push(o.feed_bookmark_categories[e])})),this.feed_bookmark_categories[i]=new AoPS.Community.Models.CategoryConglomeration({master:this.community_master,categories:s}));for(this.subfeed_array[0]={is_built:!0,topics_list_view:{$el:$('<div class="feed-no-bookmarks">'+t["feed-no-bookmark-options-checked"]+"</div>"),no_bookmarks_checked:!0}},i=1;i<=7;i++)this.subfeed_array[i]={is_built:!1};this.constructTopicsListView(this.model.get("feed_setting")),this.active_subfeed=this.subfeed_array[this.model.get("feed_setting")],this.$el.append(this.active_subfeed.topics_list_view.$el),this.topics_list_view=this.active_subfeed.topics_list_view,this.model.get("feed_setting")>0&&this.startListeningToActiveList()},constructTopicsListView:function(t){var i,s;s=this.community_master.constructTopicListFilter({category:this.feed_bookmark_categories[t]}),i=new AoPS.Community.Models.TopicList({category:this.feed_bookmark_categories[t],master:this.community_master,tag_ids:[],filter:s}),this.subfeed_array[t].filtered_list=i.get("filtered_topic_list"),this.subfeed_array[t].topics_list_view=new e.TopicsListBookmarks({collection:this.subfeed_array[t].filtered_list,main_color:this.feed_bookmark_categories[t].get("main_color"),secondary_color:this.feed_bookmark_categories[t].get("secondary_color"),category_id:0,master:this.community_master}),this.subfeed_array[t].is_built=!0},events:{"click :checkbox":"onCheckboxClick"},onCheckboxClick:function(e){for(var t=0,i=this.$checkboxes,s=0;s<=2;s++)i[s].checked&&(t+=parseInt(i[s].value));this.model.set("feed_setting",t),this.onBookmarkSettingChange()},onBookmarkSettingChange:function(){var e=this.model.get("feed_setting");this.$(".feed-resort").hide(),this.stopListening(this.active_subfeed.filtered_list),this.active_subfeed.topics_list_view.on_page=!1,this.active_subfeed.topics_list_view.$el.detach(),this.active_subfeed.topics_list_view.hasOwnProperty("no_bookmarks_checked")&&this.active_subfeed.topics_list_view.no_bookmarks_checked||(this.active_subfeed.topics_list_view.processUpdatedTopicVisibility(),this.model.set("focus_topic",null)),this.subfeed_array[e].is_built||this.constructTopicsListView(e),this.active_subfeed=this.subfeed_array[e],e>0&&(this.active_subfeed.filtered_list.category.hasItems()?this.active_subfeed.topics_list_view.onAddToFeed():(this.active_subfeed.topics_list_view.on_page=!0,this.active_subfeed.topics_list_view.appendNoMoreTopicsMessage())),this.$el.append(this.active_subfeed.topics_list_view.$el),this.topics_list_view=this.active_subfeed.topics_list_view,e>0&&this.startListeningToActiveList()},startListeningToActiveList:function(){var e=this;this.listenTo(this.active_subfeed.filtered_list,"add",(function(t){e.feed_view.active_subfeed!==e.parent_subfeed_object&&(t.get("is_read")||e.parent_subfeed_object.$button.addClass("feed-subfeed-new-topic"))})),this.listenTo(this.active_subfeed.filtered_list,"change:is_read",(function(t){AoPS.Feed.Views.processFeedTopicIsReadChange({topic:t,list:e.active_subfeed.filtered_list,$button:e.parent_subfeed_object.$button})}))},buildFeedCategory:function(e){var t,i,s=this.community_master.get("bookmarked_"+e+"_category");return i={category_type:"topic"===e?"feed_topics":"view_"+e+"s",items:_.filter(s.get("items"),(function(e){return e.hasOwnProperty("in_feed")&&1===e.in_feed}))},"topic"===e&&(i.bookmark_topic_category_id=this.community_master.get("bookmarked_topic_category").get("category_id")),(t=this.community_master.constructNewCategory(i)).listenTo(s,"item_added",_.bind((function(e){e.in_feed&&this.addItem(e)}),t)),t.listenTo(s,"item_removed",_.bind((function(e){e.in_feed&&this.removeItem(e)}),t)),t}}),e.TopicFull=AoPS.Community.Views.TopicFull.extend({template_id:"#feed-topic-full-tpl",viewing_source:"feed",scrollbar_settings:{autosize:!1},initialize:function(e){this.feed=this.model.get("master").get("feed"),AoPS.Community.Views.TopicFull.prototype.initialize.apply(this,[e])},onClickClose:function(e){this.feed.set("focus_topic",null),this.fullscreen_triggered_by_reply=!1,this.model.get("master").set("fullscreen_mode","none"),this.is_full_reply=!1,$(window).trigger("resize"),e.stopPropagation(),e.preventDefault()},onAddToFeed:function(e){this.onAddToPage(e)},onDelete:function(){var e=arguments.length>1&&arguments[2].hasOwnProperty("deleted_by_me")&&arguments[2].deleted_by_me;this.model.get("deleted")&&this.feed.get("focus_topic")===this.model&&(e?AoPS.Ui.Modal.closeAllModals():AoPS.Ui.Modal.showAlert(t["feed-topic-full-message-deleted"]),this.close(),this.feed.set("focus_topic",null))},onClickFullReply:function(){"feed"===this.model.get("master").get("fullscreen_mode")?this.completeReplyClick("full"):this.onClickReply()},onClickFullScreen:function(){this.performFullScreenEvents(!1)},performFullScreenEvents:function(e){var t="none"===this.model.get("master").get("fullscreen_mode")?"feed":"none";this.model.get("master").set("fullscreen_mode",t),"none"===this.model.get("master").get("fullscreen_mode")?(this.is_full_reply=!1,AoPS.Community.Views.removeFullReplyStyle()):(this.is_full_reply=!0,AoPS.Community.Views.setFullReplyStyle()),this.model.get("master").get("feed").trigger(undefined),$(window).trigger("resize")},doExtraInitialization:function(){this.$el.find(".feed-topic-forum").css({"background-color":this.model.get("category_main_color"),color:this.model.get("category_secondary_color")}),this.$category_top=this.$el.find(".feed-topic-forum"),this.listenTo(this.feed,"change:focus_topic_show_from change:focus_topic",this.parseFeedFocusChange)},parseFeedFocusChange:function(){this.model===this.feed.get("focus_topic")&&(this.reveal_type=this.feed.get("focus_topic_show_from"),this.setInitialPostBoxLocation())},setArchiveStatus:function(){this.hasOwnProperty(this.$archive_status)||(this.$archive_status=$('<span class="cmty-topic-archive clickable"></span>'),this.$(".cmty-topic-bookmark").replaceWith(this.$archive_status)),this.$archive_status.append('<span class="aops-icon">(</span>'),this.$archive_status[0].title=t["private-archive-topic"]},completeParticipantStatusChange:function(){var e=this.model.get("master");this.feed.set("focus_topic",null),e.get("my_privates").trigger("check_for_more_topics")},onRemoveFromFeed:function(){this.onRemoveFromPage()},removeFocusListener:function(){this.stopListening(this.feed,"change:focus_topic")},setFocusListener:function(){this.listenTo(this.feed,"change:focus_topic",this.onChangeFocusTopic)},fetchFocusTopic:function(){return this.feed.get("focus_topic")}}),e.TopicCell=AoPS.Community.Views.TopicCell.extend({full_topics_popup:!0,in_feed:!0,events:{click:"onClickTopic","click .cmty-topic-cell-jump-to-bottom":"onClickJumpToBottom","click .cmty-topic-cell-close-topic":"onClickClose","click .cmty-topic-cell-goto-unread":"onClickGoToUnread","click .cmty-topic-cell-post a":"onClickLinkInCell"},onClickTopic:function(e){if(e.ctrlKey||e.metaKey)return"user_search_topics"===this.topic_list.collection.category.get("category_type")?this.onClickMyTopicsCell(e):this.openInNewTab(),void e.stopPropagation();this.master.get("feed").set({focus_topic_show_from:"show_from_start",focus_topic:this.model}),e.stopPropagation()},onClickMyTopicsCell:function(e){var s,o=this;s=i.formatString(t["feed-my-topics-onclick"],[e.ctrlKey?t["control-click"]:t["command-click"]]),AoPS.Ui.Modal.showButtons(s,[{text:t["feed-my-topics-open-new"],value:1},{text:t["feed-my-topics-remove"],value:0}],(function(e){1===e?o.openInNewTab():(o.model.setMyStatus({status:"removed"}),o.topic_list.collection.remove(o.model))}),{width:"450px"}),e.stopPropagation()},openInNewTab:function(){var e="/c"+this.model.get("category_id")+"h"+this.model.get("topic_id");window.open("/community"+e,"_blank")},onClickLinkInCell:function(e){e.preventDefault()},onClickClose:function(e){return this.master.get("feed").set("focus_topic",null),e.stopPropagation(),!1},onClickJumpToBottom:function(e){this.master.get("feed").set({focus_topic_show_from:"show_from_end",focus_topic:this.model}),e.stopPropagation(),e.preventDefault()},onClickGoToUnread:function(e){this.master.get("feed").set({focus_topic_show_from:"show_unread",focus_topic:this.model}),e.stopPropagation(),e.preventDefault()},setFocusWatchBehavior:function(){this.listenTo(this.model,"change:is_feed_focus",this.checkFocusTopic),this.checkFocusTopic()},checkFocusTopic:function(){this.is_focus=this.model.get("is_feed_focus"),this.processFocusTopicStatusChange()}}),e.TopicCellPopout=e.TopicCell.extend({parent:e.TopicCell,buildTopic:AoPS.Community.Views.TopicCellPopout.prototype.buildTopic,createStuntDouble:function(){var e=this;AoPS.Community.Views.TopicCellPopout.prototype.createStuntDouble.apply(this),this.$stunt_double.find(".cmty-topic-cell-jump-to-bottom").on("click",(function(t){e.onClickJumpToBottom(t)})),this.$stunt_double.find(".cmty-topic-cell-close-topic").on("click",(function(t){e.onClickClose(t)})),this.$stunt_double.on("click",(function(t){e.onClickTopic(t)}))},constructWatchersLine:AoPS.Community.Views.TopicCellPopout.prototype.constructWatchersLine,onClose:function(){this.$stunt_double.remove()}}),e.TopicsList=AoPS.Community.Views.TopicsList.extend({fetch_topics_on_build:!1,list_location:"feed",topicView:e.TopicCell,popoutView:e.TopicCellPopout,onAddToFeed:function(){this.on_page=!0,this.checkQueuedUpTopicBoxes(),this.parseFocusTopic(),this.setFocusListener(),this.checkMoreTopicsNeeded(),this.checkIfEnoughCells()},setFocusListener:function(){this.listenTo(this.master.get("feed"),"change:focus_topic",this.parseFocusTopic)},processUpdatedTopicVisibility:AoPS.Community.Views.TopicsList.prototype.processUpdatedTopicVisibility,getFocusTopic:function(){return this.master.get("feed").get("focus_topic")}}),e.TopicsListBookmarks=e.TopicsList.extend({initialize:function(e){AoPS.Community.Views.TopicsList.prototype.initialize.apply(this,[e]),this.$nothing_bookmarked=$('<div class="cmty-no-more-topics">'+t["topics-list-nothing-bookmarked"]+"</div>")},onCollectionReset:function(){this.$nothing_bookmarked.detach(),AoPS.Community.Views.TopicsList.prototype.onCollectionReset.apply(this)},appendNoMoreTopicsMessage:function(){this.$loader.detach(),this.collection.length>0?(this.$nothing_bookmarked.detach(),this.$topics_box.append(this.$no_more_topics)):(this.$no_more_topics.detach(),this.$topics_box.append(this.$nothing_bookmarked))}}),e.NewTopic=AoPS.Community.Views.NewTopic.extend({onPostedNewTopic:function(e){e.topic.has("linked_tag_removed")&&e.topic.get("linked_tag_removed")?(this.model.get("master").get("feed").set("focus_topic",e.topic),AoPS.Feed.activateGlobalSubfeed()):(AoPS.Feed.openPageFeed({category_id:this.model.get("category_id"),tag_text:this.settings.hasOwnProperty("filter_tag")?this.settings.filter_tag:this.settings.target_url,subtitle:this.settings.hasOwnProperty("subtitle")?this.settings.subtitle:"",force_open:!0}),this.model.get("master").get("feed").set("focus_topic",e.topic)),"function"==typeof this.settings.onSuccess&&this.settings.onSuccess(e)}}),e.NewPrivateConversation=AoPS.Community.Views.NewPrivateConversation.extend({onPostedNewTopic:function(e){var i=this.model.get("master");"private"===e.topic.get("topic_type")&&i.get("current_user").get("pm_archive_on_send")?s.display(t["new-topic-pm-archived"]):i.get("feed").set("focus_topic",e.topic)}}),e}(AoPS.Feed.Views||{});
;//# sourceMappingURL=cmty_core.js.map