text:
package com.instructure.canvasapi.api;

import android.content.Context;

import com.instructure.canvasapi.model.Attachment;
import com.instructure.canvasapi.model.Course;
import com.instructure.canvasapi.model.Enrollment;
import com.instructure.canvasapi.model.Favorite;
import com.instructure.canvasapi.model.FileUploadParams;
import com.instructure.canvasapi.model.GradingPeriodResponse;
import com.instructure.canvasapi.model.kaltura.FileUploadParamsWrapper;
import com.instructure.canvasapi.utilities.APIHelpers;
import com.instructure.canvasapi.utilities.CanvasCallback;
import com.instructure.canvasapi.utilities.CanvasRestAdapter;
import com.instructure.canvasapi.utilities.ExhaustiveBridgeCallback;

import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import retrofit.RestAdapter;
import retrofit.http.Body;
import retrofit.http.DELETE;
import retrofit.http.GET;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.PUT;
import retrofit.http.Part;
import retrofit.http.PartMap;
import retrofit.http.Path;
import retrofit.http.Query;
import retrofit.mime.TypedFile;

public class CourseAPI extends BuildInterfaceAPI {

    interface CoursesInterface {

        @PUT("/courses/{courseid}")
        void updateCourse(@Path("courseid") long courseID,
                          @Query("course[name]") String name, @Query("course[course_code]") String courseCode,
                          @Query("course[start_at]") String startAt, @Query("course[end_at]") String endAt,
                          @Query("course[license]") String license, @Query("course[is_public]") Integer isPublic,
                          @Body String body,
                          CanvasCallback<Course> callback);

        @GET("/courses/{courseid}?include[]=term&include[]=permissions&include[]=license&include[]=is_public&include[]=needs_grading_count")
        void getCourse(@Path("courseid") long courseId, CanvasCallback<Course> callback);

        @GET("/courses/{courseid}?include[]=term&include[]=permissions&include[]=license&include[]=is_public&include[]=needs_grading_count&include[]=total_scores&include[]=current_grading_period_scores")
        void getCourseWithGrade(@Path("courseid") long courseId, CanvasCallback<Course> callback);

        @GET("/courses/{courseid}/enrollments")
        void getEnrollmentsForGradingPeriod(@Path("courseid") long courseId, @Query("grading_period_id") long gradingPeriodId, CanvasCallback<Enrollment[]> callback);

        @GET("/courses/{courseid}?include[]=syllabus_body&include[]=term&include[]=license&include[]=is_public&include[]=permissions")
        void getCourseWithSyllabus(@Path("courseid") long courseId, CanvasCallback<Course> callback);

        // I don't see why we wouldn't want to always get the grades
        @GET("/courses?include[]=term&include[]=total_scores&include[]=license&include[]=is_public&include[]=needs_grading_count&include[]=permissions&include[]=favorites&include[]=current_grading_period_scores")
        void getFirstPageCourses(CanvasCallback<Course[]> callback);

        @GET("/{next}?&include[]=needs_grading_count&include[]=permissions&include[]=favorites")
        void getNextPageCourses(@Path(value = "next", encode = false) String nextURL, CanvasCallback<Course[]> callback);

        @GET("/users/self/favorites/courses?include[]=term&include[]=total_scores&include[]=license&include[]=is_public&include[]=needs_grading_count&include[]=permissions&include[]=current_grading_period_scores")
        void getFavoriteCourses(CanvasCallback<Course[]> callback);

        @GET("/courses/{courseId}/grading_periods")
        void getGradingPeriodsForCourse(@Path("courseId") long courseId, CanvasCallback<GradingPeriodResponse> callback);

        @POST("/users/self/favorites/courses/{courseId}")
        void addCourseToFavorites(@Path("courseId") long courseId, @Body String body, CanvasCallback<Favorite> callback);

        @DELETE("/users/self/favorites/courses/{courseId}")
        void removeCourseFromFavorites(@Path("courseId") long courseId, CanvasCallback<Favorite> callback);

        @GET("/users/{user_id}/courses?include[]=total_scores&include[]=syllabus_body")
        void getCoursesForUser(@Path("user_id") long userId, CanvasCallback<Course[]> callback);

        @GET("/{next}")
        void getNextPageCoursesForUser(@Path(value = "next", encode = false) String nextURL, CanvasCallback<Course[]> callback);

        @GET("/canvas/{parentId}/{studentId}/courses?include[]=total_scores&include[]=syllabus_body&include[]=current_grading_period_scores")
        void getCoursesForUserAirwolf(@Path("parentId") String parentId, @Path("studentId") String studentId, CanvasCallback<Course[]> callback);

        @GET("/canvas/{parentId}/{studentId}/courses/{courseId}?include[]=syllabus_body&include[]=term&include[]=license&include[]=is_public&include[]=permissions")
        void getCourseWithSyllabusAirwolf(@Path("parentId") String parentId, @Path("studentId") String studentId, @Path("courseId") long courseId, CanvasCallback<Course> callback);

        @GET("/canvas/{parentId}/{studentId}/courses/{courseId}?include[]=term&include[]=permissions&include[]=license&include[]=is_public&include[]=needs_grading_count&include[]=total_scores&include[]=current_grading_period_scores")
        void getCourseWithGradeAirwolf(@Path("parentId") String parentId, @Path("studentId") String studentId, @Path("courseId") long courseId, CanvasCallback<Course> callback);

        /////////////////////////////////////////////////////////////////////////////
        // Synchronous
        /////////////////////////////////////////////////////////////////////////////
        @GET("/courses?include[]=term&include[]=total_scores&include[]=license&include[]=is_public&include[]=permissions")
        Course[] getAllCoursesSynchronous(@Query("page") int page);

        @GET("/users/self/favorites/courses?include[]=term&include[]=total_scores&include[]=license&include[]=is_public&include[]=permissions")
        Course[] getFavCoursesSynchronous(@Query("page") int page);

        @POST("/courses/{courseId}/files")
        FileUploadParams getFileUploadParams(@Path("courseId") long courseId, @Query("parent_folder_id") Long parentFolderId, @Query("size") long size, @Query("name") String fileName, @Query("content_type") String content_type, @Body String body);

        @POST("/courses/{courseId}/quizzes/{quizId}/submissions/self/files")
        FileUploadParamsWrapper getQuizFileUploadParams(@Query("name") String name, @Query("duplicate_name") String duplicateName, @Path("courseId") long courseId, @Path("quizId") long quizId, @Body String body);

        @Multipart
        @POST("/")
        Attachment uploadCourseFile(@PartMap LinkedHashMap<String, String> params, @Part("file") TypedFile file);

        @Multipart
        @POST("/")
        Attachment uploadQuizFile(@PartMap LinkedHashMap<String, String> params, @Part("file") TypedFile file);
    }

    /////////////////////////////////////////////////////////////////////////
    // API Calls
    /////////////////////////////////////////////////////////////////////////

    public static void getCourse(long courseId, CanvasCallback<Course> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildCacheInterface(CoursesInterface.class, callback, false).getCourse(courseId, callback);
        buildInterface(CoursesInterface.class, callback, false).getCourse(courseId, callback);
    }

    public static void getCourseWithGrade(long courseId, CanvasCallback<Course> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildCacheInterface(CoursesInterface.class, callback, false).getCourseWithGrade(courseId, callback);
        buildInterface(CoursesInterface.class, callback, false).getCourseWithGrade(courseId, callback);
    }

    public static void getCourseWithSyllabus(long courseId, CanvasCallback<Course> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildCacheInterface(CoursesInterface.class, callback, false).getCourseWithSyllabus(courseId, callback);
        buildInterface(CoursesInterface.class, callback, false).getCourseWithSyllabus(courseId, callback);
    }

    public static void getFirstPageCourses(CanvasCallback<Course[]> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildCacheInterface(CoursesInterface.class, callback).getFirstPageCourses(callback);
        buildInterface(CoursesInterface.class, callback).getFirstPageCourses(callback);
    }

    public static void getFirstPageFavoriteCourses(CanvasCallback<Course[]> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildCacheInterface(CoursesInterface.class, callback).getFavoriteCourses(callback);
        buildInterface(CoursesInterface.class, callback).getFavoriteCourses(callback);
    }

    public static void getGradingPeriodsForCourse(long courseId, CanvasCallback<GradingPeriodResponse> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildCacheInterface(CoursesInterface.class, callback).getGradingPeriodsForCourse(courseId, callback);
        buildInterface(CoursesInterface.class, callback).getGradingPeriodsForCourse(courseId, callback);
    }

    public static void getEnrollmentsForGradingPeriod(long courseId, long gradingPeriodId, CanvasCallback<Enrollment[]> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildCacheInterface(CoursesInterface.class, callback).getEnrollmentsForGradingPeriod(courseId, gradingPeriodId, callback);
        buildInterface(CoursesInterface.class, callback).getEnrollmentsForGradingPeriod(courseId, gradingPeriodId, callback);
    }

    public static void getNextPageCourses(CanvasCallback<Course[]> callback, String nextURL) {
        if (APIHelpers.paramIsNull(callback, nextURL)) return;

        callback.setIsNextPage(true);
        buildCacheInterface(CoursesInterface.class, callback).getNextPageCourses(nextURL, callback);
        buildInterface(CoursesInterface.class, callback).getNextPageCourses(nextURL, callback);
    }

    public static void getNextPageCoursesChained(CanvasCallback<Course[]> callback, String nextURL, boolean isCached) {
        if (APIHelpers.paramIsNull(callback, nextURL)) return;

        callback.setIsNextPage(true);
        if (isCached) {
            buildCacheInterface(CoursesInterface.class, callback).getNextPageCourses(nextURL, callback);
        } else {
            buildInterface(CoursesInterface.class, callback).getNextPageCourses(nextURL, callback);
        }
    }

    public static void addCourseToFavorites(final long courseId, final CanvasCallback<Favorite> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildInterface(CoursesInterface.class, callback).addCourseToFavorites(courseId, "", callback);
    }

    public static void removeCourseFromFavorites(final long courseId, final CanvasCallback<Favorite> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        buildInterface(CoursesInterface.class, callback).removeCourseFromFavorites(courseId, callback);
    }

    public static void getAllFavoriteCoursesChained(final CanvasCallback<Course[]> callback, boolean isCached) {
        if (APIHelpers.paramIsNull(callback)) return;

        CanvasCallback<Course[]> bridge = new ExhaustiveBridgeCallback<>(Course.class, callback, new ExhaustiveBridgeCallback.ExhaustiveBridgeEvents() {
            @Override
            public void performApiCallWithExhaustiveCallback(CanvasCallback bridgeCallback, String nextURL, boolean isCached) {
                if(callback.isCancelled()) { return; }

                CourseAPI.getNextPageCoursesChained(bridgeCallback, nextURL, isCached);
            }
        });

        if (isCached) {
            buildCacheInterface(CoursesInterface.class, callback).getFavoriteCourses(bridge);
        } else {
            buildInterface(CoursesInterface.class, callback).getFavoriteCourses(bridge);
        }
    }

    public static void getAllFavoriteCourses(final CanvasCallback<Course[]> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        CanvasCallback<Course[]> bridge = new ExhaustiveBridgeCallback<>(Course.class, callback, new ExhaustiveBridgeCallback.ExhaustiveBridgeEvents() {
            @Override
            public void performApiCallWithExhaustiveCallback(CanvasCallback bridgeCallback, String nextURL, boolean isCached) {
                if(callback.isCancelled()) { return; }

                CourseAPI.getNextPageCoursesChained(bridgeCallback, nextURL, isCached);
            }
        });

        buildCacheInterface(CoursesInterface.class, callback).getFavoriteCourses(bridge);
        buildInterface(CoursesInterface.class, callback).getFavoriteCourses(bridge);
    }

    public static void getAllCourses(final CanvasCallback<Course[]> callback) {
        if (APIHelpers.paramIsNull(callback)) return;

        CanvasCallback<Course[]> bridge = new ExhaustiveBridgeCallback<>(Course.class, callback, new ExhaustiveBridgeCallback.ExhaustiveBridgeEvents() {
            @Override
            public void performApiCallWithExhaustiveCallback(CanvasCallback bridgeCallback, String nextURL, boolean isCached) {
                if(callback.isCancelled()) { return; }

                CourseAPI.getNextPageCoursesChained(bridgeCallback, nextURL, isCached);
            }
        });

        buildCacheInterface(CoursesInterface.class, callback).getFirstPageCourses(bridge);
        buildInterface(CoursesInterface.class, callback).getFirstPageCourses(bridge);
    }

    /**
     * @param newCourseName (Optional)
     * @param newCourseCode (Optional)
     * @param newStartAt    (Optional)
     * @param newEndAt      (Optional)
     * @param license       (Optional)
     * @param newIsPublic   (Optional)
     * @param course        (Required)
     * @param callback      (Required)
     */
    public static void updateCourse(String newCourseName, String newCourseCode, Date newStartAt, Date newEndAt, Course.LICENSE license, Boolean newIsPublic, Course course, CanvasCallback<Course> callback) {
        if (APIHelpers.paramIsNull(callback, course)) return;

        String newStartAtString = APIHelpers.dateToString(newStartAt);
        String newEndAtString = APIHelpers.dateToString(newEndAt);
        Integer newIsPublicInteger = (newIsPublic == null) ? null : APIHelpers.booleanToInt(newIsPublic);

        buildInterface(CoursesInterface.class, callback).updateCourse(course.getId(), newCourseName, newCourseCode, newStartAtString, newEndAtString, Course.licenseToAPIString(license), newIsPublicInteger, "", callback);
    }

    public static void getCoursesForUser(long userId, CanvasCallback<Course[]> callback) {
        if (APIHelpers.paramIsNull(callback)) { return; }

        buildCacheInterface(CoursesInterface.class, callback).getCoursesForUser(userId, callback);
        buildInterface(CoursesInterface.class, callback).getCoursesForUser(userId, callback);

    }

    public static void getNextPageCoursesForUser(String nextURL, CanvasCallback<Course[]> callback) {
        if (APIHelpers.paramIsNull(nextURL, callback)) { return; }

        callback.setIsNextPage(true);

        buildCacheInterface(CoursesInterface.class, callback).getNextPageCoursesForUser(nextURL, callback);
        buildInterface(CoursesInterface.class, callback).getNextPageCoursesForUser(nextURL, callback);
    }

    public static void getCoursesForUserAirwolf(String parentId, String studentId, CanvasCallback<Course[]> callback) {
        if(APIHelpers.paramIsNull(parentId, studentId, callback)) { return; }

        buildCacheInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback).getCoursesForUserAirwolf(parentId, studentId, callback);
        buildInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback).getCoursesForUserAirwolf(parentId, studentId, callback);
    }

    public static void getNextPageCoursesForUserAirwolf(String nextURL, CanvasCallback<Course[]> callback) {
        if (APIHelpers.paramIsNull(nextURL, callback)) { return; }

        callback.setIsNextPage(true);

        buildCacheInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback).getNextPageCoursesForUser(nextURL, callback);
        buildInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback).getNextPageCoursesForUser(nextURL, callback);
    }

    public static void getCourseWithSyllabusAirwolf(String parentId, String studentId, long courseId, CanvasCallback<Course> callback) {
        if (APIHelpers.paramIsNull(parentId, studentId, callback)) return;

        buildCacheInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback, false).getCourseWithSyllabusAirwolf(parentId, studentId, courseId, callback);
        buildInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback, false).getCourseWithSyllabusAirwolf(parentId, studentId, courseId, callback);
    }

    public static void getCourseWithGradeAirwolf(String parentId, String studentId, long courseId, CanvasCallback<Course> callback) {
        if (APIHelpers.paramIsNull(parentId, studentId, callback)) return;

        buildCacheInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback, false).getCourseWithGradeAirwolf(parentId, studentId, courseId, callback);
        buildInterface(CoursesInterface.class, APIHelpers.getAirwolfDomain(callback.getContext()), callback, false).getCourseWithGradeAirwolf(parentId, studentId, courseId, callback);
    }
    /////////////////////////////////////////////////////////////////////////////
    // Helper Methods
    ////////////////////////////////////////////////////////////////////////////
    public static Map<Long, Course> createCourseMap(Course[] courses) {
        Map<Long, Course> courseMap = new HashMap<Long, Course>();
        if(courses == null) {
            return courseMap;
        }
        for (Course course : courses) {
            courseMap.put(course.getId(), course);
        }
        return courseMap;
    }

    /////////////////////////////////////////////////////////////////////////////
    // Synchronous
    //
    // If Retrofit is unable to parse (no network for example) Synchronous calls
    // will throw a nullPointer exception. All synchronous calls need to be in a
    // try catch block.
    /////////////////////////////////////////////////////////////////////////////

    public static Course[] getAllCoursesSynchronous(Context context) {
        RestAdapter restAdapter = CanvasRestAdapter.buildAdapter(context);

        //If not able to parse (no network for example), this will crash. Handle that case.
        try {
            ArrayList<Course> allCourses = new ArrayList<>();
            int page = 1;
            long firstItemId = -1;

            //for(ever) loop. break once we've run outta stuff;
            for (;;) {
                Course[] courses = restAdapter.create(CoursesInterface.class).getAllCoursesSynchronous(page);
                page++;

                //This is all or nothing. We don't want partial data.
                if(courses == null){
                    return null;
                } else if (courses.length == 0) {
                    break;
                } else if(courses[0].getId() == firstItemId){
                    break;
                } else {
                    firstItemId = courses[0].getId();

                    Collections.addAll(allCourses, courses);
                }
            }

            return allCourses.toArray(new Course[allCourses.size()]);

        } catch (Exception E) {
            return null;
        }
    }

    public static Course[] getFavCoursesSynchronous(Context context) {
        RestAdapter restAdapter = CanvasRestAdapter.buildAdapter(context);

        //If not able to parse (no network for example), this will crash. Handle that case.
        try {
            ArrayList<Course> allCourses = new ArrayList<>();
            int page = 1;
            long firstItemId = -1;

            //for(ever) loop. break once we've run outta stuff;
            for (;;) {
                Course[] courses = restAdapter.create(CoursesInterface.class).getFavCoursesSynchronous(page);
                page++;

                //This is all or nothing. We don't want partial data.
                if(courses == null){
                    return null;
                } else if (courses.length == 0) {
                    break;
                } else if(courses[0].getId() == firstItemId){
                    break;
                } else {
                    firstItemId = courses[0].getId();

                    Collections.addAll(allCourses, courses);
                }
            }

            return allCourses.toArray(new Course[allCourses.size()]);

        } catch (Exception E) {
            return null;
        }
    }

    public static FileUploadParams getFileUploadParams(Context context, long courseId, Long parentFolderId, String fileName, long size, String contentType){
        return buildInterface(CoursesInterface.class, context).getFileUploadParams(courseId, parentFolderId, size, fileName, contentType, "");
    }

    public static FileUploadParams getQuizFileUploadParams(Context context, long courseId, long quizId, String name, String duplicateName){
        return buildInterface(CoursesInterface.class, context, false).getQuizFileUploadParams(name, duplicateName, courseId, quizId, "").getUploadParams().get(0);
    }

    public static Attachment uploadCourseFile(Context context, String uploadUrl, LinkedHashMap<String,String> uploadParams, String mimeType, File file){
        return buildUploadInterface(CoursesInterface.class, uploadUrl).uploadCourseFile(uploadParams, new TypedFile(mimeType, file));
    }

    public static Attachment uploadQuizFile(String uploadUrl, LinkedHashMap<String,String> uploadParams, String mimeType, File file){
        return buildUploadInterface(CoursesInterface.class, uploadUrl).uploadQuizFile(uploadParams, new TypedFile(mimeType, file));
    }
}


text:
package polymorphism.shape;

public class Circle extends Shape{
	public void draw() {
		System.out.println("Circle.draw()");
	}
	public void erase() {
		System.out.println("Circle.erase()");
	}
}

/**Output:

*/

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <parameters>
        <parameter key="fazland_elastica.logger.class">Fazland\ElasticaBundle\Logger\ElasticaLogger</parameter>
        <parameter key="fazland_elastica.data_collector.class">Fazland\ElasticaBundle\DataCollector\ElasticaDataCollector</parameter>
        <parameter key="fazland_elastica.mapping_builder.class">Fazland\ElasticaBundle\Index\MappingBuilder</parameter>
        <parameter key="fazland_elastica.property_accessor.class">Symfony\Component\PropertyAccess\PropertyAccessor</parameter>
        <parameter key="fazland_elastica.property_accessor.magicCall">false</parameter>
        <parameter key="fazland_elastica.property_accessor.throwExceptionOnInvalidIndex">false</parameter>
    </parameters>

    <services>
        <service id="fazland_elastica.client_prototype" class="Fazland\ElasticaBundle\Elastica\Client" abstract="true">
            <argument type="collection" /> <!-- configuration -->
            <argument /> <!-- callback -->

            <call method="setContainer">
                <argument type="service" id="service_container" />
            </call>
            <call method="setEventDispatcher">
                <argument type="service" id="event_dispatcher" on-invalid="null" />
            </call>
        </service>

        <service id="fazland_elastica.request_listener" class="Fazland\ElasticaBundle\DataCollector\RequestListener">
            <call method="setStopwatch">
                <argument type="service" id="debug.stopwatch" on-invalid="ignore" />
            </call>
            <call method="setLogger">
                <argument type="service" id="fazland_elastica.logger" />
            </call>
        </service>

        <service id="fazland_elastica.data_collector" class="%fazland_elastica.data_collector.class%">
            <tag name="data_collector" template="FazlandElasticaBundle:Collector:elastica" id="elastica" />
            <argument type="service" id="fazland_elastica.logger" />
        </service>

        <service id="fazland_elastica.paginator.subscriber" class="Fazland\ElasticaBundle\Subscriber\PaginateElasticaQuerySubscriber">
            <argument type="service" id="request_stack" on-invalid="null" />
            <tag name="knp_paginator.subscriber" />
        </service>

        <service id="fazland_elastica.logger" class="%fazland_elastica.logger.class%">
            <argument type="service" id="logger" on-invalid="null" />
            <argument>%kernel.debug%</argument>
            <tag name="monolog.logger" channel="elastica" />
        </service>

        <service id="fazland_elastica.property_accessor" class="%fazland_elastica.property_accessor.class%">
            <argument>%fazland_elastica.property_accessor.magicCall%</argument>
            <argument>%fazland_elastica.property_accessor.throwExceptionOnInvalidIndex%</argument>
        </service>
    </services>
</container>


text:
/*! AdminLTE app.js
 * ================
 * Main JS application file for AdminLTE v2. This file
 * should be included in all pages. It controls some layout
 * options and implements exclusive AdminLTE plugins.
 *
 * @Author  Almsaeed Studio
 * @Support <http://www.almsaeedstudio.com>
 * @Email   <abdullah@almsaeedstudio.com>
 * @version 2.3.6
 * @license MIT <http://opensource.org/licenses/MIT>
 */

//Make sure jQuery has been loaded before app.js
if (typeof jQuery === "undefined") {
  throw new Error("AdminLTE requires jQuery");
}

/* AdminLTE
 *
 * @type Object
 * @description $.AdminLTE is the main object for the template's app.
 *              It's used for implementing functions and options related
 *              to the template. Keeping everything wrapped in an object
 *              prevents conflict with other plugins and is a better
 *              way to organize our code.
 */
$.AdminLTE = {};

/* --------------------
 * - AdminLTE Options -
 * --------------------
 * Modify these options to suit your implementation
 */
$.AdminLTE.options = {
  //Add slimscroll to navbar menus
  //This requires you to load the slimscroll plugin
  //in every page before app.js
  navbarMenuSlimscroll: true,
  navbarMenuSlimscrollWidth: "3px", //The width of the scroll bar
  navbarMenuHeight: "200px", //The height of the inner menu
  //General animation speed for JS animated elements such as box collapse/expand and
  //sidebar treeview slide up/down. This options accepts an integer as milliseconds,
  //'fast', 'normal', or 'slow'
  animationSpeed: 500,
  //Sidebar push menu toggle button selector
  sidebarToggleSelector: "[data-toggle='offcanvas']",
  //Activate sidebar push menu
  sidebarPushMenu: true,
  //Activate sidebar slimscroll if the fixed layout is set (requires SlimScroll Plugin)
  sidebarSlimScroll: true,
  //Enable sidebar expand on hover effect for sidebar mini
  //This option is forced to true if both the fixed layout and sidebar mini
  //are used together
  sidebarExpandOnHover: false,
  //BoxRefresh Plugin
  enableBoxRefresh: true,
  //Bootstrap.js tooltip
  enableBSToppltip: true,
  BSTooltipSelector: "[data-toggle='tooltip']",
  //Enable Fast Click. Fastclick.js creates a more
  //native touch experience with touch devices. If you
  //choose to enable the plugin, make sure you load the script
  //before AdminLTE's app.js
  enableFastclick: false,
  //Control Sidebar Options
  enableControlSidebar: true,
  controlSidebarOptions: {
    //Which button should trigger the open/close event
    toggleBtnSelector: "[data-toggle='control-sidebar']",
    //The sidebar selector
    selector: ".control-sidebar",
    //Enable slide over content
    slide: true
  },
  //Box Widget Plugin. Enable this plugin
  //to allow boxes to be collapsed and/or removed
  enableBoxWidget: true,
  //Box Widget plugin options
  boxWidgetOptions: {
    boxWidgetIcons: {
      //Collapse icon
      collapse: 'fa-minus',
      //Open icon
      open: 'fa-plus',
      //Remove icon
      remove: 'fa-times'
    },
    boxWidgetSelectors: {
      //Remove button selector
      remove: '[data-widget="remove"]',
      //Collapse button selector
      collapse: '[data-widget="collapse"]'
    }
  },
  //Direct Chat plugin options
  directChat: {
    //Enable direct chat by default
    enable: true,
    //The button to open and close the chat contacts pane
    contactToggleSelector: '[data-widget="chat-pane-toggle"]'
  },
  //Define the set of colors to use globally around the website
  colors: {
    lightBlue: "#3c8dbc",
    red: "#f56954",
    green: "#00a65a",
    aqua: "#00c0ef",
    yellow: "#f39c12",
    blue: "#0073b7",
    navy: "#001F3F",
    teal: "#39CCCC",
    olive: "#3D9970",
    lime: "#01FF70",
    orange: "#FF851B",
    fuchsia: "#F012BE",
    purple: "#8E24AA",
    maroon: "#D81B60",
    black: "#222222",
    gray: "#d2d6de"
  },
  //The standard screen sizes that bootstrap uses.
  //If you change these in the variables.less file, change
  //them here too.
  screenSizes: {
    xs: 480,
    sm: 768,
    md: 992,
    lg: 1200
  }
};

/* ------------------
 * - Implementation -
 * ------------------
 * The next block of code implements AdminLTE's
 * functions and plugins as specified by the
 * options above.
 */
$(function () {
  "use strict";

  //Fix for IE page transitions
  $("body").removeClass("hold-transition");

  //Extend options if external options exist
  if (typeof AdminLTEOptions !== "undefined") {
    $.extend(true,
      $.AdminLTE.options,
      AdminLTEOptions);
  }

  //Easy access to options
  var o = $.AdminLTE.options;

  //Set up the object
  _init();

  //Activate the layout maker
  $.AdminLTE.layout.activate();

  //Enable sidebar tree view controls
  $.AdminLTE.tree('.sidebar');

  //Enable control sidebar
  if (o.enableControlSidebar) {
    $.AdminLTE.controlSidebar.activate();
  }

  //Add slimscroll to navbar dropdown
  if (o.navbarMenuSlimscroll && typeof $.fn.slimscroll != 'undefined') {
    $(".navbar .menu").slimscroll({
      height: o.navbarMenuHeight,
      alwaysVisible: false,
      size: o.navbarMenuSlimscrollWidth
    }).css("width", "100%");
  }

  //Activate sidebar push menu
  if (o.sidebarPushMenu) {
    $.AdminLTE.pushMenu.activate(o.sidebarToggleSelector);
  }

  //Activate Bootstrap tooltip
  if (o.enableBSToppltip) {
    $('body').tooltip({
      selector: o.BSTooltipSelector
    });
  }

  //Activate box widget
  if (o.enableBoxWidget) {
    $.AdminLTE.boxWidget.activate();
  }

  //Activate fast click
  if (o.enableFastclick && typeof FastClick != 'undefined') {
    FastClick.attach(document.body);
  }

  //Activate direct chat widget
  if (o.directChat.enable) {
    $(document).on('click', o.directChat.contactToggleSelector, function () {
      var box = $(this).parents('.direct-chat').first();
      box.toggleClass('direct-chat-contacts-open');
    });
  }

  /*
   * INITIALIZE BUTTON TOGGLE
   * ------------------------
   */
  $('.btn-group[data-toggle="btn-toggle"]').each(function () {
    var group = $(this);
    $(this).find(".btn").on('click', function (e) {
      group.find(".btn.active").removeClass("active");
      $(this).addClass("active");
      e.preventDefault();
    });

  });
});

/* ----------------------------------
 * - Initialize the AdminLTE Object -
 * ----------------------------------
 * All AdminLTE functions are implemented below.
 */
function _init() {
  'use strict';
  /* Layout
   * ======
   * Fixes the layout height in case min-height fails.
   *
   * @type Object
   * @usage $.AdminLTE.layout.activate()
   *        $.AdminLTE.layout.fix()
   *        $.AdminLTE.layout.fixSidebar()
   */
  $.AdminLTE.layout = {
    activate: function () {
      var _this = this;
      _this.fix();
      _this.fixSidebar();
      $(window, ".wrapper").resize(function () {
        _this.fix();
        _this.fixSidebar();
      });
    },
    fix: function () {
      //Get window height and the wrapper height
      var neg = $('.main-header').outerHeight() + $('.main-footer').outerHeight();
      var window_height = $(window).height();
      var sidebar_height = $(".sidebar").height();
      //Set the min-height of the content and sidebar based on the
      //the height of the document.
      if ($("body").hasClass("fixed")) {
        $(".content-wrapper, .right-side").css('height', window_height - $('.main-footer').outerHeight());
      } else {
        var postSetWidth;
        if (window_height >= sidebar_height) {
          $(".content-wrapper, .right-side").css('min-height', window_height - neg);
          postSetWidth = window_height - neg;
        } else {
          $(".content-wrapper, .right-side").css('min-height', sidebar_height);
          postSetWidth = sidebar_height;
        }

        //Fix for the control sidebar height
        var controlSidebar = $($.AdminLTE.options.controlSidebarOptions.selector);
        if (typeof controlSidebar !== "undefined") {
          if (controlSidebar.height() > postSetWidth)
            $(".content-wrapper, .right-side").css('min-height', controlSidebar.height());
        }

      }
    },
    fixSidebar: function () {
      //Make sure the body tag has the .fixed class
      if (!$("body").hasClass("fixed")) {
        if (typeof $.fn.slimScroll != 'undefined') {
          $(".sidebar").slimScroll({destroy: true}).height("auto");
        }
        return;
      } else if (typeof $.fn.slimScroll == 'undefined' && window.console) {
        window.console.error("Error: the fixed layout requires the slimscroll plugin!");
      }
      //Enable slimscroll for fixed layout
      if ($.AdminLTE.options.sidebarSlimScroll) {
        if (typeof $.fn.slimScroll != 'undefined') {
          //Destroy if it exists
          $(".sidebar").slimScroll({destroy: true}).height("auto");
          //Add slimscroll
          $(".sidebar").slimscroll({
            height: ($(window).height() - $(".main-header").height()) + "px",
            color: "rgba(0,0,0,0.2)",
            size: "3px"
          });
        }
      }
    }
  };

  /* PushMenu()
   * ==========
   * Adds the push menu functionality to the sidebar.
   *
   * @type Function
   * @usage: $.AdminLTE.pushMenu("[data-toggle='offcanvas']")
   */
  $.AdminLTE.pushMenu = {
    activate: function (toggleBtn) {
      //Get the screen sizes
      var screenSizes = $.AdminLTE.options.screenSizes;

      //Enable sidebar toggle
      $(document).on('click', toggleBtn, function (e) {
        e.preventDefault();

        //Enable sidebar push menu
        if ($(window).width() > (screenSizes.sm - 1)) {
          if ($("body").hasClass('sidebar-collapse')) {
            $("body").removeClass('sidebar-collapse').trigger('expanded.pushMenu');
          } else {
            $("body").addClass('sidebar-collapse').trigger('collapsed.pushMenu');
          }
        }
        //Handle sidebar push menu for small screens
        else {
          if ($("body").hasClass('sidebar-open')) {
            $("body").removeClass('sidebar-open').removeClass('sidebar-collapse').trigger('collapsed.pushMenu');
          } else {
            $("body").addClass('sidebar-open').trigger('expanded.pushMenu');
          }
        }
      });

      $(".content-wrapper").click(function () {
        //Enable hide menu when clicking on the content-wrapper on small screens
        if ($(window).width() <= (screenSizes.sm - 1) && $("body").hasClass("sidebar-open")) {
          $("body").removeClass('sidebar-open');
        }
      });

      //Enable expand on hover for sidebar mini
      if ($.AdminLTE.options.sidebarExpandOnHover
        || ($('body').hasClass('fixed')
        && $('body').hasClass('sidebar-mini'))) {
        this.expandOnHover();
      }
    },
    expandOnHover: function () {
      var _this = this;
      var screenWidth = $.AdminLTE.options.screenSizes.sm - 1;
      //Expand sidebar on hover
      $('.main-sidebar').hover(function () {
        if ($('body').hasClass('sidebar-mini')
          && $("body").hasClass('sidebar-collapse')
          && $(window).width() > screenWidth) {
          _this.expand();
        }
      }, function () {
        if ($('body').hasClass('sidebar-mini')
          && $('body').hasClass('sidebar-expanded-on-hover')
          && $(window).width() > screenWidth) {
          _this.collapse();
        }
      });
    },
    expand: function () {
      $("body").removeClass('sidebar-collapse').addClass('sidebar-expanded-on-hover');
    },
    collapse: function () {
      if ($('body').hasClass('sidebar-expanded-on-hover')) {
        $('body').removeClass('sidebar-expanded-on-hover').addClass('sidebar-collapse');
      }
    }
  };

  /* Tree()
   * ======
   * Converts the sidebar into a multilevel
   * tree view menu.
   *
   * @type Function
   * @Usage: $.AdminLTE.tree('.sidebar')
   */
  $.AdminLTE.tree = function (menu) {
    var _this = this;
    var animationSpeed = $.AdminLTE.options.animationSpeed;
    $(document).off('click', menu + ' li a')
      .on('click', menu + ' li a', function (e) {
        //Get the clicked link and the next element
        var $this = $(this);
        var checkElement = $this.next();

        //Check if the next element is a menu and is visible
        if ((checkElement.is('.treeview-menu')) && (checkElement.is(':visible')) && (!$('body').hasClass('sidebar-collapse'))) {
          //Close the menu
          checkElement.slideUp(animationSpeed, function () {
            checkElement.removeClass('menu-open');
            //Fix the layout in case the sidebar stretches over the height of the window
            //_this.layout.fix();
          });
          checkElement.parent("li").removeClass("active");
        }
        //If the menu is not visible
        else if ((checkElement.is('.treeview-menu')) && (!checkElement.is(':visible'))) {
          //Get the parent menu
          var parent = $this.parents('ul').first();
          //Close all open menus within the parent
          var ul = parent.find('ul:visible').slideUp(animationSpeed);
          //Remove the menu-open class from the parent
          ul.removeClass('menu-open');
          //Get the parent li
          var parent_li = $this.parent("li");

          //Open the target menu and add the menu-open class
          checkElement.slideDown(animationSpeed, function () {
            //Add the class active to the parent li
            checkElement.addClass('menu-open');
            parent.find('li.active').removeClass('active');
            parent_li.addClass('active');
            //Fix the layout in case the sidebar stretches over the height of the window
            _this.layout.fix();
          });
        }
        //if this isn't a link, prevent the page from being redirected
        if (checkElement.is('.treeview-menu')) {
          e.preventDefault();
        // }else if($("body").hasClass("ajax-template")){
        //   var target = $this.attr("href");
        //   $("#loading").show();
        //   // if (typeof target === 'string') {
        //   //   $("body").animate({
        //   //     scrollTop: ($(target).offset().top) + "px"
        //   //   }, 500);
        //   // }
        //   $.ajax({
        //     url:target,
        //     dataType:"html",
        //     success:function(result){
        //       // console.log(result)
        //       $(".content").html(result);
        //       $("#loading").hide();
        //     },
        //     error:function(err){
        //       $("#loading").hide();
        //       console.log(err)
        //     }
        //   })
        //   // var htmlobj=$.ajax({url:target,async:false});
        //   return false;
        }
      });
  };

  /* ControlSidebar
   * ==============
   * Adds functionality to the right sidebar
   *
   * @type Object
   * @usage $.AdminLTE.controlSidebar.activate(options)
   */
  $.AdminLTE.controlSidebar = {
    //instantiate the object
    activate: function () {
      //Get the object
      var _this = this;
      //Update options
      var o = $.AdminLTE.options.controlSidebarOptions;
      //Get the sidebar
      var sidebar = $(o.selector);
      //The toggle button
      var btn = $(o.toggleBtnSelector);

      //Listen to the click event
      btn.on('click', function (e) {
        e.preventDefault();
        //If the sidebar is not open
        if (!sidebar.hasClass('control-sidebar-open')
          && !$('body').hasClass('control-sidebar-open')) {
          //Open the sidebar
          _this.open(sidebar, o.slide);
        } else {
          _this.close(sidebar, o.slide);
        }
      });

      //If the body has a boxed layout, fix the sidebar bg position
      var bg = $(".control-sidebar-bg");
      _this._fix(bg);

      //If the body has a fixed layout, make the control sidebar fixed
      if ($('body').hasClass('fixed')) {
        _this._fixForFixed(sidebar);
      } else {
        //If the content height is less than the sidebar's height, force max height
        if ($('.content-wrapper, .right-side').height() < sidebar.height()) {
          _this._fixForContent(sidebar);
        }
      }
    },
    //Open the control sidebar
    open: function (sidebar, slide) {
      //Slide over content
      if (slide) {
        sidebar.addClass('control-sidebar-open');
      } else {
        //Push the content by adding the open class to the body instead
        //of the sidebar itself
        $('body').addClass('control-sidebar-open');
      }
    },
    //Close the control sidebar
    close: function (sidebar, slide) {
      if (slide) {
        sidebar.removeClass('control-sidebar-open');
      } else {
        $('body').removeClass('control-sidebar-open');
      }
    },
    _fix: function (sidebar) {
      var _this = this;
      if ($("body").hasClass('layout-boxed')) {
        sidebar.css('position', 'absolute');
        sidebar.height($(".wrapper").height());
        if (_this.hasBindedResize) {
          return;
        }
        $(window).resize(function () {
          _this._fix(sidebar);
        });
        _this.hasBindedResize = true;
      } else {
        sidebar.css({
          'position': 'fixed',
          'height': 'auto'
        });
      }
    },
    _fixForFixed: function (sidebar) {
      sidebar.css({
        'position': 'fixed',
        'max-height': '100%',
        'overflow': 'auto',
        'padding-bottom': '50px'
      });
    },
    _fixForContent: function (sidebar) {
      $(".content-wrapper, .right-side").css('min-height', sidebar.height());
    }
  };

  /* BoxWidget
   * =========
   * BoxWidget is a plugin to handle collapsing and
   * removing boxes from the screen.
   *
   * @type Object
   * @usage $.AdminLTE.boxWidget.activate()
   *        Set all your options in the main $.AdminLTE.options object
   */
  $.AdminLTE.boxWidget = {
    selectors: $.AdminLTE.options.boxWidgetOptions.boxWidgetSelectors,
    icons: $.AdminLTE.options.boxWidgetOptions.boxWidgetIcons,
    animationSpeed: $.AdminLTE.options.animationSpeed,
    activate: function (_box) {
      var _this = this;
      if (!_box) {
        _box = document; // activate all boxes per default
      }
      //Listen for collapse event triggers
      $(_box).on('click', _this.selectors.collapse, function (e) {
        e.preventDefault();
        _this.collapse($(this));
      });

      //Listen for remove event triggers
      $(_box).on('click', _this.selectors.remove, function (e) {
        e.preventDefault();
        _this.remove($(this));
      });
    },
    collapse: function (element) {
      var _this = this;
      //Find the box parent
      var box = element.parents(".box").first();
      //Find the body and the footer
      var box_content = box.find("> .box-body, > .box-footer, > form  >.box-body, > form > .box-footer");
      if (!box.hasClass("collapsed-box")) {
        //Convert minus into plus
        element.children(":first")
          .removeClass(_this.icons.collapse)
          .addClass(_this.icons.open);
        //Hide the content
        box_content.slideUp(_this.animationSpeed, function () {
          box.addClass("collapsed-box");
        });
      } else {
        //Convert plus into minus
        element.children(":first")
          .removeClass(_this.icons.open)
          .addClass(_this.icons.collapse);
        //Show the content
        box_content.slideDown(_this.animationSpeed, function () {
          box.removeClass("collapsed-box");
        });
      }
    },
    remove: function (element) {
      //Find the box parent
      var box = element.parents(".box").first();
      box.slideUp(this.animationSpeed);
    }
  };
}

/* ------------------
 * - Custom Plugins -
 * ------------------
 * All custom plugins are defined below.
 */

/*
 * BOX REFRESH BUTTON
 * ------------------
 * This is a custom plugin to use with the component BOX. It allows you to add
 * a refresh button to the box. It converts the box's state to a loading state.
 *
 * @type plugin
 * @usage $("#box-widget").boxRefresh( options );
 */
(function ($) {

  "use strict";

  $.fn.boxRefresh = function (options) {

    // Render options
    var settings = $.extend({
      //Refresh button selector
      trigger: ".refresh-btn",
      //File source to be loaded (e.g: ajax/src.php)
      source: "",
      //Callbacks
      onLoadStart: function (box) {
        return box;
      }, //Right after the button has been clicked
      onLoadDone: function (box) {
        return box;
      } //When the source has been loaded

    }, options);

    //The overlay
    var overlay = $('<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>');

    return this.each(function () {
      //if a source is specified
      if (settings.source === "") {
        if (window.console) {
          window.console.log("Please specify a source first - boxRefresh()");
        }
        return;
      }
      //the box
      var box = $(this);
      //the button
      var rBtn = box.find(settings.trigger).first();

      //On trigger click
      rBtn.on('click', function (e) {
        e.preventDefault();
        //Add loading overlay
        start(box);

        //Perform ajax call
        box.find(".box-body").load(settings.source, function () {
          done(box);
        });
      });
    });

    function start(box) {
      //Add overlay and loading img
      box.append(overlay);

      settings.onLoadStart.call(box);
    }

    function done(box) {
      //Remove overlay and loading img
      box.find(overlay).remove();

      settings.onLoadDone.call(box);
    }

  };

})(jQuery);

/*
 * EXPLICIT BOX CONTROLS
 * -----------------------
 * This is a custom plugin to use with the component BOX. It allows you to activate
 * a box inserted in the DOM after the app.js was loaded, toggle and remove box.
 *
 * @type plugin
 * @usage $("#box-widget").activateBox();
 * @usage $("#box-widget").toggleBox();
 * @usage $("#box-widget").removeBox();
 */
(function ($) {

  'use strict';

  $.fn.activateBox = function () {
    $.AdminLTE.boxWidget.activate(this);
  };

  $.fn.toggleBox = function () {
    var button = $($.AdminLTE.boxWidget.selectors.collapse, this);
    $.AdminLTE.boxWidget.collapse(button);
  };

  $.fn.removeBox = function () {
    var button = $($.AdminLTE.boxWidget.selectors.remove, this);
    $.AdminLTE.boxWidget.remove(button);
  };

})(jQuery);

/*
 * TODO LIST CUSTOM PLUGIN
 * -----------------------
 * This plugin depends on iCheck plugin for checkbox and radio inputs
 *
 * @type plugin
 * @usage $("#todo-widget").todolist( options );
 */
(function ($) {

  'use strict';

  $.fn.todolist = function (options) {
    // Render options
    var settings = $.extend({
      //When the user checks the input
      onCheck: function (ele) {
        return ele;
      },
      //When the user unchecks the input
      onUncheck: function (ele) {
        return ele;
      }
    }, options);

    return this.each(function () {

      if (typeof $.fn.iCheck != 'undefined') {
        $('input', this).on('ifChecked', function () {
          var ele = $(this).parents("li").first();
          ele.toggleClass("done");
          settings.onCheck.call(ele);
        });

        $('input', this).on('ifUnchecked', function () {
          var ele = $(this).parents("li").first();
          ele.toggleClass("done");
          settings.onUncheck.call(ele);
        });
      } else {
        $('input', this).on('change', function () {
          var ele = $(this).parents("li").first();
          ele.toggleClass("done");
          if ($('input', ele).is(":checked")) {
            settings.onCheck.call(ele);
          } else {
            settings.onUncheck.call(ele);
          }
        });
      }
    });
  };
}(jQuery));

/**
 * AdminLTE Demo Menu
 * ------------------
 * You should not use this file in production.
 * This file is for demo purposes only.
 */
(function ($, AdminLTE) {

  "use strict";

  /**
   * List of all the available skins
   *
   * @type Array
   */
  var my_skins = [
    "skin-blue",
    "skin-black",
    "skin-red",
    "skin-yellow",
    "skin-purple",
    "skin-green",
    "skin-blue-light",
    "skin-black-light",
    "skin-red-light",
    "skin-yellow-light",
    "skin-purple-light",
    "skin-green-light"
  ];

  //Create the new tab
  var tab_pane = $("<div />", {
    "id": "control-sidebar-theme-demo-options-tab",
    "class": "tab-pane active"
  });

  //Create the tab button
  var tab_button = $("<li />", {"class": "active"})
      .html("<a href='#control-sidebar-theme-demo-options-tab' data-toggle='tab'>"
      + "<i class='fa fa-wrench'></i>"
      + "</a>");

  //Add the tab button to the right sidebar tabs
  $("[href='#control-sidebar-home-tab']")
      .parent()
      .before(tab_button);

  //Create the menu
  var demo_settings = $("<div />");

  //Layout options
  demo_settings.append(
      "<h4 class='control-sidebar-heading'>"
      + "布局选项"
      + "</h4>"
        //Fixed layout
      // + "<div class='form-group'>"
      // + "<label class='control-sidebar-subheading'>"
      // + "<input type='checkbox' data-layout='fixed' class='pull-right'/> "
      // + "固定布局"
      // + "</label>"
      // + "<p>激活固定布局。你不能使用固定和装箱的布局</p>"
      // + "</div>"
      //   //Boxed layout
      // + "<div class='form-group'>"
      // + "<label class='control-sidebar-subheading'>"
      // + "<input type='checkbox' data-layout='layout-boxed'class='pull-right'/> "
      // + "装箱布局"
      // + "</label>"
      // + "<p>激活装箱布局</p>"
      // + "</div>"
        //Sidebar Toggle
      + "<div class='form-group'>"
      + "<label class='control-sidebar-subheading'>"
      + "<input type='checkbox' data-layout='sidebar-collapse' class='pull-right'/> "
      + "切换侧边栏"
      + "</label>"
      + "<p>左侧边栏是否展开</p>"
      + "</div>"
        //Sidebar mini expand on hover toggle
      // + "<div class='form-group'>"
      // + "<label class='control-sidebar-subheading'>"
      // + "<input type='checkbox' data-enable='expandOnHover' class='pull-right'/> "
      // + "侧边栏自动伸缩"
      // + "</label>"
      // + "<p>让侧边栏迷你和展开自动切换</p>"
      // + "</div>"
        //Control Sidebar Toggle
      + "<div class='form-group'>"
      + "<label class='control-sidebar-subheading'>"
      + "<input type='checkbox' data-controlsidebar='control-sidebar-open' class='pull-right'/> "
      + "右侧边栏的滑动切换"
      + "</label>"
      + "<p>右侧边栏固定和浮动之间的切换</p>"
      + "</div>"
        //Control Sidebar Skin Toggle
      + "<div class='form-group'>"
      + "<label class='control-sidebar-subheading'>"
      + "<input type='checkbox' data-sidebarskin='toggle' class='pull-right'/> "
      + "切换右侧边栏的皮肤"
      + "</label>"
      + "<p>切换右侧边栏的深色皮肤和浅色皮肤</p>"
      + "</div>"
  );
  var skins_list = $("<ul />", {"class": 'list-unstyled clearfix'});

  //Dark sidebar skins
  var skin_blue =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-blue' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px; background: #367fa9;'></span><span class='bg-light-blue' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin'>Blue</p>");
  skins_list.append(skin_blue);
  var skin_black =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-black' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div style='box-shadow: 0 0 2px rgba(0,0,0,0.1)' class='clearfix'><span style='display:block; width: 20%; float: left; height: 7px; background: #fefefe;'></span><span style='display:block; width: 80%; float: left; height: 7px; background: #fefefe;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin'>Black</p>");
  skins_list.append(skin_black);
  var skin_purple =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-purple' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-purple-active'></span><span class='bg-purple' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin'>Purple</p>");
  skins_list.append(skin_purple);
  var skin_green =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-green' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-green-active'></span><span class='bg-green' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin'>Green</p>");
  skins_list.append(skin_green);
  var skin_red =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-red' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-red-active'></span><span class='bg-red' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin'>Red</p>");
  skins_list.append(skin_red);
  var skin_yellow =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-yellow' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-yellow-active'></span><span class='bg-yellow' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #222d32;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin'>Yellow</p>");
  skins_list.append(skin_yellow);

  //Light sidebar skins
  var skin_blue_light =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-blue-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px; background: #367fa9;'></span><span class='bg-light-blue' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin' style='font-size: 12px'>Blue Light</p>");
  skins_list.append(skin_blue_light);
  var skin_black_light =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-black-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div style='box-shadow: 0 0 2px rgba(0,0,0,0.1)' class='clearfix'><span style='display:block; width: 20%; float: left; height: 7px; background: #fefefe;'></span><span style='display:block; width: 80%; float: left; height: 7px; background: #fefefe;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin' style='font-size: 12px'>Black Light</p>");
  skins_list.append(skin_black_light);
  var skin_purple_light =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-purple-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-purple-active'></span><span class='bg-purple' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin' style='font-size: 12px'>Purple Light</p>");
  skins_list.append(skin_purple_light);
  var skin_green_light =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-green-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-green-active'></span><span class='bg-green' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin' style='font-size: 12px'>Green Light</p>");
  skins_list.append(skin_green_light);
  var skin_red_light =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-red-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-red-active'></span><span class='bg-red' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin' style='font-size: 12px'>Red Light</p>");
  skins_list.append(skin_red_light);
  var skin_yellow_light =
      $("<li />", {style: "float:left; width: 33.33333%; padding: 5px;"})
          .append("<a href='javascript:void(0);' data-skin='skin-yellow-light' style='display: block; box-shadow: 0 0 3px rgba(0,0,0,0.4)' class='clearfix full-opacity-hover'>"
          + "<div><span style='display:block; width: 20%; float: left; height: 7px;' class='bg-yellow-active'></span><span class='bg-yellow' style='display:block; width: 80%; float: left; height: 7px;'></span></div>"
          + "<div><span style='display:block; width: 20%; float: left; height: 20px; background: #f9fafc;'></span><span style='display:block; width: 80%; float: left; height: 20px; background: #f4f5f7;'></span></div>"
          + "</a>"
          + "<p class='text-center no-margin' style='font-size: 12px;'>Yellow Light</p>");
  skins_list.append(skin_yellow_light);

  demo_settings.append("<h4 class='control-sidebar-heading'>皮肤</h4>");
  demo_settings.append(skins_list);

  tab_pane.append(demo_settings);
  $("#control-sidebar-home-tab").after(tab_pane);

  setup();

  /**
   * Toggles layout classes
   *
   * @param String cls the layout class to toggle
   * @returns void
   */
  function change_layout(cls) {
    $("body").toggleClass(cls);
    AdminLTE.layout.fixSidebar();
    //Fix the problem with right sidebar and layout boxed
    if (cls == "layout-boxed")
      AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
    if ($('body').hasClass('fixed') && cls == 'fixed') {
      AdminLTE.pushMenu.expandOnHover();
      AdminLTE.layout.activate();
    }
    AdminLTE.controlSidebar._fix($(".control-sidebar-bg"));
    AdminLTE.controlSidebar._fix($(".control-sidebar"));
  }

  /**
   * Replaces the old skin with the new skin
   * @param String cls the new skin class
   * @returns Boolean false to prevent link's default action
   */
  function change_skin(cls) {
    $.each(my_skins, function (i) {
      $("body").removeClass(my_skins[i]);
    });

    $("body").addClass(cls);
    store('skin', cls);
    return false;
  }

  /**
   * Store a new settings in the browser
   *
   * @param String name Name of the setting
   * @param String val Value of the setting
   * @returns void
   */
  function store(name, val) {
    if (typeof (Storage) !== "undefined") {
      localStorage.setItem(name, val);
    } else {
      window.alert('Please use a modern browser to properly view this template!');
    }
  }

  /**
   * Get a prestored setting
   *
   * @param String name Name of of the setting
   * @returns String The value of the setting | null
   */
  function get(name) {
    if (typeof (Storage) !== "undefined") {
      return localStorage.getItem(name);
    } else {
      window.alert('Please use a modern browser to properly view this template!');
    }
  }

  /**
   * Retrieve default settings and apply them to the template
   *
   * @returns void
   */
  function setup() {
    var tmp = get('skin');
    if (tmp && $.inArray(tmp, my_skins))
      change_skin(tmp);

    //Add the change skin listener
    $("[data-skin]").on('click', function (e) {
      if($(this).hasClass('knob'))
        return;
      e.preventDefault();
      change_skin($(this).data('skin'));
    });

    //Add the layout manager
    $("[data-layout]").on('click', function () {
      change_layout($(this).data('layout'));
    });

    $("[data-controlsidebar]").on('click', function () {
      change_layout($(this).data('controlsidebar'));
      var slide = !AdminLTE.options.controlSidebarOptions.slide;
      AdminLTE.options.controlSidebarOptions.slide = slide;
      if (!slide)
        $('.control-sidebar').removeClass('control-sidebar-open');
    });

    $("[data-sidebarskin='toggle']").on('click', function () {
      var sidebar = $(".control-sidebar");
      if (sidebar.hasClass("control-sidebar-dark")) {
        sidebar.removeClass("control-sidebar-dark")
        sidebar.addClass("control-sidebar-light")
      } else {
        sidebar.removeClass("control-sidebar-light")
        sidebar.addClass("control-sidebar-dark")
      }
    });

    $("[data-enable='expandOnHover']").on('click', function () {
      $(this).attr('disabled', true);
      AdminLTE.pushMenu.expandOnHover();
      if (!$('body').hasClass('sidebar-collapse'))
        $("[data-layout='sidebar-collapse']").click();
    });

    // Reset options
    if ($('body').hasClass('fixed')) {
      $("[data-layout='fixed']").attr('checked', 'checked');
    }
    if ($('body').hasClass('layout-boxed')) {
      $("[data-layout='layout-boxed']").attr('checked', 'checked');
    }
    if ($('body').hasClass('sidebar-collapse')) {
      $("[data-layout='sidebar-collapse']").attr('checked', 'checked');
    }

  }
})(jQuery, $.AdminLTE);

/*
 * 自定义事件
 * -----------------------
 */
(function ($) {
  // 打开tab页
  $(".ajax-template").on("click","a[target='navTab']",function(){
    var that = $(this);
    var _text = that.text();
    var _href = that.attr("href");
    if (!$("#navTabs li[url='"+_href+"']").length) {

        $("#loading").show();
        $.ajax({
          url:_href,
          dataType:"html",
          success:function(result){
            $("#loading").hide();
            // $.each($(result),function(i,item){

            //   if (item.nodeName == "LINK" || item.nodeName == "link") {
            //     require1(item.href);
            //   }
            //   if (item.nodeName == "SCRIPT" || item.nodeName == "script" && !!item.src) {
            //     require1(item.src);
            //   }
            // })
            $("#navTabs").append('<li url="'+_href+'"><span>'+_text+'</span><a href="javascript:void(0);" class="fa fa-close"></a></li>');
            $("#content").append('<div class="tabs-panel">'+result+'</div>');
            showTab($("#navTabs li[url='"+_href+"']"));
          },
          error:function(err){
            $("#loading").hide();
            console.log(err)
          }
        })
    }else{
      showTab($("#navTabs li[url='"+_href+"']"));
    }

    if (that.parents(".sidebar-menu").length) {
      that.parent("li").addClass("active").siblings().removeClass("active");
    }
    return false;
  });

  // 点击tab标签
  $("#navTabs").on("click","li",function(){
    showTab($(this));
  });
  // tab标签右键菜单
  $("#navTabs").on("contextmenu","li",function(e){
    e.preventDefault();
    var that = $(this);
    var w = that.width();
    var i = that.index();
    var bl = $(".content-header-navtabs").offset().left;
    $("#contextMenu").show().css("left",e.clientX-bl).attr("is",i);
    return false;
  });
  // 关闭tab标签
  $("#navTabs").on("click",".fa-close",function(){
    var index = $(this).parents("li").index();
    showTab($(this).parents("li").prev());
    $("#content .tabs-panel").eq(index).remove();
    $(this).parents("li").remove();
  });
  // 关闭tab标签
  $("#contextMenu").on("click","li",function(){
    var rel = $(this).attr("rel");
    var i = $("#contextMenu").attr("is");
    if (rel === "reload") {
      var _href = $("#navTabs>li").eq(i).attr("url");
      if (!_href) return false;
        $("#loading").show();
        $.ajax({
          url:_href,
          dataType:"html",
          success:function(result){
            $("#loading").hide();
            $("#content>.tabs-panel").eq(i).html(result)
            showTab($("#navTabs li[url='"+_href+"']"));
          },
          error:function(err){
            $("#loading").hide();
            console.log(err)
          }
        })

    }else if (rel === "closeCurrent"){
      if (i == 0) return false;
      if ($("#navTabs>li").eq(i).hasClass("active")) {
        $("#navTabs>li").eq(0).addClass("active");
        $("#content>.tabs-panel").eq(0).show();
      }

      $("#navTabs>li").eq(i).remove();
      $("#content>.tabs-panel").eq(i).remove();

    }else if (rel === "closeOther"){

      $("#navTabs>li").eq(0).nextAll().attr("sel","temp");
      $("#navTabs>li").eq(i).addClass("active").removeAttr("sel");
      $("#navTabs>li[sel='temp']").remove();
      $("#content>.tabs-panel").eq(0).nextAll().attr("sel","temp");
      $("#content>.tabs-panel").eq(i).show().removeAttr("sel");
      $("#content>.tabs-panel[sel='temp']").remove();

    }else if (rel === "closeAll"){

      $("#navTabs>li").eq(0).addClass("active").nextAll().remove();
      $("#content>.tabs-panel").eq(0).show().nextAll().remove();

    }
    $("#contextMenu").hide();
  });
  // tab标签上一页、下一页
  $("#navTabs").nextAll("a").on("click",function(){
    var ml = parseInt($("#navTabs").css("marginLeft"));
    var itemL = $("#navTabs>li").length;
    var itemW = $("#navTabs>li").eq(0).width();
    var boxW = $("#navTabs").parent().width();
    if ($(this).hasClass("next")) {
      if (itemL*itemW+ml-boxW>0) {
        ml -= itemW*2;
      }
    }else{
      if (ml>itemW*2) {
        ml += itemW*2;
      }else{
        ml = 0;
      }
    }
    $("#navTabs").css("marginLeft",ml);
  });
  // show tab页内容
  function showTab(that){
    var itemL = $("#navTabs>li").length;
    var itemW = $("#navTabs>li").eq(0).width();
    var boxW = $("#navTabs").parent().width();
    that.addClass("active").siblings().removeClass("active");    $("#content>.tabs-panel").eq(that.index()).show().siblings().hide();
    if (itemL * itemW > boxW-itemW) {
      $("#navTabs").width(itemL*itemW+itemW).parent().addClass("more");
      var pl = that.prevAll().length;
      if (pl * itemW > boxW-itemW) {
        $("#navTabs").css("marginLeft",boxW-pl * itemW-itemW-30);
      }else{
        $("#navTabs").css("marginLeft",0);
      }
    }else{
      $("#navTabs").width("100%").parent().removeClass("more");
    }
  }

// 打开对话框
$(document).on("click","a[target='modal']",function(){
  var that = $(this);
  var href = that.attr("href");
  var method = that.attr("method") == "post"?"post":"get";
  var modal = that.attr("modal")
  $("#loading").show();
  $.ajax({
    url:href,
    type:method,
    dataType:"html",
    success:function(result){
      $("#loading").hide();
      $("#lgModal").find(".modal-dialog").attr("class","modal-dialog modal-"+modal);
      $("#lgModal").find(".modal-body").html(result).end().modal("show");
    },
    error:function(){
      $("#loading").hide();
      console.error("加载失败");
    }
  })
  return false;
})

// 确认对话框
$(document).on("click","a[target='ajaxTodo']",function(){
  var that = $(this);
  var href = that.attr("href");
  var title = that.attr("data-body");
  var cb = that.attr("callback");
    $("#smModal").attr("action",href).attr("callback",cb).find(".modal-body").html(title).end().modal("show");

  return false;
});
// 点击界面
$(document).on("click",function(){
  $("#contextMenu").hide();
});
$("#smModal").on("click",".modal-footer>.btn-primary",function(){
  var action = $("#smModal").attr("action");
  var clcb = $("#smModal").attr("callback");
  if (!action) {
    $("#smModal").modal("hide");
    return false;
  }

  $.get(action,function(){
    $("#smModal").modal("hide");
    if (!!clcb) {
      // console.log(clcb);
      eval(clcb);
    }else{
      alertMsg("操作成功","success");
    }
  })

})

}(jQuery));

var alertsetTime;
function alertMsg(text,type){
  if (!$("#alertMsgBox").length) {
  var html =  '<div class="box box-danger box-solid" id="alertMsgBox">'
              +'  <div class="box-header with-border">'
              +'    <h3 class="box-title">提示</h3>'
              +'    <div class="box-tools pull-right">'
              +'      <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>'
              +'    </div>'
              +'  </div>'
              +'  <div class="box-body"></div>'
              +'</div>'
    $("body").append(html)
    }
    if (!text) text="提示内容不可为空";
    if (!type) type?type:"default";
    clearTimeout(alertsetTime);
    $("#alertMsgBox").attr("class","box box-"+type+" box-solid").stop().slideDown("slow").find(".box-body").html(text);
  alertsetTime = setTimeout(function(){
    $("#alertMsgBox").slideUp("slow");
  },4000)
}

  // 动态提示
function modal1(){
  if($("#modalMain").length == 0){
    var html =  '<div class="modal fade" id="modalMain">'
                +'  <div class="modal-dialog modal-sm">'
                +'    <div class="modal-content">'
                +'      <div class="modal-header">'
                +'        <button type="button" class="close" data-dismiss="modal" aria-label="Close">'
                +'          <span aria-hidden="true">×</span></button>'
                +'        <h4 class="modal-title">提示</h4>'
                +'      </div>'
                +'      <div class="modal-body">'
                +'        <p>提示什么?</p>'
                +'     </div>'
                +'      <div class="modal-footer">'
                +'        <button type="button" aria-label="Close" class="btn btn-default" data-dismiss="modal">close</button>'
                +'        <button type="button" class="btn btn-primary" aria-label="primary">确认</button>'
                +'      </div>'
                +'    </div>'
                +'    <!-- /.modal-content -->'
                +'  </div>'
                +'  <!-- /.modal-dialog -->'
                +'</div>'
    $("body").append(html)
  }

}


text:
/*******************************************************************************
 * texture.h - complex texture access
 *******************************************************************************
 * Add license here...
 *******************************/

#ifndef TEXTURE_H
#define	TEXTURE_H

#include <algebra.h>
#include <boost/shared_array.hpp>
#include <iostream>
#include <mex.h>
#include <new>

namespace pm {

	// round implementation (this is not perfect!)
	inline int round(float f) {
		int i = std::floor(f + 0.5f);
		if (i - f > 0.5f) std::cerr << "Invalid floor of " << f << " = " << i << "\n";
		return i;
	}
	template <typename T>
	inline T roundOrNot(float f);
	template <>
	inline float roundOrNot<float>(float f){
		return f;
	}
	template <>
	inline int roundOrNot<int>(float f){
		return round(f);
	}

	/**
	 * Type of texture boundary model
	 */
	enum BoundaryModel {
		/// No out-of-bound pixel
		Unchecked = 0,
		/// Safe checking (triggers an exception if out of bound)
		Checked = 1,
		/// The boundary pixels are repeated out of the boundaries
		Same = 2,
		/// The texture wraps around a torus
		Toroidal = 3
	};

	/**
	 * The type of pixel interpolation
	 */
	enum PixelInterpolation {
		NearestNeighbor = 0,
		Bilinear = 1
	};

	template< typename T>
	struct MultiDepthPoint : public Point<T> {
		typedef T scalar;
		typedef Vec<T, 3> vec;
		typedef Point<T> base;
		typedef MultiDepthPoint<T> point;

		enum {
			typeDepth = DataDepth<scalar>::value,
			channels = 3,
			type = IM_MAKETYPE(typeDepth, channels)
		};

		MultiDepthPoint() : Point<T>(), depth(0) {}
		MultiDepthPoint(T a, T b, int d) : Point<T>(a, b), depth(d) {}
		MultiDepthPoint(base p, int d) : Point<T>(p.x, p.y), depth(d) {}

		inline point operator +(const point &p) const {
			return point(base::x + p.x, base::y + p.y, depth);
		}
		inline point operator -(const point &p) const {
			return point(base::x - p.x, base::y - p.y, depth);
		}
		inline point operator *(T f) const {
			return point(base::x * f, base::y * f, depth);
		}
		inline point operator -() const {
			return point(-base::x, -base::y, depth);
		}
		inline operator base() const {
			return base(base::x, base::y);
		}

		int depth;
	};

	struct Texture : public Mat {

		Texture() : Mat(), model(Same), interp(Bilinear) {}
		explicit Texture(const Mat &m, int depth = 0,
			BoundaryModel bm = Unchecked,
			PixelInterpolation pi = Bilinear) : Mat(m), model(bm), interp(pi) {
			if(depth > 0) {
				stack.reset(new Image[depth]);
			}
		}

		/// project a pixel coordinate according to the boundary model
		inline void project(int &y, int &x) const {
			switch (model) {
				case Checked:
					if (x < 0 || x >= width || y < 0 || y >= height) {
						mexErrMsgIdAndTxt("MATLAB:tex:outofbound", "Tried to access out of bounds!");
					}
					break;
				case Same:
					x = std::max(0, std::min(width - 1, x));
					y = std::max(0, std::min(height - 1, y));
					break;
				case Toroidal:
					if (x < 0) x += width;
					else if (x >= width) x = x % width;
					if (y < 0) y += height;
					else if (y >= height) y = y % height;
					break;
				// case Unchecked:
				default:
					break;
			}
		}

		//! Element access
		template <typename T> inline const T & at(int y, int x, int depth = 0) const {
			project(y, x);
			if(depth == 0)
                return Mat::at<T>(y, x);
            else
                return stack[depth - 1].at<T>(y, x);
		}
		template <typename T> inline T & at(int y, int x, int depth = 0) {
			project(y, x);
			if(depth == 0)
                return Mat::at<T>(y, x);
            else
                return stack[depth - 1].at<T>(y, x);
		}

		//! Element access by point location
		template <typename T> inline const T & at(const Point<int> &p) const {
			return at<T>(p.y, p.x);
		}
		template <typename T> inline T & at(const Point<int> &p) {
			return at<T>(p.y, p.x);
		}

		//! Element access by continuous point location
		template <typename T> inline T at(const Point<float> &p, int depth = 0) const {
			if (interp == NearestNeighbor) {
				return at<T>(round(p.y), round(p.x), depth);
			}

			// simple bilinear interpolation
			// @see http://en.wikipedia.org/wiki/Bilinear_interpolation
			// the pixel on the left
			int x0 = std::floor(p.x);
			int y0 = std::floor(p.y);
			// the ratios for the subpixel location
			// /!\ x - floor(x) => ratio of ceiling sidehe
			float rightRatio	= p.x - x0;
			float leftRatio		= 1.0f - rightRatio;
			float bottomRatio	= p.y - y0;
			float topRatio		= 1.0f - bottomRatio;
			// neighboring pixels
			const T &topLeft		= at<T>(y0,		x0,		depth);
			const T &bottomLeft		= at<T>(y0 + 1,	x0,		depth);
			const T &topRight		= at<T>(y0,		x0 + 1, depth);
			const T &bottomRight	= at<T>(y0 + 1, x0 + 1, depth);
			return		topLeft		* leftRatio		* topRatio
					+	bottomLeft	* leftRatio		* bottomRatio
					+	topRight	* rightRatio	* topRatio
					+	bottomRight * rightRatio	* bottomRatio;
		}

		//! Multiple depth access
		template <typename T, typename S> inline const T & at(const MultiDepthPoint<S> &p) const {
			return at<T>(p.y, p.x, p.depth);
		}
		template <typename T> inline T & at(const MultiDepthPoint<int> &p) {
			return at<T>(p.y, p.x, p.depth);
		}
		template <typename T> inline T at(const MultiDepthPoint<float> &p) const {
			return at<T>(p, p.depth);
		}

		/// The boundary model
		BoundaryModel model;
		PixelInterpolation interp;
		/// The multi-resolution texture stack
		boost::shared_array<Image> stack;
	};
}

#endif	/* TEXTURE_H */


text: require_relative 'core_ext/array'


text:
<?php
class SolrCodeBankSearchEngine implements ICodeBankSearchEngine {
    /**
     * Allows for hooking in to modify the table of the snippet class for the search engine
     */
    public static function requireTable() {}

    /**
     * Performs the search against the snippets in the system
     *
     * @param {string} $keywords Keywords to search for
     * @param {int} $languageID Language to filter to
     * @param {int} $folderID Folder to filter to
     * @return {DataList} Data list pointing to the snippets in the results
     */
    public function doSnippetSearch($keywords, $languageID=false, $folderID=false) {
        $searchIndex=singleton('CodeBankSolrIndex');
        $searchQuery=new SearchQuery();
        $searchQuery->classes=array(
                                    array(
                                            'class'=>'Snippet',
                                            'includeSubclasses'=>true
                                        )
                                );

        //Add language filtering
        if($languageID!==false && $languageID>0) {
            $searchQuery->filter('Snippet_LanguageID', $languageID);
        }

        //Add language filtering
        if($folderID!==false && $folderID>0) {
            $searchQuery->filter('Snippet_FolderID', $folderID);
        }

        //Configure search
        $searchQuery->search($keywords, null, array(
                                                    'Snippet_Title'=>2,
                                                    'Snippet_Description'=>1
                                                ));

        return $searchIndex->search($searchQuery, null, null)->Matches->getList();
    }
}

class CodeBankSolrIndex extends SolrIndex {
    public function init() {
        //Add the snippet class
        $this->addClass('Snippet');

        //Add fulltext fields
        $this->addFulltextField('Title');
        $this->addFulltextField('Description');
        $this->addFulltextField('Tags');

        //Add filter fields
        $this->addFilterField('LanguageID');
        $this->addFilterField('FolderID');
    }
}
?>


text:
__name__   = 'log'
__author__ = 'Sam'

from pica import config

def debug(line):
    if config.get('General','debug'):
        print(line+"\n")


text:
/*
Package kubernetes provides implementations of `Cluster` and
`manifests` that interact with the Kubernetes API (using kubectl or
the k8s API client).
*/
package kubernetes


text:
function [ classcount_above_thre, class2useTB, roiid_list, p_list] = summarize_TBclassMVCO_threshlist(classfile, threlist, class2do)
%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

load(classfile)
classcount_above_thre = NaN(1,length(threlist));

%if exist('adhocthresh', 'var'),
%    classcount_above_adhocthresh = classcount;
[maxscore, winclass] = max(TBscores');
%    if length(adhocthresh) == 1, adhocthres`h = adhocthresh*ones(size(class2useTB)); end;
%end;

%for ii = 1: length(class2useTB),
%    classcount(ii) = size(strmatch(class2useTB(ii), TBclass,'exact'),1);
%    classcount_above_optthresh(ii) = size(strmatch(class2useTB(ii), TBclass_above_threshold),1);
%    if exist('adhocthresh', 'var')
for ii = 1:length(threlist),
    adhocthresh = threlist(ii);
    ind = (strcmp(class2useTB(class2do), TBclass) & maxscore' >= adhocthresh);
    classcount_above_thre(ii) = sum(ind);
    %if ii == class2list,
    temp = find(ind);
    roiid_list = roinum(temp);
    p_list = maxscore(temp);
    %end;
    % end;
end;

end


text:
"""
StateXMLTestCase - Tests to assure NZB/Archive objects are successfully recovered from the
hellanzb state xml

(c) Copyright 2006 Philip Jenvey
[See end of file]
"""
import os, shutil, tempfile, time, unittest, Hellanzb, Hellanzb.NZBQueue
from Hellanzb.test import HellanzbTestCase, EVIL_STRINGS
from Hellanzb.Log import *
from Hellanzb.NZBLeecher.NZBModel import NZB, NZBFile
from Hellanzb.NZBQueue import recoverStateFromDisk
from Hellanzb.NZBLeecher.NZBSegmentQueue import NZBSegmentQueue
from Hellanzb.PostProcessorUtil import PAR2
from Hellanzb.Util import toUnicode

__id__ = '$Id$'

class StateXMLTestCase(HellanzbTestCase):
    verbose = False

    def setUp(self):
        HellanzbTestCase.setUp(self)
        self.tempDir = tempfile.mkdtemp('hellanzb-StateXMLTestCase')
        self.setUpEnv()

    def setUpEnv(self):
        self.stateXMLFileName = os.path.join(self.tempDir, 'testState.xml')
        self.stateXMLFile = open(self.stateXMLFileName, 'w+')
        Hellanzb.queue = NZBSegmentQueue()
        Hellanzb.postProcessors = []
        Hellanzb.nzbQueue = []

    def tearDown(self):
        HellanzbTestCase.tearDown(self)
        shutil.rmtree(self.tempDir)

    def testArchiveNameRecovery(self):
        """ Ensure state XML recovery via archive names """
        for test in EVIL_STRINGS:
            self.setUpEnv()
            self.assertRecoveredArchiveName(test)

    def assertRecoveredArchiveName(self, name):
        n = NZB(name)
        n.rarPassword = rarPassword = 'recoverme'
        archiveName = n.archiveName
        Hellanzb.queue.nzbAdd(n)

        self.writeState()
        del n
        self.recoverState()

        n2 = NZB.fromStateXML('downloading', name)
        self.assertEquals(rarPassword, n2.rarPassword)
        self.assertEquals(name, n2.nzbFileName)
        self.assertEquals(archiveName, n2.archiveName)

    def testSkippedParUnicodeRecovery(self):
        """ Ensure skipped par subjects can be matched after state XML recovery """
        # 'São_Paulo' looks like this in XML:
        # São_Paulo ('São_Paulo')
        # after parsed from XML into recovered:
        # ...[u'S\xc3\xc2\xa3o_Paulo']
        # u'São_Paulo' in XML:
        # São_Paulo
        # after parsed from XML:
        # [u'S\xc3\xc2\xa3o_Paulo']
        for test in EVIL_STRINGS:
            self.setUpEnv()
            self.assertRecoveredSkippedPar(test)

    def assertRecoveredSkippedPar(self, subject):
        n = NZB('test.nzb')
        n.isParRecovery = True
        n.parPrefix = 'test'
        n.parType = PAR2
        Hellanzb.queue.nzbAdd(n)

        file = NZBFile(subject, 'today', 'test@test.com', n)
        file.isSkippedPar = True

        self.writeState()
        del n
        self.recoverState()

        n2 = NZB.fromStateXML('downloading', 'test')
        #print str(Hellanzb.recoveredState)
        #print str(n2.skippedParSubjects)
        self.assertEquals(True, n2.isSkippedParSubject(subject))

    def writeState(self):
        logStateXML(self.stateXMLFile.write, False)

        if self.verbose:
            self.stateXMLFile.seek(0)
            for line in self.stateXMLFile.readlines():
                print line

        self.stateXMLFile.close()

    def recoverState(self):
        recoverStateFromDisk(self.stateXMLFileName)

"""
Copyright (c) 2006 Philip Jenvey <pjenvey@groovie.org>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. The name of the author or contributors may not be used to endorse or
   promote products derived from this software without specific prior
   written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

$Id$
"""


text:
/**
 *
 */
package apu.scratch.converter;

import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.HashMap;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultStyledDocument;

import org.json.JSONArray;

import apu.scratch.converter.CodePanel.Tab;
import apu.scratch.converter.ScratchConverter.CompileResult;

import com.seaglasslookandfeel.SeaGlassLookAndFeel;

/**
 * @author MegaApuTurkUltra
 *
 */
public class IdeFrame extends JFrame {

	private static final long serialVersionUID = -7694777067218375044L;
	private JPanel contentPane;
	public JPanel sbRender;
	JLabel lblFile;

	public static IdeFrame instance;

	CodePanel panel;

	public SaveCallback callback = new SaveCallback() {
		@Override
		public void codeSaved(String code, boolean save) {
		}
	};

	public static void launch(boolean laf) {
		if (laf) {
			try {
				UIManager.setLookAndFeel(new SeaGlassLookAndFeel());
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			try {
				UIManager.setLookAndFeel(UIManager
						.getSystemLookAndFeelClassName());
			} catch (Exception e) {
				e.printStackTrace();
				try {
					UIManager.setLookAndFeel(UIManager
							.getCrossPlatformLookAndFeelClassName());
				} catch (Exception e1) {
					e1.printStackTrace();
				}
			}
		}
		UIManager.put("TextPane.font", new Font(Font.MONOSPACED, Font.PLAIN, 13));
		try {
			instance = new IdeFrame();
			instance.setVisible(true);
			SavePanel.init();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the frame.
	 */
	public IdeFrame() {
		setTitle("ApuC IDE");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setSize(1000, 500);
		setLocationRelativeTo(null);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);

		final JSplitPane mainSplit = new JSplitPane();
		mainSplit.setResizeWeight(0.7);
		contentPane.add(mainSplit, BorderLayout.CENTER);

		JPanel leftSplit = new JPanel(new BorderLayout());
		mainSplit.setLeftComponent(leftSplit);

		JPanel header = new JPanel();
		FlowLayout flowLayout = (FlowLayout) header.getLayout();
		flowLayout.setAlignment(FlowLayout.LEADING);
		leftSplit.add(header, BorderLayout.NORTH);

		JButton btnNew = new JButton("New");
		btnNew.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				panel.addNewTab();
			}
		});
		header.add(btnNew);

		JButton btnOpen = new JButton("Open");
		btnOpen.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// Tab tab = panel.getCurrentlySelectedTab();
				// if (tab == null)
				// return;
				// DefaultStyledDocument doc = tab.doc;
				// String code;
				// try {
				// code = doc.getText(0, doc.getEndPosition().getOffset());
				// } catch (BadLocationException e1) {
				// e1.printStackTrace();
				// return;
				// }
				// if (!code.trim().isEmpty()) {
				// if (JOptionPane
				// .showConfirmDialog(
				// IdeFrame.this,
				// "You have code in the editor. If you have "
				// + "not saved it, opening a new file will cause"
				// + " it to be lost. Continue?",
				// "Continue?", JOptionPane.YES_NO_OPTION) ==
				// JOptionPane.NO_OPTION)
				// return;
				// }
				File f = SavePanel.showDialog(false, true, false);
				if (f != null && f.exists()) {
					Tab tab = panel.addNewTab();
					DefaultStyledDocument doc = tab.doc;
					tab.saveFile = f;
					tab.title.setText(f.getName());
					lblFile.setText("File: " + f.getName());
					String newCode = Sprite2IO.readFile(f);
					if (newCode != null) {
						try {
							doc.replace(0,
									doc.getEndPosition().getOffset() - 1,
									newCode, tab.defaultStyle);
							tab.checkCode(false);
						} catch (BadLocationException e1) {
							e1.printStackTrace();
						}
					}
				}
			}
		});
		header.add(btnOpen);

		JButton btnSave = new JButton("Save");
		btnSave.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Tab tab = panel.getCurrentlySelectedTab();
				if (tab == null)
					return;
				tab.checkCode(true);
			}
		});
		header.add(btnSave);

		JButton btnExport = new JButton("Export");
		btnExport.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				Tab tab = panel.getCurrentlySelectedTab();
				if (tab == null)
					return;
				DefaultStyledDocument doc = tab.doc;
				String code;
				try {
					code = doc.getText(0, doc.getEndPosition().getOffset());
				} catch (BadLocationException e1) {
					e1.printStackTrace();
					return;
				}

				if (code.trim().isEmpty()) {
					JOptionPane
							.showMessageDialog(
									IdeFrame.this,
									"You don't have any code to export! Try writing some first.",
									"Export", JOptionPane.INFORMATION_MESSAGE);
					return;
				}

				CompileResult result;
				try {
					result = ScratchConverter.compile(code);
					if (result.errors.size() > 0) {
						throw new Exception("Errors in code");
					}
				} catch (Exception e1) {
					e1.printStackTrace();
					JOptionPane
							.showMessageDialog(
									IdeFrame.this,
									"You have errors in your code! Please fix them first.",
									"Warning", JOptionPane.WARNING_MESSAGE);
					return;
				}

				File f = SavePanel.showDialog(false, false, true);
				if (f != null) {
					Sprite2IO.writeToZip(f, result.scripts);
				}
			}
		});
		header.add(btnExport);

		JButton btnExportAll = new JButton("Export all");
		btnExportAll.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (JOptionPane
						.showConfirmDialog(
								IdeFrame.this,
								"All your open tabs will be exported into a project file. Continue?",
								"Export all", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
					return;
				}
				Map<String, JSONArray> codes = new HashMap<String, JSONArray>();
				for (Tab t : panel.tabs) {
					t.checkCode(false);
					if (t.currentJson != null) {
						codes.put(t.title.getText() + Math.random(),
								t.currentJson);
					}
				}
				File f = SavePanel.showDialog(true, false, true);
				if (f != null) {
					try {
						ScratchConverter.createProjectFile(f, codes);
						int x = JOptionPane.showOptionDialog(IdeFrame.this,
								"Export all successful", "Export all",
								JOptionPane.YES_NO_OPTION,
								JOptionPane.INFORMATION_MESSAGE, null,
								new Object[] { "Dismiss",
										"Open in Scratch Offline Editor" },
								"Dismiss");
						if (x == 1) {
							Desktop.getDesktop().open(f);
						}
					} catch (Exception e1) {
						e1.printStackTrace();
						JOptionPane.showMessageDialog(IdeFrame.this,
								"Export all failed: " + e1.getMessage(),
								"Export all", JOptionPane.ERROR_MESSAGE);
					}
				}
			}
		});
		header.add(btnExportAll);

		lblFile = new JLabel("File: ");
		header.add(lblFile);

		panel = new CodePanel();
		leftSplit.add(panel, BorderLayout.CENTER);

		final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setMinimumSize(new Dimension(0, 0));
		mainSplit.setRightComponent(tabbedPane);

		sbRender = new JPanel();
		tabbedPane.addTab("Scratchblocks2 Preview", null, sbRender, null);
	}

	static interface SaveCallback {
		public void codeSaved(String code, boolean save);
	}
}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="5dp">

    <TextView
        android:id="@+id/tv_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000"
        android:text="拦截号码"
        android:textSize="18sp"/>

    <TextView
        android:id="@+id/tv_mode"
        android:layout_below="@+id/tv_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000"
        android:text="拦截类型"
        android:textSize="18sp"/>

    <ImageView
        android:id="@+id/iv_delete"
        android:layout_alignParentRight="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/selector_blacknumber_delete_btn_bg"/>

</RelativeLayout>