diff --git a/NewMediaMonitoring/settings.py b/NewMediaMonitoring/settings.py index b45e0ea..3252058 100644 --- a/NewMediaMonitoring/settings.py +++ b/NewMediaMonitoring/settings.py @@ -1,153 +1,153 @@ -""" -Django settings for NewMediaMonitoring project. - -Generated by 'django-admin startproject' using Django 2.1.8. - -For more information on this file, see -https://docs.djangoproject.com/en/2.1/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/2.1/ref/settings/ -""" - -import os - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -import sys - -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'tj5m7-ns_6x_fvn2^q+7+2fopq!#7taqv!9ai(c_45i5!%m=*z' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = ['*'] - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'django_token', - 'corsheaders', - 'bootstrap3', - 'captcha', - 'dashboard', - 'management' -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.middleware.locale.LocaleMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'corsheaders.middleware.CorsMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django_token.middleware.TokenMiddleware', -] - -ROOT_URLCONF = 'NewMediaMonitoring.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'NewMediaMonitoring.wsgi.application' - -# Database -# https://docs.djangoproject.com/en/2.1/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'NAME': 'newmediaDB1', - 'USER': 'newmedia', - 'PASSWORD': 'newmedia2020!@#', - 'HOST': '210.77.68.250', - 'PORT': '5432', - } -} - -# Password validation -# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - -AUTHENTICATION_BACKENDS = ( - 'django.contrib.auth.backends.ModelBackend', - 'django_token.backends.TokenBackend' -) - -# Internationalization -# https://docs.djangoproject.com/en/2.1/topics/i18n/ - -LANGUAGE_CODE = 'zh-Hans' - -TIME_ZONE = 'Asia/Shanghai' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = False - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/2.1/howto/static-files/ - -STATIC_URL = '/static/' -STATICFILES_DIRS = [ - os.path.join(BASE_DIR, "static"), -] -STATIC_ROOT = '/var/www/p3/newmediamonitoring/static/' -MEDIA_URL = '/media/' -MEDIA_ROOT = '/var/www/p3/newmediamonitoring/media/' - -"""用户模块扩展部分""" -AUTH_PROFILE_MODULE = 'djangoadmin.myadmin.UserProfile' -"""用户模块扩展完成""" - -CORS_ORIGIN_ALLOW_ALL = True - -CORS_URLS_REGEX = r'^/polls/.*$' - -try: - from .local_settings import * -except ImportError as e: - pass +""" +Django settings for NewMediaMonitoring project. + +Generated by 'django-admin startproject' using Django 2.1.8. + +For more information on this file, see +https://docs.djangoproject.com/en/2.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.1/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import sys + +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'tj5m7-ns_6x_fvn2^q+7+2fopq!#7taqv!9ai(c_45i5!%m=*z' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['*'] + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django_token', + 'corsheaders', + 'bootstrap3', + 'captcha', + 'dashboard', + 'management' +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.middleware.locale.LocaleMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'corsheaders.middleware.CorsMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django_token.middleware.TokenMiddleware', +] + +ROOT_URLCONF = 'NewMediaMonitoring.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'NewMediaMonitoring.wsgi.application' + +# Database +# https://docs.djangoproject.com/en/2.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'newmediaDB1', + 'USER': 'newmedia', + 'PASSWORD': 'newmedia2020!@#', + 'HOST': '210.77.68.250', + 'PORT': '5432', + } +} + +# Password validation +# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + +AUTHENTICATION_BACKENDS = ( + 'django.contrib.auth.backends.ModelBackend', + 'django_token.backends.TokenBackend' +) + +# Internationalization +# https://docs.djangoproject.com/en/2.1/topics/i18n/ + +LANGUAGE_CODE = 'zh-Hans' + +TIME_ZONE = 'Asia/Shanghai' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = False + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.1/howto/static-files/ + +STATIC_URL = '/static/' +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, "static"), +] +STATIC_ROOT = '/var/www/p3/newmediamonitoring/static/' +MEDIA_URL = '/media/' +MEDIA_ROOT = '/var/www/p3/newmediamonitoring/media/' + +"""用户模块扩展部分""" +AUTH_PROFILE_MODULE = 'djangoadmin.myadmin.UserProfile' +"""用户模块扩展完成""" + +CORS_ORIGIN_ALLOW_ALL = True + +CORS_URLS_REGEX = r'^/polls/.*$' + +try: + from .local_settings import * +except ImportError as e: + pass diff --git a/NewMediaMonitoring/wsgi.py b/NewMediaMonitoring/wsgi.py index f6a66c7..8c03040 100644 --- a/NewMediaMonitoring/wsgi.py +++ b/NewMediaMonitoring/wsgi.py @@ -18,11 +18,3 @@ from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NewMediaMonitoring.settings') sys.path.append("/var/www/p3/newmediamonitoring/current") application = get_wsgi_application() -try: - application = get_wsgi_application() -except Exception: - # Error loading applications - if 'mod_wsgi' in sys.modules: - traceback.print_exc() - os.kill(os.getpid(), signal.SIGINT) - time.sleep(2.5) diff --git a/README.md b/README.md index fe7d3e3..3764d8d 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,10 @@ git pull # enter username && password source .venv/bin/activate python manage.py make migrations python manage.py migrate +``` + +# 查看服务器apache 内存使用情况 + +```shell +sudo /usr/sbin/passenger-memory-stats ``` \ No newline at end of file diff --git a/dashboard/models.py b/dashboard/models.py index de100e8..5672aa1 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -1,357 +1,359 @@ -import uuid - -from django.contrib.auth.models import User -from django.db import models - - -# Create your models here. -class Group_type(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - type = models.CharField('群组类型',max_length=256,null=True,blank=True) - - def __str__(self): - return self.type -# 群组 -class Group(models.Model): - GROUP_STATUS_CHOICES = ( - ('0','关闭'), - ('1','开启') - ) - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - name = models.CharField('群组名称', max_length=256, null=True, blank=True) - presentation = models.TextField('群组描述', null=True, blank=True) - image = models.FileField(upload_to='groupimage', null=True, blank=True) - type = models.ForeignKey(Group_type,on_delete=models.CASCADE,null=True,blank=True) - status = models.CharField('状态',max_length=256,null=True,blank=True,choices=GROUP_STATUS_CHOICES) - province = models.CharField('省', max_length=256, null=True, blank=True) - cities = models.CharField('市', max_length=256, null=True, blank=True) - district = models.CharField('县', max_length=256, null=True, blank=True) - town = models.CharField('乡', max_length=256, null=True, blank=True) - village = models.CharField('村', max_length=256, null=True, blank=True) - - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.name - -#群组管理员 -class Group_admin(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) - group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.group.name -#群组成员 -class Group_user(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) - group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.user.username -# 权限等级 -class Level(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - name = models.CharField('等级名', max_length=256, null=True, blank=True) - level = models.IntegerField('级别', blank=True, null=True,default=0) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - - def __str__(self): - return self.name -#单位类型 -class Organizationtype(models.Model): - id = models.UUIDField('id',primary_key=True,default=uuid.uuid4) - organizationtype = models.CharField('单位类型',blank=True,null=True,max_length=256) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.organizationtype - - -# 单位 -class Organization(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - name = models.CharField('单位名', max_length=256, null=True, blank=True) - image = models.FileField(upload_to='cover', null=True, blank=True) - organizationtype = models.ForeignKey(Organizationtype,on_delete=models.CASCADE, null=True, blank=True) - province = models.CharField('省',max_length=256,null=True,blank=True) - cities = models.CharField('市',max_length=256,null=True,blank=True) - district = models.CharField('县',max_length=256,null=True,blank=True) - town = models.CharField('乡',max_length=256,null=True,blank=True) - village = models.CharField('村',max_length=256,null=True,blank=True) - # group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True) - # level = models.ForeignKey(Level,on_delete=models.CASCADE,null=True,blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.name - - -# 扩展用户表 -class Userprofile(models.Model): - user = models.ForeignKey(User, on_delete=models.CASCADE) - name = models.CharField('姓名', null=True, blank=True, max_length=256) - sex = models.CharField('性别', null=True, blank=True, max_length=256) - image = models.FileField(upload_to='profile', null=True, blank=True) - organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) - - - def __str__(self): - return self.user.username - - -def create_user_profile(sender, instance, created, **kwargs): - """Create the UserProfile when a new User is saved""" - if created: - profile = Userprofile() - profile.user = instance - profile.save() - - -# 微信公众号 -class Weixin(models.Model): - WEIXIN_STATUS_CHOICES = ( - ('1', '开启'), - ('0', '关闭') - ) - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - code = models.CharField('微信公众号', max_length=256, null=True, blank=True) - weixinid = models.CharField('微信ID',max_length=256,null=True,blank=True) - alias = models.CharField('别名',max_length=256,null=True,blank=True) - image = models.FileField(upload_to='cover', null=True, blank=True) - organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) - status = models.CharField('状态',max_length=256,null=True,blank=True,choices=WEIXIN_STATUS_CHOICES) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.code - - -# 微信文章采集 -class Weixin_data(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - title = models.CharField('文章标题', max_length=256, null=True, blank=True) - site = models.CharField('位置', max_length=256, null=True, blank=True) - date = models.CharField('发文时间', max_length=256, null=True, blank=True) - original = models.BooleanField('是否原创', null=True, blank=True) - url = models.CharField('文章链接', max_length=256, null=True, blank=True) - author = models.CharField('作者', max_length=256, null=True, blank=True) - comment = models.CharField('评论数', max_length=256, null=True, blank=True) - reply = models.CharField('作者回复数', max_length=256, null=True, blank=True) - content = models.TextField('正文', null=True, blank=True) - weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.title - - -# 微信评论 -class Weixin_comment(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - comment = models.TextField('评论', null=True, blank=True) - user = models.CharField('用户', max_length=256, null=True, blank=True) - reply = models.TextField('回复', null=True, blank=True) - weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.user - - -# 微信错别字 -class Weixin_Wrong(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - wrong = models.CharField('错别字', max_length=256, null=True, blank=True) - idea = models.CharField('建议', max_length=256, null=True, blank=True) - site = models.CharField('位置', max_length=256, null=True, blank=True) - weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True) - change = models.BooleanField('是否已修改', null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.wrong - - -# 微博 -class Weibo(models.Model): - WEIBO_STATUS_CHOICES = ( - ('1', '开启'), - ('0', '关闭') - ) - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - code = models.CharField('微博号', max_length=256, null=True, blank=True) - weiboid = models.CharField('微博ID', max_length=256, null=True, blank=True) - alias = models.CharField('别名', max_length=256, null=True, blank=True) - image = models.FileField(upload_to='cover', null=True, blank=True) - organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) - status = models.CharField('状态', max_length=256, null=True, blank=True, choices=WEIBO_STATUS_CHOICES) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.code - - -# 微博文章采集 -class Weibi_data(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - weiboid = models.CharField('微博ID', max_length=256, null=True, blank=True) - content = models.TextField('正文', null=True, blank=True) - url = models.CharField('文章url', max_length=256, null=True, blank=True) - originalimageurl = models.CharField('原始图片url', max_length=256, null=True, blank=True) - transpondimageurl = models.CharField('转发图片url', max_length=256, null=True, blank=True) - original = models.BooleanField('是否原创', null=True, blank=True) - site = models.CharField('发布位置', max_length=256, null=True, blank=True) - date = models.CharField('发布时间', max_length=256, null=True, blank=True) - tool = models.CharField('发布工具', max_length=256, null=True, blank=True) - like = models.CharField('点赞数', max_length=256, null=True, blank=True) - transpond = models.CharField('转发数', max_length=256, null=True, blank=True) - comment = models.CharField('评论数', max_length=256, null=True, blank=True) - title = models.CharField('文章标题', max_length=256, null=True, blank=True) - weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.title - - -# 微博错别字 -class Weibo_Wrong(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - wrong = models.CharField('错别字', max_length=256, null=True, blank=True) - idea = models.CharField('建议', max_length=256, null=True, blank=True) - site = models.CharField('位置', max_length=256, null=True, blank=True) - weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE, null=True, blank=True) - change = models.BooleanField('是否已修改', null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - -# 今日头条 -class Toutiao(models.Model): - TOUTIAO_STATUS_CHOICES = ( - ('1', '开启'), - ('0', '关闭') - ) - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - code = models.CharField('头条号', max_length=256, null=True, blank=True) - toutiaoid = models.CharField('头条ID', max_length=256, null=True, blank=True) - alias = models.CharField('别名', max_length=256, null=True, blank=True) - image = models.FileField(upload_to='cover', null=True, blank=True) - organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) - status = models.CharField('状态', max_length=256, null=True, blank=True, choices=TOUTIAO_STATUS_CHOICES) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.code - - -# 今日头条数据 -class Toutiao_data(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - title = models.CharField('标题', max_length=256, null=True, blank=True) - url = models.CharField('链接', max_length=256, null=True, blank=True) - img = models.CharField('缩略图', max_length=256, null=True, blank=True) - count = models.CharField('阅读数', max_length=256, null=True, blank=True) - commentcount = models.CharField('评论数', max_length=256, null=True, blank=True) - reply = models.CharField('作者回复数', max_length=256, null=True, blank=True) - date = models.CharField('时间', max_length=256, null=True, blank=True) - content = models.TextField('正文', null=True, blank=True) - comment = models.TextField('评论', null=True, blank=True) - toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.title - - -# 今日头条评论 -class Toutiao_comment(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - comment = models.TextField('评论', null=True, blank=True) - user = models.CharField('用户', max_length=256, null=True, blank=True) - reply = models.TextField('回复', null=True, blank=True) - toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.user - - -# 今日头条错别字 -class Toutiao_Wrong(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - wrong = models.CharField('错别字', max_length=256, null=True, blank=True) - idea = models.CharField('建议', max_length=256, null=True, blank=True) - site = models.CharField('位置', max_length=256, null=True, blank=True) - toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True) - change = models.BooleanField('是否已修改', null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.wrong - - -# 其他新媒体 -class Qita(models.Model): - QITA_STATUS_CHOICES = ( - ('1', '开启'), - ('0', '关闭') - ) - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - type = models.CharField('新媒体类型', max_length=256, null=True, blank=True) - name = models.CharField('新媒体名称', max_length=256, null=True, blank=True) - qitaid = models.CharField('新媒体ID', max_length=256, null=True, blank=True) - alias = models.CharField('别名', max_length=256, null=True, blank=True) - image = models.FileField(upload_to='cover', null=True, blank=True) - organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) - status = models.CharField('状态', max_length=256, null=True, blank=True, choices=QITA_STATUS_CHOICES) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.name - -#其他新媒体监测 -class Qita_jc(models.Model): - id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) - mewnedia = models.ForeignKey(Qita,on_delete=models.CASCADE) - count = models.CharField('总发文量', max_length=256, null=True, blank=True) - count_jc = models.CharField('监测时间内发文量', max_length=256, null=True, blank=True) - comment = models.CharField('评论数', max_length=256, null=True, blank=True) - reply = models.CharField('作者回复数', max_length=256, null=True, blank=True) - date = models.CharField('最近发文日期', max_length=256, null=True, blank=True) - created = models.DateTimeField('创建时间', auto_now_add=True) - updated = models.DateTimeField('更新时间', auto_now=True) - - def __str__(self): - return self.mewnedia.name -#5级地名库 -class Area_code_2020(models.Model): - code = models.CharField('区划代码',max_length=256,null=True,blank=True) - name = models.CharField('名称',max_length=256,null=True,blank=True) - level = models.CharField('级别1-5,省市县镇村',max_length=256,null=True,blank=True) - pcode = models.CharField('父级区划代码',max_length=256,null=True,blank=True) - - def __str__(self): - return self.name +import uuid + +from django.contrib.auth.models import User +from django.db import models + +# 权限等级 +class Level(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + name = models.CharField('等级名', max_length=256, null=True, blank=True) + level = models.IntegerField('级别', blank=True, null=True,default=0) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + + def __str__(self): + return self.name +# Create your models here. +class Group_type(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + type = models.CharField('群组类型',max_length=256,null=True,blank=True) + + def __str__(self): + return self.type +# 群组 +class Group(models.Model): + GROUP_STATUS_CHOICES = ( + ('0','关闭'), + ('1','开启') + ) + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + name = models.CharField('群组名称', max_length=256, null=True, blank=True) + presentation = models.TextField('群组描述', null=True, blank=True) + image = models.FileField(upload_to='groupimage', null=True, blank=True) + type = models.ForeignKey(Group_type,on_delete=models.CASCADE,null=True,blank=True) + status = models.CharField('状态',max_length=256,null=True,blank=True,choices=GROUP_STATUS_CHOICES) + province = models.CharField('省', max_length=256, null=True, blank=True) + cities = models.CharField('市', max_length=256, null=True, blank=True) + district = models.CharField('县', max_length=256, null=True, blank=True) + town = models.CharField('乡', max_length=256, null=True, blank=True) + village = models.CharField('村', max_length=256, null=True, blank=True) + + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.name + +#群组管理员 +class Group_admin(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) + group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.group.name +#群组成员 +class Group_user(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) + group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.user.username + +#单位类型 +class Organizationtype(models.Model): + id = models.UUIDField('id',primary_key=True,default=uuid.uuid4) + organizationtype = models.CharField('单位类型',blank=True,null=True,max_length=256) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.organizationtype + + +# 单位 +class Organization(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + name = models.CharField('单位名', max_length=256, null=True, blank=True) + image = models.FileField(upload_to='cover', null=True, blank=True) + organizationtype = models.ForeignKey(Organizationtype,on_delete=models.CASCADE, null=True, blank=True) + province = models.CharField('省',max_length=256,null=True,blank=True) + cities = models.CharField('市',max_length=256,null=True,blank=True) + district = models.CharField('县',max_length=256,null=True,blank=True) + town = models.CharField('乡',max_length=256,null=True,blank=True) + village = models.CharField('村',max_length=256,null=True,blank=True) + # group = models.ForeignKey(Group, on_delete=models.CASCADE, null=True, blank=True) + # level = models.ForeignKey(Level,on_delete=models.CASCADE,null=True,blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.name + + +# 扩展用户表 +class Userprofile(models.Model): + user = models.ForeignKey(User, on_delete=models.CASCADE) + name = models.CharField('姓名', null=True, blank=True, max_length=256) + sex = models.CharField('性别', null=True, blank=True, max_length=256) + image = models.FileField(upload_to='profile', null=True, blank=True) + organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) + #用户状态:注册进来默认为0,为未审核状态,审核后status=1 + status = models.IntegerField('用户状态',null=True,blank=True,default=0) + + + def __str__(self): + return self.user.username + + +def create_user_profile(sender, instance, created, **kwargs): + """Create the UserProfile when a new User is saved""" + if created: + profile = Userprofile() + profile.user = instance + profile.save() + + +# 微信公众号 +class Weixin(models.Model): + WEIXIN_STATUS_CHOICES = ( + ('1', '开启'), + ('0', '关闭') + ) + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + code = models.CharField('微信公众号', max_length=256, null=True, blank=True) + weixinid = models.CharField('微信ID',max_length=256,null=True,blank=True) + alias = models.CharField('别名',max_length=256,null=True,blank=True) + image = models.FileField(upload_to='cover', null=True, blank=True) + organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) + status = models.CharField('状态',max_length=256,null=True,blank=True,choices=WEIXIN_STATUS_CHOICES) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.code + + +# 微信文章采集 +class Weixin_data(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + title = models.CharField('文章标题', max_length=256, null=True, blank=True) + site = models.CharField('位置', max_length=256, null=True, blank=True) + date = models.CharField('发文时间', max_length=256, null=True, blank=True) + original = models.BooleanField('是否原创', null=True, blank=True) + url = models.CharField('文章链接', max_length=256, null=True, blank=True) + author = models.CharField('作者', max_length=256, null=True, blank=True) + comment = models.CharField('评论数', max_length=256, null=True, blank=True) + reply = models.CharField('作者回复数', max_length=256, null=True, blank=True) + content = models.TextField('正文', null=True, blank=True) + weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.title + + +# 微信评论 +class Weixin_comment(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + comment = models.TextField('评论', null=True, blank=True) + user = models.CharField('用户', max_length=256, null=True, blank=True) + reply = models.TextField('回复', null=True, blank=True) + weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.user + + +# 微信错别字 +class Weixin_Wrong(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + wrong = models.CharField('错别字', max_length=256, null=True, blank=True) + idea = models.CharField('建议', max_length=256, null=True, blank=True) + site = models.CharField('位置', max_length=256, null=True, blank=True) + weixin = models.ForeignKey(Weixin, on_delete=models.CASCADE, null=True, blank=True) + change = models.BooleanField('是否已修改', null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.wrong + + +# 微博 +class Weibo(models.Model): + WEIBO_STATUS_CHOICES = ( + ('1', '开启'), + ('0', '关闭') + ) + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + code = models.CharField('微博号', max_length=256, null=True, blank=True) + weiboid = models.CharField('微博ID', max_length=256, null=True, blank=True) + alias = models.CharField('别名', max_length=256, null=True, blank=True) + image = models.FileField(upload_to='cover', null=True, blank=True) + organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) + status = models.CharField('状态', max_length=256, null=True, blank=True, choices=WEIBO_STATUS_CHOICES) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.code + + +# 微博文章采集 +class Weibi_data(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + weiboid = models.CharField('微博ID', max_length=256, null=True, blank=True) + content = models.TextField('正文', null=True, blank=True) + url = models.CharField('文章url', max_length=256, null=True, blank=True) + originalimageurl = models.CharField('原始图片url', max_length=256, null=True, blank=True) + transpondimageurl = models.CharField('转发图片url', max_length=256, null=True, blank=True) + original = models.BooleanField('是否原创', null=True, blank=True) + site = models.CharField('发布位置', max_length=256, null=True, blank=True) + date = models.CharField('发布时间', max_length=256, null=True, blank=True) + tool = models.CharField('发布工具', max_length=256, null=True, blank=True) + like = models.CharField('点赞数', max_length=256, null=True, blank=True) + transpond = models.CharField('转发数', max_length=256, null=True, blank=True) + comment = models.CharField('评论数', max_length=256, null=True, blank=True) + title = models.CharField('文章标题', max_length=256, null=True, blank=True) + weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.title + + +# 微博错别字 +class Weibo_Wrong(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + wrong = models.CharField('错别字', max_length=256, null=True, blank=True) + idea = models.CharField('建议', max_length=256, null=True, blank=True) + site = models.CharField('位置', max_length=256, null=True, blank=True) + weibo = models.ForeignKey(Weibo, on_delete=models.CASCADE, null=True, blank=True) + change = models.BooleanField('是否已修改', null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + +# 今日头条 +class Toutiao(models.Model): + TOUTIAO_STATUS_CHOICES = ( + ('1', '开启'), + ('0', '关闭') + ) + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + code = models.CharField('头条号', max_length=256, null=True, blank=True) + toutiaoid = models.CharField('头条ID', max_length=256, null=True, blank=True) + alias = models.CharField('别名', max_length=256, null=True, blank=True) + image = models.FileField(upload_to='cover', null=True, blank=True) + organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) + status = models.CharField('状态', max_length=256, null=True, blank=True, choices=TOUTIAO_STATUS_CHOICES) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.code + + +# 今日头条数据 +class Toutiao_data(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + title = models.CharField('标题', max_length=256, null=True, blank=True) + url = models.CharField('链接', max_length=256, null=True, blank=True) + img = models.CharField('缩略图', max_length=256, null=True, blank=True) + count = models.CharField('阅读数', max_length=256, null=True, blank=True) + commentcount = models.CharField('评论数', max_length=256, null=True, blank=True) + reply = models.CharField('作者回复数', max_length=256, null=True, blank=True) + date = models.CharField('时间', max_length=256, null=True, blank=True) + content = models.TextField('正文', null=True, blank=True) + comment = models.TextField('评论', null=True, blank=True) + toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.title + + +# 今日头条评论 +class Toutiao_comment(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + comment = models.TextField('评论', null=True, blank=True) + user = models.CharField('用户', max_length=256, null=True, blank=True) + reply = models.TextField('回复', null=True, blank=True) + toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.user + + +# 今日头条错别字 +class Toutiao_Wrong(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + wrong = models.CharField('错别字', max_length=256, null=True, blank=True) + idea = models.CharField('建议', max_length=256, null=True, blank=True) + site = models.CharField('位置', max_length=256, null=True, blank=True) + toutiao = models.ForeignKey(Toutiao, on_delete=models.CASCADE, null=True, blank=True) + change = models.BooleanField('是否已修改', null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.wrong + + +# 其他新媒体 +class Qita(models.Model): + QITA_STATUS_CHOICES = ( + ('1', '开启'), + ('0', '关闭') + ) + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + type = models.CharField('新媒体类型', max_length=256, null=True, blank=True) + name = models.CharField('新媒体名称', max_length=256, null=True, blank=True) + qitaid = models.CharField('新媒体ID', max_length=256, null=True, blank=True) + alias = models.CharField('别名', max_length=256, null=True, blank=True) + image = models.FileField(upload_to='cover', null=True, blank=True) + organization = models.ForeignKey(Organization, on_delete=models.CASCADE, null=True, blank=True) + status = models.CharField('状态', max_length=256, null=True, blank=True, choices=QITA_STATUS_CHOICES) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.name + +#其他新媒体监测 +class Qita_jc(models.Model): + id = models.UUIDField('id', primary_key=True, default=uuid.uuid4) + mewnedia = models.ForeignKey(Qita,on_delete=models.CASCADE) + count = models.CharField('总发文量', max_length=256, null=True, blank=True) + count_jc = models.CharField('监测时间内发文量', max_length=256, null=True, blank=True) + comment = models.CharField('评论数', max_length=256, null=True, blank=True) + reply = models.CharField('作者回复数', max_length=256, null=True, blank=True) + date = models.CharField('最近发文日期', max_length=256, null=True, blank=True) + created = models.DateTimeField('创建时间', auto_now_add=True) + updated = models.DateTimeField('更新时间', auto_now=True) + + def __str__(self): + return self.mewnedia.name +#5级地名库 +class Area_code_2020(models.Model): + code = models.CharField('区划代码',max_length=256,null=True,blank=True) + name = models.CharField('名称',max_length=256,null=True,blank=True) + level = models.CharField('级别1-5,省市县镇村',max_length=256,null=True,blank=True) + pcode = models.CharField('父级区划代码',max_length=256,null=True,blank=True) + + def __str__(self): + return self.name diff --git a/dashboard/templates/dashboard/base/header.html b/dashboard/templates/dashboard/base/header.html index 2e7d847..80742a1 100644 --- a/dashboard/templates/dashboard/base/header.html +++ b/dashboard/templates/dashboard/base/header.html @@ -1,381 +1,383 @@ -{% load static %} -
-
- -
-
- -
- {% if user.is_authenticated %} - - {% else %} -
- -
- {% endif %} -
-
- -
+{% load static %} +
+
+ +
+
+ + +
+ +
diff --git a/dashboard/templates/dashboard/base/left.html b/dashboard/templates/dashboard/base/left.html index 9f4fd8d..e4f249d 100644 --- a/dashboard/templates/dashboard/base/left.html +++ b/dashboard/templates/dashboard/base/left.html @@ -1,188 +1,194 @@ - + diff --git a/dashboard/templates/dashboard/index.html b/dashboard/templates/dashboard/index.html index 4028a06..741732d 100644 --- a/dashboard/templates/dashboard/index.html +++ b/dashboard/templates/dashboard/index.html @@ -1,550 +1,560 @@ -{% extends 'dashboard/base/base.html' %} -{% load static %} -{% block css %} - - - -{% endblock %} -{% block content %} - - - - -
- - -
- - - - {% include 'dashboard/base/left.html' %} - - - -
- -
-
- New Orders - 2,345 -
-
- ... -
-
- -
-
- Visitors - 345 -
-
- ... -
-
- -
- - -
- - -
-
- -
-
- -
-

政务新媒体监测系统

- - -
-
-
- - -
-
-
-
-
-
- {# #} - -
-

{{ weixin_count }}

- 微信 -
-
-
-
-
- {# #} - -
-

{{ weibo_count }}

- 微博 -
-
-
-
-
- {# #} - -
-

{{ toutiao_count }}

- 今日头条 -
-
-
-
-
- {# #} - -
-

{{ qita_count }}

- 其他新媒体 -
-
-
-
-
- -
- -
- 98.95% - SERVER UP -
- Loading... -
- - -
- 2332 - USERS ONLINE -
- Loading... -
- - -
- 342/0 - ORDERS / SALES -
- Loading... -
- -
- - -
-
- -  PAGE VIEWS    UNIQUE VISITORS - - -        - - -
- - -
-
- -
-
- -  CPU USAGE - - -

-
-
-  LONDON    PARIS -
- -
-
- -
- -
- - -
-
-
-

Visitor's Statistics

-
-
-
-
-
-
-
-

Unique Visitors

- Last Week Rise by 62% -
-
-
-
-

Registrations

- Up by 57% last 7 days -
-
-
-
-

Direct Sales

- Last Month Rise by 22% -
-
-
-
-
-
-
- -
-
- - -
-
-
-
-
-
- -
-
-
-
- - - - -
-
- - - -
-
-
- -
-
-
-
- -
-
-
Smoothing
-
-
-
-
Preview Range
-
-
-
- -
-
- -
-
-
-
- - -
-
- -
- - - -
-

Groups

- - - -

Favourites

- - - -

More Contacts

- -
- -
- - -
- - -
-
- - - - - - -{% endblock %} -{% block add_js %} - - - - - - - - - - - - -{% endblock %} - - +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + + + +{% endblock %} +{% block content %} + + + + +
+ + +
+ + + + {% include 'dashboard/base/left.html' %} + + + +
+ +
+
+ New Orders + 2,345 +
+
+ ... +
+
+ +
+
+ Visitors + 345 +
+
+ ... +
+
+ +
+ + +
+ + +
+
+ {% if messages %} + + {% endif %} +
+
+ +
+

政务新媒体监测系统

+ + +
+
+
+ + +
+
+
+
+
+
+ {# #} + +
+

{{ weixin_count }}

+ 微信 +
+
+
+
+
+ {# #} + +
+

{{ weibo_count }}

+ 微博 +
+
+
+
+
+ {# #} + +
+

{{ toutiao_count }}

+ 今日头条 +
+
+
+
+
+ {# #} + +
+

{{ qita_count }}

+ 其他新媒体 +
+
+
+
+
+ +
+ +
+ 98.95% + SERVER UP +
+ Loading... +
+ + +
+ 2332 + USERS ONLINE +
+ Loading... +
+ + +
+ 342/0 + ORDERS / SALES +
+ Loading... +
+ +
+ + +
+
+ +  PAGE VIEWS    UNIQUE VISITORS + + +        + + +
+ + +
+
+ +
+
+ +  CPU USAGE + + +

+
+
+  LONDON    PARIS +
+ +
+
+ +
+ +
+ + +
+
+
+

Visitor's Statistics

+
+
+
+
+
+
+
+

Unique Visitors

+ Last Week Rise by 62% +
+
+
+
+

Registrations

+ Up by 57% last 7 days +
+
+
+
+

Direct Sales

+ Last Month Rise by 22% +
+
+
+
+
+
+
+ +
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ + + + +
+
+ + + +
+
+
+ +
+
+
+
+ +
+
+
Smoothing
+
+
+
+
Preview Range
+
+
+
+ +
+
+ +
+
+
+
+ + +
+
+ +
+ + + +
+

Groups

+ + + +

Favourites

+ + + +

More Contacts

+ +
+ +
+ + +
+ + +
+
+ + + + + + +{% endblock %} +{% block add_js %} + + + + + + + + + + + + +{% endblock %} + + diff --git a/dashboard/templates/dashboard/login.html b/dashboard/templates/dashboard/login.html index 031f799..8256657 100644 --- a/dashboard/templates/dashboard/login.html +++ b/dashboard/templates/dashboard/login.html @@ -1,149 +1,149 @@ -{% extends 'dashboard/base/base.html' %} -{% load static %} -{% block css %} - -{% endblock %} -{% block header %} {% endblock %} -{% block content %} - - - - -
- {% if messages %} - - {% endif %} -
-

Ultra Admin

- -
{% csrf_token %} -

- -

-

- -

-

- - - captcha - - - - - -

-

- -

- - -

- -

- -
- - - -
-
- - - - - -{% endblock %} -{% block add_js %} - -{% endblock %} +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + +{% endblock %} +{% block header %} {% endblock %} +{% block content %} + + + + +
+ {% if messages %} + + {% endif %} +
+

Ultra Admin

+ +
{% csrf_token %} +

+ +

+

+ +

+

+ + + captcha + + + + + +

+

+ +

+ + +

+ +

+ +
+ + + +
+
+ + + + + +{% endblock %} +{% block add_js %} + +{% endblock %} diff --git a/dashboard/templates/dashboard/register.html b/dashboard/templates/dashboard/register.html index 640b084..847e4d4 100644 --- a/dashboard/templates/dashboard/register.html +++ b/dashboard/templates/dashboard/register.html @@ -1,188 +1,188 @@ -{% extends 'dashboard/base/base.html' %} -{% load static %} -{% block css %} - -{% endblock %} -{% block header %}{% endblock %} -{% block content %} - - - -
- {% if messages %} - - - {% endif %} -
-

Ultra Admin

- -
{% csrf_token %} -

- -

-

- -

-

- -

- -

- -

-

- -

-

- -

-

- -

-

- -

-

- -

-

- - - captcha - - - - - -

-

- -

- - -

- -

-
- - -
- -
-
- - - - -{% endblock %} -{% block add_js %} - -{% endblock %} - +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + +{% endblock %} +{% block header %}{% endblock %} +{% block content %} + + + +
+ {% if messages %} + + + {% endif %} +
+

Ultra Admin

+ +
{% csrf_token %} +

+ +

+

+ +

+

+ +

+ +

+ +

+

+ +

+{#

#} +{# #} +{#

#} +

+ +

+

+ +

+

+ +

+

+ + + captcha + + + + + +

+

+ +

+ + +

+ +

+
+ + +
+ +
+
+ + + + +{% endblock %} +{% block add_js %} + +{% endblock %} + diff --git a/dashboard/views.py b/dashboard/views.py index 3515809..857473f 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -48,10 +48,11 @@ def user_login(request): except CaptchaStore.DoesNotExist: messages.error(request, '验证码错误') return HttpResponseRedirect('/login/') + print(username,password) if username is not None and password is not None: try: - # user = authenticate(username=username, password=password) - user = User.objects.get(Q(username=username) | Q(first_name=username) | Q(email=username)) + user = authenticate(username=username, password=password) + # user = User.objects.get(username=phone) if user is not None: if user.check_password(password): login(request, user) @@ -61,7 +62,7 @@ def user_login(request): else: messages.error(request, '账号或密码错误,请您确认账号和密码') except: - messages.error(request, '账号或密码错误,请您确认账号和密码') + messages.error(request, '111') return render(request,'dashboard/login.html',{'hash_key':hash_key,'image_url':image_url}) def user_logout(request): logout(request) @@ -72,7 +73,7 @@ def register(request): password = None confirm_password = None name = None - phone = None + # phone = None image = None flag = False o = None @@ -93,10 +94,10 @@ def register(request): messages.error(request, '请输入邮箱') else: email = request.POST.get('email') - if not request.POST.get('phone'): - messages.error(request, '请输入电话') - else: - phone = request.POST.get('phone') + # if not request.POST.get('phone'): + # messages.error(request, '请输入电话') + # else: + # phone = request.POST.get('phone') if not request.POST.get('username'): messages.error(request, '请输入用户名') else: @@ -115,9 +116,9 @@ def register(request): else: image = request.FILES.get('image') print(str(image)+"1111111111111111111111111111111111111111111") - if request.POST.get('sex') == 0: + if request.POST.get('sex') == '1': sex = '男' - else: + elif request.POST.get('sex') == '2': sex = '女' captcha_input = request.POST.get('captcha_1') captcha_hashkey = request.POST.get('captcha_0') @@ -136,16 +137,16 @@ def register(request): filter_result = User.objects.filter(username=username) if len(filter_result) > 0: - messages.error(request, '对不起,您输入的用户名已被注册') - return render(request, "dashboard/register.html") + messages.error(request, '对不起,您输入的电话号码已被注册') + return HttpResponseRedirect('/register/') if username is not None and password is not None and confirm_password is not None and email is not None and flag: - user = User.objects.create_user(username, email, password) + user = User.objects.create_user(username,email,password) user.is_active = True - user.is_staff = True - user.first_name = phone + # user.is_staff = True + # user.first_name = phone user.save() - userprofile = Userprofile(name=name,image=image,user_id=user.id,organization_id=o,sex=sex) + userprofile = Userprofile(name=name,image=image,user_id=user.id,organization_id=o,sex=sex,status=0) userprofile.save() messages.success(request, '注册成功,请登录') return HttpResponseRedirect('/login/') diff --git a/management/templates/management/user-management-update.html b/management/templates/management/user-management-update.html new file mode 100644 index 0000000..8e13aab --- /dev/null +++ b/management/templates/management/user-management-update.html @@ -0,0 +1,119 @@ +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block content %} + + + + +
+ +
+ {% include 'dashboard/base/left.html' %} +
+
+
+ {% if messages %} + + {% endif %} +
+
+ +
+

系统设置

+
+
+
+ +
+
+
+

用户信息

+
+
+
+
+
{% csrf_token %} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+
+
+ +{% endblock %} + diff --git a/management/templates/management/user-management.html b/management/templates/management/user-management.html index 5bcbdfa..1939180 100644 --- a/management/templates/management/user-management.html +++ b/management/templates/management/user-management.html @@ -1,80 +1,80 @@ -{% extends 'dashboard/base/base.html' %} -{% load static %} -{% block css %} - - -{% endblock %} -{% block content %} - -
-
- {% include 'dashboard/base/left.html' %} -
-
-
-
-
-
-

用户管理

-
-
-
-
-
-
-

成员列表

-
-
-
-
- - - - - - - - - - - - - - {% for u in userallinfo %} - - - - - - - - - - {% endfor %} - -
头像姓名电话单位名称单位类型行政区划操作
{{ u.name }}{{ u.phone }}{{ u.organization }}{{ u.type }}{{ u.administrativedivision }} - 删除 -
- -
-
-
-
-
-
-
-
-
-
- -{% endblock %} -{% block add_js %} - - - -{% endblock %} +{% extends 'dashboard/base/base.html' %} +{% load static %} +{% block css %} + + +{% endblock %} +{% block content %} + +
+
+ {% include 'dashboard/base/left.html' %} +
+
+
+
+
+
+

用户管理

+
+
+
+
+
+
+

成员列表

+
+
+
+
+ + + + + + + + + + + + + + {% for u in userallinfo %} + + + + + + + + + + {% endfor %} + +
头像姓名电话单位名称单位类型行政区划操作
{{ u.name }}{{ u.phone }}{{ u.organization }}{{ u.type }}{{ u.administrativedivision }} + 删除 +
+ +
+
+
+
+
+
+
+
+
+
+ +{% endblock %} +{% block add_js %} + + + +{% endblock %} diff --git a/management/urls.py b/management/urls.py index 13f020e..092e072 100644 --- a/management/urls.py +++ b/management/urls.py @@ -1,47 +1,48 @@ -from django.urls import path - -from management import views - -urlpatterns = [ - # 用户管理 - path('user/management/', views.user_management, name='user-management-management'), - path('user/delete//', views.user_delete, name='user-management-delete'), - # 群组管理 - path('group/management/', views.group_management, name='group-management-management'), - path('group/create/', views.group_create, name='group-management-create'), - path('group/update//', views.group_update, name='group-management-update'), - path('group/delete//', views.group_delete, name='group-management-delete'), - - # 添加群组管理员、成员 - path('group/admin/create//', views.group_admin_create, name='group-admin-create'), - path('group/admin/delete///', views.group_admin_delete, name='group-admin-delete'), - path('group/user/create//', views.group_user_create, name='group-user-create'), - path('group/user/delete///', views.group_user_delete, name='group-user-delete'), - - # 主体单位管理 - path('organization/management/', views.organization_management, name='organization-management-management'), - path('organization/create/', views.organization_create, name='organization-management-create'), - path('organization/delete//', views.organization_delete, name='organization-management-delete'), - path('organization/update//', views.organization_update, name='organization-management-update'), - - #新媒体管理 - path('newmedia/management/create/menu/',views.newmedia_management_create_menu,name='newmedia-management-create-menu'), - path('newmedia/management/edit/menu/',views.newmedia_management_edit_menu,name='newmedia-management-edit-menu'), - path('newmedia/management/create/weixin/',views.newmedia_management_create_weixin,name='newmedia-management-create-weixin'), - path('newmedia/management/create/weibo/',views.newmedia_management_create_weibo,name='newmedia-management-create-weibo'), - path('newmedia/management/create/toutiao/',views.newmedia_management_create_toutiao,name='newmedia-management-create-toutiao'), - path('newmedia/management/create/qita/',views.newmedia_management_create_qita,name='newmedia-management-create-qita'), - path('newmedia/management/edit/weixin/',views.newmedia_management_edit_weixin,name='newmedia-management-edit-weixin'), - path('newmedia/management/edit/weibo/',views.newmedia_management_edit_weibo,name='newmedia-management-edit-weibo'), - path('newmedia/management/edit/toutiao/',views.newmedia_management_edit_toutiao,name='newmedia-management-edit-toutiao'), - path('newmedia/management/edit/qita/',views.newmedia_management_edit_qita,name='newmedia-management-edit-qita'), - path('newmedia/management/update/weixin//',views.newmedia_management_update_weixin,name='newmedia-management-update-weixin'), - path('newmedia/management/update/weibo//',views.newmedia_management_update_weibo,name='newmedia-management-update-weibo'), - path('newmedia/management/update/toutiao//',views.newmedia_management_update_toutiao,name='newmedia-management-update-toutiao'), - path('newmedia/management/update/qita//',views.newmedia_management_update_qita,name='newmedia-management-update-qita'), - path('newmedia/management/delete/weixin//',views.newmedia_management_delete_weixin,name='newmedia-management-delete-weixin'), - path('newmedia/management/delete/weibo//',views.newmedia_management_delete_weibo,name='newmedia-management-delete-weibo'), - path('newmedia/management/delete/toutiao//',views.newmedia_management_delete_toutiao,name='newmedia-management-delete-toutiao'), - path('newmedia/management/delete/qita//',views.newmedia_management_delete_qita,name='newmedia-management-delete-qita'), - -] +from django.urls import path + +from management import views + +urlpatterns = [ + # 用户管理 + path('user/management/', views.user_management, name='user-management-management'), + path('user/delete//', views.user_delete, name='user-management-delete'), + path('user/update//', views.user_update, name='user-management-update'), + # 群组管理 + path('group/management/', views.group_management, name='group-management-management'), + path('group/create/', views.group_create, name='group-management-create'), + path('group/update//', views.group_update, name='group-management-update'), + path('group/delete//', views.group_delete, name='group-management-delete'), + + # 添加群组管理员、成员 + path('group/admin/create//', views.group_admin_create, name='group-admin-create'), + path('group/admin/delete///', views.group_admin_delete, name='group-admin-delete'), + path('group/user/create//', views.group_user_create, name='group-user-create'), + path('group/user/delete///', views.group_user_delete, name='group-user-delete'), + + # 主体单位管理 + path('organization/management/', views.organization_management, name='organization-management-management'), + path('organization/create/', views.organization_create, name='organization-management-create'), + path('organization/delete//', views.organization_delete, name='organization-management-delete'), + path('organization/update//', views.organization_update, name='organization-management-update'), + + #新媒体管理 + path('newmedia/management/create/menu/',views.newmedia_management_create_menu,name='newmedia-management-create-menu'), + path('newmedia/management/edit/menu/',views.newmedia_management_edit_menu,name='newmedia-management-edit-menu'), + path('newmedia/management/create/weixin/',views.newmedia_management_create_weixin,name='newmedia-management-create-weixin'), + path('newmedia/management/create/weibo/',views.newmedia_management_create_weibo,name='newmedia-management-create-weibo'), + path('newmedia/management/create/toutiao/',views.newmedia_management_create_toutiao,name='newmedia-management-create-toutiao'), + path('newmedia/management/create/qita/',views.newmedia_management_create_qita,name='newmedia-management-create-qita'), + path('newmedia/management/edit/weixin/',views.newmedia_management_edit_weixin,name='newmedia-management-edit-weixin'), + path('newmedia/management/edit/weibo/',views.newmedia_management_edit_weibo,name='newmedia-management-edit-weibo'), + path('newmedia/management/edit/toutiao/',views.newmedia_management_edit_toutiao,name='newmedia-management-edit-toutiao'), + path('newmedia/management/edit/qita/',views.newmedia_management_edit_qita,name='newmedia-management-edit-qita'), + path('newmedia/management/update/weixin//',views.newmedia_management_update_weixin,name='newmedia-management-update-weixin'), + path('newmedia/management/update/weibo//',views.newmedia_management_update_weibo,name='newmedia-management-update-weibo'), + path('newmedia/management/update/toutiao//',views.newmedia_management_update_toutiao,name='newmedia-management-update-toutiao'), + path('newmedia/management/update/qita//',views.newmedia_management_update_qita,name='newmedia-management-update-qita'), + path('newmedia/management/delete/weixin//',views.newmedia_management_delete_weixin,name='newmedia-management-delete-weixin'), + path('newmedia/management/delete/weibo//',views.newmedia_management_delete_weibo,name='newmedia-management-delete-weibo'), + path('newmedia/management/delete/toutiao//',views.newmedia_management_delete_toutiao,name='newmedia-management-delete-toutiao'), + path('newmedia/management/delete/qita//',views.newmedia_management_delete_qita,name='newmedia-management-delete-qita'), + +] diff --git a/management/views.py b/management/views.py index 25766e2..53fc29c 100644 --- a/management/views.py +++ b/management/views.py @@ -1,861 +1,912 @@ -import json - -from django.contrib import messages -from django.contrib.auth.models import User -from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage -from django.http import HttpResponse, HttpResponseRedirect -from django.shortcuts import render - -from dashboard.models import Userprofile, Group, Organization, Level, Organizationtype, Area_code_2020, Weixin, Weibo, \ - Toutiao, Qita, Group_type, Group_admin, Group_user - - -def user_management(request): - userpaginator = User.objects.all().order_by('-date_joined') - paginator = Paginator(userpaginator, 6) - page = int(request.GET.get('page', 1)) - try: - userpaginator = paginator.page(page) - except PageNotAnInteger: - userpaginator = paginator.page(1) - except EmptyPage: - userpaginator = paginator.page(paginator.num_pages) - userallinfo = [] - for u in userpaginator: - o = dict() - o['id'] = str(u.id) - o['image'] = u.userprofile_set.get(user_id=u.id).image.url - o['name'] = u.userprofile_set.get(user_id=u.id).name - o['phone'] = u.first_name - o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name - o['type'] = u.userprofile_set.get(user_id=u.id).organization.organizationtype.organizationtype - organization_id = Userprofile.objects.get(user_id=u.id).organization_id - print(organization_id) - o['administrativedivision'] = str(str(Organization.objects.get(id=organization_id).province) + '-' + str( - Organization.objects.get(id=organization_id).cities) + '-' + str( - Organization.objects.get(id=organization_id).district) + '-' + str( - Organization.objects.get(id=organization_id).town) + '-' + str( - Organization.objects.get(id=organization_id).village)).replace('None', '') - userallinfo.append(o) - print(userallinfo) - return render(request, 'management/user-management.html', - {'userallinfo': userallinfo, 'userpaginator': userpaginator}) - - -def user_delete(request, pk): - user = User.objects.get(id=pk) - user.delete() - return HttpResponseRedirect('/management/user/management/') - - -def group_management(request): - group = Group.objects.all().order_by('-created') - paginator = Paginator(group, 6) - page = int(request.GET.get('page', 1)) - try: - group = paginator.page(page) - except PageNotAnInteger: - group = paginator.page(1) - except EmptyPage: - group = paginator.page(paginator.num_pages) - res = [] - for g in group: - o = dict() - o['id'] = str(g.id) - o['image'] = g.image.url - o['name'] = g.name - o['type'] = g.type - o['admin_count'] = Group_admin.objects.filter(group_id=g.id).count() - o['user_count'] = Group_user.objects.filter(group_id=g.id).count() - o['status'] = g.status - res.append(o) - return render(request, 'management/group-management.html', {'res': res, 'group': group}) - - -def group_update(request, pk): - group = Group.objects.get(id=pk) - GROUP_STATUS_CHOICES = Group.GROUP_STATUS_CHOICES - group_status_choices_list = [] - for g in GROUP_STATUS_CHOICES: - group_status_choices_list.append(list(g)[1]) - group_type = Group_type.objects.all() - group_admin = Group_admin.objects.filter(group_id=pk) - print(pk) - g_a_list = [] - for g_a in group_admin: - o = dict() - o['id'] = str(g_a.id) - o['image'] = Userprofile.objects.get(user_id=g_a.user.id).image.url - o['username'] = g_a.user.username - o['name'] = Userprofile.objects.get(user_id=g_a.user.id).name - o['organization'] = Userprofile.objects.get(user_id=g_a.user.id).organization.name - o['administrativedivision'] = str(g_a.group.province) + '-' + str(g_a.group.cities) + '-' + str( - g_a.group.district) + '-' + str(g_a.group.town) + '-' + str(g_a.group.village) - g_a_list.append(o) - group_user = Group_user.objects.filter(group_id=pk) - g_u_list = [] - for g_u in group_user: - i = dict() - i['id'] = str(g_u.id) - i['image'] = Userprofile.objects.get(user_id=g_u.user.id).image.url - i['username'] = g_u.user.username - i['name'] = Userprofile.objects.get(user_id=g_u.user.id).name - i['organization'] = Userprofile.objects.get(user_id=g_u.user.id).organization.name - i['administrativedivision'] = str(g_u.group.province) + '-' + str(g_u.group.cities) + '-' + str( - g_u.group.district) + '-' + str(g_u.group.town) + '-' + str(g_u.group.village) - g_u_list.append(i) - if request.method == 'POST': - name = request.POST.get('name') - presentation = request.POST.get('presentation') - image = request.FILES.get('image') - type = request.POST.get('type') - status = request.POST.get('status') - province = request.POST.get('province') - print(str(province) + "66666666666666666666666666") - if province != '' and province.isdigit(): - province_r = Area_code_2020.objects.get(code=province).name - else: - province_r = province - city = request.POST.get('city') - if city != '' and city.isdigit(): - city_r = Area_code_2020.objects.get(code=city).name - else: - city_r = city - district = request.POST.get('district') - if district != '' and district.isdigit(): - district_r = Area_code_2020.objects.get(code=district).name - else: - district_r = district - town = request.POST.get('town') - if town != '' and town.isdigit(): - town_r = Area_code_2020.objects.get(code=town).name - else: - town_r = town - village = request.POST.get('village') - if village != '' and village.isdigit(): - village_r = Area_code_2020.objects.get(code=village).name - else: - village_r = village - if image is not None: - Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status, - province=province_r, cities=city_r, district=district_r, town=town_r, - village=village_r) - g = Group.objects.get(id=pk) - g.image = image - g.save() - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/group/management/') - else: - Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status, - province=province_r, cities=city_r, district=district_r, town=town_r, - village=village_r) - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/group/management/') - return render(request, 'management/group-management-update.html', - {'group': group, 'group_status_choices_list': group_status_choices_list, 'group_type': group_type, - 'g_a_list': g_a_list, 'g_u_list': g_u_list}) - - -def group_create(request): - GROUP_STATUS_CHOICES = Group.GROUP_STATUS_CHOICES - group_status_choices_list = [] - for g in GROUP_STATUS_CHOICES: - group_status_choices_list.append(list(g)[1]) - group_type = Group_type.objects.all() - if request.method == 'POST': - name = request.POST.get('name') - presentation = request.POST.get('presentation') - image = request.FILES.get('image') - type = request.POST.get('type') - status = request.POST.get('status') - province = request.POST.get('province') - if province != '': - province_r = Area_code_2020.objects.get(code=province).name - else: - messages.error(request, '请选择行政区划') - return HttpResponseRedirect('/management/organization/create/') - city = request.POST.get('city') - if city != '': - city_r = Area_code_2020.objects.get(code=city).name - else: - city_r = city - district = request.POST.get('district') - if district != '': - district_r = Area_code_2020.objects.get(code=district).name - else: - district_r = district - town = request.POST.get('town') - if town != '': - town_r = Area_code_2020.objects.get(code=town).name - else: - town_r = town - village = request.POST.get('village') - if village != '': - village_r = Area_code_2020.objects.get(code=village).name - else: - village_r = village - print(name, presentation, image, type, status, province, city, district, town, village) - if name is not None: - group = Group(name=name, presentation=presentation, image=image, type_id=type, status=status, - province=province_r, cities=city_r, district=district_r, town=town_r, village=village_r) - group.save() - messages.success(request, '添加成功') - else: - messages.error(request, '群组名不能为空') - return HttpResponseRedirect('/management/group/management/') - return render(request, 'management/group-management-create.html', - {'group_status_choices_list': group_status_choices_list, 'group_type': group_type}) - - -def group_admin_create(request, pk): - if request.method == 'POST': - user = request.POST.get("user") - print(user) - results = Group_admin.objects.filter(user_id=user, group_id=pk).count() - if results != 0: - messages.success(request, "该管理员已经存在") - return HttpResponseRedirect('/management/group/update/%s/' % (pk)) - group_admin = Group_admin(user_id=user, group_id=pk) - group_admin.save() - messages.success(request, "添加成功") - return HttpResponseRedirect('/management/group/update/%s/' % (pk)) - group = Group.objects.get(id=pk).name - user = User.objects.all() - return render(request, 'management/group-admin-create.html', {'usee': user, 'group': group, 'pk': pk}) - - -def group_admin_delete(request, pk, group_pk): - group_admin = Group_admin.objects.get(id=pk) - group_admin.delete() - messages.success(request, '删除成功') - return HttpResponseRedirect('/management/group/update/%s/' % (group_pk)) - - -def group_user_create(request, pk): - if request.method == 'POST': - user = request.POST.get('user') - results = Group_user.objects.filter(user_id=user, group_id=pk).count() - if results != 0: - messages.success(request, "该成员已经存在") - return HttpResponseRedirect('/management/group/update/%s/' % (pk)) - group_user = Group_user(user_id=user, group_id=pk) - group_user.save() - messages.success(request, '添加成功') - return HttpResponseRedirect('/management/group/update/%s' % (pk)) - group = Group.objects.get(id=pk).name - user = User.objects.all() - return render(request, 'management/group-user-create.html', {'usee': user, 'group': group, 'pk': pk}) - - -def group_user_delete(request, pk, group_pk): - group_user = Group_user.objects.get(id=pk) - group_user.delete() - messages.success(request, '删除成功') - return HttpResponseRedirect('/management/group/update/%s/' % (group_pk)) - - -def group_delete(request, pk): - group = Group.objects.get(id=pk) - group.delete() - messages.success(request, '删除成功') - return HttpResponseRedirect('/management/group/management/') - - -def organization_management(request): - organization = Organization.objects.all().order_by('-created') - paginator = Paginator(organization, 6) - page = int(request.GET.get('page', 1)) - try: - organization = paginator.page(page) - except PageNotAnInteger: - organization = paginator.page(1) - except EmptyPage: - organization = paginator.page(paginator.num_pages) - res = [] - for i in organization: - o = dict() - o['id'] = str(i.id) - o['name'] = i.name - o['image'] = i.image.url - o['organizationtype'] = i.organizationtype.organizationtype - o['administrativedivision'] = str(i.province) + '-' + str(i.cities) + '-' + str(i.district) + '-' + str( - i.town) + '-' + str(i.village) - o['usercount'] = Userprofile.objects.filter(organization_id=i.id).count() - o['mediacount'] = Weixin.objects.filter(organization_id=i.id).count() + Weibo.objects.filter( - organization_id=i.id).count() + Toutiao.objects.filter(organization_id=i.id).count() + Qita.objects.filter( - organization_id=i.id).count() - res.append(o) - - return render(request, 'management/organization-management.html', {"organization": organization, 'res': res}) - - -def organization_delete(request, pk): - organization = Organization.objects.get(id=pk) - organization.delete() - messages.success(request, '删除成功') - return HttpResponseRedirect('/management/organization/management/') - - -def organization_update(request, pk): - organization = Organization.objects.get(id=pk) - organizationtype = Organizationtype.objects.all() - if request.method == 'POST': - name = request.POST.get('name') - image = request.FILES.get('image') - organizationtype = request.POST.get('organizationtype') - province = request.POST.get('province') - if province != '' and province.isdigit(): - province_r = Area_code_2020.objects.get(code=province).name - else: - province_r = province - city = request.POST.get('city') - if city != '' and city.isdigit(): - city_r = Area_code_2020.objects.get(code=city).name - else: - city_r = city - district = request.POST.get('district') - if district != '' and district.isdigit(): - district_r = Area_code_2020.objects.get(code=district).name - else: - district_r = district - town = request.POST.get('town') - if town != '' and town.isdigit(): - town_r = Area_code_2020.objects.get(code=town).name - else: - town_r = town - village = request.POST.get('village') - if village != '' and village.isdigit(): - village_r = Area_code_2020.objects.get(code=village).name - else: - village_r = village - if name is not None: - if image is not None: - Organization.objects.filter(id=pk).update(name=name, organizationtype_id=organizationtype, - province=province_r, cities=city_r, district=district_r, - town=town_r, village=village_r) - o = Organization.objects.get(id=pk) - o.image = image - o.save() - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/organization/management/') - else: - Organization.objects.filter(id=pk).update(name=name, organizationtype_id=organizationtype, - province=province_r, cities=city_r, district=district_r, - town=town_r, village=village_r) - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/organization/management/') - return render(request, 'management/organization-management-update.html', - {'organization': organization, 'organizationtype': organizationtype}) - - -def organization_create(request): - organizationtype = Organizationtype.objects.all() - if request.method == 'POST': - name = request.POST.get('name') - image = request.FILES.get('image') - organizationtype = request.POST.get('organizationtype') - province = request.POST.get('province') - if province != '': - province_r = Area_code_2020.objects.get(code=province).name - else: - messages.error(request, '请选择行政区划') - return HttpResponseRedirect('/management/organization/create/') - city = request.POST.get('city') - if city != '': - city_r = Area_code_2020.objects.get(code=city).name - else: - city_r = city - district = request.POST.get('district') - if district != '': - district_r = Area_code_2020.objects.get(code=district).name - else: - district_r = district - town = request.POST.get('town') - if town != '': - town_r = Area_code_2020.objects.get(code=town).name - else: - town_r = town - village = request.POST.get('village') - if village != '': - village_r = Area_code_2020.objects.get(code=village).name - else: - village_r = village - print(province, city) - if name is not None: - organization = Organization(name=name, image=image, organizationtype_id=organizationtype, - province=province_r, cities=city_r, district=district_r, town=town_r, - village=village_r) - organization.save() - messages.success(request, '添加成功') - else: - messages.error(request, '单位名不能为空') - return HttpResponseRedirect('/management/organization/management/') - return render(request, 'management/organization-management-create.html', {'organizationtype': organizationtype}) - - -def newmedia_management_create_menu(request): - return render(request, 'management/newmedia-management-create-menu.html') - - -def newmedia_management_create_weixin(request): - WEIXIN_STATUS_CHOICES = Weixin.WEIXIN_STATUS_CHOICES - weixin_status_choices_list = [] - for w in WEIXIN_STATUS_CHOICES: - weixin_status_choices_list.append(list(w)[1]) - organization = Organization.objects.all() - if request.method == 'POST': - code = request.POST.get('code') - weixinid = request.POST.get('weixinid') - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if code is not None: - if organization is not None: - if image is not None: - weixin = Weixin(code=code, weixinid=weixinid, alias=alias, image=image, - organization_id=organization, status=status) - weixin.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/weixin/') - else: - weixin = Weixin(code=code, weixinid=weixinid, alias=alias, image='weixin.png', - organization_id=organization, status=status) - weixin.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/weixin/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-create-weixin.html', - {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) - else: - messages.success(request, "微信公众号不能为空") - return render(request, 'management/newmedia-management-create-weixin.html', - {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) - return render(request, 'management/newmedia-management-create-weixin.html', - {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) - - -def newmedia_management_create_weibo(request): - WEIBO_STATUS_CHOICES = Weibo.WEIBO_STATUS_CHOICES - weibo_status_choices_list = [] - for w in WEIBO_STATUS_CHOICES: - weibo_status_choices_list.append(list(w)[1]) - organization = Organization.objects.all() - if request.method == 'POST': - code = request.POST.get('code') - weiboid = request.POST.get('weiboid') - print(str(weiboid) + "11111111111111111111111111111111111111") - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if code is not None: - if organization is not None: - if image is not None: - weibo = Weibo(code=code, weiboid=weiboid, alias=alias, image=image, - organization_id=organization, status=status) - weibo.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/weibo/') - else: - weibo = Weibo(code=code, weiboid=weiboid, alias=alias, image='weibo.png', - organization_id=organization, status=status) - weibo.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/weibo/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-create-weibo.html', - {'weibo_status_choices_list': weibo_status_choices_list, "organization": organization}) - else: - messages.success(request, "微博号不能为空") - return render(request, 'management/newmedia-management-create-weibo.html', - {'weixin_status_choices_list': weibo_status_choices_list, "organization": organization}) - return render(request, 'management/newmedia-management-create-weibo.html', - {'weibo_status_choices_list': weibo_status_choices_list, "organization": organization}) - - -def newmedia_management_create_toutiao(request): - TOUTIAO_STATUS_CHOICES = Toutiao.TOUTIAO_STATUS_CHOICES - toutiao_status_choices_list = [] - for w in TOUTIAO_STATUS_CHOICES: - toutiao_status_choices_list.append(list(w)[1]) - organization = Organization.objects.all() - if request.method == 'POST': - code = request.POST.get('code') - toutiaoid = request.POST.get('toutiaoid') - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if code is not None: - if organization is not None: - if image is not None: - toutiao = Toutiao(code=code, toutiaoid=toutiaoid, alias=alias, image=image, - organization_id=organization, status=status) - toutiao.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/toutiao/') - else: - toutiao = Toutiao(code=code, toutiaoid=toutiaoid, alias=alias, image='toutiao.png', - organization_id=organization, status=status) - toutiao.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/toutiao/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-create-toutiao.html', - {'toutiao_status_choices_list': toutiao_status_choices_list, - "organization": organization}) - else: - messages.success(request, "头条号不能为空") - return render(request, 'management/newmedia-management-create-toutiao.html', - {'toutiao_status_choices_list': toutiao_status_choices_list, "organization": organization}) - return render(request, 'management/newmedia-management-create-toutiao.html', - {'toutiao_status_choices_list': toutiao_status_choices_list, "organization": organization}) - - -def newmedia_management_create_qita(request): - QITA_STATUS_CHOICES = Qita.QITA_STATUS_CHOICES - qita_status_choices_list = [] - for w in QITA_STATUS_CHOICES: - qita_status_choices_list.append(list(w)[1]) - organization = Organization.objects.all() - if request.method == 'POST': - type = request.POST.get('type') - name = request.POST.get('name') - qitaid = request.POST.get('qitaid') - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if name is not None: - if organization is not None: - if image is not None: - qita = Qita(type=type, name=name, qitaid=qitaid, alias=alias, image=image, - organization_id=organization, status=status) - qita.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/qita/') - else: - qita = Qita(type=type, name=name, qitaid=qitaid, alias=alias, image='qita.png', - organization_id=organization, status=status) - qita.save() - messages.success(request, '创建成功') - return HttpResponseRedirect('/management/newmedia/management/create/qita/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-create-qita.html', - {'qita_status_choices_list': qita_status_choices_list, "organization": organization}) - else: - messages.success(request, "新媒体名称不能为空") - return render(request, 'management/newmedia-management-create-qita.html', - {'qita_status_choices_list': qita_status_choices_list, "organization": organization}) - return render(request, 'management/newmedia-management-create-qita.html', - {'qita_status_choices_list': qita_status_choices_list, "organization": organization}) - - -def newmedia_management_edit_menu(request): - return render(request, 'management/newmedia-management-edit-menu.html') - - -def newmedia_management_edit_weixin(request): - weixin = Weixin.objects.all().order_by('-created') - paginator = Paginator(weixin, 6) - page = int(request.GET.get('page', 1)) - try: - weixin = paginator.page(page) - except PageNotAnInteger: - weixin = paginator.page(1) - except EmptyPage: - weixin = paginator.page(paginator.num_pages) - res = [] - for w in weixin: - o = dict() - o['id'] = str(w.id) - o['image'] = w.image - o['code'] = w.code - o['weixinid'] = w.weixinid - o['organization'] = w.organization.name - o['organization_type'] = w.organization.organizationtype.organizationtype - o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( - w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) - o['status'] = w.status - res.append(o) - return render(request, 'management/newmedia-management-edit-weixin.html', {'weixin': weixin, 'res': res}) - - -def newmedia_management_edit_weibo(request): - weibo = Weibo.objects.all().order_by('-created') - paginator = Paginator(weibo, 6) - page = int(request.GET.get('page', 1)) - try: - weibo = paginator.page(page) - except PageNotAnInteger: - weibo = paginator.page(1) - except EmptyPage: - weibo = paginator.page(paginator.num_pages) - res = [] - for w in weibo: - o = dict() - o['id'] = str(w.id) - o['image'] = w.image - o['code'] = w.code - o['weiboid'] = w.weiboid - o['organization'] = w.organization.name - o['organization_type'] = w.organization.organizationtype.organizationtype - o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( - w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) - o['status'] = w.status - res.append(o) - return render(request, 'management/newmedia-management-edit-weibo.html', {'weibo': weibo, 'res': res}) - - -def newmedia_management_edit_toutiao(request): - toutiao = Toutiao.objects.all().order_by('-created') - paginator = Paginator(toutiao, 6) - page = int(request.GET.get('page', 1)) - try: - toutiao = paginator.page(page) - except PageNotAnInteger: - toutiao = paginator.page(1) - except EmptyPage: - toutiao = paginator.page(paginator.num_pages) - res = [] - for w in toutiao: - o = dict() - o['id'] = str(w.id) - o['image'] = w.image - o['code'] = w.code - o['toutiaoid'] = w.toutiaoid - o['organization'] = w.organization.name - o['organization_type'] = w.organization.organizationtype.organizationtype - o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( - w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) - o['status'] = w.status - res.append(o) - return render(request, 'management/newmedia-management-edit-toutiao.html', {'toutiao': toutiao, 'res': res}) - - -def newmedia_management_edit_qita(request): - qita = Qita.objects.all().order_by('-created') - paginator = Paginator(qita, 6) - page = int(request.GET.get('page', 1)) - try: - qita = paginator.page(page) - except PageNotAnInteger: - qita = paginator.page(1) - except EmptyPage: - qita = paginator.page(paginator.num_pages) - res = [] - for w in qita: - o = dict() - o['id'] = str(w.id) - o['image'] = w.image - o['type'] = w.type - o['name'] = w.name - o['qitaid'] = w.qitaid - o['organization'] = w.organization.name - o['organization_type'] = w.organization.organizationtype.organizationtype - o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( - w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) - o['status'] = w.status - res.append(o) - return render(request, 'management/newmedia-management-edit-qita.html', {'qita': qita, 'res': res}) - - -def newmedia_management_update_weixin(request, pk): - WEIXIN_STATUS_CHOICES = Weixin.WEIXIN_STATUS_CHOICES - weixin_status_choices_list = [] - for w in WEIXIN_STATUS_CHOICES: - weixin_status_choices_list.append(list(w)[1]) - weixin = Weixin.objects.get(id=pk) - organization = Organization.objects.all() - if request.method == 'POST': - code = request.POST.get('code') - weixinid = request.POST.get('weixinid') - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if code is not None: - if organization is not None: - if image is not None: - Weixin.objects.filter(id=pk).update(code=code, weixinid=weixinid, alias=alias, - organization_id=organization, status=status) - weixin.image = image - weixin.save() - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/weixin/') - else: - Weixin.objects.filter(id=pk).update(code=code, weixinid=weixinid, alias=alias, - organization_id=organization, status=status) - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/weixin/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-update-weixin.html', - {'weixin': weixin, 'organization': organization, - 'weixin_status_choices_list': weixin_status_choices_list}) - else: - messages.success(request, "微信公众号不能为空") - return render(request, 'management/newmedia-management-update-weixin.html', - {'weixin': weixin, 'organization': organization, - 'weixin_status_choices_list': weixin_status_choices_list}) - return render(request, 'management/newmedia-management-update-weixin.html', - {'weixin': weixin, 'organization': organization, - 'weixin_status_choices_list': weixin_status_choices_list}) - -def newmedia_management_update_weibo(request, pk): - WEIBO_STATUS_CHOICES = Weibo.WEIBO_STATUS_CHOICES - weibo_status_choices_list = [] - for w in WEIBO_STATUS_CHOICES: - weibo_status_choices_list.append(list(w)[1]) - weibo = Weibo.objects.get(id=pk) - organization = Organization.objects.all() - if request.method == 'POST': - code = request.POST.get('code') - weiboid = request.POST.get('weiboid') - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if code is not None: - if organization is not None: - if image is not None: - Weibo.objects.filter(id=pk).update(code=code, weiboid=weiboid, alias=alias, - organization_id=organization, status=status) - weibo.image = image - weibo.save() - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/weibo/') - else: - Weibo.objects.filter(id=pk).update(code=code, weiboid=weiboid, alias=alias, - organization_id=organization, status=status) - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/weibo/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-update-weibo.html', - {'weibo': weibo, 'organization': organization, - 'weibo_status_choices_list': weibo_status_choices_list}) - else: - messages.success(request, "微博号不能为空") - return render(request, 'management/newmedia-management-update-weibo.html', - {'weibo': weibo, 'organization': organization, - 'weibo_status_choices_list': weibo_status_choices_list}) - return render(request, 'management/newmedia-management-update-weibo.html', - {'weibo': weibo, 'organization': organization, - 'weibo_status_choices_list': weibo_status_choices_list}) - - -def newmedia_management_update_toutiao(request, pk): - TOUTIAO_STATUS_CHOICES = Toutiao.TOUTIAO_STATUS_CHOICES - toutiao_status_choices_list = [] - for w in TOUTIAO_STATUS_CHOICES: - toutiao_status_choices_list.append(list(w)[1]) - toutiao = Toutiao.objects.get(id=pk) - organization = Organization.objects.all() - if request.method == 'POST': - code = request.POST.get('code') - toutiaoid = request.POST.get('toutiaoid') - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if code is not None: - if organization is not None: - if image is not None: - Toutiao.objects.filter(id=pk).update(code=code, toutiaoid=toutiaoid, alias=alias, - organization_id=organization, status=status) - toutiao.image = image - toutiao.save() - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/toutiao/') - else: - Toutiao.objects.filter(id=pk).update(code=code, toutiaoid=toutiaoid, alias=alias, - organization_id=organization, status=status) - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/toutiao/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-update-toutiao.html', - {'toutiao': toutiao, 'organization': organization, - 'toutiao_status_choices_list': toutiao_status_choices_list}) - else: - messages.success(request, "头条号不能为空") - return render(request, 'management/newmedia-management-update-toutiao.html', - {'toutiao': toutiao, 'organization': organization, - 'toutiao_status_choices_list': toutiao_status_choices_list}) - return render(request, 'management/newmedia-management-update-toutiao.html', - {'toutiao': toutiao, 'organization': organization, - 'toutiao_status_choices_list': toutiao_status_choices_list}) - - -def newmedia_management_update_qita(request, pk): - QITA_STATUS_CHOICES = Qita.QITA_STATUS_CHOICES - qita_status_choices_list = [] - for w in QITA_STATUS_CHOICES: - qita_status_choices_list.append(list(w)[1]) - organization = Organization.objects.all() - qita = Qita.objects.get(id=pk) - if request.method == 'POST': - type = request.POST.get('type') - name = request.POST.get('name') - qitaid = request.POST.get('qitaid') - alias = request.POST.get('alias') - image = request.FILES.get('image') - organization = request.POST.get('organization') - status = request.POST.get('status') - if name is not None: - if organization is not None: - if image is not None: - Qita.objects.filter(id=pk).update(type=type, name=name, qitaid=qitaid, alias=alias, - organization_id=organization, status=status) - qita.image = image - qita.save() - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/qita/') - else: - Qita.objects.filter(id=pk).update(type=type, name=name, qitaid=qitaid, alias=alias, - organization_id=organization, status=status) - messages.success(request, '修改成功') - return HttpResponseRedirect('/management/newmedia/management/edit/qita/') - else: - messages.success(request, "请选择单位") - return render(request, 'management/newmedia-management-update-qita.html', - {'qita': qita, 'organization': organization, - 'qita_status_choices_list': qita_status_choices_list}) - else: - messages.success(request, "新媒体名称不能为空") - return render(request, 'management/newmedia-management-update-qita.html', - {'qita': qita, 'organization': organization, - 'qita_status_choices_list': qita_status_choices_list}) - return render(request, 'management/newmedia-management-update-qita.html', - {'qita': qita, 'organization': organization, - 'qita_status_choices_list': qita_status_choices_list}) - -def newmedia_management_delete_weixin(request,pk): - weixin = Weixin.objects.get(id=pk) - weixin.delete() - messages.success(request,"删除成功") - return HttpResponseRedirect('/management/newmedia/management/edit/weixin/') - -def newmedia_management_delete_weibo(request,pk): - weibo = Weibo.objects.get(id=pk) - weibo.delete() - messages.success(request,"删除成功") - return HttpResponseRedirect('/management/newmedia/management/edit/weibo/') - -def newmedia_management_delete_toutiao(request,pk): - toutiao = Toutiao.objects.get(id=pk) - toutiao.delete() - messages.success(request,"删除成功") - return HttpResponseRedirect('/management/newmedia/management/edit/toutiao/') - -def newmedia_management_delete_qita(request,pk): - qita = Qita.objects.get(id=pk) - qita.delete() - messages.success(request,"删除成功") - return HttpResponseRedirect('/management/newmedia/management/edit/qita/') +import json + +from django.contrib import messages +from django.contrib.auth.hashers import make_password +from django.contrib.auth.models import User +from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage +from django.http import HttpResponse, HttpResponseRedirect +from django.shortcuts import render + +from dashboard.models import Userprofile, Group, Organization, Level, Organizationtype, Area_code_2020, Weixin, Weibo, \ + Toutiao, Qita, Group_type, Group_admin, Group_user + + +def user_management(request): + userpaginator = User.objects.all().order_by('-date_joined') + paginator = Paginator(userpaginator, 6) + page = int(request.GET.get('page', 1)) + try: + userpaginator = paginator.page(page) + except PageNotAnInteger: + userpaginator = paginator.page(1) + except EmptyPage: + userpaginator = paginator.page(paginator.num_pages) + userallinfo = [] + for u in userpaginator: + o = dict() + o['id'] = str(u.id) + o['image'] = u.userprofile_set.get(user_id=u.id).image + o['name'] = u.userprofile_set.get(user_id=u.id).name + o['phone'] = u.username + o['organization'] = u.userprofile_set.get(user_id=u.id).organization.name + o['type'] = u.userprofile_set.get(user_id=u.id).organization.organizationtype.organizationtype + organization_id = Userprofile.objects.get(user_id=u.id).organization_id + print(organization_id) + o['administrativedivision'] = str(str(Organization.objects.get(id=organization_id).province) + '-' + str( + Organization.objects.get(id=organization_id).cities) + '-' + str( + Organization.objects.get(id=organization_id).district) + '-' + str( + Organization.objects.get(id=organization_id).town) + '-' + str( + Organization.objects.get(id=organization_id).village)).replace('None', '') + userallinfo.append(o) + print(userallinfo) + return render(request, 'management/user-management.html', + {'userallinfo': userallinfo, 'userpaginator': userpaginator}) + + +def user_delete(request, pk): + user = User.objects.get(id=pk) + user.delete() + return HttpResponseRedirect('/management/user/management/') + + +def user_update(request, pk): + user = User.objects.get(id=pk) + userprofile = Userprofile.objects.get(user_id=user.id) + organization = Organization.objects.all() + if request.method == 'POST': + organization_id = request.POST.get('organization') + name = request.POST.get('name') + email = request.POST.get('email') + username = request.POST.get('username') + image = request.FILES.get('image') + passwordold = request.POST.get('passwordold') + passwordnew = request.POST.get('passwordnew') + confirm_password = request.POST.get('confirm_password') + if passwordold is not None and passwordnew is not None and confirm_password is not None: + if passwordnew == confirm_password: + user.email = email + user.username = username + user.password = make_password(passwordnew) + userprofile.organization_id = organization_id + userprofile.name = name + if image is not None: + userprofile.image = image + user.save() + userprofile.save() + messages.success(request,"修改成功") + return HttpResponseRedirect("/") + else: + messages.error(request,'两次输入密码不一致') + return HttpResponseRedirect('/management/user/update/%s/' % (pk)) + else: + user.email = email + user.username = username + userprofile.organization_id = organization_id + userprofile.name = name + if image is not None: + userprofile.image = image + user.save() + userprofile.save() + messages.success(request, "修改成功") + return HttpResponseRedirect("/") + + return render(request, 'management/user-management-update.html', + {'usee': user, 'userprofile': userprofile, 'organization': organization}) + + +def group_management(request): + group = Group.objects.all().order_by('-created') + paginator = Paginator(group, 6) + page = int(request.GET.get('page', 1)) + try: + group = paginator.page(page) + except PageNotAnInteger: + group = paginator.page(1) + except EmptyPage: + group = paginator.page(paginator.num_pages) + res = [] + for g in group: + o = dict() + o['id'] = str(g.id) + o['image'] = g.image.url + o['name'] = g.name + o['type'] = g.type + o['admin_count'] = Group_admin.objects.filter(group_id=g.id).count() + o['user_count'] = Group_user.objects.filter(group_id=g.id).count() + o['status'] = g.status + res.append(o) + return render(request, 'management/group-management.html', {'res': res, 'group': group}) + + +def group_update(request, pk): + group = Group.objects.get(id=pk) + GROUP_STATUS_CHOICES = Group.GROUP_STATUS_CHOICES + group_status_choices_list = [] + for g in GROUP_STATUS_CHOICES: + group_status_choices_list.append(list(g)[1]) + group_type = Group_type.objects.all() + group_admin = Group_admin.objects.filter(group_id=pk) + print(pk) + g_a_list = [] + for g_a in group_admin: + o = dict() + o['id'] = str(g_a.id) + o['image'] = Userprofile.objects.get(user_id=g_a.user.id).image.url + o['username'] = g_a.user.username + o['name'] = Userprofile.objects.get(user_id=g_a.user.id).name + o['organization'] = Userprofile.objects.get(user_id=g_a.user.id).organization.name + o['administrativedivision'] = str(g_a.group.province) + '-' + str(g_a.group.cities) + '-' + str( + g_a.group.district) + '-' + str(g_a.group.town) + '-' + str(g_a.group.village) + g_a_list.append(o) + group_user = Group_user.objects.filter(group_id=pk) + g_u_list = [] + for g_u in group_user: + i = dict() + i['id'] = str(g_u.id) + i['image'] = Userprofile.objects.get(user_id=g_u.user.id).image.url + i['username'] = g_u.user.username + i['name'] = Userprofile.objects.get(user_id=g_u.user.id).name + i['organization'] = Userprofile.objects.get(user_id=g_u.user.id).organization.name + i['administrativedivision'] = str(g_u.group.province) + '-' + str(g_u.group.cities) + '-' + str( + g_u.group.district) + '-' + str(g_u.group.town) + '-' + str(g_u.group.village) + g_u_list.append(i) + if request.method == 'POST': + name = request.POST.get('name') + presentation = request.POST.get('presentation') + image = request.FILES.get('image') + type = request.POST.get('type') + status = request.POST.get('status') + province = request.POST.get('province') + print(str(province) + "66666666666666666666666666") + if province != '' and province.isdigit(): + province_r = Area_code_2020.objects.get(code=province).name + else: + province_r = province + city = request.POST.get('city') + if city != '' and city.isdigit(): + city_r = Area_code_2020.objects.get(code=city).name + else: + city_r = city + district = request.POST.get('district') + if district != '' and district.isdigit(): + district_r = Area_code_2020.objects.get(code=district).name + else: + district_r = district + town = request.POST.get('town') + if town != '' and town.isdigit(): + town_r = Area_code_2020.objects.get(code=town).name + else: + town_r = town + village = request.POST.get('village') + if village != '' and village.isdigit(): + village_r = Area_code_2020.objects.get(code=village).name + else: + village_r = village + if image is not None: + Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status, + province=province_r, cities=city_r, district=district_r, town=town_r, + village=village_r) + g = Group.objects.get(id=pk) + g.image = image + g.save() + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/group/management/') + else: + Group.objects.filter(id=pk).update(name=name, presentation=presentation, type_id=type, status=status, + province=province_r, cities=city_r, district=district_r, town=town_r, + village=village_r) + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/group/management/') + return render(request, 'management/group-management-update.html', + {'group': group, 'group_status_choices_list': group_status_choices_list, 'group_type': group_type, + 'g_a_list': g_a_list, 'g_u_list': g_u_list}) + + +def group_create(request): + GROUP_STATUS_CHOICES = Group.GROUP_STATUS_CHOICES + group_status_choices_list = [] + for g in GROUP_STATUS_CHOICES: + group_status_choices_list.append(list(g)[1]) + group_type = Group_type.objects.all() + if request.method == 'POST': + name = request.POST.get('name') + presentation = request.POST.get('presentation') + image = request.FILES.get('image') + type = request.POST.get('type') + status = request.POST.get('status') + province = request.POST.get('province') + if province != '': + province_r = Area_code_2020.objects.get(code=province).name + else: + messages.error(request, '请选择行政区划') + return HttpResponseRedirect('/management/organization/create/') + city = request.POST.get('city') + if city != '': + city_r = Area_code_2020.objects.get(code=city).name + else: + city_r = city + district = request.POST.get('district') + if district != '': + district_r = Area_code_2020.objects.get(code=district).name + else: + district_r = district + town = request.POST.get('town') + if town != '': + town_r = Area_code_2020.objects.get(code=town).name + else: + town_r = town + village = request.POST.get('village') + if village != '': + village_r = Area_code_2020.objects.get(code=village).name + else: + village_r = village + print(name, presentation, image, type, status, province, city, district, town, village) + if name is not None: + group = Group(name=name, presentation=presentation, image=image, type_id=type, status=status, + province=province_r, cities=city_r, district=district_r, town=town_r, village=village_r) + group.save() + messages.success(request, '添加成功') + else: + messages.error(request, '群组名不能为空') + return HttpResponseRedirect('/management/group/management/') + return render(request, 'management/group-management-create.html', + {'group_status_choices_list': group_status_choices_list, 'group_type': group_type}) + + +def group_admin_create(request, pk): + if request.method == 'POST': + user = request.POST.get("user") + print(user) + results = Group_admin.objects.filter(user_id=user, group_id=pk).count() + if results != 0: + messages.success(request, "该管理员已经存在") + return HttpResponseRedirect('/management/group/update/%s/' % (pk)) + group_admin = Group_admin(user_id=user, group_id=pk) + group_admin.save() + messages.success(request, "添加成功") + return HttpResponseRedirect('/management/group/update/%s/' % (pk)) + group = Group.objects.get(id=pk).name + user = User.objects.all() + return render(request, 'management/group-admin-create.html', {'usee': user, 'group': group, 'pk': pk}) + + +def group_admin_delete(request, pk, group_pk): + group_admin = Group_admin.objects.get(id=pk) + group_admin.delete() + messages.success(request, '删除成功') + return HttpResponseRedirect('/management/group/update/%s/' % (group_pk)) + + +def group_user_create(request, pk): + if request.method == 'POST': + user = request.POST.get('user') + results = Group_user.objects.filter(user_id=user, group_id=pk).count() + if results != 0: + messages.success(request, "该成员已经存在") + return HttpResponseRedirect('/management/group/update/%s/' % (pk)) + group_user = Group_user(user_id=user, group_id=pk) + group_user.save() + messages.success(request, '添加成功') + return HttpResponseRedirect('/management/group/update/%s' % (pk)) + group = Group.objects.get(id=pk).name + user = User.objects.all() + return render(request, 'management/group-user-create.html', {'usee': user, 'group': group, 'pk': pk}) + + +def group_user_delete(request, pk, group_pk): + group_user = Group_user.objects.get(id=pk) + group_user.delete() + messages.success(request, '删除成功') + return HttpResponseRedirect('/management/group/update/%s/' % (group_pk)) + + +def group_delete(request, pk): + group = Group.objects.get(id=pk) + group.delete() + messages.success(request, '删除成功') + return HttpResponseRedirect('/management/group/management/') + + +def organization_management(request): + organization = Organization.objects.all().order_by('-created') + paginator = Paginator(organization, 6) + page = int(request.GET.get('page', 1)) + try: + organization = paginator.page(page) + except PageNotAnInteger: + organization = paginator.page(1) + except EmptyPage: + organization = paginator.page(paginator.num_pages) + res = [] + for i in organization: + o = dict() + o['id'] = str(i.id) + o['name'] = i.name + o['image'] = i.image.url + o['organizationtype'] = i.organizationtype.organizationtype + o['administrativedivision'] = str(i.province) + '-' + str(i.cities) + '-' + str(i.district) + '-' + str( + i.town) + '-' + str(i.village) + o['usercount'] = Userprofile.objects.filter(organization_id=i.id).count() + o['mediacount'] = Weixin.objects.filter(organization_id=i.id).count() + Weibo.objects.filter( + organization_id=i.id).count() + Toutiao.objects.filter(organization_id=i.id).count() + Qita.objects.filter( + organization_id=i.id).count() + res.append(o) + + return render(request, 'management/organization-management.html', {"organization": organization, 'res': res}) + + +def organization_delete(request, pk): + organization = Organization.objects.get(id=pk) + organization.delete() + messages.success(request, '删除成功') + return HttpResponseRedirect('/management/organization/management/') + + +def organization_update(request, pk): + organization = Organization.objects.get(id=pk) + organizationtype = Organizationtype.objects.all() + if request.method == 'POST': + name = request.POST.get('name') + image = request.FILES.get('image') + organizationtype = request.POST.get('organizationtype') + province = request.POST.get('province') + if province != '' and province.isdigit(): + province_r = Area_code_2020.objects.get(code=province).name + else: + province_r = province + city = request.POST.get('city') + if city != '' and city.isdigit(): + city_r = Area_code_2020.objects.get(code=city).name + else: + city_r = city + district = request.POST.get('district') + if district != '' and district.isdigit(): + district_r = Area_code_2020.objects.get(code=district).name + else: + district_r = district + town = request.POST.get('town') + if town != '' and town.isdigit(): + town_r = Area_code_2020.objects.get(code=town).name + else: + town_r = town + village = request.POST.get('village') + if village != '' and village.isdigit(): + village_r = Area_code_2020.objects.get(code=village).name + else: + village_r = village + if name is not None: + if image is not None: + Organization.objects.filter(id=pk).update(name=name, organizationtype_id=organizationtype, + province=province_r, cities=city_r, district=district_r, + town=town_r, village=village_r) + o = Organization.objects.get(id=pk) + o.image = image + o.save() + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/organization/management/') + else: + Organization.objects.filter(id=pk).update(name=name, organizationtype_id=organizationtype, + province=province_r, cities=city_r, district=district_r, + town=town_r, village=village_r) + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/organization/management/') + return render(request, 'management/organization-management-update.html', + {'organization': organization, 'organizationtype': organizationtype}) + + +def organization_create(request): + organizationtype = Organizationtype.objects.all() + if request.method == 'POST': + name = request.POST.get('name') + image = request.FILES.get('image') + organizationtype = request.POST.get('organizationtype') + province = request.POST.get('province') + if province != '': + province_r = Area_code_2020.objects.get(code=province).name + else: + messages.error(request, '请选择行政区划') + return HttpResponseRedirect('/management/organization/create/') + city = request.POST.get('city') + if city != '': + city_r = Area_code_2020.objects.get(code=city).name + else: + city_r = city + district = request.POST.get('district') + if district != '': + district_r = Area_code_2020.objects.get(code=district).name + else: + district_r = district + town = request.POST.get('town') + if town != '': + town_r = Area_code_2020.objects.get(code=town).name + else: + town_r = town + village = request.POST.get('village') + if village != '': + village_r = Area_code_2020.objects.get(code=village).name + else: + village_r = village + print(province, city) + if name is not None: + organization = Organization(name=name, image=image, organizationtype_id=organizationtype, + province=province_r, cities=city_r, district=district_r, town=town_r, + village=village_r) + organization.save() + messages.success(request, '添加成功') + else: + messages.error(request, '单位名不能为空') + return HttpResponseRedirect('/management/organization/management/') + return render(request, 'management/organization-management-create.html', {'organizationtype': organizationtype}) + + +def newmedia_management_create_menu(request): + return render(request, 'management/newmedia-management-create-menu.html') + + +def newmedia_management_create_weixin(request): + WEIXIN_STATUS_CHOICES = Weixin.WEIXIN_STATUS_CHOICES + weixin_status_choices_list = [] + for w in WEIXIN_STATUS_CHOICES: + weixin_status_choices_list.append(list(w)[1]) + organization = Organization.objects.all() + if request.method == 'POST': + code = request.POST.get('code') + weixinid = request.POST.get('weixinid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if code is not None: + if organization is not None: + if image is not None: + weixin = Weixin(code=code, weixinid=weixinid, alias=alias, image=image, + organization_id=organization, status=status) + weixin.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/weixin/') + else: + weixin = Weixin(code=code, weixinid=weixinid, alias=alias, image='weixin.png', + organization_id=organization, status=status) + weixin.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/weixin/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-create-weixin.html', + {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) + else: + messages.success(request, "微信公众号不能为空") + return render(request, 'management/newmedia-management-create-weixin.html', + {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) + return render(request, 'management/newmedia-management-create-weixin.html', + {'weixin_status_choices_list': weixin_status_choices_list, "organization": organization}) + + +def newmedia_management_create_weibo(request): + WEIBO_STATUS_CHOICES = Weibo.WEIBO_STATUS_CHOICES + weibo_status_choices_list = [] + for w in WEIBO_STATUS_CHOICES: + weibo_status_choices_list.append(list(w)[1]) + organization = Organization.objects.all() + if request.method == 'POST': + code = request.POST.get('code') + weiboid = request.POST.get('weiboid') + print(str(weiboid) + "11111111111111111111111111111111111111") + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if code is not None: + if organization is not None: + if image is not None: + weibo = Weibo(code=code, weiboid=weiboid, alias=alias, image=image, + organization_id=organization, status=status) + weibo.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/weibo/') + else: + weibo = Weibo(code=code, weiboid=weiboid, alias=alias, image='weibo.png', + organization_id=organization, status=status) + weibo.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/weibo/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-create-weibo.html', + {'weibo_status_choices_list': weibo_status_choices_list, "organization": organization}) + else: + messages.success(request, "微博号不能为空") + return render(request, 'management/newmedia-management-create-weibo.html', + {'weixin_status_choices_list': weibo_status_choices_list, "organization": organization}) + return render(request, 'management/newmedia-management-create-weibo.html', + {'weibo_status_choices_list': weibo_status_choices_list, "organization": organization}) + + +def newmedia_management_create_toutiao(request): + TOUTIAO_STATUS_CHOICES = Toutiao.TOUTIAO_STATUS_CHOICES + toutiao_status_choices_list = [] + for w in TOUTIAO_STATUS_CHOICES: + toutiao_status_choices_list.append(list(w)[1]) + organization = Organization.objects.all() + if request.method == 'POST': + code = request.POST.get('code') + toutiaoid = request.POST.get('toutiaoid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if code is not None: + if organization is not None: + if image is not None: + toutiao = Toutiao(code=code, toutiaoid=toutiaoid, alias=alias, image=image, + organization_id=organization, status=status) + toutiao.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/toutiao/') + else: + toutiao = Toutiao(code=code, toutiaoid=toutiaoid, alias=alias, image='toutiao.png', + organization_id=organization, status=status) + toutiao.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/toutiao/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-create-toutiao.html', + {'toutiao_status_choices_list': toutiao_status_choices_list, + "organization": organization}) + else: + messages.success(request, "头条号不能为空") + return render(request, 'management/newmedia-management-create-toutiao.html', + {'toutiao_status_choices_list': toutiao_status_choices_list, "organization": organization}) + return render(request, 'management/newmedia-management-create-toutiao.html', + {'toutiao_status_choices_list': toutiao_status_choices_list, "organization": organization}) + + +def newmedia_management_create_qita(request): + QITA_STATUS_CHOICES = Qita.QITA_STATUS_CHOICES + qita_status_choices_list = [] + for w in QITA_STATUS_CHOICES: + qita_status_choices_list.append(list(w)[1]) + organization = Organization.objects.all() + if request.method == 'POST': + type = request.POST.get('type') + name = request.POST.get('name') + qitaid = request.POST.get('qitaid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if name is not None: + if organization is not None: + if image is not None: + qita = Qita(type=type, name=name, qitaid=qitaid, alias=alias, image=image, + organization_id=organization, status=status) + qita.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/qita/') + else: + qita = Qita(type=type, name=name, qitaid=qitaid, alias=alias, image='qita.png', + organization_id=organization, status=status) + qita.save() + messages.success(request, '创建成功') + return HttpResponseRedirect('/management/newmedia/management/create/qita/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-create-qita.html', + {'qita_status_choices_list': qita_status_choices_list, "organization": organization}) + else: + messages.success(request, "新媒体名称不能为空") + return render(request, 'management/newmedia-management-create-qita.html', + {'qita_status_choices_list': qita_status_choices_list, "organization": organization}) + return render(request, 'management/newmedia-management-create-qita.html', + {'qita_status_choices_list': qita_status_choices_list, "organization": organization}) + + +def newmedia_management_edit_menu(request): + return render(request, 'management/newmedia-management-edit-menu.html') + + +def newmedia_management_edit_weixin(request): + weixin = Weixin.objects.all().order_by('-created') + paginator = Paginator(weixin, 6) + page = int(request.GET.get('page', 1)) + try: + weixin = paginator.page(page) + except PageNotAnInteger: + weixin = paginator.page(1) + except EmptyPage: + weixin = paginator.page(paginator.num_pages) + res = [] + for w in weixin: + o = dict() + o['id'] = str(w.id) + o['image'] = w.image + o['code'] = w.code + o['weixinid'] = w.weixinid + o['organization'] = w.organization.name + o['organization_type'] = w.organization.organizationtype.organizationtype + o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( + w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) + o['status'] = w.status + res.append(o) + return render(request, 'management/newmedia-management-edit-weixin.html', {'weixin': weixin, 'res': res}) + + +def newmedia_management_edit_weibo(request): + weibo = Weibo.objects.all().order_by('-created') + paginator = Paginator(weibo, 6) + page = int(request.GET.get('page', 1)) + try: + weibo = paginator.page(page) + except PageNotAnInteger: + weibo = paginator.page(1) + except EmptyPage: + weibo = paginator.page(paginator.num_pages) + res = [] + for w in weibo: + o = dict() + o['id'] = str(w.id) + o['image'] = w.image + o['code'] = w.code + o['weiboid'] = w.weiboid + o['organization'] = w.organization.name + o['organization_type'] = w.organization.organizationtype.organizationtype + o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( + w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) + o['status'] = w.status + res.append(o) + return render(request, 'management/newmedia-management-edit-weibo.html', {'weibo': weibo, 'res': res}) + + +def newmedia_management_edit_toutiao(request): + toutiao = Toutiao.objects.all().order_by('-created') + paginator = Paginator(toutiao, 6) + page = int(request.GET.get('page', 1)) + try: + toutiao = paginator.page(page) + except PageNotAnInteger: + toutiao = paginator.page(1) + except EmptyPage: + toutiao = paginator.page(paginator.num_pages) + res = [] + for w in toutiao: + o = dict() + o['id'] = str(w.id) + o['image'] = w.image + o['code'] = w.code + o['toutiaoid'] = w.toutiaoid + o['organization'] = w.organization.name + o['organization_type'] = w.organization.organizationtype.organizationtype + o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( + w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) + o['status'] = w.status + res.append(o) + return render(request, 'management/newmedia-management-edit-toutiao.html', {'toutiao': toutiao, 'res': res}) + + +def newmedia_management_edit_qita(request): + qita = Qita.objects.all().order_by('-created') + paginator = Paginator(qita, 6) + page = int(request.GET.get('page', 1)) + try: + qita = paginator.page(page) + except PageNotAnInteger: + qita = paginator.page(1) + except EmptyPage: + qita = paginator.page(paginator.num_pages) + res = [] + for w in qita: + o = dict() + o['id'] = str(w.id) + o['image'] = w.image + o['type'] = w.type + o['name'] = w.name + o['qitaid'] = w.qitaid + o['organization'] = w.organization.name + o['organization_type'] = w.organization.organizationtype.organizationtype + o['administrativedivision'] = str(w.organization.province) + '-' + str(w.organization.cities) + '-' + str( + w.organization.district) + '-' + str(w.organization.town) + '-' + str(w.organization.village) + o['status'] = w.status + res.append(o) + return render(request, 'management/newmedia-management-edit-qita.html', {'qita': qita, 'res': res}) + + +def newmedia_management_update_weixin(request, pk): + WEIXIN_STATUS_CHOICES = Weixin.WEIXIN_STATUS_CHOICES + weixin_status_choices_list = [] + for w in WEIXIN_STATUS_CHOICES: + weixin_status_choices_list.append(list(w)[1]) + weixin = Weixin.objects.get(id=pk) + organization = Organization.objects.all() + if request.method == 'POST': + code = request.POST.get('code') + weixinid = request.POST.get('weixinid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if code is not None: + if organization is not None: + if image is not None: + Weixin.objects.filter(id=pk).update(code=code, weixinid=weixinid, alias=alias, + organization_id=organization, status=status) + weixin.image = image + weixin.save() + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/weixin/') + else: + Weixin.objects.filter(id=pk).update(code=code, weixinid=weixinid, alias=alias, + organization_id=organization, status=status) + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/weixin/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-update-weixin.html', + {'weixin': weixin, 'organization': organization, + 'weixin_status_choices_list': weixin_status_choices_list}) + else: + messages.success(request, "微信公众号不能为空") + return render(request, 'management/newmedia-management-update-weixin.html', + {'weixin': weixin, 'organization': organization, + 'weixin_status_choices_list': weixin_status_choices_list}) + return render(request, 'management/newmedia-management-update-weixin.html', + {'weixin': weixin, 'organization': organization, + 'weixin_status_choices_list': weixin_status_choices_list}) + + +def newmedia_management_update_weibo(request, pk): + WEIBO_STATUS_CHOICES = Weibo.WEIBO_STATUS_CHOICES + weibo_status_choices_list = [] + for w in WEIBO_STATUS_CHOICES: + weibo_status_choices_list.append(list(w)[1]) + weibo = Weibo.objects.get(id=pk) + organization = Organization.objects.all() + if request.method == 'POST': + code = request.POST.get('code') + weiboid = request.POST.get('weiboid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if code is not None: + if organization is not None: + if image is not None: + Weibo.objects.filter(id=pk).update(code=code, weiboid=weiboid, alias=alias, + organization_id=organization, status=status) + weibo.image = image + weibo.save() + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/weibo/') + else: + Weibo.objects.filter(id=pk).update(code=code, weiboid=weiboid, alias=alias, + organization_id=organization, status=status) + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/weibo/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-update-weibo.html', + {'weibo': weibo, 'organization': organization, + 'weibo_status_choices_list': weibo_status_choices_list}) + else: + messages.success(request, "微博号不能为空") + return render(request, 'management/newmedia-management-update-weibo.html', + {'weibo': weibo, 'organization': organization, + 'weibo_status_choices_list': weibo_status_choices_list}) + return render(request, 'management/newmedia-management-update-weibo.html', + {'weibo': weibo, 'organization': organization, + 'weibo_status_choices_list': weibo_status_choices_list}) + + +def newmedia_management_update_toutiao(request, pk): + TOUTIAO_STATUS_CHOICES = Toutiao.TOUTIAO_STATUS_CHOICES + toutiao_status_choices_list = [] + for w in TOUTIAO_STATUS_CHOICES: + toutiao_status_choices_list.append(list(w)[1]) + toutiao = Toutiao.objects.get(id=pk) + organization = Organization.objects.all() + if request.method == 'POST': + code = request.POST.get('code') + toutiaoid = request.POST.get('toutiaoid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if code is not None: + if organization is not None: + if image is not None: + Toutiao.objects.filter(id=pk).update(code=code, toutiaoid=toutiaoid, alias=alias, + organization_id=organization, status=status) + toutiao.image = image + toutiao.save() + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/toutiao/') + else: + Toutiao.objects.filter(id=pk).update(code=code, toutiaoid=toutiaoid, alias=alias, + organization_id=organization, status=status) + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/toutiao/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-update-toutiao.html', + {'toutiao': toutiao, 'organization': organization, + 'toutiao_status_choices_list': toutiao_status_choices_list}) + else: + messages.success(request, "头条号不能为空") + return render(request, 'management/newmedia-management-update-toutiao.html', + {'toutiao': toutiao, 'organization': organization, + 'toutiao_status_choices_list': toutiao_status_choices_list}) + return render(request, 'management/newmedia-management-update-toutiao.html', + {'toutiao': toutiao, 'organization': organization, + 'toutiao_status_choices_list': toutiao_status_choices_list}) + + +def newmedia_management_update_qita(request, pk): + QITA_STATUS_CHOICES = Qita.QITA_STATUS_CHOICES + qita_status_choices_list = [] + for w in QITA_STATUS_CHOICES: + qita_status_choices_list.append(list(w)[1]) + organization = Organization.objects.all() + qita = Qita.objects.get(id=pk) + if request.method == 'POST': + type = request.POST.get('type') + name = request.POST.get('name') + qitaid = request.POST.get('qitaid') + alias = request.POST.get('alias') + image = request.FILES.get('image') + organization = request.POST.get('organization') + status = request.POST.get('status') + if name is not None: + if organization is not None: + if image is not None: + Qita.objects.filter(id=pk).update(type=type, name=name, qitaid=qitaid, alias=alias, + organization_id=organization, status=status) + qita.image = image + qita.save() + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/qita/') + else: + Qita.objects.filter(id=pk).update(type=type, name=name, qitaid=qitaid, alias=alias, + organization_id=organization, status=status) + messages.success(request, '修改成功') + return HttpResponseRedirect('/management/newmedia/management/edit/qita/') + else: + messages.success(request, "请选择单位") + return render(request, 'management/newmedia-management-update-qita.html', + {'qita': qita, 'organization': organization, + 'qita_status_choices_list': qita_status_choices_list}) + else: + messages.success(request, "新媒体名称不能为空") + return render(request, 'management/newmedia-management-update-qita.html', + {'qita': qita, 'organization': organization, + 'qita_status_choices_list': qita_status_choices_list}) + return render(request, 'management/newmedia-management-update-qita.html', + {'qita': qita, 'organization': organization, + 'qita_status_choices_list': qita_status_choices_list}) + + +def newmedia_management_delete_weixin(request, pk): + weixin = Weixin.objects.get(id=pk) + weixin.delete() + messages.success(request, "删除成功") + return HttpResponseRedirect('/management/newmedia/management/edit/weixin/') + + +def newmedia_management_delete_weibo(request, pk): + weibo = Weibo.objects.get(id=pk) + weibo.delete() + messages.success(request, "删除成功") + return HttpResponseRedirect('/management/newmedia/management/edit/weibo/') + + +def newmedia_management_delete_toutiao(request, pk): + toutiao = Toutiao.objects.get(id=pk) + toutiao.delete() + messages.success(request, "删除成功") + return HttpResponseRedirect('/management/newmedia/management/edit/toutiao/') + + +def newmedia_management_delete_qita(request, pk): + qita = Qita.objects.get(id=pk) + qita.delete() + messages.success(request, "删除成功") + return HttpResponseRedirect('/management/newmedia/management/edit/qita/') diff --git a/static/upload/cover/20181201110659913.PNG b/media/upload/cover/20181201110659913.PNG similarity index 100% rename from static/upload/cover/20181201110659913.PNG rename to media/upload/cover/20181201110659913.PNG diff --git a/static/upload/cover/20181201110659913_85e25PV.PNG b/media/upload/cover/20181201110659913_85e25PV.PNG similarity index 100% rename from static/upload/cover/20181201110659913_85e25PV.PNG rename to media/upload/cover/20181201110659913_85e25PV.PNG diff --git a/static/upload/cover/20181201110659913_ie84dq3.PNG b/media/upload/cover/20181201110659913_ie84dq3.PNG similarity index 100% rename from static/upload/cover/20181201110659913_ie84dq3.PNG rename to media/upload/cover/20181201110659913_ie84dq3.PNG diff --git a/static/upload/cover/weibo.png b/media/upload/cover/weibo.png similarity index 100% rename from static/upload/cover/weibo.png rename to media/upload/cover/weibo.png diff --git a/static/upload/cover/weixin.png b/media/upload/cover/weixin.png similarity index 100% rename from static/upload/cover/weixin.png rename to media/upload/cover/weixin.png diff --git a/static/upload/cover/weixin_T3Y4A36.png b/media/upload/cover/weixin_T3Y4A36.png similarity index 100% rename from static/upload/cover/weixin_T3Y4A36.png rename to media/upload/cover/weixin_T3Y4A36.png diff --git a/static/upload/cover/weixin_TC0D6fQ.png b/media/upload/cover/weixin_TC0D6fQ.png similarity index 100% rename from static/upload/cover/weixin_TC0D6fQ.png rename to media/upload/cover/weixin_TC0D6fQ.png diff --git a/static/upload/cover/微信图片_20200724112643.jpg b/media/upload/cover/微信图片_20200724112643.jpg similarity index 100% rename from static/upload/cover/微信图片_20200724112643.jpg rename to media/upload/cover/微信图片_20200724112643.jpg diff --git a/static/upload/cover/微信图片_20200724112643_deab8x0.jpg b/media/upload/cover/微信图片_20200724112643_deab8x0.jpg similarity index 100% rename from static/upload/cover/微信图片_20200724112643_deab8x0.jpg rename to media/upload/cover/微信图片_20200724112643_deab8x0.jpg diff --git a/static/upload/groupimage/20181201110659913.PNG b/media/upload/groupimage/20181201110659913.PNG similarity index 100% rename from static/upload/groupimage/20181201110659913.PNG rename to media/upload/groupimage/20181201110659913.PNG diff --git a/static/upload/groupimage/微信图片_20200724112643.jpg b/media/upload/groupimage/微信图片_20200724112643.jpg similarity index 100% rename from static/upload/groupimage/微信图片_20200724112643.jpg rename to media/upload/groupimage/微信图片_20200724112643.jpg diff --git a/static/upload/profile/20181201110659913.PNG b/media/upload/profile/20181201110659913.PNG similarity index 100% rename from static/upload/profile/20181201110659913.PNG rename to media/upload/profile/20181201110659913.PNG diff --git a/static/upload/profile/微信图片_20200724112643.jpg b/media/upload/profile/微信图片_20200724112643.jpg similarity index 100% rename from static/upload/profile/微信图片_20200724112643.jpg rename to media/upload/profile/微信图片_20200724112643.jpg diff --git a/media/upload/profile/微信图片_20200724112643_4e2NSOO.jpg b/media/upload/profile/微信图片_20200724112643_4e2NSOO.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/media/upload/profile/微信图片_20200724112643_4e2NSOO.jpg differ diff --git a/media/upload/profile/微信图片_20200724112643_6VlW7BD.jpg b/media/upload/profile/微信图片_20200724112643_6VlW7BD.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/media/upload/profile/微信图片_20200724112643_6VlW7BD.jpg differ diff --git a/media/upload/profile/微信图片_20200724112643_CkX05Bp.jpg b/media/upload/profile/微信图片_20200724112643_CkX05Bp.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/media/upload/profile/微信图片_20200724112643_CkX05Bp.jpg differ diff --git a/media/upload/profile/微信图片_20200724112643_Umb7HT3.jpg b/media/upload/profile/微信图片_20200724112643_Umb7HT3.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/media/upload/profile/微信图片_20200724112643_Umb7HT3.jpg differ diff --git a/media/upload/profile/微信图片_20200724112643_pakJc7t.jpg b/media/upload/profile/微信图片_20200724112643_pakJc7t.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/media/upload/profile/微信图片_20200724112643_pakJc7t.jpg differ diff --git a/static/upload/qita.png b/media/upload/qita.png similarity index 100% rename from static/upload/qita.png rename to media/upload/qita.png diff --git a/static/upload/toutiao.png b/media/upload/toutiao.png similarity index 100% rename from static/upload/toutiao.png rename to media/upload/toutiao.png diff --git a/static/upload/weibo.png b/media/upload/weibo.png similarity index 100% rename from static/upload/weibo.png rename to media/upload/weibo.png diff --git a/static/upload/weixin.png b/media/upload/weixin.png similarity index 100% rename from static/upload/weixin.png rename to media/upload/weixin.png diff --git a/passenger_wsgi.py b/passenger_wsgi.py new file mode 100644 index 0000000..8ca1177 --- /dev/null +++ b/passenger_wsgi.py @@ -0,0 +1,2 @@ +import NewMediaMonitoring.wsgi +application = NewMediaMonitoring.wsgi.application \ No newline at end of file diff --git a/polls/models.py b/polls/models.py index 18fdcd7..b220cc5 100644 --- a/polls/models.py +++ b/polls/models.py @@ -21,7 +21,7 @@ class VerifyCode(models.Model): def is_in_progress(self): now = datetime.datetime.now() - return snow <= self.timeouted + return now <= self.timeouted def __str__(self): diff --git a/polls/views.py b/polls/views.py index 83224be..fe38fe3 100644 --- a/polls/views.py +++ b/polls/views.py @@ -1,122 +1,125 @@ -from django.shortcuts import render -from django.http import HttpResponse, JsonResponse -from django.contrib.auth import get_user_model -from django.views.decorators.csrf import csrf_exempt -from django_token.models import Token - - -def index(request): - username = request.GET.get('username') - password = request.GET.get('password') - print(username, password) - return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) - - -def status_500(request): - return HttpResponse(status=500) - - -def status_401(request): - return HttpResponse(status=401) - - -@csrf_exempt -def polls_login(request): - if request.method == 'POST': - phone = request.POST.get('phone') - password = request.POST.get('password') - UserModel = get_user_model() - user = UserModel.objects.filter(first_name=phone).first() - if not user: - return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) - - u = authenticate(request, username=user.username, password=password) - if u is not None: - login(request, u) - token = Token.objects.get_or_create(user=u) - result = dict() - profile = u.userprofile_set.first() - result['phone'] = u.first_name - result['token'] = token - if profile: - result['name'] = profile.name - result['gender'] = profile.sex - result['thumbnail'] = profile.image.path - result['organization'] = profile.organization.name - return JsonResponse({'status': 'success', 'message': result}) - else: - return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) - else: - return HttpResponse(status=405) - - -@csrf_exempt -def send_code(request): - if request.method == 'GET': - return HttpResponse(status=405) - phone = request.POST.get('phone') - category = request.POST.get('category', 0) - if not phone: - return JsonResponse({'status': 'error', 'message': '手机号不正确'}) - - exist_code = VerifyCode.objects.filter(phone=phone, category=category).first() - if exist_code and exist_code.in_progress(): - return JsonResponse({'status': 'error', 'message': '验证码使用中'}) - - code = generate_code() - now = datetime.datetime.now() - after_10mins = now + datetime.timedelta(minutes=10) - response = send_sms_code(phone, code) - result = response.decode('utf8') - if "OK" in result: - VerifyCode.objects.create(code=code, phone=phone, category=category) - return JsonResponse({'status': 'success'}) - return JsonResponse({'status': 'error', 'message': '验证码发送失败'}) - - - -@csrf_exempt -def register_step_one(request): - if request.method == 'GET': - return HttpResponse(status=405) - phone = request.POST.get('phone') - code = request.POST.get('code') - exist_code = VerifyCode.objects.filter(phone=phone, code=code, category=0).exist() - if exist_code.in_progress(): - return JsonResponse({'status': 'success', 'message': {phone: phone}}) - else: - return JsonResponse({'status': 'error', 'message': '验证码超时,请重发'}) - - -@csrf_exempt -def register_step_two(request): - if request.method == 'GET': - return HttpResponse(status=405) - phone = request.POST.get('phone') - name = request.POST.get('name') - gender = request.POST.get('gender') - organization = request.POST.get('organization') - # create user - return JsonResponse({'status': 'success', 'message': '注册成功'}) - - -@csrf_exempt -def password_recover_step_one(request): - if request.method == 'GET': - return HttpResponse(status=405) - phone = request.POST.get('phone') - code = request.POST.get('code') - exist_code = VerifyCode.objects.filter(phone=phone, code=code, category=1).exist() - if exist_code.in_progress(): - return JsonResponse({'status': 'success', 'message': {phone: phone}}) - else: - return JsonResponse({'status': 'error', 'message': '验证码超时,请重发'}) - - -@csrf_exempt -def password_recover_step_two(request): - if request.method == 'GET': - return HttpResponse(status=405) - phone = request.POST.get('phone') - password = request.POST.get('password') - password_confirm = request.POST.get('password_confirm') \ No newline at end of file +from django.shortcuts import render +from django.http import HttpResponse, JsonResponse +from django.contrib.auth import get_user_model, authenticate, login +from django.views.decorators.csrf import csrf_exempt +from django_token.models import Token +import datetime + +from .models import VerifyCode +from .utils import generate_code, send_sms_code + +def index(request): + username = request.GET.get('username') + password = request.GET.get('password') + print(username, password) + return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) + + +def status_500(request): + return HttpResponse(status=500) + + +def status_401(request): + return HttpResponse(status=401) + + +@csrf_exempt +def polls_login(request): + if request.method == 'POST': + phone = request.POST.get('phone') + password = request.POST.get('password') + UserModel = get_user_model() + user = UserModel.objects.filter(first_name=phone).first() + if not user: + return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) + + u = authenticate(request, username=user.username, password=password) + if u is not None: + login(request, u) + token = Token.objects.get_or_create(user=u) + result = dict() + profile = u.userprofile_set.first() + result['phone'] = u.first_name + result['token'] = token + if profile: + result['name'] = profile.name + result['gender'] = profile.sex + result['thumbnail'] = profile.image.path + result['organization'] = profile.organization.name + return JsonResponse({'status': 'success', 'message': result}) + else: + return JsonResponse({'status': 'error', 'message': '用户名或密码错误'}) + else: + return HttpResponse(status=405) + + +@csrf_exempt +def send_code(request): + if request.method == 'GET': + return HttpResponse(status=405) + phone = request.POST.get('phone') + category = request.POST.get('category', 0) + if not phone: + return JsonResponse({'status': 'error', 'message': '手机号不正确'}) + + exist_code = VerifyCode.objects.filter(phone=phone, category=category).first() + if exist_code and exist_code.in_progress(): + return JsonResponse({'status': 'error', 'message': '验证码使用中'}) + + code = generate_code() + now = datetime.datetime.now() + after_10mins = now + datetime.timedelta(minutes=10) + response = send_sms_code(phone, code) + result = response.decode('utf8') + if "OK" in result: + VerifyCode.objects.create(code=code, phone=phone, category=category) + return JsonResponse({'status': 'success'}) + return JsonResponse({'status': 'error', 'message': '验证码发送失败'}) + + + +@csrf_exempt +def register_step_one(request): + if request.method == 'GET': + return HttpResponse(status=405) + phone = request.POST.get('phone') + code = request.POST.get('code') + exist_code = VerifyCode.objects.filter(phone=phone, code=code, category=0).exist() + if exist_code.in_progress(): + return JsonResponse({'status': 'success', 'message': {phone: phone}}) + else: + return JsonResponse({'status': 'error', 'message': '验证码超时,请重发'}) + + +@csrf_exempt +def register_step_two(request): + if request.method == 'GET': + return HttpResponse(status=405) + phone = request.POST.get('phone') + name = request.POST.get('name') + gender = request.POST.get('gender') + organization = request.POST.get('organization') + # create user + return JsonResponse({'status': 'success', 'message': '注册成功'}) + + +@csrf_exempt +def password_recover_step_one(request): + if request.method == 'GET': + return HttpResponse(status=405) + phone = request.POST.get('phone') + code = request.POST.get('code') + exist_code = VerifyCode.objects.filter(phone=phone, code=code, category=1).exist() + if exist_code.in_progress(): + return JsonResponse({'status': 'success', 'message': {phone: phone}}) + else: + return JsonResponse({'status': 'error', 'message': '验证码超时,请重发'}) + + +@csrf_exempt +def password_recover_step_two(request): + if request.method == 'GET': + return HttpResponse(status=405) + phone = request.POST.get('phone') + password = request.POST.get('password') + password_confirm = request.POST.get('password_confirm') diff --git a/requirements.txt b/requirements.txt index 9ecb5e1..89c3ac3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -Django~=2.2.15 -django-bootstrap3 -django-simple-captcha -psycopg2-binary -django-cors-headers -aliyun-python-sdk-core-v3 - +Django~=2.2.15 +django-bootstrap3 +django-simple-captcha +psycopg2-binary +django-cors-headers +aliyun-python-sdk-core-v3 + diff --git a/static/js/scripts.js b/static/js/scripts.js index f8b1a0f..0c51786 100644 --- a/static/js/scripts.js +++ b/static/js/scripts.js @@ -1,3638 +1,3638 @@ -/** - * @Package: Ultra Admin HTML Theme - * @Since: Ultra 1.0 - * This file is part of Ultra Admin Theme HTML package. - */ - - -jQuery(function($) { - - 'use strict'; - - var ULTRA_SETTINGS = window.ULTRA_SETTINGS || {}; - - - - - - /*-------------------------------- - Window Based Layout - --------------------------------*/ - ULTRA_SETTINGS.windowBasedLayout = function() { - var width = window.innerWidth; - //console.log(width); - - if ($("body").hasClass("chat-open") || $("body").hasClass("sidebar-collapse")) { - - ULTRA_SETTINGS.mainmenuCollapsed(); - - } else if (width < 1025) { - - // small window - $(".page-topbar").addClass("sidebar_shift").removeClass("chat_shift"); - $(".page-sidebar").addClass("collapseit").removeClass("expandit"); - $("#main-content").addClass("sidebar_shift").removeClass("chat_shift"); - $(".page-chatapi").removeClass("showit").addClass("hideit"); - $(".chatapi-windows").removeClass("showit").addClass("hideit"); - ULTRA_SETTINGS.mainmenuCollapsed(); - - } else { - - // large window - $(".page-topbar").removeClass("sidebar_shift chat_shift"); - $(".page-sidebar").removeClass("collapseit chat_shift"); - $("#main-content").removeClass("sidebar_shift chat_shift"); - ULTRA_SETTINGS.mainmenuScroll(); - } - - - } - - - - /*-------------------------------- - CHAT API - --------------------------------*/ - ULTRA_SETTINGS.chatAPI = function() { - - - $('.page-topbar .toggle_chat').on('click', function() { - var chatarea = $(".page-chatapi"); - var chatwindow = $(".chatapi-windows"); - var topbar = $(".page-topbar"); - var mainarea = $("#main-content"); - var menuarea = $(".page-sidebar"); - - if (chatarea.hasClass("hideit")) { - chatarea.addClass("showit").removeClass("hideit"); - chatwindow.addClass("showit").removeClass("hideit"); - topbar.addClass("chat_shift"); - mainarea.addClass("chat_shift"); - menuarea.addClass("chat_shift"); - ULTRA_SETTINGS.mainmenuCollapsed(); - } else { - chatarea.addClass("hideit").removeClass("showit"); - chatwindow.addClass("hideit").removeClass("showit"); - topbar.removeClass("chat_shift"); - mainarea.removeClass("chat_shift"); - menuarea.removeClass("chat_shift"); - //ULTRA_SETTINGS.mainmenuScroll(); - ULTRA_SETTINGS.windowBasedLayout(); - } - }); - - $('.page-topbar .sidebar_toggle').on('click', function() { - var chatarea = $(".page-chatapi"); - var chatwindow = $(".chatapi-windows"); - var topbar = $(".page-topbar"); - var mainarea = $("#main-content"); - var menuarea = $(".page-sidebar"); - - if (menuarea.hasClass("collapseit") || menuarea.hasClass("chat_shift")) { - menuarea.addClass("expandit").removeClass("collapseit").removeClass("chat_shift"); - topbar.removeClass("sidebar_shift").removeClass("chat_shift"); - mainarea.removeClass("sidebar_shift").removeClass("chat_shift"); - chatarea.addClass("hideit").removeClass("showit"); - chatwindow.addClass("hideit").removeClass("showit"); - ULTRA_SETTINGS.mainmenuScroll(); - } else { - menuarea.addClass("collapseit").removeClass("expandit").removeClass("chat_shift"); - topbar.addClass("sidebar_shift").removeClass("chat_shift"); - mainarea.addClass("sidebar_shift").removeClass("chat_shift"); - ULTRA_SETTINGS.mainmenuCollapsed(); - } - }); - - }; - - - /*-------------------------------- - CHAT API Scroll - --------------------------------*/ - ULTRA_SETTINGS.chatApiScroll = function() { - - var topsearch = $(".page-chatapi .search-bar").height(); - var height = window.innerHeight - topsearch; - $('.chat-wrapper').height(height).perfectScrollbar({ - suppressScrollX: true - }); - }; - - - /*-------------------------------- - CHAT API window - --------------------------------*/ - ULTRA_SETTINGS.chatApiWindow = function() { - - var chatarea = $(".page-chatapi"); - - $('.page-chatapi .user-row').on('click', function() { - - var name = $(this).find(".user-info h4 a").html(); - var img = $(this).find(".user-img a img").attr("src"); - var id = $(this).attr("data-user-id"); - var status = $(this).find(".user-info .status").attr("data-status"); - - if ($(this).hasClass("active")) { - $(this).toggleClass("active"); - - $(".chatapi-windows #user-window" + id).hide(); - - } else { - $(this).toggleClass("active"); - - if ($(".chatapi-windows #user-window" + id).length) { - - $(".chatapi-windows #user-window" + id).removeClass("minimizeit").show(); - - } else { - var msg = chatformat_msg('Wow! What a Beautiful theme!', 'receive', name); - msg += chatformat_msg('Yes! Ultra Admin Theme ;)', 'sent', 'You'); - var html = "
"; - html += "
" + name + "
"; - html += "
" + msg + "
"; - html += "
"; - html += "
"; - $(".chatapi-windows").append(html); - } - } - - }); - - $(document).on('click', ".chatapi-windows .user-window .controlbar .closeit", function(e) { - var id = $(this).attr("data-user-id"); - $(".chatapi-windows #user-window" + id).hide(); - $(".page-chatapi .user-row#chat_user_" + id).removeClass("active"); - }); - - $(document).on('click', ".chatapi-windows .user-window .controlbar img, .chatapi-windows .user-window .controlbar .minimizeit", function(e) { - var id = $(this).attr("data-user-id"); - - if (!$(".chatapi-windows #user-window" + id).hasClass("minimizeit")) { - $(".chatapi-windows #user-window" + id).addClass("minimizeit"); - ULTRA_SETTINGS.tooltipsPopovers(); - } else { - $(".chatapi-windows #user-window" + id).removeClass("minimizeit"); - } - - }); - - $(document).on('keypress', ".chatapi-windows .user-window .typearea input", function(e) { - if (e.keyCode == 13) { - var id = $(this).attr("data-user-id"); - var msg = $(this).val(); - msg = chatformat_msg(msg, 'sent', 'You'); - $(".chatapi-windows #user-window" + id + " .chatarea").append(msg); - $(this).val(""); - $(this).focus(); - } - $(".chatapi-windows #user-window" + id + " .chatarea").perfectScrollbar({ - suppressScrollX: true - }); - }); - - }; - - function chatformat_msg(msg, type, name) { - var d = new Date(); - var h = d.getHours(); - var m = d.getMinutes(); - return "
" + name + "" + msg + "" + h + ":" + m + "
"; - } - - - /*-------------------------------- - Login Page - --------------------------------*/ - ULTRA_SETTINGS.loginPage = function() { - - var height = window.innerHeight; - var formheight = $("#login").height(); - var newheight = (height - formheight) / 2; - //console.log(height+" - "+ formheight + " / "+ newheight); - $('#login').css('margin-top', +newheight + 'px'); - - if ($('#login #user_login').length) { - var d = document.getElementById('user_login'); - d.focus(); - } - - }; - - - - /*-------------------------------- - Search Page - --------------------------------*/ - ULTRA_SETTINGS.searchPage = function() { - - $('.search_data .tab-pane').perfectScrollbar({ - suppressScrollX: true - }); - var search = $(".search-page-input"); - if (search.length) { - search.focus(); - } - }; - - - /*-------------------------------- - Viewport Checker - --------------------------------*/ - ULTRA_SETTINGS.viewportElement = function() { - - if ($.isFunction($.fn.viewportChecker)) { - - $('.inviewport').viewportChecker({ - callbackFunction: function(elem, action) { - //setTimeout(function(){ - //elem.html((action == "add") ? 'Callback with 500ms timeout: added class' : 'Callback with 500ms timeout: removed class'); - //},500); - } - }); - - - $('.number_counter').viewportChecker({ - classToAdd: 'start_timer', - offset: 10, - callbackFunction: function(elem) { - $('.start_timer:not(.counted)').each(count); - //$(elem).removeClass('number_counter'); - } - }); - - } - - // start count - function count(options) { - var $this = $(this); - options = $.extend({}, options || {}, $this.data('countToOptions') || {}); - $this.countTo(options).addClass("counted"); - } - }; - - - - /*-------------------------------- - Sortable / Draggable Panels - --------------------------------*/ - ULTRA_SETTINGS.draggablePanels = function() { - - if ($.isFunction($.fn.sortable)) { - $(".sort_panel").sortable({ - connectWith: ".sort_panel", - handle: "header.panel_header", - cancel: ".panel_actions", - placeholder: "portlet-placeholder" - }); - } - }; - - - - /*-------------------------------- - Breadcrumb autoHidden - --------------------------------*/ - ULTRA_SETTINGS.breadcrumbAutoHidden = function() { - - $('.breadcrumb.auto-hidden a').on('mouseover', function() { - $(this).removeClass("collapsed"); - }); - $('.breadcrumb.auto-hidden a').on('mouseout', function() { - $(this).addClass("collapsed"); - }); - - }; - - - - - - /*-------------------------------- - Section Box Actions - --------------------------------*/ - ULTRA_SETTINGS.sectionBoxActions = function() { - - $('section.box .actions .box_toggle').on('click', function() { - - var content = $(this).parent().parent().parent().find(".content-body"); - if (content.hasClass("collapsed")) { - content.removeClass("collapsed").slideDown(500); - $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - } else { - content.addClass("collapsed").slideUp(500); - $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - } - - }); - - $('section.box .actions .box_close').on('click', function() { - content = $(this).parent().parent().parent().remove(); - }); - - - - }; - - - - - - - /*-------------------------------- - Main Menu Scroll - --------------------------------*/ - ULTRA_SETTINGS.mainmenuScroll = function() { - - //console.log("expand scroll menu"); - - var topbar = $(".page-topbar").height(); - var projectinfo = $(".project-info").innerHeight(); - - var height = window.innerHeight - topbar - projectinfo; - - $('#main-menu-wrapper').height(height).perfectScrollbar({ - suppressScrollX: true - }); - $("#main-menu-wrapper .wraplist").height('auto'); - - - /*show first sub menu of open menu item only - opened after closed*/ - // > in the selector is used to select only immediate elements and not the inner nested elements. - $("li.open > .sub-menu").attr("style", "display:block;"); - - - }; - - - /*-------------------------------- - Collapsed Main Menu - --------------------------------*/ - ULTRA_SETTINGS.mainmenuCollapsed = function() { - - if ($(".page-sidebar.chat_shift #main-menu-wrapper").length > 0 || $(".page-sidebar.collapseit #main-menu-wrapper").length > 0) { - //console.log("collapse menu"); - var topbar = $(".page-topbar").height(); - var windowheight = window.innerHeight; - var minheight = windowheight - topbar; - var fullheight = $(".page-container #main-content .wrapper").height(); - - var height = fullheight; - - if (fullheight < minheight) { - height = minheight; - } - - $('#main-menu-wrapper').perfectScrollbar('destroy'); - - $('.page-sidebar.chat_shift #main-menu-wrapper .wraplist, .page-sidebar.collapseit #main-menu-wrapper .wraplist').height(height); - - /*hide sub menu of open menu item*/ - $("li.open .sub-menu").attr("style", ""); - - } - - }; - - - - - /*-------------------------------- - Main Menu - --------------------------------*/ - ULTRA_SETTINGS.mainMenu = function() { - $('#main-menu-wrapper li a').click(function(e) { - - if ($(this).next().hasClass('sub-menu') === false) { - return; - } - - var parent = $(this).parent().parent(); - var sub = $(this).next(); - - parent.children('li.open').children('.sub-menu').slideUp(200); - parent.children('li.open').children('a').children('.arrow').removeClass('open'); - parent.children('li').removeClass('open'); - - if (sub.is(":visible")) { - $(this).find(".arrow").removeClass("open"); - sub.slideUp(200); - } else { - $(this).parent().addClass("open"); - $(this).find(".arrow").addClass("open"); - sub.slideDown(200); - } - - }); - - $("body").click(function(e) { - $(".page-sidebar.collapseit .wraplist li.open .sub-menu").attr("style",""); - $(".page-sidebar.collapseit .wraplist li.open").removeClass("open"); - $(".page-sidebar.chat_shift .wraplist li.open .sub-menu").attr("style",""); - $(".page-sidebar.chat_shift .wraplist li.open").removeClass("open"); - }); - - }; - - - - /*-------------------------------- - Mailbox - --------------------------------*/ - ULTRA_SETTINGS.mailboxInbox = function() { - - $('.mail_list table .star i').click(function(e) { - $(this).toggleClass("fa-star fa-star-o"); - }); - - $('.mail_list .open-view').click(function(e) { - window.location = 'mail-view.html'; - }); - - $('.mail_view_info .labels .cc').click(function(e) { - var ele = $(".mail_compose_cc"); - if (ele.is(":visible")) { - ele.hide(); - } else { - ele.show(); - } - }); - - $('.mail_view_info .labels .bcc').click(function(e) { - var ele = $(".mail_compose_bcc"); - if (ele.is(":visible")) { - ele.hide(); - } else { - ele.show(); - } - }); - - }; - - - - - /*-------------------------------- - Top Bar - --------------------------------*/ - ULTRA_SETTINGS.pageTopBar = function() { - $('.page-topbar li.searchform .input-group-addon').click(function(e) { - $(this).parent().parent().toggleClass("focus"); - $(this).parent().find("input").focus(); - }); - - $('.page-topbar li .dropdown-menu .list').perfectScrollbar({ - suppressScrollX: true - }); - - }; - - - /*-------------------------------- - Extra form settings - --------------------------------*/ - ULTRA_SETTINGS.extraFormSettings = function() { - - // transparent input group focus/blur - $('.input-group .form-control').focus(function(e) { - $(this).parent().find(".input-group-addon").addClass("input-focus"); - $(this).parent().find(".input-group-btn").addClass("input-focus"); - }); - - $('.input-group .form-control').blur(function(e) { - $(this).parent().find(".input-group-addon").removeClass("input-focus"); - $(this).parent().find(".input-group-btn").removeClass("input-focus"); - }); - - }; - - - - /*-------------------------------- - js tree - --------------------------------*/ - ULTRA_SETTINGS.jsTreeINIT = function() { - - - if ($.isFunction($.fn.jstree)) { - $(function() { - var to = false; - $('#treedata_q').keyup(function() { - if (to) { - clearTimeout(to); - } - to = setTimeout(function() { - var v = $('#treedata_q').val(); - $('#jstree_treedata').jstree(true).search(v); - }, 250); - }); - - $('#jstree_treedata') - .jstree({ - "core": { - "animation": 0, - "check_callback": true, - "themes": { - "stripes": true - }, - 'data': { - 'url': function(node) { - return node.id === '#' ? 'data/ajax_demo_roots_jstree.json' : 'data/ajax_demo_children_jstree.json'; - }, - 'data': function(node) { - return { - 'id': node.id - }; - } - } - }, - "types": { - "#": { - "max_children": 1, - "max_depth": 4, - "valid_children": ["root"] - }, - "root": { - "icon": "assets/plugins/jstree/images/tree_icon.png", - "valid_children": ["default"] - }, - "default": { - "valid_children": ["default", "file"] - }, - "file": { - "icon": "fa fa-file", - "valid_children": [] - } - }, - "checkbox": { - "keep_selected_style": false - }, - "plugins": ["checkbox", "contextmenu", "dnd", "search", "sort", "state", "types", "unique", "wholerow"] - }); - }); - - } - }; - - - - /*-------------------------------- - Vector maps - --------------------------------*/ - ULTRA_SETTINGS.jvectorMaps = function() { - - if ($.isFunction($.fn.vectorMap)) { - - if ($("#world-map-markers").length) { - //@code_start - $(function() { - $('#world-map-markers').vectorMap({ - map: 'world_mill_en', - scaleColors: ['#1fb5ac', '#1fb5ac'], - normalizeFunction: 'polynomial', - hoverOpacity: 0.7, - hoverColor: false, - regionsSelectable: true, - markersSelectable: true, - markersSelectableOne: true, - - onRegionOver: function(event, code) { - //console.log('region-over', code); - }, - onRegionOut: function(event, code) { - //console.log('region-out', code); - }, - onRegionClick: function(event, code) { - //console.log('region-click', code); - }, - onRegionSelected: function(event, code, isSelected, selectedRegions) { - //console.log('region-select', code, isSelected, selectedRegions); - if (window.localStorage) { - window.localStorage.setItem( - 'jvectormap-selected-regions', - JSON.stringify(selectedRegions) - ); - } - }, - - panOnDrag: true, - - focusOn: { - x: 0.5, - y: 0.5, - scale: 1, - animate: true - }, - - - regionStyle: { - initial: { - fill: 'white', - 'fill-opacity': 1, - stroke: 'none', - 'stroke-width': 0, - 'stroke-opacity': 1 - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - }, - selectedHover: {} - }, - - - - markerStyle: { - initial: { - fill: '#9972b5', - stroke: '#9972b5', - r: 6 - }, - hover: { - stroke: '#FDB45C', - "stroke-width": 2, - cursor: 'pointer' - }, - selected: { - fill: '#FDB45C', - "stroke-width": 0, - }, - }, - backgroundColor: '#1fb5ac', - markers: [{ - latLng: [41.90, 12.45], - name: 'Vatican City' - }, { - latLng: [43.73, 7.41], - name: 'Monaco' - }, { - latLng: [-0.52, 166.93], - name: 'Nauru' - }, { - latLng: [-8.51, 179.21], - name: 'Tuvalu' - }, { - latLng: [43.93, 12.46], - name: 'San Marino' - }, { - latLng: [47.14, 9.52], - name: 'Liechtenstein' - }, { - latLng: [7.11, 171.06], - name: 'Marshall Islands' - }, { - latLng: [17.3, -62.73], - name: 'Saint Kitts and Nevis' - }, { - latLng: [3.2, 73.22], - name: 'Maldives' - }, { - latLng: [35.88, 14.5], - name: 'Malta' - }, { - latLng: [12.05, -61.75], - name: 'Grenada' - }, { - latLng: [13.16, -61.23], - name: 'Saint Vincent and the Grenadines' - }, { - latLng: [13.16, -59.55], - name: 'Barbados' - }, { - latLng: [17.11, -61.85], - name: 'Antigua and Barbuda' - }, { - latLng: [-4.61, 55.45], - name: 'Seychelles' - }, { - latLng: [7.35, 134.46], - name: 'Palau' - }, { - latLng: [42.5, 1.51], - name: 'Andorra' - }, { - latLng: [14.01, -60.98], - name: 'Saint Lucia' - }, { - latLng: [6.91, 158.18], - name: 'Federated States of Micronesia' - }, { - latLng: [1.3, 103.8], - name: 'Singapore' - }, { - latLng: [1.46, 173.03], - name: 'Kiribati' - }, { - latLng: [-21.13, -175.2], - name: 'Tonga' - }, { - latLng: [15.3, -61.38], - name: 'Dominica' - }, { - latLng: [-20.2, 57.5], - name: 'Mauritius' - }, { - latLng: [26.02, 50.55], - name: 'Bahrain' - }, { - latLng: [0.33, 6.73], - name: 'São Tomé and Príncipe' - }] - }); - }); - //@code_end - } - - var mapid = ""; - mapid = $('#europe_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'europe_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 1, - animate: true - }, - }); - } // Europe - mapid = $('#in_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'in_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // India - mapid = $('#us_aea_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'us_aea_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // USA - mapid = $('#pt_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'pt_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Portugal - mapid = $('#cn_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'cn_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // China - mapid = $('#nz_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'nz_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // New Zealand - mapid = $('#no_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'no_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Norway - mapid = $('#es_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'es_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Spain - mapid = $('#au_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'au_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Australia - mapid = $('#fr_regions_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'fr_regions_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // France - Regions - mapid = $('#th_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'th_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Thailand - mapid = $('#co_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'co_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Colombia - mapid = $('#be_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'be_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Belgium - mapid = $('#ar_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'ar_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Argentina - mapid = $('#ve_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 've_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Venezuela - mapid = $('#it_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'it_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Italy - mapid = $('#dk_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'dk_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Denmark - mapid = $('#at_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'at_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Austria - mapid = $('#ca_lcc_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'ca_lcc_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Canada - mapid = $('#nl_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'nl_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Netherlands - mapid = $('#se_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'se_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Sweden - mapid = $('#pl_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'pl_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Poland - mapid = $('#de_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'de_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Germany - mapid = $('#fr_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'fr_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // France - Departments - mapid = $('#za_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'za_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // South Africa - mapid = $('#ch_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'ch_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Switzerland - mapid = $('#us-ny-newyork_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'us-ny-newyork_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // New York City - mapid = $('#us-il-chicago_mill_en-map'); - if (mapid.length) { - mapid.vectorMap({ - map: 'us-il-chicago_mill_en', - regionsSelectable: true, - backgroundColor: '#1fb5ac', - regionStyle: { - initial: { - fill: 'white', - stroke: 'none', - }, - hover: { - fill: '#fa8564', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#fa8564' - } - }, - focusOn: { - x: 0, - y: 0, - scale: 5, - animate: true - }, - }); - } // Chicago - - } - - }; - - - /*-------------------------------- - DataTables - --------------------------------*/ - ULTRA_SETTINGS.dataTablesInit = function() { - - if ($.isFunction($.fn.dataTable)) { - - /*--- start ---*/ - - $("#example-1").dataTable({ - responsive: true, - aLengthMenu: [ - [10, 25, 50, 100, -1], - [10, 25, 50, 100, "All"] - ] - }); - - /*--- end ---*/ - - /*--- start ---*/ - - $('#example-4').dataTable(); - - /*--- end ---*/ - - - - /* Set the defaults for DataTables initialisation */ - $.extend(true, $.fn.dataTable.defaults, { - "sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-12'p i>>", - "sPaginationType": "bootstrap", - "oLanguage": { - "sLengthMenu": "_MENU_" - } - }); - - - /* Default class modification */ - $.extend($.fn.dataTableExt.oStdClasses, { - "sWrapper": "dataTables_wrapper form-inline" - }); - - - /* API method to get paging information */ - $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings) { - return { - "iStart": oSettings._iDisplayStart, - "iEnd": oSettings.fnDisplayEnd(), - "iLength": oSettings._iDisplayLength, - "iTotal": oSettings.fnRecordsTotal(), - "iFilteredTotal": oSettings.fnRecordsDisplay(), - "iPage": oSettings._iDisplayLength === -1 ? - 0 : Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength), - "iTotalPages": oSettings._iDisplayLength === -1 ? - 0 : Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength) - }; - }; - - - /* Bootstrap style pagination control */ - $.extend($.fn.dataTableExt.oPagination, { - "bootstrap": { - "fnInit": function(oSettings, nPaging, fnDraw) { - var oLang = oSettings.oLanguage.oPaginate; - var fnClickHandler = function(e) { - e.preventDefault(); - if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) { - fnDraw(oSettings); - } - }; - - $(nPaging).addClass('').append( - '
    ' + - '' + - '' + - '
' - ); - var els = $('a', nPaging); - $(els[0]).bind('click.DT', { - action: "previous" - }, fnClickHandler); - $(els[1]).bind('click.DT', { - action: "next" - }, fnClickHandler); - }, - - "fnUpdate": function(oSettings, fnDraw) { - var iListLength = 5; - var oPaging = oSettings.oInstance.fnPagingInfo(); - var an = oSettings.aanFeatures.p; - var i, ien, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2); - - if (oPaging.iTotalPages < iListLength) { - iStart = 1; - iEnd = oPaging.iTotalPages; - } else if (oPaging.iPage <= iHalf) { - iStart = 1; - iEnd = iListLength; - } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) { - iStart = oPaging.iTotalPages - iListLength + 1; - iEnd = oPaging.iTotalPages; - } else { - iStart = oPaging.iPage - iHalf + 1; - iEnd = iStart + iListLength - 1; - } - - for (i = 0, ien = an.length; i < ien; i++) { - // Remove the middle elements - $('li:gt(0)', an[i]).filter(':not(:last)').remove(); - - // Add the new list items and their event handlers - for (j = iStart; j <= iEnd; j++) { - sClass = (j == oPaging.iPage + 1) ? 'class="active"' : ''; - $('
  • ' + j + '
  • ') - .insertBefore($('li:last', an[i])[0]) - .bind('click', function(e) { - e.preventDefault(); - oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength; - fnDraw(oSettings); - }); - } - - // Add / remove disabled classes from the static elements - if (oPaging.iPage === 0) { - $('li:first', an[i]).addClass('disabled'); - } else { - $('li:first', an[i]).removeClass('disabled'); - } - - if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) { - $('li:last', an[i]).addClass('disabled'); - } else { - $('li:last', an[i]).removeClass('disabled'); - } - } - } - } - }); - - - /* - * TableTools Bootstrap compatibility - * Required TableTools 2.1+ - */ - - // Set the classes that TableTools uses to something suitable for Bootstrap - $.extend(true, $.fn.DataTable.TableTools.classes, { - "container": "DTTT ", - "buttons": { - "normal": "btn btn-white", - "disabled": "disabled" - }, - "collection": { - "container": "DTTT_dropdown dropdown-menu", - "buttons": { - "normal": "", - "disabled": "disabled" - } - }, - "print": { - "info": "DTTT_print_info modal" - }, - "select": { - "row": "active" - } - }); - - // Have the collection use a bootstrap compatible dropdown - $.extend(true, $.fn.DataTable.TableTools.DEFAULTS.oTags, { - "collection": { - "container": "ul", - "button": "li", - "liner": "a" - } - }); - - - /* Table initialisation */ - $(document).ready(function() { - var responsiveHelper = undefined; - var breakpointDefinition = { - tablet: 1024, - phone: 480 - }; - var tableElement = $('#example'); - - tableElement.dataTable({ - "sDom": "<'row'<'col-md-6'l T><'col-md-6'f>r>t<'row'<'col-md-12'p i>>", - "oTableTools": { - "aButtons": [{ - "sExtends": "collection", - "sButtonText": "", - "aButtons": ["csv", "xls", "pdf", "copy"] - }] - }, - "sPaginationType": "bootstrap", - "aoColumnDefs": [{ - 'bSortable': false, - 'aTargets': [0] - }], - "aaSorting": [ - [1, "asc"] - ], - "oLanguage": { - "sLengthMenu": "_MENU_ ", - "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries" - }, - bAutoWidth: false, - fnPreDrawCallback: function() { - // Initialize the responsive datatables helper once. - if (!responsiveHelper) { - //responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); - } - }, - fnRowCallback: function(nRow) { - //responsiveHelper.createExpandIcon(nRow); - }, - fnDrawCallback: function(oSettings) { - //responsiveHelper.respond(); - } - }); - - $('#example_wrapper .dataTables_filter input').addClass("input-medium "); // modify table search input - $('#example_wrapper .dataTables_length select').addClass("select2-wrapper col-md-12"); // modify table per page dropdown - - - - $('#example input').click(function() { - $(this).parent().parent().parent().toggleClass('row_selected'); - }); - - - /* - * Insert a 'details' column to the table - */ - var nCloneTh = document.createElement('th'); - var nCloneTd = document.createElement('td'); - nCloneTd.innerHTML = ''; - nCloneTd.className = "center"; - - $('#example2 thead tr').each(function() { - this.insertBefore(nCloneTh, this.childNodes[0]); - }); - - $('#example2 tbody tr').each(function() { - this.insertBefore(nCloneTd.cloneNode(true), this.childNodes[0]); - }); - - /* - * Initialse DataTables, with no sorting on the 'details' column - */ - var oTable = $('#example2').dataTable({ - "sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-12'p i>>", - "aaSorting": [], - "oLanguage": { - "sLengthMenu": "_MENU_ ", - "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries" - }, - }); - - - $("div.toolbar").html('
    '); - - - $('#example2_wrapper .dataTables_filter input').addClass("input-medium "); - $('#example2_wrapper .dataTables_length select').addClass("select2-wrapper col-md-12"); - - /* Add event listener for opening and closing details - * Note that the indicator for showing which row is open is not controlled by DataTables, - * rather it is done here - */ - $('#example2 tbody td i').on('click', function() { - var nTr = $(this).parents('tr')[0]; - if (oTable.fnIsOpen(nTr)) { - /* This row is already open - close it */ - this.removeClass = "fa fa-plus-circle"; - this.addClass = "fa fa-minus-circle"; - oTable.fnClose(nTr); - } else { - /* Open this row */ - this.removeClass = "fa fa-minus-circle"; - this.addClass = "fa fa-plus-circle"; - oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr), 'details'); - } - - - /* Formating function for row details */ - function fnFormatDetails(oTable, nTr) { - var aData = oTable.fnGetData(nTr); - var sOut = ''; - sOut += ''; - sOut += ''; - sOut += ''; - sOut += '
    Rendering engine:' + aData[1] + ' ' + aData[4] + '
    Link to source:Could provide a link here
    Extra info:And any further details here (images etc)
    '; - - return sOut; - } - - }); - - }); - - - - - - } - }; - - - - /*-------------------------------- - Pretty Photo - --------------------------------*/ - ULTRA_SETTINGS.loadPrettyPhoto = function() { - - if ($.isFunction($.fn.prettyPhoto)) { - //Pretty Photo - $("a[rel^='prettyPhoto']").prettyPhoto({ - social_tools: false - }); - } - }; - - - - - /*-------------------------------- - Gallery - --------------------------------*/ - ULTRA_SETTINGS.isotopeGallery = function() { - if ($.isFunction($.fn.isotope)) { - - var $portfolio_selectors = $('.portfolio-filter >li>a'); - var $portfolio = $('.portfolio-items'); - $portfolio.isotope({ - itemSelector: '.portfolio-item', - layoutMode: 'sloppyMasonry' - }); - - $portfolio_selectors.on('click', function() { - $portfolio_selectors.removeClass('active'); - $(this).addClass('active'); - var selector = $(this).attr('data-filter'); - $portfolio.isotope({ - filter: selector - }); - return false; - }); - - - } - }; - - - /*-------------------------------- - Tocify - --------------------------------*/ - ULTRA_SETTINGS.tocifyScrollMenu = function() { - if ($.isFunction($.fn.tocify)) { - var toc = $("#toc").tocify({ - selectors: "h2,h3,h4,h5", - context: ".tocify-content", - extendPage: false - }).data("toc-tocify"); - } - }; - - - - /*-------------------------------- - Full Calendar - --------------------------------*/ - ULTRA_SETTINGS.uiCalendar = function() { - - - if ($.isFunction($.fn.fullCalendar)) { - - /* initialize the external events - -----------------------------------------------------------------*/ - - $('#external-events .fc-event').each(function() { - - // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) - // it doesn't need to have a start or end - var eventObject = { - title: $.trim($(this).text()) // use the element's text as the event title - }; - - // store the Event Object in the DOM element so we can get to it later - $(this).data('eventObject', eventObject); - - // make the event draggable using jQuery UI - $(this).draggable({ - zIndex: 999, - revert: true, // will cause the event to go back to its - revertDuration: 0 // original position after the drag - }); - - }); - - - /* initialize the calendar - -----------------------------------------------------------------*/ - - var date = new Date(); - var d = date.getDate(); - var m = date.getMonth(); - var y = date.getFullYear(); - - $('#calendar').fullCalendar({ - header: { - left: 'prev,next today', - center: 'title', - right: 'month,basicWeek,basicDay' - }, - editable: true, - eventLimit: true, // allow "more" link when too many events - droppable: true, // this allows things to be dropped onto the calendar !!! - drop: function(date, allDay) { // this function is called when something is dropped - - // retrieve the dropped element's stored Event Object - var originalEventObject = $(this).data('eventObject'); - - // we need to copy it, so that multiple events don't have a reference to the same object - var copiedEventObject = $.extend({}, originalEventObject); - - // assign it the date that was reported - copiedEventObject.start = date; - copiedEventObject.allDay = allDay; - - // render the event on the calendar - // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) - $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); - - // is the "remove after drop" checkbox checked? - if ($('#drop-remove').is(':checked')) { - // if so, remove the element from the "Draggable Events" list - $(this).remove(); - } - - }, - events: [{ - title: 'All Day Event', - start: new Date(y, m, 1) - }, { - title: 'Long Event', - start: new Date(y, m, d - 5), - end: new Date(y, m, d - 2) - }, { - id: 999, - title: 'Repeating Event', - start: new Date(y, m, d - 3, 16, 0), - allDay: false - }, { - id: 999, - title: 'Repeating Event', - start: new Date(y, m, d + 4, 16, 0), - allDay: false - }, { - title: 'Meeting', - start: new Date(y, m, d, 10, 30), - allDay: false - }, { - title: 'Lunch', - start: new Date(y, m, d, 12, 0), - end: new Date(y, m, d, 14, 0), - allDay: false - }, { - title: 'Birthday Party', - start: new Date(y, m, d + 1, 19, 0), - end: new Date(y, m, d + 1, 22, 30), - allDay: false - }, { - title: 'Click for Google', - start: new Date(y, m, 28), - end: new Date(y, m, 29), - url: 'http://google.com/' - }] - }); - - - - - - /*Add new event*/ - // Form to add new event - - $("#add_event_form").on('submit', function(ev) { - ev.preventDefault(); - - var $event = $(this).find('.new-event-form'), - event_name = $event.val(); - - if (event_name.length >= 3) { - - var newid = "new" + "" + Math.random().toString(36).substring(7); - // Create Event Entry - $("#external-events").append( - '
    ' + event_name + '
    ' - ); - - - var eventObject = { - title: $.trim($("#" + newid).text()) // use the element's text as the event title - }; - - // store the Event Object in the DOM element so we can get to it later - $("#" + newid).data('eventObject', eventObject); - - // Reset draggable - $("#" + newid).draggable({ - revert: true, - revertDuration: 0, - zIndex: 999 - }); - - // Reset input - $event.val('').focus(); - } else { - $event.focus(); - } - }); - - - - } - - }; - - - - /*-------------------------------- - Sortable (Nestable) List - --------------------------------*/ - ULTRA_SETTINGS.nestableList = function() { - - $("#nestableList-1").on('stop.uk.nestable', function(ev) { - var serialized = $(this).data('nestable').serialize(), - str = ''; - - str = nestableIterate(serialized, 0); - - $("#nestableList-1-ev").val(str); - }); - - - function nestableIterate(items, depth) { - var str = ''; - - if (!depth) - depth = 0; - - //console.log(items); - - jQuery.each(items, function(i, obj) { - str += '[ID: ' + obj.itemId + ']\t' + nestableRepeat('—', depth + 1) + ' ' + obj.item; - str += '\n'; - - if (obj.children) { - str += nestableIterate(obj.children, depth + 1); - } - }); - - return str; - } - - function nestableRepeat(s, n) { - var a = []; - while (a.length < n) { - a.push(s); - } - return a.join(''); - } - }; - - - - - - - - - - /*-------------------------------- - Tooltips & Popovers - --------------------------------*/ - ULTRA_SETTINGS.tooltipsPopovers = function() { - - $('[rel="tooltip"]').each(function() { - var animate = $(this).attr("data-animate"); - var colorclass = $(this).attr("data-color-class"); - $(this).tooltip({ - template: '
    ' - }); - }); - - $('[rel="popover"]').each(function() { - var animate = $(this).attr("data-animate"); - var colorclass = $(this).attr("data-color-class"); - $(this).popover({ - template: '

    ' - }); - }); - - }; - - - - - - /*-------------------------------- - iCheck - --------------------------------*/ - ULTRA_SETTINGS.iCheck = function() { - - - - if ($.isFunction($.fn.iCheck)) { - - - $('input[type="checkbox"].iCheck').iCheck({ - checkboxClass: 'icheckbox_minimal', - radioClass: 'iradio_minimal', - increaseArea: '20%' - }); - - - var x; - var colors = ["-green", "-red", "-yellow", "-blue", "-aero", "-orange", "-grey", "-pink", "-purple","-white"]; - - for (x = 0; x < colors.length; x++) { - - if (x == 0) { - $('input.icheck-minimal').iCheck({ - checkboxClass: 'icheckbox_minimal' + colors[x], - radioClass: 'iradio_minimal' + colors[x], - increaseArea: '20%' - }); - - $('input.skin-square').iCheck({ - checkboxClass: 'icheckbox_square' + colors[x], - radioClass: 'iradio_square' + colors[x], - increaseArea: '20%' - }); - - $('input.skin-flat').iCheck({ - checkboxClass: 'icheckbox_flat' + colors[x], - radioClass: 'iradio_flat' + colors[x], - }); - - - $('input.skin-line').each(function() { - var self = $(this), - label = self.next(), - label_text = label.text(); - - label.remove(); - self.iCheck({ - checkboxClass: 'icheckbox_line' + colors[x], - radioClass: 'iradio_line' + colors[x], - insert: '
    ' + label_text - }); - }); - - } // end x = 0 - - $('input.icheck-minimal' + colors[x]).iCheck({ - checkboxClass: 'icheckbox_minimal' + colors[x], - radioClass: 'iradio_minimal' + colors[x], - increaseArea: '20%' - }); - - - $('input.skin-square' + colors[x]).iCheck({ - checkboxClass: 'icheckbox_square' + colors[x], - radioClass: 'iradio_square' + colors[x], - increaseArea: '20%' - }); - - - $('input.skin-flat' + colors[x]).iCheck({ - checkboxClass: 'icheckbox_flat' + colors[x], - radioClass: 'iradio_flat' + colors[x], - }); - - - $('input.skin-line' + colors[x]).each(function() { - var self = $(this), - label = self.next(), - label_text = label.text(); - - label.remove(); - self.iCheck({ - checkboxClass: 'icheckbox_line' + colors[x], - radioClass: 'iradio_line' + colors[x], - insert: '
    ' + label_text - }); - }); - - } // end for loop - - - } - }; - - - - - /*-------------------------------- - Form Editors - --------------------------------*/ - ULTRA_SETTINGS.formEditors = function() { - - if ($.isFunction($.fn.wysihtml5)) { - $('.bootstrap-wysihtml5-textarea').wysihtml5({ - toolbar: { - "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true - "emphasis": true, //Italics, bold, etc. Default true - "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true - "html": true, //Button which allows you to edit the generated HTML. Default false - "link": true, //Button to insert a link. Default true - "image": true, //Button to insert an image. Default true, - "color": true, //Button to change color of font - "blockquote": true, //Blockquote - "size": "none" //default: none, other options are xs, sm, lg - } - }); - - - $('.mail-compose-editor').wysihtml5({ - toolbar: { - "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true - "emphasis": true, //Italics, bold, etc. Default true - "lists": false, //(Un)ordered lists, e.g. Bullets, Numbers. Default true - "html": true, //Button which allows you to edit the generated HTML. Default false - "link": true, //Button to insert a link. Default true - "image": true, //Button to insert an image. Default true, - "color": true, //Button to change color of font - "blockquote": false, //Blockquote - "size": "none" //default: none, other options are xs, sm, lg - } - }); - - } - - if ($.isFunction($.fn.CKEDITOR)) { - // This code is generally not necessary, but it is here to demonstrate - // how to customize specific editor instances on the fly. This fits well - // this demo because we have editable elements (like headers) that - // require less features. - - // The "instanceCreated" event is fired for every editor instance created. - CKEDITOR.on('instanceCreated', function(event) { - var editor = event.editor, - element = editor.element; - - // Customize editors for headers and tag list. - // These editors don't need features like smileys, templates, iframes etc. - if (element.is('h1', 'h2', 'h3') || element.getAttribute('id') == 'taglist') { - // Customize the editor configurations on "configLoaded" event, - // which is fired after the configuration file loading and - // execution. This makes it possible to change the - // configurations before the editor initialization takes place. - editor.on('configLoaded', function() { - - // Remove unnecessary plugins to make the editor simpler. - editor.config.removePlugins = 'colorbutton,find,flash,font,' + - 'forms,iframe,image,newpage,removeformat,' + - 'smiley,specialchar,stylescombo,templates'; - - // Rearrange the layout of the toolbar. - editor.config.toolbarGroups = [{ - name: 'editing', - groups: ['basicstyles', 'links'] - }, { - name: 'undo' - }, { - name: 'clipboard', - groups: ['selection', 'clipboard'] - }, { - name: 'about' - }]; - }); - } - }); - } - }; - - - /*-------------------------------- - Custom Dropzone - --------------------------------*/ - ULTRA_SETTINGS.customDropZone = function() { - - - - if ($.isFunction($.fn.dropzone)) { - - var i = 1, - $custom_droplist = $("#custom-droptable"), - example_dropzone = $("#customDZ").dropzone({ - url: 'data/upload-file.php', - - // Events - addedfile: function(file) { - if (i == 1) { - $custom_droplist.find('tbody').html(''); - } - - var size = parseInt(file.size / 1024, 10); - size = size < 1024 ? (size + " KB") : (parseInt(size / 1024, 10) + " MB"); - - var $el = $('\ - ' + (i++) + '\ - ' + file.name + '\ -
    \ - ' + size + '\ - '); - - $custom_droplist.find('tbody').append($el); - file.fileEntryTd = $el; - file.progressBar = $el.find('.progress-bar'); - }, - - uploadprogress: function(file, progress, bytesSent) { - file.progressBar.width(progress + '%'); - $('.custom-dropzone .drop-table').perfectScrollbar({ - suppressScrollX: true - }); - }, - - success: function(file) { - file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-success'); - }, - - error: function(file) { - file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-red'); - } - }); - - } - - }; - - - /*-------------------------------- - Other Form component Scripts - --------------------------------*/ - ULTRA_SETTINGS.otherScripts = function() { - - - - /*--------------------------------*/ - - - if ($.isFunction($.fn.autosize)) { - $(".autogrow").autosize(); - } - - /*--------------------------------*/ - - - - - // Input Mask - if ($.isFunction($.fn.inputmask)) { - $("[data-mask]").each(function(i, el) { - var $this = $(el), - mask = $this.data('mask').toString(), - opts = { - numericInput: getValue($this, 'numeric', false), - radixPoint: getValue($this, 'radixPoint', ''), - rightAlign: getValue($this, 'numericAlign', 'left') == 'right' - }, - placeholder = getValue($this, 'placeholder', ''), - is_regex = getValue($this, 'isRegex', ''); - - if (placeholder.length) { - opts[placeholder] = placeholder; - } - - - if (mask.toLowerCase() == "phone") { - mask = "(999) 999-9999"; - } - - if (mask.toLowerCase() == "email") { - mask = 'Regex'; - opts.regex = "[a-zA-Z0-9._%-]+@[a-zA-Z0-9-]+\\.[a-zA-Z]{2,4}"; - } - - if (mask.toLowerCase() == "fdecimal") { - mask = 'decimal'; - $.extend(opts, { - autoGroup: true, - groupSize: 3, - radixPoint: getValue($this, 'rad', '.'), - groupSeparator: getValue($this, 'dec', ',') - }); - } - - - if (mask.toLowerCase() == "currency" || mask.toLowerCase() == "rcurrency") { - - var sign = getValue($this, 'sign', '$');; - - mask = "999,999,999.99"; - if (mask.toLowerCase() == 'rcurrency') { - mask += ' ' + sign; - } else { - mask = sign + ' ' + mask; - } - - opts.numericInput = true; - opts.rightAlignNumerics = false; - opts.radixPoint = '.'; - - } - - if (is_regex) { - opts.regex = mask; - mask = 'Regex'; - } - - $this.inputmask(mask, opts); - }); - } - - - /*---------------------------------*/ - - // autoNumeric - if ($.isFunction($.fn.autoNumeric)) { - $('.autoNumeric').autoNumeric('init'); - } - - /*---------------------------------*/ - - // Slider - if ($.isFunction($.fn.slider)) { - $(".slider").each(function(i, el) { - var $this = $(el), - $label_1 = $(''), - $label_2 = $label_1.clone(), - - orientation = getValue($this, 'vertical', 0) != 0 ? 'vertical' : 'horizontal', - - prefix = getValue($this, 'prefix', ''), - postfix = getValue($this, 'postfix', ''), - - fill = getValue($this, 'fill', ''), - $fill = $(fill), - - step = getValue($this, 'step', 1), - value = getValue($this, 'value', 5), - min = getValue($this, 'min', 0), - max = getValue($this, 'max', 100), - min_val = getValue($this, 'min-val', 10), - max_val = getValue($this, 'max-val', 90), - - is_range = $this.is('[data-min-val]') || $this.is('[data-max-val]'), - - reps = 0; - - - // Range Slider Options - if (is_range) { - $this.slider({ - range: true, - orientation: orientation, - min: min, - max: max, - values: [min_val, max_val], - step: step, - slide: function(e, ui) { - var min_val = (prefix ? prefix : '') + ui.values[0] + (postfix ? postfix : ''), - max_val = (prefix ? prefix : '') + ui.values[1] + (postfix ? postfix : ''); - - $label_1.html(min_val); - $label_2.html(max_val); - - if (fill) - $fill.val(min_val + ',' + max_val); - - reps++; - }, - change: function(ev, ui) { - if (reps == 1) { - var min_val = (prefix ? prefix : '') + ui.values[0] + (postfix ? postfix : ''), - max_val = (prefix ? prefix : '') + ui.values[1] + (postfix ? postfix : ''); - - $label_1.html(min_val); - $label_2.html(max_val); - - if (fill) - $fill.val(min_val + ',' + max_val); - } - - reps = 0; - } - }); - - var $handles = $this.find('.ui-slider-handle'); - - $label_1.html((prefix ? prefix : '') + min_val + (postfix ? postfix : '')); - $handles.first().append($label_1); - - $label_2.html((prefix ? prefix : '') + max_val + (postfix ? postfix : '')); - $handles.last().append($label_2); - } - // Normal Slider - else { - - $this.slider({ - range: getValue($this, 'basic', 0) ? false : "min", - orientation: orientation, - min: min, - max: max, - value: value, - step: step, - slide: function(ev, ui) { - var val = (prefix ? prefix : '') + ui.value + (postfix ? postfix : ''); - - $label_1.html(val); - - - if (fill) - $fill.val(val); - - reps++; - }, - change: function(ev, ui) { - if (reps == 1) { - var val = (prefix ? prefix : '') + ui.value + (postfix ? postfix : ''); - - $label_1.html(val); - - if (fill) - $fill.val(val); - } - - reps = 0; - } - }); - - var $handles = $this.find('.ui-slider-handle'); - //$fill = $('
    '); - - $label_1.html((prefix ? prefix : '') + value + (postfix ? postfix : '')); - $handles.html($label_1); - - //$handles.parent().prepend( $fill ); - - //$fill.width($handles.get(0).style.left); - } - - }) - } - - - - /*------------- Color Slider widget---------------*/ - - function hexFromRGB(r, g, b) { - var hex = [ - r.toString(16), - g.toString(16), - b.toString(16) - ]; - $.each(hex, function(nr, val) { - if (val.length === 1) { - hex[nr] = "0" + val; - } - }); - return hex.join("").toUpperCase(); - } - - function refreshSwatch() { - var red = $("#slider-red").slider("value"), - green = $("#slider-green").slider("value"), - blue = $("#slider-blue").slider("value"), - hex = hexFromRGB(red, green, blue); - $("#slider-swatch").css("background-color", "#" + hex); - } - - - if ($.isFunction($.fn.slider)) { - - $(function() { - $("#slider-red, #slider-green, #slider-blue").slider({ - orientation: "horizontal", - range: "min", - max: 255, - value: 127, - slide: refreshSwatch, - change: refreshSwatch - }); - $("#slider-red").slider("value", 235); - $("#slider-green").slider("value", 70); - $("#slider-blue").slider("value", 60); - }); - } - - - - /*-------------------------------------*/ - - /*--------------------------------*/ - - - // Spinner - if ($.isFunction($.fn.spinner)) { - - $( "#spinner" ).spinner(); - - $( "#spinner2" ).spinner({ - min: 5, - max: 2500, - step: 25, - start: 1000, - numberFormat: "C" - }); - - - $( "#spinner3" ).spinner({ - spin: function( event, ui ) { - if ( ui.value > 10 ) { - $( this ).spinner( "value", -10 ); - return false; - } else if ( ui.value < -10 ) { - $( this ).spinner( "value", 10 ); - return false; - } - } - }); -} - /*------------------------------------*/ - - // tagsinput - if ($.isFunction($.fn.tagsinput)) { - - // categorize tags input - var i = -1, - colors = ['primary', 'info', 'warning', 'success']; - - colors = shuffleArray(colors); - - $("#tagsinput-2").tagsinput({ - tagClass: function() { - i++; - return "label label-" + colors[i % colors.length]; - } - }); - - - $(".mail_compose_to").tagsinput({ - tagClass: function() { - i++; - return "label label-" + colors[i % colors.length]; - } - }); - - - } - - // Just for demo purpose - function shuffleArray(array) { - for (var i = array.length - 1; i > 0; i--) { - var j = Math.floor(Math.random() * (i + 1)); - var temp = array[i]; - array[i] = array[j]; - array[j] = temp; - } - return array; - } - - /*----------------------------*/ - - - // datepicker - if ($.isFunction($.fn.datepicker)) { - $(".datepicker").each(function(i, e) { - var $this = $(e), - options = { - minViewMode: getValue($this, 'minViewMode', 0), - format: getValue($this, 'format', 'mm/dd/yyyy'), - startDate: getValue($this, 'startDate', ''), - endDate: getValue($this, 'endDate', ''), - daysOfWeekDisabled: getValue($this, 'disabledDays', ''), - startView: getValue($this, 'startView', 0) - }, - $nxt = $this.next(), - $prv = $this.prev(); - - - $this.datepicker(options); - - if ($nxt.is('.input-group-addon') && $nxt.has('a')) { - $nxt.on('click', function(ev) { - ev.preventDefault(); - $this.datepicker('show'); - }); - } - - if ($prv.is('.input-group-addon') && $prv.has('a')) { - $prv.on('click', function(ev) { - ev.preventDefault(); - - $this.datepicker('show'); - }); - } - }); - } - - - - /*-------------------------------------------*/ - - - - // Date Range Picker - if ($.isFunction($.fn.daterangepicker)) { - $(".daterange").each(function(i, e) { - // Change the range as you desire - var ranges = { - 'Today': [moment(), moment()], - 'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)], - 'Last 7 Days': [moment().subtract('days', 6), moment()], - 'Last 30 Days': [moment().subtract('days', 29), moment()], - 'This Month': [moment().startOf('month'), moment().endOf('month')], - 'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')] - }; - - var $this = $(e), - options = { - format: getValue($this, 'format', 'MM/DD/YYYY'), - timePicker: getValue($this, 'timePicker', false), - timePickerIncrement: getValue($this, 'timePickerIncrement', false), - separator: getValue($this, 'separator', ' - '), - }, - min_date = getValue($this, 'minDate', ''), - max_date = getValue($this, 'maxDate', ''), - start_date = getValue($this, 'startDate', ''), - end_date = getValue($this, 'endDate', ''); - - if ($this.hasClass('add-date-ranges')) { - options['ranges'] = ranges; - } - - if (min_date.length) { - options['minDate'] = min_date; - } - - if (max_date.length) { - options['maxDate'] = max_date; - } - - if (start_date.length) { - options['startDate'] = start_date; - } - - if (end_date.length) { - options['endDate'] = end_date; - } - - - $this.daterangepicker(options, function(start, end) { - var drp = $this.data('daterangepicker'); - - if ($this.hasClass('daterange-text')) { - $this.find('span').html(start.format(drp.format) + drp.separator + end.format(drp.format)); - } - }); - - if (typeof options['ranges'] == 'object') { - $this.data('daterangepicker').container.removeClass('show-calendar'); - } - }); - } - - - - - /*-------------------------------------*/ - - - // Timepicker - if ($.isFunction($.fn.timepicker)) { - $(".timepicker").each(function(i, e) { - var $this = $(e), - options = { - template: getValue($this, 'template', false), - showSeconds: getValue($this, 'showSeconds', false), - defaultTime: getValue($this, 'defaultTime', 'current'), - showMeridian: getValue($this, 'showMeridian', true), - minuteStep: getValue($this, 'minuteStep', 15), - secondStep: getValue($this, 'secondStep', 15) - }, - $nxt = $this.next(), - $prv = $this.prev(); - - $this.timepicker(options); - - if ($nxt.is('.input-group-addon') && $nxt.has('a')) { - $nxt.on('click', function(ev) { - ev.preventDefault(); - - $this.timepicker('showWidget'); - }); - } - - if ($prv.is('.input-group-addon') && $prv.has('a')) { - $prv.on('click', function(ev) { - ev.preventDefault(); - - $this.timepicker('showWidget'); - }); - } - }); - } - - - - /*-------------------------------------*/ - - - // DateTimepicker - if ($.isFunction($.fn.datetimepicker)) { - - $('.form_datetime').datetimepicker({ - //language: 'fr', - format: "yyyy-mm-dd hh:ii", - weekStart: 1, - todayBtn: 1, - autoclose: 1, - todayHighlight: 1, - startView: 2, - forceParse: 0, - showMeridian: 0 - }); - - - $('.form_datetime_meridian').datetimepicker({ - //language: 'fr', - format: "dd MM yyyy - hh:ii", - weekStart: 1, - todayBtn: 1, - autoclose: 1, - todayHighlight: 1, - startView: 2, - forceParse: 0, - showMeridian: 1 - }); - - - $('.form_datetime_lang').datetimepicker({ - language: 'fr', - format: "yyyy-mm-dd hh:ii", - weekStart: 1, - todayBtn: 1, - autoclose: 1, - todayHighlight: 1, - startView: 2, - forceParse: 0, - showMeridian: 0 - }); - - - /* $('.form_date').datetimepicker({ - weekStart: 1, - todayBtn: 1, - autoclose: 1, - todayHighlight: 1, - startView: 2, - minView: 2, - forceParse: 0 - }); - $('.form_time').datetimepicker({ - //language: 'fr', - weekStart: 1, - todayBtn: 1, - autoclose: 1, - todayHighlight: 1, - startView: 1, - minView: 0, - maxView: 1, - forceParse: 0 - });*/ - - } - - /*-------------------------------------*/ - - - - - - // Colorpicker - if ($.isFunction($.fn.colorpicker)) { - $(".colorpicker").each(function(i, e) { - var $this = $(e), - options = {}, - $nxt = $this.next(), - $prv = $this.prev(), - $view = $this.siblings('.input-group-addon').find('.sel-color'); - - $this.colorpicker(options); - - if ($nxt.is('.input-group-addon') && $nxt.has('a')) { - $nxt.on('click', function(ev) { - ev.preventDefault(); - - $this.colorpicker('show'); - }); - } - - if ($prv.is('.input-group-addon') && $prv.has('a')) { - $prv.on('click', function(ev) { - ev.preventDefault(); - - $this.colorpicker('show'); - }); - } - - if ($view.length) { - $this.on('changeColor', function(ev) { - - $view.css('background-color', ev.color.toHex()); - }); - - if ($this.val().length) { - $view.css('background-color', $this.val()); - } - } - }); - } - - - /*--------------------------------------*/ - - - // select2 - if ($.isFunction($.fn.select2)) { - - $("#s2example-1").select2({ - placeholder: 'Select your country...', - allowClear: true - }).on('select2-open', function() { - // Adding Custom Scrollbar - $(this).data('select2').results.addClass('overflow-hidden').perfectScrollbar(); - }); - - - $("#s2example-2").select2({ - placeholder: 'Choose your favorite US Countries', - allowClear: true - }).on('select2-open', function() { - // Adding Custom Scrollbar - $(this).data('select2').results.addClass('overflow-hidden').perfectScrollbar(); - }); - - - $("#s2example-4").select2({ - minimumInputLength: 1, - placeholder: 'Search', - ajax: { - url: "data/select2-remote-data.php", - dataType: 'json', - quietMillis: 100, - data: function(term, page) { - return { - limit: -1, - q: term - }; - }, - results: function(data, page) { - return { - results: data - } - } - }, - formatResult: function(student) { - return "
    " + student.name + "
    "; - }, - formatSelection: function(student) { - return student.name; - } - - }); - } - /*------------------------------------*/ - - - - - //multiselect start - - if ($.isFunction($.fn.multiSelect)) { - - $('#my_multi_select1').multiSelect(); - $('#my_multi_select2').multiSelect({ - selectableOptgroup: true - }); - - $('#my_multi_select3').multiSelect({ - selectableHeader: "", - selectionHeader: "", - afterInit: function(ms) { - var that = this, - $selectableSearch = that.$selectableUl.prev(), - $selectionSearch = that.$selectionUl.prev(), - selectableSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selectable:not(.ms-selected)', - selectionSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selection.ms-selected'; - - that.qs1 = $selectableSearch.quicksearch(selectableSearchString) - .on('keydown', function(e) { - if (e.which === 40) { - that.$selectableUl.focus(); - return false; - } - }); - - that.qs2 = $selectionSearch.quicksearch(selectionSearchString) - .on('keydown', function(e) { - if (e.which == 40) { - that.$selectionUl.focus(); - return false; - } - }); - }, - afterSelect: function() { - this.qs1.cache(); - this.qs2.cache(); - }, - afterDeselect: function() { - this.qs1.cache(); - this.qs2.cache(); - } - }); - - } - //multiselect end - - - - - - - - - - /*---------------------------------------*/ - - - if ($.isFunction($.fn.typeahead)) { - - // basic typeahead - - var substringMatcher = function(strs) { - return function findMatches(q, cb) { - var matches, substrRegex; - - // an array that will be populated with substring matches - matches = []; - - // regex used to determine if a string contains the substring `q` - substrRegex = new RegExp(q, 'i'); - - // iterate through the pool of strings and for any string that - // contains the substring `q`, add it to the `matches` array - $.each(strs, function(i, str) { - if (substrRegex.test(str)) { - // the typeahead jQuery plugin expects suggestions to a - // JavaScript object, refer to typeahead docs for more info - matches.push({ - value: str - }); - } - }); - - cb(matches); - }; - }; - - var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', - 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', - 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', - 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', - 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', - 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', - 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', - 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', - 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming' - ]; - - $('#typeahead-1').typeahead({ - hint: true, - highlight: true, - minLength: 1 - }, { - name: 'states', - displayKey: 'value', - source: substringMatcher(states) - }); - - - - // prefetch typeahead - - var names = new Bloodhound({ - datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), - queryTokenizer: Bloodhound.tokenizers.whitespace, - limit: 10, - prefetch: { - url: 'data/names.json', - filter: function(list) { - return $.map(list, function(name) { - return { - name: name - }; - }); - } - } - }); - - names.initialize(); - - $('#typeahead-2').typeahead(null, { - name: 'names', - displayKey: 'name', - source: names.ttAdapter() - }); - - - // remote data - - - var name_randomizer = new Bloodhound({ - datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), - queryTokenizer: Bloodhound.tokenizers.whitespace, - // You can also prefetch suggestions - // prefetch: 'data/typeahead-generate.php', - remote: 'data/typeahead-generate.php?q=%QUERY' - }); - - name_randomizer.initialize(); - - $('#typeahead-3').typeahead({ - hint: true, - highlight: true - }, { - name: 'string-randomizer', - displayKey: 'value', - source: name_randomizer.ttAdapter() - }); - - - // templating - - var oscar_movies = new Bloodhound({ - datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), - queryTokenizer: Bloodhound.tokenizers.whitespace, - remote: 'data/typeahead-hp-movies.php?q=%QUERY' - }); - - oscar_movies.initialize(); - - $('#typeahead-4').typeahead(null, { - name: 'oscar-movies', - displayKey: 'value', - source: oscar_movies.ttAdapter(), - templates: { - empty: [ - '
    ', - 'We cannot find this movie title', - '
    ' - ].join('\n'), - suggestion: Handlebars.compile('
    {{value}} — {{year}}
    ') - } - }) - .bind('typeahead:opened', function() { - $(this).data('ttTypeahead').dropdown.$menu.addClass('overflow-hidden').perfectScrollbar(); - }) - .on('keyup', function() { - $(this).data('ttTypeahead').dropdown.$menu.perfectScrollbar('update'); - }); - - } - /*------------------------------------*/ - - - - /*------------------------------------------*/ - - }; - - - - /*-------------------------------- - Widgets - --------------------------------*/ - ULTRA_SETTINGS.ultraWidgets = function() { - - /*notification widget*/ - var notif_widget = $(".notification-widget").height(); - $('.notification-widget').height(notif_widget).perfectScrollbar({ - suppressScrollX: true - }); - - }; - - - - /*-------------------------------- - weather widget - --------------------------------*/ - ULTRA_SETTINGS.ultraWidgetWeather = function() { - - /*notification widget*/ - /*var wid = $(".wid-weather"); - var notif_widget = $(".notification-widget").height(); - $('.notification-widget').height(notif_widget).perfectScrollbar({suppressScrollX: true}); - - $('.wid-weather').each( function () { - var days = $(this).find(".weekdays"); - var today = $(this).find(".today"); - - var height = days.height(); - if(days.height() < today.height()){ - height = today.height(); - } - - days.height(height); - today.height(height); - });*/ - - - $('.wid-weather .weekdays ul').perfectScrollbar({ - suppressScrollX: true - }); - - - }; - - - - - - /*-------------------------------- - To Do Task Widget - --------------------------------*/ - ULTRA_SETTINGS.ultraToDoWidget = function() { - - /*todo task widget*/ - $(".icheck-minimal-white.todo-task").on('ifChecked', function(event) { - $(this).parent().parent().addClass("checked"); - }); - $(".icheck-minimal-white.todo-task").on('ifUnchecked', function(event) { - $(this).parent().parent().removeClass("checked"); - }); - - $(".wid-all-tasks ul").perfectScrollbar({ - suppressScrollX: true - }); - - }; - - - - /*-------------------------------- - To Do Add Task Widget - --------------------------------*/ - ULTRA_SETTINGS.ultraToDoAddTaskWidget = function() { - - $(".wid-add-task input").on('keypress', function(e) { - if (e.keyCode == 13) { - var i = Math.random().toString(36).substring(7); - var msg = $(this).val(); - var msg = '
  • '; - $(this).parent().parent().find(".wid-all-tasks ul").append(msg); - $(this).val(""); - $(this).focus(); - ULTRA_SETTINGS.iCheck(); - ULTRA_SETTINGS.ultraToDoWidget(); - $(this).parent().parent().find(".wid-all-tasks ul").perfectScrollbar('update'); - } - }); - - }; - - - - - - - - /*-------------------------------- - Vector maps - --------------------------------*/ - ULTRA_SETTINGS.dbjvectorMap = function() { - - if ($.isFunction($.fn.vectorMap)) { - //@code_start - $(function() { - $('#db-world-map-markers').vectorMap({ - map: 'world_mill_en', - scaleColors: ['#1fb5ac', '#1fb5ac'], - normalizeFunction: 'polynomial', - hoverOpacity: 0.7, - hoverColor: false, - regionsSelectable: true, - markersSelectable: true, - markersSelectableOne: true, - updateSize: true, - onRegionOver: function(event, code) { - //console.log('region-over', code); - }, - onRegionOut: function(event, code) { - //console.log('region-out', code); - }, - onRegionClick: function(event, code) { - //console.log('region-click', code); - }, - onRegionSelected: function(event, code, isSelected, selectedRegions) { - //console.log('region-select', code, isSelected, selectedRegions); - if (window.localStorage) { - window.localStorage.setItem( - 'jvectormap-selected-regions', - JSON.stringify(selectedRegions) - ); - } - }, - - panOnDrag: true, - - focusOn: { - x: 0.5, - y: 0.5, - scale: 1.2, - animate: true - }, - - - regionStyle: { - initial: { - fill: '#aaaaaa', - 'fill-opacity': 1, - stroke: 'false', - 'stroke-width': 0, - 'stroke-opacity': 1 - }, - hover: { - fill: '#1fb5ac', - 'fill-opacity': 1, - cursor: 'pointer' - }, - selected: { - fill: '#1fb5ac' - }, - selectedHover: {} - }, - - - - markerStyle: { - initial: { - fill: '#fa8564', - stroke: '#ffffff', - r: 5 - }, - hover: { - stroke: '#FDB45C', - "stroke-width": 2, - cursor: 'pointer' - }, - selected: { - fill: '#FDB45C', - "stroke-width": 0, - }, - }, - backgroundColor: '#ffffff', - markers: [{ - latLng: [41.90, 12.45], - name: 'Vatican City' - }, { - latLng: [43.73, 7.41], - name: 'Monaco' - }, { - latLng: [-0.52, 166.93], - name: 'Nauru' - }, { - latLng: [-8.51, 179.21], - name: 'Tuvalu' - }, { - latLng: [43.93, 12.46], - name: 'San Marino' - }, { - latLng: [47.14, 9.52], - name: 'Liechtenstein' - }, { - latLng: [7.11, 171.06], - name: 'Marshall Islands' - }, { - latLng: [17.3, -62.73], - name: 'Saint Kitts and Nevis' - }, { - latLng: [3.2, 73.22], - name: 'Maldives' - }, { - latLng: [35.88, 14.5], - name: 'Malta' - }, { - latLng: [12.05, -61.75], - name: 'Grenada' - }, { - latLng: [13.16, -61.23], - name: 'Saint Vincent and the Grenadines' - }, { - latLng: [13.16, -59.55], - name: 'Barbados' - }, { - latLng: [17.11, -61.85], - name: 'Antigua and Barbuda' - }, { - latLng: [-4.61, 55.45], - name: 'Seychelles' - }, { - latLng: [7.35, 134.46], - name: 'Palau' - }, { - latLng: [42.5, 1.51], - name: 'Andorra' - }, { - latLng: [14.01, -60.98], - name: 'Saint Lucia' - }, { - latLng: [6.91, 158.18], - name: 'Federated States of Micronesia' - }, { - latLng: [1.3, 103.8], - name: 'Singapore' - }, { - latLng: [1.46, 173.03], - name: 'Kiribati' - }, { - latLng: [-21.13, -175.2], - name: 'Tonga' - }, { - latLng: [15.3, -61.38], - name: 'Dominica' - }, { - latLng: [-20.2, 57.5], - name: 'Mauritius' - }, { - latLng: [26.02, 50.55], - name: 'Bahrain' - }, { - latLng: [0.33, 6.73], - name: 'São Tomé and Príncipe' - }] - }); - }); - //@code_end - } - - }; - - - - - /*-------------------------------- - Sparkline Chart - Widgets - --------------------------------*/ - ULTRA_SETTINGS.widgetSparklineChart = function() { - - if ($.isFunction($.fn.sparkline)) { - - $('.wid_dynamicbar').sparkline([8.4, 9, 8.8, 8, 9.5, 9.2, 9.9, 9, 9, 8, 7, 8, 9, 8, 7, 9, 9, 9.5, 8, 9.5, 9.8], { - type: 'bar', - barColor: '#f5f5f5', - height: '60', - barWidth: '12', - barSpacing: 1, - }); - - $('.wid_linesparkline').sparkline([2000, 3454, 5454, 2323, 3432, 4656, 2897, 3545, 4232, 4656, 2897, 3545, 4232, 5434, 4656, 3567, 4878, 3676, 3787], { - type: 'line', - width: '100%', - height: '60', - lineWidth: 2, - lineColor: '#f5f5f5', - fillColor: 'rgba(255,255,255,0.2)', - highlightSpotColor: '#ffffff', - highlightLineColor: '#ffffff', - spotRadius: 3, - }); - - - // Bar + line composite charts - $('.wid_compositebar').sparkline([4, 6, 7, 7, 4, 3, 2, 4, 6, 7, 7, 8, 8, 4, 4, 3, 1, 4, 6, 5, 9], { - type: 'bar', - barColor: '#f5f5f5', - height: '60', - barWidth: '12', - barSpacing: 1, - }); - - $('.wid_compositebar').sparkline([4, 1, 5, 7, 9, 9, 8, 8, 4, 7, 8, 4, 7, 9, 9, 8, 8, 4, 2, 5, 6, 7], { - composite: true, - fillColor: 'rgba(153,114,181,0)', - type: 'line', - width: '100%', - height: '40', - lineWidth: 2, - lineColor: '#9972b5', - highlightSpotColor: '#fa8564', - highlightLineColor: '#9972b5', - spotRadius: 3, - }); - - - - } - - }; - - - - - - - - - // Element Attribute Helper - function getValue($el, data_var, default_val) { - if (typeof $el.data(data_var) != 'undefined') { - return $el.data(data_var); - } - - return default_val; - } - - - /****************************** - initialize respective scripts - *****************************/ - $(document).ready(function() { - ULTRA_SETTINGS.windowBasedLayout(); - ULTRA_SETTINGS.mainmenuScroll(); - ULTRA_SETTINGS.mainMenu(); - ULTRA_SETTINGS.mainmenuCollapsed(); - ULTRA_SETTINGS.pageTopBar(); - ULTRA_SETTINGS.otherScripts(); - ULTRA_SETTINGS.iCheck(); - ULTRA_SETTINGS.customDropZone(); - ULTRA_SETTINGS.formEditors(); - ULTRA_SETTINGS.extraFormSettings(); - ULTRA_SETTINGS.tooltipsPopovers(); - ULTRA_SETTINGS.nestableList(); - ULTRA_SETTINGS.uiCalendar(); - ULTRA_SETTINGS.tocifyScrollMenu(); - ULTRA_SETTINGS.loadPrettyPhoto(); - ULTRA_SETTINGS.jvectorMaps(); - ULTRA_SETTINGS.dataTablesInit(); - ULTRA_SETTINGS.jsTreeINIT(); - ULTRA_SETTINGS.breadcrumbAutoHidden(); - ULTRA_SETTINGS.chatAPI(); - ULTRA_SETTINGS.chatApiScroll(); - ULTRA_SETTINGS.chatApiWindow(); - ULTRA_SETTINGS.mailboxInbox(); - ULTRA_SETTINGS.ultraWidgets(); - ULTRA_SETTINGS.sectionBoxActions(); - ULTRA_SETTINGS.draggablePanels(); - ULTRA_SETTINGS.viewportElement(); - ULTRA_SETTINGS.searchPage(); - ULTRA_SETTINGS.ultraToDoAddTaskWidget(); - ULTRA_SETTINGS.ultraToDoWidget(); - ULTRA_SETTINGS.dbjvectorMap(); - ULTRA_SETTINGS.widgetSparklineChart(); - ULTRA_SETTINGS.ultraWidgetWeather(); - }); - - $(window).resize(function() { - ULTRA_SETTINGS.windowBasedLayout(); - //ULTRA_SETTINGS.mainmenuScroll(); - //ULTRA_SETTINGS.ultraWidgetWeather(); - ULTRA_SETTINGS.isotopeGallery(); - ULTRA_SETTINGS.loginPage(); - ULTRA_SETTINGS.widgetSparklineChart(); - }); - - $(window).load(function() { - ULTRA_SETTINGS.isotopeGallery(); - ULTRA_SETTINGS.loginPage(); - }); - -}); +/** + * @Package: Ultra Admin HTML Theme + * @Since: Ultra 1.0 + * This file is part of Ultra Admin Theme HTML package. + */ + + +jQuery(function($) { + + 'use strict'; + + var ULTRA_SETTINGS = window.ULTRA_SETTINGS || {}; + + + + + + /*-------------------------------- + Window Based Layout + --------------------------------*/ + ULTRA_SETTINGS.windowBasedLayout = function() { + var width = window.innerWidth; + //console.log(width); + + if ($("body").hasClass("chat-open") || $("body").hasClass("sidebar-collapse")) { + + ULTRA_SETTINGS.mainmenuCollapsed(); + + } else if (width < 1025) { + + // small window + $(".page-topbar").addClass("sidebar_shift").removeClass("chat_shift"); + $(".page-sidebar").addClass("collapseit").removeClass("expandit"); + $("#main-content").addClass("sidebar_shift").removeClass("chat_shift"); + $(".page-chatapi").removeClass("showit").addClass("hideit"); + $(".chatapi-windows").removeClass("showit").addClass("hideit"); + ULTRA_SETTINGS.mainmenuCollapsed(); + + } else { + + // large window + $(".page-topbar").removeClass("sidebar_shift chat_shift"); + $(".page-sidebar").removeClass("collapseit chat_shift"); + $("#main-content").removeClass("sidebar_shift chat_shift"); + ULTRA_SETTINGS.mainmenuScroll(); + } + + + } + + + + /*-------------------------------- + CHAT API + --------------------------------*/ + ULTRA_SETTINGS.chatAPI = function() { + + + $('.page-topbar .toggle_chat').on('click', function() { + var chatarea = $(".page-chatapi"); + var chatwindow = $(".chatapi-windows"); + var topbar = $(".page-topbar"); + var mainarea = $("#main-content"); + var menuarea = $(".page-sidebar"); + + if (chatarea.hasClass("hideit")) { + chatarea.addClass("showit").removeClass("hideit"); + chatwindow.addClass("showit").removeClass("hideit"); + topbar.addClass("chat_shift"); + mainarea.addClass("chat_shift"); + menuarea.addClass("chat_shift"); + ULTRA_SETTINGS.mainmenuCollapsed(); + } else { + chatarea.addClass("hideit").removeClass("showit"); + chatwindow.addClass("hideit").removeClass("showit"); + topbar.removeClass("chat_shift"); + mainarea.removeClass("chat_shift"); + menuarea.removeClass("chat_shift"); + //ULTRA_SETTINGS.mainmenuScroll(); + ULTRA_SETTINGS.windowBasedLayout(); + } + }); + + $('.page-topbar .sidebar_toggle').on('click', function() { + var chatarea = $(".page-chatapi"); + var chatwindow = $(".chatapi-windows"); + var topbar = $(".page-topbar"); + var mainarea = $("#main-content"); + var menuarea = $(".page-sidebar"); + + if (menuarea.hasClass("collapseit") || menuarea.hasClass("chat_shift")) { + menuarea.addClass("expandit").removeClass("collapseit").removeClass("chat_shift"); + topbar.removeClass("sidebar_shift").removeClass("chat_shift"); + mainarea.removeClass("sidebar_shift").removeClass("chat_shift"); + chatarea.addClass("hideit").removeClass("showit"); + chatwindow.addClass("hideit").removeClass("showit"); + ULTRA_SETTINGS.mainmenuScroll(); + } else { + menuarea.addClass("collapseit").removeClass("expandit").removeClass("chat_shift"); + topbar.addClass("sidebar_shift").removeClass("chat_shift"); + mainarea.addClass("sidebar_shift").removeClass("chat_shift"); + ULTRA_SETTINGS.mainmenuCollapsed(); + } + }); + + }; + + + /*-------------------------------- + CHAT API Scroll + --------------------------------*/ + ULTRA_SETTINGS.chatApiScroll = function() { + + var topsearch = $(".page-chatapi .search-bar").height(); + var height = window.innerHeight - topsearch; + $('.chat-wrapper').height(height).perfectScrollbar({ + suppressScrollX: true + }); + }; + + + /*-------------------------------- + CHAT API window + --------------------------------*/ + ULTRA_SETTINGS.chatApiWindow = function() { + + var chatarea = $(".page-chatapi"); + + $('.page-chatapi .user-row').on('click', function() { + + var name = $(this).find(".user-info h4 a").html(); + var img = $(this).find(".user-img a img").attr("src"); + var id = $(this).attr("data-user-id"); + var status = $(this).find(".user-info .status").attr("data-status"); + + if ($(this).hasClass("active")) { + $(this).toggleClass("active"); + + $(".chatapi-windows #user-window" + id).hide(); + + } else { + $(this).toggleClass("active"); + + if ($(".chatapi-windows #user-window" + id).length) { + + $(".chatapi-windows #user-window" + id).removeClass("minimizeit").show(); + + } else { + var msg = chatformat_msg('Wow! What a Beautiful theme!', 'receive', name); + msg += chatformat_msg('Yes! Ultra Admin Theme ;)', 'sent', 'You'); + var html = "
    "; + html += "
    " + name + "
    "; + html += "
    " + msg + "
    "; + html += "
    "; + html += "
    "; + $(".chatapi-windows").append(html); + } + } + + }); + + $(document).on('click', ".chatapi-windows .user-window .controlbar .closeit", function(e) { + var id = $(this).attr("data-user-id"); + $(".chatapi-windows #user-window" + id).hide(); + $(".page-chatapi .user-row#chat_user_" + id).removeClass("active"); + }); + + $(document).on('click', ".chatapi-windows .user-window .controlbar img, .chatapi-windows .user-window .controlbar .minimizeit", function(e) { + var id = $(this).attr("data-user-id"); + + if (!$(".chatapi-windows #user-window" + id).hasClass("minimizeit")) { + $(".chatapi-windows #user-window" + id).addClass("minimizeit"); + ULTRA_SETTINGS.tooltipsPopovers(); + } else { + $(".chatapi-windows #user-window" + id).removeClass("minimizeit"); + } + + }); + + $(document).on('keypress', ".chatapi-windows .user-window .typearea input", function(e) { + if (e.keyCode == 13) { + var id = $(this).attr("data-user-id"); + var msg = $(this).val(); + msg = chatformat_msg(msg, 'sent', 'You'); + $(".chatapi-windows #user-window" + id + " .chatarea").append(msg); + $(this).val(""); + $(this).focus(); + } + $(".chatapi-windows #user-window" + id + " .chatarea").perfectScrollbar({ + suppressScrollX: true + }); + }); + + }; + + function chatformat_msg(msg, type, name) { + var d = new Date(); + var h = d.getHours(); + var m = d.getMinutes(); + return "
    " + name + "" + msg + "" + h + ":" + m + "
    "; + } + + + /*-------------------------------- + Login Page + --------------------------------*/ + ULTRA_SETTINGS.loginPage = function() { + + var height = window.innerHeight; + var formheight = $("#login").height(); + var newheight = (height - formheight) / 2; + //console.log(height+" - "+ formheight + " / "+ newheight); + $('#login').css('margin-top', +newheight + 'px'); + + if ($('#login #user_login').length) { + var d = document.getElementById('user_login'); + d.focus(); + } + + }; + + + + /*-------------------------------- + Search Page + --------------------------------*/ + ULTRA_SETTINGS.searchPage = function() { + + $('.search_data .tab-pane').perfectScrollbar({ + suppressScrollX: true + }); + var search = $(".search-page-input"); + if (search.length) { + search.focus(); + } + }; + + + /*-------------------------------- + Viewport Checker + --------------------------------*/ + ULTRA_SETTINGS.viewportElement = function() { + + if ($.isFunction($.fn.viewportChecker)) { + + $('.inviewport').viewportChecker({ + callbackFunction: function(elem, action) { + //setTimeout(function(){ + //elem.html((action == "add") ? 'Callback with 500ms timeout: added class' : 'Callback with 500ms timeout: removed class'); + //},500); + } + }); + + + $('.number_counter').viewportChecker({ + classToAdd: 'start_timer', + offset: 10, + callbackFunction: function(elem) { + $('.start_timer:not(.counted)').each(count); + //$(elem).removeClass('number_counter'); + } + }); + + } + + // start count + function count(options) { + var $this = $(this); + options = $.extend({}, options || {}, $this.data('countToOptions') || {}); + $this.countTo(options).addClass("counted"); + } + }; + + + + /*-------------------------------- + Sortable / Draggable Panels + --------------------------------*/ + ULTRA_SETTINGS.draggablePanels = function() { + + if ($.isFunction($.fn.sortable)) { + $(".sort_panel").sortable({ + connectWith: ".sort_panel", + handle: "header.panel_header", + cancel: ".panel_actions", + placeholder: "portlet-placeholder" + }); + } + }; + + + + /*-------------------------------- + Breadcrumb autoHidden + --------------------------------*/ + ULTRA_SETTINGS.breadcrumbAutoHidden = function() { + + $('.breadcrumb.auto-hidden a').on('mouseover', function() { + $(this).removeClass("collapsed"); + }); + $('.breadcrumb.auto-hidden a').on('mouseout', function() { + $(this).addClass("collapsed"); + }); + + }; + + + + + + /*-------------------------------- + Section Box Actions + --------------------------------*/ + ULTRA_SETTINGS.sectionBoxActions = function() { + + $('section.box .actions .box_toggle').on('click', function() { + + var content = $(this).parent().parent().parent().find(".content-body"); + if (content.hasClass("collapsed")) { + content.removeClass("collapsed").slideDown(500); + $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); + } else { + content.addClass("collapsed").slideUp(500); + $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); + } + + }); + + $('section.box .actions .box_close').on('click', function() { + content = $(this).parent().parent().parent().remove(); + }); + + + + }; + + + + + + + /*-------------------------------- + Main Menu Scroll + --------------------------------*/ + ULTRA_SETTINGS.mainmenuScroll = function() { + + //console.log("expand scroll menu"); + + var topbar = $(".page-topbar").height(); + var projectinfo = $(".project-info").innerHeight(); + + var height = window.innerHeight - topbar - projectinfo; + + $('#main-menu-wrapper').height(height).perfectScrollbar({ + suppressScrollX: true + }); + $("#main-menu-wrapper .wraplist").height('auto'); + + + /*show first sub menu of open menu item only - opened after closed*/ + // > in the selector is used to select only immediate elements and not the inner nested elements. + $("li.open > .sub-menu").attr("style", "display:block;"); + + + }; + + + /*-------------------------------- + Collapsed Main Menu + --------------------------------*/ + ULTRA_SETTINGS.mainmenuCollapsed = function() { + + if ($(".page-sidebar.chat_shift #main-menu-wrapper").length > 0 || $(".page-sidebar.collapseit #main-menu-wrapper").length > 0) { + //console.log("collapse menu"); + var topbar = $(".page-topbar").height(); + var windowheight = window.innerHeight; + var minheight = windowheight - topbar; + var fullheight = $(".page-container #main-content .wrapper").height(); + + var height = fullheight; + + if (fullheight < minheight) { + height = minheight; + } + + $('#main-menu-wrapper').perfectScrollbar('destroy'); + + $('.page-sidebar.chat_shift #main-menu-wrapper .wraplist, .page-sidebar.collapseit #main-menu-wrapper .wraplist').height(height); + + /*hide sub menu of open menu item*/ + $("li.open .sub-menu").attr("style", ""); + + } + + }; + + + + + /*-------------------------------- + Main Menu + --------------------------------*/ + ULTRA_SETTINGS.mainMenu = function() { + $('#main-menu-wrapper li a').click(function(e) { + + if ($(this).next().hasClass('sub-menu') === false) { + return; + } + + var parent = $(this).parent().parent(); + var sub = $(this).next(); + + parent.children('li.open').children('.sub-menu').slideUp(200); + parent.children('li.open').children('a').children('.arrow').removeClass('open'); + parent.children('li').removeClass('open'); + + if (sub.is(":visible")) { + $(this).find(".arrow").removeClass("open"); + sub.slideUp(200); + } else { + $(this).parent().addClass("open"); + $(this).find(".arrow").addClass("open"); + sub.slideDown(200); + } + + }); + + $("body").click(function(e) { + $(".page-sidebar.collapseit .wraplist li.open .sub-menu").attr("style",""); + $(".page-sidebar.collapseit .wraplist li.open").removeClass("open"); + $(".page-sidebar.chat_shift .wraplist li.open .sub-menu").attr("style",""); + $(".page-sidebar.chat_shift .wraplist li.open").removeClass("open"); + }); + + }; + + + + /*-------------------------------- + Mailbox + --------------------------------*/ + ULTRA_SETTINGS.mailboxInbox = function() { + + $('.mail_list table .star i').click(function(e) { + $(this).toggleClass("fa-star fa-star-o"); + }); + + $('.mail_list .open-view').click(function(e) { + window.location = 'mail-view.html'; + }); + + $('.mail_view_info .labels .cc').click(function(e) { + var ele = $(".mail_compose_cc"); + if (ele.is(":visible")) { + ele.hide(); + } else { + ele.show(); + } + }); + + $('.mail_view_info .labels .bcc').click(function(e) { + var ele = $(".mail_compose_bcc"); + if (ele.is(":visible")) { + ele.hide(); + } else { + ele.show(); + } + }); + + }; + + + + + /*-------------------------------- + Top Bar + --------------------------------*/ + ULTRA_SETTINGS.pageTopBar = function() { + $('.page-topbar li.searchform .input-group-addon').click(function(e) { + $(this).parent().parent().toggleClass("focus"); + $(this).parent().find("input").focus(); + }); + + $('.page-topbar li .dropdown-menu .list').perfectScrollbar({ + suppressScrollX: true + }); + + }; + + + /*-------------------------------- + Extra form settings + --------------------------------*/ + ULTRA_SETTINGS.extraFormSettings = function() { + + // transparent input group focus/blur + $('.input-group .form-control').focus(function(e) { + $(this).parent().find(".input-group-addon").addClass("input-focus"); + $(this).parent().find(".input-group-btn").addClass("input-focus"); + }); + + $('.input-group .form-control').blur(function(e) { + $(this).parent().find(".input-group-addon").removeClass("input-focus"); + $(this).parent().find(".input-group-btn").removeClass("input-focus"); + }); + + }; + + + + /*-------------------------------- + js tree + --------------------------------*/ + ULTRA_SETTINGS.jsTreeINIT = function() { + + + if ($.isFunction($.fn.jstree)) { + $(function() { + var to = false; + $('#treedata_q').keyup(function() { + if (to) { + clearTimeout(to); + } + to = setTimeout(function() { + var v = $('#treedata_q').val(); + $('#jstree_treedata').jstree(true).search(v); + }, 250); + }); + + $('#jstree_treedata') + .jstree({ + "core": { + "animation": 0, + "check_callback": true, + "themes": { + "stripes": true + }, + 'data': { + 'url': function(node) { + return node.id === '#' ? 'data/ajax_demo_roots_jstree.json' : 'data/ajax_demo_children_jstree.json'; + }, + 'data': function(node) { + return { + 'id': node.id + }; + } + } + }, + "types": { + "#": { + "max_children": 1, + "max_depth": 4, + "valid_children": ["root"] + }, + "root": { + "icon": "assets/plugins/jstree/images/tree_icon.png", + "valid_children": ["default"] + }, + "default": { + "valid_children": ["default", "file"] + }, + "file": { + "icon": "fa fa-file", + "valid_children": [] + } + }, + "checkbox": { + "keep_selected_style": false + }, + "plugins": ["checkbox", "contextmenu", "dnd", "search", "sort", "state", "types", "unique", "wholerow"] + }); + }); + + } + }; + + + + /*-------------------------------- + Vector maps + --------------------------------*/ + ULTRA_SETTINGS.jvectorMaps = function() { + + if ($.isFunction($.fn.vectorMap)) { + + if ($("#world-map-markers").length) { + //@code_start + $(function() { + $('#world-map-markers').vectorMap({ + map: 'world_mill_en', + scaleColors: ['#1fb5ac', '#1fb5ac'], + normalizeFunction: 'polynomial', + hoverOpacity: 0.7, + hoverColor: false, + regionsSelectable: true, + markersSelectable: true, + markersSelectableOne: true, + + onRegionOver: function(event, code) { + //console.log('region-over', code); + }, + onRegionOut: function(event, code) { + //console.log('region-out', code); + }, + onRegionClick: function(event, code) { + //console.log('region-click', code); + }, + onRegionSelected: function(event, code, isSelected, selectedRegions) { + //console.log('region-select', code, isSelected, selectedRegions); + if (window.localStorage) { + window.localStorage.setItem( + 'jvectormap-selected-regions', + JSON.stringify(selectedRegions) + ); + } + }, + + panOnDrag: true, + + focusOn: { + x: 0.5, + y: 0.5, + scale: 1, + animate: true + }, + + + regionStyle: { + initial: { + fill: 'white', + 'fill-opacity': 1, + stroke: 'none', + 'stroke-width': 0, + 'stroke-opacity': 1 + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + }, + selectedHover: {} + }, + + + + markerStyle: { + initial: { + fill: '#9972b5', + stroke: '#9972b5', + r: 6 + }, + hover: { + stroke: '#FDB45C', + "stroke-width": 2, + cursor: 'pointer' + }, + selected: { + fill: '#FDB45C', + "stroke-width": 0, + }, + }, + backgroundColor: '#1fb5ac', + markers: [{ + latLng: [41.90, 12.45], + name: 'Vatican City' + }, { + latLng: [43.73, 7.41], + name: 'Monaco' + }, { + latLng: [-0.52, 166.93], + name: 'Nauru' + }, { + latLng: [-8.51, 179.21], + name: 'Tuvalu' + }, { + latLng: [43.93, 12.46], + name: 'San Marino' + }, { + latLng: [47.14, 9.52], + name: 'Liechtenstein' + }, { + latLng: [7.11, 171.06], + name: 'Marshall Islands' + }, { + latLng: [17.3, -62.73], + name: 'Saint Kitts and Nevis' + }, { + latLng: [3.2, 73.22], + name: 'Maldives' + }, { + latLng: [35.88, 14.5], + name: 'Malta' + }, { + latLng: [12.05, -61.75], + name: 'Grenada' + }, { + latLng: [13.16, -61.23], + name: 'Saint Vincent and the Grenadines' + }, { + latLng: [13.16, -59.55], + name: 'Barbados' + }, { + latLng: [17.11, -61.85], + name: 'Antigua and Barbuda' + }, { + latLng: [-4.61, 55.45], + name: 'Seychelles' + }, { + latLng: [7.35, 134.46], + name: 'Palau' + }, { + latLng: [42.5, 1.51], + name: 'Andorra' + }, { + latLng: [14.01, -60.98], + name: 'Saint Lucia' + }, { + latLng: [6.91, 158.18], + name: 'Federated States of Micronesia' + }, { + latLng: [1.3, 103.8], + name: 'Singapore' + }, { + latLng: [1.46, 173.03], + name: 'Kiribati' + }, { + latLng: [-21.13, -175.2], + name: 'Tonga' + }, { + latLng: [15.3, -61.38], + name: 'Dominica' + }, { + latLng: [-20.2, 57.5], + name: 'Mauritius' + }, { + latLng: [26.02, 50.55], + name: 'Bahrain' + }, { + latLng: [0.33, 6.73], + name: 'São Tomé and Príncipe' + }] + }); + }); + //@code_end + } + + var mapid = ""; + mapid = $('#europe_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'europe_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 1, + animate: true + }, + }); + } // Europe + mapid = $('#in_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'in_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // India + mapid = $('#us_aea_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'us_aea_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // USA + mapid = $('#pt_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'pt_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Portugal + mapid = $('#cn_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'cn_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // China + mapid = $('#nz_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'nz_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // New Zealand + mapid = $('#no_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'no_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Norway + mapid = $('#es_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'es_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Spain + mapid = $('#au_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'au_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Australia + mapid = $('#fr_regions_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'fr_regions_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // France - Regions + mapid = $('#th_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'th_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Thailand + mapid = $('#co_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'co_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Colombia + mapid = $('#be_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'be_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Belgium + mapid = $('#ar_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'ar_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Argentina + mapid = $('#ve_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 've_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Venezuela + mapid = $('#it_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'it_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Italy + mapid = $('#dk_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'dk_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Denmark + mapid = $('#at_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'at_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Austria + mapid = $('#ca_lcc_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'ca_lcc_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Canada + mapid = $('#nl_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'nl_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Netherlands + mapid = $('#se_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'se_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Sweden + mapid = $('#pl_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'pl_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Poland + mapid = $('#de_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'de_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Germany + mapid = $('#fr_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'fr_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // France - Departments + mapid = $('#za_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'za_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // South Africa + mapid = $('#ch_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'ch_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Switzerland + mapid = $('#us-ny-newyork_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'us-ny-newyork_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // New York City + mapid = $('#us-il-chicago_mill_en-map'); + if (mapid.length) { + mapid.vectorMap({ + map: 'us-il-chicago_mill_en', + regionsSelectable: true, + backgroundColor: '#1fb5ac', + regionStyle: { + initial: { + fill: 'white', + stroke: 'none', + }, + hover: { + fill: '#fa8564', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#fa8564' + } + }, + focusOn: { + x: 0, + y: 0, + scale: 5, + animate: true + }, + }); + } // Chicago + + } + + }; + + + /*-------------------------------- + DataTables + --------------------------------*/ + ULTRA_SETTINGS.dataTablesInit = function() { + + if ($.isFunction($.fn.dataTable)) { + + /*--- start ---*/ + + $("#example-1").dataTable({ + responsive: true, + aLengthMenu: [ + [10, 25, 50, 100, -1], + [10, 25, 50, 100, "All"] + ] + }); + + /*--- end ---*/ + + /*--- start ---*/ + + $('#example-4').dataTable(); + + /*--- end ---*/ + + + + /* Set the defaults for DataTables initialisation */ + $.extend(true, $.fn.dataTable.defaults, { + "sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-12'p i>>", + "sPaginationType": "bootstrap", + "oLanguage": { + "sLengthMenu": "_MENU_" + } + }); + + + /* Default class modification */ + $.extend($.fn.dataTableExt.oStdClasses, { + "sWrapper": "dataTables_wrapper form-inline" + }); + + + /* API method to get paging information */ + $.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings) { + return { + "iStart": oSettings._iDisplayStart, + "iEnd": oSettings.fnDisplayEnd(), + "iLength": oSettings._iDisplayLength, + "iTotal": oSettings.fnRecordsTotal(), + "iFilteredTotal": oSettings.fnRecordsDisplay(), + "iPage": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength), + "iTotalPages": oSettings._iDisplayLength === -1 ? + 0 : Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength) + }; + }; + + + /* Bootstrap style pagination control */ + $.extend($.fn.dataTableExt.oPagination, { + "bootstrap": { + "fnInit": function(oSettings, nPaging, fnDraw) { + var oLang = oSettings.oLanguage.oPaginate; + var fnClickHandler = function(e) { + e.preventDefault(); + if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) { + fnDraw(oSettings); + } + }; + + $(nPaging).addClass('').append( + '
      ' + + '' + + '' + + '
    ' + ); + var els = $('a', nPaging); + $(els[0]).bind('click.DT', { + action: "previous" + }, fnClickHandler); + $(els[1]).bind('click.DT', { + action: "next" + }, fnClickHandler); + }, + + "fnUpdate": function(oSettings, fnDraw) { + var iListLength = 5; + var oPaging = oSettings.oInstance.fnPagingInfo(); + var an = oSettings.aanFeatures.p; + var i, ien, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2); + + if (oPaging.iTotalPages < iListLength) { + iStart = 1; + iEnd = oPaging.iTotalPages; + } else if (oPaging.iPage <= iHalf) { + iStart = 1; + iEnd = iListLength; + } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) { + iStart = oPaging.iTotalPages - iListLength + 1; + iEnd = oPaging.iTotalPages; + } else { + iStart = oPaging.iPage - iHalf + 1; + iEnd = iStart + iListLength - 1; + } + + for (i = 0, ien = an.length; i < ien; i++) { + // Remove the middle elements + $('li:gt(0)', an[i]).filter(':not(:last)').remove(); + + // Add the new list items and their event handlers + for (j = iStart; j <= iEnd; j++) { + sClass = (j == oPaging.iPage + 1) ? 'class="active"' : ''; + $('
  • ' + j + '
  • ') + .insertBefore($('li:last', an[i])[0]) + .bind('click', function(e) { + e.preventDefault(); + oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength; + fnDraw(oSettings); + }); + } + + // Add / remove disabled classes from the static elements + if (oPaging.iPage === 0) { + $('li:first', an[i]).addClass('disabled'); + } else { + $('li:first', an[i]).removeClass('disabled'); + } + + if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) { + $('li:last', an[i]).addClass('disabled'); + } else { + $('li:last', an[i]).removeClass('disabled'); + } + } + } + } + }); + + + /* + * TableTools Bootstrap compatibility + * Required TableTools 2.1+ + */ + + // Set the classes that TableTools uses to something suitable for Bootstrap + $.extend(true, $.fn.DataTable.TableTools.classes, { + "container": "DTTT ", + "buttons": { + "normal": "btn btn-white", + "disabled": "disabled" + }, + "collection": { + "container": "DTTT_dropdown dropdown-menu", + "buttons": { + "normal": "", + "disabled": "disabled" + } + }, + "print": { + "info": "DTTT_print_info modal" + }, + "select": { + "row": "active" + } + }); + + // Have the collection use a bootstrap compatible dropdown + $.extend(true, $.fn.DataTable.TableTools.DEFAULTS.oTags, { + "collection": { + "container": "ul", + "button": "li", + "liner": "a" + } + }); + + + /* Table initialisation */ + $(document).ready(function() { + var responsiveHelper = undefined; + var breakpointDefinition = { + tablet: 1024, + phone: 480 + }; + var tableElement = $('#example'); + + tableElement.dataTable({ + "sDom": "<'row'<'col-md-6'l T><'col-md-6'f>r>t<'row'<'col-md-12'p i>>", + "oTableTools": { + "aButtons": [{ + "sExtends": "collection", + "sButtonText": "", + "aButtons": ["csv", "xls", "pdf", "copy"] + }] + }, + "sPaginationType": "bootstrap", + "aoColumnDefs": [{ + 'bSortable': false, + 'aTargets': [0] + }], + "aaSorting": [ + [1, "asc"] + ], + "oLanguage": { + "sLengthMenu": "_MENU_ ", + "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries" + }, + bAutoWidth: false, + fnPreDrawCallback: function() { + // Initialize the responsive datatables helper once. + if (!responsiveHelper) { + //responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition); + } + }, + fnRowCallback: function(nRow) { + //responsiveHelper.createExpandIcon(nRow); + }, + fnDrawCallback: function(oSettings) { + //responsiveHelper.respond(); + } + }); + + $('#example_wrapper .dataTables_filter input').addClass("input-medium "); // modify table search input + $('#example_wrapper .dataTables_length select').addClass("select2-wrapper col-md-12"); // modify table per page dropdown + + + + $('#example input').click(function() { + $(this).parent().parent().parent().toggleClass('row_selected'); + }); + + + /* + * Insert a 'details' column to the table + */ + var nCloneTh = document.createElement('th'); + var nCloneTd = document.createElement('td'); + nCloneTd.innerHTML = ''; + nCloneTd.className = "center"; + + $('#example2 thead tr').each(function() { + this.insertBefore(nCloneTh, this.childNodes[0]); + }); + + $('#example2 tbody tr').each(function() { + this.insertBefore(nCloneTd.cloneNode(true), this.childNodes[0]); + }); + + /* + * Initialse DataTables, with no sorting on the 'details' column + */ + var oTable = $('#example2').dataTable({ + "sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-12'p i>>", + "aaSorting": [], + "oLanguage": { + "sLengthMenu": "_MENU_ ", + "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries" + }, + }); + + + $("div.toolbar").html('
    '); + + + $('#example2_wrapper .dataTables_filter input').addClass("input-medium "); + $('#example2_wrapper .dataTables_length select').addClass("select2-wrapper col-md-12"); + + /* Add event listener for opening and closing details + * Note that the indicator for showing which row is open is not controlled by DataTables, + * rather it is done here + */ + $('#example2 tbody td i').on('click', function() { + var nTr = $(this).parents('tr')[0]; + if (oTable.fnIsOpen(nTr)) { + /* This row is already open - close it */ + this.removeClass = "fa fa-plus-circle"; + this.addClass = "fa fa-minus-circle"; + oTable.fnClose(nTr); + } else { + /* Open this row */ + this.removeClass = "fa fa-minus-circle"; + this.addClass = "fa fa-plus-circle"; + oTable.fnOpen(nTr, fnFormatDetails(oTable, nTr), 'details'); + } + + + /* Formating function for row details */ + function fnFormatDetails(oTable, nTr) { + var aData = oTable.fnGetData(nTr); + var sOut = ''; + sOut += ''; + sOut += ''; + sOut += ''; + sOut += '
    Rendering engine:' + aData[1] + ' ' + aData[4] + '
    Link to source:Could provide a link here
    Extra info:And any further details here (images etc)
    '; + + return sOut; + } + + }); + + }); + + + + + + } + }; + + + + /*-------------------------------- + Pretty Photo + --------------------------------*/ + ULTRA_SETTINGS.loadPrettyPhoto = function() { + + if ($.isFunction($.fn.prettyPhoto)) { + //Pretty Photo + $("a[rel^='prettyPhoto']").prettyPhoto({ + social_tools: false + }); + } + }; + + + + + /*-------------------------------- + Gallery + --------------------------------*/ + ULTRA_SETTINGS.isotopeGallery = function() { + if ($.isFunction($.fn.isotope)) { + + var $portfolio_selectors = $('.portfolio-filter >li>a'); + var $portfolio = $('.portfolio-items'); + $portfolio.isotope({ + itemSelector: '.portfolio-item', + layoutMode: 'sloppyMasonry' + }); + + $portfolio_selectors.on('click', function() { + $portfolio_selectors.removeClass('active'); + $(this).addClass('active'); + var selector = $(this).attr('data-filter'); + $portfolio.isotope({ + filter: selector + }); + return false; + }); + + + } + }; + + + /*-------------------------------- + Tocify + --------------------------------*/ + ULTRA_SETTINGS.tocifyScrollMenu = function() { + if ($.isFunction($.fn.tocify)) { + var toc = $("#toc").tocify({ + selectors: "h2,h3,h4,h5", + context: ".tocify-content", + extendPage: false + }).data("toc-tocify"); + } + }; + + + + /*-------------------------------- + Full Calendar + --------------------------------*/ + ULTRA_SETTINGS.uiCalendar = function() { + + + if ($.isFunction($.fn.fullCalendar)) { + + /* initialize the external events + -----------------------------------------------------------------*/ + + $('#external-events .fc-event').each(function() { + + // create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/) + // it doesn't need to have a start or end + var eventObject = { + title: $.trim($(this).text()) // use the element's text as the event title + }; + + // store the Event Object in the DOM element so we can get to it later + $(this).data('eventObject', eventObject); + + // make the event draggable using jQuery UI + $(this).draggable({ + zIndex: 999, + revert: true, // will cause the event to go back to its + revertDuration: 0 // original position after the drag + }); + + }); + + + /* initialize the calendar + -----------------------------------------------------------------*/ + + var date = new Date(); + var d = date.getDate(); + var m = date.getMonth(); + var y = date.getFullYear(); + + $('#calendar').fullCalendar({ + header: { + left: 'prev,next today', + center: 'title', + right: 'month,basicWeek,basicDay' + }, + editable: true, + eventLimit: true, // allow "more" link when too many events + droppable: true, // this allows things to be dropped onto the calendar !!! + drop: function(date, allDay) { // this function is called when something is dropped + + // retrieve the dropped element's stored Event Object + var originalEventObject = $(this).data('eventObject'); + + // we need to copy it, so that multiple events don't have a reference to the same object + var copiedEventObject = $.extend({}, originalEventObject); + + // assign it the date that was reported + copiedEventObject.start = date; + copiedEventObject.allDay = allDay; + + // render the event on the calendar + // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) + $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); + + // is the "remove after drop" checkbox checked? + if ($('#drop-remove').is(':checked')) { + // if so, remove the element from the "Draggable Events" list + $(this).remove(); + } + + }, + events: [{ + title: 'All Day Event', + start: new Date(y, m, 1) + }, { + title: 'Long Event', + start: new Date(y, m, d - 5), + end: new Date(y, m, d - 2) + }, { + id: 999, + title: 'Repeating Event', + start: new Date(y, m, d - 3, 16, 0), + allDay: false + }, { + id: 999, + title: 'Repeating Event', + start: new Date(y, m, d + 4, 16, 0), + allDay: false + }, { + title: 'Meeting', + start: new Date(y, m, d, 10, 30), + allDay: false + }, { + title: 'Lunch', + start: new Date(y, m, d, 12, 0), + end: new Date(y, m, d, 14, 0), + allDay: false + }, { + title: 'Birthday Party', + start: new Date(y, m, d + 1, 19, 0), + end: new Date(y, m, d + 1, 22, 30), + allDay: false + }, { + title: 'Click for Google', + start: new Date(y, m, 28), + end: new Date(y, m, 29), + url: 'http://google.com/' + }] + }); + + + + + + /*Add new event*/ + // Form to add new event + + $("#add_event_form").on('submit', function(ev) { + ev.preventDefault(); + + var $event = $(this).find('.new-event-form'), + event_name = $event.val(); + + if (event_name.length >= 3) { + + var newid = "new" + "" + Math.random().toString(36).substring(7); + // Create Event Entry + $("#external-events").append( + '
    ' + event_name + '
    ' + ); + + + var eventObject = { + title: $.trim($("#" + newid).text()) // use the element's text as the event title + }; + + // store the Event Object in the DOM element so we can get to it later + $("#" + newid).data('eventObject', eventObject); + + // Reset draggable + $("#" + newid).draggable({ + revert: true, + revertDuration: 0, + zIndex: 999 + }); + + // Reset input + $event.val('').focus(); + } else { + $event.focus(); + } + }); + + + + } + + }; + + + + /*-------------------------------- + Sortable (Nestable) List + --------------------------------*/ + ULTRA_SETTINGS.nestableList = function() { + + $("#nestableList-1").on('stop.uk.nestable', function(ev) { + var serialized = $(this).data('nestable').serialize(), + str = ''; + + str = nestableIterate(serialized, 0); + + $("#nestableList-1-ev").val(str); + }); + + + function nestableIterate(items, depth) { + var str = ''; + + if (!depth) + depth = 0; + + //console.log(items); + + jQuery.each(items, function(i, obj) { + str += '[ID: ' + obj.itemId + ']\t' + nestableRepeat('—', depth + 1) + ' ' + obj.item; + str += '\n'; + + if (obj.children) { + str += nestableIterate(obj.children, depth + 1); + } + }); + + return str; + } + + function nestableRepeat(s, n) { + var a = []; + while (a.length < n) { + a.push(s); + } + return a.join(''); + } + }; + + + + + + + + + + /*-------------------------------- + Tooltips & Popovers + --------------------------------*/ + ULTRA_SETTINGS.tooltipsPopovers = function() { + + $('[rel="tooltip"]').each(function() { + var animate = $(this).attr("data-animate"); + var colorclass = $(this).attr("data-color-class"); + $(this).tooltip({ + template: '
    ' + }); + }); + + $('[rel="popover"]').each(function() { + var animate = $(this).attr("data-animate"); + var colorclass = $(this).attr("data-color-class"); + $(this).popover({ + template: '

    ' + }); + }); + + }; + + + + + + /*-------------------------------- + iCheck + --------------------------------*/ + ULTRA_SETTINGS.iCheck = function() { + + + + if ($.isFunction($.fn.iCheck)) { + + + $('input[type="checkbox"].iCheck').iCheck({ + checkboxClass: 'icheckbox_minimal', + radioClass: 'iradio_minimal', + increaseArea: '20%' + }); + + + var x; + var colors = ["-green", "-red", "-yellow", "-blue", "-aero", "-orange", "-grey", "-pink", "-purple","-white"]; + + for (x = 0; x < colors.length; x++) { + + if (x == 0) { + $('input.icheck-minimal').iCheck({ + checkboxClass: 'icheckbox_minimal' + colors[x], + radioClass: 'iradio_minimal' + colors[x], + increaseArea: '20%' + }); + + $('input.skin-square').iCheck({ + checkboxClass: 'icheckbox_square' + colors[x], + radioClass: 'iradio_square' + colors[x], + increaseArea: '20%' + }); + + $('input.skin-flat').iCheck({ + checkboxClass: 'icheckbox_flat' + colors[x], + radioClass: 'iradio_flat' + colors[x], + }); + + + $('input.skin-line').each(function() { + var self = $(this), + label = self.next(), + label_text = label.text(); + + label.remove(); + self.iCheck({ + checkboxClass: 'icheckbox_line' + colors[x], + radioClass: 'iradio_line' + colors[x], + insert: '
    ' + label_text + }); + }); + + } // end x = 0 + + $('input.icheck-minimal' + colors[x]).iCheck({ + checkboxClass: 'icheckbox_minimal' + colors[x], + radioClass: 'iradio_minimal' + colors[x], + increaseArea: '20%' + }); + + + $('input.skin-square' + colors[x]).iCheck({ + checkboxClass: 'icheckbox_square' + colors[x], + radioClass: 'iradio_square' + colors[x], + increaseArea: '20%' + }); + + + $('input.skin-flat' + colors[x]).iCheck({ + checkboxClass: 'icheckbox_flat' + colors[x], + radioClass: 'iradio_flat' + colors[x], + }); + + + $('input.skin-line' + colors[x]).each(function() { + var self = $(this), + label = self.next(), + label_text = label.text(); + + label.remove(); + self.iCheck({ + checkboxClass: 'icheckbox_line' + colors[x], + radioClass: 'iradio_line' + colors[x], + insert: '
    ' + label_text + }); + }); + + } // end for loop + + + } + }; + + + + + /*-------------------------------- + Form Editors + --------------------------------*/ + ULTRA_SETTINGS.formEditors = function() { + + if ($.isFunction($.fn.wysihtml5)) { + $('.bootstrap-wysihtml5-textarea').wysihtml5({ + toolbar: { + "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true + "emphasis": true, //Italics, bold, etc. Default true + "lists": true, //(Un)ordered lists, e.g. Bullets, Numbers. Default true + "html": true, //Button which allows you to edit the generated HTML. Default false + "link": true, //Button to insert a link. Default true + "image": true, //Button to insert an image. Default true, + "color": true, //Button to change color of font + "blockquote": true, //Blockquote + "size": "none" //default: none, other options are xs, sm, lg + } + }); + + + $('.mail-compose-editor').wysihtml5({ + toolbar: { + "font-styles": true, //Font styling, e.g. h1, h2, etc. Default true + "emphasis": true, //Italics, bold, etc. Default true + "lists": false, //(Un)ordered lists, e.g. Bullets, Numbers. Default true + "html": true, //Button which allows you to edit the generated HTML. Default false + "link": true, //Button to insert a link. Default true + "image": true, //Button to insert an image. Default true, + "color": true, //Button to change color of font + "blockquote": false, //Blockquote + "size": "none" //default: none, other options are xs, sm, lg + } + }); + + } + + if ($.isFunction($.fn.CKEDITOR)) { + // This code is generally not necessary, but it is here to demonstrate + // how to customize specific editor instances on the fly. This fits well + // this demo because we have editable elements (like headers) that + // require less features. + + // The "instanceCreated" event is fired for every editor instance created. + CKEDITOR.on('instanceCreated', function(event) { + var editor = event.editor, + element = editor.element; + + // Customize editors for headers and tag list. + // These editors don't need features like smileys, templates, iframes etc. + if (element.is('h1', 'h2', 'h3') || element.getAttribute('id') == 'taglist') { + // Customize the editor configurations on "configLoaded" event, + // which is fired after the configuration file loading and + // execution. This makes it possible to change the + // configurations before the editor initialization takes place. + editor.on('configLoaded', function() { + + // Remove unnecessary plugins to make the editor simpler. + editor.config.removePlugins = 'colorbutton,find,flash,font,' + + 'forms,iframe,image,newpage,removeformat,' + + 'smiley,specialchar,stylescombo,templates'; + + // Rearrange the layout of the toolbar. + editor.config.toolbarGroups = [{ + name: 'editing', + groups: ['basicstyles', 'links'] + }, { + name: 'undo' + }, { + name: 'clipboard', + groups: ['selection', 'clipboard'] + }, { + name: 'about' + }]; + }); + } + }); + } + }; + + + /*-------------------------------- + Custom Dropzone + --------------------------------*/ + ULTRA_SETTINGS.customDropZone = function() { + + + + if ($.isFunction($.fn.dropzone)) { + + var i = 1, + $custom_droplist = $("#custom-droptable"), + example_dropzone = $("#customDZ").dropzone({ + url: 'data/media-file.php', + + // Events + addedfile: function(file) { + if (i == 1) { + $custom_droplist.find('tbody').html(''); + } + + var size = parseInt(file.size / 1024, 10); + size = size < 1024 ? (size + " KB") : (parseInt(size / 1024, 10) + " MB"); + + var $el = $('\ + ' + (i++) + '\ + ' + file.name + '\ +
    \ + ' + size + '\ + '); + + $custom_droplist.find('tbody').append($el); + file.fileEntryTd = $el; + file.progressBar = $el.find('.progress-bar'); + }, + + uploadprogress: function(file, progress, bytesSent) { + file.progressBar.width(progress + '%'); + $('.custom-dropzone .drop-table').perfectScrollbar({ + suppressScrollX: true + }); + }, + + success: function(file) { + file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-success'); + }, + + error: function(file) { + file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-red'); + } + }); + + } + + }; + + + /*-------------------------------- + Other Form component Scripts + --------------------------------*/ + ULTRA_SETTINGS.otherScripts = function() { + + + + /*--------------------------------*/ + + + if ($.isFunction($.fn.autosize)) { + $(".autogrow").autosize(); + } + + /*--------------------------------*/ + + + + + // Input Mask + if ($.isFunction($.fn.inputmask)) { + $("[data-mask]").each(function(i, el) { + var $this = $(el), + mask = $this.data('mask').toString(), + opts = { + numericInput: getValue($this, 'numeric', false), + radixPoint: getValue($this, 'radixPoint', ''), + rightAlign: getValue($this, 'numericAlign', 'left') == 'right' + }, + placeholder = getValue($this, 'placeholder', ''), + is_regex = getValue($this, 'isRegex', ''); + + if (placeholder.length) { + opts[placeholder] = placeholder; + } + + + if (mask.toLowerCase() == "phone") { + mask = "(999) 999-9999"; + } + + if (mask.toLowerCase() == "email") { + mask = 'Regex'; + opts.regex = "[a-zA-Z0-9._%-]+@[a-zA-Z0-9-]+\\.[a-zA-Z]{2,4}"; + } + + if (mask.toLowerCase() == "fdecimal") { + mask = 'decimal'; + $.extend(opts, { + autoGroup: true, + groupSize: 3, + radixPoint: getValue($this, 'rad', '.'), + groupSeparator: getValue($this, 'dec', ',') + }); + } + + + if (mask.toLowerCase() == "currency" || mask.toLowerCase() == "rcurrency") { + + var sign = getValue($this, 'sign', '$');; + + mask = "999,999,999.99"; + if (mask.toLowerCase() == 'rcurrency') { + mask += ' ' + sign; + } else { + mask = sign + ' ' + mask; + } + + opts.numericInput = true; + opts.rightAlignNumerics = false; + opts.radixPoint = '.'; + + } + + if (is_regex) { + opts.regex = mask; + mask = 'Regex'; + } + + $this.inputmask(mask, opts); + }); + } + + + /*---------------------------------*/ + + // autoNumeric + if ($.isFunction($.fn.autoNumeric)) { + $('.autoNumeric').autoNumeric('init'); + } + + /*---------------------------------*/ + + // Slider + if ($.isFunction($.fn.slider)) { + $(".slider").each(function(i, el) { + var $this = $(el), + $label_1 = $(''), + $label_2 = $label_1.clone(), + + orientation = getValue($this, 'vertical', 0) != 0 ? 'vertical' : 'horizontal', + + prefix = getValue($this, 'prefix', ''), + postfix = getValue($this, 'postfix', ''), + + fill = getValue($this, 'fill', ''), + $fill = $(fill), + + step = getValue($this, 'step', 1), + value = getValue($this, 'value', 5), + min = getValue($this, 'min', 0), + max = getValue($this, 'max', 100), + min_val = getValue($this, 'min-val', 10), + max_val = getValue($this, 'max-val', 90), + + is_range = $this.is('[data-min-val]') || $this.is('[data-max-val]'), + + reps = 0; + + + // Range Slider Options + if (is_range) { + $this.slider({ + range: true, + orientation: orientation, + min: min, + max: max, + values: [min_val, max_val], + step: step, + slide: function(e, ui) { + var min_val = (prefix ? prefix : '') + ui.values[0] + (postfix ? postfix : ''), + max_val = (prefix ? prefix : '') + ui.values[1] + (postfix ? postfix : ''); + + $label_1.html(min_val); + $label_2.html(max_val); + + if (fill) + $fill.val(min_val + ',' + max_val); + + reps++; + }, + change: function(ev, ui) { + if (reps == 1) { + var min_val = (prefix ? prefix : '') + ui.values[0] + (postfix ? postfix : ''), + max_val = (prefix ? prefix : '') + ui.values[1] + (postfix ? postfix : ''); + + $label_1.html(min_val); + $label_2.html(max_val); + + if (fill) + $fill.val(min_val + ',' + max_val); + } + + reps = 0; + } + }); + + var $handles = $this.find('.ui-slider-handle'); + + $label_1.html((prefix ? prefix : '') + min_val + (postfix ? postfix : '')); + $handles.first().append($label_1); + + $label_2.html((prefix ? prefix : '') + max_val + (postfix ? postfix : '')); + $handles.last().append($label_2); + } + // Normal Slider + else { + + $this.slider({ + range: getValue($this, 'basic', 0) ? false : "min", + orientation: orientation, + min: min, + max: max, + value: value, + step: step, + slide: function(ev, ui) { + var val = (prefix ? prefix : '') + ui.value + (postfix ? postfix : ''); + + $label_1.html(val); + + + if (fill) + $fill.val(val); + + reps++; + }, + change: function(ev, ui) { + if (reps == 1) { + var val = (prefix ? prefix : '') + ui.value + (postfix ? postfix : ''); + + $label_1.html(val); + + if (fill) + $fill.val(val); + } + + reps = 0; + } + }); + + var $handles = $this.find('.ui-slider-handle'); + //$fill = $('
    '); + + $label_1.html((prefix ? prefix : '') + value + (postfix ? postfix : '')); + $handles.html($label_1); + + //$handles.parent().prepend( $fill ); + + //$fill.width($handles.get(0).style.left); + } + + }) + } + + + + /*------------- Color Slider widget---------------*/ + + function hexFromRGB(r, g, b) { + var hex = [ + r.toString(16), + g.toString(16), + b.toString(16) + ]; + $.each(hex, function(nr, val) { + if (val.length === 1) { + hex[nr] = "0" + val; + } + }); + return hex.join("").toUpperCase(); + } + + function refreshSwatch() { + var red = $("#slider-red").slider("value"), + green = $("#slider-green").slider("value"), + blue = $("#slider-blue").slider("value"), + hex = hexFromRGB(red, green, blue); + $("#slider-swatch").css("background-color", "#" + hex); + } + + + if ($.isFunction($.fn.slider)) { + + $(function() { + $("#slider-red, #slider-green, #slider-blue").slider({ + orientation: "horizontal", + range: "min", + max: 255, + value: 127, + slide: refreshSwatch, + change: refreshSwatch + }); + $("#slider-red").slider("value", 235); + $("#slider-green").slider("value", 70); + $("#slider-blue").slider("value", 60); + }); + } + + + + /*-------------------------------------*/ + + /*--------------------------------*/ + + + // Spinner + if ($.isFunction($.fn.spinner)) { + + $( "#spinner" ).spinner(); + + $( "#spinner2" ).spinner({ + min: 5, + max: 2500, + step: 25, + start: 1000, + numberFormat: "C" + }); + + + $( "#spinner3" ).spinner({ + spin: function( event, ui ) { + if ( ui.value > 10 ) { + $( this ).spinner( "value", -10 ); + return false; + } else if ( ui.value < -10 ) { + $( this ).spinner( "value", 10 ); + return false; + } + } + }); +} + /*------------------------------------*/ + + // tagsinput + if ($.isFunction($.fn.tagsinput)) { + + // categorize tags input + var i = -1, + colors = ['primary', 'info', 'warning', 'success']; + + colors = shuffleArray(colors); + + $("#tagsinput-2").tagsinput({ + tagClass: function() { + i++; + return "label label-" + colors[i % colors.length]; + } + }); + + + $(".mail_compose_to").tagsinput({ + tagClass: function() { + i++; + return "label label-" + colors[i % colors.length]; + } + }); + + + } + + // Just for demo purpose + function shuffleArray(array) { + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Math.random() * (i + 1)); + var temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + return array; + } + + /*----------------------------*/ + + + // datepicker + if ($.isFunction($.fn.datepicker)) { + $(".datepicker").each(function(i, e) { + var $this = $(e), + options = { + minViewMode: getValue($this, 'minViewMode', 0), + format: getValue($this, 'format', 'mm/dd/yyyy'), + startDate: getValue($this, 'startDate', ''), + endDate: getValue($this, 'endDate', ''), + daysOfWeekDisabled: getValue($this, 'disabledDays', ''), + startView: getValue($this, 'startView', 0) + }, + $nxt = $this.next(), + $prv = $this.prev(); + + + $this.datepicker(options); + + if ($nxt.is('.input-group-addon') && $nxt.has('a')) { + $nxt.on('click', function(ev) { + ev.preventDefault(); + $this.datepicker('show'); + }); + } + + if ($prv.is('.input-group-addon') && $prv.has('a')) { + $prv.on('click', function(ev) { + ev.preventDefault(); + + $this.datepicker('show'); + }); + } + }); + } + + + + /*-------------------------------------------*/ + + + + // Date Range Picker + if ($.isFunction($.fn.daterangepicker)) { + $(".daterange").each(function(i, e) { + // Change the range as you desire + var ranges = { + 'Today': [moment(), moment()], + 'Yesterday': [moment().subtract('days', 1), moment().subtract('days', 1)], + 'Last 7 Days': [moment().subtract('days', 6), moment()], + 'Last 30 Days': [moment().subtract('days', 29), moment()], + 'This Month': [moment().startOf('month'), moment().endOf('month')], + 'Last Month': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')] + }; + + var $this = $(e), + options = { + format: getValue($this, 'format', 'MM/DD/YYYY'), + timePicker: getValue($this, 'timePicker', false), + timePickerIncrement: getValue($this, 'timePickerIncrement', false), + separator: getValue($this, 'separator', ' - '), + }, + min_date = getValue($this, 'minDate', ''), + max_date = getValue($this, 'maxDate', ''), + start_date = getValue($this, 'startDate', ''), + end_date = getValue($this, 'endDate', ''); + + if ($this.hasClass('add-date-ranges')) { + options['ranges'] = ranges; + } + + if (min_date.length) { + options['minDate'] = min_date; + } + + if (max_date.length) { + options['maxDate'] = max_date; + } + + if (start_date.length) { + options['startDate'] = start_date; + } + + if (end_date.length) { + options['endDate'] = end_date; + } + + + $this.daterangepicker(options, function(start, end) { + var drp = $this.data('daterangepicker'); + + if ($this.hasClass('daterange-text')) { + $this.find('span').html(start.format(drp.format) + drp.separator + end.format(drp.format)); + } + }); + + if (typeof options['ranges'] == 'object') { + $this.data('daterangepicker').container.removeClass('show-calendar'); + } + }); + } + + + + + /*-------------------------------------*/ + + + // Timepicker + if ($.isFunction($.fn.timepicker)) { + $(".timepicker").each(function(i, e) { + var $this = $(e), + options = { + template: getValue($this, 'template', false), + showSeconds: getValue($this, 'showSeconds', false), + defaultTime: getValue($this, 'defaultTime', 'current'), + showMeridian: getValue($this, 'showMeridian', true), + minuteStep: getValue($this, 'minuteStep', 15), + secondStep: getValue($this, 'secondStep', 15) + }, + $nxt = $this.next(), + $prv = $this.prev(); + + $this.timepicker(options); + + if ($nxt.is('.input-group-addon') && $nxt.has('a')) { + $nxt.on('click', function(ev) { + ev.preventDefault(); + + $this.timepicker('showWidget'); + }); + } + + if ($prv.is('.input-group-addon') && $prv.has('a')) { + $prv.on('click', function(ev) { + ev.preventDefault(); + + $this.timepicker('showWidget'); + }); + } + }); + } + + + + /*-------------------------------------*/ + + + // DateTimepicker + if ($.isFunction($.fn.datetimepicker)) { + + $('.form_datetime').datetimepicker({ + //language: 'fr', + format: "yyyy-mm-dd hh:ii", + weekStart: 1, + todayBtn: 1, + autoclose: 1, + todayHighlight: 1, + startView: 2, + forceParse: 0, + showMeridian: 0 + }); + + + $('.form_datetime_meridian').datetimepicker({ + //language: 'fr', + format: "dd MM yyyy - hh:ii", + weekStart: 1, + todayBtn: 1, + autoclose: 1, + todayHighlight: 1, + startView: 2, + forceParse: 0, + showMeridian: 1 + }); + + + $('.form_datetime_lang').datetimepicker({ + language: 'fr', + format: "yyyy-mm-dd hh:ii", + weekStart: 1, + todayBtn: 1, + autoclose: 1, + todayHighlight: 1, + startView: 2, + forceParse: 0, + showMeridian: 0 + }); + + + /* $('.form_date').datetimepicker({ + weekStart: 1, + todayBtn: 1, + autoclose: 1, + todayHighlight: 1, + startView: 2, + minView: 2, + forceParse: 0 + }); + $('.form_time').datetimepicker({ + //language: 'fr', + weekStart: 1, + todayBtn: 1, + autoclose: 1, + todayHighlight: 1, + startView: 1, + minView: 0, + maxView: 1, + forceParse: 0 + });*/ + + } + + /*-------------------------------------*/ + + + + + + // Colorpicker + if ($.isFunction($.fn.colorpicker)) { + $(".colorpicker").each(function(i, e) { + var $this = $(e), + options = {}, + $nxt = $this.next(), + $prv = $this.prev(), + $view = $this.siblings('.input-group-addon').find('.sel-color'); + + $this.colorpicker(options); + + if ($nxt.is('.input-group-addon') && $nxt.has('a')) { + $nxt.on('click', function(ev) { + ev.preventDefault(); + + $this.colorpicker('show'); + }); + } + + if ($prv.is('.input-group-addon') && $prv.has('a')) { + $prv.on('click', function(ev) { + ev.preventDefault(); + + $this.colorpicker('show'); + }); + } + + if ($view.length) { + $this.on('changeColor', function(ev) { + + $view.css('background-color', ev.color.toHex()); + }); + + if ($this.val().length) { + $view.css('background-color', $this.val()); + } + } + }); + } + + + /*--------------------------------------*/ + + + // select2 + if ($.isFunction($.fn.select2)) { + + $("#s2example-1").select2({ + placeholder: 'Select your country...', + allowClear: true + }).on('select2-open', function() { + // Adding Custom Scrollbar + $(this).data('select2').results.addClass('overflow-hidden').perfectScrollbar(); + }); + + + $("#s2example-2").select2({ + placeholder: 'Choose your favorite US Countries', + allowClear: true + }).on('select2-open', function() { + // Adding Custom Scrollbar + $(this).data('select2').results.addClass('overflow-hidden').perfectScrollbar(); + }); + + + $("#s2example-4").select2({ + minimumInputLength: 1, + placeholder: 'Search', + ajax: { + url: "data/select2-remote-data.php", + dataType: 'json', + quietMillis: 100, + data: function(term, page) { + return { + limit: -1, + q: term + }; + }, + results: function(data, page) { + return { + results: data + } + } + }, + formatResult: function(student) { + return "
    " + student.name + "
    "; + }, + formatSelection: function(student) { + return student.name; + } + + }); + } + /*------------------------------------*/ + + + + + //multiselect start + + if ($.isFunction($.fn.multiSelect)) { + + $('#my_multi_select1').multiSelect(); + $('#my_multi_select2').multiSelect({ + selectableOptgroup: true + }); + + $('#my_multi_select3').multiSelect({ + selectableHeader: "", + selectionHeader: "", + afterInit: function(ms) { + var that = this, + $selectableSearch = that.$selectableUl.prev(), + $selectionSearch = that.$selectionUl.prev(), + selectableSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selectable:not(.ms-selected)', + selectionSearchString = '#' + that.$container.attr('id') + ' .ms-elem-selection.ms-selected'; + + that.qs1 = $selectableSearch.quicksearch(selectableSearchString) + .on('keydown', function(e) { + if (e.which === 40) { + that.$selectableUl.focus(); + return false; + } + }); + + that.qs2 = $selectionSearch.quicksearch(selectionSearchString) + .on('keydown', function(e) { + if (e.which == 40) { + that.$selectionUl.focus(); + return false; + } + }); + }, + afterSelect: function() { + this.qs1.cache(); + this.qs2.cache(); + }, + afterDeselect: function() { + this.qs1.cache(); + this.qs2.cache(); + } + }); + + } + //multiselect end + + + + + + + + + + /*---------------------------------------*/ + + + if ($.isFunction($.fn.typeahead)) { + + // basic typeahead + + var substringMatcher = function(strs) { + return function findMatches(q, cb) { + var matches, substrRegex; + + // an array that will be populated with substring matches + matches = []; + + // regex used to determine if a string contains the substring `q` + substrRegex = new RegExp(q, 'i'); + + // iterate through the pool of strings and for any string that + // contains the substring `q`, add it to the `matches` array + $.each(strs, function(i, str) { + if (substrRegex.test(str)) { + // the typeahead jQuery plugin expects suggestions to a + // JavaScript object, refer to typeahead docs for more info + matches.push({ + value: str + }); + } + }); + + cb(matches); + }; + }; + + var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', + 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', + 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', + 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', + 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', + 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', + 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', + 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', + 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming' + ]; + + $('#typeahead-1').typeahead({ + hint: true, + highlight: true, + minLength: 1 + }, { + name: 'states', + displayKey: 'value', + source: substringMatcher(states) + }); + + + + // prefetch typeahead + + var names = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), + queryTokenizer: Bloodhound.tokenizers.whitespace, + limit: 10, + prefetch: { + url: 'data/names.json', + filter: function(list) { + return $.map(list, function(name) { + return { + name: name + }; + }); + } + } + }); + + names.initialize(); + + $('#typeahead-2').typeahead(null, { + name: 'names', + displayKey: 'name', + source: names.ttAdapter() + }); + + + // remote data + + + var name_randomizer = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'), + queryTokenizer: Bloodhound.tokenizers.whitespace, + // You can also prefetch suggestions + // prefetch: 'data/typeahead-generate.php', + remote: 'data/typeahead-generate.php?q=%QUERY' + }); + + name_randomizer.initialize(); + + $('#typeahead-3').typeahead({ + hint: true, + highlight: true + }, { + name: 'string-randomizer', + displayKey: 'value', + source: name_randomizer.ttAdapter() + }); + + + // templating + + var oscar_movies = new Bloodhound({ + datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), + queryTokenizer: Bloodhound.tokenizers.whitespace, + remote: 'data/typeahead-hp-movies.php?q=%QUERY' + }); + + oscar_movies.initialize(); + + $('#typeahead-4').typeahead(null, { + name: 'oscar-movies', + displayKey: 'value', + source: oscar_movies.ttAdapter(), + templates: { + empty: [ + '
    ', + 'We cannot find this movie title', + '
    ' + ].join('\n'), + suggestion: Handlebars.compile('
    {{value}} — {{year}}
    ') + } + }) + .bind('typeahead:opened', function() { + $(this).data('ttTypeahead').dropdown.$menu.addClass('overflow-hidden').perfectScrollbar(); + }) + .on('keyup', function() { + $(this).data('ttTypeahead').dropdown.$menu.perfectScrollbar('update'); + }); + + } + /*------------------------------------*/ + + + + /*------------------------------------------*/ + + }; + + + + /*-------------------------------- + Widgets + --------------------------------*/ + ULTRA_SETTINGS.ultraWidgets = function() { + + /*notification widget*/ + var notif_widget = $(".notification-widget").height(); + $('.notification-widget').height(notif_widget).perfectScrollbar({ + suppressScrollX: true + }); + + }; + + + + /*-------------------------------- + weather widget + --------------------------------*/ + ULTRA_SETTINGS.ultraWidgetWeather = function() { + + /*notification widget*/ + /*var wid = $(".wid-weather"); + var notif_widget = $(".notification-widget").height(); + $('.notification-widget').height(notif_widget).perfectScrollbar({suppressScrollX: true}); + + $('.wid-weather').each( function () { + var days = $(this).find(".weekdays"); + var today = $(this).find(".today"); + + var height = days.height(); + if(days.height() < today.height()){ + height = today.height(); + } + + days.height(height); + today.height(height); + });*/ + + + $('.wid-weather .weekdays ul').perfectScrollbar({ + suppressScrollX: true + }); + + + }; + + + + + + /*-------------------------------- + To Do Task Widget + --------------------------------*/ + ULTRA_SETTINGS.ultraToDoWidget = function() { + + /*todo task widget*/ + $(".icheck-minimal-white.todo-task").on('ifChecked', function(event) { + $(this).parent().parent().addClass("checked"); + }); + $(".icheck-minimal-white.todo-task").on('ifUnchecked', function(event) { + $(this).parent().parent().removeClass("checked"); + }); + + $(".wid-all-tasks ul").perfectScrollbar({ + suppressScrollX: true + }); + + }; + + + + /*-------------------------------- + To Do Add Task Widget + --------------------------------*/ + ULTRA_SETTINGS.ultraToDoAddTaskWidget = function() { + + $(".wid-add-task input").on('keypress', function(e) { + if (e.keyCode == 13) { + var i = Math.random().toString(36).substring(7); + var msg = $(this).val(); + var msg = '
  • '; + $(this).parent().parent().find(".wid-all-tasks ul").append(msg); + $(this).val(""); + $(this).focus(); + ULTRA_SETTINGS.iCheck(); + ULTRA_SETTINGS.ultraToDoWidget(); + $(this).parent().parent().find(".wid-all-tasks ul").perfectScrollbar('update'); + } + }); + + }; + + + + + + + + /*-------------------------------- + Vector maps + --------------------------------*/ + ULTRA_SETTINGS.dbjvectorMap = function() { + + if ($.isFunction($.fn.vectorMap)) { + //@code_start + $(function() { + $('#db-world-map-markers').vectorMap({ + map: 'world_mill_en', + scaleColors: ['#1fb5ac', '#1fb5ac'], + normalizeFunction: 'polynomial', + hoverOpacity: 0.7, + hoverColor: false, + regionsSelectable: true, + markersSelectable: true, + markersSelectableOne: true, + updateSize: true, + onRegionOver: function(event, code) { + //console.log('region-over', code); + }, + onRegionOut: function(event, code) { + //console.log('region-out', code); + }, + onRegionClick: function(event, code) { + //console.log('region-click', code); + }, + onRegionSelected: function(event, code, isSelected, selectedRegions) { + //console.log('region-select', code, isSelected, selectedRegions); + if (window.localStorage) { + window.localStorage.setItem( + 'jvectormap-selected-regions', + JSON.stringify(selectedRegions) + ); + } + }, + + panOnDrag: true, + + focusOn: { + x: 0.5, + y: 0.5, + scale: 1.2, + animate: true + }, + + + regionStyle: { + initial: { + fill: '#aaaaaa', + 'fill-opacity': 1, + stroke: 'false', + 'stroke-width': 0, + 'stroke-opacity': 1 + }, + hover: { + fill: '#1fb5ac', + 'fill-opacity': 1, + cursor: 'pointer' + }, + selected: { + fill: '#1fb5ac' + }, + selectedHover: {} + }, + + + + markerStyle: { + initial: { + fill: '#fa8564', + stroke: '#ffffff', + r: 5 + }, + hover: { + stroke: '#FDB45C', + "stroke-width": 2, + cursor: 'pointer' + }, + selected: { + fill: '#FDB45C', + "stroke-width": 0, + }, + }, + backgroundColor: '#ffffff', + markers: [{ + latLng: [41.90, 12.45], + name: 'Vatican City' + }, { + latLng: [43.73, 7.41], + name: 'Monaco' + }, { + latLng: [-0.52, 166.93], + name: 'Nauru' + }, { + latLng: [-8.51, 179.21], + name: 'Tuvalu' + }, { + latLng: [43.93, 12.46], + name: 'San Marino' + }, { + latLng: [47.14, 9.52], + name: 'Liechtenstein' + }, { + latLng: [7.11, 171.06], + name: 'Marshall Islands' + }, { + latLng: [17.3, -62.73], + name: 'Saint Kitts and Nevis' + }, { + latLng: [3.2, 73.22], + name: 'Maldives' + }, { + latLng: [35.88, 14.5], + name: 'Malta' + }, { + latLng: [12.05, -61.75], + name: 'Grenada' + }, { + latLng: [13.16, -61.23], + name: 'Saint Vincent and the Grenadines' + }, { + latLng: [13.16, -59.55], + name: 'Barbados' + }, { + latLng: [17.11, -61.85], + name: 'Antigua and Barbuda' + }, { + latLng: [-4.61, 55.45], + name: 'Seychelles' + }, { + latLng: [7.35, 134.46], + name: 'Palau' + }, { + latLng: [42.5, 1.51], + name: 'Andorra' + }, { + latLng: [14.01, -60.98], + name: 'Saint Lucia' + }, { + latLng: [6.91, 158.18], + name: 'Federated States of Micronesia' + }, { + latLng: [1.3, 103.8], + name: 'Singapore' + }, { + latLng: [1.46, 173.03], + name: 'Kiribati' + }, { + latLng: [-21.13, -175.2], + name: 'Tonga' + }, { + latLng: [15.3, -61.38], + name: 'Dominica' + }, { + latLng: [-20.2, 57.5], + name: 'Mauritius' + }, { + latLng: [26.02, 50.55], + name: 'Bahrain' + }, { + latLng: [0.33, 6.73], + name: 'São Tomé and Príncipe' + }] + }); + }); + //@code_end + } + + }; + + + + + /*-------------------------------- + Sparkline Chart - Widgets + --------------------------------*/ + ULTRA_SETTINGS.widgetSparklineChart = function() { + + if ($.isFunction($.fn.sparkline)) { + + $('.wid_dynamicbar').sparkline([8.4, 9, 8.8, 8, 9.5, 9.2, 9.9, 9, 9, 8, 7, 8, 9, 8, 7, 9, 9, 9.5, 8, 9.5, 9.8], { + type: 'bar', + barColor: '#f5f5f5', + height: '60', + barWidth: '12', + barSpacing: 1, + }); + + $('.wid_linesparkline').sparkline([2000, 3454, 5454, 2323, 3432, 4656, 2897, 3545, 4232, 4656, 2897, 3545, 4232, 5434, 4656, 3567, 4878, 3676, 3787], { + type: 'line', + width: '100%', + height: '60', + lineWidth: 2, + lineColor: '#f5f5f5', + fillColor: 'rgba(255,255,255,0.2)', + highlightSpotColor: '#ffffff', + highlightLineColor: '#ffffff', + spotRadius: 3, + }); + + + // Bar + line composite charts + $('.wid_compositebar').sparkline([4, 6, 7, 7, 4, 3, 2, 4, 6, 7, 7, 8, 8, 4, 4, 3, 1, 4, 6, 5, 9], { + type: 'bar', + barColor: '#f5f5f5', + height: '60', + barWidth: '12', + barSpacing: 1, + }); + + $('.wid_compositebar').sparkline([4, 1, 5, 7, 9, 9, 8, 8, 4, 7, 8, 4, 7, 9, 9, 8, 8, 4, 2, 5, 6, 7], { + composite: true, + fillColor: 'rgba(153,114,181,0)', + type: 'line', + width: '100%', + height: '40', + lineWidth: 2, + lineColor: '#9972b5', + highlightSpotColor: '#fa8564', + highlightLineColor: '#9972b5', + spotRadius: 3, + }); + + + + } + + }; + + + + + + + + + // Element Attribute Helper + function getValue($el, data_var, default_val) { + if (typeof $el.data(data_var) != 'undefined') { + return $el.data(data_var); + } + + return default_val; + } + + + /****************************** + initialize respective scripts + *****************************/ + $(document).ready(function() { + ULTRA_SETTINGS.windowBasedLayout(); + ULTRA_SETTINGS.mainmenuScroll(); + ULTRA_SETTINGS.mainMenu(); + ULTRA_SETTINGS.mainmenuCollapsed(); + ULTRA_SETTINGS.pageTopBar(); + ULTRA_SETTINGS.otherScripts(); + ULTRA_SETTINGS.iCheck(); + ULTRA_SETTINGS.customDropZone(); + ULTRA_SETTINGS.formEditors(); + ULTRA_SETTINGS.extraFormSettings(); + ULTRA_SETTINGS.tooltipsPopovers(); + ULTRA_SETTINGS.nestableList(); + ULTRA_SETTINGS.uiCalendar(); + ULTRA_SETTINGS.tocifyScrollMenu(); + ULTRA_SETTINGS.loadPrettyPhoto(); + ULTRA_SETTINGS.jvectorMaps(); + ULTRA_SETTINGS.dataTablesInit(); + ULTRA_SETTINGS.jsTreeINIT(); + ULTRA_SETTINGS.breadcrumbAutoHidden(); + ULTRA_SETTINGS.chatAPI(); + ULTRA_SETTINGS.chatApiScroll(); + ULTRA_SETTINGS.chatApiWindow(); + ULTRA_SETTINGS.mailboxInbox(); + ULTRA_SETTINGS.ultraWidgets(); + ULTRA_SETTINGS.sectionBoxActions(); + ULTRA_SETTINGS.draggablePanels(); + ULTRA_SETTINGS.viewportElement(); + ULTRA_SETTINGS.searchPage(); + ULTRA_SETTINGS.ultraToDoAddTaskWidget(); + ULTRA_SETTINGS.ultraToDoWidget(); + ULTRA_SETTINGS.dbjvectorMap(); + ULTRA_SETTINGS.widgetSparklineChart(); + ULTRA_SETTINGS.ultraWidgetWeather(); + }); + + $(window).resize(function() { + ULTRA_SETTINGS.windowBasedLayout(); + //ULTRA_SETTINGS.mainmenuScroll(); + //ULTRA_SETTINGS.ultraWidgetWeather(); + ULTRA_SETTINGS.isotopeGallery(); + ULTRA_SETTINGS.loginPage(); + ULTRA_SETTINGS.widgetSparklineChart(); + }); + + $(window).load(function() { + ULTRA_SETTINGS.isotopeGallery(); + ULTRA_SETTINGS.loginPage(); + }); + +}); diff --git a/static/media/cover/20181201110659913.PNG b/static/media/cover/20181201110659913.PNG new file mode 100644 index 0000000..7c28870 Binary files /dev/null and b/static/media/cover/20181201110659913.PNG differ diff --git a/static/media/cover/20181201110659913_85e25PV.PNG b/static/media/cover/20181201110659913_85e25PV.PNG new file mode 100644 index 0000000..7c28870 Binary files /dev/null and b/static/media/cover/20181201110659913_85e25PV.PNG differ diff --git a/static/media/cover/20181201110659913_ie84dq3.PNG b/static/media/cover/20181201110659913_ie84dq3.PNG new file mode 100644 index 0000000..7c28870 Binary files /dev/null and b/static/media/cover/20181201110659913_ie84dq3.PNG differ diff --git a/static/media/cover/weibo.png b/static/media/cover/weibo.png new file mode 100644 index 0000000..e09ce60 Binary files /dev/null and b/static/media/cover/weibo.png differ diff --git a/static/media/cover/weixin.png b/static/media/cover/weixin.png new file mode 100644 index 0000000..a053b34 Binary files /dev/null and b/static/media/cover/weixin.png differ diff --git a/static/media/cover/weixin_T3Y4A36.png b/static/media/cover/weixin_T3Y4A36.png new file mode 100644 index 0000000..a053b34 Binary files /dev/null and b/static/media/cover/weixin_T3Y4A36.png differ diff --git a/static/media/cover/weixin_TC0D6fQ.png b/static/media/cover/weixin_TC0D6fQ.png new file mode 100644 index 0000000..a053b34 Binary files /dev/null and b/static/media/cover/weixin_TC0D6fQ.png differ diff --git a/static/media/cover/微信图片_20200724112643.jpg b/static/media/cover/微信图片_20200724112643.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/static/media/cover/微信图片_20200724112643.jpg differ diff --git a/static/media/cover/微信图片_20200724112643_deab8x0.jpg b/static/media/cover/微信图片_20200724112643_deab8x0.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/static/media/cover/微信图片_20200724112643_deab8x0.jpg differ diff --git a/static/media/groupimage/20181201110659913.PNG b/static/media/groupimage/20181201110659913.PNG new file mode 100644 index 0000000..7c28870 Binary files /dev/null and b/static/media/groupimage/20181201110659913.PNG differ diff --git a/static/media/groupimage/微信图片_20200724112643.jpg b/static/media/groupimage/微信图片_20200724112643.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/static/media/groupimage/微信图片_20200724112643.jpg differ diff --git a/static/media/profile/20181201110659913.PNG b/static/media/profile/20181201110659913.PNG new file mode 100644 index 0000000..7c28870 Binary files /dev/null and b/static/media/profile/20181201110659913.PNG differ diff --git a/static/media/profile/微信图片_20200724112643.jpg b/static/media/profile/微信图片_20200724112643.jpg new file mode 100644 index 0000000..00f7364 Binary files /dev/null and b/static/media/profile/微信图片_20200724112643.jpg differ diff --git a/static/media/qita.png b/static/media/qita.png new file mode 100644 index 0000000..2322471 Binary files /dev/null and b/static/media/qita.png differ diff --git a/static/media/toutiao.png b/static/media/toutiao.png new file mode 100644 index 0000000..d78afc3 Binary files /dev/null and b/static/media/toutiao.png differ diff --git a/static/media/weibo.png b/static/media/weibo.png new file mode 100644 index 0000000..e09ce60 Binary files /dev/null and b/static/media/weibo.png differ diff --git a/static/media/weixin.png b/static/media/weixin.png new file mode 100644 index 0000000..a053b34 Binary files /dev/null and b/static/media/weixin.png differ