لتطوير احلى منتدى الاشعارات الصوتية مع امكانية التعطيل من قبل العضو

يسرنا اسرة مدونة مايكل ان نقدم لكم تحويل الكود الرائع الاشعارات الصوتية مع توافر امكانية ايقافها من قبل كل مستخدم على حده
يتكون الكود من جزئين
جزىء جافا سكربت والجزىء الاخر تومبلات
انتبه انه قد لا يعمل بشكل جدي اذا كان لديك تعديلات كثيرة فى التومبلات
والان لشكل الكود من اجل المعاينة
هذا يكون شكلة اثناء التعطيل






وهذا يكون شكلة اثناء التنشيط






والان مع الخطوة الاولى
ادارة المنتدى > عناصر اضافية > اكواد الجافا واضف الكود التالى
اسم العنصر الاشعارات
مكان الظور جميع الصفحات
المحتوى
alarm_color_on = "white";
alarm_color_off = "#806060";
alarm_title_on = "ايقاف الاشعارات";
alarm_title_off = "تفعيل الاشعارات";
update_timer = 1000;

function GetAlarm() {
var al = localStorage.getItem('alarm');
return al === "1";
};

alarm = false;

function SetAlarm(al) {
localStorage.setItem('alarm', al ? "1" : "0");
if (GetAlarm()) {
$('#alarm').text('notifications');
$('#alarm').css('color', alarm_color_on);
$('#alarm').attr('title', alarm_title_on);
DeskInstallNotify();
} else {
$('#alarm').text('notifications_off');
$('#alarm').css('color', alarm_color_off);
$('#alarm').attr('title', alarm_title_off);
}
alarm = al;
};

function SwitchAlarm() {
SetAlarm(!GetAlarm());
};

prevunread = -1;
_DeskSoundNotify = function() {
$.ajax({
url: '/notification.forum',
dataType: 'json',
success: function(data, txt, xhr) {
if (alarm) {
if (data.unread > prevunread) {
if (prevunread >= 0)
$('#sound').get(0).play();
prevunread = data.unread
}
}
}
}).always(function() {
setTimeout(_DeskSoundNotify, update_timer)
});
};

function DeskInstallNotify() {
setTimeout(_DeskSoundNotify, update_timer * 2);
};


$(function() {
$(function() {
if ($('#mNotificationBtn').length == 0 && _userdata["session_logged_in"] > 0) {
alarm = GetAlarm();
$('<span id="notify_alarm" onclick="SwitchAlarm();" style="font-size: 20px; cursor: pointer;" ><i title="' + (alarm ? alarm_title_on : alarm_title_off) + '"class="material-icons" style="font-size: 18px; position: relative; top: 5px; color:' + (alarm ? alarm_color_on : alarm_color_off) + '" id="alarm">' + (alarm ? 'notifications' : 'notifications_off') + '</i></span>') .insertBefore($('#fa_hide'));
if (alarm) DeskInstallNotify();
};
});
});

 ثم الذهاب الى قالب 
ovarl_header
واضافة الكود التالى بعد التعديل واضافة رابط ملف الصوت المباشر بصيغة
 MP3
يتم اضافة الكود باى مكان داخل القالب لكن يفضل ان يكون اسفل كلمة <head>

          <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
          <audio id="sound">        <source src="ملف الصوت"/>      </audio>

وتلك نماذج يمكنك استخدامها
  1. https://s1.vocaroo.com/media/download_temp/Vocaroo_s12lFH1cG3Km.mp3
  2. http://illiweb.com/fa/fdf/future.mp3 
  3. http://illiweb.com/fa/fdf/hal.mp3
  4. http://illiweb.com/fa/fdf/secret.mp3
  5. http://illiweb.com/fa/fdf/zelda.mono.mp3
مع تحيات اسرة مايكل للتطوير
المصدر
https://help.forumotion.com/t157012-sound-notifications#1086421

Comments

Popular posts from this blog

The paintings from Minecraft were first real paintings.

30+ Hilariously Relatable Illustrations About The Struggles Of Raising A Baby

iTunes Flash is Available on 3uTools Now!